@webex/plugin-meetings 3.11.0 → 3.12.0-llmrefactor.2
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 +197 -0
- package/dist/aiEnableRequest/index.js.map +1 -0
- package/dist/aiEnableRequest/utils.js +36 -0
- package/dist/aiEnableRequest/utils.js.map +1 -0
- package/dist/annotation/index.js +60 -15
- package/dist/annotation/index.js.map +1 -1
- package/dist/breakouts/breakout.js +8 -3
- package/dist/breakouts/breakout.js.map +1 -1
- package/dist/breakouts/events.js +29 -14
- package/dist/breakouts/events.js.map +1 -1
- package/dist/breakouts/index.js +128 -7
- 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 +8 -3
- package/dist/config.js.map +1 -1
- package/dist/constants.js +60 -11
- 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 +16 -2
- package/dist/hashTree/constants.js.map +1 -1
- package/dist/hashTree/hashTree.js +18 -0
- package/dist/hashTree/hashTree.js.map +1 -1
- package/dist/hashTree/hashTreeParser.js +1655 -538
- package/dist/hashTree/hashTreeParser.js.map +1 -1
- package/dist/hashTree/types.js +4 -2
- package/dist/hashTree/types.js.map +1 -1
- package/dist/hashTree/utils.js +52 -0
- package/dist/hashTree/utils.js.map +1 -1
- package/dist/index.js +18 -2
- package/dist/index.js.map +1 -1
- package/dist/interceptors/constant.js +12 -0
- package/dist/interceptors/constant.js.map +1 -0
- package/dist/interceptors/dataChannelAuthToken.js +332 -0
- package/dist/interceptors/dataChannelAuthToken.js.map +1 -0
- package/dist/interceptors/index.js +7 -0
- package/dist/interceptors/index.js.map +1 -1
- package/dist/interceptors/locusRetry.js +23 -8
- package/dist/interceptors/locusRetry.js.map +1 -1
- package/dist/interceptors/utils.js +27 -0
- package/dist/interceptors/utils.js.map +1 -0
- package/dist/interpretation/index.js +11 -2
- 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 +9 -4
- package/dist/locus-info/controlsUtils.js.map +1 -1
- package/dist/locus-info/index.js +914 -212
- 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/selfUtils.js +1 -0
- package/dist/locus-info/selfUtils.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 +72 -3
- 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 +8 -7
- package/dist/media/properties.js.map +1 -1
- package/dist/meeting/in-meeting-actions.js +11 -1
- package/dist/meeting/in-meeting-actions.js.map +1 -1
- package/dist/meeting/index.js +2287 -1118
- 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 +55 -2
- package/dist/meeting/request.js.map +1 -1
- package/dist/meeting/request.type.js.map +1 -1
- package/dist/meeting/util.js +168 -5
- 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 +369 -162
- 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 +20 -0
- package/dist/member/index.js.map +1 -1
- package/dist/member/types.js.map +1 -1
- package/dist/member/util.js +40 -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 +12 -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 +64 -68
- 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/remoteMediaManager.js +11 -0
- package/dist/multistream/remoteMediaManager.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 +139 -93
- 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/reconnection-manager/index.js +0 -1
- package/dist/reconnection-manager/index.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/aiEnableRequest/index.d.ts +5 -0
- package/dist/types/aiEnableRequest/utils.d.ts +2 -0
- package/dist/types/annotation/index.d.ts +19 -0
- package/dist/types/common/errors/webex-errors.d.ts +32 -2
- package/dist/types/config.d.ts +6 -2
- package/dist/types/constants.d.ts +35 -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 +3 -0
- package/dist/types/hashTree/hashTree.d.ts +7 -0
- package/dist/types/hashTree/hashTreeParser.d.ts +315 -30
- package/dist/types/hashTree/types.d.ts +3 -0
- package/dist/types/hashTree/utils.d.ts +24 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/interceptors/constant.d.ts +5 -0
- package/dist/types/interceptors/dataChannelAuthToken.d.ts +43 -0
- package/dist/types/interceptors/index.d.ts +2 -1
- package/dist/types/interceptors/locusRetry.d.ts +4 -4
- package/dist/types/interceptors/utils.d.ts +1 -0
- package/dist/types/interpretation/interpretation.types.d.ts +10 -0
- package/dist/types/locus-info/index.d.ts +126 -15
- package/dist/types/locus-info/infoUtils.d.ts +8 -0
- package/dist/types/locus-info/types.d.ts +28 -1
- package/dist/types/media/MediaConnectionAwaiter.d.ts +20 -2
- package/dist/types/media/properties.d.ts +8 -3
- package/dist/types/meeting/in-meeting-actions.d.ts +10 -0
- package/dist/types/meeting/index.d.ts +271 -16
- package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
- package/dist/types/meeting/request.d.ts +17 -1
- package/dist/types/meeting/request.type.d.ts +5 -0
- package/dist/types/meeting/util.d.ts +40 -0
- package/dist/types/meetings/index.d.ts +42 -20
- 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 +2 -0
- package/dist/types/member/types.d.ts +1 -0
- package/dist/types/member/util.d.ts +14 -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 +11 -0
- package/dist/types/multistream/codec/constants.d.ts +7 -0
- package/dist/types/multistream/mediaRequestManager.d.ts +20 -26
- 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 +4 -0
- package/dist/types/webinar/utils.d.ts +6 -0
- package/dist/webinar/index.js +612 -165
- package/dist/webinar/index.js.map +1 -1
- package/dist/webinar/utils.js +25 -0
- package/dist/webinar/utils.js.map +1 -0
- package/package.json +24 -23
- package/src/aiEnableRequest/README.md +84 -0
- package/src/aiEnableRequest/index.ts +186 -0
- package/src/aiEnableRequest/utils.ts +25 -0
- package/src/annotation/index.ts +67 -15
- package/src/breakouts/breakout.ts +3 -1
- package/src/breakouts/events.ts +33 -11
- package/src/breakouts/index.ts +145 -3
- package/src/common/errors/webex-errors.ts +50 -3
- package/src/config.ts +6 -2
- package/src/constants.ts +49 -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 +17 -0
- package/src/hashTree/hashTree.ts +17 -0
- package/src/hashTree/hashTreeParser.ts +1482 -361
- package/src/hashTree/types.ts +4 -0
- package/src/hashTree/utils.ts +45 -0
- package/src/index.ts +14 -1
- package/src/interceptors/constant.ts +6 -0
- package/src/interceptors/dataChannelAuthToken.ts +217 -0
- package/src/interceptors/index.ts +2 -1
- package/src/interceptors/locusRetry.ts +25 -4
- package/src/interceptors/utils.ts +16 -0
- package/src/interpretation/index.ts +29 -11
- package/src/interpretation/interpretation.types.ts +11 -0
- package/src/locus-info/controlsUtils.ts +14 -1
- package/src/locus-info/index.ts +976 -203
- package/src/locus-info/infoUtils.ts +41 -6
- package/src/locus-info/selfUtils.ts +1 -0
- package/src/locus-info/types.ts +33 -1
- package/src/media/MediaConnectionAwaiter.ts +62 -5
- package/src/media/index.ts +10 -1
- package/src/media/properties.ts +11 -4
- package/src/meeting/in-meeting-actions.ts +20 -0
- package/src/meeting/index.ts +1258 -222
- package/src/meeting/locusMediaRequest.ts +106 -6
- package/src/meeting/muteState.ts +10 -1
- package/src/meeting/request.ts +53 -0
- package/src/meeting/request.type.ts +6 -0
- package/src/meeting/util.ts +207 -7
- package/src/meeting-info/meeting-info-v2.ts +4 -2
- package/src/meetings/index.ts +319 -117
- 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 +20 -0
- package/src/member/types.ts +1 -0
- package/src/member/util.ts +41 -0
- package/src/members/index.ts +70 -7
- package/src/members/util.ts +12 -4
- package/src/metrics/constants.ts +12 -0
- package/src/multistream/codec/constants.ts +58 -0
- package/src/multistream/mediaRequestManager.ts +117 -76
- package/src/multistream/receiveSlot.ts +18 -0
- package/src/multistream/remoteMediaManager.ts +13 -0
- package/src/multistream/sendSlotManager.ts +97 -3
- package/src/reachability/clusterReachability.ts +3 -2
- package/src/reachability/index.ts +56 -16
- package/src/reachability/reachability.types.ts +11 -0
- package/src/reachability/util.ts +36 -0
- package/src/reactions/reactions.type.ts +4 -0
- package/src/reconnection-manager/index.ts +0 -1
- package/src/recording-controller/index.ts +1 -2
- package/src/roap/turnDiscovery.ts +9 -1
- package/src/webinar/index.ts +416 -12
- package/src/webinar/utils.ts +16 -0
- package/test/unit/spec/aiEnableRequest/index.ts +1067 -0
- package/test/unit/spec/aiEnableRequest/utils.ts +130 -0
- package/test/unit/spec/annotation/index.ts +228 -134
- package/test/unit/spec/breakouts/breakout.ts +9 -3
- package/test/unit/spec/breakouts/events.ts +120 -2
- package/test/unit/spec/breakouts/index.ts +331 -15
- 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/hashTree.ts +66 -0
- package/test/unit/spec/hashTree/hashTreeParser.ts +4528 -171
- package/test/unit/spec/hashTree/utils.ts +125 -1
- package/test/unit/spec/interceptors/dataChannelAuthToken.ts +388 -0
- package/test/unit/spec/interceptors/locusRetry.ts +205 -4
- package/test/unit/spec/interceptors/utils.ts +75 -0
- package/test/unit/spec/interpretation/index.ts +26 -4
- package/test/unit/spec/locus-info/controlsUtils.js +200 -56
- package/test/unit/spec/locus-info/index.js +1861 -149
- package/test/unit/spec/locus-info/infoUtils.js +184 -1
- package/test/unit/spec/media/MediaConnectionAwaiter.ts +96 -1
- package/test/unit/spec/media/index.ts +92 -0
- package/test/unit/spec/media/properties.ts +35 -26
- package/test/unit/spec/meeting/in-meeting-actions.ts +12 -2
- package/test/unit/spec/meeting/index.js +3694 -450
- 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 +82 -0
- package/test/unit/spec/meeting/utils.js +595 -27
- package/test/unit/spec/meeting-info/meetinginfov2.js +19 -10
- package/test/unit/spec/meetings/index.js +1138 -86
- 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 +35 -4
- package/test/unit/spec/member/util.js +154 -27
- 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 +503 -122
- package/test/unit/spec/multistream/remoteMediaManager.ts +30 -0
- package/test/unit/spec/multistream/sendSlotManager.ts +135 -36
- package/test/unit/spec/reachability/index.ts +151 -46
- package/test/unit/spec/reachability/util.ts +31 -0
- package/test/unit/spec/reconnection-manager/index.js +4 -8
- 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 +1087 -167
- package/test/unit/spec/webinar/utils.ts +39 -0
|
@@ -5,7 +5,7 @@ var _Array$from = require("@babel/runtime-corejs2/core-js/array/from");
|
|
|
5
5
|
var _Symbol = require("@babel/runtime-corejs2/core-js/symbol");
|
|
6
6
|
var _Symbol$iterator = require("@babel/runtime-corejs2/core-js/symbol/iterator");
|
|
7
7
|
var _Array$isArray2 = require("@babel/runtime-corejs2/core-js/array/is-array");
|
|
8
|
-
var _Object$
|
|
8
|
+
var _Object$keys4 = require("@babel/runtime-corejs2/core-js/object/keys");
|
|
9
9
|
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
|
|
10
10
|
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
|
|
11
11
|
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
|
|
@@ -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.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,25 +38,37 @@ 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
|
-
function ownKeys(e, r) { var t = _Object$
|
|
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; }
|
|
45
50
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof _Symbol && r[_Symbol$iterator] || r["@@iterator"]; if (!t) { if (_Array$isArray2(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
46
51
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? _Array$from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
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
|
};
|
|
66
|
+
var SYNC_METRICS_DATA_SETS = [_constants3.DataSetNames.MAIN, _constants3.DataSetNames.ATD_ACTIVE, _constants3.DataSetNames.ATD_UNMUTED];
|
|
54
67
|
/**
|
|
55
68
|
* This error is thrown if we receive information that the meeting has ended while we're processing some hash messages.
|
|
56
69
|
* It's handled internally by HashTreeParser and results in MEETING_ENDED being sent up.
|
|
57
70
|
*/
|
|
58
|
-
var MeetingEndedError = /*#__PURE__*/function (_Error) {
|
|
71
|
+
var MeetingEndedError = exports.MeetingEndedError = /*#__PURE__*/function (_Error) {
|
|
59
72
|
function MeetingEndedError() {
|
|
60
73
|
(0, _classCallCheck2.default)(this, MeetingEndedError);
|
|
61
74
|
return _callSuper(this, MeetingEndedError, arguments);
|
|
@@ -63,6 +76,25 @@ var MeetingEndedError = /*#__PURE__*/function (_Error) {
|
|
|
63
76
|
(0, _inherits2.default)(MeetingEndedError, _Error);
|
|
64
77
|
return (0, _createClass2.default)(MeetingEndedError);
|
|
65
78
|
}(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
|
|
79
|
+
/**
|
|
80
|
+
* This error is thrown when a 404 is received from Locus hash tree endpoints, indicating that the locus URL
|
|
81
|
+
* is no longer valid (e.g. participant moved to a breakout room, or meeting ended).
|
|
82
|
+
* It's handled internally by HashTreeParser and results in LOCUS_NOT_FOUND being sent up.
|
|
83
|
+
*/
|
|
84
|
+
var LocusNotFoundError = exports.LocusNotFoundError = /*#__PURE__*/function (_Error2) {
|
|
85
|
+
function LocusNotFoundError() {
|
|
86
|
+
(0, _classCallCheck2.default)(this, LocusNotFoundError);
|
|
87
|
+
return _callSuper(this, LocusNotFoundError, arguments);
|
|
88
|
+
}
|
|
89
|
+
(0, _inherits2.default)(LocusNotFoundError, _Error2);
|
|
90
|
+
return (0, _createClass2.default)(LocusNotFoundError);
|
|
91
|
+
}(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
|
|
92
|
+
/* Currently Locus always sends Metadata objects only in the "self" dataset.
|
|
93
|
+
* If this ever changes, update all the code that relies on this constant.
|
|
94
|
+
*/
|
|
95
|
+
var MetadataDataSetName = _constants3.DataSetNames.SELF;
|
|
96
|
+
var PossibleSentinelMessageDataSetNames = [_constants3.DataSetNames.MAIN, _constants3.DataSetNames.SELF, _constants3.DataSetNames.UNJOINED];
|
|
97
|
+
|
|
66
98
|
/**
|
|
67
99
|
* Parses hash tree eventing locus data
|
|
68
100
|
*/
|
|
@@ -73,30 +105,52 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
73
105
|
* @param {Object} options.initialLocus The initial locus data containing the hash tree information
|
|
74
106
|
*/
|
|
75
107
|
function HashTreeParser(options) {
|
|
76
|
-
var _locus$
|
|
108
|
+
var _locus$links, _locus$links$resource, _locus$links$resource2, _options$metadata, _options$metadata2, _options$metadata2$vi;
|
|
77
109
|
(0, _classCallCheck2.default)(this, HashTreeParser);
|
|
78
110
|
(0, _defineProperty2.default)(this, "dataSets", {});
|
|
79
111
|
(0, _defineProperty2.default)(this, "visibleDataSetsUrl", void 0);
|
|
80
112
|
// url from which we can get info about all data sets
|
|
81
113
|
(0, _defineProperty2.default)(this, "webexRequest", void 0);
|
|
82
|
-
(0, _defineProperty2.default)(this, "
|
|
114
|
+
(0, _defineProperty2.default)(this, "callbacks", void 0);
|
|
115
|
+
(0, _defineProperty2.default)(this, "syncLatencyMeetingId", void 0);
|
|
83
116
|
(0, _defineProperty2.default)(this, "visibleDataSets", void 0);
|
|
84
117
|
(0, _defineProperty2.default)(this, "debugId", void 0);
|
|
118
|
+
(0, _defineProperty2.default)(this, "excludedDataSets", void 0);
|
|
119
|
+
(0, _defineProperty2.default)(this, "state", void 0);
|
|
120
|
+
(0, _defineProperty2.default)(this, "syncQueue", []);
|
|
121
|
+
(0, _defineProperty2.default)(this, "isSyncInProgress", false);
|
|
122
|
+
// tracks whether syncAllDatasets is currently in its backoff delay phase and with what scope
|
|
123
|
+
(0, _defineProperty2.default)(this, "syncAllBackoffType", SyncAllBackoffType.NONE);
|
|
124
|
+
// datasets that received messages during the syncAllDatasets backoff sleep and should be skipped
|
|
125
|
+
(0, _defineProperty2.default)(this, "dataSetsSyncedDuringBackoff", new _set.default());
|
|
126
|
+
(0, _defineProperty2.default)(this, "syncQueueProcessingPromise", _promise.default.resolve());
|
|
127
|
+
// top-level heartbeat interval from the most recent message, used as fallback when dataset-level value is missing
|
|
128
|
+
(0, _defineProperty2.default)(this, "topLevelHeartbeatIntervalMs", void 0);
|
|
85
129
|
var _options$initialLocus = options.initialLocus,
|
|
86
130
|
dataSets = _options$initialLocus.dataSets,
|
|
87
131
|
locus = _options$initialLocus.locus; // extract dataSets from initialLocus
|
|
88
132
|
|
|
89
133
|
this.debugId = options.debugId;
|
|
90
134
|
this.webexRequest = options.webexRequest;
|
|
91
|
-
this.
|
|
92
|
-
this.
|
|
93
|
-
|
|
94
|
-
|
|
135
|
+
this.callbacks = options.callbacks;
|
|
136
|
+
this.syncLatencyMeetingId = options.syncLatencyMeetingId;
|
|
137
|
+
this.excludedDataSets = options.excludedDataSets || [];
|
|
138
|
+
this.visibleDataSetsUrl = locus === null || locus === void 0 ? void 0 : (_locus$links = locus.links) === null || _locus$links === void 0 ? void 0 : (_locus$links$resource = _locus$links.resources) === null || _locus$links$resource === void 0 ? void 0 : (_locus$links$resource2 = _locus$links$resource.visibleDataSets) === null || _locus$links$resource2 === void 0 ? void 0 : _locus$links$resource2.url;
|
|
139
|
+
this.setVisibleDataSets(((_options$metadata = options.metadata) === null || _options$metadata === void 0 ? void 0 : _options$metadata.visibleDataSets) || [], dataSets);
|
|
140
|
+
this.state = 'active';
|
|
141
|
+
if (((_options$metadata2 = options.metadata) === null || _options$metadata2 === void 0 ? void 0 : (_options$metadata2$vi = _options$metadata2.visibleDataSets) === null || _options$metadata2$vi === void 0 ? void 0 : _options$metadata2$vi.length) === 0) {
|
|
142
|
+
_loggerProxy.default.logger.warn("HashTreeParser#constructor --> ".concat(this.debugId, " No visibleDataSets found in Metadata"));
|
|
95
143
|
}
|
|
96
144
|
// object mapping dataset names to arrays of leaf data
|
|
97
145
|
var leafData = this.analyzeLocusHtMeta(locus);
|
|
98
|
-
|
|
146
|
+
if (options.metadata) {
|
|
147
|
+
// add also the metadata that's outside of locus object itself
|
|
148
|
+
this.analyzeMetadata(leafData, options.metadata);
|
|
149
|
+
}
|
|
150
|
+
_loggerProxy.default.logger.info("HashTreeParser#constructor --> ".concat(this.debugId, " creating HashTreeParser for datasets: ").concat((0, _stringify.default)(dataSets.map(function (ds) {
|
|
99
151
|
return ds.name;
|
|
152
|
+
})), " with visible datasets: ").concat((0, _stringify.default)(this.visibleDataSets.map(function (vds) {
|
|
153
|
+
return vds.name;
|
|
100
154
|
}))));
|
|
101
155
|
var _iterator = _createForOfIteratorHelper(dataSets),
|
|
102
156
|
_step;
|
|
@@ -106,7 +160,7 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
106
160
|
var name = dataSet.name,
|
|
107
161
|
leafCount = dataSet.leafCount;
|
|
108
162
|
this.dataSets[name] = _objectSpread(_objectSpread({}, dataSet), {}, {
|
|
109
|
-
hashTree: this.
|
|
163
|
+
hashTree: this.isVisibleDataSet(name) ? new _hashTree.default(leafData[name] || [], leafCount) : undefined
|
|
110
164
|
});
|
|
111
165
|
}
|
|
112
166
|
} catch (err) {
|
|
@@ -117,75 +171,142 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
117
171
|
}
|
|
118
172
|
|
|
119
173
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* from that dataset (in the response or via messages).
|
|
174
|
+
* Sets the visible data sets list for the HashTreeParser. This method should be called only at the start, to initialize
|
|
175
|
+
* the visible data sets, before any message processsing, so for example from the constructor or when resuming the parser.
|
|
123
176
|
*
|
|
124
|
-
* @param {
|
|
125
|
-
* @
|
|
177
|
+
* @param {Array<VisibleDataSetInfo>} visibleDataSets - The visible data sets to set
|
|
178
|
+
* @param {Array<DataSet>} dataSets - The "dataSets" list from Locus (yes, Locus sends visibleDataSets and dataSets as separate lists and they can differ)
|
|
179
|
+
* @returns {void}
|
|
126
180
|
*/
|
|
127
181
|
return (0, _createClass2.default)(HashTreeParser, [{
|
|
128
|
-
key: "
|
|
129
|
-
value: function
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
this.dataSets[dataSet.name] = _objectSpread(_objectSpread({}, dataSet), {}, {
|
|
141
|
-
hashTree: hashTree
|
|
182
|
+
key: "setVisibleDataSets",
|
|
183
|
+
value: function setVisibleDataSets(visibleDataSets, dataSets) {
|
|
184
|
+
var _this = this;
|
|
185
|
+
this.visibleDataSets = (0, _lodash.cloneDeep)(visibleDataSets).filter(function (vds) {
|
|
186
|
+
return (
|
|
187
|
+
// exclude data sets we will never care about
|
|
188
|
+
!_this.isExcludedDataSet(vds.name) &&
|
|
189
|
+
// and make sure that visibleDataSets list is consistent with dataSets list
|
|
190
|
+
dataSets.some(function (ds) {
|
|
191
|
+
return ds.name === vds.name;
|
|
192
|
+
})
|
|
193
|
+
);
|
|
142
194
|
});
|
|
143
|
-
return this.sendInitializationSyncRequestToLocus(dataSet.name, 'new visible data set');
|
|
144
195
|
}
|
|
145
196
|
|
|
146
197
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
* @
|
|
150
|
-
* @param {string} debugText - text to include in logs
|
|
151
|
-
* @returns {Promise}
|
|
198
|
+
* Checks if the given data set name is in the list of visible data sets
|
|
199
|
+
* @param {string} dataSetName data set name to check
|
|
200
|
+
* @returns {Boolean} True if the data set is visible, false otherwise
|
|
152
201
|
*/
|
|
153
202
|
}, {
|
|
154
|
-
key: "
|
|
155
|
-
value: function
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if (!dataset) {
|
|
159
|
-
_loggerProxy.default.logger.warn("HashTreeParser#sendInitializationSyncRequestToLocus --> ".concat(this.debugId, " No data set found for ").concat(datasetName, ", cannot send the request for leaf data"));
|
|
160
|
-
return _promise.default.resolve(null);
|
|
161
|
-
}
|
|
162
|
-
var emptyLeavesData = new Array(dataset.leafCount).fill([]);
|
|
163
|
-
_loggerProxy.default.logger.info("HashTreeParser#sendInitializationSyncRequestToLocus --> ".concat(this.debugId, " Sending initial sync request to Locus for data set \"").concat(datasetName, "\" with empty leaf data"));
|
|
164
|
-
return this.sendSyncRequestToLocus(this.dataSets[datasetName], emptyLeavesData).then(function (syncResponse) {
|
|
165
|
-
if (syncResponse) {
|
|
166
|
-
return _this.parseMessage(syncResponse, "via empty leaves /sync API call for ".concat(debugText));
|
|
167
|
-
}
|
|
168
|
-
return {
|
|
169
|
-
updateType: LocusInfoUpdateType.OBJECTS_UPDATED,
|
|
170
|
-
updatedObjects: []
|
|
171
|
-
};
|
|
203
|
+
key: "isVisibleDataSet",
|
|
204
|
+
value: function isVisibleDataSet(dataSetName) {
|
|
205
|
+
return this.visibleDataSets.some(function (vds) {
|
|
206
|
+
return vds.name === dataSetName;
|
|
172
207
|
});
|
|
173
208
|
}
|
|
174
209
|
|
|
175
210
|
/**
|
|
176
|
-
*
|
|
211
|
+
* Checks if the given data set name is in the excluded list
|
|
212
|
+
* @param {string} dataSetName data set name to check
|
|
213
|
+
* @returns {boolean} True if the data set is excluded, false otherwise
|
|
214
|
+
*/
|
|
215
|
+
}, {
|
|
216
|
+
key: "isExcludedDataSet",
|
|
217
|
+
value: function isExcludedDataSet(dataSetName) {
|
|
218
|
+
return this.excludedDataSets.some(function (name) {
|
|
219
|
+
return name === dataSetName;
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Adds a data set to the visible data sets list, unless it is in the excluded list.
|
|
225
|
+
* @param {VisibleDataSetInfo} dataSetInfo data set info to add
|
|
226
|
+
* @returns {boolean} True if the data set was added, false if it was excluded
|
|
227
|
+
*/
|
|
228
|
+
}, {
|
|
229
|
+
key: "addToVisibleDataSetsList",
|
|
230
|
+
value: function addToVisibleDataSetsList(dataSetInfo) {
|
|
231
|
+
if (this.isExcludedDataSet(dataSetInfo.name)) {
|
|
232
|
+
_loggerProxy.default.logger.info("HashTreeParser#addToVisibleDataSetsList --> ".concat(this.debugId, " Data set \"").concat(dataSetInfo.name, "\" is in the excluded list, ignoring"));
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
this.visibleDataSets.push(dataSetInfo);
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Initializes a new visible data set by creating a hash tree for it, adding it to all the internal structures,
|
|
241
|
+
* and sending an initial sync request to Locus with empty leaf data - that will trigger Locus to gives us all the data
|
|
242
|
+
* from that dataset (in the response or via messages).
|
|
243
|
+
*
|
|
244
|
+
* @param {VisibleDataSetInfo} visibleDataSetInfo Information about the new visible data set
|
|
245
|
+
* @param {DataSet} dataSetInfo The new data set to be added
|
|
246
|
+
* @returns {Promise}
|
|
247
|
+
*/
|
|
248
|
+
}, {
|
|
249
|
+
key: "initializeNewVisibleDataSet",
|
|
250
|
+
value: (function () {
|
|
251
|
+
var _initializeNewVisibleDataSet = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(visibleDataSetInfo, dataSetInfo) {
|
|
252
|
+
var hashTree;
|
|
253
|
+
return _regenerator.default.wrap(function (_context) {
|
|
254
|
+
while (1) switch (_context.prev = _context.next) {
|
|
255
|
+
case 0:
|
|
256
|
+
if (!this.isVisibleDataSet(dataSetInfo.name)) {
|
|
257
|
+
_context.next = 1;
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
_loggerProxy.default.logger.info("HashTreeParser#initializeNewVisibleDataSet --> ".concat(this.debugId, " Data set \"").concat(dataSetInfo.name, "\" already exists, skipping init"));
|
|
261
|
+
return _context.abrupt("return");
|
|
262
|
+
case 1:
|
|
263
|
+
_loggerProxy.default.logger.info("HashTreeParser#initializeNewVisibleDataSet --> ".concat(this.debugId, " Adding visible data set \"").concat(dataSetInfo.name, "\""));
|
|
264
|
+
if (this.addToVisibleDataSetsList(visibleDataSetInfo)) {
|
|
265
|
+
_context.next = 2;
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
return _context.abrupt("return");
|
|
269
|
+
case 2:
|
|
270
|
+
hashTree = new _hashTree.default([], dataSetInfo.leafCount);
|
|
271
|
+
this.dataSets[dataSetInfo.name] = _objectSpread(_objectSpread({}, dataSetInfo), {}, {
|
|
272
|
+
hashTree: hashTree
|
|
273
|
+
});
|
|
274
|
+
this.enqueueSyncForDataset(dataSetInfo.name, 'new visible data set initialization', true);
|
|
275
|
+
_context.next = 3;
|
|
276
|
+
return this.syncQueueProcessingPromise;
|
|
277
|
+
case 3:
|
|
278
|
+
case "end":
|
|
279
|
+
return _context.stop();
|
|
280
|
+
}
|
|
281
|
+
}, _callee, this);
|
|
282
|
+
}));
|
|
283
|
+
function initializeNewVisibleDataSet(_x, _x2) {
|
|
284
|
+
return _initializeNewVisibleDataSet.apply(this, arguments);
|
|
285
|
+
}
|
|
286
|
+
return initializeNewVisibleDataSet;
|
|
287
|
+
}()
|
|
288
|
+
/**
|
|
289
|
+
* Queries Locus for all up-to-date information about all visible data sets
|
|
177
290
|
*
|
|
178
|
-
* @param {string} url - url from which we can get info about all data sets
|
|
179
291
|
* @returns {Promise}
|
|
180
292
|
*/
|
|
293
|
+
)
|
|
181
294
|
}, {
|
|
182
|
-
key: "
|
|
183
|
-
value: function
|
|
295
|
+
key: "getAllVisibleDataSetsFromLocus",
|
|
296
|
+
value: function getAllVisibleDataSetsFromLocus() {
|
|
297
|
+
var _this2 = this;
|
|
298
|
+
if (!this.visibleDataSetsUrl) {
|
|
299
|
+
_loggerProxy.default.logger.warn("HashTreeParser#getAllVisibleDataSetsFromLocus --> ".concat(this.debugId, " No visibleDataSetsUrl, cannot get data sets information"));
|
|
300
|
+
return _promise.default.resolve([]);
|
|
301
|
+
}
|
|
184
302
|
return this.webexRequest({
|
|
185
|
-
method:
|
|
186
|
-
uri:
|
|
303
|
+
method: _constants2.HTTP_VERBS.GET,
|
|
304
|
+
uri: this.visibleDataSetsUrl
|
|
187
305
|
}).then(function (response) {
|
|
188
306
|
return response.body.dataSets;
|
|
307
|
+
}).catch(function (error) {
|
|
308
|
+
_this2.checkForSentinelHttpResponse(error);
|
|
309
|
+
throw error;
|
|
189
310
|
});
|
|
190
311
|
}
|
|
191
312
|
|
|
@@ -198,25 +319,26 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
198
319
|
}, {
|
|
199
320
|
key: "initializeFromMessage",
|
|
200
321
|
value: (function () {
|
|
201
|
-
var _initializeFromMessage = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
202
|
-
var
|
|
203
|
-
return _regenerator.default.wrap(function (
|
|
204
|
-
while (1) switch (
|
|
322
|
+
var _initializeFromMessage = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2(message) {
|
|
323
|
+
var visibleDataSets;
|
|
324
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
325
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
205
326
|
case 0:
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
327
|
+
this.visibleDataSetsUrl = message.visibleDataSetsUrl;
|
|
328
|
+
_loggerProxy.default.logger.info("HashTreeParser#initializeFromMessage --> ".concat(this.debugId, " visibleDataSetsUrl=").concat(this.visibleDataSetsUrl));
|
|
329
|
+
_context2.next = 1;
|
|
330
|
+
return this.getAllVisibleDataSetsFromLocus();
|
|
209
331
|
case 1:
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
return this.initializeDataSets(
|
|
332
|
+
visibleDataSets = _context2.sent;
|
|
333
|
+
_context2.next = 2;
|
|
334
|
+
return this.initializeDataSets(visibleDataSets, 'initialization from message');
|
|
213
335
|
case 2:
|
|
214
336
|
case "end":
|
|
215
|
-
return
|
|
337
|
+
return _context2.stop();
|
|
216
338
|
}
|
|
217
|
-
},
|
|
339
|
+
}, _callee2, this);
|
|
218
340
|
}));
|
|
219
|
-
function initializeFromMessage(
|
|
341
|
+
function initializeFromMessage(_x3) {
|
|
220
342
|
return _initializeFromMessage.apply(this, arguments);
|
|
221
343
|
}
|
|
222
344
|
return initializeFromMessage;
|
|
@@ -234,33 +356,34 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
234
356
|
}, {
|
|
235
357
|
key: "initializeFromGetLociResponse",
|
|
236
358
|
value: (function () {
|
|
237
|
-
var _initializeFromGetLociResponse = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
238
|
-
var _locus$
|
|
239
|
-
var
|
|
240
|
-
return _regenerator.default.wrap(function (
|
|
241
|
-
while (1) switch (
|
|
359
|
+
var _initializeFromGetLociResponse = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3(locus) {
|
|
360
|
+
var _locus$links2, _locus$links2$resourc, _locus$links2$resourc2;
|
|
361
|
+
var visibleDataSets;
|
|
362
|
+
return _regenerator.default.wrap(function (_context3) {
|
|
363
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
242
364
|
case 0:
|
|
243
|
-
if (locus !== null && locus !== void 0 && (_locus$
|
|
244
|
-
|
|
365
|
+
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) {
|
|
366
|
+
_context3.next = 1;
|
|
245
367
|
break;
|
|
246
368
|
}
|
|
247
369
|
_loggerProxy.default.logger.warn("HashTreeParser#initializeFromGetLociResponse --> ".concat(this.debugId, " missing visibleDataSets url in GET Loci response, cannot initialize hash trees"));
|
|
248
|
-
return
|
|
370
|
+
return _context3.abrupt("return");
|
|
249
371
|
case 1:
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
372
|
+
this.visibleDataSetsUrl = locus.links.resources.visibleDataSets.url;
|
|
373
|
+
_loggerProxy.default.logger.info("HashTreeParser#initializeFromGetLociResponse --> ".concat(this.debugId, " visibleDataSets url: ").concat(this.visibleDataSetsUrl));
|
|
374
|
+
_context3.next = 2;
|
|
375
|
+
return this.getAllVisibleDataSetsFromLocus();
|
|
253
376
|
case 2:
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
return this.initializeDataSets(
|
|
377
|
+
visibleDataSets = _context3.sent;
|
|
378
|
+
_context3.next = 3;
|
|
379
|
+
return this.initializeDataSets(visibleDataSets, 'initialization from GET /loci response');
|
|
257
380
|
case 3:
|
|
258
381
|
case "end":
|
|
259
|
-
return
|
|
382
|
+
return _context3.stop();
|
|
260
383
|
}
|
|
261
|
-
},
|
|
384
|
+
}, _callee3, this);
|
|
262
385
|
}));
|
|
263
|
-
function initializeFromGetLociResponse(
|
|
386
|
+
function initializeFromGetLociResponse(_x4) {
|
|
264
387
|
return _initializeFromGetLociResponse.apply(this, arguments);
|
|
265
388
|
}
|
|
266
389
|
return initializeFromGetLociResponse;
|
|
@@ -268,7 +391,7 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
268
391
|
/**
|
|
269
392
|
* Initializes data sets by doing an initialization sync on each visible data set that doesn't have a hash tree yet.
|
|
270
393
|
*
|
|
271
|
-
* @param {DataSet[]}
|
|
394
|
+
* @param {DataSet[]} visibleDataSets Array of visible DataSet objects to initialize
|
|
272
395
|
* @param {string} debugText Text to include in logs for debugging purposes
|
|
273
396
|
* @returns {Promise}
|
|
274
397
|
*/
|
|
@@ -276,78 +399,75 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
276
399
|
}, {
|
|
277
400
|
key: "initializeDataSets",
|
|
278
401
|
value: (function () {
|
|
279
|
-
var _initializeDataSets = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
280
|
-
var
|
|
281
|
-
return _regenerator.default.wrap(function (
|
|
282
|
-
while (1) switch (
|
|
402
|
+
var _initializeDataSets = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4(visibleDataSets, debugText) {
|
|
403
|
+
var _iterator2, _step2, dataSet, name, leafCount, url, _t;
|
|
404
|
+
return _regenerator.default.wrap(function (_context4) {
|
|
405
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
283
406
|
case 0:
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
407
|
+
if (!(this.state === 'stopped')) {
|
|
408
|
+
_context4.next = 1;
|
|
409
|
+
break;
|
|
410
|
+
}
|
|
411
|
+
return _context4.abrupt("return");
|
|
412
|
+
case 1:
|
|
413
|
+
_iterator2 = _createForOfIteratorHelper((0, _utils.sortByInitPriority)(visibleDataSets, _constants3.DATA_SET_INIT_PRIORITY));
|
|
414
|
+
_context4.prev = 2;
|
|
287
415
|
_iterator2.s();
|
|
288
|
-
case
|
|
416
|
+
case 3:
|
|
289
417
|
if ((_step2 = _iterator2.n()).done) {
|
|
290
|
-
|
|
418
|
+
_context4.next = 6;
|
|
291
419
|
break;
|
|
292
420
|
}
|
|
293
421
|
dataSet = _step2.value;
|
|
294
|
-
name = dataSet.name, leafCount = dataSet.leafCount;
|
|
422
|
+
name = dataSet.name, leafCount = dataSet.leafCount, url = dataSet.url;
|
|
295
423
|
if (!this.dataSets[name]) {
|
|
296
424
|
_loggerProxy.default.logger.info("HashTreeParser#initializeDataSets --> ".concat(this.debugId, " initializing dataset \"").concat(name, "\" (").concat(debugText, ")"));
|
|
297
425
|
this.dataSets[name] = _objectSpread({}, dataSet);
|
|
298
426
|
} else {
|
|
299
427
|
_loggerProxy.default.logger.info("HashTreeParser#initializeDataSets --> ".concat(this.debugId, " dataset \"").concat(name, "\" already exists (").concat(debugText, ")"));
|
|
300
428
|
}
|
|
301
|
-
if (
|
|
302
|
-
|
|
429
|
+
if (this.isVisibleDataSet(name)) {
|
|
430
|
+
_context4.next = 4;
|
|
303
431
|
break;
|
|
304
432
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
return this.sendInitializationSyncRequestToLocus(name, debugText);
|
|
311
|
-
case 3:
|
|
312
|
-
_data = _context3.sent;
|
|
313
|
-
if (!(_data.updateType === LocusInfoUpdateType.MEETING_ENDED)) {
|
|
314
|
-
_context3.next = 4;
|
|
433
|
+
if (this.addToVisibleDataSetsList({
|
|
434
|
+
name: name,
|
|
435
|
+
url: url
|
|
436
|
+
})) {
|
|
437
|
+
_context4.next = 4;
|
|
315
438
|
break;
|
|
316
439
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
// throw an error, it will be caught higher up and the meeting will be destroyed
|
|
320
|
-
throw new MeetingEndedError();
|
|
440
|
+
return _context4.abrupt("continue", 5);
|
|
321
441
|
case 4:
|
|
322
|
-
if (
|
|
323
|
-
|
|
442
|
+
if (!this.dataSets[name].hashTree) {
|
|
443
|
+
_loggerProxy.default.logger.info("HashTreeParser#initializeDataSets --> ".concat(this.debugId, " creating hash tree for visible dataset \"").concat(name, "\" (").concat(debugText, ")"));
|
|
444
|
+
this.dataSets[name].hashTree = new _hashTree.default([], leafCount);
|
|
445
|
+
this.enqueueSyncForDataset(name, "initialization sync for ".concat(debugText), true);
|
|
324
446
|
}
|
|
325
447
|
case 5:
|
|
326
|
-
|
|
448
|
+
_context4.next = 3;
|
|
327
449
|
break;
|
|
328
450
|
case 6:
|
|
329
|
-
|
|
451
|
+
_context4.next = 8;
|
|
330
452
|
break;
|
|
331
453
|
case 7:
|
|
332
|
-
|
|
333
|
-
_t =
|
|
454
|
+
_context4.prev = 7;
|
|
455
|
+
_t = _context4["catch"](2);
|
|
334
456
|
_iterator2.e(_t);
|
|
335
457
|
case 8:
|
|
336
|
-
|
|
458
|
+
_context4.prev = 8;
|
|
337
459
|
_iterator2.f();
|
|
338
|
-
return
|
|
460
|
+
return _context4.finish(8);
|
|
339
461
|
case 9:
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
updatedObjects: updatedObjects
|
|
343
|
-
});
|
|
462
|
+
_context4.next = 10;
|
|
463
|
+
return this.syncQueueProcessingPromise;
|
|
344
464
|
case 10:
|
|
345
465
|
case "end":
|
|
346
|
-
return
|
|
466
|
+
return _context4.stop();
|
|
347
467
|
}
|
|
348
|
-
},
|
|
468
|
+
}, _callee4, this, [[2, 7, 8, 9]]);
|
|
349
469
|
}));
|
|
350
|
-
function initializeDataSets(
|
|
470
|
+
function initializeDataSets(_x5, _x6) {
|
|
351
471
|
return _initializeDataSets.apply(this, arguments);
|
|
352
472
|
}
|
|
353
473
|
return initializeDataSets;
|
|
@@ -371,7 +491,7 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
371
491
|
copyData = _ref$copyData === void 0 ? false : _ref$copyData;
|
|
372
492
|
// object mapping dataset names to arrays of leaf data
|
|
373
493
|
var leafInfo = {};
|
|
374
|
-
var _findAndStoreMetaData = function findAndStoreMetaData(currentLocusPart) {
|
|
494
|
+
var _findAndStoreMetaData = function findAndStoreMetaData(currentLocusPart, currentLocusPartName) {
|
|
375
495
|
if ((0, _typeof2.default)(currentLocusPart) !== 'object' || currentLocusPart === null) {
|
|
376
496
|
return;
|
|
377
497
|
}
|
|
@@ -387,10 +507,16 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
387
507
|
version: version
|
|
388
508
|
};
|
|
389
509
|
if (copyData) {
|
|
390
|
-
|
|
510
|
+
if (type.toLowerCase() === _types.ObjectType.control) {
|
|
511
|
+
// control entries require special handling, because they are signalled by Locus
|
|
512
|
+
// differently when coming in messages vs API responses
|
|
513
|
+
newLeafInfo.data = (0, _defineProperty2.default)({}, currentLocusPartName, (0, _lodash.cloneDeep)(currentLocusPart));
|
|
514
|
+
} else {
|
|
515
|
+
newLeafInfo.data = (0, _lodash.cloneDeep)(currentLocusPart);
|
|
391
516
|
|
|
392
|
-
|
|
393
|
-
|
|
517
|
+
// remove any nested other objects that have their own htMeta
|
|
518
|
+
(0, _utils.deleteNestedObjectsWithHtMeta)(newLeafInfo.data);
|
|
519
|
+
}
|
|
394
520
|
}
|
|
395
521
|
var _iterator3 = _createForOfIteratorHelper(dataSetNames),
|
|
396
522
|
_step3;
|
|
@@ -409,12 +535,14 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
409
535
|
}
|
|
410
536
|
}
|
|
411
537
|
if ((0, _isArray.default)(currentLocusPart)) {
|
|
412
|
-
var _iterator4 = _createForOfIteratorHelper(currentLocusPart),
|
|
538
|
+
var _iterator4 = _createForOfIteratorHelper(currentLocusPart.entries()),
|
|
413
539
|
_step4;
|
|
414
540
|
try {
|
|
415
541
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
416
|
-
var
|
|
417
|
-
|
|
542
|
+
var _step4$value = (0, _slicedToArray2.default)(_step4.value, 2),
|
|
543
|
+
index = _step4$value[0],
|
|
544
|
+
item = _step4$value[1];
|
|
545
|
+
_findAndStoreMetaData(item, index.toString());
|
|
418
546
|
}
|
|
419
547
|
} catch (err) {
|
|
420
548
|
_iterator4.e(err);
|
|
@@ -425,15 +553,47 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
425
553
|
for (var _i = 0, _Object$keys = (0, _keys.default)(currentLocusPart); _i < _Object$keys.length; _i++) {
|
|
426
554
|
var key = _Object$keys[_i];
|
|
427
555
|
if (Object.prototype.hasOwnProperty.call(currentLocusPart, key)) {
|
|
428
|
-
_findAndStoreMetaData(currentLocusPart[key]);
|
|
556
|
+
_findAndStoreMetaData(currentLocusPart[key], key);
|
|
429
557
|
}
|
|
430
558
|
}
|
|
431
559
|
}
|
|
432
560
|
};
|
|
433
|
-
_findAndStoreMetaData(locus);
|
|
561
|
+
_findAndStoreMetaData(locus, 'locus');
|
|
434
562
|
return leafInfo;
|
|
435
563
|
}
|
|
436
564
|
|
|
565
|
+
/**
|
|
566
|
+
* Analyzes the Metadata object that is sent outside of Locus object, and appends its data to passed in leafInfo
|
|
567
|
+
* structure.
|
|
568
|
+
*
|
|
569
|
+
* @param {Record<string, LeafInfo[]>} leafInfo the structure to which the Metadata info will be appended
|
|
570
|
+
* @param {Metadata} metadata Metadata object
|
|
571
|
+
* @returns {void}
|
|
572
|
+
*/
|
|
573
|
+
}, {
|
|
574
|
+
key: "analyzeMetadata",
|
|
575
|
+
value: function analyzeMetadata(leafInfo, metadata) {
|
|
576
|
+
var _htMeta$dataSetNames;
|
|
577
|
+
var htMeta = metadata.htMeta;
|
|
578
|
+
if ((htMeta === null || htMeta === void 0 ? void 0 : (_htMeta$dataSetNames = htMeta.dataSetNames) === null || _htMeta$dataSetNames === void 0 ? void 0 : _htMeta$dataSetNames.length) === 1 && htMeta.dataSetNames[0].toLowerCase() === MetadataDataSetName) {
|
|
579
|
+
var _metadata$htMeta$elem = metadata.htMeta.elementId,
|
|
580
|
+
type = _metadata$htMeta$elem.type,
|
|
581
|
+
id = _metadata$htMeta$elem.id,
|
|
582
|
+
version = _metadata$htMeta$elem.version;
|
|
583
|
+
var dataSetName = htMeta.dataSetNames[0];
|
|
584
|
+
if (!leafInfo[dataSetName]) {
|
|
585
|
+
leafInfo[dataSetName] = [];
|
|
586
|
+
}
|
|
587
|
+
leafInfo[dataSetName].push({
|
|
588
|
+
type: type,
|
|
589
|
+
id: id,
|
|
590
|
+
version: version
|
|
591
|
+
});
|
|
592
|
+
} else {
|
|
593
|
+
throw new Error("".concat(this.debugId, " Metadata htMeta has unexpected dataSetNames: ").concat(htMeta && htMeta.dataSetNames.join(',')));
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
437
597
|
/**
|
|
438
598
|
* Checks if the provided hash tree message indicates the end of the meeting and that there won't be any more updates.
|
|
439
599
|
*
|
|
@@ -443,14 +603,14 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
443
603
|
}, {
|
|
444
604
|
key: "isEndMessage",
|
|
445
605
|
value: function isEndMessage(message) {
|
|
446
|
-
var
|
|
447
|
-
|
|
606
|
+
var _this3 = this;
|
|
607
|
+
return message.dataSets.some(function (dataSet) {
|
|
608
|
+
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())) {
|
|
609
|
+
// this is a special way for Locus to indicate that this meeting has ended
|
|
610
|
+
return true;
|
|
611
|
+
}
|
|
612
|
+
return false;
|
|
448
613
|
});
|
|
449
|
-
if (mainDataSet && mainDataSet.leafCount === 1 && mainDataSet.root === _constants2.EMPTY_HASH && this.dataSets[_constants2.DataSetNames.MAIN].version < mainDataSet.version) {
|
|
450
|
-
// this is a special way for Locus to indicate that this meeting has ended
|
|
451
|
-
return true;
|
|
452
|
-
}
|
|
453
|
-
return false;
|
|
454
614
|
}
|
|
455
615
|
|
|
456
616
|
/**
|
|
@@ -462,7 +622,7 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
462
622
|
}, {
|
|
463
623
|
key: "handleRootHashHeartBeatMessage",
|
|
464
624
|
value: function handleRootHashHeartBeatMessage(message) {
|
|
465
|
-
var
|
|
625
|
+
var _this4 = this;
|
|
466
626
|
var dataSets = message.dataSets;
|
|
467
627
|
_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) {
|
|
468
628
|
var name = _ref2.name,
|
|
@@ -476,12 +636,106 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
476
636
|
version: version
|
|
477
637
|
};
|
|
478
638
|
}))));
|
|
639
|
+
this.cancelPendingSyncsForDataSets(dataSets.map(function (ds) {
|
|
640
|
+
return ds.name;
|
|
641
|
+
}));
|
|
479
642
|
dataSets.forEach(function (dataSet) {
|
|
480
|
-
|
|
481
|
-
|
|
643
|
+
_this4.updateDataSetInfo(dataSet);
|
|
644
|
+
_this4.runSyncAlgorithm(dataSet);
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Handles known errors that can happen during syncs
|
|
650
|
+
*
|
|
651
|
+
* @param {any} error - The error to handle
|
|
652
|
+
* @returns {boolean} true if the error was recognized and handled, false otherwise
|
|
653
|
+
*/
|
|
654
|
+
}, {
|
|
655
|
+
key: "handleSyncErrors",
|
|
656
|
+
value: function handleSyncErrors(error) {
|
|
657
|
+
if (error instanceof MeetingEndedError) {
|
|
658
|
+
this.callLocusInfoUpdateCallback({
|
|
659
|
+
updateType: LocusInfoUpdateType.MEETING_ENDED
|
|
660
|
+
});
|
|
661
|
+
return true;
|
|
662
|
+
}
|
|
663
|
+
if (error instanceof LocusNotFoundError) {
|
|
664
|
+
this.callLocusInfoUpdateCallback({
|
|
665
|
+
updateType: LocusInfoUpdateType.LOCUS_NOT_FOUND
|
|
666
|
+
});
|
|
667
|
+
this.stop();
|
|
668
|
+
return true;
|
|
669
|
+
}
|
|
670
|
+
return false;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Asynchronously initializes new visible data sets
|
|
675
|
+
*
|
|
676
|
+
* @param {VisibleDataSetInfo[]} dataSetsRequiringInitialization list of datasets to initialize
|
|
677
|
+
* @returns {void}
|
|
678
|
+
*/
|
|
679
|
+
}, {
|
|
680
|
+
key: "queueInitForNewVisibleDataSets",
|
|
681
|
+
value: function queueInitForNewVisibleDataSets(dataSetsRequiringInitialization) {
|
|
682
|
+
var _this5 = this;
|
|
683
|
+
_loggerProxy.default.logger.info("HashTreeParser#queueInitForNewVisibleDataSets --> ".concat(this.debugId, " queuing initialization of new visible datasets: ").concat(dataSetsRequiringInitialization.map(function (ds) {
|
|
684
|
+
return ds.name;
|
|
685
|
+
}).join(', ')));
|
|
686
|
+
queueMicrotask(function () {
|
|
687
|
+
_this5.initializeNewVisibleDataSets(dataSetsRequiringInitialization).catch(function (error) {
|
|
688
|
+
if (!_this5.handleSyncErrors(error)) {
|
|
689
|
+
_loggerProxy.default.logger.warn("HashTreeParser#queueInitForNewVisibleDataSets --> ".concat(_this5.debugId, " error while initializing new visible datasets: ").concat(dataSetsRequiringInitialization.map(function (ds) {
|
|
690
|
+
return ds.name;
|
|
691
|
+
}).join(', '), ": "), error);
|
|
692
|
+
}
|
|
693
|
+
});
|
|
482
694
|
});
|
|
483
695
|
}
|
|
484
696
|
|
|
697
|
+
/**
|
|
698
|
+
* Handles updates to Metadata object that we receive from Locus via other means than messages. Right now
|
|
699
|
+
* that means only in the API response alongside locus object.
|
|
700
|
+
*
|
|
701
|
+
* @param {Metadata} metadata received in Locus update other than a message (for example in an API response)
|
|
702
|
+
* @param {HashTreeObject[]} updatedObjects a list of updated hash tree objects to which any updates resulting from new Metadata will be added
|
|
703
|
+
* @returns {void}
|
|
704
|
+
*/
|
|
705
|
+
}, {
|
|
706
|
+
key: "handleMetadataUpdate",
|
|
707
|
+
value: function handleMetadataUpdate(metadata, updatedObjects) {
|
|
708
|
+
var _this$dataSets$Metada;
|
|
709
|
+
var dataSetsRequiringInitialization = [];
|
|
710
|
+
|
|
711
|
+
// current assumption based on Locus docs is that Metadata object lives always in "self" data set
|
|
712
|
+
var hashTree = (_this$dataSets$Metada = this.dataSets[MetadataDataSetName]) === null || _this$dataSets$Metada === void 0 ? void 0 : _this$dataSets$Metada.hashTree;
|
|
713
|
+
if (!hashTree) {
|
|
714
|
+
_loggerProxy.default.logger.warn("HashTreeParser#handleLocusUpdate --> ".concat(this.debugId, " received Metadata object but no hash tree for \"").concat(MetadataDataSetName, "\" data set exists"));
|
|
715
|
+
} else {
|
|
716
|
+
var metadataUpdated = hashTree.putItem(metadata.htMeta.elementId);
|
|
717
|
+
if (metadataUpdated) {
|
|
718
|
+
// metadata in Locus API response is in a slightly different format than the objects in messages, so need to adapt it
|
|
719
|
+
var metadataObject = {
|
|
720
|
+
htMeta: metadata.htMeta,
|
|
721
|
+
data: metadata
|
|
722
|
+
};
|
|
723
|
+
updatedObjects.push(metadataObject);
|
|
724
|
+
var _this$checkForVisible = this.checkForVisibleDataSetChanges([metadataObject]),
|
|
725
|
+
changeDetected = _this$checkForVisible.changeDetected,
|
|
726
|
+
removedDataSets = _this$checkForVisible.removedDataSets,
|
|
727
|
+
addedDataSets = _this$checkForVisible.addedDataSets;
|
|
728
|
+
if (changeDetected) {
|
|
729
|
+
dataSetsRequiringInitialization = this.processVisibleDataSetChanges(removedDataSets, addedDataSets, updatedObjects);
|
|
730
|
+
}
|
|
731
|
+
if (dataSetsRequiringInitialization.length > 0) {
|
|
732
|
+
// there are some data sets that we need to initialize asynchronously
|
|
733
|
+
this.queueInitForNewVisibleDataSets(dataSetsRequiringInitialization);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
|
|
485
739
|
/**
|
|
486
740
|
* This method should be called when we receive a partial locus DTO that contains dataSets and htMeta information
|
|
487
741
|
* It updates the hash trees with the new leaf data based on the received Locus
|
|
@@ -492,23 +746,32 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
492
746
|
}, {
|
|
493
747
|
key: "handleLocusUpdate",
|
|
494
748
|
value: function handleLocusUpdate(update) {
|
|
495
|
-
var
|
|
749
|
+
var _this6 = this;
|
|
750
|
+
if (this.state === 'stopped') {
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
496
753
|
var dataSets = update.dataSets,
|
|
497
|
-
locus = update.locus
|
|
754
|
+
locus = update.locus,
|
|
755
|
+
metadata = update.metadata;
|
|
756
|
+
_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) {
|
|
757
|
+
return ds.name;
|
|
758
|
+
}).join(','), " metadata=").concat(metadata ? 'yes' : 'no'));
|
|
498
759
|
if (!dataSets) {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
760
|
+
// this happens for example when we handle GET /loci response
|
|
761
|
+
_loggerProxy.default.logger.info("HashTreeParser#handleLocusUpdate --> ".concat(this.debugId, " received hash tree update without dataSets"));
|
|
762
|
+
} else {
|
|
763
|
+
var _iterator5 = _createForOfIteratorHelper(dataSets),
|
|
764
|
+
_step5;
|
|
765
|
+
try {
|
|
766
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
767
|
+
var dataSet = _step5.value;
|
|
768
|
+
this.updateDataSetInfo(dataSet);
|
|
769
|
+
}
|
|
770
|
+
} catch (err) {
|
|
771
|
+
_iterator5.e(err);
|
|
772
|
+
} finally {
|
|
773
|
+
_iterator5.f();
|
|
507
774
|
}
|
|
508
|
-
} catch (err) {
|
|
509
|
-
_iterator5.e(err);
|
|
510
|
-
} finally {
|
|
511
|
-
_iterator5.f();
|
|
512
775
|
}
|
|
513
776
|
var updatedObjects = [];
|
|
514
777
|
|
|
@@ -517,11 +780,16 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
517
780
|
copyData: true
|
|
518
781
|
});
|
|
519
782
|
|
|
783
|
+
// if we got metadata, process it (currently that means only potential visible data set list changes)
|
|
784
|
+
if (metadata) {
|
|
785
|
+
this.handleMetadataUpdate(metadata, updatedObjects);
|
|
786
|
+
}
|
|
787
|
+
|
|
520
788
|
// then process the data in hash trees, if it is a new version, then add it to updatedObjects
|
|
521
789
|
(0, _keys.default)(leafInfo).forEach(function (dataSetName) {
|
|
522
|
-
if (
|
|
523
|
-
if (
|
|
524
|
-
var appliedChangesList =
|
|
790
|
+
if (_this6.dataSets[dataSetName]) {
|
|
791
|
+
if (_this6.dataSets[dataSetName].hashTree) {
|
|
792
|
+
var appliedChangesList = _this6.dataSets[dataSetName].hashTree.putItems(leafInfo[dataSetName].map(function (leaf) {
|
|
525
793
|
return {
|
|
526
794
|
id: leaf.id,
|
|
527
795
|
type: leaf.type,
|
|
@@ -548,10 +816,10 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
548
816
|
});
|
|
549
817
|
} else {
|
|
550
818
|
// no hash tree means that the data set is not visible
|
|
551
|
-
_loggerProxy.default.logger.warn("HashTreeParser#handleLocusUpdate --> ".concat(
|
|
819
|
+
_loggerProxy.default.logger.warn("HashTreeParser#handleLocusUpdate --> ".concat(_this6.debugId, " received leaf data for data set \"").concat(dataSetName, "\" that has no hash tree created, ignoring"));
|
|
552
820
|
}
|
|
553
821
|
} else {
|
|
554
|
-
_loggerProxy.default.logger.
|
|
822
|
+
_loggerProxy.default.logger.info("HashTreeParser#handleLocusUpdate --> ".concat(_this6.debugId, " received leaf data for unknown data set \"").concat(dataSetName, "\", ignoring"));
|
|
555
823
|
}
|
|
556
824
|
});
|
|
557
825
|
if (updatedObjects.length === 0) {
|
|
@@ -562,9 +830,6 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
562
830
|
updatedObjects: updatedObjects
|
|
563
831
|
});
|
|
564
832
|
}
|
|
565
|
-
|
|
566
|
-
// todo: once Locus design on how visible data sets will be communicated in subsequent API responses is confirmed,
|
|
567
|
-
// we'll need to check here if visible data sets have changed and update this.visibleDataSets, remove/create hash trees etc
|
|
568
833
|
}
|
|
569
834
|
|
|
570
835
|
/**
|
|
@@ -578,7 +843,7 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
578
843
|
value: function updateDataSetInfo(receivedDataSet) {
|
|
579
844
|
if (!this.dataSets[receivedDataSet.name]) {
|
|
580
845
|
this.dataSets[receivedDataSet.name] = _objectSpread({}, receivedDataSet);
|
|
581
|
-
_loggerProxy.default.logger.info("HashTreeParser#
|
|
846
|
+
_loggerProxy.default.logger.info("HashTreeParser#updateDataSetInfo --> ".concat(this.debugId, " created entry for \"").concat(receivedDataSet.name, "\" dataset: version=").concat(receivedDataSet.version, ", root=").concat(receivedDataSet.root));
|
|
582
847
|
return;
|
|
583
848
|
}
|
|
584
849
|
// update our version of the dataSet
|
|
@@ -590,10 +855,26 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
590
855
|
maxMs: receivedDataSet.backoff.maxMs,
|
|
591
856
|
exponent: receivedDataSet.backoff.exponent
|
|
592
857
|
};
|
|
593
|
-
|
|
858
|
+
this.dataSets[receivedDataSet.name].heartbeatIntervalMs = receivedDataSet.heartbeatIntervalMs;
|
|
859
|
+
_loggerProxy.default.logger.info("HashTreeParser#updateDataSetInfo --> ".concat(this.debugId, " updated \"").concat(receivedDataSet.name, "\" dataset to version=").concat(receivedDataSet.version, ", root=").concat(receivedDataSet.root));
|
|
594
860
|
}
|
|
595
861
|
}
|
|
596
862
|
|
|
863
|
+
/**
|
|
864
|
+
* Updates the leaf count for a data set, resizing its hash tree accordingly.
|
|
865
|
+
*
|
|
866
|
+
* @param {InternalDataSet} dataSet - The data set to update
|
|
867
|
+
* @param {number} newLeafCount - The new leaf count
|
|
868
|
+
* @returns {void}
|
|
869
|
+
*/
|
|
870
|
+
}, {
|
|
871
|
+
key: "updateDataSetLeafCount",
|
|
872
|
+
value: function updateDataSetLeafCount(dataSet, newLeafCount) {
|
|
873
|
+
var _dataSet$hashTree;
|
|
874
|
+
(_dataSet$hashTree = dataSet.hashTree) === null || _dataSet$hashTree === void 0 ? void 0 : _dataSet$hashTree.resize(newLeafCount);
|
|
875
|
+
dataSet.leafCount = newLeafCount;
|
|
876
|
+
}
|
|
877
|
+
|
|
597
878
|
/**
|
|
598
879
|
* Checks for changes in the visible data sets based on the updated objects.
|
|
599
880
|
* @param {HashTreeObject[]} updatedObjects - The list of updated hash tree objects.
|
|
@@ -602,24 +883,33 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
602
883
|
}, {
|
|
603
884
|
key: "checkForVisibleDataSetChanges",
|
|
604
885
|
value: function checkForVisibleDataSetChanges(updatedObjects) {
|
|
605
|
-
var
|
|
886
|
+
var _this7 = this;
|
|
606
887
|
var removedDataSets = [];
|
|
607
888
|
var addedDataSets = [];
|
|
608
889
|
|
|
609
|
-
// visibleDataSets can only be changed by
|
|
890
|
+
// visibleDataSets can only be changed by Metadata object updates
|
|
610
891
|
updatedObjects.forEach(function (object) {
|
|
611
892
|
var _object$data;
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
893
|
+
if ((0, _utils.isMetadata)(object) && (_object$data = object.data) !== null && _object$data !== void 0 && _object$data.visibleDataSets) {
|
|
894
|
+
var newVisibleDataSets = object.data.visibleDataSets.filter(function (vds) {
|
|
895
|
+
return !_this7.isExcludedDataSet(vds.name);
|
|
896
|
+
});
|
|
897
|
+
removedDataSets = _this7.visibleDataSets.filter(function (ds) {
|
|
898
|
+
return !newVisibleDataSets.some(function (nvs) {
|
|
899
|
+
return nvs.name === ds.name;
|
|
900
|
+
});
|
|
617
901
|
});
|
|
618
|
-
addedDataSets = newVisibleDataSets.filter(function (
|
|
619
|
-
return
|
|
902
|
+
addedDataSets = newVisibleDataSets.filter(function (nvs) {
|
|
903
|
+
return _this7.visibleDataSets.every(function (ds) {
|
|
904
|
+
return ds.name !== nvs.name;
|
|
905
|
+
});
|
|
620
906
|
});
|
|
621
907
|
if (removedDataSets.length > 0 || addedDataSets.length > 0) {
|
|
622
|
-
_loggerProxy.default.logger.info("HashTreeParser#checkForVisibleDataSetChanges --> ".concat(
|
|
908
|
+
_loggerProxy.default.logger.info("HashTreeParser#checkForVisibleDataSetChanges --> ".concat(_this7.debugId, " visible data sets change: removed: ").concat(removedDataSets.map(function (ds) {
|
|
909
|
+
return ds.name;
|
|
910
|
+
}).join(', '), ", added: ").concat(addedDataSets.map(function (ds) {
|
|
911
|
+
return ds.name;
|
|
912
|
+
}).join(', ')));
|
|
623
913
|
}
|
|
624
914
|
}
|
|
625
915
|
});
|
|
@@ -639,13 +929,20 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
639
929
|
}, {
|
|
640
930
|
key: "deleteHashTree",
|
|
641
931
|
value: function deleteHashTree(dataSetName) {
|
|
932
|
+
var _this$dataSets$dataSe;
|
|
642
933
|
this.dataSets[dataSetName].hashTree = undefined;
|
|
934
|
+
(_this$dataSets$dataSe = this.dataSets[dataSetName].syncAbortController) === null || _this$dataSets$dataSe === void 0 ? void 0 : _this$dataSets$dataSe.abort();
|
|
935
|
+
this.dataSets[dataSetName].syncAbortController = undefined;
|
|
643
936
|
|
|
644
|
-
// we also need to stop the
|
|
937
|
+
// we also need to stop the timers as there is no hash tree anymore to sync
|
|
645
938
|
if (this.dataSets[dataSetName].timer) {
|
|
646
939
|
clearTimeout(this.dataSets[dataSetName].timer);
|
|
647
940
|
this.dataSets[dataSetName].timer = undefined;
|
|
648
941
|
}
|
|
942
|
+
if (this.dataSets[dataSetName].heartbeatWatchdogTimer) {
|
|
943
|
+
clearTimeout(this.dataSets[dataSetName].heartbeatWatchdogTimer);
|
|
944
|
+
this.dataSets[dataSetName].heartbeatWatchdogTimer = undefined;
|
|
945
|
+
}
|
|
649
946
|
}
|
|
650
947
|
|
|
651
948
|
/**
|
|
@@ -657,38 +954,40 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
657
954
|
* visible data sets and they require async initialization, the names of these data sets
|
|
658
955
|
* are returned in an array.
|
|
659
956
|
*
|
|
660
|
-
* @param {
|
|
661
|
-
* @param {
|
|
957
|
+
* @param {VisibleDataSetInfo[]} removedDataSets - The list of removed data sets.
|
|
958
|
+
* @param {VisibleDataSetInfo[]} addedDataSets - The list of added data sets.
|
|
662
959
|
* @param {HashTreeObject[]} updatedObjects - The list of updated hash tree objects to which changes will be added.
|
|
663
|
-
* @returns {
|
|
960
|
+
* @returns {VisibleDataSetInfo[]} list of data sets that couldn't be initialized synchronously
|
|
664
961
|
*/
|
|
665
962
|
}, {
|
|
666
963
|
key: "processVisibleDataSetChanges",
|
|
667
964
|
value: function processVisibleDataSetChanges(removedDataSets, addedDataSets, updatedObjects) {
|
|
668
|
-
var
|
|
965
|
+
var _this8 = this;
|
|
669
966
|
var dataSetsRequiringInitialization = [];
|
|
670
967
|
|
|
671
968
|
// if a visible data set was removed, we need to tell our client that all objects from it are removed
|
|
672
969
|
var removedObjects = [];
|
|
673
970
|
removedDataSets.forEach(function (ds) {
|
|
674
|
-
var
|
|
675
|
-
if ((
|
|
676
|
-
for (var i = 0; i <
|
|
677
|
-
removedObjects.push.apply(removedObjects, (0, _toConsumableArray2.default)(
|
|
971
|
+
var _this8$dataSets$ds$na;
|
|
972
|
+
if ((_this8$dataSets$ds$na = _this8.dataSets[ds.name]) !== null && _this8$dataSets$ds$na !== void 0 && _this8$dataSets$ds$na.hashTree) {
|
|
973
|
+
for (var i = 0; i < _this8.dataSets[ds.name].hashTree.numLeaves; i += 1) {
|
|
974
|
+
removedObjects.push.apply(removedObjects, (0, _toConsumableArray2.default)(_this8.dataSets[ds.name].hashTree.getLeafData(i).map(function (elementId) {
|
|
678
975
|
return {
|
|
679
976
|
htMeta: {
|
|
680
977
|
elementId: elementId,
|
|
681
|
-
dataSetNames: [ds]
|
|
978
|
+
dataSetNames: [ds.name]
|
|
682
979
|
},
|
|
683
980
|
data: null
|
|
684
981
|
};
|
|
685
982
|
})));
|
|
686
983
|
}
|
|
687
|
-
|
|
984
|
+
_this8.deleteHashTree(ds.name);
|
|
688
985
|
}
|
|
689
986
|
});
|
|
690
987
|
this.visibleDataSets = this.visibleDataSets.filter(function (vds) {
|
|
691
|
-
return !removedDataSets.
|
|
988
|
+
return !removedDataSets.some(function (rds) {
|
|
989
|
+
return rds.name === vds.name;
|
|
990
|
+
});
|
|
692
991
|
});
|
|
693
992
|
updatedObjects.push.apply(updatedObjects, removedObjects);
|
|
694
993
|
|
|
@@ -698,22 +997,29 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
698
997
|
try {
|
|
699
998
|
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
700
999
|
var ds = _step6.value;
|
|
701
|
-
var dataSetInfo = this.dataSets[ds];
|
|
1000
|
+
var dataSetInfo = this.dataSets[ds.name];
|
|
702
1001
|
if (dataSetInfo) {
|
|
703
|
-
if (this.
|
|
704
|
-
_loggerProxy.default.logger.info("HashTreeParser#processVisibleDataSetChanges --> ".concat(this.debugId, " Data set \"").concat(ds, "\" is already visible, skipping"));
|
|
1002
|
+
if (this.isVisibleDataSet(dataSetInfo.name)) {
|
|
1003
|
+
_loggerProxy.default.logger.info("HashTreeParser#processVisibleDataSetChanges --> ".concat(this.debugId, " Data set \"").concat(ds.name, "\" is already visible, skipping"));
|
|
705
1004
|
|
|
706
1005
|
// eslint-disable-next-line no-continue
|
|
707
1006
|
continue;
|
|
708
1007
|
}
|
|
709
|
-
_loggerProxy.default.logger.info("HashTreeParser#processVisibleDataSetChanges --> ".concat(this.debugId, " Adding visible data set \"").concat(ds, "\""));
|
|
710
|
-
this.
|
|
1008
|
+
_loggerProxy.default.logger.info("HashTreeParser#processVisibleDataSetChanges --> ".concat(this.debugId, " Adding visible data set \"").concat(ds.name, "\""));
|
|
1009
|
+
if (!this.addToVisibleDataSetsList(ds)) {
|
|
1010
|
+
// eslint-disable-next-line no-continue
|
|
1011
|
+
continue;
|
|
1012
|
+
}
|
|
711
1013
|
var hashTree = new _hashTree.default([], dataSetInfo.leafCount);
|
|
712
1014
|
this.dataSets[dataSetInfo.name] = _objectSpread(_objectSpread({}, dataSetInfo), {}, {
|
|
713
1015
|
hashTree: hashTree
|
|
714
1016
|
});
|
|
1017
|
+
|
|
1018
|
+
// this call is needed here for the edge case where we receive a message with new visible data sets
|
|
1019
|
+
// and there are no objects belonging to these data sets in the message but we already have the info about them in this.dataSets
|
|
1020
|
+
this.runSyncAlgorithm(this.dataSets[dataSetInfo.name]);
|
|
715
1021
|
} else {
|
|
716
|
-
_loggerProxy.default.logger.info("HashTreeParser#processVisibleDataSetChanges --> ".concat(this.debugId, " visible data set \"").concat(ds, "\" added but no info about it in our dataSets structures"));
|
|
1022
|
+
_loggerProxy.default.logger.info("HashTreeParser#processVisibleDataSetChanges --> ".concat(this.debugId, " visible data set \"").concat(ds.name, "\" added but no info about it in our dataSets structures"));
|
|
717
1023
|
// todo: add a metric here
|
|
718
1024
|
dataSetsRequiringInitialization.push(ds);
|
|
719
1025
|
}
|
|
@@ -730,82 +1036,84 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
730
1036
|
* Adds entries to the passed in updateObjects array
|
|
731
1037
|
* for the changes that result from adding and removing visible data sets.
|
|
732
1038
|
*
|
|
733
|
-
* @param {
|
|
734
|
-
* @param {string[]} addedDataSets - The list of added data sets.
|
|
1039
|
+
* @param {VisibleDataSetInfo[]} addedDataSets - The list of added data sets.
|
|
735
1040
|
* @returns {Promise<void>}
|
|
736
1041
|
*/
|
|
737
1042
|
}, {
|
|
738
1043
|
key: "initializeNewVisibleDataSets",
|
|
739
1044
|
value: (function () {
|
|
740
|
-
var _initializeNewVisibleDataSets = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
741
|
-
var
|
|
1045
|
+
var _initializeNewVisibleDataSets = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5(addedDataSets) {
|
|
1046
|
+
var _this9 = this;
|
|
742
1047
|
var allDataSets, _iterator7, _step7, _loop, _t2;
|
|
743
|
-
return _regenerator.default.wrap(function (
|
|
744
|
-
while (1) switch (
|
|
1048
|
+
return _regenerator.default.wrap(function (_context6) {
|
|
1049
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
745
1050
|
case 0:
|
|
746
|
-
|
|
747
|
-
|
|
1051
|
+
if (!(this.state === 'stopped')) {
|
|
1052
|
+
_context6.next = 1;
|
|
1053
|
+
break;
|
|
1054
|
+
}
|
|
1055
|
+
return _context6.abrupt("return");
|
|
748
1056
|
case 1:
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
1057
|
+
_context6.next = 2;
|
|
1058
|
+
return this.getAllVisibleDataSetsFromLocus();
|
|
1059
|
+
case 2:
|
|
1060
|
+
allDataSets = _context6.sent;
|
|
1061
|
+
_iterator7 = _createForOfIteratorHelper((0, _utils.sortByInitPriority)(addedDataSets, _constants3.DATA_SET_INIT_PRIORITY));
|
|
1062
|
+
_context6.prev = 3;
|
|
752
1063
|
_loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
|
|
753
|
-
var ds, dataSetInfo
|
|
754
|
-
return _regenerator.default.wrap(function (
|
|
755
|
-
while (1) switch (
|
|
1064
|
+
var ds, dataSetInfo;
|
|
1065
|
+
return _regenerator.default.wrap(function (_context5) {
|
|
1066
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
756
1067
|
case 0:
|
|
757
1068
|
ds = _step7.value;
|
|
758
1069
|
dataSetInfo = allDataSets.find(function (d) {
|
|
759
|
-
return d.name === ds;
|
|
1070
|
+
return d.name === ds.name;
|
|
760
1071
|
});
|
|
761
|
-
_loggerProxy.default.logger.info("HashTreeParser#initializeNewVisibleDataSets --> ".concat(
|
|
1072
|
+
_loggerProxy.default.logger.info("HashTreeParser#initializeNewVisibleDataSets --> ".concat(_this9.debugId, " initializing data set \"").concat(ds.name, "\""));
|
|
762
1073
|
if (dataSetInfo) {
|
|
763
|
-
|
|
1074
|
+
_context5.next = 1;
|
|
764
1075
|
break;
|
|
765
1076
|
}
|
|
766
|
-
_loggerProxy.default.logger.warn("HashTreeParser#
|
|
767
|
-
|
|
1077
|
+
_loggerProxy.default.logger.warn("HashTreeParser#initializeNewVisibleDataSets --> ".concat(_this9.debugId, " missing info about data set \"").concat(ds.name, "\" in Locus response from visibleDataSetsUrl"));
|
|
1078
|
+
_context5.next = 2;
|
|
768
1079
|
break;
|
|
769
1080
|
case 1:
|
|
770
|
-
|
|
771
|
-
return
|
|
1081
|
+
_context5.next = 2;
|
|
1082
|
+
return _this9.initializeNewVisibleDataSet(ds, dataSetInfo);
|
|
772
1083
|
case 2:
|
|
773
|
-
updates = _context4.sent;
|
|
774
|
-
_this6.callLocusInfoUpdateCallback(updates);
|
|
775
|
-
case 3:
|
|
776
1084
|
case "end":
|
|
777
|
-
return
|
|
1085
|
+
return _context5.stop();
|
|
778
1086
|
}
|
|
779
1087
|
}, _loop);
|
|
780
1088
|
});
|
|
781
1089
|
_iterator7.s();
|
|
782
|
-
case
|
|
1090
|
+
case 4:
|
|
783
1091
|
if ((_step7 = _iterator7.n()).done) {
|
|
784
|
-
|
|
1092
|
+
_context6.next = 6;
|
|
785
1093
|
break;
|
|
786
1094
|
}
|
|
787
|
-
return
|
|
788
|
-
case 4:
|
|
789
|
-
_context5.next = 3;
|
|
790
|
-
break;
|
|
1095
|
+
return _context6.delegateYield(_loop(), "t0", 5);
|
|
791
1096
|
case 5:
|
|
792
|
-
|
|
1097
|
+
_context6.next = 4;
|
|
793
1098
|
break;
|
|
794
1099
|
case 6:
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
_iterator7.e(_t2);
|
|
1100
|
+
_context6.next = 8;
|
|
1101
|
+
break;
|
|
798
1102
|
case 7:
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
1103
|
+
_context6.prev = 7;
|
|
1104
|
+
_t2 = _context6["catch"](3);
|
|
1105
|
+
_iterator7.e(_t2);
|
|
802
1106
|
case 8:
|
|
1107
|
+
_context6.prev = 8;
|
|
1108
|
+
_iterator7.f();
|
|
1109
|
+
return _context6.finish(8);
|
|
1110
|
+
case 9:
|
|
803
1111
|
case "end":
|
|
804
|
-
return
|
|
1112
|
+
return _context6.stop();
|
|
805
1113
|
}
|
|
806
|
-
},
|
|
1114
|
+
}, _callee5, this, [[3, 7, 8, 9]]);
|
|
807
1115
|
}));
|
|
808
|
-
function initializeNewVisibleDataSets(
|
|
1116
|
+
function initializeNewVisibleDataSets(_x7) {
|
|
809
1117
|
return _initializeNewVisibleDataSets.apply(this, arguments);
|
|
810
1118
|
}
|
|
811
1119
|
return initializeNewVisibleDataSets;
|
|
@@ -815,156 +1123,131 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
815
1123
|
*
|
|
816
1124
|
* @param {HashTreeMessage} message - The hash tree message containing data sets and objects to be processed
|
|
817
1125
|
* @param {string} [debugText] - Optional debug text to include in logs
|
|
818
|
-
* @returns {
|
|
1126
|
+
* @returns {HashTreeObject[]} list of hash tree objects that were updated as a result of processing the message
|
|
819
1127
|
*/
|
|
820
1128
|
)
|
|
821
1129
|
}, {
|
|
822
1130
|
key: "parseMessage",
|
|
823
|
-
value:
|
|
824
|
-
var
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
1131
|
+
value: function parseMessage(message, debugText) {
|
|
1132
|
+
var _message$dataSets,
|
|
1133
|
+
_message$locusStateEl,
|
|
1134
|
+
_message$locusStateEl2,
|
|
1135
|
+
_this0 = this;
|
|
1136
|
+
if (this.state === 'stopped') {
|
|
1137
|
+
return [];
|
|
1138
|
+
}
|
|
1139
|
+
var dataSets = message.dataSets,
|
|
1140
|
+
visibleDataSetsUrl = message.visibleDataSetsUrl;
|
|
1141
|
+
_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) {
|
|
1142
|
+
var name = _ref5.name,
|
|
1143
|
+
version = _ref5.version;
|
|
1144
|
+
return "".concat(name, ":").concat(version);
|
|
1145
|
+
}).join(','), ", elements: ").concat((_message$locusStateEl = message.locusStateElements) === null || _message$locusStateEl === void 0 ? void 0 : _message$locusStateEl.map(function (el) {
|
|
1146
|
+
return "".concat(el.htMeta.elementId.type, ":").concat(el.htMeta.elementId.id, ":").concat(el.htMeta.elementId.version).concat(el.data ? '+' : '-');
|
|
1147
|
+
}).join(',')));
|
|
1148
|
+
if (((_message$locusStateEl2 = message.locusStateElements) === null || _message$locusStateEl2 === void 0 ? void 0 : _message$locusStateEl2.length) === 0) {
|
|
1149
|
+
_loggerProxy.default.logger.warn("HashTreeParser#parseMessage --> ".concat(this.debugId, " got empty locusStateElements!!!"));
|
|
1150
|
+
_metrics.default.sendBehavioralMetric(_constants.default.HASH_TREE_EMPTY_LOCUS_STATE_ELEMENTS, {
|
|
1151
|
+
debugId: this.debugId
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
837
1154
|
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
_loggerProxy.default.logger.info("HashTreeParser#parseMessage --> ".concat(this.debugId, " received END message"));
|
|
848
|
-
this.stopAllTimers();
|
|
849
|
-
return _context6.abrupt("return", {
|
|
850
|
-
updateType: LocusInfoUpdateType.MEETING_ENDED
|
|
851
|
-
});
|
|
852
|
-
case 1:
|
|
853
|
-
isRosterDropped = false;
|
|
854
|
-
updatedObjects = []; // when we detect new visible datasets, it may be that the metadata about them is not
|
|
855
|
-
// available in the message, they will require separate async initialization
|
|
856
|
-
dataSetsRequiringInitialization = []; // first find out if there are any visible data set changes - they're signalled in SELF object updates
|
|
857
|
-
selfUpdates = (message.locusStateElements || []).filter(function (object) {
|
|
858
|
-
return (
|
|
859
|
-
// todo: SPARK-744859 once Locus supports it, we will filter for "Metadata" type here instead of "self"
|
|
860
|
-
(0, _utils.isSelf)(object)
|
|
861
|
-
);
|
|
862
|
-
});
|
|
863
|
-
if (selfUpdates.length > 0) {
|
|
864
|
-
updatedSelfObjects = [];
|
|
865
|
-
selfUpdates.forEach(function (object) {
|
|
866
|
-
// todo: once Locus supports it, we will use the "view" field here instead of dataSetNames
|
|
867
|
-
var _iterator8 = _createForOfIteratorHelper(object.htMeta.dataSetNames),
|
|
868
|
-
_step8;
|
|
869
|
-
try {
|
|
870
|
-
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
871
|
-
var _this7$dataSets$dataS;
|
|
872
|
-
var dataSetName = _step8.value;
|
|
873
|
-
var hashTree = (_this7$dataSets$dataS = _this7.dataSets[dataSetName]) === null || _this7$dataSets$dataS === void 0 ? void 0 : _this7$dataSets$dataS.hashTree;
|
|
874
|
-
if (hashTree && object.data) {
|
|
875
|
-
if (hashTree.putItem(object.htMeta.elementId)) {
|
|
876
|
-
updatedSelfObjects.push(object);
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
} catch (err) {
|
|
881
|
-
_iterator8.e(err);
|
|
882
|
-
} finally {
|
|
883
|
-
_iterator8.f();
|
|
884
|
-
}
|
|
885
|
-
});
|
|
886
|
-
updatedObjects.push.apply(updatedObjects, updatedSelfObjects);
|
|
887
|
-
_this$checkForVisible = this.checkForVisibleDataSetChanges(updatedSelfObjects), changeDetected = _this$checkForVisible.changeDetected, removedDataSets = _this$checkForVisible.removedDataSets, addedDataSets = _this$checkForVisible.addedDataSets;
|
|
888
|
-
if (changeDetected) {
|
|
889
|
-
dataSetsRequiringInitialization = this.processVisibleDataSetChanges(removedDataSets, addedDataSets, updatedObjects);
|
|
890
|
-
}
|
|
891
|
-
}
|
|
1155
|
+
// first, update our metadata about the datasets with info from the message
|
|
1156
|
+
this.visibleDataSetsUrl = visibleDataSetsUrl;
|
|
1157
|
+
dataSets.forEach(function (dataSet) {
|
|
1158
|
+
return _this0.updateDataSetInfo(dataSet);
|
|
1159
|
+
});
|
|
1160
|
+
this.cancelPendingSyncsForDataSets(dataSets.map(function (ds) {
|
|
1161
|
+
return ds.name;
|
|
1162
|
+
}));
|
|
1163
|
+
var updatedObjects = [];
|
|
892
1164
|
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
object = _ref6[1];
|
|
916
|
-
if (changeApplied) {
|
|
917
|
-
if ((0, _utils.isSelf)(object) && !object.data) {
|
|
918
|
-
isRosterDropped = true;
|
|
919
|
-
}
|
|
920
|
-
// add to updatedObjects so that our locus DTO will get updated with the new object
|
|
921
|
-
updatedObjects.push(object);
|
|
922
|
-
}
|
|
923
|
-
});
|
|
924
|
-
} else {
|
|
925
|
-
_loggerProxy.default.logger.info("Locus-info:index#parseMessage --> ".concat(_this7.debugId, " unexpected (not visible) dataSet ").concat(dataSet.name, " received in hash tree message"));
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
if (!isRosterDropped) {
|
|
929
|
-
_this7.runSyncAlgorithm(dataSet);
|
|
1165
|
+
// when we detect new visible datasets, it may be that the metadata about them is not
|
|
1166
|
+
// available in the message, they will require separate async initialization
|
|
1167
|
+
var dataSetsRequiringInitialization = [];
|
|
1168
|
+
|
|
1169
|
+
// first find out if there are any visible data set changes - they're signalled in Metadata object updates
|
|
1170
|
+
var metadataUpdates = (message.locusStateElements || []).filter(function (object) {
|
|
1171
|
+
return (0, _utils.isMetadata)(object);
|
|
1172
|
+
});
|
|
1173
|
+
if (metadataUpdates.length > 0) {
|
|
1174
|
+
var updatedMetadataObjects = [];
|
|
1175
|
+
metadataUpdates.forEach(function (object) {
|
|
1176
|
+
// todo: once Locus supports it, we will use the "view" field here instead of dataSetNames
|
|
1177
|
+
var _iterator8 = _createForOfIteratorHelper(object.htMeta.dataSetNames),
|
|
1178
|
+
_step8;
|
|
1179
|
+
try {
|
|
1180
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
1181
|
+
var _this0$dataSets$dataS;
|
|
1182
|
+
var dataSetName = _step8.value;
|
|
1183
|
+
var hashTree = (_this0$dataSets$dataS = _this0.dataSets[dataSetName]) === null || _this0$dataSets$dataS === void 0 ? void 0 : _this0$dataSets$dataS.hashTree;
|
|
1184
|
+
if (hashTree && object.data) {
|
|
1185
|
+
if (hashTree.putItem(object.htMeta.elementId)) {
|
|
1186
|
+
updatedMetadataObjects.push(object);
|
|
930
1187
|
}
|
|
931
|
-
});
|
|
932
|
-
if (!isRosterDropped) {
|
|
933
|
-
_context6.next = 2;
|
|
934
|
-
break;
|
|
935
1188
|
}
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
1189
|
+
}
|
|
1190
|
+
} catch (err) {
|
|
1191
|
+
_iterator8.e(err);
|
|
1192
|
+
} finally {
|
|
1193
|
+
_iterator8.f();
|
|
1194
|
+
}
|
|
1195
|
+
});
|
|
1196
|
+
updatedObjects.push.apply(updatedObjects, updatedMetadataObjects);
|
|
1197
|
+
var _this$checkForVisible2 = this.checkForVisibleDataSetChanges(updatedMetadataObjects),
|
|
1198
|
+
changeDetected = _this$checkForVisible2.changeDetected,
|
|
1199
|
+
removedDataSets = _this$checkForVisible2.removedDataSets,
|
|
1200
|
+
addedDataSets = _this$checkForVisible2.addedDataSets;
|
|
1201
|
+
if (changeDetected) {
|
|
1202
|
+
dataSetsRequiringInitialization = this.processVisibleDataSetChanges(removedDataSets, addedDataSets, updatedObjects);
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
if (message.locusStateElements && message.locusStateElements.length > 0) {
|
|
1206
|
+
// by this point we now have this.dataSets setup for data sets from this message
|
|
1207
|
+
// and hash trees created for the new visible data sets,
|
|
1208
|
+
// so we can now process all the updates from the message
|
|
1209
|
+
dataSets.forEach(function (dataSet) {
|
|
1210
|
+
if (_this0.dataSets[dataSet.name]) {
|
|
1211
|
+
var hashTree = _this0.dataSets[dataSet.name].hashTree;
|
|
1212
|
+
if (hashTree) {
|
|
1213
|
+
var locusStateElementsForThisSet = message.locusStateElements.filter(function (object) {
|
|
1214
|
+
return object.htMeta.dataSetNames.includes(dataSet.name);
|
|
942
1215
|
});
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
1216
|
+
var appliedChangesList = hashTree.updateItems(locusStateElementsForThisSet.map(function (object) {
|
|
1217
|
+
return object.data ? {
|
|
1218
|
+
operation: 'update',
|
|
1219
|
+
item: object.htMeta.elementId
|
|
1220
|
+
} : {
|
|
1221
|
+
operation: 'remove',
|
|
1222
|
+
item: object.htMeta.elementId
|
|
1223
|
+
};
|
|
1224
|
+
}));
|
|
1225
|
+
(0, _lodash.zip)(appliedChangesList, locusStateElementsForThisSet).forEach(function (_ref6) {
|
|
1226
|
+
var _ref7 = (0, _slicedToArray2.default)(_ref6, 2),
|
|
1227
|
+
changeApplied = _ref7[0],
|
|
1228
|
+
object = _ref7[1];
|
|
1229
|
+
if (changeApplied) {
|
|
1230
|
+
// add to updatedObjects so that our locus DTO will get updated with the new object
|
|
1231
|
+
updatedObjects.push(object);
|
|
1232
|
+
}
|
|
956
1233
|
});
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
1234
|
+
} else {
|
|
1235
|
+
_loggerProxy.default.logger.info("Locus-info:index#parseMessage --> ".concat(_this0.debugId, " unexpected (not visible) dataSet ").concat(dataSet.name, " received in hash tree message"));
|
|
1236
|
+
}
|
|
960
1237
|
}
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
function parseMessage(_x7, _x8) {
|
|
964
|
-
return _parseMessage.apply(this, arguments);
|
|
1238
|
+
_this0.runSyncAlgorithm(dataSet);
|
|
1239
|
+
});
|
|
965
1240
|
}
|
|
966
|
-
|
|
967
|
-
|
|
1241
|
+
if (dataSetsRequiringInitialization.length > 0) {
|
|
1242
|
+
// there are some data sets that we need to initialize asynchronously
|
|
1243
|
+
this.queueInitForNewVisibleDataSets(dataSetsRequiringInitialization);
|
|
1244
|
+
}
|
|
1245
|
+
if (updatedObjects.length === 0) {
|
|
1246
|
+
_loggerProxy.default.logger.info("HashTreeParser#parseMessage --> ".concat(this.debugId, " No objects updated as a result of received message"));
|
|
1247
|
+
}
|
|
1248
|
+
return updatedObjects;
|
|
1249
|
+
}
|
|
1250
|
+
|
|
968
1251
|
/**
|
|
969
1252
|
* Handles incoming hash tree messages, updates the hash trees and calls locusInfoUpdateCallback
|
|
970
1253
|
*
|
|
@@ -972,71 +1255,690 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
972
1255
|
* @param {string} [debugText] - Optional debug text to include in logs
|
|
973
1256
|
* @returns {void}
|
|
974
1257
|
*/
|
|
975
|
-
)
|
|
976
1258
|
}, {
|
|
977
1259
|
key: "handleMessage",
|
|
1260
|
+
value: function handleMessage(message, debugText) {
|
|
1261
|
+
if (this.state === 'stopped') {
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
if (message.heartbeatIntervalMs !== undefined) {
|
|
1265
|
+
this.topLevelHeartbeatIntervalMs = message.heartbeatIntervalMs;
|
|
1266
|
+
}
|
|
1267
|
+
if (this.isEndMessage(message)) {
|
|
1268
|
+
_loggerProxy.default.logger.info("HashTreeParser#handleMessage --> ".concat(this.debugId, " received sentinel END MEETING message"));
|
|
1269
|
+
this.stopAllTimers();
|
|
1270
|
+
this.callLocusInfoUpdateCallback({
|
|
1271
|
+
updateType: LocusInfoUpdateType.MEETING_ENDED
|
|
1272
|
+
});
|
|
1273
|
+
} else if (message.locusStateElements === undefined) {
|
|
1274
|
+
this.handleRootHashHeartBeatMessage(message);
|
|
1275
|
+
this.resetHeartbeatWatchdogs(message.dataSets);
|
|
1276
|
+
} else {
|
|
1277
|
+
// Completion of the sync latency metric (client.locus.sync.complete) is driven solely from
|
|
1278
|
+
// Meeting#processLocusLLMEvent once the matching LLM message arrives. body-mode syncs return
|
|
1279
|
+
// the locus state elements in the /sync HTTP response body, but per design the CA metric is
|
|
1280
|
+
// emitted only from the LLM message path, so no completion happens here.
|
|
1281
|
+
var updatedObjects = this.parseMessage(message, debugText);
|
|
1282
|
+
this.resetHeartbeatWatchdogs(message.dataSets);
|
|
1283
|
+
this.callLocusInfoUpdateCallback({
|
|
1284
|
+
updateType: LocusInfoUpdateType.OBJECTS_UPDATED,
|
|
1285
|
+
updatedObjects: updatedObjects
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
/**
|
|
1291
|
+
* Checks if Locus sync latency metrics should be collected for a dataset.
|
|
1292
|
+
*
|
|
1293
|
+
* @param {string} dataSetName dataset name
|
|
1294
|
+
* @param {boolean} [isInitialization=false] whether this is an initialization sync
|
|
1295
|
+
* @returns {boolean}
|
|
1296
|
+
*/
|
|
1297
|
+
}, {
|
|
1298
|
+
key: "shouldCollectSyncMetrics",
|
|
1299
|
+
value: function shouldCollectSyncMetrics(dataSetName) {
|
|
1300
|
+
var isInitialization = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1301
|
+
return Boolean(this.callbacks.syncLatencyTracker && !isInitialization && SYNC_METRICS_DATA_SETS.includes(dataSetName));
|
|
1302
|
+
}
|
|
1303
|
+
}, {
|
|
1304
|
+
key: "saveSyncBackoffLatency",
|
|
1305
|
+
value: function saveSyncBackoffLatency(dataSetName, randomBackoffTime) {
|
|
1306
|
+
var _this$callbacks$syncL;
|
|
1307
|
+
var isInitialization = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1308
|
+
if (!this.shouldCollectSyncMetrics(dataSetName, isInitialization)) {
|
|
1309
|
+
return;
|
|
1310
|
+
}
|
|
1311
|
+
(_this$callbacks$syncL = this.callbacks.syncLatencyTracker) === null || _this$callbacks$syncL === void 0 ? void 0 : _this$callbacks$syncL.saveLatency('internal.client.locus.sync.random.backoff', Math.round(randomBackoffTime), {
|
|
1312
|
+
meetingId: this.syncLatencyMeetingId,
|
|
1313
|
+
dataSetName: dataSetName
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1318
|
+
* Calls the updateInfo callback if there are any updates to report
|
|
1319
|
+
*
|
|
1320
|
+
* @param {Object} updates parsed from a Locus message
|
|
1321
|
+
* @returns {void}
|
|
1322
|
+
*/
|
|
1323
|
+
}, {
|
|
1324
|
+
key: "callLocusInfoUpdateCallback",
|
|
1325
|
+
value: function callLocusInfoUpdateCallback(updates) {
|
|
1326
|
+
var _updates$updatedObjec,
|
|
1327
|
+
_this1 = this;
|
|
1328
|
+
if (this.state === 'stopped') {
|
|
1329
|
+
return;
|
|
1330
|
+
}
|
|
1331
|
+
var updateType = updates.updateType;
|
|
1332
|
+
if (updateType === LocusInfoUpdateType.OBJECTS_UPDATED && ((_updates$updatedObjec = updates.updatedObjects) === null || _updates$updatedObjec === void 0 ? void 0 : _updates$updatedObjec.length) > 0) {
|
|
1333
|
+
// Filter out updates for objects that already have a higher version in their datasets,
|
|
1334
|
+
// or removals for objects that still exist in any of their datasets
|
|
1335
|
+
var filteredUpdates = updates.updatedObjects.filter(function (object) {
|
|
1336
|
+
var elementId = object.htMeta.elementId;
|
|
1337
|
+
var type = elementId.type,
|
|
1338
|
+
id = elementId.id,
|
|
1339
|
+
version = elementId.version;
|
|
1340
|
+
|
|
1341
|
+
// Check all datasets
|
|
1342
|
+
for (var _i2 = 0, _Object$keys3 = (0, _keys.default)(_this1.dataSets); _i2 < _Object$keys3.length; _i2++) {
|
|
1343
|
+
var dataSetName = _Object$keys3[_i2];
|
|
1344
|
+
var dataSet = _this1.dataSets[dataSetName];
|
|
1345
|
+
|
|
1346
|
+
// only visible datasets have hash trees set
|
|
1347
|
+
if (dataSet !== null && dataSet !== void 0 && dataSet.hashTree) {
|
|
1348
|
+
var existingVersion = dataSet.hashTree.getItemVersion(id, type);
|
|
1349
|
+
if (existingVersion !== undefined) {
|
|
1350
|
+
if (object.data) {
|
|
1351
|
+
// For updates: filter out if any dataset has a higher version
|
|
1352
|
+
if (existingVersion > version) {
|
|
1353
|
+
_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));
|
|
1354
|
+
return false;
|
|
1355
|
+
}
|
|
1356
|
+
} else if (existingVersion >= version) {
|
|
1357
|
+
// For removals: filter out if the object still exists in any dataset
|
|
1358
|
+
_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));
|
|
1359
|
+
return false;
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
return true;
|
|
1365
|
+
});
|
|
1366
|
+
if (filteredUpdates.length > 0) {
|
|
1367
|
+
this.callbacks.locusInfoUpdateCallback({
|
|
1368
|
+
updateType: updateType,
|
|
1369
|
+
updatedObjects: filteredUpdates
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
} else if (updateType !== LocusInfoUpdateType.OBJECTS_UPDATED) {
|
|
1373
|
+
this.callbacks.locusInfoUpdateCallback({
|
|
1374
|
+
updateType: updateType
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
/**
|
|
1380
|
+
* Calculates a weighted backoff time that should be used for syncs
|
|
1381
|
+
*
|
|
1382
|
+
* @param {Object} backoff - The backoff configuration containing maxMs and exponent
|
|
1383
|
+
* @returns {number} - A weighted backoff time based on the provided configuration, using algorithm supplied by Locus team
|
|
1384
|
+
*/
|
|
1385
|
+
}, {
|
|
1386
|
+
key: "getWeightedBackoffTime",
|
|
1387
|
+
value: function getWeightedBackoffTime(backoff) {
|
|
1388
|
+
var maxMs = backoff.maxMs,
|
|
1389
|
+
exponent = backoff.exponent;
|
|
1390
|
+
var randomValue = Math.random();
|
|
1391
|
+
return Math.round(Math.pow(randomValue, exponent) * maxMs);
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
/**
|
|
1395
|
+
* Returns a copy of a hash tree message restricted to a single dataset, keeping only the
|
|
1396
|
+
* requested dataset and the elements belonging to it. Used to strip out datasets that Locus
|
|
1397
|
+
* may include in a sync response but that we didn't request (e.g. "unjoined" sharing elements
|
|
1398
|
+
* with "main"), which would otherwise be applied once per dataset.
|
|
1399
|
+
*
|
|
1400
|
+
* @param {HashTreeMessage} message the sync response message
|
|
1401
|
+
* @param {string} dataSetName the dataset that was requested
|
|
1402
|
+
* @returns {HashTreeMessage} a new message containing only the requested dataset
|
|
1403
|
+
*/
|
|
1404
|
+
}, {
|
|
1405
|
+
key: "filterMessageToDataSet",
|
|
1406
|
+
value: function filterMessageToDataSet(message, dataSetName) {
|
|
1407
|
+
var _message$dataSets$fil, _message$dataSets2, _message$locusStateEl3, _message$locusStateEl4, _message$dataSets3, _message$locusStateEl5;
|
|
1408
|
+
var filteredOutDataSets = (_message$dataSets$fil = (_message$dataSets2 = message.dataSets) === null || _message$dataSets2 === void 0 ? void 0 : _message$dataSets2.filter(function (ds) {
|
|
1409
|
+
return ds.name !== dataSetName;
|
|
1410
|
+
})) !== null && _message$dataSets$fil !== void 0 ? _message$dataSets$fil : [];
|
|
1411
|
+
var filteredOutElements = (_message$locusStateEl3 = (_message$locusStateEl4 = message.locusStateElements) === null || _message$locusStateEl4 === void 0 ? void 0 : _message$locusStateEl4.filter(function (el) {
|
|
1412
|
+
var _el$htMeta$dataSetNam;
|
|
1413
|
+
return !((_el$htMeta$dataSetNam = el.htMeta.dataSetNames) !== null && _el$htMeta$dataSetNam !== void 0 && _el$htMeta$dataSetNam.includes(dataSetName));
|
|
1414
|
+
})) !== null && _message$locusStateEl3 !== void 0 ? _message$locusStateEl3 : [];
|
|
1415
|
+
if (filteredOutDataSets.length > 0 || filteredOutElements.length > 0) {
|
|
1416
|
+
_loggerProxy.default.logger.info("HashTreeParser#filterMessageToDataSet --> ".concat(this.debugId, " keeping only dataset \"").concat(dataSetName, "\", filtering out datasets: [").concat(filteredOutDataSets.map(function (ds) {
|
|
1417
|
+
return "".concat(ds.name, ":").concat(ds.version);
|
|
1418
|
+
}).join(','), "], elements: [").concat(filteredOutElements.map(function (el) {
|
|
1419
|
+
var _el$htMeta, _el$htMeta$elementId, _el$htMeta2, _el$htMeta2$elementId, _el$htMeta3, _el$htMeta3$elementId;
|
|
1420
|
+
return "".concat((_el$htMeta = el.htMeta) === null || _el$htMeta === void 0 ? void 0 : (_el$htMeta$elementId = _el$htMeta.elementId) === null || _el$htMeta$elementId === void 0 ? void 0 : _el$htMeta$elementId.type, ":").concat((_el$htMeta2 = el.htMeta) === null || _el$htMeta2 === void 0 ? void 0 : (_el$htMeta2$elementId = _el$htMeta2.elementId) === null || _el$htMeta2$elementId === void 0 ? void 0 : _el$htMeta2$elementId.id, ":").concat((_el$htMeta3 = el.htMeta) === null || _el$htMeta3 === void 0 ? void 0 : (_el$htMeta3$elementId = _el$htMeta3.elementId) === null || _el$htMeta3$elementId === void 0 ? void 0 : _el$htMeta3$elementId.version);
|
|
1421
|
+
}).join(','), "]"));
|
|
1422
|
+
}
|
|
1423
|
+
return _objectSpread(_objectSpread({}, message), {}, {
|
|
1424
|
+
dataSets: (_message$dataSets3 = message.dataSets) === null || _message$dataSets3 === void 0 ? void 0 : _message$dataSets3.filter(function (ds) {
|
|
1425
|
+
return ds.name === dataSetName;
|
|
1426
|
+
}),
|
|
1427
|
+
locusStateElements: (_message$locusStateEl5 = message.locusStateElements) === null || _message$locusStateEl5 === void 0 ? void 0 : _message$locusStateEl5.filter(function (el) {
|
|
1428
|
+
var _el$htMeta$dataSetNam2;
|
|
1429
|
+
return (_el$htMeta$dataSetNam2 = el.htMeta.dataSetNames) === null || _el$htMeta$dataSetNam2 === void 0 ? void 0 : _el$htMeta$dataSetNam2.includes(dataSetName);
|
|
1430
|
+
})
|
|
1431
|
+
});
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
/**
|
|
1435
|
+
* Performs a sync for the given data set.
|
|
1436
|
+
*
|
|
1437
|
+
* @param {InternalDataSet} dataSet - The data set to sync
|
|
1438
|
+
* @param {string} reason - The reason for the sync (used for logging)
|
|
1439
|
+
* @param {boolean} [isInitialization] - Whether this is an initialization sync (sends empty leaves data instead of comparing hashes)
|
|
1440
|
+
* @returns {Promise<void>}
|
|
1441
|
+
*/
|
|
1442
|
+
}, {
|
|
1443
|
+
key: "performSync",
|
|
978
1444
|
value: (function () {
|
|
979
|
-
var
|
|
980
|
-
var
|
|
1445
|
+
var _performSync = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6(dataSet, reason, isInitialization) {
|
|
1446
|
+
var _dataSet$syncAbortCon, _this$callbacks$gener, _this$callbacks, _this$callbacks$gener2, _this$callbacks2;
|
|
1447
|
+
var abortController, hashTree, rootHash, shouldCollectMetrics, hashtreeTrackingId, syncTrackingId, syncRequestSent, _this$callbacks$syncL2, leavesData, receivedHashes, hashesResult, mismatchedLeaveIndexes, syncResponse, filteredResponse, _this$callbacks$syncL3, _t3, _t4;
|
|
981
1448
|
return _regenerator.default.wrap(function (_context7) {
|
|
982
1449
|
while (1) switch (_context7.prev = _context7.next) {
|
|
983
1450
|
case 0:
|
|
984
|
-
if (
|
|
1451
|
+
if (dataSet.hashTree) {
|
|
985
1452
|
_context7.next = 1;
|
|
986
1453
|
break;
|
|
987
1454
|
}
|
|
988
|
-
|
|
989
|
-
|
|
1455
|
+
return _context7.abrupt("return");
|
|
1456
|
+
case 1:
|
|
1457
|
+
abortController = (_dataSet$syncAbortCon = dataSet.syncAbortController) !== null && _dataSet$syncAbortCon !== void 0 ? _dataSet$syncAbortCon : new AbortController();
|
|
1458
|
+
dataSet.syncAbortController = abortController;
|
|
1459
|
+
hashTree = dataSet.hashTree;
|
|
1460
|
+
rootHash = hashTree.getRootHash();
|
|
1461
|
+
shouldCollectMetrics = this.shouldCollectSyncMetrics(dataSet.name, isInitialization); // Generate two distinct tracking ids up-front. Each Locus request must carry its own unique
|
|
1462
|
+
// tracking id, so the /hashtree and /sync requests must not share one. hashtreeTrackingId is
|
|
1463
|
+
// generated first so that syncTrackingId (forced onto the /sync request, stored in metrics, and
|
|
1464
|
+
// used to match the LLM broadcast message) ends up with the later/higher sequence number,
|
|
1465
|
+
// matching the order in which Locus sees the requests. If we never call /hashtree (single-leaf
|
|
1466
|
+
// or initialization syncs), hashtreeTrackingId is simply unused.
|
|
1467
|
+
hashtreeTrackingId = shouldCollectMetrics ? (_this$callbacks$gener = (_this$callbacks = this.callbacks).generateTrackingId) === null || _this$callbacks$gener === void 0 ? void 0 : _this$callbacks$gener.call(_this$callbacks) : undefined;
|
|
1468
|
+
syncTrackingId = shouldCollectMetrics ? (_this$callbacks$gener2 = (_this$callbacks2 = this.callbacks).generateTrackingId) === null || _this$callbacks$gener2 === void 0 ? void 0 : _this$callbacks$gener2.call(_this$callbacks2) : undefined;
|
|
1469
|
+
syncRequestSent = false;
|
|
1470
|
+
if (shouldCollectMetrics) {
|
|
1471
|
+
(_this$callbacks$syncL2 = this.callbacks.syncLatencyTracker) === null || _this$callbacks$syncL2 === void 0 ? void 0 : _this$callbacks$syncL2.saveTimestamp({
|
|
1472
|
+
key: 'internal.client.locus.sync.start',
|
|
1473
|
+
options: {
|
|
1474
|
+
meetingId: this.syncLatencyMeetingId,
|
|
1475
|
+
dataSetName: dataSet.name,
|
|
1476
|
+
trackingId: syncTrackingId
|
|
1477
|
+
}
|
|
1478
|
+
});
|
|
1479
|
+
}
|
|
1480
|
+
_context7.prev = 2;
|
|
1481
|
+
_loggerProxy.default.logger.info("HashTreeParser#performSync --> ".concat(this.debugId, " ").concat(reason, ", syncing data set \"").concat(dataSet.name, "\""));
|
|
1482
|
+
leavesData = {};
|
|
1483
|
+
if (isInitialization) {
|
|
1484
|
+
_context7.next = 10;
|
|
1485
|
+
break;
|
|
1486
|
+
}
|
|
1487
|
+
if (!(dataSet.leafCount !== 1)) {
|
|
1488
|
+
_context7.next = 9;
|
|
1489
|
+
break;
|
|
1490
|
+
}
|
|
1491
|
+
_context7.prev = 3;
|
|
1492
|
+
_context7.next = 4;
|
|
1493
|
+
return this.getHashesFromLocus(dataSet.name, rootHash, {
|
|
1494
|
+
requestTrackingId: hashtreeTrackingId,
|
|
1495
|
+
metricTrackingId: syncTrackingId
|
|
1496
|
+
});
|
|
1497
|
+
case 4:
|
|
1498
|
+
hashesResult = _context7.sent;
|
|
1499
|
+
if (hashesResult) {
|
|
1500
|
+
_context7.next = 5;
|
|
1501
|
+
break;
|
|
1502
|
+
}
|
|
1503
|
+
return _context7.abrupt("return");
|
|
1504
|
+
case 5:
|
|
1505
|
+
receivedHashes = hashesResult.hashes;
|
|
1506
|
+
this.updateDataSetLeafCount(dataSet, hashesResult.dataSet.leafCount);
|
|
1507
|
+
_context7.next = 8;
|
|
1508
|
+
break;
|
|
1509
|
+
case 6:
|
|
1510
|
+
_context7.prev = 6;
|
|
1511
|
+
_t3 = _context7["catch"](3);
|
|
1512
|
+
if (!((_t3 === null || _t3 === void 0 ? void 0 : _t3.statusCode) === 409)) {
|
|
1513
|
+
_context7.next = 7;
|
|
1514
|
+
break;
|
|
1515
|
+
}
|
|
1516
|
+
// this is a leaf count mismatch, we should do nothing, just wait for another heartbeat message from Locus
|
|
1517
|
+
_loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(this.debugId, " Got 409 when fetching hashes for data set \"").concat(dataSet.name, "\": ").concat(_t3.message));
|
|
1518
|
+
return _context7.abrupt("return");
|
|
1519
|
+
case 7:
|
|
1520
|
+
throw _t3;
|
|
1521
|
+
case 8:
|
|
1522
|
+
// identify mismatched leaves
|
|
1523
|
+
mismatchedLeaveIndexes = hashTree.diffHashes(receivedHashes);
|
|
1524
|
+
mismatchedLeaveIndexes.forEach(function (index) {
|
|
1525
|
+
leavesData[index] = hashTree.getLeafData(index);
|
|
1526
|
+
});
|
|
1527
|
+
_context7.next = 10;
|
|
1528
|
+
break;
|
|
1529
|
+
case 9:
|
|
1530
|
+
leavesData = {
|
|
1531
|
+
0: hashTree.getLeafData(0)
|
|
1532
|
+
};
|
|
1533
|
+
case 10:
|
|
1534
|
+
if (!abortController.signal.aborted) {
|
|
1535
|
+
_context7.next = 11;
|
|
1536
|
+
break;
|
|
1537
|
+
}
|
|
1538
|
+
_loggerProxy.default.logger.info("HashTreeParser#performSync --> ".concat(this.debugId, " abandoning sync for \"").concat(dataSet.name, "\" before /sync - message received during sync"));
|
|
1539
|
+
return _context7.abrupt("return");
|
|
1540
|
+
case 11:
|
|
1541
|
+
// request sync for mismatched leaves
|
|
1542
|
+
syncResponse = null;
|
|
1543
|
+
if (!isInitialization) {
|
|
1544
|
+
_context7.next = 13;
|
|
1545
|
+
break;
|
|
1546
|
+
}
|
|
1547
|
+
_context7.next = 12;
|
|
1548
|
+
return this.sendSyncRequestToLocus(dataSet, {
|
|
1549
|
+
isInitialization: true
|
|
1550
|
+
}, syncTrackingId);
|
|
1551
|
+
case 12:
|
|
1552
|
+
syncResponse = _context7.sent;
|
|
1553
|
+
syncRequestSent = true;
|
|
1554
|
+
_context7.next = 15;
|
|
1555
|
+
break;
|
|
1556
|
+
case 13:
|
|
1557
|
+
if (!((0, _keys.default)(leavesData).length > 0)) {
|
|
1558
|
+
_context7.next = 15;
|
|
1559
|
+
break;
|
|
1560
|
+
}
|
|
1561
|
+
_context7.next = 14;
|
|
1562
|
+
return this.sendSyncRequestToLocus(dataSet, {
|
|
1563
|
+
mismatchedLeavesData: leavesData
|
|
1564
|
+
}, syncTrackingId);
|
|
1565
|
+
case 14:
|
|
1566
|
+
syncResponse = _context7.sent;
|
|
1567
|
+
syncRequestSent = true;
|
|
1568
|
+
case 15:
|
|
1569
|
+
// sync API may return nothing (in that case data will arrive via messages)
|
|
1570
|
+
// or it may return a response in the same format as messages
|
|
1571
|
+
// We still need to restart the sync timer as a safety net in case the messages don't arrive.
|
|
1572
|
+
this.runSyncAlgorithm(dataSet);
|
|
1573
|
+
if (syncResponse) {
|
|
1574
|
+
// clear the abort controller before processing the response so that
|
|
1575
|
+
// parseMessage() -> cancelPendingSyncsForDataSets() doesn't log a
|
|
1576
|
+
// misleading "aborting sync" message for this already-completed sync
|
|
1577
|
+
dataSet.syncAbortController = undefined;
|
|
1578
|
+
|
|
1579
|
+
// we only requested this dataset, so restrict the response to it before processing
|
|
1580
|
+
// (Locus may include shared datasets like "unjoined" alongside "main")
|
|
1581
|
+
filteredResponse = this.filterMessageToDataSet(syncResponse, dataSet.name); // the format of sync response is the same as messages, so we can reuse the same handler
|
|
1582
|
+
this.handleMessage(filteredResponse, "via sync API (".concat(isInitialization ? 'init' : "".concat((0, _keys.default)(leavesData).length, " mismatched leaves"), ")"));
|
|
1583
|
+
}
|
|
1584
|
+
_context7.next = 17;
|
|
990
1585
|
break;
|
|
1586
|
+
case 16:
|
|
1587
|
+
_context7.prev = 16;
|
|
1588
|
+
_t4 = _context7["catch"](2);
|
|
1589
|
+
if (!this.handleSyncErrors(_t4)) {
|
|
1590
|
+
_loggerProxy.default.logger.warn("HashTreeParser#performSync --> ".concat(this.debugId, " error during sync for data set \"").concat(dataSet.name, "\":"), _t4);
|
|
1591
|
+
}
|
|
1592
|
+
case 17:
|
|
1593
|
+
_context7.prev = 17;
|
|
1594
|
+
if (shouldCollectMetrics && !syncRequestSent) {
|
|
1595
|
+
// Drop only this sync's in-progress record (matched by its tracking id) rather than the
|
|
1596
|
+
// whole dataset, so a still-pending record from an earlier successful sync isn't wiped.
|
|
1597
|
+
// This mirrors the native client's onSyncError(syncId) which discards a single record.
|
|
1598
|
+
(_this$callbacks$syncL3 = this.callbacks.syncLatencyTracker) === null || _this$callbacks$syncL3 === void 0 ? void 0 : _this$callbacks$syncL3.clearLocusSyncLatency(dataSet.name, this.syncLatencyMeetingId, syncTrackingId);
|
|
1599
|
+
}
|
|
1600
|
+
dataSet.syncAbortController = undefined;
|
|
1601
|
+
return _context7.finish(17);
|
|
1602
|
+
case 18:
|
|
1603
|
+
case "end":
|
|
1604
|
+
return _context7.stop();
|
|
1605
|
+
}
|
|
1606
|
+
}, _callee6, this, [[2, 16, 17, 18], [3, 6]]);
|
|
1607
|
+
}));
|
|
1608
|
+
function performSync(_x8, _x9, _x0) {
|
|
1609
|
+
return _performSync.apply(this, arguments);
|
|
1610
|
+
}
|
|
1611
|
+
return performSync;
|
|
1612
|
+
}()
|
|
1613
|
+
/**
|
|
1614
|
+
* Cancels any pending or in-flight syncs for the specified data sets.
|
|
1615
|
+
* This removes matching entries from the sync queue and aborts any in-flight sync HTTP requests.
|
|
1616
|
+
*
|
|
1617
|
+
* @param {string[]} dataSetNames - The names of the data sets to cancel syncs for
|
|
1618
|
+
* @returns {void}
|
|
1619
|
+
*/
|
|
1620
|
+
)
|
|
1621
|
+
}, {
|
|
1622
|
+
key: "cancelPendingSyncsForDataSets",
|
|
1623
|
+
value: function cancelPendingSyncsForDataSets(dataSetNames) {
|
|
1624
|
+
var previousLength = this.syncQueue.length;
|
|
1625
|
+
this.syncQueue = this.syncQueue.filter(function (entry) {
|
|
1626
|
+
return !dataSetNames.includes(entry.dataSetName);
|
|
1627
|
+
});
|
|
1628
|
+
if (previousLength !== this.syncQueue.length) {
|
|
1629
|
+
_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(', ')));
|
|
1630
|
+
}
|
|
1631
|
+
this.markDataSetsForSyncAllBackoffSkip(dataSetNames);
|
|
1632
|
+
this.abortInFlightSyncs(dataSetNames);
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
/**
|
|
1636
|
+
* If a syncAllDatasets backoff sleep is in progress, marks the given data sets to be skipped
|
|
1637
|
+
* after the sleep completes.
|
|
1638
|
+
*
|
|
1639
|
+
* @param {string[]} dataSetNames - The names of the data sets to mark
|
|
1640
|
+
* @returns {void}
|
|
1641
|
+
*/
|
|
1642
|
+
}, {
|
|
1643
|
+
key: "markDataSetsForSyncAllBackoffSkip",
|
|
1644
|
+
value: function markDataSetsForSyncAllBackoffSkip(dataSetNames) {
|
|
1645
|
+
if (this.syncAllBackoffType !== SyncAllBackoffType.NONE) {
|
|
1646
|
+
var _iterator9 = _createForOfIteratorHelper(dataSetNames),
|
|
1647
|
+
_step9;
|
|
1648
|
+
try {
|
|
1649
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
1650
|
+
var name = _step9.value;
|
|
1651
|
+
this.dataSetsSyncedDuringBackoff.add(name);
|
|
1652
|
+
}
|
|
1653
|
+
} catch (err) {
|
|
1654
|
+
_iterator9.e(err);
|
|
1655
|
+
} finally {
|
|
1656
|
+
_iterator9.f();
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
/**
|
|
1662
|
+
* Aborts any in-flight sync HTTP requests for the specified data sets.
|
|
1663
|
+
*
|
|
1664
|
+
* @param {string[]} dataSetNames - The names of the data sets whose syncs should be aborted
|
|
1665
|
+
* @returns {void}
|
|
1666
|
+
*/
|
|
1667
|
+
}, {
|
|
1668
|
+
key: "abortInFlightSyncs",
|
|
1669
|
+
value: function abortInFlightSyncs(dataSetNames) {
|
|
1670
|
+
var _iterator0 = _createForOfIteratorHelper(dataSetNames),
|
|
1671
|
+
_step0;
|
|
1672
|
+
try {
|
|
1673
|
+
for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
|
|
1674
|
+
var _this$dataSets$name;
|
|
1675
|
+
var name = _step0.value;
|
|
1676
|
+
if ((_this$dataSets$name = this.dataSets[name]) !== null && _this$dataSets$name !== void 0 && _this$dataSets$name.syncAbortController) {
|
|
1677
|
+
_loggerProxy.default.logger.info("HashTreeParser#cancelPendingSyncsForDataSets --> ".concat(this.debugId, " aborting in-flight sync for data set \"").concat(name, "\""));
|
|
1678
|
+
this.dataSets[name].syncAbortController.abort();
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
} catch (err) {
|
|
1682
|
+
_iterator0.e(err);
|
|
1683
|
+
} finally {
|
|
1684
|
+
_iterator0.f();
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
/**
|
|
1689
|
+
* Enqueues a sync for the given data set. If the data set is already in the queue, the request is ignored.
|
|
1690
|
+
* This ensures that all syncs are executed sequentially and no more than 1 sync runs at a time.
|
|
1691
|
+
*
|
|
1692
|
+
* @param {string} dataSetName - The name of the data set to sync
|
|
1693
|
+
* @param {string} reason - The reason for the sync (used for logging)
|
|
1694
|
+
* @param {boolean} [isInitialization=false] - Whether this is an initialization sync (uses empty leaves data instead of hash comparison)
|
|
1695
|
+
* @returns {void}
|
|
1696
|
+
*/
|
|
1697
|
+
}, {
|
|
1698
|
+
key: "enqueueSyncForDataset",
|
|
1699
|
+
value: function enqueueSyncForDataset(dataSetName, reason) {
|
|
1700
|
+
var isInitialization = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1701
|
+
if (this.state === 'stopped') return;
|
|
1702
|
+
var existingEntry = this.syncQueue.find(function (entry) {
|
|
1703
|
+
return entry.dataSetName === dataSetName;
|
|
1704
|
+
});
|
|
1705
|
+
if (existingEntry) {
|
|
1706
|
+
if (isInitialization) {
|
|
1707
|
+
existingEntry.isInitialization = true;
|
|
1708
|
+
}
|
|
1709
|
+
_loggerProxy.default.logger.info("HashTreeParser#enqueueSyncForDataset --> ".concat(this.debugId, " data set \"").concat(dataSetName, "\" already in sync queue, skipping"));
|
|
1710
|
+
return;
|
|
1711
|
+
}
|
|
1712
|
+
this.syncQueue.push({
|
|
1713
|
+
dataSetName: dataSetName,
|
|
1714
|
+
reason: reason,
|
|
1715
|
+
isInitialization: isInitialization
|
|
1716
|
+
});
|
|
1717
|
+
if (!this.isSyncInProgress) {
|
|
1718
|
+
this.syncQueueProcessingPromise = this.processSyncQueue();
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
/**
|
|
1723
|
+
* Processes the sync queue sequentially. Only one instance of this method runs at a time.
|
|
1724
|
+
*
|
|
1725
|
+
* @returns {Promise<void>}
|
|
1726
|
+
*/
|
|
1727
|
+
}, {
|
|
1728
|
+
key: "processSyncQueue",
|
|
1729
|
+
value: (function () {
|
|
1730
|
+
var _processSyncQueue = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7() {
|
|
1731
|
+
var _ref8, dataSetName, reason, isInitialization, dataSet;
|
|
1732
|
+
return _regenerator.default.wrap(function (_context8) {
|
|
1733
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
1734
|
+
case 0:
|
|
1735
|
+
if (!this.isSyncInProgress) {
|
|
1736
|
+
_context8.next = 1;
|
|
1737
|
+
break;
|
|
1738
|
+
}
|
|
1739
|
+
return _context8.abrupt("return");
|
|
991
1740
|
case 1:
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
case 2:
|
|
995
|
-
updates = _context7.sent;
|
|
996
|
-
this.callLocusInfoUpdateCallback(updates);
|
|
1741
|
+
this.isSyncInProgress = true;
|
|
1742
|
+
_context8.prev = 2;
|
|
997
1743
|
case 3:
|
|
1744
|
+
if (!(this.syncQueue.length > 0 && this.state !== 'stopped')) {
|
|
1745
|
+
_context8.next = 6;
|
|
1746
|
+
break;
|
|
1747
|
+
}
|
|
1748
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1749
|
+
_ref8 = this.syncQueue.shift(), dataSetName = _ref8.dataSetName, reason = _ref8.reason, isInitialization = _ref8.isInitialization;
|
|
1750
|
+
dataSet = this.dataSets[dataSetName];
|
|
1751
|
+
if (dataSet !== null && dataSet !== void 0 && dataSet.hashTree) {
|
|
1752
|
+
_context8.next = 4;
|
|
1753
|
+
break;
|
|
1754
|
+
}
|
|
1755
|
+
return _context8.abrupt("continue", 3);
|
|
1756
|
+
case 4:
|
|
1757
|
+
_context8.next = 5;
|
|
1758
|
+
return this.performSync(dataSet, reason, isInitialization);
|
|
1759
|
+
case 5:
|
|
1760
|
+
_context8.next = 3;
|
|
1761
|
+
break;
|
|
1762
|
+
case 6:
|
|
1763
|
+
_context8.prev = 6;
|
|
1764
|
+
this.isSyncInProgress = false;
|
|
1765
|
+
return _context8.finish(6);
|
|
1766
|
+
case 7:
|
|
998
1767
|
case "end":
|
|
999
|
-
return
|
|
1768
|
+
return _context8.stop();
|
|
1000
1769
|
}
|
|
1001
|
-
},
|
|
1770
|
+
}, _callee7, this, [[2,, 6, 7]]);
|
|
1002
1771
|
}));
|
|
1003
|
-
function
|
|
1004
|
-
return
|
|
1772
|
+
function processSyncQueue() {
|
|
1773
|
+
return _processSyncQueue.apply(this, arguments);
|
|
1005
1774
|
}
|
|
1006
|
-
return
|
|
1775
|
+
return processSyncQueue;
|
|
1007
1776
|
}()
|
|
1008
1777
|
/**
|
|
1009
|
-
*
|
|
1778
|
+
* sets the backoff type for syncAllDatasets calls, which determines the scope of datasets that will be synced after the backoff delay.
|
|
1010
1779
|
*
|
|
1011
|
-
* @param {
|
|
1780
|
+
* @param {boolean} onlyLLM - Whether the backoff is for a syncAllDatasets call that is syncing only LLM datasets
|
|
1012
1781
|
* @returns {void}
|
|
1013
1782
|
*/
|
|
1014
1783
|
)
|
|
1015
1784
|
}, {
|
|
1016
|
-
key: "
|
|
1017
|
-
value: function
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1785
|
+
key: "setSyncAllBackoffType",
|
|
1786
|
+
value: function setSyncAllBackoffType(onlyLLM) {
|
|
1787
|
+
this.syncAllBackoffType = onlyLLM ? SyncAllBackoffType.ONLY_LLM : SyncAllBackoffType.ALL;
|
|
1788
|
+
}
|
|
1789
|
+
|
|
1790
|
+
/**
|
|
1791
|
+
* Checks if a syncAll backoff is already in progress. If so, upgrades the scope from
|
|
1792
|
+
* onlyLLM to all datasets when the new call has a broader scope.
|
|
1793
|
+
*
|
|
1794
|
+
* @param {boolean} onlyLLM - Whether the current call is for LLM datasets only
|
|
1795
|
+
* @returns {boolean} true if a backoff is already pending (caller should return early)
|
|
1796
|
+
*/
|
|
1797
|
+
}, {
|
|
1798
|
+
key: "tryUpgradePendingBackoff",
|
|
1799
|
+
value: function tryUpgradePendingBackoff(onlyLLM) {
|
|
1800
|
+
if (this.syncAllBackoffType !== SyncAllBackoffType.NONE) {
|
|
1801
|
+
if (!onlyLLM && this.syncAllBackoffType === SyncAllBackoffType.ONLY_LLM) {
|
|
1802
|
+
this.setSyncAllBackoffType(false);
|
|
1803
|
+
_loggerProxy.default.logger.info("HashTreeParser#syncAllDatasets --> ".concat(this.debugId, " upgraded pending syncAll from onlyLLM to all datasets"));
|
|
1804
|
+
}
|
|
1805
|
+
return true;
|
|
1024
1806
|
}
|
|
1807
|
+
return false;
|
|
1025
1808
|
}
|
|
1026
1809
|
|
|
1027
1810
|
/**
|
|
1028
|
-
*
|
|
1811
|
+
* Syncs all data sets that have hash trees, one by one in sequence, using the priority order
|
|
1812
|
+
* provided by sortByInitPriority().
|
|
1029
1813
|
*
|
|
1030
|
-
*
|
|
1031
|
-
*
|
|
1814
|
+
* If a call is already waiting in the backoff delay phase, a new call with a broader scope
|
|
1815
|
+
* (onlyLLM=false) will upgrade the pending scope, and the dataset list will be computed after
|
|
1816
|
+
* the backoff using the upgraded scope. After the backoff, the sync queue handles deduplication
|
|
1817
|
+
* so no guard is needed.
|
|
1818
|
+
*
|
|
1819
|
+
* @param {Object} [options={}] - Options for syncing
|
|
1820
|
+
* @param {boolean} [options.onlyLLM=false] - Whether to sync only LLM based data sets
|
|
1821
|
+
* @returns {Promise<void>}
|
|
1032
1822
|
*/
|
|
1033
1823
|
}, {
|
|
1034
|
-
key: "
|
|
1035
|
-
value: function
|
|
1036
|
-
var
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1824
|
+
key: "syncAllDatasets",
|
|
1825
|
+
value: (function () {
|
|
1826
|
+
var _syncAllDatasets = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8() {
|
|
1827
|
+
var options,
|
|
1828
|
+
_options$onlyLLM,
|
|
1829
|
+
onlyLLM,
|
|
1830
|
+
dataSetsToSync,
|
|
1831
|
+
delay,
|
|
1832
|
+
effectiveBackoffType,
|
|
1833
|
+
skippedDataSets,
|
|
1834
|
+
effectiveDataSetsToSync,
|
|
1835
|
+
_iterator1,
|
|
1836
|
+
_step1,
|
|
1837
|
+
ds,
|
|
1838
|
+
_args9 = arguments;
|
|
1839
|
+
return _regenerator.default.wrap(function (_context9) {
|
|
1840
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
1841
|
+
case 0:
|
|
1842
|
+
options = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
|
|
1843
|
+
_options$onlyLLM = options.onlyLLM, onlyLLM = _options$onlyLLM === void 0 ? false : _options$onlyLLM;
|
|
1844
|
+
if (!(this.state === 'stopped')) {
|
|
1845
|
+
_context9.next = 1;
|
|
1846
|
+
break;
|
|
1847
|
+
}
|
|
1848
|
+
return _context9.abrupt("return");
|
|
1849
|
+
case 1:
|
|
1850
|
+
if (!this.tryUpgradePendingBackoff(onlyLLM)) {
|
|
1851
|
+
_context9.next = 2;
|
|
1852
|
+
break;
|
|
1853
|
+
}
|
|
1854
|
+
return _context9.abrupt("return");
|
|
1855
|
+
case 2:
|
|
1856
|
+
dataSetsToSync = this.getSortedDataSetsWithHashTrees(onlyLLM);
|
|
1857
|
+
if (!(dataSetsToSync.length === 0)) {
|
|
1858
|
+
_context9.next = 3;
|
|
1859
|
+
break;
|
|
1860
|
+
}
|
|
1861
|
+
return _context9.abrupt("return");
|
|
1862
|
+
case 3:
|
|
1863
|
+
this.setSyncAllBackoffType(onlyLLM);
|
|
1864
|
+
delay = this.getWeightedBackoffTime(dataSetsToSync[0].backoff);
|
|
1865
|
+
_loggerProxy.default.logger.info("HashTreeParser#syncAllDatasets --> ".concat(this.debugId, " starting backoff delay of ").concat(delay, "ms (onlyLLM=").concat(onlyLLM, ")"));
|
|
1866
|
+
|
|
1867
|
+
// delay the start of the syncs - this is a Locus requirement to avoid thundering herd issues
|
|
1868
|
+
_context9.next = 4;
|
|
1869
|
+
return (0, _utils.sleep)(delay);
|
|
1870
|
+
case 4:
|
|
1871
|
+
// read the (possibly upgraded) scope and clear the backoff flag
|
|
1872
|
+
effectiveBackoffType = this.syncAllBackoffType;
|
|
1873
|
+
skippedDataSets = this.dataSetsSyncedDuringBackoff;
|
|
1874
|
+
this.syncAllBackoffType = SyncAllBackoffType.NONE;
|
|
1875
|
+
this.dataSetsSyncedDuringBackoff = new _set.default();
|
|
1876
|
+
if (!(this.state === 'stopped')) {
|
|
1877
|
+
_context9.next = 5;
|
|
1878
|
+
break;
|
|
1879
|
+
}
|
|
1880
|
+
return _context9.abrupt("return");
|
|
1881
|
+
case 5:
|
|
1882
|
+
// re-evaluate the dataset list after the sleep, since the scope may have been upgraded
|
|
1883
|
+
// and exclude datasets that received messages during the backoff sleep
|
|
1884
|
+
effectiveDataSetsToSync = this.getSortedDataSetsWithHashTrees(effectiveBackoffType === SyncAllBackoffType.ONLY_LLM).filter(function (ds) {
|
|
1885
|
+
return !skippedDataSets.has(ds.name);
|
|
1886
|
+
});
|
|
1887
|
+
if (skippedDataSets.size > 0) {
|
|
1888
|
+
_loggerProxy.default.logger.info("HashTreeParser#syncAllDatasets --> ".concat(this.debugId, " skipping datasets that received messages during backoff: ").concat((0, _toConsumableArray2.default)(skippedDataSets).join(', ')));
|
|
1889
|
+
}
|
|
1890
|
+
_loggerProxy.default.logger.info("HashTreeParser#syncAllDatasets --> ".concat(this.debugId, " syncing ").concat(effectiveBackoffType === SyncAllBackoffType.ONLY_LLM ? 'only LLM' : 'all', " datasets: ").concat(effectiveDataSetsToSync.map(function (ds) {
|
|
1891
|
+
return ds.name;
|
|
1892
|
+
}).join(', ')));
|
|
1893
|
+
_iterator1 = _createForOfIteratorHelper(effectiveDataSetsToSync);
|
|
1894
|
+
try {
|
|
1895
|
+
for (_iterator1.s(); !(_step1 = _iterator1.n()).done;) {
|
|
1896
|
+
ds = _step1.value;
|
|
1897
|
+
this.saveSyncBackoffLatency(ds.name, delay);
|
|
1898
|
+
this.enqueueSyncForDataset(ds.name, 'syncAllDatasets');
|
|
1899
|
+
}
|
|
1900
|
+
} catch (err) {
|
|
1901
|
+
_iterator1.e(err);
|
|
1902
|
+
} finally {
|
|
1903
|
+
_iterator1.f();
|
|
1904
|
+
}
|
|
1905
|
+
_context9.next = 6;
|
|
1906
|
+
return this.syncQueueProcessingPromise;
|
|
1907
|
+
case 6:
|
|
1908
|
+
case "end":
|
|
1909
|
+
return _context9.stop();
|
|
1910
|
+
}
|
|
1911
|
+
}, _callee8, this);
|
|
1912
|
+
}));
|
|
1913
|
+
function syncAllDatasets() {
|
|
1914
|
+
return _syncAllDatasets.apply(this, arguments);
|
|
1915
|
+
}
|
|
1916
|
+
return syncAllDatasets;
|
|
1917
|
+
}()
|
|
1918
|
+
/**
|
|
1919
|
+
* Returns the list of data sets that have hash trees, sorted by the priority order provided by sortByInitPriority().
|
|
1920
|
+
*
|
|
1921
|
+
* @param {boolean} onlyLLM - Whether to include only LLM based data sets
|
|
1922
|
+
* @returns {Array<{name: string, backoff: {maxMs: number, exponent: number}}>} The sorted list of data sets with their backoff configurations
|
|
1923
|
+
*/
|
|
1924
|
+
)
|
|
1925
|
+
}, {
|
|
1926
|
+
key: "getSortedDataSetsWithHashTrees",
|
|
1927
|
+
value: function getSortedDataSetsWithHashTrees(onlyLLM) {
|
|
1928
|
+
var dataSets = (0, _values.default)(this.dataSets).filter(function (dataSet) {
|
|
1929
|
+
return dataSet === null || dataSet === void 0 ? void 0 : dataSet.hashTree;
|
|
1930
|
+
}).map(function (dataSet) {
|
|
1931
|
+
return {
|
|
1932
|
+
name: dataSet.name,
|
|
1933
|
+
backoff: dataSet.backoff
|
|
1934
|
+
};
|
|
1935
|
+
});
|
|
1936
|
+
if (onlyLLM) {
|
|
1937
|
+
dataSets = dataSets.filter(function (ds) {
|
|
1938
|
+
return _constants3.LLM_DATASET_NAMES.includes(ds.name);
|
|
1939
|
+
});
|
|
1940
|
+
}
|
|
1941
|
+
return (0, _utils.sortByInitPriority)(dataSets, _constants3.DATA_SET_INIT_PRIORITY);
|
|
1040
1942
|
}
|
|
1041
1943
|
|
|
1042
1944
|
/**
|
|
@@ -1048,114 +1950,97 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1048
1950
|
}, {
|
|
1049
1951
|
key: "runSyncAlgorithm",
|
|
1050
1952
|
value: function runSyncAlgorithm(receivedDataSet) {
|
|
1051
|
-
var
|
|
1953
|
+
var _this10 = this;
|
|
1052
1954
|
var dataSet = this.dataSets[receivedDataSet.name];
|
|
1053
1955
|
if (!dataSet) {
|
|
1054
1956
|
_loggerProxy.default.logger.warn("HashTreeParser#runSyncAlgorithm --> ".concat(this.debugId, " No data set found for ").concat(receivedDataSet.name, ", skipping sync algorithm"));
|
|
1055
1957
|
return;
|
|
1056
1958
|
}
|
|
1057
1959
|
if (!dataSet.hashTree) {
|
|
1058
|
-
|
|
1960
|
+
// no hash tree, so no need to do any syncing
|
|
1961
|
+
// we fall into this branch often, because Locus sends dataSets in messages that are not visible to us
|
|
1962
|
+
|
|
1059
1963
|
return;
|
|
1060
1964
|
}
|
|
1061
1965
|
dataSet.hashTree.resize(receivedDataSet.leafCount);
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
var ourCurrentRootHash = dataSet.hashTree.getRootHash();
|
|
1065
|
-
_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));
|
|
1066
|
-
var delay = dataSet.idleMs + this.getWeightedBackoffTime(dataSet.backoff);
|
|
1966
|
+
var randomBackoffTime = this.getWeightedBackoffTime(dataSet.backoff);
|
|
1967
|
+
var delay = dataSet.idleMs + randomBackoffTime;
|
|
1067
1968
|
if (delay > 0) {
|
|
1068
1969
|
if (dataSet.timer) {
|
|
1069
1970
|
clearTimeout(dataSet.timer);
|
|
1070
1971
|
}
|
|
1071
|
-
|
|
1072
|
-
dataSet.timer = setTimeout(
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
return _context8.abrupt("return");
|
|
1084
|
-
case 1:
|
|
1085
|
-
rootHash = dataSet.hashTree.getRootHash();
|
|
1086
|
-
if (!(dataSet.root !== rootHash)) {
|
|
1087
|
-
_context8.next = 11;
|
|
1088
|
-
break;
|
|
1089
|
-
}
|
|
1090
|
-
_loggerProxy.default.logger.info("HashTreeParser#runSyncAlgorithm --> ".concat(_this8.debugId, " Root hash mismatch: received=").concat(dataSet.root, ", ours=").concat(rootHash, ", syncing data set \"").concat(dataSet.name, "\""));
|
|
1091
|
-
mismatchedLeavesData = {};
|
|
1092
|
-
if (!(dataSet.leafCount !== 1)) {
|
|
1093
|
-
_context8.next = 7;
|
|
1094
|
-
break;
|
|
1095
|
-
}
|
|
1096
|
-
_context8.prev = 2;
|
|
1097
|
-
_context8.next = 3;
|
|
1098
|
-
return _this8.getHashesFromLocus(dataSet.name);
|
|
1099
|
-
case 3:
|
|
1100
|
-
_yield$_this8$getHash = _context8.sent;
|
|
1101
|
-
hashes = _yield$_this8$getHash.hashes;
|
|
1102
|
-
latestDataSetInfo = _yield$_this8$getHash.dataSet;
|
|
1103
|
-
receivedHashes = hashes;
|
|
1104
|
-
dataSet.hashTree.resize(latestDataSetInfo.leafCount);
|
|
1105
|
-
_context8.next = 6;
|
|
1106
|
-
break;
|
|
1107
|
-
case 4:
|
|
1108
|
-
_context8.prev = 4;
|
|
1109
|
-
_t3 = _context8["catch"](2);
|
|
1110
|
-
if (!(_t3.statusCode === 409)) {
|
|
1111
|
-
_context8.next = 5;
|
|
1112
|
-
break;
|
|
1113
|
-
}
|
|
1114
|
-
// this is a leaf count mismatch, we should do nothing, just wait for another heartbeat message from Locus
|
|
1115
|
-
_loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(_this8.debugId, " Got 409 when fetching hashes for data set \"").concat(dataSet.name, "\": ").concat(_t3.message));
|
|
1116
|
-
return _context8.abrupt("return");
|
|
1117
|
-
case 5:
|
|
1118
|
-
throw _t3;
|
|
1119
|
-
case 6:
|
|
1120
|
-
// identify mismatched leaves
|
|
1121
|
-
mismatchedLeaveIndexes = dataSet.hashTree.diffHashes(receivedHashes);
|
|
1122
|
-
mismatchedLeaveIndexes.forEach(function (index) {
|
|
1123
|
-
mismatchedLeavesData[index] = dataSet.hashTree.getLeafData(index);
|
|
1124
|
-
});
|
|
1125
|
-
_context8.next = 8;
|
|
1126
|
-
break;
|
|
1127
|
-
case 7:
|
|
1128
|
-
mismatchedLeavesData[0] = dataSet.hashTree.getLeafData(0);
|
|
1129
|
-
case 8:
|
|
1130
|
-
if (!((0, _keys.default)(mismatchedLeavesData).length > 0)) {
|
|
1131
|
-
_context8.next = 10;
|
|
1132
|
-
break;
|
|
1133
|
-
}
|
|
1134
|
-
_context8.next = 9;
|
|
1135
|
-
return _this8.sendSyncRequestToLocus(dataSet, mismatchedLeavesData);
|
|
1136
|
-
case 9:
|
|
1137
|
-
syncResponse = _context8.sent;
|
|
1138
|
-
// sync API may return nothing (in that case data will arrive via messages)
|
|
1139
|
-
// or it may return a response in the same format as messages
|
|
1140
|
-
if (syncResponse) {
|
|
1141
|
-
_this8.handleMessage(syncResponse, 'via sync API');
|
|
1142
|
-
}
|
|
1143
|
-
case 10:
|
|
1144
|
-
_context8.next = 12;
|
|
1145
|
-
break;
|
|
1146
|
-
case 11:
|
|
1147
|
-
_loggerProxy.default.logger.info("HashTreeParser#runSyncAlgorithm --> ".concat(_this8.debugId, " \"").concat(dataSet.name, "\" root hash matching: ").concat(rootHash, ", version=").concat(dataSet.version));
|
|
1148
|
-
case 12:
|
|
1149
|
-
case "end":
|
|
1150
|
-
return _context8.stop();
|
|
1151
|
-
}
|
|
1152
|
-
}, _callee7, null, [[2, 4]]);
|
|
1153
|
-
})), delay);
|
|
1972
|
+
this.saveSyncBackoffLatency(dataSet.name, randomBackoffTime);
|
|
1973
|
+
dataSet.timer = setTimeout(function () {
|
|
1974
|
+
dataSet.timer = undefined;
|
|
1975
|
+
if (!dataSet.hashTree) {
|
|
1976
|
+
_loggerProxy.default.logger.warn("HashTreeParser#runSyncAlgorithm --> ".concat(_this10.debugId, " Data set \"").concat(dataSet.name, "\" no longer has a hash tree, cannot run sync algorithm"));
|
|
1977
|
+
return;
|
|
1978
|
+
}
|
|
1979
|
+
var rootHash = dataSet.hashTree.getRootHash();
|
|
1980
|
+
if (dataSet.root !== rootHash) {
|
|
1981
|
+
_this10.enqueueSyncForDataset(dataSet.name, "Root hash mismatch: received=".concat(dataSet.root, ", ours=").concat(rootHash));
|
|
1982
|
+
}
|
|
1983
|
+
}, delay);
|
|
1154
1984
|
} else {
|
|
1155
1985
|
_loggerProxy.default.logger.info("HashTreeParser#runSyncAlgorithm --> ".concat(this.debugId, " No delay for \"").concat(dataSet.name, "\" data set, skipping sync timer reset/setup"));
|
|
1156
1986
|
}
|
|
1157
1987
|
}
|
|
1158
1988
|
|
|
1989
|
+
/**
|
|
1990
|
+
* Resets the heartbeat watchdog timers for the specified data sets. Each data set has its own
|
|
1991
|
+
* watchdog timer that monitors whether heartbeats are being received within the expected interval.
|
|
1992
|
+
* If a heartbeat is not received for a specific data set within heartbeatIntervalMs plus
|
|
1993
|
+
* a backoff-calculated time, the sync algorithm is initiated for that data set
|
|
1994
|
+
*
|
|
1995
|
+
* @param {Array<DataSet>} receivedDataSets - The data sets from the received message for which watchdog timers should be reset
|
|
1996
|
+
* @returns {void}
|
|
1997
|
+
*/
|
|
1998
|
+
}, {
|
|
1999
|
+
key: "resetHeartbeatWatchdogs",
|
|
2000
|
+
value: function resetHeartbeatWatchdogs(receivedDataSets) {
|
|
2001
|
+
var _this11 = this;
|
|
2002
|
+
var _iterator10 = _createForOfIteratorHelper(receivedDataSets),
|
|
2003
|
+
_step10;
|
|
2004
|
+
try {
|
|
2005
|
+
var _loop2 = function _loop2() {
|
|
2006
|
+
var _dataSet$heartbeatInt;
|
|
2007
|
+
var receivedDataSet = _step10.value;
|
|
2008
|
+
var dataSet = _this11.dataSets[receivedDataSet.name];
|
|
2009
|
+
if (dataSet.heartbeatWatchdogTimer) {
|
|
2010
|
+
clearTimeout(dataSet.heartbeatWatchdogTimer);
|
|
2011
|
+
dataSet.heartbeatWatchdogTimer = undefined;
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
// dataset-level heartbeatIntervalMs takes priority; fall back to top-level common value
|
|
2015
|
+
var heartbeatIntervalMs = (_dataSet$heartbeatInt = dataSet === null || dataSet === void 0 ? void 0 : dataSet.heartbeatIntervalMs) !== null && _dataSet$heartbeatInt !== void 0 ? _dataSet$heartbeatInt : _this11.topLevelHeartbeatIntervalMs;
|
|
2016
|
+
if (!(dataSet !== null && dataSet !== void 0 && dataSet.hashTree) || !heartbeatIntervalMs) {
|
|
2017
|
+
// eslint-disable-next-line no-continue
|
|
2018
|
+
return 1; // continue
|
|
2019
|
+
}
|
|
2020
|
+
var backoffTime = _this11.getWeightedBackoffTime(dataSet.backoff);
|
|
2021
|
+
var delay = heartbeatIntervalMs + backoffTime;
|
|
2022
|
+
dataSet.heartbeatWatchdogTimer = setTimeout(function () {
|
|
2023
|
+
dataSet.heartbeatWatchdogTimer = undefined;
|
|
2024
|
+
_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"));
|
|
2025
|
+
_metrics.default.sendBehavioralMetric(_constants.default.HASH_TREE_HEARTBEAT_WATCHDOG_EXPIRED, {
|
|
2026
|
+
debugId: _this11.debugId,
|
|
2027
|
+
dataSetName: dataSet.name
|
|
2028
|
+
});
|
|
2029
|
+
_this11.saveSyncBackoffLatency(dataSet.name, backoffTime);
|
|
2030
|
+
_this11.enqueueSyncForDataset(dataSet.name, "heartbeat watchdog expired");
|
|
2031
|
+
_this11.resetHeartbeatWatchdogs([dataSet]);
|
|
2032
|
+
}, delay);
|
|
2033
|
+
};
|
|
2034
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
2035
|
+
if (_loop2()) continue;
|
|
2036
|
+
}
|
|
2037
|
+
} catch (err) {
|
|
2038
|
+
_iterator10.e(err);
|
|
2039
|
+
} finally {
|
|
2040
|
+
_iterator10.f();
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
|
|
1159
2044
|
/**
|
|
1160
2045
|
* Stops all timers for the data sets to prevent any further sync attempts.
|
|
1161
2046
|
* @returns {void}
|
|
@@ -1168,39 +2053,220 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1168
2053
|
clearTimeout(dataSet.timer);
|
|
1169
2054
|
dataSet.timer = undefined;
|
|
1170
2055
|
}
|
|
2056
|
+
if (dataSet.heartbeatWatchdogTimer) {
|
|
2057
|
+
clearTimeout(dataSet.heartbeatWatchdogTimer);
|
|
2058
|
+
dataSet.heartbeatWatchdogTimer = undefined;
|
|
2059
|
+
}
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
|
|
2063
|
+
/**
|
|
2064
|
+
* Stops the HashTreeParser, preventing it from processing any further messages and clearing all timers.
|
|
2065
|
+
* It also clears all the hash trees, so if the parser is resumed later, it will need to do a sync
|
|
2066
|
+
* to be up-to-date.
|
|
2067
|
+
* @returns {void}
|
|
2068
|
+
*/
|
|
2069
|
+
}, {
|
|
2070
|
+
key: "stop",
|
|
2071
|
+
value: function stop() {
|
|
2072
|
+
_loggerProxy.default.logger.info("HashTreeParser#stop --> ".concat(this.debugId, " Stopping HashTreeParser, clearing timers and hash trees"));
|
|
2073
|
+
this.stopAllTimers();
|
|
2074
|
+
this.syncQueue = [];
|
|
2075
|
+
this.topLevelHeartbeatIntervalMs = undefined;
|
|
2076
|
+
this.syncAllBackoffType = SyncAllBackoffType.NONE;
|
|
2077
|
+
this.dataSetsSyncedDuringBackoff = new _set.default();
|
|
2078
|
+
(0, _values.default)(this.dataSets).forEach(function (dataSet) {
|
|
2079
|
+
var _dataSet$syncAbortCon2;
|
|
2080
|
+
(_dataSet$syncAbortCon2 = dataSet.syncAbortController) === null || _dataSet$syncAbortCon2 === void 0 ? void 0 : _dataSet$syncAbortCon2.abort();
|
|
2081
|
+
dataSet.syncAbortController = undefined;
|
|
2082
|
+
dataSet.hashTree = undefined;
|
|
1171
2083
|
});
|
|
2084
|
+
this.visibleDataSets = [];
|
|
2085
|
+
this.state = 'stopped';
|
|
2086
|
+
}
|
|
2087
|
+
|
|
2088
|
+
/**
|
|
2089
|
+
* Cleans up the HashTreeParser, stopping all timers and clearing all internal state.
|
|
2090
|
+
* After calling this, the parser should not be used anymore.
|
|
2091
|
+
* @returns {void}
|
|
2092
|
+
*/
|
|
2093
|
+
}, {
|
|
2094
|
+
key: "cleanUp",
|
|
2095
|
+
value: function cleanUp() {
|
|
2096
|
+
this.stop();
|
|
2097
|
+
this.dataSets = {};
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
/**
|
|
2101
|
+
* Resumes the HashTreeParser that was previously stopped, using a hash tree message.
|
|
2102
|
+
* @param {HashTreeMessage} message - The message to resume with, it must contain metadata with visible data sets info
|
|
2103
|
+
* @returns {void}
|
|
2104
|
+
*/
|
|
2105
|
+
}, {
|
|
2106
|
+
key: "resumeFromMessage",
|
|
2107
|
+
value: function resumeFromMessage(message) {
|
|
2108
|
+
var _message$locusStateEl6, _metadataObject$data;
|
|
2109
|
+
var metadataObject = (_message$locusStateEl6 = message.locusStateElements) === null || _message$locusStateEl6 === void 0 ? void 0 : _message$locusStateEl6.find(function (el) {
|
|
2110
|
+
return (0, _utils.isMetadata)(el);
|
|
2111
|
+
});
|
|
2112
|
+
if (!(metadataObject !== null && metadataObject !== void 0 && (_metadataObject$data = metadataObject.data) !== null && _metadataObject$data !== void 0 && _metadataObject$data.visibleDataSets)) {
|
|
2113
|
+
_loggerProxy.default.logger.warn("HashTreeParser#resumeFromMessage --> ".concat(this.debugId, " Cannot resume HashTreeParser because the message is missing metadata with visible data sets info"));
|
|
2114
|
+
return;
|
|
2115
|
+
}
|
|
2116
|
+
this.setVisibleDataSets(metadataObject.data.visibleDataSets, message.dataSets);
|
|
2117
|
+
this.dataSets = {};
|
|
2118
|
+
var _iterator11 = _createForOfIteratorHelper(message.dataSets),
|
|
2119
|
+
_step11;
|
|
2120
|
+
try {
|
|
2121
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
2122
|
+
var dataSet = _step11.value;
|
|
2123
|
+
var name = dataSet.name,
|
|
2124
|
+
leafCount = dataSet.leafCount;
|
|
2125
|
+
this.dataSets[name] = _objectSpread(_objectSpread({}, dataSet), {}, {
|
|
2126
|
+
hashTree: this.isVisibleDataSet(name) ? new _hashTree.default([], leafCount) : undefined
|
|
2127
|
+
});
|
|
2128
|
+
}
|
|
2129
|
+
} catch (err) {
|
|
2130
|
+
_iterator11.e(err);
|
|
2131
|
+
} finally {
|
|
2132
|
+
_iterator11.f();
|
|
2133
|
+
}
|
|
2134
|
+
_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) {
|
|
2135
|
+
return ds.name;
|
|
2136
|
+
}).join(', ')));
|
|
2137
|
+
this.state = 'active';
|
|
2138
|
+
this.handleMessage(message, 'on resume');
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2141
|
+
/**
|
|
2142
|
+
* Resumes the HashTreeParser that was previously stopped, using a Locus API response.
|
|
2143
|
+
* Unlike resumeFromMessage(), this does not require metadata/dataSets in the input,
|
|
2144
|
+
* as it fetches all necessary information from Locus via initializeFromGetLociResponse.
|
|
2145
|
+
* @param {LocusDTO} locus - locus object from an API response
|
|
2146
|
+
* @returns {Promise}
|
|
2147
|
+
*/
|
|
2148
|
+
}, {
|
|
2149
|
+
key: "resumeFromApiResponse",
|
|
2150
|
+
value: (function () {
|
|
2151
|
+
var _resumeFromApiResponse = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9(locus) {
|
|
2152
|
+
return _regenerator.default.wrap(function (_context0) {
|
|
2153
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
2154
|
+
case 0:
|
|
2155
|
+
this.state = 'active';
|
|
2156
|
+
this.dataSets = {};
|
|
2157
|
+
_loggerProxy.default.logger.info("HashTreeParser#resumeFromApiResponse --> ".concat(this.debugId, " Resuming HashTreeParser from API response"));
|
|
2158
|
+
_context0.next = 1;
|
|
2159
|
+
return this.initializeFromGetLociResponse(locus);
|
|
2160
|
+
case 1:
|
|
2161
|
+
case "end":
|
|
2162
|
+
return _context0.stop();
|
|
2163
|
+
}
|
|
2164
|
+
}, _callee9, this);
|
|
2165
|
+
}));
|
|
2166
|
+
function resumeFromApiResponse(_x1) {
|
|
2167
|
+
return _resumeFromApiResponse.apply(this, arguments);
|
|
2168
|
+
}
|
|
2169
|
+
return resumeFromApiResponse;
|
|
2170
|
+
}())
|
|
2171
|
+
}, {
|
|
2172
|
+
key: "checkForSentinelHttpResponse",
|
|
2173
|
+
value: function checkForSentinelHttpResponse(error, dataSetName) {
|
|
2174
|
+
var _error$body;
|
|
2175
|
+
// 404 for any dataset means the locus is no longer available at this URL - could be replaced or ended
|
|
2176
|
+
// if a dataset is just not visible, we would get a 400
|
|
2177
|
+
if (error.statusCode === 404) {
|
|
2178
|
+
_loggerProxy.default.logger.info("HashTreeParser#checkForSentinelHttpResponse --> ".concat(this.debugId, " Received 404 for data set \"").concat(dataSetName, "\", locus not found"));
|
|
2179
|
+
this.stopAllTimers();
|
|
2180
|
+
throw new LocusNotFoundError();
|
|
2181
|
+
}
|
|
2182
|
+
var isValidDataSetForSentinel = dataSetName === undefined || PossibleSentinelMessageDataSetNames.includes(dataSetName.toLowerCase());
|
|
2183
|
+
if (error.statusCode === 409 && ((_error$body = error.body) === null || _error$body === void 0 ? void 0 : _error$body.errorCode) === _types2.LocusErrorCodes.LOCUS_INACTIVE && isValidDataSetForSentinel) {
|
|
2184
|
+
var _error$body2;
|
|
2185
|
+
_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"));
|
|
2186
|
+
this.stopAllTimers();
|
|
2187
|
+
throw new MeetingEndedError();
|
|
2188
|
+
}
|
|
1172
2189
|
}
|
|
1173
2190
|
|
|
1174
2191
|
/**
|
|
1175
2192
|
* Gets the current hashes from the locus for a specific data set.
|
|
1176
2193
|
* @param {string} dataSetName
|
|
1177
|
-
* @
|
|
2194
|
+
* @param {string} currentRootHash
|
|
2195
|
+
* @param {Object} [trackingIds] tracking ids for the /hashtree request
|
|
2196
|
+
* @param {string} [trackingIds.requestTrackingId] tracking id forced onto the /hashtree HTTP request header (kept distinct from the /sync request's tracking id)
|
|
2197
|
+
* @param {string} [trackingIds.metricTrackingId] tracking id (the /sync request's) under which the hashtree latency milestones are recorded, so they belong to the same sync latency record
|
|
2198
|
+
* @returns {Object|null} An object containing the hashes and leaf count, or null if the hashes match and no sync is needed
|
|
1178
2199
|
*/
|
|
1179
2200
|
}, {
|
|
1180
2201
|
key: "getHashesFromLocus",
|
|
1181
|
-
value: function getHashesFromLocus(dataSetName) {
|
|
1182
|
-
var
|
|
2202
|
+
value: function getHashesFromLocus(dataSetName, currentRootHash, trackingIds) {
|
|
2203
|
+
var _this12 = this;
|
|
2204
|
+
var _ref9 = trackingIds !== null && trackingIds !== void 0 ? trackingIds : {},
|
|
2205
|
+
requestTrackingId = _ref9.requestTrackingId,
|
|
2206
|
+
metricTrackingId = _ref9.metricTrackingId;
|
|
1183
2207
|
_loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(this.debugId, " Requesting hashes for data set \"").concat(dataSetName, "\""));
|
|
1184
2208
|
var dataSet = this.dataSets[dataSetName];
|
|
1185
2209
|
var url = "".concat(dataSet.url, "/hashtree");
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
2210
|
+
if (this.shouldCollectSyncMetrics(dataSetName)) {
|
|
2211
|
+
var _this$callbacks$syncL4;
|
|
2212
|
+
(_this$callbacks$syncL4 = this.callbacks.syncLatencyTracker) === null || _this$callbacks$syncL4 === void 0 ? void 0 : _this$callbacks$syncL4.saveTimestamp({
|
|
2213
|
+
key: 'internal.client.locus.hashtree.request',
|
|
2214
|
+
options: {
|
|
2215
|
+
meetingId: this.syncLatencyMeetingId,
|
|
2216
|
+
dataSetName: dataSetName,
|
|
2217
|
+
trackingId: metricTrackingId
|
|
2218
|
+
}
|
|
2219
|
+
});
|
|
2220
|
+
}
|
|
2221
|
+
return this.webexRequest(_objectSpread({
|
|
2222
|
+
method: _constants2.HTTP_VERBS.GET,
|
|
2223
|
+
uri: url,
|
|
2224
|
+
qs: {
|
|
2225
|
+
rootHash: currentRootHash
|
|
2226
|
+
}
|
|
2227
|
+
}, requestTrackingId ? {
|
|
2228
|
+
headers: {
|
|
2229
|
+
trackingid: requestTrackingId
|
|
2230
|
+
}
|
|
2231
|
+
} : {})).then(function (response) {
|
|
1190
2232
|
var _response$body, _response$body2;
|
|
2233
|
+
if (_this12.shouldCollectSyncMetrics(dataSetName)) {
|
|
2234
|
+
var _this12$callbacks$syn;
|
|
2235
|
+
(_this12$callbacks$syn = _this12.callbacks.syncLatencyTracker) === null || _this12$callbacks$syn === void 0 ? void 0 : _this12$callbacks$syn.saveTimestamp({
|
|
2236
|
+
key: 'internal.client.locus.hashtree.response',
|
|
2237
|
+
options: {
|
|
2238
|
+
meetingId: _this12.syncLatencyMeetingId,
|
|
2239
|
+
dataSetName: dataSetName,
|
|
2240
|
+
trackingId: metricTrackingId
|
|
2241
|
+
}
|
|
2242
|
+
});
|
|
2243
|
+
}
|
|
2244
|
+
if (!response.body || (0, _lodash.isEmpty)(response.body)) {
|
|
2245
|
+
// 204 with empty body means our hashes match Locus, no sync needed
|
|
2246
|
+
_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"));
|
|
2247
|
+
return null;
|
|
2248
|
+
}
|
|
1191
2249
|
var hashes = (_response$body = response.body) === null || _response$body === void 0 ? void 0 : _response$body.hashes;
|
|
1192
2250
|
var dataSetFromResponse = (_response$body2 = response.body) === null || _response$body2 === void 0 ? void 0 : _response$body2.dataSet;
|
|
1193
2251
|
if (!hashes || !(0, _isArray.default)(hashes)) {
|
|
1194
|
-
_loggerProxy.default.logger.warn("HashTreeParser#getHashesFromLocus --> ".concat(
|
|
2252
|
+
_loggerProxy.default.logger.warn("HashTreeParser#getHashesFromLocus --> ".concat(_this12.debugId, " Locus returned invalid hashes, response body="), response.body);
|
|
1195
2253
|
throw new Error("Locus returned invalid hashes: ".concat(hashes));
|
|
1196
2254
|
}
|
|
1197
|
-
_loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(
|
|
2255
|
+
_loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(_this12.debugId, " Received hashes for data set \"").concat(dataSetName, "\": ").concat((0, _stringify.default)(hashes)));
|
|
1198
2256
|
return {
|
|
1199
2257
|
hashes: hashes,
|
|
1200
2258
|
dataSet: dataSetFromResponse
|
|
1201
2259
|
};
|
|
1202
2260
|
}).catch(function (error) {
|
|
1203
|
-
_loggerProxy.default.logger.error("HashTreeParser#getHashesFromLocus --> ".concat(
|
|
2261
|
+
_loggerProxy.default.logger.error("HashTreeParser#getHashesFromLocus --> ".concat(_this12.debugId, " Error ").concat(error.statusCode, " fetching hashes for data set \"").concat(dataSetName, "\":"), error);
|
|
2262
|
+
_this12.checkForSentinelHttpResponse(error, dataSet.name);
|
|
2263
|
+
_metrics.default.sendBehavioralMetric(_constants.default.HASH_TREE_SYNC_FAILURE, {
|
|
2264
|
+
debugId: _this12.debugId,
|
|
2265
|
+
dataSetName: dataSetName,
|
|
2266
|
+
request: 'GET /hashtree',
|
|
2267
|
+
statusCode: error.statusCode,
|
|
2268
|
+
reason: error.message
|
|
2269
|
+
});
|
|
1204
2270
|
throw error;
|
|
1205
2271
|
});
|
|
1206
2272
|
}
|
|
@@ -1209,38 +2275,89 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1209
2275
|
* Sends a sync request to Locus for the specified data set.
|
|
1210
2276
|
*
|
|
1211
2277
|
* @param {InternalDataSet} dataSet The data set to sync.
|
|
1212
|
-
* @param {
|
|
1213
|
-
* @
|
|
2278
|
+
* @param {Object} options Either `{ isInitialization: true }` for init syncs (uses leafCount=1 with empty leaf data) or `{ mismatchedLeavesData }` for normal syncs.
|
|
2279
|
+
* @param {string} [trackingId] tracking id
|
|
2280
|
+
* @returns {Promise<HashTreeMessage | null>}
|
|
1214
2281
|
*/
|
|
1215
2282
|
}, {
|
|
1216
2283
|
key: "sendSyncRequestToLocus",
|
|
1217
|
-
value: function sendSyncRequestToLocus(dataSet,
|
|
1218
|
-
var
|
|
2284
|
+
value: function sendSyncRequestToLocus(dataSet, options, trackingId) {
|
|
2285
|
+
var _this13 = this;
|
|
1219
2286
|
_loggerProxy.default.logger.info("HashTreeParser#sendSyncRequestToLocus --> ".concat(this.debugId, " Sending sync request for data set \"").concat(dataSet.name, "\""));
|
|
2287
|
+
var isInitialization = 'isInitialization' in options;
|
|
1220
2288
|
var url = "".concat(dataSet.url, "/sync");
|
|
1221
2289
|
var body = {
|
|
1222
|
-
leafCount: dataSet.leafCount,
|
|
2290
|
+
leafCount: isInitialization ? 1 : dataSet.leafCount,
|
|
1223
2291
|
leafDataEntries: []
|
|
1224
2292
|
};
|
|
1225
|
-
|
|
2293
|
+
if (isInitialization) {
|
|
2294
|
+
// initialization sync: Locus requires leafCount=1 with a single empty leaf
|
|
1226
2295
|
body.leafDataEntries.push({
|
|
1227
|
-
leafIndex:
|
|
1228
|
-
elementIds:
|
|
2296
|
+
leafIndex: 0,
|
|
2297
|
+
elementIds: []
|
|
1229
2298
|
});
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
|
-
|
|
2299
|
+
} else {
|
|
2300
|
+
var mismatchedLeavesData = options.mismatchedLeavesData;
|
|
2301
|
+
(0, _keys.default)(mismatchedLeavesData).forEach(function (index) {
|
|
2302
|
+
var leafIndex = (0, _parseInt2.default)(index, 10);
|
|
2303
|
+
body.leafDataEntries.push({
|
|
2304
|
+
leafIndex: leafIndex,
|
|
2305
|
+
elementIds: mismatchedLeavesData[leafIndex]
|
|
2306
|
+
});
|
|
2307
|
+
});
|
|
2308
|
+
}
|
|
2309
|
+
var ourCurrentRootHash = dataSet.hashTree ? dataSet.hashTree.getRootHash() : _constants3.EMPTY_HASH;
|
|
2310
|
+
var shouldCollectMetrics = this.shouldCollectSyncMetrics(dataSet.name, isInitialization);
|
|
2311
|
+
if (shouldCollectMetrics) {
|
|
2312
|
+
var _this$callbacks$syncL5;
|
|
2313
|
+
(_this$callbacks$syncL5 = this.callbacks.syncLatencyTracker) === null || _this$callbacks$syncL5 === void 0 ? void 0 : _this$callbacks$syncL5.saveTimestamp({
|
|
2314
|
+
key: 'internal.client.locus.sync.request',
|
|
2315
|
+
options: {
|
|
2316
|
+
meetingId: this.syncLatencyMeetingId,
|
|
2317
|
+
dataSetName: dataSet.name,
|
|
2318
|
+
trackingId: trackingId
|
|
2319
|
+
}
|
|
2320
|
+
});
|
|
2321
|
+
}
|
|
2322
|
+
return this.webexRequest(_objectSpread(_objectSpread({
|
|
2323
|
+
method: _constants2.HTTP_VERBS.POST,
|
|
1233
2324
|
uri: url,
|
|
2325
|
+
qs: {
|
|
2326
|
+
rootHash: ourCurrentRootHash
|
|
2327
|
+
}
|
|
2328
|
+
}, trackingId ? {
|
|
2329
|
+
headers: {
|
|
2330
|
+
trackingid: trackingId
|
|
2331
|
+
}
|
|
2332
|
+
} : {}), {}, {
|
|
1234
2333
|
body: body
|
|
1235
|
-
}).then(function (resp) {
|
|
1236
|
-
|
|
2334
|
+
})).then(function (resp) {
|
|
2335
|
+
if (shouldCollectMetrics) {
|
|
2336
|
+
var _this13$callbacks$syn;
|
|
2337
|
+
(_this13$callbacks$syn = _this13.callbacks.syncLatencyTracker) === null || _this13$callbacks$syn === void 0 ? void 0 : _this13$callbacks$syn.saveTimestamp({
|
|
2338
|
+
key: 'internal.client.locus.sync.response',
|
|
2339
|
+
options: {
|
|
2340
|
+
meetingId: _this13.syncLatencyMeetingId,
|
|
2341
|
+
dataSetName: dataSet.name,
|
|
2342
|
+
trackingId: trackingId
|
|
2343
|
+
}
|
|
2344
|
+
});
|
|
2345
|
+
}
|
|
1237
2346
|
if (!resp.body || (0, _lodash.isEmpty)(resp.body)) {
|
|
1238
|
-
_loggerProxy.default.logger.info("HashTreeParser#sendSyncRequestToLocus --> ".concat(
|
|
2347
|
+
_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"));
|
|
1239
2348
|
return null;
|
|
1240
2349
|
}
|
|
1241
2350
|
return resp.body;
|
|
1242
2351
|
}).catch(function (error) {
|
|
1243
|
-
_loggerProxy.default.logger.error("HashTreeParser#sendSyncRequestToLocus --> ".concat(
|
|
2352
|
+
_loggerProxy.default.logger.error("HashTreeParser#sendSyncRequestToLocus --> ".concat(_this13.debugId, " Error ").concat(error.statusCode, " sending sync request for data set \"").concat(dataSet.name, "\":"), error);
|
|
2353
|
+
_this13.checkForSentinelHttpResponse(error, dataSet.name);
|
|
2354
|
+
_metrics.default.sendBehavioralMetric(_constants.default.HASH_TREE_SYNC_FAILURE, {
|
|
2355
|
+
debugId: _this13.debugId,
|
|
2356
|
+
dataSetName: dataSet.name,
|
|
2357
|
+
request: 'POST /sync',
|
|
2358
|
+
statusCode: error.statusCode,
|
|
2359
|
+
reason: error.message
|
|
2360
|
+
});
|
|
1244
2361
|
throw error;
|
|
1245
2362
|
});
|
|
1246
2363
|
}
|