diff --git a/hazelcast/generated-sources/src/hazelcast/client/protocol/codec/codecs.cpp b/hazelcast/generated-sources/src/hazelcast/client/protocol/codec/codecs.cpp index a7c7debc5..d41778613 100644 --- a/hazelcast/generated-sources/src/hazelcast/client/protocol/codec/codecs.cpp +++ b/hazelcast/generated-sources/src/hazelcast/client/protocol/codec/codecs.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2023, Hazelcast, Inc. All Rights Reserved. + * Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ #include #include "hazelcast/client/member.h" -#include "hazelcast/client/serialization/pimpl/compact/schema.h" #include "hazelcast/logger.h" #include "codecs.h" @@ -34,11 +33,14 @@ client_authentication_encode(const std::string& cluster_name, byte serialization_version, const std::string& client_hazelcast_version, const std::string& client_name, - const std::vector& labels) + const std::vector& labels, + byte routing_mode, + bool cp_direct_to_leader_routing) { - size_t initial_frame_size = ClientMessage::REQUEST_HEADER_LEN + - ClientMessage::UUID_SIZE + - ClientMessage::UINT8_SIZE; + size_t initial_frame_size = + ClientMessage::REQUEST_HEADER_LEN + ClientMessage::UUID_SIZE + + ClientMessage::UINT8_SIZE + ClientMessage::UINT8_SIZE + + ClientMessage::UINT8_SIZE; ClientMessage msg(initial_frame_size); msg.set_retryable(true); msg.set_operation_name("client.authentication"); @@ -48,6 +50,8 @@ client_authentication_encode(const std::string& cluster_name, msg.set(uuid); msg.set(serialization_version); + msg.set(routing_mode); + msg.set(cp_direct_to_leader_routing); msg.set(cluster_name); msg.set_nullable(username); @@ -73,11 +77,14 @@ client_authenticationcustom_encode(const std::string& cluster_name, byte serialization_version, const std::string& client_hazelcast_version, const std::string& client_name, - const std::vector& labels) + const std::vector& labels, + byte routing_mode, + bool cp_direct_to_leader_routing) { - size_t initial_frame_size = ClientMessage::REQUEST_HEADER_LEN + - ClientMessage::UUID_SIZE + - ClientMessage::UINT8_SIZE; + size_t initial_frame_size = + ClientMessage::REQUEST_HEADER_LEN + ClientMessage::UUID_SIZE + + ClientMessage::UINT8_SIZE + ClientMessage::UINT8_SIZE + + ClientMessage::UINT8_SIZE; ClientMessage msg(initial_frame_size); msg.set_retryable(true); msg.set_operation_name("client.authenticationcustom"); @@ -87,6 +94,8 @@ client_authenticationcustom_encode(const std::string& cluster_name, msg.set(uuid); msg.set(serialization_version); + msg.set(routing_mode); + msg.set(cp_direct_to_leader_routing); msg.set(cluster_name); msg.set(credentials); @@ -150,9 +159,29 @@ client_addclusterviewlistener_handler::handle(ClientMessage& msg) handle_partitionsview(version, partitions); return; } + if (messageType == 772) { + auto* initial_frame = + reinterpret_cast( + msg.rd_ptr(ClientMessage::EVENT_HEADER_LEN)); + auto version = msg.get(); + msg.seek(static_cast(initial_frame->frame_len)); + + auto member_groups = + msg.get>>(); + + handle_membergroupsview(version, member_groups); + return; + } + if (messageType == 773) { + msg.rd_ptr(ClientMessage::EVENT_HEADER_LEN); + + auto version = msg.get(); + handle_clusterversion(version); + return; + } HZ_LOG( get_logger(), - warning, + finest, (boost::format("[client_addclusterviewlistener_handler::handle] Unknown " "message type (%1%) received on event handler.") % messageType) @@ -269,13 +298,62 @@ client_localbackuplistener_handler::handle(ClientMessage& msg) } HZ_LOG( get_logger(), - warning, + finest, (boost::format("[client_localbackuplistener_handler::handle] Unknown " "message type (%1%) received on event handler.") % messageType) .str()); } +ClientMessage +client_sendschema_encode(const serialization::pimpl::schema& schema) +{ + size_t initial_frame_size = ClientMessage::REQUEST_HEADER_LEN; + ClientMessage msg(initial_frame_size); + msg.set_retryable(true); + msg.set_operation_name("client.sendschema"); + + msg.set_message_type(static_cast(4864)); + msg.set_partition_id(-1); + + msg.set(schema, true); + + return msg; +} + +ClientMessage +client_fetchschema_encode(int64_t schema_id) +{ + size_t initial_frame_size = + ClientMessage::REQUEST_HEADER_LEN + ClientMessage::INT64_SIZE; + ClientMessage msg(initial_frame_size, true); + msg.set_retryable(true); + msg.set_operation_name("client.fetchschema"); + + msg.set_message_type(static_cast(5120)); + msg.set_partition_id(-1); + + msg.set(schema_id); + return msg; +} + +ClientMessage +client_sendallschemas_encode( + const std::vector& schemas) +{ + size_t initial_frame_size = ClientMessage::REQUEST_HEADER_LEN; + ClientMessage msg(initial_frame_size); + msg.set_retryable(true); + msg.set_operation_name("client.sendallschemas"); + + msg.set_message_type(static_cast(5376)); + msg.set_partition_id(-1); + + msg.set(schemas, true); + + return msg; +} + ClientMessage map_put_encode(const std::string& name, const serialization::pimpl::data& key, @@ -842,7 +920,7 @@ map_addentrylistenerwithpredicate_handler::handle(ClientMessage& msg) } HZ_LOG( get_logger(), - warning, + finest, (boost::format("[map_addentrylistenerwithpredicate_handler::handle] " "Unknown message type (%1%) received on event handler.") % messageType) @@ -908,7 +986,7 @@ map_addentrylistenertokey_handler::handle(ClientMessage& msg) return; } HZ_LOG(get_logger(), - warning, + finest, (boost::format("[map_addentrylistenertokey_handler::handle] Unknown " "message type (%1%) received on event handler.") % messageType) @@ -971,7 +1049,7 @@ map_addentrylistener_handler::handle(ClientMessage& msg) return; } HZ_LOG(get_logger(), - warning, + finest, (boost::format("[map_addentrylistener_handler::handle] Unknown " "message type (%1%) received on event handler.") % messageType) @@ -1546,7 +1624,7 @@ map_addnearcacheinvalidationlistener_handler::handle(ClientMessage& msg) } HZ_LOG( get_logger(), - warning, + finest, (boost::format("[map_addnearcacheinvalidationlistener_handler::handle] " "Unknown message type (%1%) received on event handler.") % messageType) @@ -1868,7 +1946,7 @@ multimap_addentrylistenertokey_handler::handle(ClientMessage& msg) } HZ_LOG( get_logger(), - warning, + finest, (boost::format("[multimap_addentrylistenertokey_handler::handle] Unknown " "message type (%1%) received on event handler.") % messageType) @@ -1929,7 +2007,7 @@ multimap_addentrylistener_handler::handle(ClientMessage& msg) return; } HZ_LOG(get_logger(), - warning, + finest, (boost::format("[multimap_addentrylistener_handler::handle] Unknown " "message type (%1%) received on event handler.") % messageType) @@ -2437,7 +2515,7 @@ queue_addlistener_handler::handle(ClientMessage& msg) return; } HZ_LOG(get_logger(), - warning, + finest, (boost::format("[queue_addlistener_handler::handle] Unknown message " "type (%1%) received on event handler.") % messageType) @@ -2554,7 +2632,7 @@ topic_addmessagelistener_handler::handle(ClientMessage& msg) return; } HZ_LOG(get_logger(), - warning, + finest, (boost::format("[topic_addmessagelistener_handler::handle] Unknown " "message type (%1%) received on event handler.") % messageType) @@ -2807,7 +2885,7 @@ list_addlistener_handler::handle(ClientMessage& msg) return; } HZ_LOG(get_logger(), - warning, + finest, (boost::format("[list_addlistener_handler::handle] Unknown message " "type (%1%) received on event handler.") % messageType) @@ -3236,7 +3314,7 @@ set_addlistener_handler::handle(ClientMessage& msg) return; } HZ_LOG(get_logger(), - warning, + finest, (boost::format("[set_addlistener_handler::handle] Unknown message " "type (%1%) received on event handler.") % messageType) @@ -4293,7 +4371,7 @@ replicatedmap_addentrylistenertokeywithpredicate_handler::handle( return; } HZ_LOG(get_logger(), - warning, + finest, (boost::format( "[replicatedmap_addentrylistenertokeywithpredicate_handler::" "handle] Unknown message type (%1%) received on event handler.") % @@ -4357,7 +4435,7 @@ replicatedmap_addentrylistenerwithpredicate_handler::handle(ClientMessage& msg) return; } HZ_LOG(get_logger(), - warning, + finest, (boost::format( "[replicatedmap_addentrylistenerwithpredicate_handler::handle] " "Unknown message type (%1%) received on event handler.") % @@ -4422,7 +4500,7 @@ replicatedmap_addentrylistenertokey_handler::handle(ClientMessage& msg) } HZ_LOG( get_logger(), - warning, + finest, (boost::format("[replicatedmap_addentrylistenertokey_handler::handle] " "Unknown message type (%1%) received on event handler.") % messageType) @@ -4481,7 +4559,7 @@ replicatedmap_addentrylistener_handler::handle(ClientMessage& msg) } HZ_LOG( get_logger(), - warning, + finest, (boost::format("[replicatedmap_addentrylistener_handler::handle] Unknown " "message type (%1%) received on event handler.") % messageType) @@ -4611,7 +4689,7 @@ replicatedmap_addnearcacheentrylistener_handler::handle(ClientMessage& msg) } HZ_LOG( get_logger(), - warning, + finest, (boost::format("[replicatedmap_addnearcacheentrylistener_handler::handle]" " Unknown message type (%1%) received on event handler.") % messageType) @@ -5873,7 +5951,7 @@ sql_execute_encode(const std::string& sql, msg.set(skip_update_statistics); msg.set(sql); - msg.set(parameters); + msg.set_contains_nullable(parameters); msg.set_nullable(schema); @@ -5901,55 +5979,6 @@ sql_fetch_encode(const sql::impl::query_id& query_id, return msg; } -ClientMessage -client_sendschema_encode(const serialization::pimpl::schema& schema) -{ - size_t initial_frame_size = ClientMessage::REQUEST_HEADER_LEN; - ClientMessage msg(initial_frame_size); - msg.set_retryable(true); - msg.set_operation_name("client.sendschema"); - - msg.set_message_type(static_cast(4864)); - msg.set_partition_id(-1); - - msg.set(schema, true); - - return msg; -} - -ClientMessage -client_sendallschemas_encode( - const std::vector& schemas) -{ - size_t initial_frame_size = ClientMessage::REQUEST_HEADER_LEN; - ClientMessage msg(initial_frame_size); - msg.set_retryable(true); - msg.set_operation_name("client.sendallschemas"); - - msg.set_message_type(static_cast(5376)); - msg.set_partition_id(-1); - - msg.set(schemas, true); - - return msg; -} - -ClientMessage -client_fetchschema_encode(int64_t schema_id) -{ - size_t initial_frame_size = - ClientMessage::REQUEST_HEADER_LEN + ClientMessage::INT64_SIZE; - ClientMessage msg(initial_frame_size, true); - msg.set_retryable(true); - msg.set_operation_name("client.fetchschema"); - - msg.set_message_type(static_cast(5120)); - msg.set_partition_id(-1); - - msg.set(schema_id); - return msg; -} - } // namespace codec } // namespace protocol } // namespace client diff --git a/hazelcast/generated-sources/src/hazelcast/client/protocol/codec/codecs.h b/hazelcast/generated-sources/src/hazelcast/client/protocol/codec/codecs.h index 80f139b00..8d5b49e71 100644 --- a/hazelcast/generated-sources/src/hazelcast/client/protocol/codec/codecs.h +++ b/hazelcast/generated-sources/src/hazelcast/client/protocol/codec/codecs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2023, Hazelcast, Inc. All Rights Reserved. + * Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,9 @@ client_authentication_encode(const std::string& cluster_name, byte serialization_version, const std::string& client_hazelcast_version, const std::string& client_name, - const std::vector& labels); + const std::vector& labels, + byte routing_mode, + bool cp_direct_to_leader_routing); /** * Makes an authentication request to the cluster using custom credentials. @@ -51,7 +53,9 @@ client_authenticationcustom_encode(const std::string& cluster_name, byte serialization_version, const std::string& client_hazelcast_version, const std::string& client_name, - const std::vector& labels); + const std::vector& labels, + byte routing_mode, + bool cp_direct_to_leader_routing); /** * Adds a cluster view listener to a connection. @@ -83,6 +87,20 @@ struct HAZELCAST_API client_addclusterviewlistener_handler int32_t version, std::vector>> const& partitions) = 0; + + /** + * @param version Holds the state of member-groups and member-list-version + * @param member_groups Grouped members by their UUID. Grouping is done + * based on RoutingStrategy. + */ + virtual void handle_membergroupsview( + int32_t version, + std::vector> const& member_groups) = 0; + + /** + * @param version The cluster version. + */ + virtual void handle_clusterversion(version const& version) = 0; }; /** @@ -301,6 +319,25 @@ struct HAZELCAST_API client_localbackuplistener_handler virtual void handle_backup(int64_t source_invocation_correlation_id) = 0; }; +/** + * Sends a schema to cluster + */ +ClientMessage HAZELCAST_API +client_sendschema_encode(const serialization::pimpl::schema& schema); + +/** + * Fetches a schema from the cluster with the given schemaId + */ +ClientMessage HAZELCAST_API +client_fetchschema_encode(int64_t schema_id); + +/** + * Sends all the schemas to the cluster + */ +ClientMessage HAZELCAST_API +client_sendallschemas_encode( + const std::vector& schemas); + /** * Puts an entry into this map with a given ttl (time to live) value.Entry will * expire and get evicted after the ttl If ttl is 0, then the entry lives @@ -3113,25 +3150,6 @@ ClientMessage HAZELCAST_API sql_fetch_encode(const sql::impl::query_id& query_id, int32_t cursor_buffer_size); -/** - * Replicates schema on cluster - */ -ClientMessage HAZELCAST_API -client_sendschema_encode(const serialization::pimpl::schema& schema); - -/** - * Sends all the schemas to the cluster - */ -ClientMessage HAZELCAST_API -client_sendallschemas_encode( - const std::vector& schemas); - -/** - * Fetches a schema from the cluster with the given schemaId - */ -ClientMessage HAZELCAST_API -client_fetchschema_encode(int64_t schema_id); - } // namespace codec } // namespace protocol } // namespace client diff --git a/hazelcast/include/hazelcast/client/protocol/ClientMessage.h b/hazelcast/include/hazelcast/client/protocol/ClientMessage.h index 4df3620dc..e354304e1 100644 --- a/hazelcast/include/hazelcast/client/protocol/ClientMessage.h +++ b/hazelcast/include/hazelcast/client/protocol/ClientMessage.h @@ -42,6 +42,7 @@ #include "hazelcast/client/exception/protocol_exceptions.h" #include "hazelcast/client/map/data_entry_view.h" #include "hazelcast/client/member.h" +#include "hazelcast/client/version.h" #include "hazelcast/client/protocol/codec/ErrorCodec.h" #include "hazelcast/client/query/paging_predicate.h" #include "hazelcast/client/serialization/pimpl/data.h" @@ -1042,6 +1043,24 @@ class HAZELCAST_API ClientMessage std::move(suggestion) }; } + template + typename std::enable_if::value, + T>::type + get() + { + // begin frame + skip_frame(); + + const auto header = read_frame_header(); + + auto major = get(); + auto minor = get(); + + fast_forward_to_end_frame(); + + return version{major, minor}; + } + template boost::optional get_nullable( std::function decoder = default_nullable_decoder{}) diff --git a/hazelcast/include/hazelcast/client/version.h b/hazelcast/include/hazelcast/client/version.h new file mode 100644 index 000000000..fe7aaef95 --- /dev/null +++ b/hazelcast/include/hazelcast/client/version.h @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2008-2023, Hazelcast, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +#include + +#include "hazelcast/util/export.h" +#include "hazelcast/util/byte.h" + +#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) +#pragma warning(push) +#pragma warning(disable : 4251) // for dll export +#endif + +namespace hazelcast { +namespace client { +/** + * A generic version to be used with VersionAware classes. The version is composed of two bytes, denoting + * {@code major.minor} version. It is used to represent the Hazelcast cluster version and the serialization version of + * VersionAware classes. + * + * @since 5.4 + */ +struct HAZELCAST_API version +{ + // Accessible for testing + /** + * Use 0 as major & minor values for UNKNOWN version + */ + //static constexpr byte UNKNOWN_VERSION = 0; + + /** + * Version 0.0 is UNKNOWN constant + *
    + *
  • {@code UNKNOWN} is only equal to itself.
  • + *
  • {@code is(Less|Greater)Than} method with an {@code UNKNOWN} operand returns false.
  • + *
  • {@code is(Less|Greater)OrEqual} with an {@code UNKNOWN} operand returns false, unless both operands are + * {@code UNKNOWN}.
  • + *
  • {@code UNKNOWN.isUnknown(Less|Greater)(Than|OrEqual)} returns true.
  • + *
  • {@code otherVersion.isUnknown(Less|Greater)(Than|OrEqual)} with an {@code UNKNOWN} argument returns false.
  • + *
+ */ + + + byte major; + byte minor; + +/* + bool operator==(const version& rhs) const; + + bool operator!=(const version& rhs) const; + + bool operator<(const version& rhs) const; + + bool operator>(const version& rhs) const; + + bool operator<=(const version& rhs) const; + + bool operator>=(const version& rhs) const; + + friend std::ostream HAZELCAST_API& operator<<(std::ostream& os, + const version& version); +*/ +}; + +} // namespace client +} // namespace hazelcast + +#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) +#pragma warning(pop) +#endif \ No newline at end of file