@webex/plugin-meetings 3.11.0-next.23 → 3.11.0-next.25
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/dist/breakouts/breakout.js +1 -1
- package/dist/breakouts/index.js +1 -1
- package/dist/hashTree/hashTreeParser.js +226 -114
- package/dist/hashTree/hashTreeParser.js.map +1 -1
- package/dist/interpretation/index.js +1 -1
- package/dist/interpretation/siLanguage.js +1 -1
- package/dist/types/hashTree/hashTreeParser.d.ts +22 -0
- package/dist/webinar/index.js +1 -1
- package/package.json +1 -1
- package/src/hashTree/hashTreeParser.ts +180 -88
- package/test/unit/spec/hashTree/hashTreeParser.ts +477 -4
package/dist/breakouts/index.js
CHANGED
|
@@ -1109,7 +1109,7 @@ var Breakouts = _webexCore.WebexPlugin.extend({
|
|
|
1109
1109
|
this.trigger(_constants.BREAKOUTS.EVENTS.ASK_RETURN_TO_MAIN);
|
|
1110
1110
|
}
|
|
1111
1111
|
},
|
|
1112
|
-
version: "3.11.0-next.
|
|
1112
|
+
version: "3.11.0-next.25"
|
|
1113
1113
|
});
|
|
1114
1114
|
var _default = exports.default = Breakouts;
|
|
1115
1115
|
//# sourceMappingURL=index.js.map
|
|
@@ -87,6 +87,7 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
87
87
|
(0, _defineProperty2.default)(this, "locusInfoUpdateCallback", void 0);
|
|
88
88
|
(0, _defineProperty2.default)(this, "visibleDataSets", void 0);
|
|
89
89
|
(0, _defineProperty2.default)(this, "debugId", void 0);
|
|
90
|
+
(0, _defineProperty2.default)(this, "heartbeatIntervalMs", void 0);
|
|
90
91
|
var _options$initialLocus = options.initialLocus,
|
|
91
92
|
dataSets = _options$initialLocus.dataSets,
|
|
92
93
|
locus = _options$initialLocus.locus; // extract dataSets from initialLocus
|
|
@@ -763,11 +764,15 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
763
764
|
value: function deleteHashTree(dataSetName) {
|
|
764
765
|
this.dataSets[dataSetName].hashTree = undefined;
|
|
765
766
|
|
|
766
|
-
// we also need to stop the
|
|
767
|
+
// we also need to stop the timers as there is no hash tree anymore to sync
|
|
767
768
|
if (this.dataSets[dataSetName].timer) {
|
|
768
769
|
clearTimeout(this.dataSets[dataSetName].timer);
|
|
769
770
|
this.dataSets[dataSetName].timer = undefined;
|
|
770
771
|
}
|
|
772
|
+
if (this.dataSets[dataSetName].heartbeatWatchdogTimer) {
|
|
773
|
+
clearTimeout(this.dataSets[dataSetName].heartbeatWatchdogTimer);
|
|
774
|
+
this.dataSets[dataSetName].heartbeatWatchdogTimer = undefined;
|
|
775
|
+
}
|
|
771
776
|
}
|
|
772
777
|
|
|
773
778
|
/**
|
|
@@ -946,7 +951,8 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
946
951
|
value: (function () {
|
|
947
952
|
var _parseMessage = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5(message, debugText) {
|
|
948
953
|
var _message$locusStateEl,
|
|
949
|
-
_this8 = this
|
|
954
|
+
_this8 = this,
|
|
955
|
+
_message$locusStateEl2;
|
|
950
956
|
var dataSets, visibleDataSetsUrl, isRosterDropped, updatedObjects, dataSetsRequiringInitialization, metadataUpdates, updatedMetadataObjects, _this$checkForVisible2, changeDetected, removedDataSets, addedDataSets;
|
|
951
957
|
return _regenerator.default.wrap(function (_context6) {
|
|
952
958
|
while (1) switch (_context6.prev = _context6.next) {
|
|
@@ -1009,46 +1015,47 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1009
1015
|
dataSetsRequiringInitialization = this.processVisibleDataSetChanges(removedDataSets, addedDataSets, updatedObjects);
|
|
1010
1016
|
}
|
|
1011
1017
|
}
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1018
|
+
if (((_message$locusStateEl2 = message.locusStateElements) === null || _message$locusStateEl2 === void 0 ? void 0 : _message$locusStateEl2.length) > 0) {
|
|
1019
|
+
// by this point we now have this.dataSets setup for data sets from this message
|
|
1020
|
+
// and hash trees created for the new visible data sets,
|
|
1021
|
+
// so we can now process all the updates from the message
|
|
1022
|
+
dataSets.forEach(function (dataSet) {
|
|
1023
|
+
if (_this8.dataSets[dataSet.name]) {
|
|
1024
|
+
var hashTree = _this8.dataSets[dataSet.name].hashTree;
|
|
1025
|
+
if (hashTree) {
|
|
1026
|
+
var locusStateElementsForThisSet = message.locusStateElements.filter(function (object) {
|
|
1027
|
+
return object.htMeta.dataSetNames.includes(dataSet.name);
|
|
1028
|
+
});
|
|
1029
|
+
var appliedChangesList = hashTree.updateItems(locusStateElementsForThisSet.map(function (object) {
|
|
1030
|
+
return object.data ? {
|
|
1031
|
+
operation: 'update',
|
|
1032
|
+
item: object.htMeta.elementId
|
|
1033
|
+
} : {
|
|
1034
|
+
operation: 'remove',
|
|
1035
|
+
item: object.htMeta.elementId
|
|
1036
|
+
};
|
|
1037
|
+
}));
|
|
1038
|
+
(0, _lodash.zip)(appliedChangesList, locusStateElementsForThisSet).forEach(function (_ref5) {
|
|
1039
|
+
var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
|
|
1040
|
+
changeApplied = _ref6[0],
|
|
1041
|
+
object = _ref6[1];
|
|
1042
|
+
if (changeApplied) {
|
|
1043
|
+
if ((0, _utils.isSelf)(object) && !object.data) {
|
|
1044
|
+
isRosterDropped = true;
|
|
1045
|
+
}
|
|
1046
|
+
// add to updatedObjects so that our locus DTO will get updated with the new object
|
|
1047
|
+
updatedObjects.push(object);
|
|
1039
1048
|
}
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
}
|
|
1044
|
-
} else {
|
|
1045
|
-
_loggerProxy.default.logger.info("Locus-info:index#parseMessage --> ".concat(_this8.debugId, " unexpected (not visible) dataSet ").concat(dataSet.name, " received in hash tree message"));
|
|
1049
|
+
});
|
|
1050
|
+
} else {
|
|
1051
|
+
_loggerProxy.default.logger.info("Locus-info:index#parseMessage --> ".concat(_this8.debugId, " unexpected (not visible) dataSet ").concat(dataSet.name, " received in hash tree message"));
|
|
1052
|
+
}
|
|
1046
1053
|
}
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1054
|
+
if (!isRosterDropped) {
|
|
1055
|
+
_this8.runSyncAlgorithm(dataSet);
|
|
1056
|
+
}
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1052
1059
|
if (!isRosterDropped) {
|
|
1053
1060
|
_context6.next = 2;
|
|
1054
1061
|
break;
|
|
@@ -1101,11 +1108,15 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1101
1108
|
return _regenerator.default.wrap(function (_context7) {
|
|
1102
1109
|
while (1) switch (_context7.prev = _context7.next) {
|
|
1103
1110
|
case 0:
|
|
1111
|
+
if (message.heartbeatIntervalMs) {
|
|
1112
|
+
this.heartbeatIntervalMs = message.heartbeatIntervalMs;
|
|
1113
|
+
}
|
|
1104
1114
|
if (!(message.locusStateElements === undefined)) {
|
|
1105
1115
|
_context7.next = 1;
|
|
1106
1116
|
break;
|
|
1107
1117
|
}
|
|
1108
1118
|
this.handleRootHashHeartBeatMessage(message);
|
|
1119
|
+
this.resetHeartbeatWatchdogs(message.dataSets);
|
|
1109
1120
|
_context7.next = 3;
|
|
1110
1121
|
break;
|
|
1111
1122
|
case 1:
|
|
@@ -1113,6 +1124,10 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1113
1124
|
return this.parseMessage(message, debugText);
|
|
1114
1125
|
case 2:
|
|
1115
1126
|
updates = _context7.sent;
|
|
1127
|
+
// Only reset watchdogs if the meeting hasn't ended
|
|
1128
|
+
if (updates.updateType !== LocusInfoUpdateType.MEETING_ENDED) {
|
|
1129
|
+
this.resetHeartbeatWatchdogs(message.dataSets);
|
|
1130
|
+
}
|
|
1116
1131
|
this.callLocusInfoUpdateCallback(updates);
|
|
1117
1132
|
case 3:
|
|
1118
1133
|
case "end":
|
|
@@ -1199,12 +1214,99 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1199
1214
|
return Math.round(Math.pow(randomValue, exponent) * maxMs);
|
|
1200
1215
|
}
|
|
1201
1216
|
|
|
1217
|
+
/**
|
|
1218
|
+
* Performs a sync for the given data set.
|
|
1219
|
+
*
|
|
1220
|
+
* @param {InternalDataSet} dataSet - The data set to sync
|
|
1221
|
+
* @param {string} rootHash - Our current root hash for this data set
|
|
1222
|
+
* @param {string} reason - The reason for the sync (used for logging)
|
|
1223
|
+
* @returns {Promise<void>}
|
|
1224
|
+
*/
|
|
1225
|
+
}, {
|
|
1226
|
+
key: "performSync",
|
|
1227
|
+
value: (function () {
|
|
1228
|
+
var _performSync = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7(dataSet, rootHash, reason) {
|
|
1229
|
+
var mismatchedLeavesData, receivedHashes, _yield$this$getHashes, hashes, latestDataSetInfo, mismatchedLeaveIndexes, syncResponse, _t3;
|
|
1230
|
+
return _regenerator.default.wrap(function (_context8) {
|
|
1231
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
1232
|
+
case 0:
|
|
1233
|
+
if (dataSet.hashTree) {
|
|
1234
|
+
_context8.next = 1;
|
|
1235
|
+
break;
|
|
1236
|
+
}
|
|
1237
|
+
return _context8.abrupt("return");
|
|
1238
|
+
case 1:
|
|
1239
|
+
_loggerProxy.default.logger.info("HashTreeParser#performSync --> ".concat(this.debugId, " ").concat(reason, ", syncing data set \"").concat(dataSet.name, "\""));
|
|
1240
|
+
mismatchedLeavesData = {};
|
|
1241
|
+
if (!(dataSet.leafCount !== 1)) {
|
|
1242
|
+
_context8.next = 7;
|
|
1243
|
+
break;
|
|
1244
|
+
}
|
|
1245
|
+
_context8.prev = 2;
|
|
1246
|
+
_context8.next = 3;
|
|
1247
|
+
return this.getHashesFromLocus(dataSet.name, rootHash);
|
|
1248
|
+
case 3:
|
|
1249
|
+
_yield$this$getHashes = _context8.sent;
|
|
1250
|
+
hashes = _yield$this$getHashes.hashes;
|
|
1251
|
+
latestDataSetInfo = _yield$this$getHashes.dataSet;
|
|
1252
|
+
receivedHashes = hashes;
|
|
1253
|
+
dataSet.hashTree.resize(latestDataSetInfo.leafCount);
|
|
1254
|
+
_context8.next = 6;
|
|
1255
|
+
break;
|
|
1256
|
+
case 4:
|
|
1257
|
+
_context8.prev = 4;
|
|
1258
|
+
_t3 = _context8["catch"](2);
|
|
1259
|
+
if (!(_t3.statusCode === 409)) {
|
|
1260
|
+
_context8.next = 5;
|
|
1261
|
+
break;
|
|
1262
|
+
}
|
|
1263
|
+
// this is a leaf count mismatch, we should do nothing, just wait for another heartbeat message from Locus
|
|
1264
|
+
_loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(this.debugId, " Got 409 when fetching hashes for data set \"").concat(dataSet.name, "\": ").concat(_t3.message));
|
|
1265
|
+
return _context8.abrupt("return");
|
|
1266
|
+
case 5:
|
|
1267
|
+
throw _t3;
|
|
1268
|
+
case 6:
|
|
1269
|
+
// identify mismatched leaves
|
|
1270
|
+
mismatchedLeaveIndexes = dataSet.hashTree.diffHashes(receivedHashes);
|
|
1271
|
+
mismatchedLeaveIndexes.forEach(function (index) {
|
|
1272
|
+
mismatchedLeavesData[index] = dataSet.hashTree.getLeafData(index);
|
|
1273
|
+
});
|
|
1274
|
+
_context8.next = 8;
|
|
1275
|
+
break;
|
|
1276
|
+
case 7:
|
|
1277
|
+
mismatchedLeavesData[0] = dataSet.hashTree.getLeafData(0);
|
|
1278
|
+
case 8:
|
|
1279
|
+
if (!((0, _keys.default)(mismatchedLeavesData).length > 0)) {
|
|
1280
|
+
_context8.next = 10;
|
|
1281
|
+
break;
|
|
1282
|
+
}
|
|
1283
|
+
_context8.next = 9;
|
|
1284
|
+
return this.sendSyncRequestToLocus(dataSet, mismatchedLeavesData);
|
|
1285
|
+
case 9:
|
|
1286
|
+
syncResponse = _context8.sent;
|
|
1287
|
+
// sync API may return nothing (in that case data will arrive via messages)
|
|
1288
|
+
// or it may return a response in the same format as messages
|
|
1289
|
+
if (syncResponse) {
|
|
1290
|
+
this.handleMessage(syncResponse, 'via sync API');
|
|
1291
|
+
}
|
|
1292
|
+
case 10:
|
|
1293
|
+
case "end":
|
|
1294
|
+
return _context8.stop();
|
|
1295
|
+
}
|
|
1296
|
+
}, _callee7, this, [[2, 4]]);
|
|
1297
|
+
}));
|
|
1298
|
+
function performSync(_x0, _x1, _x10) {
|
|
1299
|
+
return _performSync.apply(this, arguments);
|
|
1300
|
+
}
|
|
1301
|
+
return performSync;
|
|
1302
|
+
}()
|
|
1202
1303
|
/**
|
|
1203
1304
|
* Runs the sync algorithm for the given data set.
|
|
1204
1305
|
*
|
|
1205
1306
|
* @param {DataSet} receivedDataSet - The data set to run the sync algorithm for.
|
|
1206
1307
|
* @returns {void}
|
|
1207
1308
|
*/
|
|
1309
|
+
)
|
|
1208
1310
|
}, {
|
|
1209
1311
|
key: "runSyncAlgorithm",
|
|
1210
1312
|
value: function runSyncAlgorithm(receivedDataSet) {
|
|
@@ -1229,93 +1331,99 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1229
1331
|
clearTimeout(dataSet.timer);
|
|
1230
1332
|
}
|
|
1231
1333
|
_loggerProxy.default.logger.info("HashTreeParser#runSyncAlgorithm --> ".concat(this.debugId, " setting \"").concat(dataSet.name, "\" sync timer for ").concat(delay));
|
|
1232
|
-
dataSet.timer = setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1233
|
-
var rootHash
|
|
1234
|
-
return _regenerator.default.wrap(function (
|
|
1235
|
-
while (1) switch (
|
|
1334
|
+
dataSet.timer = setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8() {
|
|
1335
|
+
var rootHash;
|
|
1336
|
+
return _regenerator.default.wrap(function (_context9) {
|
|
1337
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
1236
1338
|
case 0:
|
|
1237
1339
|
dataSet.timer = undefined;
|
|
1238
1340
|
if (dataSet.hashTree) {
|
|
1239
|
-
|
|
1341
|
+
_context9.next = 1;
|
|
1240
1342
|
break;
|
|
1241
1343
|
}
|
|
1242
1344
|
_loggerProxy.default.logger.warn("HashTreeParser#runSyncAlgorithm --> ".concat(_this0.debugId, " Data set \"").concat(dataSet.name, "\" no longer has a hash tree, cannot run sync algorithm"));
|
|
1243
|
-
return
|
|
1345
|
+
return _context9.abrupt("return");
|
|
1244
1346
|
case 1:
|
|
1245
1347
|
rootHash = dataSet.hashTree.getRootHash();
|
|
1246
1348
|
if (!(dataSet.root !== rootHash)) {
|
|
1247
|
-
|
|
1248
|
-
break;
|
|
1249
|
-
}
|
|
1250
|
-
_loggerProxy.default.logger.info("HashTreeParser#runSyncAlgorithm --> ".concat(_this0.debugId, " Root hash mismatch: received=").concat(dataSet.root, ", ours=").concat(rootHash, ", syncing data set \"").concat(dataSet.name, "\""));
|
|
1251
|
-
mismatchedLeavesData = {};
|
|
1252
|
-
if (!(dataSet.leafCount !== 1)) {
|
|
1253
|
-
_context8.next = 7;
|
|
1254
|
-
break;
|
|
1255
|
-
}
|
|
1256
|
-
_context8.prev = 2;
|
|
1257
|
-
_context8.next = 3;
|
|
1258
|
-
return _this0.getHashesFromLocus(dataSet.name, rootHash);
|
|
1259
|
-
case 3:
|
|
1260
|
-
_yield$_this0$getHash = _context8.sent;
|
|
1261
|
-
hashes = _yield$_this0$getHash.hashes;
|
|
1262
|
-
latestDataSetInfo = _yield$_this0$getHash.dataSet;
|
|
1263
|
-
receivedHashes = hashes;
|
|
1264
|
-
dataSet.hashTree.resize(latestDataSetInfo.leafCount);
|
|
1265
|
-
_context8.next = 6;
|
|
1266
|
-
break;
|
|
1267
|
-
case 4:
|
|
1268
|
-
_context8.prev = 4;
|
|
1269
|
-
_t3 = _context8["catch"](2);
|
|
1270
|
-
if (!(_t3.statusCode === 409)) {
|
|
1271
|
-
_context8.next = 5;
|
|
1349
|
+
_context9.next = 3;
|
|
1272
1350
|
break;
|
|
1273
1351
|
}
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
throw _t3;
|
|
1279
|
-
case 6:
|
|
1280
|
-
// identify mismatched leaves
|
|
1281
|
-
mismatchedLeaveIndexes = dataSet.hashTree.diffHashes(receivedHashes);
|
|
1282
|
-
mismatchedLeaveIndexes.forEach(function (index) {
|
|
1283
|
-
mismatchedLeavesData[index] = dataSet.hashTree.getLeafData(index);
|
|
1284
|
-
});
|
|
1285
|
-
_context8.next = 8;
|
|
1352
|
+
_context9.next = 2;
|
|
1353
|
+
return _this0.performSync(dataSet, rootHash, "Root hash mismatch: received=".concat(dataSet.root, ", ours=").concat(rootHash));
|
|
1354
|
+
case 2:
|
|
1355
|
+
_context9.next = 4;
|
|
1286
1356
|
break;
|
|
1287
|
-
case
|
|
1288
|
-
mismatchedLeavesData[0] = dataSet.hashTree.getLeafData(0);
|
|
1289
|
-
case 8:
|
|
1290
|
-
if (!((0, _keys.default)(mismatchedLeavesData).length > 0)) {
|
|
1291
|
-
_context8.next = 10;
|
|
1292
|
-
break;
|
|
1293
|
-
}
|
|
1294
|
-
_context8.next = 9;
|
|
1295
|
-
return _this0.sendSyncRequestToLocus(dataSet, mismatchedLeavesData);
|
|
1296
|
-
case 9:
|
|
1297
|
-
syncResponse = _context8.sent;
|
|
1298
|
-
// sync API may return nothing (in that case data will arrive via messages)
|
|
1299
|
-
// or it may return a response in the same format as messages
|
|
1300
|
-
if (syncResponse) {
|
|
1301
|
-
_this0.handleMessage(syncResponse, 'via sync API');
|
|
1302
|
-
}
|
|
1303
|
-
case 10:
|
|
1304
|
-
_context8.next = 12;
|
|
1305
|
-
break;
|
|
1306
|
-
case 11:
|
|
1357
|
+
case 3:
|
|
1307
1358
|
_loggerProxy.default.logger.info("HashTreeParser#runSyncAlgorithm --> ".concat(_this0.debugId, " \"").concat(dataSet.name, "\" root hash matching: ").concat(rootHash, ", version=").concat(dataSet.version));
|
|
1308
|
-
case
|
|
1359
|
+
case 4:
|
|
1309
1360
|
case "end":
|
|
1310
|
-
return
|
|
1361
|
+
return _context9.stop();
|
|
1311
1362
|
}
|
|
1312
|
-
},
|
|
1363
|
+
}, _callee8);
|
|
1313
1364
|
})), delay);
|
|
1314
1365
|
} else {
|
|
1315
1366
|
_loggerProxy.default.logger.info("HashTreeParser#runSyncAlgorithm --> ".concat(this.debugId, " No delay for \"").concat(dataSet.name, "\" data set, skipping sync timer reset/setup"));
|
|
1316
1367
|
}
|
|
1317
1368
|
}
|
|
1318
1369
|
|
|
1370
|
+
/**
|
|
1371
|
+
* Resets the heartbeat watchdog timers for the specified data sets. Each data set has its own
|
|
1372
|
+
* watchdog timer that monitors whether heartbeats are being received within the expected interval.
|
|
1373
|
+
* If a heartbeat is not received for a specific data set within heartbeatIntervalMs plus
|
|
1374
|
+
* a backoff-calculated time, the sync algorithm is initiated for that data set
|
|
1375
|
+
*
|
|
1376
|
+
* @param {Array<DataSet>} receivedDataSets - The data sets from the received message for which watchdog timers should be reset
|
|
1377
|
+
* @returns {void}
|
|
1378
|
+
*/
|
|
1379
|
+
}, {
|
|
1380
|
+
key: "resetHeartbeatWatchdogs",
|
|
1381
|
+
value: function resetHeartbeatWatchdogs(receivedDataSets) {
|
|
1382
|
+
var _this1 = this;
|
|
1383
|
+
if (!this.heartbeatIntervalMs) {
|
|
1384
|
+
return;
|
|
1385
|
+
}
|
|
1386
|
+
var _iterator9 = _createForOfIteratorHelper(receivedDataSets),
|
|
1387
|
+
_step9;
|
|
1388
|
+
try {
|
|
1389
|
+
var _loop2 = function _loop2() {
|
|
1390
|
+
var receivedDataSet = _step9.value;
|
|
1391
|
+
var dataSet = _this1.dataSets[receivedDataSet.name];
|
|
1392
|
+
if (!(dataSet !== null && dataSet !== void 0 && dataSet.hashTree)) {
|
|
1393
|
+
// eslint-disable-next-line no-continue
|
|
1394
|
+
return 1; // continue
|
|
1395
|
+
}
|
|
1396
|
+
if (dataSet.heartbeatWatchdogTimer) {
|
|
1397
|
+
clearTimeout(dataSet.heartbeatWatchdogTimer);
|
|
1398
|
+
dataSet.heartbeatWatchdogTimer = undefined;
|
|
1399
|
+
}
|
|
1400
|
+
var backoffTime = _this1.getWeightedBackoffTime(dataSet.backoff);
|
|
1401
|
+
var delay = _this1.heartbeatIntervalMs + backoffTime;
|
|
1402
|
+
dataSet.heartbeatWatchdogTimer = setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
|
|
1403
|
+
return _regenerator.default.wrap(function (_context0) {
|
|
1404
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
1405
|
+
case 0:
|
|
1406
|
+
dataSet.heartbeatWatchdogTimer = undefined;
|
|
1407
|
+
_loggerProxy.default.logger.warn("HashTreeParser#resetHeartbeatWatchdogs --> ".concat(_this1.debugId, " Heartbeat watchdog fired for data set \"").concat(dataSet.name, "\" - no heartbeat received within expected interval, initiating sync"));
|
|
1408
|
+
_context0.next = 1;
|
|
1409
|
+
return _this1.performSync(dataSet, dataSet.hashTree.getRootHash(), "heartbeat watchdog expired");
|
|
1410
|
+
case 1:
|
|
1411
|
+
case "end":
|
|
1412
|
+
return _context0.stop();
|
|
1413
|
+
}
|
|
1414
|
+
}, _callee9);
|
|
1415
|
+
})), delay);
|
|
1416
|
+
};
|
|
1417
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
1418
|
+
if (_loop2()) continue;
|
|
1419
|
+
}
|
|
1420
|
+
} catch (err) {
|
|
1421
|
+
_iterator9.e(err);
|
|
1422
|
+
} finally {
|
|
1423
|
+
_iterator9.f();
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1319
1427
|
/**
|
|
1320
1428
|
* Stops all timers for the data sets to prevent any further sync attempts.
|
|
1321
1429
|
* @returns {void}
|
|
@@ -1328,6 +1436,10 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1328
1436
|
clearTimeout(dataSet.timer);
|
|
1329
1437
|
dataSet.timer = undefined;
|
|
1330
1438
|
}
|
|
1439
|
+
if (dataSet.heartbeatWatchdogTimer) {
|
|
1440
|
+
clearTimeout(dataSet.heartbeatWatchdogTimer);
|
|
1441
|
+
dataSet.heartbeatWatchdogTimer = undefined;
|
|
1442
|
+
}
|
|
1331
1443
|
});
|
|
1332
1444
|
}
|
|
1333
1445
|
|
|
@@ -1340,7 +1452,7 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1340
1452
|
}, {
|
|
1341
1453
|
key: "getHashesFromLocus",
|
|
1342
1454
|
value: function getHashesFromLocus(dataSetName, currentRootHash) {
|
|
1343
|
-
var
|
|
1455
|
+
var _this10 = this;
|
|
1344
1456
|
_loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(this.debugId, " Requesting hashes for data set \"").concat(dataSetName, "\""));
|
|
1345
1457
|
var dataSet = this.dataSets[dataSetName];
|
|
1346
1458
|
var url = "".concat(dataSet.url, "/hashtree");
|
|
@@ -1355,16 +1467,16 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1355
1467
|
var hashes = (_response$body = response.body) === null || _response$body === void 0 ? void 0 : _response$body.hashes;
|
|
1356
1468
|
var dataSetFromResponse = (_response$body2 = response.body) === null || _response$body2 === void 0 ? void 0 : _response$body2.dataSet;
|
|
1357
1469
|
if (!hashes || !(0, _isArray.default)(hashes)) {
|
|
1358
|
-
_loggerProxy.default.logger.warn("HashTreeParser#getHashesFromLocus --> ".concat(
|
|
1470
|
+
_loggerProxy.default.logger.warn("HashTreeParser#getHashesFromLocus --> ".concat(_this10.debugId, " Locus returned invalid hashes, response body="), response.body);
|
|
1359
1471
|
throw new Error("Locus returned invalid hashes: ".concat(hashes));
|
|
1360
1472
|
}
|
|
1361
|
-
_loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(
|
|
1473
|
+
_loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(_this10.debugId, " Received hashes for data set \"").concat(dataSetName, "\": ").concat((0, _stringify.default)(hashes)));
|
|
1362
1474
|
return {
|
|
1363
1475
|
hashes: hashes,
|
|
1364
1476
|
dataSet: dataSetFromResponse
|
|
1365
1477
|
};
|
|
1366
1478
|
}).catch(function (error) {
|
|
1367
|
-
_loggerProxy.default.logger.error("HashTreeParser#getHashesFromLocus --> ".concat(
|
|
1479
|
+
_loggerProxy.default.logger.error("HashTreeParser#getHashesFromLocus --> ".concat(_this10.debugId, " Error ").concat(error.statusCode, " fetching hashes for data set \"").concat(dataSetName, "\":"), error);
|
|
1368
1480
|
throw error;
|
|
1369
1481
|
});
|
|
1370
1482
|
}
|
|
@@ -1379,7 +1491,7 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1379
1491
|
}, {
|
|
1380
1492
|
key: "sendSyncRequestToLocus",
|
|
1381
1493
|
value: function sendSyncRequestToLocus(dataSet, mismatchedLeavesData) {
|
|
1382
|
-
var
|
|
1494
|
+
var _this11 = this;
|
|
1383
1495
|
_loggerProxy.default.logger.info("HashTreeParser#sendSyncRequestToLocus --> ".concat(this.debugId, " Sending sync request for data set \"").concat(dataSet.name, "\""));
|
|
1384
1496
|
var url = "".concat(dataSet.url, "/sync");
|
|
1385
1497
|
var body = {
|
|
@@ -1401,14 +1513,14 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1401
1513
|
},
|
|
1402
1514
|
body: body
|
|
1403
1515
|
}).then(function (resp) {
|
|
1404
|
-
_loggerProxy.default.logger.info("HashTreeParser#sendSyncRequestToLocus --> ".concat(
|
|
1516
|
+
_loggerProxy.default.logger.info("HashTreeParser#sendSyncRequestToLocus --> ".concat(_this11.debugId, " Sync request succeeded for \"").concat(dataSet.name, "\""));
|
|
1405
1517
|
if (!resp.body || (0, _lodash.isEmpty)(resp.body)) {
|
|
1406
|
-
_loggerProxy.default.logger.info("HashTreeParser#sendSyncRequestToLocus --> ".concat(
|
|
1518
|
+
_loggerProxy.default.logger.info("HashTreeParser#sendSyncRequestToLocus --> ".concat(_this11.debugId, " Got ").concat(resp.statusCode, " with empty body for sync request for data set \"").concat(dataSet.name, "\", data should arrive via messages"));
|
|
1407
1519
|
return null;
|
|
1408
1520
|
}
|
|
1409
1521
|
return resp.body;
|
|
1410
1522
|
}).catch(function (error) {
|
|
1411
|
-
_loggerProxy.default.logger.error("HashTreeParser#sendSyncRequestToLocus --> ".concat(
|
|
1523
|
+
_loggerProxy.default.logger.error("HashTreeParser#sendSyncRequestToLocus --> ".concat(_this11.debugId, " Error ").concat(error.statusCode, " sending sync request for data set \"").concat(dataSet.name, "\":"), error);
|
|
1412
1524
|
throw error;
|
|
1413
1525
|
});
|
|
1414
1526
|
}
|