@celerispay/hazelcast-client 3.12.5-6 → 3.12.5-8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/PartitionService.js
CHANGED
|
@@ -69,11 +69,13 @@ var PartitionService = /** @class */ (function () {
|
|
|
69
69
|
var ownerConnection = this.client.getClusterService().getOwnerConnection();
|
|
70
70
|
if (ownerConnection == null) {
|
|
71
71
|
this.logger.warn('PartitionService', 'Cannot refresh partitions, no owner connection available');
|
|
72
|
-
|
|
72
|
+
// Return a rejected promise instead of resolved to indicate failure
|
|
73
|
+
return Promise.reject(new Error('No owner connection available for partition refresh'));
|
|
73
74
|
}
|
|
74
75
|
this.refreshInProgress = true;
|
|
75
76
|
var clientMessage = GetPartitionsCodec.encodeRequest();
|
|
76
|
-
|
|
77
|
+
// Add timeout to prevent hanging
|
|
78
|
+
var refreshPromise = this.client.getInvocationService()
|
|
77
79
|
.invokeOnConnection(ownerConnection, clientMessage)
|
|
78
80
|
.then(function (response) {
|
|
79
81
|
var receivedPartitionMap = GetPartitionsCodec.decodeResponse(response);
|
|
@@ -93,9 +95,17 @@ var PartitionService = /** @class */ (function () {
|
|
|
93
95
|
_this.clearPartitionTable();
|
|
94
96
|
}
|
|
95
97
|
}
|
|
98
|
+
throw e; // Re-throw the error to propagate it
|
|
96
99
|
}).finally(function () {
|
|
97
100
|
_this.refreshInProgress = false;
|
|
98
101
|
});
|
|
102
|
+
// Add timeout to prevent hanging
|
|
103
|
+
var timeoutPromise = new Promise(function (_, reject) {
|
|
104
|
+
setTimeout(function () {
|
|
105
|
+
reject(new Error('Partition refresh timed out'));
|
|
106
|
+
}, 10000); // 10 second timeout
|
|
107
|
+
});
|
|
108
|
+
return Promise.race([refreshPromise, timeoutPromise]);
|
|
99
109
|
};
|
|
100
110
|
/**
|
|
101
111
|
* Returns the {@link Address} of the node which owns given partition id.
|
|
@@ -289,6 +289,10 @@ var InvocationService = /** @class */ (function () {
|
|
|
289
289
|
throw new Error("Still no partition owner for partition " + partitionId + " after refresh");
|
|
290
290
|
}
|
|
291
291
|
return _this.invokeOnAddress(invocation, newOwnerAddress);
|
|
292
|
+
}).catch(function (error) {
|
|
293
|
+
_this.logger.error('InvocationService', "Failed to refresh partition table for partition " + partitionId + ":", error);
|
|
294
|
+
// If partition refresh fails, reject the invocation instead of hanging
|
|
295
|
+
throw new Error("Cannot find partition owner for partition " + partitionId + ": " + error.message);
|
|
292
296
|
});
|
|
293
297
|
}
|
|
294
298
|
return this.client.getConnectionManager().getOrConnect(ownerAddress).then(function (connection) {
|
|
@@ -301,6 +305,10 @@ var InvocationService = /** @class */ (function () {
|
|
|
301
305
|
return _this.client.getPartitionService().refresh().then(function () {
|
|
302
306
|
// Retry the invocation with updated partition information
|
|
303
307
|
return _this.doInvoke(invocation);
|
|
308
|
+
}).catch(function (refreshError) {
|
|
309
|
+
_this.logger.error('InvocationService', "Failed to refresh partition table after partition owner failure:", refreshError);
|
|
310
|
+
// If refresh fails, reject the invocation instead of hanging
|
|
311
|
+
throw new Error("Partition owner " + ownerAddress.toString() + " unavailable and partition refresh failed: " + refreshError.message);
|
|
304
312
|
});
|
|
305
313
|
}
|
|
306
314
|
throw new HazelcastError_1.IOError(ownerAddress.toString() + '(partition owner) is not available.', e);
|
|
@@ -37,8 +37,4 @@ export declare class ProxyManager {
|
|
|
37
37
|
private findNextAddress();
|
|
38
38
|
private initializeProxy(proxyObject, promise, deadline);
|
|
39
39
|
private createDistributedObjectListener();
|
|
40
|
-
/**
|
|
41
|
-
* Checks if the cluster is healthy enough to create proxies
|
|
42
|
-
*/
|
|
43
|
-
private isClusterHealthy();
|
|
44
40
|
}
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
var Promise = require("bluebird");
|
|
19
18
|
var ClientAddDistributedObjectListenerCodec_1 = require("../codec/ClientAddDistributedObjectListenerCodec");
|
|
20
19
|
var ClientCreateProxyCodec_1 = require("../codec/ClientCreateProxyCodec");
|
|
21
20
|
var ClientDestroyProxyCodec_1 = require("../codec/ClientDestroyProxyCodec");
|
|
@@ -69,12 +68,6 @@ var ProxyManager = /** @class */ (function () {
|
|
|
69
68
|
if (this.proxies[fullName]) {
|
|
70
69
|
return this.proxies[fullName];
|
|
71
70
|
}
|
|
72
|
-
// Check if cluster is healthy before creating proxy
|
|
73
|
-
if (!this.isClusterHealthy()) {
|
|
74
|
-
var error = new Error('Cluster is not healthy, cannot create proxy for ' + name);
|
|
75
|
-
this.logger.error('ProxyManager', error.message);
|
|
76
|
-
return Promise.reject(error);
|
|
77
|
-
}
|
|
78
71
|
var deferred = Util_1.DeferredPromise();
|
|
79
72
|
var newProxy;
|
|
80
73
|
if (serviceName === ProxyManager.MAP_SERVICE && this.client.getConfig().getNearCacheConfig(name)) {
|
|
@@ -98,9 +91,6 @@ var ProxyManager = /** @class */ (function () {
|
|
|
98
91
|
if (createAtServer) {
|
|
99
92
|
this.createProxy(newProxy).then(function () {
|
|
100
93
|
deferred.resolve(newProxy);
|
|
101
|
-
}).catch(function (error) {
|
|
102
|
-
_this.logger.error('ProxyManager', 'Failed to create proxy for ' + name + ': ' + error);
|
|
103
|
-
deferred.reject(error);
|
|
104
94
|
});
|
|
105
95
|
}
|
|
106
96
|
this.proxies[fullName] = deferred.promise;
|
|
@@ -171,37 +161,36 @@ var ProxyManager = /** @class */ (function () {
|
|
|
171
161
|
};
|
|
172
162
|
ProxyManager.prototype.initializeProxy = function (proxyObject, promise, deadline) {
|
|
173
163
|
var _this = this;
|
|
174
|
-
if (Date.now()
|
|
175
|
-
var
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
var address = this.findNextAddress();
|
|
181
|
-
if (!address) {
|
|
182
|
-
var error = new Error('No cluster members available for proxy creation: ' + proxyObject.getName());
|
|
183
|
-
this.logger.error('ProxyManager', error.message);
|
|
184
|
-
promise.reject(error);
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
var request = ClientCreateProxyCodec_1.ClientCreateProxyCodec.encodeRequest(proxyObject.getName(), proxyObject.getServiceName(), address);
|
|
188
|
-
var invocation = new InvocationService_1.Invocation(this.client, request);
|
|
189
|
-
invocation.address = address;
|
|
190
|
-
this.client.getInvocationService().invoke(invocation).then(function (response) {
|
|
191
|
-
promise.resolve(response);
|
|
192
|
-
}).catch(function (error) {
|
|
193
|
-
if (_this.isRetryable(error)) {
|
|
194
|
-
_this.logger.warn('ProxyManager', 'Create proxy request for ' + proxyObject.getName() +
|
|
195
|
-
' failed. Retrying in ' + _this.invocationRetryPauseMillis + 'ms. ' + error);
|
|
196
|
-
setTimeout(function () {
|
|
197
|
-
_this.initializeProxy(proxyObject, promise, deadline);
|
|
198
|
-
}, _this.invocationRetryPauseMillis);
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
_this.logger.error('ProxyManager', 'Create proxy request for ' + proxyObject.getName() + ' failed ' + error);
|
|
164
|
+
if (Date.now() <= deadline) {
|
|
165
|
+
var address = this.findNextAddress();
|
|
166
|
+
if (!address) {
|
|
167
|
+
var error = new Error('No cluster members available for proxy creation: ' + proxyObject.getName());
|
|
168
|
+
this.logger.error('ProxyManager', error.message);
|
|
202
169
|
promise.reject(error);
|
|
170
|
+
return;
|
|
203
171
|
}
|
|
204
|
-
|
|
172
|
+
var request = ClientCreateProxyCodec_1.ClientCreateProxyCodec.encodeRequest(proxyObject.getName(), proxyObject.getServiceName(), address);
|
|
173
|
+
var invocation = new InvocationService_1.Invocation(this.client, request);
|
|
174
|
+
invocation.address = address;
|
|
175
|
+
this.client.getInvocationService().invoke(invocation).then(function (response) {
|
|
176
|
+
promise.resolve(response);
|
|
177
|
+
}).catch(function (error) {
|
|
178
|
+
if (_this.isRetryable(error)) {
|
|
179
|
+
_this.logger.warn('ProxyManager', 'Create proxy request for ' + proxyObject.getName() +
|
|
180
|
+
' failed. Retrying in ' + _this.invocationRetryPauseMillis + 'ms. ' + error);
|
|
181
|
+
setTimeout(function () {
|
|
182
|
+
_this.initializeProxy(proxyObject, promise, deadline);
|
|
183
|
+
}, _this.invocationRetryPauseMillis);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
_this.logger.error('ProxyManager', 'Create proxy request for ' + proxyObject.getName() + ' failed ' + error);
|
|
187
|
+
promise.reject(error);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
promise.reject('Create proxy request timed-out for ' + proxyObject.getName());
|
|
193
|
+
}
|
|
205
194
|
};
|
|
206
195
|
ProxyManager.prototype.createDistributedObjectListener = function () {
|
|
207
196
|
return {
|
|
@@ -216,30 +205,6 @@ var ProxyManager = /** @class */ (function () {
|
|
|
216
205
|
},
|
|
217
206
|
};
|
|
218
207
|
};
|
|
219
|
-
/**
|
|
220
|
-
* Checks if the cluster is healthy enough to create proxies
|
|
221
|
-
*/
|
|
222
|
-
ProxyManager.prototype.isClusterHealthy = function () {
|
|
223
|
-
var members = this.client.getClusterService().getMembers();
|
|
224
|
-
var hasMembers = members && members.length > 0;
|
|
225
|
-
if (!hasMembers) {
|
|
226
|
-
this.logger.warn('ProxyManager', 'No cluster members available');
|
|
227
|
-
return false;
|
|
228
|
-
}
|
|
229
|
-
// Check if we have at least one data member
|
|
230
|
-
var hasDataMember = members.some(function (member) { return member && !member.isLiteMember; });
|
|
231
|
-
if (!hasDataMember) {
|
|
232
|
-
this.logger.warn('ProxyManager', 'No data members available in cluster');
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
|
-
// Check if we have an owner connection
|
|
236
|
-
var ownerConnection = this.client.getClusterService().getOwnerConnection();
|
|
237
|
-
if (!ownerConnection || !ownerConnection.isHealthy()) {
|
|
238
|
-
this.logger.warn('ProxyManager', 'No healthy owner connection available');
|
|
239
|
-
return false;
|
|
240
|
-
}
|
|
241
|
-
return true;
|
|
242
|
-
};
|
|
243
208
|
ProxyManager.MAP_SERVICE = 'hz:impl:mapService';
|
|
244
209
|
ProxyManager.SET_SERVICE = 'hz:impl:setService';
|
|
245
210
|
ProxyManager.LOCK_SERVICE = 'hz:impl:lockService';
|
package/package.json
CHANGED