@webex/plugin-meetings 3.12.0-next.1 → 3.12.0-next.100
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/AGENTS.md +9 -0
- package/dist/aiEnableRequest/index.js +15 -2
- package/dist/aiEnableRequest/index.js.map +1 -1
- package/dist/breakouts/breakout.js +8 -3
- package/dist/breakouts/breakout.js.map +1 -1
- package/dist/breakouts/index.js +26 -2
- package/dist/breakouts/index.js.map +1 -1
- package/dist/common/errors/webex-errors.js +49 -5
- package/dist/common/errors/webex-errors.js.map +1 -1
- package/dist/config.js +2 -2
- package/dist/config.js.map +1 -1
- package/dist/constants.js +35 -9
- package/dist/constants.js.map +1 -1
- package/dist/controls-options-manager/constants.js +11 -1
- package/dist/controls-options-manager/constants.js.map +1 -1
- package/dist/controls-options-manager/index.js +67 -29
- package/dist/controls-options-manager/index.js.map +1 -1
- package/dist/controls-options-manager/util.js +91 -0
- package/dist/controls-options-manager/util.js.map +1 -1
- package/dist/hashTree/constants.js +13 -1
- package/dist/hashTree/constants.js.map +1 -1
- package/dist/hashTree/hashTreeParser.js +898 -391
- package/dist/hashTree/hashTreeParser.js.map +1 -1
- package/dist/hashTree/utils.js +42 -0
- package/dist/hashTree/utils.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/interceptors/dataChannelAuthToken.js +75 -15
- package/dist/interceptors/dataChannelAuthToken.js.map +1 -1
- package/dist/interceptors/locusRetry.js +23 -8
- package/dist/interceptors/locusRetry.js.map +1 -1
- package/dist/interpretation/index.js +10 -1
- package/dist/interpretation/index.js.map +1 -1
- package/dist/interpretation/interpretation.types.js +7 -0
- package/dist/interpretation/interpretation.types.js.map +1 -0
- package/dist/interpretation/siLanguage.js +1 -1
- package/dist/locus-info/controlsUtils.js +4 -1
- package/dist/locus-info/controlsUtils.js.map +1 -1
- package/dist/locus-info/index.js +401 -115
- package/dist/locus-info/index.js.map +1 -1
- package/dist/locus-info/infoUtils.js +36 -5
- package/dist/locus-info/infoUtils.js.map +1 -1
- package/dist/locus-info/types.js +19 -0
- package/dist/locus-info/types.js.map +1 -1
- package/dist/media/MediaConnectionAwaiter.js +15 -2
- package/dist/media/MediaConnectionAwaiter.js.map +1 -1
- package/dist/media/index.js +8 -2
- package/dist/media/index.js.map +1 -1
- package/dist/media/properties.js +1 -0
- package/dist/media/properties.js.map +1 -1
- package/dist/meeting/in-meeting-actions.js +5 -1
- package/dist/meeting/in-meeting-actions.js.map +1 -1
- package/dist/meeting/index.js +1444 -772
- package/dist/meeting/index.js.map +1 -1
- package/dist/meeting/locusMediaRequest.js +229 -82
- package/dist/meeting/locusMediaRequest.js.map +1 -1
- package/dist/meeting/muteState.js +10 -1
- package/dist/meeting/muteState.js.map +1 -1
- package/dist/meeting/request.js +5 -2
- package/dist/meeting/request.js.map +1 -1
- package/dist/meeting/util.js +35 -2
- package/dist/meeting/util.js.map +1 -1
- package/dist/meeting-info/meeting-info-v2.js +2 -2
- package/dist/meeting-info/meeting-info-v2.js.map +1 -1
- package/dist/meetings/index.js +231 -118
- package/dist/meetings/index.js.map +1 -1
- package/dist/meetings/meetings.types.js +6 -1
- package/dist/meetings/meetings.types.js.map +1 -1
- package/dist/meetings/request.js +39 -0
- package/dist/meetings/request.js.map +1 -1
- package/dist/meetings/util.js +116 -18
- package/dist/meetings/util.js.map +1 -1
- package/dist/member/index.js +10 -0
- package/dist/member/index.js.map +1 -1
- package/dist/member/types.js.map +1 -1
- package/dist/member/util.js +30 -0
- package/dist/member/util.js.map +1 -1
- package/dist/members/index.js +101 -43
- package/dist/members/index.js.map +1 -1
- package/dist/members/util.js +8 -1
- package/dist/members/util.js.map +1 -1
- package/dist/metrics/constants.js +10 -1
- package/dist/metrics/constants.js.map +1 -1
- package/dist/multistream/codec/constants.js +63 -0
- package/dist/multistream/codec/constants.js.map +1 -0
- package/dist/multistream/mediaRequestManager.js +62 -15
- package/dist/multistream/mediaRequestManager.js.map +1 -1
- package/dist/multistream/receiveSlot.js +9 -0
- package/dist/multistream/receiveSlot.js.map +1 -1
- package/dist/multistream/sendSlotManager.js +116 -2
- package/dist/multistream/sendSlotManager.js.map +1 -1
- package/dist/reachability/clusterReachability.js.map +1 -1
- package/dist/reachability/index.js +121 -83
- package/dist/reachability/index.js.map +1 -1
- package/dist/reachability/reachability.types.js +2 -0
- package/dist/reachability/reachability.types.js.map +1 -1
- package/dist/reachability/util.js +45 -0
- package/dist/reachability/util.js.map +1 -1
- package/dist/reactions/reactions.type.js.map +1 -1
- package/dist/recording-controller/index.js +1 -3
- package/dist/recording-controller/index.js.map +1 -1
- package/dist/roap/turnDiscovery.js +8 -1
- package/dist/roap/turnDiscovery.js.map +1 -1
- package/dist/types/common/errors/webex-errors.d.ts +32 -2
- package/dist/types/config.d.ts +2 -2
- package/dist/types/constants.d.ts +12 -1
- package/dist/types/controls-options-manager/constants.d.ts +6 -1
- package/dist/types/controls-options-manager/index.d.ts +16 -0
- package/dist/types/hashTree/constants.d.ts +2 -0
- package/dist/types/hashTree/hashTreeParser.d.ts +146 -17
- package/dist/types/hashTree/utils.d.ts +18 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/interceptors/locusRetry.d.ts +4 -4
- package/dist/types/interpretation/interpretation.types.d.ts +10 -0
- package/dist/types/locus-info/index.d.ts +59 -6
- package/dist/types/locus-info/infoUtils.d.ts +8 -0
- package/dist/types/locus-info/types.d.ts +21 -1
- package/dist/types/media/MediaConnectionAwaiter.d.ts +10 -1
- package/dist/types/media/properties.d.ts +1 -0
- package/dist/types/meeting/in-meeting-actions.d.ts +4 -0
- package/dist/types/meeting/index.d.ts +143 -9
- package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
- package/dist/types/meeting/request.d.ts +1 -0
- package/dist/types/meeting/util.d.ts +9 -0
- package/dist/types/meetings/index.d.ts +30 -18
- package/dist/types/meetings/meetings.types.d.ts +15 -0
- package/dist/types/meetings/request.d.ts +14 -0
- package/dist/types/member/index.d.ts +1 -0
- package/dist/types/member/types.d.ts +1 -0
- package/dist/types/member/util.d.ts +9 -0
- package/dist/types/members/index.d.ts +15 -2
- package/dist/types/members/util.d.ts +1 -5
- package/dist/types/metrics/constants.d.ts +9 -0
- package/dist/types/multistream/codec/constants.d.ts +7 -0
- package/dist/types/multistream/mediaRequestManager.d.ts +22 -5
- package/dist/types/multistream/sendSlotManager.d.ts +23 -1
- package/dist/types/reachability/clusterReachability.d.ts +3 -3
- package/dist/types/reachability/index.d.ts +10 -3
- package/dist/types/reachability/reachability.types.d.ts +7 -0
- package/dist/types/reachability/util.d.ts +17 -0
- package/dist/types/reactions/reactions.type.d.ts +3 -0
- package/dist/webinar/index.js +485 -234
- package/dist/webinar/index.js.map +1 -1
- package/package.json +22 -22
- package/src/aiEnableRequest/index.ts +16 -0
- package/src/breakouts/breakout.ts +3 -1
- package/src/breakouts/index.ts +31 -0
- package/src/common/errors/webex-errors.ts +50 -3
- package/src/config.ts +2 -2
- package/src/constants.ts +20 -3
- package/src/controls-options-manager/constants.ts +14 -1
- package/src/controls-options-manager/index.ts +87 -28
- package/src/controls-options-manager/util.ts +81 -1
- package/src/hashTree/constants.ts +16 -0
- package/src/hashTree/hashTreeParser.ts +596 -204
- package/src/hashTree/utils.ts +36 -0
- package/src/index.ts +6 -0
- package/src/interceptors/dataChannelAuthToken.ts +88 -12
- package/src/interceptors/locusRetry.ts +25 -4
- package/src/interpretation/index.ts +27 -9
- package/src/interpretation/interpretation.types.ts +11 -0
- package/src/locus-info/controlsUtils.ts +3 -1
- package/src/locus-info/index.ts +415 -136
- package/src/locus-info/infoUtils.ts +41 -6
- package/src/locus-info/types.ts +25 -1
- package/src/media/MediaConnectionAwaiter.ts +21 -4
- package/src/media/index.ts +10 -1
- package/src/media/properties.ts +1 -0
- package/src/meeting/in-meeting-actions.ts +8 -0
- package/src/meeting/index.ts +790 -136
- package/src/meeting/locusMediaRequest.ts +106 -6
- package/src/meeting/muteState.ts +10 -1
- package/src/meeting/request.ts +11 -0
- package/src/meeting/util.ts +47 -5
- package/src/meeting-info/meeting-info-v2.ts +4 -2
- package/src/meetings/index.ts +133 -78
- package/src/meetings/meetings.types.ts +19 -0
- package/src/meetings/request.ts +43 -0
- package/src/meetings/util.ts +117 -4
- package/src/member/index.ts +10 -0
- package/src/member/types.ts +1 -0
- package/src/member/util.ts +29 -0
- package/src/members/index.ts +70 -7
- package/src/members/util.ts +12 -4
- package/src/metrics/constants.ts +10 -0
- package/src/multistream/codec/constants.ts +58 -0
- package/src/multistream/mediaRequestManager.ts +119 -28
- package/src/multistream/receiveSlot.ts +18 -0
- package/src/multistream/sendSlotManager.ts +97 -3
- package/src/reachability/clusterReachability.ts +3 -2
- package/src/reachability/index.ts +47 -16
- package/src/reachability/reachability.types.ts +11 -0
- package/src/reachability/util.ts +36 -0
- package/src/reactions/reactions.type.ts +3 -0
- package/src/recording-controller/index.ts +1 -2
- package/src/roap/turnDiscovery.ts +9 -1
- package/src/webinar/index.ts +330 -50
- package/test/unit/spec/aiEnableRequest/index.ts +86 -0
- package/test/unit/spec/breakouts/breakout.ts +9 -3
- package/test/unit/spec/breakouts/index.ts +49 -0
- package/test/unit/spec/common/errors/webex-errors.ts +78 -0
- package/test/unit/spec/controls-options-manager/index.js +244 -29
- package/test/unit/spec/controls-options-manager/util.js +165 -0
- package/test/unit/spec/hashTree/hashTreeParser.ts +1911 -143
- package/test/unit/spec/hashTree/utils.ts +125 -1
- package/test/unit/spec/interceptors/dataChannelAuthToken.ts +196 -0
- package/test/unit/spec/interceptors/locusRetry.ts +205 -4
- package/test/unit/spec/interpretation/index.ts +26 -4
- package/test/unit/spec/locus-info/controlsUtils.js +172 -57
- package/test/unit/spec/locus-info/index.js +645 -80
- package/test/unit/spec/locus-info/infoUtils.js +184 -1
- package/test/unit/spec/media/MediaConnectionAwaiter.ts +55 -0
- package/test/unit/spec/media/index.ts +92 -0
- package/test/unit/spec/meeting/in-meeting-actions.ts +4 -0
- package/test/unit/spec/meeting/index.js +2261 -109
- package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
- package/test/unit/spec/meeting/muteState.js +81 -0
- package/test/unit/spec/meeting/request.js +12 -0
- package/test/unit/spec/meeting/utils.js +157 -1
- package/test/unit/spec/meeting-info/meetinginfov2.js +19 -10
- package/test/unit/spec/meetings/index.js +366 -39
- package/test/unit/spec/meetings/request.js +141 -0
- package/test/unit/spec/meetings/utils.js +402 -51
- package/test/unit/spec/member/index.js +7 -0
- package/test/unit/spec/member/util.js +89 -0
- package/test/unit/spec/members/index.js +216 -0
- package/test/unit/spec/members/request.js +37 -1
- package/test/unit/spec/members/utils.js +63 -0
- package/test/unit/spec/multistream/mediaRequestManager.ts +501 -37
- package/test/unit/spec/multistream/sendSlotManager.ts +135 -36
- package/test/unit/spec/reachability/index.ts +128 -46
- package/test/unit/spec/reachability/util.ts +31 -0
- package/test/unit/spec/recording-controller/index.js +9 -8
- package/test/unit/spec/roap/turnDiscovery.ts +20 -0
- package/test/unit/spec/webinar/index.ts +516 -30
|
@@ -15,17 +15,18 @@ var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequ
|
|
|
15
15
|
_Object$defineProperty(exports, "__esModule", {
|
|
16
16
|
value: true
|
|
17
17
|
});
|
|
18
|
-
exports.default = exports.MeetingEndedError = exports.LocusInfoUpdateType = void 0;
|
|
18
|
+
exports.default = exports.SyncAllBackoffType = exports.MeetingEndedError = exports.LocusNotFoundError = exports.LocusInfoUpdateType = void 0;
|
|
19
19
|
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
|
20
|
-
var
|
|
20
|
+
var _set = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/set"));
|
|
21
21
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
22
|
+
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
22
23
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/array/is-array"));
|
|
23
24
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
|
|
24
25
|
var _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/values"));
|
|
25
26
|
var _parseInt2 = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/parse-int"));
|
|
27
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
|
|
26
28
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
|
|
27
29
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/typeof"));
|
|
28
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
|
|
29
30
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
30
31
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
31
32
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
@@ -37,8 +38,12 @@ var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime-corejs2/h
|
|
|
37
38
|
var _lodash = require("lodash");
|
|
38
39
|
var _hashTree = _interopRequireDefault(require("./hashTree"));
|
|
39
40
|
var _loggerProxy = _interopRequireDefault(require("../common/logs/logger-proxy"));
|
|
40
|
-
var
|
|
41
|
-
var
|
|
41
|
+
var _metrics = _interopRequireDefault(require("../metrics"));
|
|
42
|
+
var _constants = _interopRequireDefault(require("../metrics/constants"));
|
|
43
|
+
var _constants2 = require("../constants");
|
|
44
|
+
var _constants3 = require("./constants");
|
|
45
|
+
var _types = require("./types");
|
|
46
|
+
var _types2 = require("../locus-info/types");
|
|
42
47
|
var _utils = require("./utils");
|
|
43
48
|
function ownKeys(e, r) { var t = _Object$keys4(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
44
49
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -47,9 +52,16 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
47
52
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
48
53
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
49
54
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
55
|
+
var SyncAllBackoffType = exports.SyncAllBackoffType = /*#__PURE__*/function (SyncAllBackoffType) {
|
|
56
|
+
SyncAllBackoffType["NONE"] = "none";
|
|
57
|
+
SyncAllBackoffType["ONLY_LLM"] = "onlyLLM";
|
|
58
|
+
SyncAllBackoffType["ALL"] = "all";
|
|
59
|
+
return SyncAllBackoffType;
|
|
60
|
+
}({});
|
|
50
61
|
var LocusInfoUpdateType = exports.LocusInfoUpdateType = {
|
|
51
62
|
OBJECTS_UPDATED: 'OBJECTS_UPDATED',
|
|
52
|
-
MEETING_ENDED: 'MEETING_ENDED'
|
|
63
|
+
MEETING_ENDED: 'MEETING_ENDED',
|
|
64
|
+
LOCUS_NOT_FOUND: 'LOCUS_NOT_FOUND'
|
|
53
65
|
};
|
|
54
66
|
/**
|
|
55
67
|
* This error is thrown if we receive information that the meeting has ended while we're processing some hash messages.
|
|
@@ -63,11 +75,24 @@ var MeetingEndedError = exports.MeetingEndedError = /*#__PURE__*/function (_Erro
|
|
|
63
75
|
(0, _inherits2.default)(MeetingEndedError, _Error);
|
|
64
76
|
return (0, _createClass2.default)(MeetingEndedError);
|
|
65
77
|
}(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
|
|
78
|
+
/**
|
|
79
|
+
* This error is thrown when a 404 is received from Locus hash tree endpoints, indicating that the locus URL
|
|
80
|
+
* is no longer valid (e.g. participant moved to a breakout room, or meeting ended).
|
|
81
|
+
* It's handled internally by HashTreeParser and results in LOCUS_NOT_FOUND being sent up.
|
|
82
|
+
*/
|
|
83
|
+
var LocusNotFoundError = exports.LocusNotFoundError = /*#__PURE__*/function (_Error2) {
|
|
84
|
+
function LocusNotFoundError() {
|
|
85
|
+
(0, _classCallCheck2.default)(this, LocusNotFoundError);
|
|
86
|
+
return _callSuper(this, LocusNotFoundError, arguments);
|
|
87
|
+
}
|
|
88
|
+
(0, _inherits2.default)(LocusNotFoundError, _Error2);
|
|
89
|
+
return (0, _createClass2.default)(LocusNotFoundError);
|
|
90
|
+
}(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
|
|
66
91
|
/* Currently Locus always sends Metadata objects only in the "self" dataset.
|
|
67
92
|
* If this ever changes, update all the code that relies on this constant.
|
|
68
93
|
*/
|
|
69
|
-
var MetadataDataSetName =
|
|
70
|
-
var PossibleSentinelMessageDataSetNames = [
|
|
94
|
+
var MetadataDataSetName = _constants3.DataSetNames.SELF;
|
|
95
|
+
var PossibleSentinelMessageDataSetNames = [_constants3.DataSetNames.MAIN, _constants3.DataSetNames.SELF, _constants3.DataSetNames.UNJOINED];
|
|
71
96
|
|
|
72
97
|
/**
|
|
73
98
|
* Parses hash tree eventing locus data
|
|
@@ -88,9 +113,17 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
88
113
|
(0, _defineProperty2.default)(this, "locusInfoUpdateCallback", void 0);
|
|
89
114
|
(0, _defineProperty2.default)(this, "visibleDataSets", void 0);
|
|
90
115
|
(0, _defineProperty2.default)(this, "debugId", void 0);
|
|
91
|
-
(0, _defineProperty2.default)(this, "heartbeatIntervalMs", void 0);
|
|
92
116
|
(0, _defineProperty2.default)(this, "excludedDataSets", void 0);
|
|
93
117
|
(0, _defineProperty2.default)(this, "state", void 0);
|
|
118
|
+
(0, _defineProperty2.default)(this, "syncQueue", []);
|
|
119
|
+
(0, _defineProperty2.default)(this, "isSyncInProgress", false);
|
|
120
|
+
// tracks whether syncAllDatasets is currently in its backoff delay phase and with what scope
|
|
121
|
+
(0, _defineProperty2.default)(this, "syncAllBackoffType", SyncAllBackoffType.NONE);
|
|
122
|
+
// datasets that received messages during the syncAllDatasets backoff sleep and should be skipped
|
|
123
|
+
(0, _defineProperty2.default)(this, "dataSetsSyncedDuringBackoff", new _set.default());
|
|
124
|
+
(0, _defineProperty2.default)(this, "syncQueueProcessingPromise", _promise.default.resolve());
|
|
125
|
+
// top-level heartbeat interval from the most recent message, used as fallback when dataset-level value is missing
|
|
126
|
+
(0, _defineProperty2.default)(this, "topLevelHeartbeatIntervalMs", void 0);
|
|
94
127
|
var _options$initialLocus = options.initialLocus,
|
|
95
128
|
dataSets = _options$initialLocus.dataSets,
|
|
96
129
|
locus = _options$initialLocus.locus; // extract dataSets from initialLocus
|
|
@@ -211,80 +244,65 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
211
244
|
*/
|
|
212
245
|
}, {
|
|
213
246
|
key: "initializeNewVisibleDataSet",
|
|
214
|
-
value: function
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
return
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
_loggerProxy.default.logger.warn("HashTreeParser#sendInitializationSyncRequestToLocus --> ".concat(this.debugId, " No data set found for ").concat(datasetName, ", cannot send the request for leaf data"));
|
|
250
|
-
return _promise.default.resolve(null);
|
|
247
|
+
value: (function () {
|
|
248
|
+
var _initializeNewVisibleDataSet = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(visibleDataSetInfo, dataSetInfo) {
|
|
249
|
+
var hashTree;
|
|
250
|
+
return _regenerator.default.wrap(function (_context) {
|
|
251
|
+
while (1) switch (_context.prev = _context.next) {
|
|
252
|
+
case 0:
|
|
253
|
+
if (!this.isVisibleDataSet(dataSetInfo.name)) {
|
|
254
|
+
_context.next = 1;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
_loggerProxy.default.logger.info("HashTreeParser#initializeNewVisibleDataSet --> ".concat(this.debugId, " Data set \"").concat(dataSetInfo.name, "\" already exists, skipping init"));
|
|
258
|
+
return _context.abrupt("return");
|
|
259
|
+
case 1:
|
|
260
|
+
_loggerProxy.default.logger.info("HashTreeParser#initializeNewVisibleDataSet --> ".concat(this.debugId, " Adding visible data set \"").concat(dataSetInfo.name, "\""));
|
|
261
|
+
if (this.addToVisibleDataSetsList(visibleDataSetInfo)) {
|
|
262
|
+
_context.next = 2;
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
return _context.abrupt("return");
|
|
266
|
+
case 2:
|
|
267
|
+
hashTree = new _hashTree.default([], dataSetInfo.leafCount);
|
|
268
|
+
this.dataSets[dataSetInfo.name] = _objectSpread(_objectSpread({}, dataSetInfo), {}, {
|
|
269
|
+
hashTree: hashTree
|
|
270
|
+
});
|
|
271
|
+
this.enqueueSyncForDataset(dataSetInfo.name, 'new visible data set initialization', true);
|
|
272
|
+
_context.next = 3;
|
|
273
|
+
return this.syncQueueProcessingPromise;
|
|
274
|
+
case 3:
|
|
275
|
+
case "end":
|
|
276
|
+
return _context.stop();
|
|
277
|
+
}
|
|
278
|
+
}, _callee, this);
|
|
279
|
+
}));
|
|
280
|
+
function initializeNewVisibleDataSet(_x, _x2) {
|
|
281
|
+
return _initializeNewVisibleDataSet.apply(this, arguments);
|
|
251
282
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
return this.sendSyncRequestToLocus(this.dataSets[datasetName], emptyLeavesData).then(function (syncResponse) {
|
|
255
|
-
if (syncResponse) {
|
|
256
|
-
return {
|
|
257
|
-
updateType: LocusInfoUpdateType.OBJECTS_UPDATED,
|
|
258
|
-
updatedObjects: _this2.parseMessage(syncResponse, "via empty leaves /sync API call for ".concat(debugText))
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
return {
|
|
262
|
-
updateType: LocusInfoUpdateType.OBJECTS_UPDATED,
|
|
263
|
-
updatedObjects: []
|
|
264
|
-
};
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
|
|
283
|
+
return initializeNewVisibleDataSet;
|
|
284
|
+
}()
|
|
268
285
|
/**
|
|
269
286
|
* Queries Locus for all up-to-date information about all visible data sets
|
|
270
287
|
*
|
|
271
288
|
* @returns {Promise}
|
|
272
289
|
*/
|
|
290
|
+
)
|
|
273
291
|
}, {
|
|
274
292
|
key: "getAllVisibleDataSetsFromLocus",
|
|
275
293
|
value: function getAllVisibleDataSetsFromLocus() {
|
|
276
|
-
var
|
|
294
|
+
var _this2 = this;
|
|
277
295
|
if (!this.visibleDataSetsUrl) {
|
|
278
296
|
_loggerProxy.default.logger.warn("HashTreeParser#getAllVisibleDataSetsFromLocus --> ".concat(this.debugId, " No visibleDataSetsUrl, cannot get data sets information"));
|
|
279
297
|
return _promise.default.resolve([]);
|
|
280
298
|
}
|
|
281
299
|
return this.webexRequest({
|
|
282
|
-
method:
|
|
300
|
+
method: _constants2.HTTP_VERBS.GET,
|
|
283
301
|
uri: this.visibleDataSetsUrl
|
|
284
302
|
}).then(function (response) {
|
|
285
303
|
return response.body.dataSets;
|
|
286
304
|
}).catch(function (error) {
|
|
287
|
-
|
|
305
|
+
_this2.checkForSentinelHttpResponse(error);
|
|
288
306
|
throw error;
|
|
289
307
|
});
|
|
290
308
|
}
|
|
@@ -298,26 +316,26 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
298
316
|
}, {
|
|
299
317
|
key: "initializeFromMessage",
|
|
300
318
|
value: (function () {
|
|
301
|
-
var _initializeFromMessage = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
319
|
+
var _initializeFromMessage = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2(message) {
|
|
302
320
|
var visibleDataSets;
|
|
303
|
-
return _regenerator.default.wrap(function (
|
|
304
|
-
while (1) switch (
|
|
321
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
322
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
305
323
|
case 0:
|
|
306
324
|
this.visibleDataSetsUrl = message.visibleDataSetsUrl;
|
|
307
325
|
_loggerProxy.default.logger.info("HashTreeParser#initializeFromMessage --> ".concat(this.debugId, " visibleDataSetsUrl=").concat(this.visibleDataSetsUrl));
|
|
308
|
-
|
|
326
|
+
_context2.next = 1;
|
|
309
327
|
return this.getAllVisibleDataSetsFromLocus();
|
|
310
328
|
case 1:
|
|
311
|
-
visibleDataSets =
|
|
312
|
-
|
|
329
|
+
visibleDataSets = _context2.sent;
|
|
330
|
+
_context2.next = 2;
|
|
313
331
|
return this.initializeDataSets(visibleDataSets, 'initialization from message');
|
|
314
332
|
case 2:
|
|
315
333
|
case "end":
|
|
316
|
-
return
|
|
334
|
+
return _context2.stop();
|
|
317
335
|
}
|
|
318
|
-
},
|
|
336
|
+
}, _callee2, this);
|
|
319
337
|
}));
|
|
320
|
-
function initializeFromMessage(
|
|
338
|
+
function initializeFromMessage(_x3) {
|
|
321
339
|
return _initializeFromMessage.apply(this, arguments);
|
|
322
340
|
}
|
|
323
341
|
return initializeFromMessage;
|
|
@@ -335,34 +353,34 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
335
353
|
}, {
|
|
336
354
|
key: "initializeFromGetLociResponse",
|
|
337
355
|
value: (function () {
|
|
338
|
-
var _initializeFromGetLociResponse = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
356
|
+
var _initializeFromGetLociResponse = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3(locus) {
|
|
339
357
|
var _locus$links2, _locus$links2$resourc, _locus$links2$resourc2;
|
|
340
358
|
var visibleDataSets;
|
|
341
|
-
return _regenerator.default.wrap(function (
|
|
342
|
-
while (1) switch (
|
|
359
|
+
return _regenerator.default.wrap(function (_context3) {
|
|
360
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
343
361
|
case 0:
|
|
344
362
|
if (locus !== null && locus !== void 0 && (_locus$links2 = locus.links) !== null && _locus$links2 !== void 0 && (_locus$links2$resourc = _locus$links2.resources) !== null && _locus$links2$resourc !== void 0 && (_locus$links2$resourc2 = _locus$links2$resourc.visibleDataSets) !== null && _locus$links2$resourc2 !== void 0 && _locus$links2$resourc2.url) {
|
|
345
|
-
|
|
363
|
+
_context3.next = 1;
|
|
346
364
|
break;
|
|
347
365
|
}
|
|
348
366
|
_loggerProxy.default.logger.warn("HashTreeParser#initializeFromGetLociResponse --> ".concat(this.debugId, " missing visibleDataSets url in GET Loci response, cannot initialize hash trees"));
|
|
349
|
-
return
|
|
367
|
+
return _context3.abrupt("return");
|
|
350
368
|
case 1:
|
|
351
369
|
this.visibleDataSetsUrl = locus.links.resources.visibleDataSets.url;
|
|
352
370
|
_loggerProxy.default.logger.info("HashTreeParser#initializeFromGetLociResponse --> ".concat(this.debugId, " visibleDataSets url: ").concat(this.visibleDataSetsUrl));
|
|
353
|
-
|
|
371
|
+
_context3.next = 2;
|
|
354
372
|
return this.getAllVisibleDataSetsFromLocus();
|
|
355
373
|
case 2:
|
|
356
|
-
visibleDataSets =
|
|
357
|
-
|
|
374
|
+
visibleDataSets = _context3.sent;
|
|
375
|
+
_context3.next = 3;
|
|
358
376
|
return this.initializeDataSets(visibleDataSets, 'initialization from GET /loci response');
|
|
359
377
|
case 3:
|
|
360
378
|
case "end":
|
|
361
|
-
return
|
|
379
|
+
return _context3.stop();
|
|
362
380
|
}
|
|
363
|
-
},
|
|
381
|
+
}, _callee3, this);
|
|
364
382
|
}));
|
|
365
|
-
function initializeFromGetLociResponse(
|
|
383
|
+
function initializeFromGetLociResponse(_x4) {
|
|
366
384
|
return _initializeFromGetLociResponse.apply(this, arguments);
|
|
367
385
|
}
|
|
368
386
|
return initializeFromGetLociResponse;
|
|
@@ -378,24 +396,23 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
378
396
|
}, {
|
|
379
397
|
key: "initializeDataSets",
|
|
380
398
|
value: (function () {
|
|
381
|
-
var _initializeDataSets = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
382
|
-
var
|
|
383
|
-
return _regenerator.default.wrap(function (
|
|
384
|
-
while (1) switch (
|
|
399
|
+
var _initializeDataSets = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4(visibleDataSets, debugText) {
|
|
400
|
+
var _iterator2, _step2, dataSet, name, leafCount, url, _t;
|
|
401
|
+
return _regenerator.default.wrap(function (_context4) {
|
|
402
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
385
403
|
case 0:
|
|
386
404
|
if (!(this.state === 'stopped')) {
|
|
387
|
-
|
|
405
|
+
_context4.next = 1;
|
|
388
406
|
break;
|
|
389
407
|
}
|
|
390
|
-
return
|
|
408
|
+
return _context4.abrupt("return");
|
|
391
409
|
case 1:
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
_context3.prev = 2;
|
|
410
|
+
_iterator2 = _createForOfIteratorHelper((0, _utils.sortByInitPriority)(visibleDataSets, _constants3.DATA_SET_INIT_PRIORITY));
|
|
411
|
+
_context4.prev = 2;
|
|
395
412
|
_iterator2.s();
|
|
396
413
|
case 3:
|
|
397
414
|
if ((_step2 = _iterator2.n()).done) {
|
|
398
|
-
|
|
415
|
+
_context4.next = 6;
|
|
399
416
|
break;
|
|
400
417
|
}
|
|
401
418
|
dataSet = _step2.value;
|
|
@@ -407,59 +424,47 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
407
424
|
_loggerProxy.default.logger.info("HashTreeParser#initializeDataSets --> ".concat(this.debugId, " dataset \"").concat(name, "\" already exists (").concat(debugText, ")"));
|
|
408
425
|
}
|
|
409
426
|
if (this.isVisibleDataSet(name)) {
|
|
410
|
-
|
|
427
|
+
_context4.next = 4;
|
|
411
428
|
break;
|
|
412
429
|
}
|
|
413
430
|
if (this.addToVisibleDataSetsList({
|
|
414
431
|
name: name,
|
|
415
432
|
url: url
|
|
416
433
|
})) {
|
|
417
|
-
|
|
434
|
+
_context4.next = 4;
|
|
418
435
|
break;
|
|
419
436
|
}
|
|
420
|
-
return
|
|
437
|
+
return _context4.abrupt("continue", 5);
|
|
421
438
|
case 4:
|
|
422
|
-
if (this.dataSets[name].hashTree) {
|
|
423
|
-
|
|
424
|
-
|
|
439
|
+
if (!this.dataSets[name].hashTree) {
|
|
440
|
+
_loggerProxy.default.logger.info("HashTreeParser#initializeDataSets --> ".concat(this.debugId, " creating hash tree for visible dataset \"").concat(name, "\" (").concat(debugText, ")"));
|
|
441
|
+
this.dataSets[name].hashTree = new _hashTree.default([], leafCount);
|
|
442
|
+
this.enqueueSyncForDataset(name, "initialization sync for ".concat(debugText), true);
|
|
425
443
|
}
|
|
426
|
-
_loggerProxy.default.logger.info("HashTreeParser#initializeDataSets --> ".concat(this.debugId, " creating hash tree for visible dataset \"").concat(name, "\" (").concat(debugText, ")"));
|
|
427
|
-
this.dataSets[name].hashTree = new _hashTree.default([], leafCount);
|
|
428
|
-
|
|
429
|
-
// eslint-disable-next-line no-await-in-loop
|
|
430
|
-
_context3.next = 5;
|
|
431
|
-
return this.sendInitializationSyncRequestToLocus(name, debugText);
|
|
432
444
|
case 5:
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
updatedObjects.push.apply(updatedObjects, (0, _toConsumableArray2.default)(_data.updatedObjects || []));
|
|
436
|
-
}
|
|
445
|
+
_context4.next = 3;
|
|
446
|
+
break;
|
|
437
447
|
case 6:
|
|
438
|
-
|
|
448
|
+
_context4.next = 8;
|
|
439
449
|
break;
|
|
440
450
|
case 7:
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
case 8:
|
|
444
|
-
_context3.prev = 8;
|
|
445
|
-
_t = _context3["catch"](2);
|
|
451
|
+
_context4.prev = 7;
|
|
452
|
+
_t = _context4["catch"](2);
|
|
446
453
|
_iterator2.e(_t);
|
|
447
|
-
case
|
|
448
|
-
|
|
454
|
+
case 8:
|
|
455
|
+
_context4.prev = 8;
|
|
449
456
|
_iterator2.f();
|
|
450
|
-
return
|
|
457
|
+
return _context4.finish(8);
|
|
458
|
+
case 9:
|
|
459
|
+
_context4.next = 10;
|
|
460
|
+
return this.syncQueueProcessingPromise;
|
|
451
461
|
case 10:
|
|
452
|
-
this.callLocusInfoUpdateCallback({
|
|
453
|
-
updateType: LocusInfoUpdateType.OBJECTS_UPDATED,
|
|
454
|
-
updatedObjects: updatedObjects
|
|
455
|
-
});
|
|
456
|
-
case 11:
|
|
457
462
|
case "end":
|
|
458
|
-
return
|
|
463
|
+
return _context4.stop();
|
|
459
464
|
}
|
|
460
|
-
},
|
|
465
|
+
}, _callee4, this, [[2, 7, 8, 9]]);
|
|
461
466
|
}));
|
|
462
|
-
function initializeDataSets(
|
|
467
|
+
function initializeDataSets(_x5, _x6) {
|
|
463
468
|
return _initializeDataSets.apply(this, arguments);
|
|
464
469
|
}
|
|
465
470
|
return initializeDataSets;
|
|
@@ -483,7 +488,7 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
483
488
|
copyData = _ref$copyData === void 0 ? false : _ref$copyData;
|
|
484
489
|
// object mapping dataset names to arrays of leaf data
|
|
485
490
|
var leafInfo = {};
|
|
486
|
-
var _findAndStoreMetaData = function findAndStoreMetaData(currentLocusPart) {
|
|
491
|
+
var _findAndStoreMetaData = function findAndStoreMetaData(currentLocusPart, currentLocusPartName) {
|
|
487
492
|
if ((0, _typeof2.default)(currentLocusPart) !== 'object' || currentLocusPart === null) {
|
|
488
493
|
return;
|
|
489
494
|
}
|
|
@@ -499,10 +504,16 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
499
504
|
version: version
|
|
500
505
|
};
|
|
501
506
|
if (copyData) {
|
|
502
|
-
|
|
507
|
+
if (type.toLowerCase() === _types.ObjectType.control) {
|
|
508
|
+
// control entries require special handling, because they are signalled by Locus
|
|
509
|
+
// differently when coming in messages vs API responses
|
|
510
|
+
newLeafInfo.data = (0, _defineProperty2.default)({}, currentLocusPartName, (0, _lodash.cloneDeep)(currentLocusPart));
|
|
511
|
+
} else {
|
|
512
|
+
newLeafInfo.data = (0, _lodash.cloneDeep)(currentLocusPart);
|
|
503
513
|
|
|
504
|
-
|
|
505
|
-
|
|
514
|
+
// remove any nested other objects that have their own htMeta
|
|
515
|
+
(0, _utils.deleteNestedObjectsWithHtMeta)(newLeafInfo.data);
|
|
516
|
+
}
|
|
506
517
|
}
|
|
507
518
|
var _iterator3 = _createForOfIteratorHelper(dataSetNames),
|
|
508
519
|
_step3;
|
|
@@ -521,12 +532,14 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
521
532
|
}
|
|
522
533
|
}
|
|
523
534
|
if ((0, _isArray.default)(currentLocusPart)) {
|
|
524
|
-
var _iterator4 = _createForOfIteratorHelper(currentLocusPart),
|
|
535
|
+
var _iterator4 = _createForOfIteratorHelper(currentLocusPart.entries()),
|
|
525
536
|
_step4;
|
|
526
537
|
try {
|
|
527
538
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
528
|
-
var
|
|
529
|
-
|
|
539
|
+
var _step4$value = (0, _slicedToArray2.default)(_step4.value, 2),
|
|
540
|
+
index = _step4$value[0],
|
|
541
|
+
item = _step4$value[1];
|
|
542
|
+
_findAndStoreMetaData(item, index.toString());
|
|
530
543
|
}
|
|
531
544
|
} catch (err) {
|
|
532
545
|
_iterator4.e(err);
|
|
@@ -537,12 +550,12 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
537
550
|
for (var _i = 0, _Object$keys = (0, _keys.default)(currentLocusPart); _i < _Object$keys.length; _i++) {
|
|
538
551
|
var key = _Object$keys[_i];
|
|
539
552
|
if (Object.prototype.hasOwnProperty.call(currentLocusPart, key)) {
|
|
540
|
-
_findAndStoreMetaData(currentLocusPart[key]);
|
|
553
|
+
_findAndStoreMetaData(currentLocusPart[key], key);
|
|
541
554
|
}
|
|
542
555
|
}
|
|
543
556
|
}
|
|
544
557
|
};
|
|
545
|
-
_findAndStoreMetaData(locus);
|
|
558
|
+
_findAndStoreMetaData(locus, 'locus');
|
|
546
559
|
return leafInfo;
|
|
547
560
|
}
|
|
548
561
|
|
|
@@ -587,9 +600,9 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
587
600
|
}, {
|
|
588
601
|
key: "isEndMessage",
|
|
589
602
|
value: function isEndMessage(message) {
|
|
590
|
-
var
|
|
603
|
+
var _this3 = this;
|
|
591
604
|
return message.dataSets.some(function (dataSet) {
|
|
592
|
-
if (dataSet.leafCount === 1 && dataSet.root ===
|
|
605
|
+
if (dataSet.leafCount === 1 && dataSet.root === _constants3.EMPTY_HASH && (!_this3.dataSets[dataSet.name] || _this3.dataSets[dataSet.name].version < dataSet.version) && PossibleSentinelMessageDataSetNames.includes(dataSet.name.toLowerCase())) {
|
|
593
606
|
// this is a special way for Locus to indicate that this meeting has ended
|
|
594
607
|
return true;
|
|
595
608
|
}
|
|
@@ -606,7 +619,7 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
606
619
|
}, {
|
|
607
620
|
key: "handleRootHashHeartBeatMessage",
|
|
608
621
|
value: function handleRootHashHeartBeatMessage(message) {
|
|
609
|
-
var
|
|
622
|
+
var _this4 = this;
|
|
610
623
|
var dataSets = message.dataSets;
|
|
611
624
|
_loggerProxy.default.logger.info("HashTreeParser#handleRootHashMessage --> ".concat(this.debugId, " Received heartbeat root hash message with data sets: ").concat((0, _stringify.default)(dataSets.map(function (_ref2) {
|
|
612
625
|
var name = _ref2.name,
|
|
@@ -620,12 +633,40 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
620
633
|
version: version
|
|
621
634
|
};
|
|
622
635
|
}))));
|
|
636
|
+
this.cancelPendingSyncsForDataSets(dataSets.map(function (ds) {
|
|
637
|
+
return ds.name;
|
|
638
|
+
}));
|
|
623
639
|
dataSets.forEach(function (dataSet) {
|
|
624
|
-
|
|
625
|
-
|
|
640
|
+
_this4.updateDataSetInfo(dataSet);
|
|
641
|
+
_this4.runSyncAlgorithm(dataSet);
|
|
626
642
|
});
|
|
627
643
|
}
|
|
628
644
|
|
|
645
|
+
/**
|
|
646
|
+
* Handles known errors that can happen during syncs
|
|
647
|
+
*
|
|
648
|
+
* @param {any} error - The error to handle
|
|
649
|
+
* @returns {boolean} true if the error was recognized and handled, false otherwise
|
|
650
|
+
*/
|
|
651
|
+
}, {
|
|
652
|
+
key: "handleSyncErrors",
|
|
653
|
+
value: function handleSyncErrors(error) {
|
|
654
|
+
if (error instanceof MeetingEndedError) {
|
|
655
|
+
this.callLocusInfoUpdateCallback({
|
|
656
|
+
updateType: LocusInfoUpdateType.MEETING_ENDED
|
|
657
|
+
});
|
|
658
|
+
return true;
|
|
659
|
+
}
|
|
660
|
+
if (error instanceof LocusNotFoundError) {
|
|
661
|
+
this.callLocusInfoUpdateCallback({
|
|
662
|
+
updateType: LocusInfoUpdateType.LOCUS_NOT_FOUND
|
|
663
|
+
});
|
|
664
|
+
this.stop();
|
|
665
|
+
return true;
|
|
666
|
+
}
|
|
667
|
+
return false;
|
|
668
|
+
}
|
|
669
|
+
|
|
629
670
|
/**
|
|
630
671
|
* Asynchronously initializes new visible data sets
|
|
631
672
|
*
|
|
@@ -635,18 +676,14 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
635
676
|
}, {
|
|
636
677
|
key: "queueInitForNewVisibleDataSets",
|
|
637
678
|
value: function queueInitForNewVisibleDataSets(dataSetsRequiringInitialization) {
|
|
638
|
-
var
|
|
679
|
+
var _this5 = this;
|
|
639
680
|
_loggerProxy.default.logger.info("HashTreeParser#queueInitForNewVisibleDataSets --> ".concat(this.debugId, " queuing initialization of new visible datasets: ").concat(dataSetsRequiringInitialization.map(function (ds) {
|
|
640
681
|
return ds.name;
|
|
641
682
|
}).join(', ')));
|
|
642
683
|
queueMicrotask(function () {
|
|
643
|
-
|
|
644
|
-
if (error
|
|
645
|
-
|
|
646
|
-
updateType: LocusInfoUpdateType.MEETING_ENDED
|
|
647
|
-
});
|
|
648
|
-
} else {
|
|
649
|
-
_loggerProxy.default.logger.warn("HashTreeParser#queueInitForNewVisibleDataSets --> ".concat(_this6.debugId, " error while initializing new visible datasets: ").concat(dataSetsRequiringInitialization.map(function (ds) {
|
|
684
|
+
_this5.initializeNewVisibleDataSets(dataSetsRequiringInitialization).catch(function (error) {
|
|
685
|
+
if (!_this5.handleSyncErrors(error)) {
|
|
686
|
+
_loggerProxy.default.logger.warn("HashTreeParser#queueInitForNewVisibleDataSets --> ".concat(_this5.debugId, " error while initializing new visible datasets: ").concat(dataSetsRequiringInitialization.map(function (ds) {
|
|
650
687
|
return ds.name;
|
|
651
688
|
}).join(', '), ": "), error);
|
|
652
689
|
}
|
|
@@ -706,14 +743,18 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
706
743
|
}, {
|
|
707
744
|
key: "handleLocusUpdate",
|
|
708
745
|
value: function handleLocusUpdate(update) {
|
|
709
|
-
var
|
|
746
|
+
var _this6 = this;
|
|
710
747
|
if (this.state === 'stopped') {
|
|
711
748
|
return;
|
|
712
749
|
}
|
|
713
750
|
var dataSets = update.dataSets,
|
|
714
751
|
locus = update.locus,
|
|
715
752
|
metadata = update.metadata;
|
|
753
|
+
_loggerProxy.default.logger.info("HashTreeParser#handleLocusUpdate --> ".concat(this.debugId, " received update with dataSets=").concat(dataSets === null || dataSets === void 0 ? void 0 : dataSets.map(function (ds) {
|
|
754
|
+
return ds.name;
|
|
755
|
+
}).join(','), " metadata=").concat(metadata ? 'yes' : 'no'));
|
|
716
756
|
if (!dataSets) {
|
|
757
|
+
// this happens for example when we handle GET /loci response
|
|
717
758
|
_loggerProxy.default.logger.info("HashTreeParser#handleLocusUpdate --> ".concat(this.debugId, " received hash tree update without dataSets"));
|
|
718
759
|
} else {
|
|
719
760
|
var _iterator5 = _createForOfIteratorHelper(dataSets),
|
|
@@ -743,9 +784,9 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
743
784
|
|
|
744
785
|
// then process the data in hash trees, if it is a new version, then add it to updatedObjects
|
|
745
786
|
(0, _keys.default)(leafInfo).forEach(function (dataSetName) {
|
|
746
|
-
if (
|
|
747
|
-
if (
|
|
748
|
-
var appliedChangesList =
|
|
787
|
+
if (_this6.dataSets[dataSetName]) {
|
|
788
|
+
if (_this6.dataSets[dataSetName].hashTree) {
|
|
789
|
+
var appliedChangesList = _this6.dataSets[dataSetName].hashTree.putItems(leafInfo[dataSetName].map(function (leaf) {
|
|
749
790
|
return {
|
|
750
791
|
id: leaf.id,
|
|
751
792
|
type: leaf.type,
|
|
@@ -772,10 +813,10 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
772
813
|
});
|
|
773
814
|
} else {
|
|
774
815
|
// no hash tree means that the data set is not visible
|
|
775
|
-
_loggerProxy.default.logger.warn("HashTreeParser#handleLocusUpdate --> ".concat(
|
|
816
|
+
_loggerProxy.default.logger.warn("HashTreeParser#handleLocusUpdate --> ".concat(_this6.debugId, " received leaf data for data set \"").concat(dataSetName, "\" that has no hash tree created, ignoring"));
|
|
776
817
|
}
|
|
777
818
|
} else {
|
|
778
|
-
_loggerProxy.default.logger.info("HashTreeParser#handleLocusUpdate --> ".concat(
|
|
819
|
+
_loggerProxy.default.logger.info("HashTreeParser#handleLocusUpdate --> ".concat(_this6.debugId, " received leaf data for unknown data set \"").concat(dataSetName, "\", ignoring"));
|
|
779
820
|
}
|
|
780
821
|
});
|
|
781
822
|
if (updatedObjects.length === 0) {
|
|
@@ -811,10 +852,26 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
811
852
|
maxMs: receivedDataSet.backoff.maxMs,
|
|
812
853
|
exponent: receivedDataSet.backoff.exponent
|
|
813
854
|
};
|
|
855
|
+
this.dataSets[receivedDataSet.name].heartbeatIntervalMs = receivedDataSet.heartbeatIntervalMs;
|
|
814
856
|
_loggerProxy.default.logger.info("HashTreeParser#updateDataSetInfo --> ".concat(this.debugId, " updated \"").concat(receivedDataSet.name, "\" dataset to version=").concat(receivedDataSet.version, ", root=").concat(receivedDataSet.root));
|
|
815
857
|
}
|
|
816
858
|
}
|
|
817
859
|
|
|
860
|
+
/**
|
|
861
|
+
* Updates the leaf count for a data set, resizing its hash tree accordingly.
|
|
862
|
+
*
|
|
863
|
+
* @param {InternalDataSet} dataSet - The data set to update
|
|
864
|
+
* @param {number} newLeafCount - The new leaf count
|
|
865
|
+
* @returns {void}
|
|
866
|
+
*/
|
|
867
|
+
}, {
|
|
868
|
+
key: "updateDataSetLeafCount",
|
|
869
|
+
value: function updateDataSetLeafCount(dataSet, newLeafCount) {
|
|
870
|
+
var _dataSet$hashTree;
|
|
871
|
+
(_dataSet$hashTree = dataSet.hashTree) === null || _dataSet$hashTree === void 0 ? void 0 : _dataSet$hashTree.resize(newLeafCount);
|
|
872
|
+
dataSet.leafCount = newLeafCount;
|
|
873
|
+
}
|
|
874
|
+
|
|
818
875
|
/**
|
|
819
876
|
* Checks for changes in the visible data sets based on the updated objects.
|
|
820
877
|
* @param {HashTreeObject[]} updatedObjects - The list of updated hash tree objects.
|
|
@@ -823,7 +880,7 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
823
880
|
}, {
|
|
824
881
|
key: "checkForVisibleDataSetChanges",
|
|
825
882
|
value: function checkForVisibleDataSetChanges(updatedObjects) {
|
|
826
|
-
var
|
|
883
|
+
var _this7 = this;
|
|
827
884
|
var removedDataSets = [];
|
|
828
885
|
var addedDataSets = [];
|
|
829
886
|
|
|
@@ -832,20 +889,20 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
832
889
|
var _object$data;
|
|
833
890
|
if ((0, _utils.isMetadata)(object) && (_object$data = object.data) !== null && _object$data !== void 0 && _object$data.visibleDataSets) {
|
|
834
891
|
var newVisibleDataSets = object.data.visibleDataSets.filter(function (vds) {
|
|
835
|
-
return !
|
|
892
|
+
return !_this7.isExcludedDataSet(vds.name);
|
|
836
893
|
});
|
|
837
|
-
removedDataSets =
|
|
894
|
+
removedDataSets = _this7.visibleDataSets.filter(function (ds) {
|
|
838
895
|
return !newVisibleDataSets.some(function (nvs) {
|
|
839
896
|
return nvs.name === ds.name;
|
|
840
897
|
});
|
|
841
898
|
});
|
|
842
899
|
addedDataSets = newVisibleDataSets.filter(function (nvs) {
|
|
843
|
-
return
|
|
900
|
+
return _this7.visibleDataSets.every(function (ds) {
|
|
844
901
|
return ds.name !== nvs.name;
|
|
845
902
|
});
|
|
846
903
|
});
|
|
847
904
|
if (removedDataSets.length > 0 || addedDataSets.length > 0) {
|
|
848
|
-
_loggerProxy.default.logger.info("HashTreeParser#checkForVisibleDataSetChanges --> ".concat(
|
|
905
|
+
_loggerProxy.default.logger.info("HashTreeParser#checkForVisibleDataSetChanges --> ".concat(_this7.debugId, " visible data sets change: removed: ").concat(removedDataSets.map(function (ds) {
|
|
849
906
|
return ds.name;
|
|
850
907
|
}).join(', '), ", added: ").concat(addedDataSets.map(function (ds) {
|
|
851
908
|
return ds.name;
|
|
@@ -869,7 +926,10 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
869
926
|
}, {
|
|
870
927
|
key: "deleteHashTree",
|
|
871
928
|
value: function deleteHashTree(dataSetName) {
|
|
929
|
+
var _this$dataSets$dataSe;
|
|
872
930
|
this.dataSets[dataSetName].hashTree = undefined;
|
|
931
|
+
(_this$dataSets$dataSe = this.dataSets[dataSetName].syncAbortController) === null || _this$dataSets$dataSe === void 0 ? void 0 : _this$dataSets$dataSe.abort();
|
|
932
|
+
this.dataSets[dataSetName].syncAbortController = undefined;
|
|
873
933
|
|
|
874
934
|
// we also need to stop the timers as there is no hash tree anymore to sync
|
|
875
935
|
if (this.dataSets[dataSetName].timer) {
|
|
@@ -899,16 +959,16 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
899
959
|
}, {
|
|
900
960
|
key: "processVisibleDataSetChanges",
|
|
901
961
|
value: function processVisibleDataSetChanges(removedDataSets, addedDataSets, updatedObjects) {
|
|
902
|
-
var
|
|
962
|
+
var _this8 = this;
|
|
903
963
|
var dataSetsRequiringInitialization = [];
|
|
904
964
|
|
|
905
965
|
// if a visible data set was removed, we need to tell our client that all objects from it are removed
|
|
906
966
|
var removedObjects = [];
|
|
907
967
|
removedDataSets.forEach(function (ds) {
|
|
908
|
-
var
|
|
909
|
-
if ((
|
|
910
|
-
for (var i = 0; i <
|
|
911
|
-
removedObjects.push.apply(removedObjects, (0, _toConsumableArray2.default)(
|
|
968
|
+
var _this8$dataSets$ds$na;
|
|
969
|
+
if ((_this8$dataSets$ds$na = _this8.dataSets[ds.name]) !== null && _this8$dataSets$ds$na !== void 0 && _this8$dataSets$ds$na.hashTree) {
|
|
970
|
+
for (var i = 0; i < _this8.dataSets[ds.name].hashTree.numLeaves; i += 1) {
|
|
971
|
+
removedObjects.push.apply(removedObjects, (0, _toConsumableArray2.default)(_this8.dataSets[ds.name].hashTree.getLeafData(i).map(function (elementId) {
|
|
912
972
|
return {
|
|
913
973
|
htMeta: {
|
|
914
974
|
elementId: elementId,
|
|
@@ -918,7 +978,7 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
918
978
|
};
|
|
919
979
|
})));
|
|
920
980
|
}
|
|
921
|
-
|
|
981
|
+
_this8.deleteHashTree(ds.name);
|
|
922
982
|
}
|
|
923
983
|
});
|
|
924
984
|
this.visibleDataSets = this.visibleDataSets.filter(function (vds) {
|
|
@@ -979,81 +1039,78 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
979
1039
|
}, {
|
|
980
1040
|
key: "initializeNewVisibleDataSets",
|
|
981
1041
|
value: (function () {
|
|
982
|
-
var _initializeNewVisibleDataSets = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
983
|
-
var
|
|
1042
|
+
var _initializeNewVisibleDataSets = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5(addedDataSets) {
|
|
1043
|
+
var _this9 = this;
|
|
984
1044
|
var allDataSets, _iterator7, _step7, _loop, _t2;
|
|
985
|
-
return _regenerator.default.wrap(function (
|
|
986
|
-
while (1) switch (
|
|
1045
|
+
return _regenerator.default.wrap(function (_context6) {
|
|
1046
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
987
1047
|
case 0:
|
|
988
1048
|
if (!(this.state === 'stopped')) {
|
|
989
|
-
|
|
1049
|
+
_context6.next = 1;
|
|
990
1050
|
break;
|
|
991
1051
|
}
|
|
992
|
-
return
|
|
1052
|
+
return _context6.abrupt("return");
|
|
993
1053
|
case 1:
|
|
994
|
-
|
|
1054
|
+
_context6.next = 2;
|
|
995
1055
|
return this.getAllVisibleDataSetsFromLocus();
|
|
996
1056
|
case 2:
|
|
997
|
-
allDataSets =
|
|
998
|
-
_iterator7 = _createForOfIteratorHelper(addedDataSets);
|
|
999
|
-
|
|
1057
|
+
allDataSets = _context6.sent;
|
|
1058
|
+
_iterator7 = _createForOfIteratorHelper((0, _utils.sortByInitPriority)(addedDataSets, _constants3.DATA_SET_INIT_PRIORITY));
|
|
1059
|
+
_context6.prev = 3;
|
|
1000
1060
|
_loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
|
|
1001
|
-
var ds, dataSetInfo
|
|
1002
|
-
return _regenerator.default.wrap(function (
|
|
1003
|
-
while (1) switch (
|
|
1061
|
+
var ds, dataSetInfo;
|
|
1062
|
+
return _regenerator.default.wrap(function (_context5) {
|
|
1063
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
1004
1064
|
case 0:
|
|
1005
1065
|
ds = _step7.value;
|
|
1006
1066
|
dataSetInfo = allDataSets.find(function (d) {
|
|
1007
1067
|
return d.name === ds.name;
|
|
1008
1068
|
});
|
|
1009
|
-
_loggerProxy.default.logger.info("HashTreeParser#initializeNewVisibleDataSets --> ".concat(
|
|
1069
|
+
_loggerProxy.default.logger.info("HashTreeParser#initializeNewVisibleDataSets --> ".concat(_this9.debugId, " initializing data set \"").concat(ds.name, "\""));
|
|
1010
1070
|
if (dataSetInfo) {
|
|
1011
|
-
|
|
1071
|
+
_context5.next = 1;
|
|
1012
1072
|
break;
|
|
1013
1073
|
}
|
|
1014
|
-
_loggerProxy.default.logger.warn("HashTreeParser#initializeNewVisibleDataSets --> ".concat(
|
|
1015
|
-
|
|
1074
|
+
_loggerProxy.default.logger.warn("HashTreeParser#initializeNewVisibleDataSets --> ".concat(_this9.debugId, " missing info about data set \"").concat(ds.name, "\" in Locus response from visibleDataSetsUrl"));
|
|
1075
|
+
_context5.next = 2;
|
|
1016
1076
|
break;
|
|
1017
1077
|
case 1:
|
|
1018
|
-
|
|
1019
|
-
return
|
|
1078
|
+
_context5.next = 2;
|
|
1079
|
+
return _this9.initializeNewVisibleDataSet(ds, dataSetInfo);
|
|
1020
1080
|
case 2:
|
|
1021
|
-
updates = _context4.sent;
|
|
1022
|
-
_this0.callLocusInfoUpdateCallback(updates);
|
|
1023
|
-
case 3:
|
|
1024
1081
|
case "end":
|
|
1025
|
-
return
|
|
1082
|
+
return _context5.stop();
|
|
1026
1083
|
}
|
|
1027
1084
|
}, _loop);
|
|
1028
1085
|
});
|
|
1029
1086
|
_iterator7.s();
|
|
1030
1087
|
case 4:
|
|
1031
1088
|
if ((_step7 = _iterator7.n()).done) {
|
|
1032
|
-
|
|
1089
|
+
_context6.next = 6;
|
|
1033
1090
|
break;
|
|
1034
1091
|
}
|
|
1035
|
-
return
|
|
1092
|
+
return _context6.delegateYield(_loop(), "t0", 5);
|
|
1036
1093
|
case 5:
|
|
1037
|
-
|
|
1094
|
+
_context6.next = 4;
|
|
1038
1095
|
break;
|
|
1039
1096
|
case 6:
|
|
1040
|
-
|
|
1097
|
+
_context6.next = 8;
|
|
1041
1098
|
break;
|
|
1042
1099
|
case 7:
|
|
1043
|
-
|
|
1044
|
-
_t2 =
|
|
1100
|
+
_context6.prev = 7;
|
|
1101
|
+
_t2 = _context6["catch"](3);
|
|
1045
1102
|
_iterator7.e(_t2);
|
|
1046
1103
|
case 8:
|
|
1047
|
-
|
|
1104
|
+
_context6.prev = 8;
|
|
1048
1105
|
_iterator7.f();
|
|
1049
|
-
return
|
|
1106
|
+
return _context6.finish(8);
|
|
1050
1107
|
case 9:
|
|
1051
1108
|
case "end":
|
|
1052
|
-
return
|
|
1109
|
+
return _context6.stop();
|
|
1053
1110
|
}
|
|
1054
|
-
},
|
|
1111
|
+
}, _callee5, this, [[3, 7, 8, 9]]);
|
|
1055
1112
|
}));
|
|
1056
|
-
function initializeNewVisibleDataSets(
|
|
1113
|
+
function initializeNewVisibleDataSets(_x7) {
|
|
1057
1114
|
return _initializeNewVisibleDataSets.apply(this, arguments);
|
|
1058
1115
|
}
|
|
1059
1116
|
return initializeNewVisibleDataSets;
|
|
@@ -1069,25 +1126,37 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1069
1126
|
}, {
|
|
1070
1127
|
key: "parseMessage",
|
|
1071
1128
|
value: function parseMessage(message, debugText) {
|
|
1072
|
-
var _message$
|
|
1073
|
-
|
|
1074
|
-
_message$locusStateEl2
|
|
1129
|
+
var _message$dataSets,
|
|
1130
|
+
_message$locusStateEl,
|
|
1131
|
+
_message$locusStateEl2,
|
|
1132
|
+
_this0 = this;
|
|
1075
1133
|
if (this.state === 'stopped') {
|
|
1076
1134
|
return [];
|
|
1077
1135
|
}
|
|
1078
1136
|
var dataSets = message.dataSets,
|
|
1079
1137
|
visibleDataSetsUrl = message.visibleDataSetsUrl;
|
|
1080
|
-
_loggerProxy.default.logger.info("HashTreeParser#parseMessage --> ".concat(this.debugId, "
|
|
1081
|
-
|
|
1138
|
+
_loggerProxy.default.logger.info("HashTreeParser#parseMessage --> ".concat(this.debugId, " ").concat(debugText || '', " dataSets: ").concat((_message$dataSets = message.dataSets) === null || _message$dataSets === void 0 ? void 0 : _message$dataSets.map(function (_ref5) {
|
|
1139
|
+
var name = _ref5.name,
|
|
1140
|
+
version = _ref5.version;
|
|
1141
|
+
return "".concat(name, ":").concat(version);
|
|
1142
|
+
}).join(','), ", elements: ").concat((_message$locusStateEl = message.locusStateElements) === null || _message$locusStateEl === void 0 ? void 0 : _message$locusStateEl.map(function (el) {
|
|
1143
|
+
return "".concat(el.htMeta.elementId.type, ":").concat(el.htMeta.elementId.id, ":").concat(el.htMeta.elementId.version).concat(el.data ? '+' : '-');
|
|
1144
|
+
}).join(',')));
|
|
1145
|
+
if (((_message$locusStateEl2 = message.locusStateElements) === null || _message$locusStateEl2 === void 0 ? void 0 : _message$locusStateEl2.length) === 0) {
|
|
1082
1146
|
_loggerProxy.default.logger.warn("HashTreeParser#parseMessage --> ".concat(this.debugId, " got empty locusStateElements!!!"));
|
|
1083
|
-
|
|
1147
|
+
_metrics.default.sendBehavioralMetric(_constants.default.HASH_TREE_EMPTY_LOCUS_STATE_ELEMENTS, {
|
|
1148
|
+
debugId: this.debugId
|
|
1149
|
+
});
|
|
1084
1150
|
}
|
|
1085
1151
|
|
|
1086
1152
|
// first, update our metadata about the datasets with info from the message
|
|
1087
1153
|
this.visibleDataSetsUrl = visibleDataSetsUrl;
|
|
1088
1154
|
dataSets.forEach(function (dataSet) {
|
|
1089
|
-
return
|
|
1155
|
+
return _this0.updateDataSetInfo(dataSet);
|
|
1090
1156
|
});
|
|
1157
|
+
this.cancelPendingSyncsForDataSets(dataSets.map(function (ds) {
|
|
1158
|
+
return ds.name;
|
|
1159
|
+
}));
|
|
1091
1160
|
var updatedObjects = [];
|
|
1092
1161
|
|
|
1093
1162
|
// when we detect new visible datasets, it may be that the metadata about them is not
|
|
@@ -1106,9 +1175,9 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1106
1175
|
_step8;
|
|
1107
1176
|
try {
|
|
1108
1177
|
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
1109
|
-
var
|
|
1178
|
+
var _this0$dataSets$dataS;
|
|
1110
1179
|
var dataSetName = _step8.value;
|
|
1111
|
-
var hashTree = (
|
|
1180
|
+
var hashTree = (_this0$dataSets$dataS = _this0.dataSets[dataSetName]) === null || _this0$dataSets$dataS === void 0 ? void 0 : _this0$dataSets$dataS.hashTree;
|
|
1112
1181
|
if (hashTree && object.data) {
|
|
1113
1182
|
if (hashTree.putItem(object.htMeta.elementId)) {
|
|
1114
1183
|
updatedMetadataObjects.push(object);
|
|
@@ -1130,13 +1199,13 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1130
1199
|
dataSetsRequiringInitialization = this.processVisibleDataSetChanges(removedDataSets, addedDataSets, updatedObjects);
|
|
1131
1200
|
}
|
|
1132
1201
|
}
|
|
1133
|
-
if (
|
|
1202
|
+
if (message.locusStateElements && message.locusStateElements.length > 0) {
|
|
1134
1203
|
// by this point we now have this.dataSets setup for data sets from this message
|
|
1135
1204
|
// and hash trees created for the new visible data sets,
|
|
1136
1205
|
// so we can now process all the updates from the message
|
|
1137
1206
|
dataSets.forEach(function (dataSet) {
|
|
1138
|
-
if (
|
|
1139
|
-
var hashTree =
|
|
1207
|
+
if (_this0.dataSets[dataSet.name]) {
|
|
1208
|
+
var hashTree = _this0.dataSets[dataSet.name].hashTree;
|
|
1140
1209
|
if (hashTree) {
|
|
1141
1210
|
var locusStateElementsForThisSet = message.locusStateElements.filter(function (object) {
|
|
1142
1211
|
return object.htMeta.dataSetNames.includes(dataSet.name);
|
|
@@ -1150,20 +1219,20 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1150
1219
|
item: object.htMeta.elementId
|
|
1151
1220
|
};
|
|
1152
1221
|
}));
|
|
1153
|
-
(0, _lodash.zip)(appliedChangesList, locusStateElementsForThisSet).forEach(function (
|
|
1154
|
-
var
|
|
1155
|
-
changeApplied =
|
|
1156
|
-
object =
|
|
1222
|
+
(0, _lodash.zip)(appliedChangesList, locusStateElementsForThisSet).forEach(function (_ref6) {
|
|
1223
|
+
var _ref7 = (0, _slicedToArray2.default)(_ref6, 2),
|
|
1224
|
+
changeApplied = _ref7[0],
|
|
1225
|
+
object = _ref7[1];
|
|
1157
1226
|
if (changeApplied) {
|
|
1158
1227
|
// add to updatedObjects so that our locus DTO will get updated with the new object
|
|
1159
1228
|
updatedObjects.push(object);
|
|
1160
1229
|
}
|
|
1161
1230
|
});
|
|
1162
1231
|
} else {
|
|
1163
|
-
_loggerProxy.default.logger.info("Locus-info:index#parseMessage --> ".concat(
|
|
1232
|
+
_loggerProxy.default.logger.info("Locus-info:index#parseMessage --> ".concat(_this0.debugId, " unexpected (not visible) dataSet ").concat(dataSet.name, " received in hash tree message"));
|
|
1164
1233
|
}
|
|
1165
1234
|
}
|
|
1166
|
-
|
|
1235
|
+
_this0.runSyncAlgorithm(dataSet);
|
|
1167
1236
|
});
|
|
1168
1237
|
}
|
|
1169
1238
|
if (dataSetsRequiringInitialization.length > 0) {
|
|
@@ -1189,8 +1258,8 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1189
1258
|
if (this.state === 'stopped') {
|
|
1190
1259
|
return;
|
|
1191
1260
|
}
|
|
1192
|
-
if (message.heartbeatIntervalMs) {
|
|
1193
|
-
this.
|
|
1261
|
+
if (message.heartbeatIntervalMs !== undefined) {
|
|
1262
|
+
this.topLevelHeartbeatIntervalMs = message.heartbeatIntervalMs;
|
|
1194
1263
|
}
|
|
1195
1264
|
if (this.isEndMessage(message)) {
|
|
1196
1265
|
_loggerProxy.default.logger.info("HashTreeParser#handleMessage --> ".concat(this.debugId, " received sentinel END MEETING message"));
|
|
@@ -1220,25 +1289,25 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1220
1289
|
}, {
|
|
1221
1290
|
key: "callLocusInfoUpdateCallback",
|
|
1222
1291
|
value: function callLocusInfoUpdateCallback(updates) {
|
|
1223
|
-
var
|
|
1292
|
+
var _updates$updatedObjec,
|
|
1293
|
+
_this1 = this;
|
|
1224
1294
|
if (this.state === 'stopped') {
|
|
1225
1295
|
return;
|
|
1226
1296
|
}
|
|
1227
|
-
var updateType = updates.updateType
|
|
1228
|
-
|
|
1229
|
-
if (updateType === LocusInfoUpdateType.OBJECTS_UPDATED && (updatedObjects === null || updatedObjects === void 0 ? void 0 : updatedObjects.length) > 0) {
|
|
1297
|
+
var updateType = updates.updateType;
|
|
1298
|
+
if (updateType === LocusInfoUpdateType.OBJECTS_UPDATED && ((_updates$updatedObjec = updates.updatedObjects) === null || _updates$updatedObjec === void 0 ? void 0 : _updates$updatedObjec.length) > 0) {
|
|
1230
1299
|
// Filter out updates for objects that already have a higher version in their datasets,
|
|
1231
1300
|
// or removals for objects that still exist in any of their datasets
|
|
1232
|
-
var filteredUpdates = updatedObjects.filter(function (object) {
|
|
1301
|
+
var filteredUpdates = updates.updatedObjects.filter(function (object) {
|
|
1233
1302
|
var elementId = object.htMeta.elementId;
|
|
1234
1303
|
var type = elementId.type,
|
|
1235
1304
|
id = elementId.id,
|
|
1236
1305
|
version = elementId.version;
|
|
1237
1306
|
|
|
1238
1307
|
// Check all datasets
|
|
1239
|
-
for (var _i2 = 0, _Object$keys3 = (0, _keys.default)(
|
|
1308
|
+
for (var _i2 = 0, _Object$keys3 = (0, _keys.default)(_this1.dataSets); _i2 < _Object$keys3.length; _i2++) {
|
|
1240
1309
|
var dataSetName = _Object$keys3[_i2];
|
|
1241
|
-
var dataSet =
|
|
1310
|
+
var dataSet = _this1.dataSets[dataSetName];
|
|
1242
1311
|
|
|
1243
1312
|
// only visible datasets have hash trees set
|
|
1244
1313
|
if (dataSet !== null && dataSet !== void 0 && dataSet.hashTree) {
|
|
@@ -1247,12 +1316,12 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1247
1316
|
if (object.data) {
|
|
1248
1317
|
// For updates: filter out if any dataset has a higher version
|
|
1249
1318
|
if (existingVersion > version) {
|
|
1250
|
-
_loggerProxy.default.logger.info("HashTreeParser#callLocusInfoUpdateCallback --> ".concat(
|
|
1319
|
+
_loggerProxy.default.logger.info("HashTreeParser#callLocusInfoUpdateCallback --> ".concat(_this1.debugId, " Filtering out update for ").concat(type, ":").concat(id, " v").concat(version, " because dataset \"").concat(dataSetName, "\" has v").concat(existingVersion));
|
|
1251
1320
|
return false;
|
|
1252
1321
|
}
|
|
1253
1322
|
} else if (existingVersion >= version) {
|
|
1254
1323
|
// For removals: filter out if the object still exists in any dataset
|
|
1255
|
-
_loggerProxy.default.logger.info("HashTreeParser#callLocusInfoUpdateCallback --> ".concat(
|
|
1324
|
+
_loggerProxy.default.logger.info("HashTreeParser#callLocusInfoUpdateCallback --> ".concat(_this1.debugId, " Filtering out removal for ").concat(type, ":").concat(id, " v").concat(version, " because dataset \"").concat(dataSetName, "\" still has v").concat(existingVersion));
|
|
1256
1325
|
return false;
|
|
1257
1326
|
}
|
|
1258
1327
|
}
|
|
@@ -1261,13 +1330,14 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1261
1330
|
return true;
|
|
1262
1331
|
});
|
|
1263
1332
|
if (filteredUpdates.length > 0) {
|
|
1264
|
-
this.locusInfoUpdateCallback(
|
|
1333
|
+
this.locusInfoUpdateCallback({
|
|
1334
|
+
updateType: updateType,
|
|
1265
1335
|
updatedObjects: filteredUpdates
|
|
1266
1336
|
});
|
|
1267
1337
|
}
|
|
1268
1338
|
} else if (updateType !== LocusInfoUpdateType.OBJECTS_UPDATED) {
|
|
1269
|
-
this.locusInfoUpdateCallback(
|
|
1270
|
-
|
|
1339
|
+
this.locusInfoUpdateCallback({
|
|
1340
|
+
updateType: updateType
|
|
1271
1341
|
});
|
|
1272
1342
|
}
|
|
1273
1343
|
}
|
|
@@ -1291,164 +1361,517 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1291
1361
|
* Performs a sync for the given data set.
|
|
1292
1362
|
*
|
|
1293
1363
|
* @param {InternalDataSet} dataSet - The data set to sync
|
|
1294
|
-
* @param {string} rootHash - Our current root hash for this data set
|
|
1295
1364
|
* @param {string} reason - The reason for the sync (used for logging)
|
|
1365
|
+
* @param {boolean} [isInitialization] - Whether this is an initialization sync (sends empty leaves data instead of comparing hashes)
|
|
1296
1366
|
* @returns {Promise<void>}
|
|
1297
1367
|
*/
|
|
1298
1368
|
}, {
|
|
1299
1369
|
key: "performSync",
|
|
1300
1370
|
value: (function () {
|
|
1301
|
-
var _performSync = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1302
|
-
var
|
|
1303
|
-
|
|
1304
|
-
|
|
1371
|
+
var _performSync = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6(dataSet, reason, isInitialization) {
|
|
1372
|
+
var _dataSet$syncAbortCon;
|
|
1373
|
+
var abortController, hashTree, rootHash, leavesData, receivedHashes, hashesResult, mismatchedLeaveIndexes, syncResponse, _t3, _t4;
|
|
1374
|
+
return _regenerator.default.wrap(function (_context7) {
|
|
1375
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
1305
1376
|
case 0:
|
|
1306
1377
|
if (dataSet.hashTree) {
|
|
1307
|
-
|
|
1378
|
+
_context7.next = 1;
|
|
1308
1379
|
break;
|
|
1309
1380
|
}
|
|
1310
|
-
return
|
|
1381
|
+
return _context7.abrupt("return");
|
|
1311
1382
|
case 1:
|
|
1312
|
-
|
|
1383
|
+
abortController = (_dataSet$syncAbortCon = dataSet.syncAbortController) !== null && _dataSet$syncAbortCon !== void 0 ? _dataSet$syncAbortCon : new AbortController();
|
|
1384
|
+
dataSet.syncAbortController = abortController;
|
|
1385
|
+
hashTree = dataSet.hashTree;
|
|
1386
|
+
rootHash = hashTree.getRootHash();
|
|
1387
|
+
_context7.prev = 2;
|
|
1313
1388
|
_loggerProxy.default.logger.info("HashTreeParser#performSync --> ".concat(this.debugId, " ").concat(reason, ", syncing data set \"").concat(dataSet.name, "\""));
|
|
1314
|
-
|
|
1389
|
+
leavesData = {};
|
|
1390
|
+
if (isInitialization) {
|
|
1391
|
+
_context7.next = 10;
|
|
1392
|
+
break;
|
|
1393
|
+
}
|
|
1315
1394
|
if (!(dataSet.leafCount !== 1)) {
|
|
1316
|
-
|
|
1395
|
+
_context7.next = 9;
|
|
1317
1396
|
break;
|
|
1318
1397
|
}
|
|
1319
|
-
|
|
1320
|
-
|
|
1398
|
+
_context7.prev = 3;
|
|
1399
|
+
_context7.next = 4;
|
|
1321
1400
|
return this.getHashesFromLocus(dataSet.name, rootHash);
|
|
1322
|
-
case 3:
|
|
1323
|
-
_yield$this$getHashes = _context6.sent;
|
|
1324
|
-
hashes = _yield$this$getHashes.hashes;
|
|
1325
|
-
latestDataSetInfo = _yield$this$getHashes.dataSet;
|
|
1326
|
-
receivedHashes = hashes;
|
|
1327
|
-
dataSet.hashTree.resize(latestDataSetInfo.leafCount);
|
|
1328
|
-
_context6.next = 6;
|
|
1329
|
-
break;
|
|
1330
1401
|
case 4:
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1402
|
+
hashesResult = _context7.sent;
|
|
1403
|
+
if (hashesResult) {
|
|
1404
|
+
_context7.next = 5;
|
|
1405
|
+
break;
|
|
1406
|
+
}
|
|
1407
|
+
return _context7.abrupt("return");
|
|
1408
|
+
case 5:
|
|
1409
|
+
receivedHashes = hashesResult.hashes;
|
|
1410
|
+
this.updateDataSetLeafCount(dataSet, hashesResult.dataSet.leafCount);
|
|
1411
|
+
_context7.next = 8;
|
|
1412
|
+
break;
|
|
1413
|
+
case 6:
|
|
1414
|
+
_context7.prev = 6;
|
|
1415
|
+
_t3 = _context7["catch"](3);
|
|
1416
|
+
if (!((_t3 === null || _t3 === void 0 ? void 0 : _t3.statusCode) === 409)) {
|
|
1417
|
+
_context7.next = 7;
|
|
1335
1418
|
break;
|
|
1336
1419
|
}
|
|
1337
1420
|
// this is a leaf count mismatch, we should do nothing, just wait for another heartbeat message from Locus
|
|
1338
1421
|
_loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(this.debugId, " Got 409 when fetching hashes for data set \"").concat(dataSet.name, "\": ").concat(_t3.message));
|
|
1339
|
-
return
|
|
1340
|
-
case
|
|
1422
|
+
return _context7.abrupt("return");
|
|
1423
|
+
case 7:
|
|
1341
1424
|
throw _t3;
|
|
1342
|
-
case
|
|
1425
|
+
case 8:
|
|
1343
1426
|
// identify mismatched leaves
|
|
1344
|
-
mismatchedLeaveIndexes =
|
|
1427
|
+
mismatchedLeaveIndexes = hashTree.diffHashes(receivedHashes);
|
|
1345
1428
|
mismatchedLeaveIndexes.forEach(function (index) {
|
|
1346
|
-
|
|
1429
|
+
leavesData[index] = hashTree.getLeafData(index);
|
|
1347
1430
|
});
|
|
1348
|
-
|
|
1431
|
+
_context7.next = 10;
|
|
1349
1432
|
break;
|
|
1350
|
-
case
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1433
|
+
case 9:
|
|
1434
|
+
leavesData = {
|
|
1435
|
+
0: hashTree.getLeafData(0)
|
|
1436
|
+
};
|
|
1437
|
+
case 10:
|
|
1438
|
+
if (!abortController.signal.aborted) {
|
|
1439
|
+
_context7.next = 11;
|
|
1355
1440
|
break;
|
|
1356
1441
|
}
|
|
1357
|
-
|
|
1358
|
-
return
|
|
1359
|
-
case
|
|
1360
|
-
|
|
1442
|
+
_loggerProxy.default.logger.info("HashTreeParser#performSync --> ".concat(this.debugId, " abandoning sync for \"").concat(dataSet.name, "\" before /sync - message received during sync"));
|
|
1443
|
+
return _context7.abrupt("return");
|
|
1444
|
+
case 11:
|
|
1445
|
+
// request sync for mismatched leaves
|
|
1446
|
+
syncResponse = null;
|
|
1447
|
+
if (!isInitialization) {
|
|
1448
|
+
_context7.next = 13;
|
|
1449
|
+
break;
|
|
1450
|
+
}
|
|
1451
|
+
_context7.next = 12;
|
|
1452
|
+
return this.sendSyncRequestToLocus(dataSet, {
|
|
1453
|
+
isInitialization: true
|
|
1454
|
+
});
|
|
1455
|
+
case 12:
|
|
1456
|
+
syncResponse = _context7.sent;
|
|
1457
|
+
_context7.next = 15;
|
|
1458
|
+
break;
|
|
1459
|
+
case 13:
|
|
1460
|
+
if (!((0, _keys.default)(leavesData).length > 0)) {
|
|
1461
|
+
_context7.next = 15;
|
|
1462
|
+
break;
|
|
1463
|
+
}
|
|
1464
|
+
_context7.next = 14;
|
|
1465
|
+
return this.sendSyncRequestToLocus(dataSet, {
|
|
1466
|
+
mismatchedLeavesData: leavesData
|
|
1467
|
+
});
|
|
1468
|
+
case 14:
|
|
1469
|
+
syncResponse = _context7.sent;
|
|
1470
|
+
case 15:
|
|
1361
1471
|
// sync API may return nothing (in that case data will arrive via messages)
|
|
1362
1472
|
// or it may return a response in the same format as messages
|
|
1473
|
+
// We still need to restart the sync timer as a safety net in case the messages don't arrive.
|
|
1474
|
+
this.runSyncAlgorithm(dataSet);
|
|
1363
1475
|
if (syncResponse) {
|
|
1364
|
-
|
|
1476
|
+
// clear the abort controller before processing the response so that
|
|
1477
|
+
// parseMessage() -> cancelPendingSyncsForDataSets() doesn't log a
|
|
1478
|
+
// misleading "aborting sync" message for this already-completed sync
|
|
1479
|
+
dataSet.syncAbortController = undefined;
|
|
1480
|
+
|
|
1481
|
+
// the format of sync response is the same as messages, so we can reuse the same handler
|
|
1482
|
+
this.handleMessage(syncResponse, "via sync API (".concat(isInitialization ? 'init' : "".concat((0, _keys.default)(leavesData).length, " mismatched leaves"), ")"));
|
|
1365
1483
|
}
|
|
1366
|
-
|
|
1367
|
-
_context6.next = 12;
|
|
1484
|
+
_context7.next = 17;
|
|
1368
1485
|
break;
|
|
1369
|
-
case
|
|
1370
|
-
|
|
1371
|
-
_t4 =
|
|
1372
|
-
if (_t4
|
|
1373
|
-
this.callLocusInfoUpdateCallback({
|
|
1374
|
-
updateType: LocusInfoUpdateType.MEETING_ENDED
|
|
1375
|
-
});
|
|
1376
|
-
} else {
|
|
1486
|
+
case 16:
|
|
1487
|
+
_context7.prev = 16;
|
|
1488
|
+
_t4 = _context7["catch"](2);
|
|
1489
|
+
if (!this.handleSyncErrors(_t4)) {
|
|
1377
1490
|
_loggerProxy.default.logger.warn("HashTreeParser#performSync --> ".concat(this.debugId, " error during sync for data set \"").concat(dataSet.name, "\":"), _t4);
|
|
1378
1491
|
}
|
|
1379
|
-
case
|
|
1492
|
+
case 17:
|
|
1493
|
+
_context7.prev = 17;
|
|
1494
|
+
dataSet.syncAbortController = undefined;
|
|
1495
|
+
return _context7.finish(17);
|
|
1496
|
+
case 18:
|
|
1380
1497
|
case "end":
|
|
1381
|
-
return
|
|
1498
|
+
return _context7.stop();
|
|
1382
1499
|
}
|
|
1383
|
-
},
|
|
1500
|
+
}, _callee6, this, [[2, 16, 17, 18], [3, 6]]);
|
|
1384
1501
|
}));
|
|
1385
|
-
function performSync(
|
|
1502
|
+
function performSync(_x8, _x9, _x0) {
|
|
1386
1503
|
return _performSync.apply(this, arguments);
|
|
1387
1504
|
}
|
|
1388
1505
|
return performSync;
|
|
1389
1506
|
}()
|
|
1507
|
+
/**
|
|
1508
|
+
* Cancels any pending or in-flight syncs for the specified data sets.
|
|
1509
|
+
* This removes matching entries from the sync queue and aborts any in-flight sync HTTP requests.
|
|
1510
|
+
*
|
|
1511
|
+
* @param {string[]} dataSetNames - The names of the data sets to cancel syncs for
|
|
1512
|
+
* @returns {void}
|
|
1513
|
+
*/
|
|
1514
|
+
)
|
|
1515
|
+
}, {
|
|
1516
|
+
key: "cancelPendingSyncsForDataSets",
|
|
1517
|
+
value: function cancelPendingSyncsForDataSets(dataSetNames) {
|
|
1518
|
+
var previousLength = this.syncQueue.length;
|
|
1519
|
+
this.syncQueue = this.syncQueue.filter(function (entry) {
|
|
1520
|
+
return !dataSetNames.includes(entry.dataSetName);
|
|
1521
|
+
});
|
|
1522
|
+
if (previousLength !== this.syncQueue.length) {
|
|
1523
|
+
_loggerProxy.default.logger.info("HashTreeParser#cancelPendingSyncsForDataSets --> ".concat(this.debugId, " removed ").concat(previousLength - this.syncQueue.length, " entries from sync queue for data sets: ").concat(dataSetNames.join(', ')));
|
|
1524
|
+
}
|
|
1525
|
+
this.markDataSetsForSyncAllBackoffSkip(dataSetNames);
|
|
1526
|
+
this.abortInFlightSyncs(dataSetNames);
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
/**
|
|
1530
|
+
* If a syncAllDatasets backoff sleep is in progress, marks the given data sets to be skipped
|
|
1531
|
+
* after the sleep completes.
|
|
1532
|
+
*
|
|
1533
|
+
* @param {string[]} dataSetNames - The names of the data sets to mark
|
|
1534
|
+
* @returns {void}
|
|
1535
|
+
*/
|
|
1536
|
+
}, {
|
|
1537
|
+
key: "markDataSetsForSyncAllBackoffSkip",
|
|
1538
|
+
value: function markDataSetsForSyncAllBackoffSkip(dataSetNames) {
|
|
1539
|
+
if (this.syncAllBackoffType !== SyncAllBackoffType.NONE) {
|
|
1540
|
+
var _iterator9 = _createForOfIteratorHelper(dataSetNames),
|
|
1541
|
+
_step9;
|
|
1542
|
+
try {
|
|
1543
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
1544
|
+
var name = _step9.value;
|
|
1545
|
+
this.dataSetsSyncedDuringBackoff.add(name);
|
|
1546
|
+
}
|
|
1547
|
+
} catch (err) {
|
|
1548
|
+
_iterator9.e(err);
|
|
1549
|
+
} finally {
|
|
1550
|
+
_iterator9.f();
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
/**
|
|
1556
|
+
* Aborts any in-flight sync HTTP requests for the specified data sets.
|
|
1557
|
+
*
|
|
1558
|
+
* @param {string[]} dataSetNames - The names of the data sets whose syncs should be aborted
|
|
1559
|
+
* @returns {void}
|
|
1560
|
+
*/
|
|
1561
|
+
}, {
|
|
1562
|
+
key: "abortInFlightSyncs",
|
|
1563
|
+
value: function abortInFlightSyncs(dataSetNames) {
|
|
1564
|
+
var _iterator0 = _createForOfIteratorHelper(dataSetNames),
|
|
1565
|
+
_step0;
|
|
1566
|
+
try {
|
|
1567
|
+
for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
|
|
1568
|
+
var _this$dataSets$name;
|
|
1569
|
+
var name = _step0.value;
|
|
1570
|
+
if ((_this$dataSets$name = this.dataSets[name]) !== null && _this$dataSets$name !== void 0 && _this$dataSets$name.syncAbortController) {
|
|
1571
|
+
_loggerProxy.default.logger.info("HashTreeParser#cancelPendingSyncsForDataSets --> ".concat(this.debugId, " aborting in-flight sync for data set \"").concat(name, "\""));
|
|
1572
|
+
this.dataSets[name].syncAbortController.abort();
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
} catch (err) {
|
|
1576
|
+
_iterator0.e(err);
|
|
1577
|
+
} finally {
|
|
1578
|
+
_iterator0.f();
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
/**
|
|
1583
|
+
* Enqueues a sync for the given data set. If the data set is already in the queue, the request is ignored.
|
|
1584
|
+
* This ensures that all syncs are executed sequentially and no more than 1 sync runs at a time.
|
|
1585
|
+
*
|
|
1586
|
+
* @param {string} dataSetName - The name of the data set to sync
|
|
1587
|
+
* @param {string} reason - The reason for the sync (used for logging)
|
|
1588
|
+
* @param {boolean} [isInitialization=false] - Whether this is an initialization sync (uses empty leaves data instead of hash comparison)
|
|
1589
|
+
* @returns {void}
|
|
1590
|
+
*/
|
|
1591
|
+
}, {
|
|
1592
|
+
key: "enqueueSyncForDataset",
|
|
1593
|
+
value: function enqueueSyncForDataset(dataSetName, reason) {
|
|
1594
|
+
var isInitialization = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1595
|
+
if (this.state === 'stopped') return;
|
|
1596
|
+
var existingEntry = this.syncQueue.find(function (entry) {
|
|
1597
|
+
return entry.dataSetName === dataSetName;
|
|
1598
|
+
});
|
|
1599
|
+
if (existingEntry) {
|
|
1600
|
+
if (isInitialization) {
|
|
1601
|
+
existingEntry.isInitialization = true;
|
|
1602
|
+
}
|
|
1603
|
+
_loggerProxy.default.logger.info("HashTreeParser#enqueueSyncForDataset --> ".concat(this.debugId, " data set \"").concat(dataSetName, "\" already in sync queue, skipping"));
|
|
1604
|
+
return;
|
|
1605
|
+
}
|
|
1606
|
+
this.syncQueue.push({
|
|
1607
|
+
dataSetName: dataSetName,
|
|
1608
|
+
reason: reason,
|
|
1609
|
+
isInitialization: isInitialization
|
|
1610
|
+
});
|
|
1611
|
+
if (!this.isSyncInProgress) {
|
|
1612
|
+
this.syncQueueProcessingPromise = this.processSyncQueue();
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
/**
|
|
1617
|
+
* Processes the sync queue sequentially. Only one instance of this method runs at a time.
|
|
1618
|
+
*
|
|
1619
|
+
* @returns {Promise<void>}
|
|
1620
|
+
*/
|
|
1621
|
+
}, {
|
|
1622
|
+
key: "processSyncQueue",
|
|
1623
|
+
value: (function () {
|
|
1624
|
+
var _processSyncQueue = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7() {
|
|
1625
|
+
var _ref8, dataSetName, reason, isInitialization, dataSet;
|
|
1626
|
+
return _regenerator.default.wrap(function (_context8) {
|
|
1627
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
1628
|
+
case 0:
|
|
1629
|
+
if (!this.isSyncInProgress) {
|
|
1630
|
+
_context8.next = 1;
|
|
1631
|
+
break;
|
|
1632
|
+
}
|
|
1633
|
+
return _context8.abrupt("return");
|
|
1634
|
+
case 1:
|
|
1635
|
+
this.isSyncInProgress = true;
|
|
1636
|
+
_context8.prev = 2;
|
|
1637
|
+
case 3:
|
|
1638
|
+
if (!(this.syncQueue.length > 0 && this.state !== 'stopped')) {
|
|
1639
|
+
_context8.next = 6;
|
|
1640
|
+
break;
|
|
1641
|
+
}
|
|
1642
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1643
|
+
_ref8 = this.syncQueue.shift(), dataSetName = _ref8.dataSetName, reason = _ref8.reason, isInitialization = _ref8.isInitialization;
|
|
1644
|
+
dataSet = this.dataSets[dataSetName];
|
|
1645
|
+
if (dataSet !== null && dataSet !== void 0 && dataSet.hashTree) {
|
|
1646
|
+
_context8.next = 4;
|
|
1647
|
+
break;
|
|
1648
|
+
}
|
|
1649
|
+
return _context8.abrupt("continue", 3);
|
|
1650
|
+
case 4:
|
|
1651
|
+
_context8.next = 5;
|
|
1652
|
+
return this.performSync(dataSet, reason, isInitialization);
|
|
1653
|
+
case 5:
|
|
1654
|
+
_context8.next = 3;
|
|
1655
|
+
break;
|
|
1656
|
+
case 6:
|
|
1657
|
+
_context8.prev = 6;
|
|
1658
|
+
this.isSyncInProgress = false;
|
|
1659
|
+
return _context8.finish(6);
|
|
1660
|
+
case 7:
|
|
1661
|
+
case "end":
|
|
1662
|
+
return _context8.stop();
|
|
1663
|
+
}
|
|
1664
|
+
}, _callee7, this, [[2,, 6, 7]]);
|
|
1665
|
+
}));
|
|
1666
|
+
function processSyncQueue() {
|
|
1667
|
+
return _processSyncQueue.apply(this, arguments);
|
|
1668
|
+
}
|
|
1669
|
+
return processSyncQueue;
|
|
1670
|
+
}()
|
|
1671
|
+
/**
|
|
1672
|
+
* sets the backoff type for syncAllDatasets calls, which determines the scope of datasets that will be synced after the backoff delay.
|
|
1673
|
+
*
|
|
1674
|
+
* @param {boolean} onlyLLM - Whether the backoff is for a syncAllDatasets call that is syncing only LLM datasets
|
|
1675
|
+
* @returns {void}
|
|
1676
|
+
*/
|
|
1677
|
+
)
|
|
1678
|
+
}, {
|
|
1679
|
+
key: "setSyncAllBackoffType",
|
|
1680
|
+
value: function setSyncAllBackoffType(onlyLLM) {
|
|
1681
|
+
this.syncAllBackoffType = onlyLLM ? SyncAllBackoffType.ONLY_LLM : SyncAllBackoffType.ALL;
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
/**
|
|
1685
|
+
* Checks if a syncAll backoff is already in progress. If so, upgrades the scope from
|
|
1686
|
+
* onlyLLM to all datasets when the new call has a broader scope.
|
|
1687
|
+
*
|
|
1688
|
+
* @param {boolean} onlyLLM - Whether the current call is for LLM datasets only
|
|
1689
|
+
* @returns {boolean} true if a backoff is already pending (caller should return early)
|
|
1690
|
+
*/
|
|
1691
|
+
}, {
|
|
1692
|
+
key: "tryUpgradePendingBackoff",
|
|
1693
|
+
value: function tryUpgradePendingBackoff(onlyLLM) {
|
|
1694
|
+
if (this.syncAllBackoffType !== SyncAllBackoffType.NONE) {
|
|
1695
|
+
if (!onlyLLM && this.syncAllBackoffType === SyncAllBackoffType.ONLY_LLM) {
|
|
1696
|
+
this.setSyncAllBackoffType(false);
|
|
1697
|
+
_loggerProxy.default.logger.info("HashTreeParser#syncAllDatasets --> ".concat(this.debugId, " upgraded pending syncAll from onlyLLM to all datasets"));
|
|
1698
|
+
}
|
|
1699
|
+
return true;
|
|
1700
|
+
}
|
|
1701
|
+
return false;
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
/**
|
|
1705
|
+
* Syncs all data sets that have hash trees, one by one in sequence, using the priority order
|
|
1706
|
+
* provided by sortByInitPriority().
|
|
1707
|
+
*
|
|
1708
|
+
* If a call is already waiting in the backoff delay phase, a new call with a broader scope
|
|
1709
|
+
* (onlyLLM=false) will upgrade the pending scope, and the dataset list will be computed after
|
|
1710
|
+
* the backoff using the upgraded scope. After the backoff, the sync queue handles deduplication
|
|
1711
|
+
* so no guard is needed.
|
|
1712
|
+
*
|
|
1713
|
+
* @param {Object} [options={}] - Options for syncing
|
|
1714
|
+
* @param {boolean} [options.onlyLLM=false] - Whether to sync only LLM based data sets
|
|
1715
|
+
* @returns {Promise<void>}
|
|
1716
|
+
*/
|
|
1717
|
+
}, {
|
|
1718
|
+
key: "syncAllDatasets",
|
|
1719
|
+
value: (function () {
|
|
1720
|
+
var _syncAllDatasets = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8() {
|
|
1721
|
+
var options,
|
|
1722
|
+
_options$onlyLLM,
|
|
1723
|
+
onlyLLM,
|
|
1724
|
+
dataSetsToSync,
|
|
1725
|
+
delay,
|
|
1726
|
+
effectiveBackoffType,
|
|
1727
|
+
skippedDataSets,
|
|
1728
|
+
effectiveDataSetsToSync,
|
|
1729
|
+
_iterator1,
|
|
1730
|
+
_step1,
|
|
1731
|
+
ds,
|
|
1732
|
+
_args9 = arguments;
|
|
1733
|
+
return _regenerator.default.wrap(function (_context9) {
|
|
1734
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
1735
|
+
case 0:
|
|
1736
|
+
options = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
|
|
1737
|
+
_options$onlyLLM = options.onlyLLM, onlyLLM = _options$onlyLLM === void 0 ? false : _options$onlyLLM;
|
|
1738
|
+
if (!(this.state === 'stopped')) {
|
|
1739
|
+
_context9.next = 1;
|
|
1740
|
+
break;
|
|
1741
|
+
}
|
|
1742
|
+
return _context9.abrupt("return");
|
|
1743
|
+
case 1:
|
|
1744
|
+
if (!this.tryUpgradePendingBackoff(onlyLLM)) {
|
|
1745
|
+
_context9.next = 2;
|
|
1746
|
+
break;
|
|
1747
|
+
}
|
|
1748
|
+
return _context9.abrupt("return");
|
|
1749
|
+
case 2:
|
|
1750
|
+
dataSetsToSync = this.getSortedDataSetsWithHashTrees(onlyLLM);
|
|
1751
|
+
if (!(dataSetsToSync.length === 0)) {
|
|
1752
|
+
_context9.next = 3;
|
|
1753
|
+
break;
|
|
1754
|
+
}
|
|
1755
|
+
return _context9.abrupt("return");
|
|
1756
|
+
case 3:
|
|
1757
|
+
this.setSyncAllBackoffType(onlyLLM);
|
|
1758
|
+
delay = this.getWeightedBackoffTime(dataSetsToSync[0].backoff);
|
|
1759
|
+
_loggerProxy.default.logger.info("HashTreeParser#syncAllDatasets --> ".concat(this.debugId, " starting backoff delay of ").concat(delay, "ms (onlyLLM=").concat(onlyLLM, ")"));
|
|
1760
|
+
|
|
1761
|
+
// delay the start of the syncs - this is a Locus requirement to avoid thundering herd issues
|
|
1762
|
+
_context9.next = 4;
|
|
1763
|
+
return (0, _utils.sleep)(delay);
|
|
1764
|
+
case 4:
|
|
1765
|
+
// read the (possibly upgraded) scope and clear the backoff flag
|
|
1766
|
+
effectiveBackoffType = this.syncAllBackoffType;
|
|
1767
|
+
skippedDataSets = this.dataSetsSyncedDuringBackoff;
|
|
1768
|
+
this.syncAllBackoffType = SyncAllBackoffType.NONE;
|
|
1769
|
+
this.dataSetsSyncedDuringBackoff = new _set.default();
|
|
1770
|
+
if (!(this.state === 'stopped')) {
|
|
1771
|
+
_context9.next = 5;
|
|
1772
|
+
break;
|
|
1773
|
+
}
|
|
1774
|
+
return _context9.abrupt("return");
|
|
1775
|
+
case 5:
|
|
1776
|
+
// re-evaluate the dataset list after the sleep, since the scope may have been upgraded
|
|
1777
|
+
// and exclude datasets that received messages during the backoff sleep
|
|
1778
|
+
effectiveDataSetsToSync = this.getSortedDataSetsWithHashTrees(effectiveBackoffType === SyncAllBackoffType.ONLY_LLM).filter(function (ds) {
|
|
1779
|
+
return !skippedDataSets.has(ds.name);
|
|
1780
|
+
});
|
|
1781
|
+
if (skippedDataSets.size > 0) {
|
|
1782
|
+
_loggerProxy.default.logger.info("HashTreeParser#syncAllDatasets --> ".concat(this.debugId, " skipping datasets that received messages during backoff: ").concat((0, _toConsumableArray2.default)(skippedDataSets).join(', ')));
|
|
1783
|
+
}
|
|
1784
|
+
_loggerProxy.default.logger.info("HashTreeParser#syncAllDatasets --> ".concat(this.debugId, " syncing ").concat(effectiveBackoffType === SyncAllBackoffType.ONLY_LLM ? 'only LLM' : 'all', " datasets: ").concat(effectiveDataSetsToSync.map(function (ds) {
|
|
1785
|
+
return ds.name;
|
|
1786
|
+
}).join(', ')));
|
|
1787
|
+
_iterator1 = _createForOfIteratorHelper(effectiveDataSetsToSync);
|
|
1788
|
+
try {
|
|
1789
|
+
for (_iterator1.s(); !(_step1 = _iterator1.n()).done;) {
|
|
1790
|
+
ds = _step1.value;
|
|
1791
|
+
this.enqueueSyncForDataset(ds.name, 'syncAllDatasets');
|
|
1792
|
+
}
|
|
1793
|
+
} catch (err) {
|
|
1794
|
+
_iterator1.e(err);
|
|
1795
|
+
} finally {
|
|
1796
|
+
_iterator1.f();
|
|
1797
|
+
}
|
|
1798
|
+
_context9.next = 6;
|
|
1799
|
+
return this.syncQueueProcessingPromise;
|
|
1800
|
+
case 6:
|
|
1801
|
+
case "end":
|
|
1802
|
+
return _context9.stop();
|
|
1803
|
+
}
|
|
1804
|
+
}, _callee8, this);
|
|
1805
|
+
}));
|
|
1806
|
+
function syncAllDatasets() {
|
|
1807
|
+
return _syncAllDatasets.apply(this, arguments);
|
|
1808
|
+
}
|
|
1809
|
+
return syncAllDatasets;
|
|
1810
|
+
}()
|
|
1811
|
+
/**
|
|
1812
|
+
* Returns the list of data sets that have hash trees, sorted by the priority order provided by sortByInitPriority().
|
|
1813
|
+
*
|
|
1814
|
+
* @param {boolean} onlyLLM - Whether to include only LLM based data sets
|
|
1815
|
+
* @returns {Array<{name: string, backoff: {maxMs: number, exponent: number}}>} The sorted list of data sets with their backoff configurations
|
|
1816
|
+
*/
|
|
1817
|
+
)
|
|
1818
|
+
}, {
|
|
1819
|
+
key: "getSortedDataSetsWithHashTrees",
|
|
1820
|
+
value: function getSortedDataSetsWithHashTrees(onlyLLM) {
|
|
1821
|
+
var dataSets = (0, _values.default)(this.dataSets).filter(function (dataSet) {
|
|
1822
|
+
return dataSet === null || dataSet === void 0 ? void 0 : dataSet.hashTree;
|
|
1823
|
+
}).map(function (dataSet) {
|
|
1824
|
+
return {
|
|
1825
|
+
name: dataSet.name,
|
|
1826
|
+
backoff: dataSet.backoff
|
|
1827
|
+
};
|
|
1828
|
+
});
|
|
1829
|
+
if (onlyLLM) {
|
|
1830
|
+
dataSets = dataSets.filter(function (ds) {
|
|
1831
|
+
return _constants3.LLM_DATASET_NAMES.includes(ds.name);
|
|
1832
|
+
});
|
|
1833
|
+
}
|
|
1834
|
+
return (0, _utils.sortByInitPriority)(dataSets, _constants3.DATA_SET_INIT_PRIORITY);
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1390
1837
|
/**
|
|
1391
1838
|
* Runs the sync algorithm for the given data set.
|
|
1392
1839
|
*
|
|
1393
1840
|
* @param {DataSet} receivedDataSet - The data set to run the sync algorithm for.
|
|
1394
1841
|
* @returns {void}
|
|
1395
1842
|
*/
|
|
1396
|
-
)
|
|
1397
1843
|
}, {
|
|
1398
1844
|
key: "runSyncAlgorithm",
|
|
1399
1845
|
value: function runSyncAlgorithm(receivedDataSet) {
|
|
1400
|
-
var
|
|
1846
|
+
var _this10 = this;
|
|
1401
1847
|
var dataSet = this.dataSets[receivedDataSet.name];
|
|
1402
1848
|
if (!dataSet) {
|
|
1403
1849
|
_loggerProxy.default.logger.warn("HashTreeParser#runSyncAlgorithm --> ".concat(this.debugId, " No data set found for ").concat(receivedDataSet.name, ", skipping sync algorithm"));
|
|
1404
1850
|
return;
|
|
1405
1851
|
}
|
|
1406
1852
|
if (!dataSet.hashTree) {
|
|
1407
|
-
|
|
1853
|
+
// no hash tree, so no need to do any syncing
|
|
1854
|
+
// we fall into this branch often, because Locus sends dataSets in messages that are not visible to us
|
|
1855
|
+
|
|
1408
1856
|
return;
|
|
1409
1857
|
}
|
|
1410
1858
|
dataSet.hashTree.resize(receivedDataSet.leafCount);
|
|
1411
|
-
|
|
1412
|
-
// temporary log for the workshop // todo: remove
|
|
1413
|
-
var ourCurrentRootHash = dataSet.hashTree.getRootHash();
|
|
1414
|
-
_loggerProxy.default.logger.info("HashTreeParser#runSyncAlgorithm --> ".concat(this.debugId, " dataSet=\"").concat(dataSet.name, "\" version=").concat(dataSet.version, " hashes before starting timer: ours=").concat(ourCurrentRootHash, " Locus=").concat(dataSet.root));
|
|
1415
1859
|
var delay = dataSet.idleMs + this.getWeightedBackoffTime(dataSet.backoff);
|
|
1416
1860
|
if (delay > 0) {
|
|
1417
1861
|
if (dataSet.timer) {
|
|
1418
1862
|
clearTimeout(dataSet.timer);
|
|
1419
1863
|
}
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
_loggerProxy.default.logger.warn("HashTreeParser#runSyncAlgorithm --> ".concat(_this11.debugId, " Data set \"").concat(dataSet.name, "\" no longer has a hash tree, cannot run sync algorithm"));
|
|
1432
|
-
return _context7.abrupt("return");
|
|
1433
|
-
case 1:
|
|
1434
|
-
rootHash = dataSet.hashTree.getRootHash();
|
|
1435
|
-
if (!(dataSet.root !== rootHash)) {
|
|
1436
|
-
_context7.next = 3;
|
|
1437
|
-
break;
|
|
1438
|
-
}
|
|
1439
|
-
_context7.next = 2;
|
|
1440
|
-
return _this11.performSync(dataSet, rootHash, "Root hash mismatch: received=".concat(dataSet.root, ", ours=").concat(rootHash));
|
|
1441
|
-
case 2:
|
|
1442
|
-
_context7.next = 4;
|
|
1443
|
-
break;
|
|
1444
|
-
case 3:
|
|
1445
|
-
_loggerProxy.default.logger.info("HashTreeParser#runSyncAlgorithm --> ".concat(_this11.debugId, " \"").concat(dataSet.name, "\" root hash matching: ").concat(rootHash, ", version=").concat(dataSet.version));
|
|
1446
|
-
case 4:
|
|
1447
|
-
case "end":
|
|
1448
|
-
return _context7.stop();
|
|
1449
|
-
}
|
|
1450
|
-
}, _callee6);
|
|
1451
|
-
})), delay);
|
|
1864
|
+
dataSet.timer = setTimeout(function () {
|
|
1865
|
+
dataSet.timer = undefined;
|
|
1866
|
+
if (!dataSet.hashTree) {
|
|
1867
|
+
_loggerProxy.default.logger.warn("HashTreeParser#runSyncAlgorithm --> ".concat(_this10.debugId, " Data set \"").concat(dataSet.name, "\" no longer has a hash tree, cannot run sync algorithm"));
|
|
1868
|
+
return;
|
|
1869
|
+
}
|
|
1870
|
+
var rootHash = dataSet.hashTree.getRootHash();
|
|
1871
|
+
if (dataSet.root !== rootHash) {
|
|
1872
|
+
_this10.enqueueSyncForDataset(dataSet.name, "Root hash mismatch: received=".concat(dataSet.root, ", ours=").concat(rootHash));
|
|
1873
|
+
}
|
|
1874
|
+
}, delay);
|
|
1452
1875
|
} else {
|
|
1453
1876
|
_loggerProxy.default.logger.info("HashTreeParser#runSyncAlgorithm --> ".concat(this.debugId, " No delay for \"").concat(dataSet.name, "\" data set, skipping sync timer reset/setup"));
|
|
1454
1877
|
}
|
|
@@ -1466,48 +1889,45 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1466
1889
|
}, {
|
|
1467
1890
|
key: "resetHeartbeatWatchdogs",
|
|
1468
1891
|
value: function resetHeartbeatWatchdogs(receivedDataSets) {
|
|
1469
|
-
var
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
}
|
|
1473
|
-
var _iterator9 = _createForOfIteratorHelper(receivedDataSets),
|
|
1474
|
-
_step9;
|
|
1892
|
+
var _this11 = this;
|
|
1893
|
+
var _iterator10 = _createForOfIteratorHelper(receivedDataSets),
|
|
1894
|
+
_step10;
|
|
1475
1895
|
try {
|
|
1476
1896
|
var _loop2 = function _loop2() {
|
|
1477
|
-
var
|
|
1478
|
-
var
|
|
1479
|
-
|
|
1480
|
-
// eslint-disable-next-line no-continue
|
|
1481
|
-
return 1; // continue
|
|
1482
|
-
}
|
|
1897
|
+
var _dataSet$heartbeatInt;
|
|
1898
|
+
var receivedDataSet = _step10.value;
|
|
1899
|
+
var dataSet = _this11.dataSets[receivedDataSet.name];
|
|
1483
1900
|
if (dataSet.heartbeatWatchdogTimer) {
|
|
1484
1901
|
clearTimeout(dataSet.heartbeatWatchdogTimer);
|
|
1485
1902
|
dataSet.heartbeatWatchdogTimer = undefined;
|
|
1486
1903
|
}
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1904
|
+
|
|
1905
|
+
// dataset-level heartbeatIntervalMs takes priority; fall back to top-level common value
|
|
1906
|
+
var heartbeatIntervalMs = (_dataSet$heartbeatInt = dataSet === null || dataSet === void 0 ? void 0 : dataSet.heartbeatIntervalMs) !== null && _dataSet$heartbeatInt !== void 0 ? _dataSet$heartbeatInt : _this11.topLevelHeartbeatIntervalMs;
|
|
1907
|
+
if (!(dataSet !== null && dataSet !== void 0 && dataSet.hashTree) || !heartbeatIntervalMs) {
|
|
1908
|
+
// eslint-disable-next-line no-continue
|
|
1909
|
+
return 1; // continue
|
|
1910
|
+
}
|
|
1911
|
+
var backoffTime = _this11.getWeightedBackoffTime(dataSet.backoff);
|
|
1912
|
+
var delay = heartbeatIntervalMs + backoffTime;
|
|
1913
|
+
dataSet.heartbeatWatchdogTimer = setTimeout(function () {
|
|
1914
|
+
dataSet.heartbeatWatchdogTimer = undefined;
|
|
1915
|
+
_loggerProxy.default.logger.warn("HashTreeParser#resetHeartbeatWatchdogs --> ".concat(_this11.debugId, " Heartbeat watchdog fired for data set \"").concat(dataSet.name, "\" - no heartbeat received within expected interval, initiating sync"));
|
|
1916
|
+
_metrics.default.sendBehavioralMetric(_constants.default.HASH_TREE_HEARTBEAT_WATCHDOG_EXPIRED, {
|
|
1917
|
+
debugId: _this11.debugId,
|
|
1918
|
+
dataSetName: dataSet.name
|
|
1919
|
+
});
|
|
1920
|
+
_this11.enqueueSyncForDataset(dataSet.name, "heartbeat watchdog expired");
|
|
1921
|
+
_this11.resetHeartbeatWatchdogs([dataSet]);
|
|
1922
|
+
}, delay);
|
|
1503
1923
|
};
|
|
1504
|
-
for (
|
|
1924
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
1505
1925
|
if (_loop2()) continue;
|
|
1506
1926
|
}
|
|
1507
1927
|
} catch (err) {
|
|
1508
|
-
|
|
1928
|
+
_iterator10.e(err);
|
|
1509
1929
|
} finally {
|
|
1510
|
-
|
|
1930
|
+
_iterator10.f();
|
|
1511
1931
|
}
|
|
1512
1932
|
}
|
|
1513
1933
|
|
|
@@ -1541,7 +1961,14 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1541
1961
|
value: function stop() {
|
|
1542
1962
|
_loggerProxy.default.logger.info("HashTreeParser#stop --> ".concat(this.debugId, " Stopping HashTreeParser, clearing timers and hash trees"));
|
|
1543
1963
|
this.stopAllTimers();
|
|
1964
|
+
this.syncQueue = [];
|
|
1965
|
+
this.topLevelHeartbeatIntervalMs = undefined;
|
|
1966
|
+
this.syncAllBackoffType = SyncAllBackoffType.NONE;
|
|
1967
|
+
this.dataSetsSyncedDuringBackoff = new _set.default();
|
|
1544
1968
|
(0, _values.default)(this.dataSets).forEach(function (dataSet) {
|
|
1969
|
+
var _dataSet$syncAbortCon2;
|
|
1970
|
+
(_dataSet$syncAbortCon2 = dataSet.syncAbortController) === null || _dataSet$syncAbortCon2 === void 0 ? void 0 : _dataSet$syncAbortCon2.abort();
|
|
1971
|
+
dataSet.syncAbortController = undefined;
|
|
1545
1972
|
dataSet.hashTree = undefined;
|
|
1546
1973
|
});
|
|
1547
1974
|
this.visibleDataSets = [];
|
|
@@ -1549,29 +1976,41 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1549
1976
|
}
|
|
1550
1977
|
|
|
1551
1978
|
/**
|
|
1552
|
-
*
|
|
1979
|
+
* Cleans up the HashTreeParser, stopping all timers and clearing all internal state.
|
|
1980
|
+
* After calling this, the parser should not be used anymore.
|
|
1981
|
+
* @returns {void}
|
|
1982
|
+
*/
|
|
1983
|
+
}, {
|
|
1984
|
+
key: "cleanUp",
|
|
1985
|
+
value: function cleanUp() {
|
|
1986
|
+
this.stop();
|
|
1987
|
+
this.dataSets = {};
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
/**
|
|
1991
|
+
* Resumes the HashTreeParser that was previously stopped, using a hash tree message.
|
|
1553
1992
|
* @param {HashTreeMessage} message - The message to resume with, it must contain metadata with visible data sets info
|
|
1554
1993
|
* @returns {void}
|
|
1555
1994
|
*/
|
|
1556
1995
|
}, {
|
|
1557
|
-
key: "
|
|
1558
|
-
value: function
|
|
1996
|
+
key: "resumeFromMessage",
|
|
1997
|
+
value: function resumeFromMessage(message) {
|
|
1559
1998
|
var _message$locusStateEl3, _metadataObject$data;
|
|
1560
1999
|
// check that message contains metadata with visible data sets - this is essential to be able to resume
|
|
1561
2000
|
var metadataObject = (_message$locusStateEl3 = message.locusStateElements) === null || _message$locusStateEl3 === void 0 ? void 0 : _message$locusStateEl3.find(function (el) {
|
|
1562
2001
|
return (0, _utils.isMetadata)(el);
|
|
1563
2002
|
});
|
|
1564
2003
|
if (!(metadataObject !== null && metadataObject !== void 0 && (_metadataObject$data = metadataObject.data) !== null && _metadataObject$data !== void 0 && _metadataObject$data.visibleDataSets)) {
|
|
1565
|
-
_loggerProxy.default.logger.warn("HashTreeParser#
|
|
2004
|
+
_loggerProxy.default.logger.warn("HashTreeParser#resumeFromMessage --> ".concat(this.debugId, " Cannot resume HashTreeParser because the message is missing metadata with visible data sets info"));
|
|
1566
2005
|
return;
|
|
1567
2006
|
}
|
|
1568
2007
|
this.setVisibleDataSets(metadataObject.data.visibleDataSets, message.dataSets);
|
|
1569
2008
|
this.dataSets = {};
|
|
1570
|
-
var
|
|
1571
|
-
|
|
2009
|
+
var _iterator11 = _createForOfIteratorHelper(message.dataSets),
|
|
2010
|
+
_step11;
|
|
1572
2011
|
try {
|
|
1573
|
-
for (
|
|
1574
|
-
var dataSet =
|
|
2012
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
2013
|
+
var dataSet = _step11.value;
|
|
1575
2014
|
var name = dataSet.name,
|
|
1576
2015
|
leafCount = dataSet.leafCount;
|
|
1577
2016
|
this.dataSets[name] = _objectSpread(_objectSpread({}, dataSet), {}, {
|
|
@@ -1579,23 +2018,62 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1579
2018
|
});
|
|
1580
2019
|
}
|
|
1581
2020
|
} catch (err) {
|
|
1582
|
-
|
|
2021
|
+
_iterator11.e(err);
|
|
1583
2022
|
} finally {
|
|
1584
|
-
|
|
2023
|
+
_iterator11.f();
|
|
1585
2024
|
}
|
|
1586
|
-
_loggerProxy.default.logger.info("HashTreeParser#
|
|
2025
|
+
_loggerProxy.default.logger.info("HashTreeParser#resumeFromMessage --> ".concat(this.debugId, " Resuming HashTreeParser with data sets: ").concat((0, _keys.default)(this.dataSets).join(', '), ", visible data sets: ").concat(this.visibleDataSets.map(function (ds) {
|
|
1587
2026
|
return ds.name;
|
|
1588
2027
|
}).join(', ')));
|
|
1589
2028
|
this.state = 'active';
|
|
1590
2029
|
this.handleMessage(message, 'on resume');
|
|
1591
2030
|
}
|
|
2031
|
+
|
|
2032
|
+
/**
|
|
2033
|
+
* Resumes the HashTreeParser that was previously stopped, using a Locus API response.
|
|
2034
|
+
* Unlike resumeFromMessage(), this does not require metadata/dataSets in the input,
|
|
2035
|
+
* as it fetches all necessary information from Locus via initializeFromGetLociResponse.
|
|
2036
|
+
* @param {LocusDTO} locus - locus object from an API response
|
|
2037
|
+
* @returns {Promise}
|
|
2038
|
+
*/
|
|
2039
|
+
}, {
|
|
2040
|
+
key: "resumeFromApiResponse",
|
|
2041
|
+
value: (function () {
|
|
2042
|
+
var _resumeFromApiResponse = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9(locus) {
|
|
2043
|
+
return _regenerator.default.wrap(function (_context0) {
|
|
2044
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
2045
|
+
case 0:
|
|
2046
|
+
this.state = 'active';
|
|
2047
|
+
this.dataSets = {};
|
|
2048
|
+
_loggerProxy.default.logger.info("HashTreeParser#resumeFromApiResponse --> ".concat(this.debugId, " Resuming HashTreeParser from API response"));
|
|
2049
|
+
_context0.next = 1;
|
|
2050
|
+
return this.initializeFromGetLociResponse(locus);
|
|
2051
|
+
case 1:
|
|
2052
|
+
case "end":
|
|
2053
|
+
return _context0.stop();
|
|
2054
|
+
}
|
|
2055
|
+
}, _callee9, this);
|
|
2056
|
+
}));
|
|
2057
|
+
function resumeFromApiResponse(_x1) {
|
|
2058
|
+
return _resumeFromApiResponse.apply(this, arguments);
|
|
2059
|
+
}
|
|
2060
|
+
return resumeFromApiResponse;
|
|
2061
|
+
}())
|
|
1592
2062
|
}, {
|
|
1593
2063
|
key: "checkForSentinelHttpResponse",
|
|
1594
2064
|
value: function checkForSentinelHttpResponse(error, dataSetName) {
|
|
1595
2065
|
var _error$body;
|
|
2066
|
+
// 404 for any dataset means the locus is no longer available at this URL - could be replaced or ended
|
|
2067
|
+
// if a dataset is just not visible, we would get a 400
|
|
2068
|
+
if (error.statusCode === 404) {
|
|
2069
|
+
_loggerProxy.default.logger.info("HashTreeParser#checkForSentinelHttpResponse --> ".concat(this.debugId, " Received 404 for data set \"").concat(dataSetName, "\", locus not found"));
|
|
2070
|
+
this.stopAllTimers();
|
|
2071
|
+
throw new LocusNotFoundError();
|
|
2072
|
+
}
|
|
1596
2073
|
var isValidDataSetForSentinel = dataSetName === undefined || PossibleSentinelMessageDataSetNames.includes(dataSetName.toLowerCase());
|
|
1597
|
-
if (
|
|
1598
|
-
|
|
2074
|
+
if (error.statusCode === 409 && ((_error$body = error.body) === null || _error$body === void 0 ? void 0 : _error$body.errorCode) === _types2.LocusErrorCodes.LOCUS_INACTIVE && isValidDataSetForSentinel) {
|
|
2075
|
+
var _error$body2;
|
|
2076
|
+
_loggerProxy.default.logger.info("HashTreeParser#checkForSentinelHttpResponse --> ".concat(this.debugId, " Received ").concat(error.statusCode, "/").concat((_error$body2 = error.body) === null || _error$body2 === void 0 ? void 0 : _error$body2.errorCode, " for data set \"").concat(dataSetName, "\", indicating that the meeting has ended"));
|
|
1599
2077
|
this.stopAllTimers();
|
|
1600
2078
|
throw new MeetingEndedError();
|
|
1601
2079
|
}
|
|
@@ -1605,37 +2083,49 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1605
2083
|
* Gets the current hashes from the locus for a specific data set.
|
|
1606
2084
|
* @param {string} dataSetName
|
|
1607
2085
|
* @param {string} currentRootHash
|
|
1608
|
-
* @returns {
|
|
2086
|
+
* @returns {Object|null} An object containing the hashes and leaf count, or null if the hashes match and no sync is needed
|
|
1609
2087
|
*/
|
|
1610
2088
|
}, {
|
|
1611
2089
|
key: "getHashesFromLocus",
|
|
1612
2090
|
value: function getHashesFromLocus(dataSetName, currentRootHash) {
|
|
1613
|
-
var
|
|
2091
|
+
var _this12 = this;
|
|
1614
2092
|
_loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(this.debugId, " Requesting hashes for data set \"").concat(dataSetName, "\""));
|
|
1615
2093
|
var dataSet = this.dataSets[dataSetName];
|
|
1616
2094
|
var url = "".concat(dataSet.url, "/hashtree");
|
|
1617
2095
|
return this.webexRequest({
|
|
1618
|
-
method:
|
|
2096
|
+
method: _constants2.HTTP_VERBS.GET,
|
|
1619
2097
|
uri: url,
|
|
1620
2098
|
qs: {
|
|
1621
2099
|
rootHash: currentRootHash
|
|
1622
2100
|
}
|
|
1623
2101
|
}).then(function (response) {
|
|
1624
2102
|
var _response$body, _response$body2;
|
|
2103
|
+
if (!response.body || (0, _lodash.isEmpty)(response.body)) {
|
|
2104
|
+
// 204 with empty body means our hashes match Locus, no sync needed
|
|
2105
|
+
_loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(_this12.debugId, " Got ").concat(response.statusCode, " with empty body for data set \"").concat(dataSetName, "\", hashes match - no sync needed"));
|
|
2106
|
+
return null;
|
|
2107
|
+
}
|
|
1625
2108
|
var hashes = (_response$body = response.body) === null || _response$body === void 0 ? void 0 : _response$body.hashes;
|
|
1626
2109
|
var dataSetFromResponse = (_response$body2 = response.body) === null || _response$body2 === void 0 ? void 0 : _response$body2.dataSet;
|
|
1627
2110
|
if (!hashes || !(0, _isArray.default)(hashes)) {
|
|
1628
|
-
_loggerProxy.default.logger.warn("HashTreeParser#getHashesFromLocus --> ".concat(
|
|
2111
|
+
_loggerProxy.default.logger.warn("HashTreeParser#getHashesFromLocus --> ".concat(_this12.debugId, " Locus returned invalid hashes, response body="), response.body);
|
|
1629
2112
|
throw new Error("Locus returned invalid hashes: ".concat(hashes));
|
|
1630
2113
|
}
|
|
1631
|
-
_loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(
|
|
2114
|
+
_loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(_this12.debugId, " Received hashes for data set \"").concat(dataSetName, "\": ").concat((0, _stringify.default)(hashes)));
|
|
1632
2115
|
return {
|
|
1633
2116
|
hashes: hashes,
|
|
1634
2117
|
dataSet: dataSetFromResponse
|
|
1635
2118
|
};
|
|
1636
2119
|
}).catch(function (error) {
|
|
1637
|
-
_loggerProxy.default.logger.error("HashTreeParser#getHashesFromLocus --> ".concat(
|
|
1638
|
-
|
|
2120
|
+
_loggerProxy.default.logger.error("HashTreeParser#getHashesFromLocus --> ".concat(_this12.debugId, " Error ").concat(error.statusCode, " fetching hashes for data set \"").concat(dataSetName, "\":"), error);
|
|
2121
|
+
_this12.checkForSentinelHttpResponse(error, dataSet.name);
|
|
2122
|
+
_metrics.default.sendBehavioralMetric(_constants.default.HASH_TREE_SYNC_FAILURE, {
|
|
2123
|
+
debugId: _this12.debugId,
|
|
2124
|
+
dataSetName: dataSetName,
|
|
2125
|
+
request: 'GET /hashtree',
|
|
2126
|
+
statusCode: error.statusCode,
|
|
2127
|
+
reason: error.message
|
|
2128
|
+
});
|
|
1639
2129
|
throw error;
|
|
1640
2130
|
});
|
|
1641
2131
|
}
|
|
@@ -1644,43 +2134,60 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1644
2134
|
* Sends a sync request to Locus for the specified data set.
|
|
1645
2135
|
*
|
|
1646
2136
|
* @param {InternalDataSet} dataSet The data set to sync.
|
|
1647
|
-
* @param {
|
|
2137
|
+
* @param {Object} options Either `{ isInitialization: true }` for init syncs (uses leafCount=1 with empty leaf data) or `{ mismatchedLeavesData }` for normal syncs.
|
|
1648
2138
|
* @returns {Promise<HashTreeMessage|null>}
|
|
1649
2139
|
*/
|
|
1650
2140
|
}, {
|
|
1651
2141
|
key: "sendSyncRequestToLocus",
|
|
1652
|
-
value: function sendSyncRequestToLocus(dataSet,
|
|
1653
|
-
var
|
|
2142
|
+
value: function sendSyncRequestToLocus(dataSet, options) {
|
|
2143
|
+
var _this13 = this;
|
|
1654
2144
|
_loggerProxy.default.logger.info("HashTreeParser#sendSyncRequestToLocus --> ".concat(this.debugId, " Sending sync request for data set \"").concat(dataSet.name, "\""));
|
|
2145
|
+
var isInitialization = 'isInitialization' in options;
|
|
1655
2146
|
var url = "".concat(dataSet.url, "/sync");
|
|
1656
2147
|
var body = {
|
|
1657
|
-
leafCount: dataSet.leafCount,
|
|
2148
|
+
leafCount: isInitialization ? 1 : dataSet.leafCount,
|
|
1658
2149
|
leafDataEntries: []
|
|
1659
2150
|
};
|
|
1660
|
-
|
|
2151
|
+
if (isInitialization) {
|
|
2152
|
+
// initialization sync: Locus requires leafCount=1 with a single empty leaf
|
|
1661
2153
|
body.leafDataEntries.push({
|
|
1662
|
-
leafIndex:
|
|
1663
|
-
elementIds:
|
|
2154
|
+
leafIndex: 0,
|
|
2155
|
+
elementIds: []
|
|
1664
2156
|
});
|
|
1665
|
-
}
|
|
1666
|
-
|
|
2157
|
+
} else {
|
|
2158
|
+
var mismatchedLeavesData = options.mismatchedLeavesData;
|
|
2159
|
+
(0, _keys.default)(mismatchedLeavesData).forEach(function (index) {
|
|
2160
|
+
var leafIndex = (0, _parseInt2.default)(index, 10);
|
|
2161
|
+
body.leafDataEntries.push({
|
|
2162
|
+
leafIndex: leafIndex,
|
|
2163
|
+
elementIds: mismatchedLeavesData[leafIndex]
|
|
2164
|
+
});
|
|
2165
|
+
});
|
|
2166
|
+
}
|
|
2167
|
+
var ourCurrentRootHash = dataSet.hashTree ? dataSet.hashTree.getRootHash() : _constants3.EMPTY_HASH;
|
|
1667
2168
|
return this.webexRequest({
|
|
1668
|
-
method:
|
|
2169
|
+
method: _constants2.HTTP_VERBS.POST,
|
|
1669
2170
|
uri: url,
|
|
1670
2171
|
qs: {
|
|
1671
2172
|
rootHash: ourCurrentRootHash
|
|
1672
2173
|
},
|
|
1673
2174
|
body: body
|
|
1674
2175
|
}).then(function (resp) {
|
|
1675
|
-
_loggerProxy.default.logger.info("HashTreeParser#sendSyncRequestToLocus --> ".concat(_this14.debugId, " Sync request succeeded for \"").concat(dataSet.name, "\""));
|
|
1676
2176
|
if (!resp.body || (0, _lodash.isEmpty)(resp.body)) {
|
|
1677
|
-
_loggerProxy.default.logger.info("HashTreeParser#sendSyncRequestToLocus --> ".concat(
|
|
2177
|
+
_loggerProxy.default.logger.info("HashTreeParser#sendSyncRequestToLocus --> ".concat(_this13.debugId, " Got ").concat(resp.statusCode, " with empty body for sync request for data set \"").concat(dataSet.name, "\", data should arrive via messages"));
|
|
1678
2178
|
return null;
|
|
1679
2179
|
}
|
|
1680
2180
|
return resp.body;
|
|
1681
2181
|
}).catch(function (error) {
|
|
1682
|
-
_loggerProxy.default.logger.error("HashTreeParser#sendSyncRequestToLocus --> ".concat(
|
|
1683
|
-
|
|
2182
|
+
_loggerProxy.default.logger.error("HashTreeParser#sendSyncRequestToLocus --> ".concat(_this13.debugId, " Error ").concat(error.statusCode, " sending sync request for data set \"").concat(dataSet.name, "\":"), error);
|
|
2183
|
+
_this13.checkForSentinelHttpResponse(error, dataSet.name);
|
|
2184
|
+
_metrics.default.sendBehavioralMetric(_constants.default.HASH_TREE_SYNC_FAILURE, {
|
|
2185
|
+
debugId: _this13.debugId,
|
|
2186
|
+
dataSetName: dataSet.name,
|
|
2187
|
+
request: 'POST /sync',
|
|
2188
|
+
statusCode: error.statusCode,
|
|
2189
|
+
reason: error.message
|
|
2190
|
+
});
|
|
1684
2191
|
throw error;
|
|
1685
2192
|
});
|
|
1686
2193
|
}
|