@@ -66,6 +66,7 @@ import {ClientMessage} from './protocol/ClientMessage';
6666import { Connection } from './network/Connection' ;
6767import { ConnectionRegistryImpl } from './network/ConnectionRegistry' ;
6868import { SqlService , SqlServiceImpl } from './sql/SqlService' ;
69+ import { SchemaService } from './serialization/compact/SchemaService' ;
6970
7071/**
7172 * Hazelcast client instance. When you want to use Hazelcast's distributed
@@ -129,6 +130,8 @@ export class HazelcastClient {
129130 private readonly sqlService : SqlService ;
130131 /** @internal */
131132 private shutdownPromise : Promise < void > | undefined ;
133+ /** @internal */
134+ private readonly schemaService : SchemaService ;
132135
133136 /** @internal */
134137 constructor ( config ?: ClientConfigImpl , failoverConfig ?: ClientFailoverConfigImpl ) {
@@ -140,26 +143,28 @@ export class HazelcastClient {
140143 this . loadBalancer = this . initLoadBalancer ( ) ;
141144 this . failoverConfig = failoverConfig ;
142145 this . errorFactory = new ClientErrorFactory ( ) ;
143- this . serializationService = new SerializationServiceV1 ( this . config . serialization ) ;
144- this . instanceName = this . config . instanceName || 'hz.client_' + this . id ;
145146 this . loggingService = new LoggingService ( this . config . customLogger ,
146147 this . config . properties [ 'hazelcast.logging.level' ] as string ) ;
148+ const logger = this . loggingService . getLogger ( ) ;
149+ this . schemaService = new SchemaService ( ( ) => this . invocationService , logger ) ;
150+ this . serializationService = new SerializationServiceV1 ( this . config . serialization , this . schemaService ) ;
151+ this . instanceName = this . config . instanceName || 'hz.client_' + this . id ;
147152 this . nearCacheManager = new NearCacheManager (
148153 this . config ,
149154 this . serializationService
150155 ) ;
151156 this . partitionService = new PartitionServiceImpl (
152- this . loggingService . getLogger ( ) ,
157+ logger ,
153158 this . serializationService
154159 ) ;
155160 this . lifecycleService = new LifecycleServiceImpl (
156161 this . config . lifecycleListeners ,
157- this . loggingService . getLogger ( )
162+ logger
158163 ) ;
159164 this . clusterFailoverService = this . initClusterFailoverService ( ) ;
160165 this . clusterService = new ClusterService (
161166 this . config ,
162- this . loggingService . getLogger ( ) ,
167+ logger ,
163168 this . clusterFailoverService
164169 ) ;
165170 this . connectionRegistry = new ConnectionRegistryImpl (
@@ -171,17 +176,19 @@ export class HazelcastClient {
171176 ) ;
172177 this . invocationService = new InvocationService (
173178 this . config ,
174- this . loggingService . getLogger ( ) ,
179+ logger ,
175180 this . partitionService as PartitionServiceImpl ,
176181 this . errorFactory ,
177182 this . lifecycleService ,
178- this . connectionRegistry
183+ this . connectionRegistry ,
184+ this . schemaService ,
185+ this . serializationService
179186 ) ;
180187 this . connectionManager = new ConnectionManager (
181188 this ,
182189 this . instanceName ,
183190 this . config ,
184- this . loggingService . getLogger ( ) ,
191+ logger ,
185192 this . partitionService ,
186193 this . serializationService ,
187194 this . lifecycleService ,
@@ -192,15 +199,15 @@ export class HazelcastClient {
192199 this . connectionRegistry
193200 ) ;
194201 this . listenerService = new ListenerService (
195- this . loggingService . getLogger ( ) ,
202+ logger ,
196203 this . config . network . smartRouting ,
197204 this . connectionManager ,
198205 this . invocationService
199206 ) ;
200207 this . lockReferenceIdGenerator = new LockReferenceIdGenerator ( ) ;
201208 this . proxyManager = new ProxyManager (
202209 this . config ,
203- this . loggingService . getLogger ( ) ,
210+ logger ,
204211 this . invocationService ,
205212 this . listenerService ,
206213 this . partitionService ,
@@ -209,7 +216,8 @@ export class HazelcastClient {
209216 ( ) => this . getRepairingTask ( ) ,
210217 this . clusterService ,
211218 this . lockReferenceIdGenerator ,
212- this . connectionRegistry
219+ this . connectionRegistry ,
220+ this . schemaService
213221 ) ;
214222 this . statistics = new Statistics (
215223 this . loggingService . getLogger ( ) ,
@@ -220,14 +228,14 @@ export class HazelcastClient {
220228 this . connectionManager
221229 ) ;
222230 this . clusterViewListenerService = new ClusterViewListenerService (
223- this . loggingService . getLogger ( ) ,
231+ logger ,
224232 this . connectionManager ,
225233 this . partitionService as PartitionServiceImpl ,
226234 this . clusterService ,
227235 this . invocationService
228236 ) ;
229237 this . cpSubsystem = new CPSubsystemImpl (
230- this . loggingService . getLogger ( ) ,
238+ logger ,
231239 this . instanceName ,
232240 this . invocationService ,
233241 this . serializationService
@@ -304,12 +312,11 @@ export class HazelcastClient {
304312 const clientMessage = ClientGetDistributedObjectsCodec . encodeRequest ( ) ;
305313 let localDistributedObjects : Set < string > ;
306314 let responseMessage : ClientMessage ;
307- return this . invocationService . invokeOnRandomTarget ( clientMessage )
315+ return this . invocationService . invokeOnRandomTarget ( clientMessage , x => x )
308316 . then ( ( resp ) => {
309317 responseMessage = resp ;
310318 return this . proxyManager . getDistributedObjects ( ) ;
311- } )
312- . then ( ( distributedObjects ) => {
319+ } ) . then ( ( distributedObjects ) => {
313320 localDistributedObjects = new Set < string > ( ) ;
314321 distributedObjects . forEach ( ( obj ) => {
315322 localDistributedObjects . add ( obj . getServiceName ( ) + NAMESPACE_SEPARATOR + obj . getName ( ) ) ;
@@ -491,7 +498,6 @@ export class HazelcastClient {
491498
492499 /**
493500 * Returns a service to execute distributed SQL queries.
494- * The service is in beta state. Behavior and API might be changed in future releases.
495501 *
496502 * @returns SQL service
497503 *
@@ -562,7 +568,9 @@ export class HazelcastClient {
562568
563569 /** @internal */
564570 sendStateToCluster ( ) : Promise < void > {
565- return this . proxyManager . createDistributedObjectsOnCluster ( ) ;
571+ return this . schemaService . sendAllSchemas ( ) . then ( ( ) => {
572+ return this . proxyManager . createDistributedObjectsOnCluster ( ) ;
573+ } ) ;
566574 }
567575
568576 /** @internal */
0 commit comments