Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
"sinon-chai": "~3.7.0",
"source-map-support": "~0.5.21",
"thrift": "~0.16.0",
"ts-node": "~10.9.1",
"typedoc": "~0.23.28",
"typescript": "~4.9.5",
"ts-node": "^10.9.2",
"typedoc": "^0.28.20",
"typescript": "^6.0.3",
"winston": "~3.8.2",
"yargs": "~17.5.1"
},
Expand Down
6 changes: 3 additions & 3 deletions src/ClusterFailoverService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,17 @@ export class ClusterFailoverServiceBuilder {
}

const cloudAddressProvider = this.initCloudAddressProvider(config);
if (cloudAddressProvider != null) {
if (cloudAddressProvider) {
return cloudAddressProvider;
}

return new DefaultAddressProvider(networkConfig);
}

private initCloudAddressProvider(config: ClientConfigImpl): HazelcastCloudAddressProvider {
private initCloudAddressProvider(config: ClientConfigImpl): HazelcastCloudAddressProvider | null {
const cloudConfig = config.network.hazelcastCloud;
const discoveryToken = cloudConfig.discoveryToken;
if (discoveryToken != null) {
if (discoveryToken) {
const urlEndpoint = HazelcastCloudDiscovery.createUrlEndpoint(config.properties, discoveryToken);
return new HazelcastCloudAddressProvider(
urlEndpoint, ClusterFailoverServiceBuilder.getConnectionTimeoutMillis(config), this.loggingService.getLogger());
Expand Down
24 changes: 12 additions & 12 deletions src/HazelcastClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class HazelcastClient {
/** @internal */
private readonly clusterViewListenerService: ClusterViewListenerService;
/** @internal */
private mapRepairingTask: RepairingTask;
private mapRepairingTask?: RepairingTask;
/** @internal */
private readonly connectionRegistry: ConnectionRegistryImpl;
/** @internal */
Expand All @@ -135,15 +135,15 @@ export class HazelcastClient {

/** @internal */
constructor(config?: ClientConfigImpl, failoverConfig?: ClientFailoverConfigImpl) {
if (config != null) {
if (config) {
this.config = config;
} else {
this.config = failoverConfig.clientConfigs[0];
this.config = failoverConfig?.clientConfigs[0] || new ClientConfigImpl();
}
this.loadBalancer = this.initLoadBalancer();
this.failoverConfig = failoverConfig;
this.errorFactory = new ClientErrorFactory();
this.loggingService = new LoggingService(this.config.customLogger,
this.loggingService = new LoggingService(this.config.customLogger || null,
this.config.properties['hazelcast.logging.level'] as string);
const logger = this.loggingService.getLogger();
this.schemaService = new SchemaService(
Expand All @@ -167,10 +167,10 @@ export class HazelcastClient {
logger
);
this.clusterFailoverService = HazelcastClient.initClusterFailoverService(
this.failoverConfig,
this.config,
this.lifecycleService,
this.loggingService
this.loggingService,
this.failoverConfig,
);
this.clusterService = new ClusterService(
this.config,
Expand Down Expand Up @@ -283,7 +283,7 @@ export class HazelcastClient {
static newHazelcastFailoverClient(failoverConfig?: ClientFailoverConfig): Promise<HazelcastClient> {
const configBuilder = new FailoverConfigBuilder(failoverConfig);
const effectiveConfig = configBuilder.build();
const client = new HazelcastClient(null, effectiveConfig);
const client = new HazelcastClient(undefined, effectiveConfig);
return client.init();
}

Expand All @@ -298,8 +298,8 @@ export class HazelcastClient {
* Gathers information of this local client.
*/
getLocalEndpoint(): ClientInfo {
const connection: Connection = this.connectionRegistry.getRandomConnection();
const localAddress = connection != null ? connection.getLocalAddress() : null;
const connection: Connection | null = this.connectionRegistry.getRandomConnection();
const localAddress = connection?.getLocalAddress();
const info = new ClientInfo();
info.uuid = this.connectionManager.getClientUuid();
info.localAddress = localAddress;
Expand Down Expand Up @@ -650,7 +650,7 @@ export class HazelcastClient {
/** @internal */
private initLoadBalancer(): LoadBalancer {
let lb = this.config.loadBalancer.customLoadBalancer;
if (lb == null) {
if (!lb) {
if (this.config.loadBalancer.type === LoadBalancerType.ROUND_ROBIN) {
lb = new RoundRobinLB();
} else if (this.config.loadBalancer.type === LoadBalancerType.RANDOM) {
Expand All @@ -665,10 +665,10 @@ export class HazelcastClient {

/** @internal */
private static initClusterFailoverService(
failoverConfig: ClientFailoverConfigImpl,
config: ClientConfigImpl,
lifecycleService: LifecycleService,
loggingService: LoggingService
loggingService: LoggingService,
failoverConfig?: ClientFailoverConfigImpl,
): ClusterFailoverService {
let tryCount: number;
let clientConfigs: ClientConfigImpl[];
Expand Down
1 change: 1 addition & 0 deletions src/LifecycleService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export class LifecycleServiceImpl extends EventEmitter implements LifecycleServi

constructor(lifecycleListeners: Array<(state: LifecycleState) => void>, private logger: ILogger) {
super();
this.active = false;
this.setMaxListeners(0);
lifecycleListeners.forEach((listener) => {
this.on(LIFECYCLE_EVENT_NAME, listener);
Expand Down
11 changes: 6 additions & 5 deletions src/PartitionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import {ILogger} from './logging/ILogger';
import {ILogger} from './logging';
import {Connection} from './network/Connection';
import {ClientOfflineError, HazelcastSerializationError, SchemaNotReplicatedError, UUID} from './core';
import {SerializationService} from './serialization/SerializationService';
Expand All @@ -31,7 +31,7 @@ export interface PartitionService {
* @return UUID of the owner of the partition
* or `undefined` if a partition is not assigned yet
*/
getPartitionOwner(partitionId: number): UUID;
getPartitionOwner(partitionId: number): UUID | undefined;

/**
* Returns partition count of the connected cluster.
Expand All @@ -54,7 +54,7 @@ export interface PartitionService {
}

class PartitionTable {
connection: Connection;
connection?: Connection;
partitionStateVersion = -1;
partitions = new Map<number, UUID>();
}
Expand Down Expand Up @@ -91,7 +91,7 @@ export class PartitionServiceImpl implements PartitionService {
this.partitionTable.partitions = newPartitions;
}

getPartitionOwner(partitionId: number): UUID {
getPartitionOwner(partitionId: number): UUID | undefined {
return this.getPartitions().get(partitionId);
}

Expand All @@ -118,6 +118,7 @@ export class PartitionServiceImpl implements PartitionService {
, e
);
}
throw e;
}
}
return Math.abs(partitionHash) % this.partitionCount;
Expand Down Expand Up @@ -174,7 +175,7 @@ export class PartitionServiceImpl implements PartitionService {
return false;
}

if (!connection.equals(current.connection)) {
if (!current.connection || !connection.equals(current.connection)) {
this.logger.trace('PartitionService', 'Event coming from a new connection. Old connection: ' + current.connection
+ ', new connection ' + connection);
return true;
Expand Down
12 changes: 6 additions & 6 deletions src/aggregation/Aggregator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

import * as Long from 'long';
import {DataInput, DataOutput} from '../serialization/Data';
import {IdentifiedDataSerializable} from '../serialization/Serializable';
import Long from 'long';
import {DataInput, DataOutput} from '../serialization';
import {IdentifiedDataSerializable} from '../serialization';
import * as AggregatorConstants from './AggregatorConstants';
import {HazelcastError} from '../core';

Expand All @@ -32,10 +32,10 @@ export abstract class AbstractAggregator<R> implements Aggregator<R> {

abstract classId: number;
factoryId = AggregatorConstants.AGGREGATOR_FACTORY_ID;
protected attributePath: string;
protected attributePath: string | null;

constructor(attributePath?: string) {
this.attributePath = attributePath;
this.attributePath = attributePath === undefined? null : attributePath;
}

abstract readData(input: DataInput): any;
Expand Down Expand Up @@ -302,6 +302,6 @@ export function aggregatorFactory(classId: number): IdentifiedDataSerializable {
try {
return new idToConstructor[classId]();
} catch (e) {
throw new HazelcastError('There is no known aggregator with type id ' + classId, e);
throw new HazelcastError('There is no known aggregator with type id ' + classId, e as Error);
}
}
9 changes: 8 additions & 1 deletion src/codec/AtomicLongAddAndGetCodec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Auto-generated by Hazelcast Client Protocol Code Generator.
*
* @generated Hazelcast Client Protocol Code Generator @f33179b
* @see <a href="https://github.com/hazelcast/hazelcast-client-protocol">Protocol Generator</a>
* DO NOT MODIFY. Changes to this file will be lost when the code is regenerated.
*/

/* eslint-disable max-len */
import {BitsUtil} from '../util/BitsUtil';
import {FixSizedTypesCodec} from './builtin/FixSizedTypesCodec';
import {ClientMessage, Frame, RESPONSE_BACKUP_ACKS_OFFSET, PARTITION_ID_OFFSET} from '../protocol/ClientMessage';
import * as Long from 'long';
import Long from 'long';
import {RaftGroupId} from '../proxy/cpsubsystem/RaftGroupId';
import {RaftGroupIdCodec} from './custom/RaftGroupIdCodec';
import {StringCodec} from './builtin/StringCodec';
Expand Down
9 changes: 8 additions & 1 deletion src/codec/AtomicLongCompareAndSetCodec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Auto-generated by Hazelcast Client Protocol Code Generator.
*
* @generated Hazelcast Client Protocol Code Generator @f33179b
* @see <a href="https://github.com/hazelcast/hazelcast-client-protocol">Protocol Generator</a>
* DO NOT MODIFY. Changes to this file will be lost when the code is regenerated.
*/

/* eslint-disable max-len */
import {BitsUtil} from '../util/BitsUtil';
import {FixSizedTypesCodec} from './builtin/FixSizedTypesCodec';
import {ClientMessage, Frame, RESPONSE_BACKUP_ACKS_OFFSET, PARTITION_ID_OFFSET} from '../protocol/ClientMessage';
import * as Long from 'long';
import Long from 'long';
import {RaftGroupId} from '../proxy/cpsubsystem/RaftGroupId';
import {RaftGroupIdCodec} from './custom/RaftGroupIdCodec';
import {StringCodec} from './builtin/StringCodec';
Expand Down
9 changes: 8 additions & 1 deletion src/codec/AtomicLongGetAndAddCodec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Auto-generated by Hazelcast Client Protocol Code Generator.
*
* @generated Hazelcast Client Protocol Code Generator @f33179b
* @see <a href="https://github.com/hazelcast/hazelcast-client-protocol">Protocol Generator</a>
* DO NOT MODIFY. Changes to this file will be lost when the code is regenerated.
*/

/* eslint-disable max-len */
import {BitsUtil} from '../util/BitsUtil';
import {FixSizedTypesCodec} from './builtin/FixSizedTypesCodec';
import {ClientMessage, Frame, RESPONSE_BACKUP_ACKS_OFFSET, PARTITION_ID_OFFSET} from '../protocol/ClientMessage';
import * as Long from 'long';
import Long from 'long';
import {RaftGroupId} from '../proxy/cpsubsystem/RaftGroupId';
import {RaftGroupIdCodec} from './custom/RaftGroupIdCodec';
import {StringCodec} from './builtin/StringCodec';
Expand Down
9 changes: 8 additions & 1 deletion src/codec/AtomicLongGetAndSetCodec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Auto-generated by Hazelcast Client Protocol Code Generator.
*
* @generated Hazelcast Client Protocol Code Generator @f33179b
* @see <a href="https://github.com/hazelcast/hazelcast-client-protocol">Protocol Generator</a>
* DO NOT MODIFY. Changes to this file will be lost when the code is regenerated.
*/

/* eslint-disable max-len */
import {BitsUtil} from '../util/BitsUtil';
import {FixSizedTypesCodec} from './builtin/FixSizedTypesCodec';
import {ClientMessage, Frame, RESPONSE_BACKUP_ACKS_OFFSET, PARTITION_ID_OFFSET} from '../protocol/ClientMessage';
import * as Long from 'long';
import Long from 'long';
import {RaftGroupId} from '../proxy/cpsubsystem/RaftGroupId';
import {RaftGroupIdCodec} from './custom/RaftGroupIdCodec';
import {StringCodec} from './builtin/StringCodec';
Expand Down
9 changes: 8 additions & 1 deletion src/codec/AtomicLongGetCodec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Auto-generated by Hazelcast Client Protocol Code Generator.
*
* @generated Hazelcast Client Protocol Code Generator @f33179b
* @see <a href="https://github.com/hazelcast/hazelcast-client-protocol">Protocol Generator</a>
* DO NOT MODIFY. Changes to this file will be lost when the code is regenerated.
*/

/* eslint-disable max-len */
import {BitsUtil} from '../util/BitsUtil';
Expand All @@ -21,7 +28,7 @@ import {ClientMessage, Frame, RESPONSE_BACKUP_ACKS_OFFSET, PARTITION_ID_OFFSET}
import {RaftGroupId} from '../proxy/cpsubsystem/RaftGroupId';
import {RaftGroupIdCodec} from './custom/RaftGroupIdCodec';
import {StringCodec} from './builtin/StringCodec';
import * as Long from 'long';
import Long from 'long';

// hex: 0x090500
const REQUEST_MESSAGE_TYPE = 591104;
Expand Down
9 changes: 8 additions & 1 deletion src/codec/AtomicRefCompareAndSetCodec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Auto-generated by Hazelcast Client Protocol Code Generator.
*
* @generated Hazelcast Client Protocol Code Generator @f33179b
* @see <a href="https://github.com/hazelcast/hazelcast-client-protocol">Protocol Generator</a>
* DO NOT MODIFY. Changes to this file will be lost when the code is regenerated.
*/

/* eslint-disable max-len */
import {BitsUtil} from '../util/BitsUtil';
Expand All @@ -35,7 +42,7 @@ const RESPONSE_RESPONSE_OFFSET = RESPONSE_BACKUP_ACKS_OFFSET + BitsUtil.BYTE_SIZ

/** @internal */
export class AtomicRefCompareAndSetCodec {
static encodeRequest(groupId: RaftGroupId, name: string, oldValue: Data, newValue: Data): ClientMessage {
static encodeRequest(groupId: RaftGroupId, name: string, oldValue: Data | null , newValue: Data | null ): ClientMessage {
const clientMessage = ClientMessage.createForEncode();
clientMessage.setRetryable(false);
clientMessage.setContainsSerializedDataInRequest(true);
Expand Down
9 changes: 8 additions & 1 deletion src/codec/AtomicRefContainsCodec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Auto-generated by Hazelcast Client Protocol Code Generator.
*
* @generated Hazelcast Client Protocol Code Generator @f33179b
* @see <a href="https://github.com/hazelcast/hazelcast-client-protocol">Protocol Generator</a>
* DO NOT MODIFY. Changes to this file will be lost when the code is regenerated.
*/

/* eslint-disable max-len */
import {BitsUtil} from '../util/BitsUtil';
Expand All @@ -35,7 +42,7 @@ const RESPONSE_RESPONSE_OFFSET = RESPONSE_BACKUP_ACKS_OFFSET + BitsUtil.BYTE_SIZ

/** @internal */
export class AtomicRefContainsCodec {
static encodeRequest(groupId: RaftGroupId, name: string, value: Data): ClientMessage {
static encodeRequest(groupId: RaftGroupId, name: string, value: Data | null ): ClientMessage {
const clientMessage = ClientMessage.createForEncode();
clientMessage.setRetryable(true);
clientMessage.setContainsSerializedDataInRequest(true);
Expand Down
9 changes: 8 additions & 1 deletion src/codec/AtomicRefGetCodec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Auto-generated by Hazelcast Client Protocol Code Generator.
*
* @generated Hazelcast Client Protocol Code Generator @f33179b
* @see <a href="https://github.com/hazelcast/hazelcast-client-protocol">Protocol Generator</a>
* DO NOT MODIFY. Changes to this file will be lost when the code is regenerated.
*/

/* eslint-disable max-len */
import {BitsUtil} from '../util/BitsUtil';
Expand Down Expand Up @@ -47,7 +54,7 @@ export class AtomicRefGetCodec {
return clientMessage;
}

static decodeResponse(clientMessage: ClientMessage): Data {
static decodeResponse(clientMessage: ClientMessage): Data | null {
// empty initial frame
clientMessage.nextFrame();

Expand Down
Loading
Loading