Skip to content

Commit c8533ab

Browse files
authored
Updated the codecs used with latest changes [CTT-713] (#1336)
Updated the codecs used with latest changes. Also, updated the code to use these codecs properly with the new introduced parameters. Associated protocol PR is hazelcast/hazelcast-client-protocol#557
1 parent 08fd880 commit c8533ab

File tree

8 files changed

+379
-127
lines changed

8 files changed

+379
-127
lines changed

hazelcast/generated-sources/src/hazelcast/client/protocol/codec/codecs.cpp

Lines changed: 123 additions & 93 deletions
Large diffs are not rendered by default.

hazelcast/generated-sources/src/hazelcast/client/protocol/codec/codecs.h

Lines changed: 159 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424

2525
namespace hazelcast {
2626
namespace client {
27+
28+
namespace serialization {
29+
namespace pimpl {
30+
class schema;
31+
} // namespace pimpl
32+
} // namespace serialization
33+
2734
namespace protocol {
2835
namespace codec {
2936
/**
@@ -38,7 +45,9 @@ client_authentication_encode(const std::string& cluster_name,
3845
byte serialization_version,
3946
const std::string& client_hazelcast_version,
4047
const std::string& client_name,
41-
const std::vector<std::string>& labels);
48+
const std::vector<std::string>& labels,
49+
byte routing_mode,
50+
bool cp_direct_to_leader_routing);
4251

4352
/**
4453
* Makes an authentication request to the cluster using custom credentials.
@@ -51,7 +60,9 @@ client_authenticationcustom_encode(const std::string& cluster_name,
5160
byte serialization_version,
5261
const std::string& client_hazelcast_version,
5362
const std::string& client_name,
54-
const std::vector<std::string>& labels);
63+
const std::vector<std::string>& labels,
64+
byte routing_mode,
65+
bool cp_direct_to_leader_routing);
5566

5667
/**
5768
* Adds a cluster view listener to a connection.
@@ -62,6 +73,15 @@ client_addclusterviewlistener_encode();
6273
struct HAZELCAST_API client_addclusterviewlistener_handler
6374
: public impl::BaseEventHandler
6475
{
76+
// Define event constants
77+
enum event_message_type
78+
{
79+
EVENT_MEMBERS_VIEW = 770,
80+
EVENT_PARTITIONS_VIEW = 771,
81+
EVENT_MEMBER_GROUPS_VIEW = 772,
82+
EVENT_CLUSTER_VERSION = 773,
83+
};
84+
6585
client_addclusterviewlistener_handler(logger& l);
6686

6787
void handle(ClientMessage& msg);
@@ -83,13 +103,21 @@ struct HAZELCAST_API client_addclusterviewlistener_handler
83103
int32_t version,
84104
std::vector<std::pair<boost::uuids::uuid, std::vector<int>>> const&
85105
partitions) = 0;
86-
};
87106

88-
/**
89-
* Triggers partition assignment manually on the cluster.
90-
* Note that Partition based operations triggers this automatically
91-
*/
92-
ClientMessage HAZELCAST_API client_triggerpartitionassignment_encode();
107+
/**
108+
* @param version Holds the state of member-groups and member-list-version
109+
* @param member_groups Grouped members by their UUID. Grouping is done
110+
* based on RoutingStrategy.
111+
*/
112+
virtual void handle_membergroupsview(
113+
int32_t version,
114+
std::vector<std::vector<boost::uuids::uuid>> const& member_groups) = 0;
115+
116+
/**
117+
* @param version The cluster version.
118+
*/
119+
virtual void handle_clusterversion(internal::version const& version) = 0;
120+
};
93121

94122
/**
95123
* Creates a cluster-wide proxy with the given name and service.
@@ -297,6 +325,12 @@ client_localbackuplistener_encode();
297325
struct HAZELCAST_API client_localbackuplistener_handler
298326
: public impl::BaseEventHandler
299327
{
328+
// Define event constants
329+
enum event_message_type
330+
{
331+
EVENT_BACKUP = 3842,
332+
};
333+
300334
client_localbackuplistener_handler(logger& l);
301335

302336
void handle(ClientMessage& msg);
@@ -307,6 +341,32 @@ struct HAZELCAST_API client_localbackuplistener_handler
307341
virtual void handle_backup(int64_t source_invocation_correlation_id) = 0;
308342
};
309343

344+
/**
345+
* Triggers partition assignment manually on the cluster.
346+
* Note that Partition based operations triggers this automatically
347+
*/
348+
ClientMessage HAZELCAST_API
349+
client_triggerpartitionassignment_encode();
350+
351+
/**
352+
* Sends a schema to cluster
353+
*/
354+
ClientMessage HAZELCAST_API
355+
client_sendschema_encode(const serialization::pimpl::schema& schema);
356+
357+
/**
358+
* Fetches a schema from the cluster with the given schemaId
359+
*/
360+
ClientMessage HAZELCAST_API
361+
client_fetchschema_encode(int64_t schema_id);
362+
363+
/**
364+
* Sends all the schemas to the cluster
365+
*/
366+
ClientMessage HAZELCAST_API
367+
client_sendallschemas_encode(
368+
const std::vector<serialization::pimpl::schema>& schemas);
369+
310370
/**
311371
* Puts an entry into this map with a given ttl (time to live) value.Entry will
312372
* expire and get evicted after the ttl If ttl is 0, then the entry lives
@@ -558,6 +618,12 @@ map_addentrylistenerwithpredicate_encode(
558618
struct HAZELCAST_API map_addentrylistenerwithpredicate_handler
559619
: public impl::BaseEventHandler
560620
{
621+
// Define event constants
622+
enum event_message_type
623+
{
624+
EVENT_ENTRY = 71426,
625+
};
626+
561627
map_addentrylistenerwithpredicate_handler(logger& l);
562628

563629
void handle(ClientMessage& msg);
@@ -605,6 +671,12 @@ map_addentrylistenertokey_encode(const std::string& name,
605671
struct HAZELCAST_API map_addentrylistenertokey_handler
606672
: public impl::BaseEventHandler
607673
{
674+
// Define event constants
675+
enum event_message_type
676+
{
677+
EVENT_ENTRY = 71682,
678+
};
679+
608680
map_addentrylistenertokey_handler(logger& l);
609681

610682
void handle(ClientMessage& msg);
@@ -651,6 +723,12 @@ map_addentrylistener_encode(const std::string& name,
651723
struct HAZELCAST_API map_addentrylistener_handler
652724
: public impl::BaseEventHandler
653725
{
726+
// Define event constants
727+
enum event_message_type
728+
{
729+
EVENT_ENTRY = 71938,
730+
};
731+
654732
map_addentrylistener_handler(logger& l);
655733

656734
void handle(ClientMessage& msg);
@@ -968,6 +1046,13 @@ map_addnearcacheinvalidationlistener_encode(const std::string& name,
9681046
struct HAZELCAST_API map_addnearcacheinvalidationlistener_handler
9691047
: public impl::BaseEventHandler
9701048
{
1049+
// Define event constants
1050+
enum event_message_type
1051+
{
1052+
EVENT_I_MAP_INVALIDATION = 81666,
1053+
EVENT_I_MAP_BATCH_INVALIDATION = 81667,
1054+
};
1055+
9711056
map_addnearcacheinvalidationlistener_handler(logger& l);
9721057

9731058
void handle(ClientMessage& msg);
@@ -1115,6 +1200,12 @@ multimap_addentrylistenertokey_encode(const std::string& name,
11151200
struct HAZELCAST_API multimap_addentrylistenertokey_handler
11161201
: public impl::BaseEventHandler
11171202
{
1203+
// Define event constants
1204+
enum event_message_type
1205+
{
1206+
EVENT_ENTRY = 134402,
1207+
};
1208+
11181209
multimap_addentrylistenertokey_handler(logger& l);
11191210

11201211
void handle(ClientMessage& msg);
@@ -1160,6 +1251,12 @@ multimap_addentrylistener_encode(const std::string& name,
11601251
struct HAZELCAST_API multimap_addentrylistener_handler
11611252
: public impl::BaseEventHandler
11621253
{
1254+
// Define event constants
1255+
enum event_message_type
1256+
{
1257+
EVENT_ENTRY = 134658,
1258+
};
1259+
11631260
multimap_addentrylistener_handler(logger& l);
11641261

11651262
void handle(ClientMessage& msg);
@@ -1424,6 +1521,12 @@ queue_addlistener_encode(const std::string& name,
14241521

14251522
struct HAZELCAST_API queue_addlistener_handler : public impl::BaseEventHandler
14261523
{
1524+
// Define event constants
1525+
enum event_message_type
1526+
{
1527+
EVENT_ITEM = 200962,
1528+
};
1529+
14271530
queue_addlistener_handler(logger& l);
14281531

14291532
void handle(ClientMessage& msg);
@@ -1481,6 +1584,12 @@ topic_addmessagelistener_encode(const std::string& name, bool local_only);
14811584
struct HAZELCAST_API topic_addmessagelistener_handler
14821585
: public impl::BaseEventHandler
14831586
{
1587+
// Define event constants
1588+
enum event_message_type
1589+
{
1590+
EVENT_TOPIC = 262658,
1591+
};
1592+
14841593
topic_addmessagelistener_handler(logger& l);
14851594

14861595
void handle(ClientMessage& msg);
@@ -1601,6 +1710,12 @@ list_addlistener_encode(const std::string& name,
16011710

16021711
struct HAZELCAST_API list_addlistener_handler : public impl::BaseEventHandler
16031712
{
1713+
// Define event constants
1714+
enum event_message_type
1715+
{
1716+
EVENT_ITEM = 330498,
1717+
};
1718+
16041719
list_addlistener_handler(logger& l);
16051720

16061721
void handle(ClientMessage& msg);
@@ -1819,6 +1934,12 @@ set_addlistener_encode(const std::string& name,
18191934

18201935
struct HAZELCAST_API set_addlistener_handler : public impl::BaseEventHandler
18211936
{
1937+
// Define event constants
1938+
enum event_message_type
1939+
{
1940+
EVENT_ITEM = 396034,
1941+
};
1942+
18221943
set_addlistener_handler(logger& l);
18231944

18241945
void handle(ClientMessage& msg);
@@ -2289,6 +2410,12 @@ replicatedmap_addentrylistenertokeywithpredicate_encode(
22892410
struct HAZELCAST_API replicatedmap_addentrylistenertokeywithpredicate_handler
22902411
: public impl::BaseEventHandler
22912412
{
2413+
// Define event constants
2414+
enum event_message_type
2415+
{
2416+
EVENT_ENTRY = 854530,
2417+
};
2418+
22922419
replicatedmap_addentrylistenertokeywithpredicate_handler(logger& l);
22932420

22942421
void handle(ClientMessage& msg);
@@ -2335,6 +2462,12 @@ replicatedmap_addentrylistenerwithpredicate_encode(
23352462
struct HAZELCAST_API replicatedmap_addentrylistenerwithpredicate_handler
23362463
: public impl::BaseEventHandler
23372464
{
2465+
// Define event constants
2466+
enum event_message_type
2467+
{
2468+
EVENT_ENTRY = 854786,
2469+
};
2470+
23382471
replicatedmap_addentrylistenerwithpredicate_handler(logger& l);
23392472

23402473
void handle(ClientMessage& msg);
@@ -2381,6 +2514,12 @@ replicatedmap_addentrylistenertokey_encode(
23812514
struct HAZELCAST_API replicatedmap_addentrylistenertokey_handler
23822515
: public impl::BaseEventHandler
23832516
{
2517+
// Define event constants
2518+
enum event_message_type
2519+
{
2520+
EVENT_ENTRY = 855042,
2521+
};
2522+
23842523
replicatedmap_addentrylistenertokey_handler(logger& l);
23852524

23862525
void handle(ClientMessage& msg);
@@ -2424,6 +2563,12 @@ replicatedmap_addentrylistener_encode(const std::string& name, bool local_only);
24242563
struct HAZELCAST_API replicatedmap_addentrylistener_handler
24252564
: public impl::BaseEventHandler
24262565
{
2566+
// Define event constants
2567+
enum event_message_type
2568+
{
2569+
EVENT_ENTRY = 855298,
2570+
};
2571+
24272572
replicatedmap_addentrylistener_handler(logger& l);
24282573

24292574
void handle(ClientMessage& msg);
@@ -2504,6 +2649,12 @@ replicatedmap_addnearcacheentrylistener_encode(const std::string& name,
25042649
struct HAZELCAST_API replicatedmap_addnearcacheentrylistener_handler
25052650
: public impl::BaseEventHandler
25062651
{
2652+
// Define event constants
2653+
enum event_message_type
2654+
{
2655+
EVENT_ENTRY = 856578,
2656+
};
2657+
25072658
replicatedmap_addnearcacheentrylistener_handler(logger& l);
25082659

25092660
void handle(ClientMessage& msg);
@@ -3119,25 +3270,6 @@ ClientMessage HAZELCAST_API
31193270
sql_fetch_encode(const sql::impl::query_id& query_id,
31203271
int32_t cursor_buffer_size);
31213272

3122-
/**
3123-
* Replicates schema on cluster
3124-
*/
3125-
ClientMessage HAZELCAST_API
3126-
client_sendschema_encode(const serialization::pimpl::schema& schema);
3127-
3128-
/**
3129-
* Sends all the schemas to the cluster
3130-
*/
3131-
ClientMessage HAZELCAST_API
3132-
client_sendallschemas_encode(
3133-
const std::vector<serialization::pimpl::schema>& schemas);
3134-
3135-
/**
3136-
* Fetches a schema from the cluster with the given schemaId
3137-
*/
3138-
ClientMessage HAZELCAST_API
3139-
client_fetchschema_encode(int64_t schema_id);
3140-
31413273
} // namespace codec
31423274
} // namespace protocol
31433275
} // namespace client

hazelcast/include/hazelcast/client/connection/ClientConnectionManagerImpl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ class HAZELCAST_API ClientConnectionManagerImpl
199199
static constexpr int32_t CLIENT = 1;
200200
static const endpoint_qualifier PUBLIC_ENDPOINT_QUALIFIER;
201201
static constexpr int SQL_CONNECTION_RANDOM_ATTEMPTS = 10;
202+
static constexpr byte ALL_MEMBERS_ROUTING = 1;
202203

203204
struct auth_response
204205
{
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#pragma once
18+
19+
#include "hazelcast/util/byte.h"
20+
21+
namespace hazelcast {
22+
namespace client {
23+
namespace internal {
24+
/**
25+
* A generic version to be used with version aware classes. The version is composed of two bytes, denoting
26+
* {@code MAJOR.MINOR} version. It is used to represent the Hazelcast cluster version.
27+
*
28+
* @since 5.5
29+
*/
30+
struct version
31+
{
32+
byte major;
33+
byte minor;
34+
};
35+
} // namespace impl
36+
} // namespace client
37+
} // namespace hazelcast

0 commit comments

Comments
 (0)