@celerispay/hazelcast-client 3.12.5-6 → 3.12.5-7
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/proxy/ProxyManager.d.ts +0 -4
- package/lib/proxy/ProxyManager.js +28 -60
- package/package.json +1 -1
|
@@ -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)) {
|
|
@@ -171,37 +164,36 @@ var ProxyManager = /** @class */ (function () {
|
|
|
171
164
|
};
|
|
172
165
|
ProxyManager.prototype.initializeProxy = function (proxyObject, promise, deadline) {
|
|
173
166
|
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);
|
|
167
|
+
if (Date.now() <= deadline) {
|
|
168
|
+
var address = this.findNextAddress();
|
|
169
|
+
if (!address) {
|
|
170
|
+
var error = new Error('No cluster members available for proxy creation: ' + proxyObject.getName());
|
|
171
|
+
this.logger.error('ProxyManager', error.message);
|
|
202
172
|
promise.reject(error);
|
|
173
|
+
return;
|
|
203
174
|
}
|
|
204
|
-
|
|
175
|
+
var request = ClientCreateProxyCodec_1.ClientCreateProxyCodec.encodeRequest(proxyObject.getName(), proxyObject.getServiceName(), address);
|
|
176
|
+
var invocation = new InvocationService_1.Invocation(this.client, request);
|
|
177
|
+
invocation.address = address;
|
|
178
|
+
this.client.getInvocationService().invoke(invocation).then(function (response) {
|
|
179
|
+
promise.resolve(response);
|
|
180
|
+
}).catch(function (error) {
|
|
181
|
+
if (_this.isRetryable(error)) {
|
|
182
|
+
_this.logger.warn('ProxyManager', 'Create proxy request for ' + proxyObject.getName() +
|
|
183
|
+
' failed. Retrying in ' + _this.invocationRetryPauseMillis + 'ms. ' + error);
|
|
184
|
+
setTimeout(function () {
|
|
185
|
+
_this.initializeProxy(proxyObject, promise, deadline);
|
|
186
|
+
}, _this.invocationRetryPauseMillis);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
_this.logger.error('ProxyManager', 'Create proxy request for ' + proxyObject.getName() + ' failed ' + error);
|
|
190
|
+
promise.reject(error);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
promise.reject('Create proxy request timed-out for ' + proxyObject.getName());
|
|
196
|
+
}
|
|
205
197
|
};
|
|
206
198
|
ProxyManager.prototype.createDistributedObjectListener = function () {
|
|
207
199
|
return {
|
|
@@ -216,30 +208,6 @@ var ProxyManager = /** @class */ (function () {
|
|
|
216
208
|
},
|
|
217
209
|
};
|
|
218
210
|
};
|
|
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
211
|
ProxyManager.MAP_SERVICE = 'hz:impl:mapService';
|
|
244
212
|
ProxyManager.SET_SERVICE = 'hz:impl:setService';
|
|
245
213
|
ProxyManager.LOCK_SERVICE = 'hz:impl:lockService';
|
package/package.json
CHANGED