@webex/plugin-meetings 3.12.0-next.14 → 3.12.0-next.140
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +9 -0
- package/dist/aiEnableRequest/index.js +15 -2
- package/dist/aiEnableRequest/index.js.map +1 -1
- package/dist/annotation/index.js +2 -2
- 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 +99 -4
- package/dist/breakouts/index.js.map +1 -1
- package/dist/common/errors/webex-errors.js +49 -5
- package/dist/common/errors/webex-errors.js.map +1 -1
- package/dist/config.js +2 -2
- package/dist/config.js.map +1 -1
- package/dist/constants.js +37 -10
- package/dist/constants.js.map +1 -1
- package/dist/controls-options-manager/index.js +46 -10
- package/dist/controls-options-manager/index.js.map +1 -1
- package/dist/hashTree/constants.js +4 -1
- package/dist/hashTree/constants.js.map +1 -1
- package/dist/hashTree/hashTreeParser.js +1096 -391
- package/dist/hashTree/hashTreeParser.js.map +1 -1
- package/dist/hashTree/utils.js +20 -0
- package/dist/hashTree/utils.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/interceptors/dataChannelAuthToken.js +75 -15
- package/dist/interceptors/dataChannelAuthToken.js.map +1 -1
- package/dist/interceptors/locusRetry.js +23 -8
- package/dist/interceptors/locusRetry.js.map +1 -1
- package/dist/interpretation/index.js +10 -1
- package/dist/interpretation/index.js.map +1 -1
- package/dist/interpretation/interpretation.types.js +7 -0
- package/dist/interpretation/interpretation.types.js.map +1 -0
- package/dist/interpretation/siLanguage.js +1 -1
- package/dist/locus-info/controlsUtils.js +4 -1
- package/dist/locus-info/controlsUtils.js.map +1 -1
- package/dist/locus-info/index.js +615 -176
- package/dist/locus-info/index.js.map +1 -1
- package/dist/locus-info/infoUtils.js +36 -5
- package/dist/locus-info/infoUtils.js.map +1 -1
- package/dist/locus-info/types.js +20 -0
- package/dist/locus-info/types.js.map +1 -1
- package/dist/media/MediaConnectionAwaiter.js +15 -2
- package/dist/media/MediaConnectionAwaiter.js.map +1 -1
- package/dist/media/index.js +8 -2
- package/dist/media/index.js.map +1 -1
- package/dist/media/properties.js +4 -5
- package/dist/media/properties.js.map +1 -1
- package/dist/meeting/in-meeting-actions.js +5 -1
- package/dist/meeting/in-meeting-actions.js.map +1 -1
- package/dist/meeting/index.js +1680 -835
- package/dist/meeting/index.js.map +1 -1
- package/dist/meeting/locusMediaRequest.js +229 -82
- package/dist/meeting/locusMediaRequest.js.map +1 -1
- package/dist/meeting/muteState.js +10 -1
- package/dist/meeting/muteState.js.map +1 -1
- package/dist/meeting/request.js +5 -2
- package/dist/meeting/request.js.map +1 -1
- package/dist/meeting/util.js +34 -2
- package/dist/meeting/util.js.map +1 -1
- package/dist/meeting/voicea-meeting.js +2 -1
- package/dist/meeting/voicea-meeting.js.map +1 -1
- package/dist/meeting-info/meeting-info-v2.js +9 -3
- package/dist/meeting-info/meeting-info-v2.js.map +1 -1
- package/dist/meetings/index.js +293 -124
- package/dist/meetings/index.js.map +1 -1
- package/dist/meetings/meetings.types.js +6 -1
- package/dist/meetings/meetings.types.js.map +1 -1
- package/dist/meetings/request.js +39 -0
- package/dist/meetings/request.js.map +1 -1
- package/dist/meetings/util.js +116 -18
- package/dist/meetings/util.js.map +1 -1
- package/dist/member/index.js +10 -0
- package/dist/member/index.js.map +1 -1
- package/dist/member/types.js.map +1 -1
- package/dist/member/util.js +30 -0
- package/dist/member/util.js.map +1 -1
- package/dist/members/index.js +101 -43
- package/dist/members/index.js.map +1 -1
- package/dist/members/util.js +8 -1
- package/dist/members/util.js.map +1 -1
- package/dist/metrics/constants.js +7 -1
- package/dist/metrics/constants.js.map +1 -1
- package/dist/multistream/codec/constants.js +63 -0
- package/dist/multistream/codec/constants.js.map +1 -0
- package/dist/multistream/mediaRequestManager.js +62 -15
- package/dist/multistream/mediaRequestManager.js.map +1 -1
- package/dist/multistream/receiveSlot.js +9 -0
- package/dist/multistream/receiveSlot.js.map +1 -1
- package/dist/reachability/clusterReachability.js.map +1 -1
- package/dist/reachability/index.js +121 -83
- package/dist/reachability/index.js.map +1 -1
- package/dist/reachability/reachability.types.js +2 -0
- package/dist/reachability/reachability.types.js.map +1 -1
- package/dist/reachability/util.js +45 -0
- package/dist/reachability/util.js.map +1 -1
- package/dist/reactions/reactions.type.js.map +1 -1
- package/dist/recording-controller/index.js +1 -3
- package/dist/recording-controller/index.js.map +1 -1
- package/dist/roap/turnDiscovery.js +8 -1
- package/dist/roap/turnDiscovery.js.map +1 -1
- package/dist/types/common/errors/webex-errors.d.ts +32 -2
- package/dist/types/config.d.ts +2 -2
- package/dist/types/constants.d.ts +13 -1
- package/dist/types/controls-options-manager/index.d.ts +16 -0
- package/dist/types/hashTree/constants.d.ts +1 -0
- package/dist/types/hashTree/hashTreeParser.d.ts +201 -22
- package/dist/types/hashTree/utils.d.ts +7 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/interceptors/locusRetry.d.ts +4 -4
- package/dist/types/interpretation/interpretation.types.d.ts +10 -0
- package/dist/types/locus-info/index.d.ts +106 -8
- package/dist/types/locus-info/infoUtils.d.ts +8 -0
- package/dist/types/locus-info/types.d.ts +22 -1
- package/dist/types/media/MediaConnectionAwaiter.d.ts +10 -1
- package/dist/types/media/properties.d.ts +6 -2
- package/dist/types/meeting/in-meeting-actions.d.ts +4 -0
- package/dist/types/meeting/index.d.ts +176 -11
- package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
- package/dist/types/meeting/request.d.ts +1 -0
- package/dist/types/meeting/util.d.ts +9 -0
- package/dist/types/meeting-info/meeting-info-v2.d.ts +1 -0
- package/dist/types/meetings/index.d.ts +40 -19
- package/dist/types/meetings/meetings.types.d.ts +15 -0
- package/dist/types/meetings/request.d.ts +14 -0
- package/dist/types/member/index.d.ts +1 -0
- package/dist/types/member/types.d.ts +1 -0
- package/dist/types/member/util.d.ts +9 -0
- package/dist/types/members/index.d.ts +15 -2
- package/dist/types/members/util.d.ts +1 -5
- package/dist/types/metrics/constants.d.ts +6 -0
- package/dist/types/multistream/codec/constants.d.ts +7 -0
- package/dist/types/multistream/mediaRequestManager.d.ts +22 -5
- package/dist/types/reachability/clusterReachability.d.ts +3 -3
- package/dist/types/reachability/index.d.ts +10 -3
- package/dist/types/reachability/reachability.types.d.ts +7 -0
- package/dist/types/reachability/util.d.ts +17 -0
- package/dist/types/reactions/reactions.type.d.ts +3 -0
- package/dist/webinar/index.js +307 -161
- package/dist/webinar/index.js.map +1 -1
- package/package.json +23 -23
- package/src/aiEnableRequest/index.ts +16 -0
- package/src/annotation/index.ts +6 -4
- package/src/breakouts/breakout.ts +3 -1
- package/src/breakouts/events.ts +33 -11
- package/src/breakouts/index.ts +122 -2
- package/src/common/errors/webex-errors.ts +50 -3
- package/src/config.ts +2 -2
- package/src/constants.ts +21 -3
- package/src/controls-options-manager/index.ts +62 -10
- package/src/hashTree/constants.ts +7 -0
- package/src/hashTree/hashTreeParser.ts +861 -193
- package/src/hashTree/utils.ts +19 -0
- package/src/index.ts +6 -0
- package/src/interceptors/dataChannelAuthToken.ts +88 -12
- package/src/interceptors/locusRetry.ts +25 -4
- package/src/interpretation/index.ts +27 -9
- package/src/interpretation/interpretation.types.ts +11 -0
- package/src/locus-info/controlsUtils.ts +3 -1
- package/src/locus-info/index.ts +566 -164
- package/src/locus-info/infoUtils.ts +41 -6
- package/src/locus-info/types.ts +26 -1
- package/src/media/MediaConnectionAwaiter.ts +21 -4
- package/src/media/index.ts +10 -1
- package/src/media/properties.ts +8 -3
- package/src/meeting/in-meeting-actions.ts +8 -0
- package/src/meeting/index.ts +933 -119
- package/src/meeting/locusMediaRequest.ts +106 -6
- package/src/meeting/muteState.ts +10 -1
- package/src/meeting/request.ts +11 -0
- package/src/meeting/util.ts +46 -5
- package/src/meeting/voicea-meeting.ts +1 -1
- package/src/meeting-info/meeting-info-v2.ts +10 -4
- package/src/meetings/index.ts +197 -80
- package/src/meetings/meetings.types.ts +19 -0
- package/src/meetings/request.ts +43 -0
- package/src/meetings/util.ts +117 -4
- package/src/member/index.ts +10 -0
- package/src/member/types.ts +1 -0
- package/src/member/util.ts +29 -0
- package/src/members/index.ts +70 -7
- package/src/members/util.ts +12 -4
- package/src/metrics/constants.ts +6 -0
- package/src/multistream/codec/constants.ts +58 -0
- package/src/multistream/mediaRequestManager.ts +119 -28
- package/src/multistream/receiveSlot.ts +18 -0
- package/src/reachability/clusterReachability.ts +3 -2
- package/src/reachability/index.ts +47 -16
- package/src/reachability/reachability.types.ts +11 -0
- package/src/reachability/util.ts +36 -0
- package/src/reactions/reactions.type.ts +3 -0
- package/src/recording-controller/index.ts +1 -2
- package/src/roap/turnDiscovery.ts +9 -1
- package/src/webinar/index.ts +216 -38
- package/test/unit/spec/aiEnableRequest/index.ts +86 -0
- package/test/unit/spec/annotation/index.ts +3 -3
- 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 +223 -3
- package/test/unit/spec/common/errors/webex-errors.ts +78 -0
- package/test/unit/spec/controls-options-manager/index.js +139 -32
- package/test/unit/spec/hashTree/hashTreeParser.ts +2451 -184
- package/test/unit/spec/hashTree/utils.ts +37 -0
- package/test/unit/spec/interceptors/dataChannelAuthToken.ts +196 -0
- package/test/unit/spec/interceptors/locusRetry.ts +205 -4
- package/test/unit/spec/interpretation/index.ts +26 -4
- package/test/unit/spec/locus-info/controlsUtils.js +172 -57
- package/test/unit/spec/locus-info/index.js +1014 -58
- package/test/unit/spec/locus-info/infoUtils.js +184 -1
- package/test/unit/spec/media/MediaConnectionAwaiter.ts +55 -0
- package/test/unit/spec/media/index.ts +92 -0
- package/test/unit/spec/media/properties.ts +23 -23
- package/test/unit/spec/meeting/in-meeting-actions.ts +4 -0
- package/test/unit/spec/meeting/index.js +2805 -116
- package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
- package/test/unit/spec/meeting/muteState.js +81 -0
- package/test/unit/spec/meeting/request.js +12 -0
- package/test/unit/spec/meeting/utils.js +153 -1
- package/test/unit/spec/meeting/voicea-meeting.ts +85 -1
- package/test/unit/spec/meeting-info/meetinginfov2.js +76 -10
- package/test/unit/spec/meetings/index.js +533 -49
- package/test/unit/spec/meetings/request.js +141 -0
- package/test/unit/spec/meetings/utils.js +402 -51
- package/test/unit/spec/member/index.js +7 -0
- package/test/unit/spec/member/util.js +89 -0
- package/test/unit/spec/members/index.js +216 -0
- package/test/unit/spec/members/request.js +37 -1
- package/test/unit/spec/members/utils.js +63 -0
- package/test/unit/spec/multistream/mediaRequestManager.ts +501 -37
- package/test/unit/spec/reachability/index.ts +128 -46
- package/test/unit/spec/reachability/util.ts +31 -0
- package/test/unit/spec/recording-controller/index.js +9 -8
- package/test/unit/spec/roap/turnDiscovery.ts +20 -0
- package/test/unit/spec/webinar/index.ts +332 -31
|
@@ -15,17 +15,18 @@ var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequ
|
|
|
15
15
|
_Object$defineProperty(exports, "__esModule", {
|
|
16
16
|
value: true
|
|
17
17
|
});
|
|
18
|
-
exports.default = exports.MeetingEndedError = exports.LocusInfoUpdateType = void 0;
|
|
18
|
+
exports.default = exports.SyncAllBackoffType = exports.MeetingEndedError = exports.LocusNotFoundError = exports.LocusInfoUpdateType = void 0;
|
|
19
19
|
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
|
20
|
-
var
|
|
20
|
+
var _set = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/set"));
|
|
21
21
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
22
|
+
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
22
23
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/array/is-array"));
|
|
23
24
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
|
|
24
25
|
var _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/values"));
|
|
25
26
|
var _parseInt2 = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/parse-int"));
|
|
27
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
|
|
26
28
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
|
|
27
29
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/typeof"));
|
|
28
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
|
|
29
30
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
30
31
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
31
32
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
@@ -37,9 +38,12 @@ var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime-corejs2/h
|
|
|
37
38
|
var _lodash = require("lodash");
|
|
38
39
|
var _hashTree = _interopRequireDefault(require("./hashTree"));
|
|
39
40
|
var _loggerProxy = _interopRequireDefault(require("../common/logs/logger-proxy"));
|
|
40
|
-
var
|
|
41
|
-
var
|
|
41
|
+
var _metrics = _interopRequireDefault(require("../metrics"));
|
|
42
|
+
var _constants = _interopRequireDefault(require("../metrics/constants"));
|
|
43
|
+
var _constants2 = require("../constants");
|
|
44
|
+
var _constants3 = require("./constants");
|
|
42
45
|
var _types = require("./types");
|
|
46
|
+
var _types2 = require("../locus-info/types");
|
|
43
47
|
var _utils = require("./utils");
|
|
44
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; }
|
|
45
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; }
|
|
@@ -48,10 +52,18 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
48
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; }
|
|
49
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)); }
|
|
50
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
|
+
}({});
|
|
51
61
|
var LocusInfoUpdateType = exports.LocusInfoUpdateType = {
|
|
52
62
|
OBJECTS_UPDATED: 'OBJECTS_UPDATED',
|
|
53
|
-
MEETING_ENDED: 'MEETING_ENDED'
|
|
63
|
+
MEETING_ENDED: 'MEETING_ENDED',
|
|
64
|
+
LOCUS_NOT_FOUND: 'LOCUS_NOT_FOUND'
|
|
54
65
|
};
|
|
66
|
+
var SYNC_METRICS_DATA_SETS = [_constants3.DataSetNames.MAIN, _constants3.DataSetNames.ATD_ACTIVE, _constants3.DataSetNames.ATD_UNMUTED];
|
|
55
67
|
/**
|
|
56
68
|
* This error is thrown if we receive information that the meeting has ended while we're processing some hash messages.
|
|
57
69
|
* It's handled internally by HashTreeParser and results in MEETING_ENDED being sent up.
|
|
@@ -64,11 +76,24 @@ var MeetingEndedError = exports.MeetingEndedError = /*#__PURE__*/function (_Erro
|
|
|
64
76
|
(0, _inherits2.default)(MeetingEndedError, _Error);
|
|
65
77
|
return (0, _createClass2.default)(MeetingEndedError);
|
|
66
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));
|
|
67
92
|
/* Currently Locus always sends Metadata objects only in the "self" dataset.
|
|
68
93
|
* If this ever changes, update all the code that relies on this constant.
|
|
69
94
|
*/
|
|
70
|
-
var MetadataDataSetName =
|
|
71
|
-
var PossibleSentinelMessageDataSetNames = [
|
|
95
|
+
var MetadataDataSetName = _constants3.DataSetNames.SELF;
|
|
96
|
+
var PossibleSentinelMessageDataSetNames = [_constants3.DataSetNames.MAIN, _constants3.DataSetNames.SELF, _constants3.DataSetNames.UNJOINED];
|
|
72
97
|
|
|
73
98
|
/**
|
|
74
99
|
* Parses hash tree eventing locus data
|
|
@@ -86,19 +111,32 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
86
111
|
(0, _defineProperty2.default)(this, "visibleDataSetsUrl", void 0);
|
|
87
112
|
// url from which we can get info about all data sets
|
|
88
113
|
(0, _defineProperty2.default)(this, "webexRequest", void 0);
|
|
89
|
-
(0, _defineProperty2.default)(this, "
|
|
114
|
+
(0, _defineProperty2.default)(this, "callbacks", void 0);
|
|
115
|
+
(0, _defineProperty2.default)(this, "syncLatencyMeetingId", void 0);
|
|
90
116
|
(0, _defineProperty2.default)(this, "visibleDataSets", void 0);
|
|
91
117
|
(0, _defineProperty2.default)(this, "debugId", void 0);
|
|
92
|
-
(0, _defineProperty2.default)(this, "heartbeatIntervalMs", void 0);
|
|
93
118
|
(0, _defineProperty2.default)(this, "excludedDataSets", void 0);
|
|
94
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);
|
|
129
|
+
// LLM data sets that were received while LLM was not expected, so their heartbeat watchdog was
|
|
130
|
+
// skipped; reevaluateLlmWatchdogs() arms these once LLM becomes expected and then clears this set
|
|
131
|
+
(0, _defineProperty2.default)(this, "pendingLlmWatchdogDataSetNames", new _set.default());
|
|
95
132
|
var _options$initialLocus = options.initialLocus,
|
|
96
133
|
dataSets = _options$initialLocus.dataSets,
|
|
97
134
|
locus = _options$initialLocus.locus; // extract dataSets from initialLocus
|
|
98
135
|
|
|
99
136
|
this.debugId = options.debugId;
|
|
100
137
|
this.webexRequest = options.webexRequest;
|
|
101
|
-
this.
|
|
138
|
+
this.callbacks = options.callbacks;
|
|
139
|
+
this.syncLatencyMeetingId = options.syncLatencyMeetingId;
|
|
102
140
|
this.excludedDataSets = options.excludedDataSets || [];
|
|
103
141
|
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;
|
|
104
142
|
this.setVisibleDataSets(((_options$metadata = options.metadata) === null || _options$metadata === void 0 ? void 0 : _options$metadata.visibleDataSets) || [], dataSets);
|
|
@@ -212,83 +250,65 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
212
250
|
*/
|
|
213
251
|
}, {
|
|
214
252
|
key: "initializeNewVisibleDataSet",
|
|
215
|
-
value: function
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
return
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
_loggerProxy.default.logger.warn("HashTreeParser#sendInitializationSyncRequestToLocus --> ".concat(this.debugId, " No data set found for ").concat(datasetName, ", cannot send the request for leaf data"));
|
|
251
|
-
return _promise.default.resolve({
|
|
252
|
-
updateType: LocusInfoUpdateType.OBJECTS_UPDATED,
|
|
253
|
-
updatedObjects: []
|
|
254
|
-
});
|
|
253
|
+
value: (function () {
|
|
254
|
+
var _initializeNewVisibleDataSet = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(visibleDataSetInfo, dataSetInfo) {
|
|
255
|
+
var hashTree;
|
|
256
|
+
return _regenerator.default.wrap(function (_context) {
|
|
257
|
+
while (1) switch (_context.prev = _context.next) {
|
|
258
|
+
case 0:
|
|
259
|
+
if (!this.isVisibleDataSet(dataSetInfo.name)) {
|
|
260
|
+
_context.next = 1;
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
_loggerProxy.default.logger.info("HashTreeParser#initializeNewVisibleDataSet --> ".concat(this.debugId, " Data set \"").concat(dataSetInfo.name, "\" already exists, skipping init"));
|
|
264
|
+
return _context.abrupt("return");
|
|
265
|
+
case 1:
|
|
266
|
+
_loggerProxy.default.logger.info("HashTreeParser#initializeNewVisibleDataSet --> ".concat(this.debugId, " Adding visible data set \"").concat(dataSetInfo.name, "\""));
|
|
267
|
+
if (this.addToVisibleDataSetsList(visibleDataSetInfo)) {
|
|
268
|
+
_context.next = 2;
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
return _context.abrupt("return");
|
|
272
|
+
case 2:
|
|
273
|
+
hashTree = new _hashTree.default([], dataSetInfo.leafCount);
|
|
274
|
+
this.dataSets[dataSetInfo.name] = _objectSpread(_objectSpread({}, dataSetInfo), {}, {
|
|
275
|
+
hashTree: hashTree
|
|
276
|
+
});
|
|
277
|
+
this.enqueueSyncForDataset(dataSetInfo.name, 'new visible data set initialization', true);
|
|
278
|
+
_context.next = 3;
|
|
279
|
+
return this.syncQueueProcessingPromise;
|
|
280
|
+
case 3:
|
|
281
|
+
case "end":
|
|
282
|
+
return _context.stop();
|
|
283
|
+
}
|
|
284
|
+
}, _callee, this);
|
|
285
|
+
}));
|
|
286
|
+
function initializeNewVisibleDataSet(_x, _x2) {
|
|
287
|
+
return _initializeNewVisibleDataSet.apply(this, arguments);
|
|
255
288
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
return this.sendSyncRequestToLocus(this.dataSets[datasetName], emptyLeavesData).then(function (syncResponse) {
|
|
259
|
-
if (syncResponse) {
|
|
260
|
-
return {
|
|
261
|
-
updateType: LocusInfoUpdateType.OBJECTS_UPDATED,
|
|
262
|
-
updatedObjects: _this2.parseMessage(syncResponse, "via empty leaves /sync API call for ".concat(debugText))
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
return {
|
|
266
|
-
updateType: LocusInfoUpdateType.OBJECTS_UPDATED,
|
|
267
|
-
updatedObjects: []
|
|
268
|
-
};
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
|
|
289
|
+
return initializeNewVisibleDataSet;
|
|
290
|
+
}()
|
|
272
291
|
/**
|
|
273
292
|
* Queries Locus for all up-to-date information about all visible data sets
|
|
274
293
|
*
|
|
275
294
|
* @returns {Promise}
|
|
276
295
|
*/
|
|
296
|
+
)
|
|
277
297
|
}, {
|
|
278
298
|
key: "getAllVisibleDataSetsFromLocus",
|
|
279
299
|
value: function getAllVisibleDataSetsFromLocus() {
|
|
280
|
-
var
|
|
300
|
+
var _this2 = this;
|
|
281
301
|
if (!this.visibleDataSetsUrl) {
|
|
282
302
|
_loggerProxy.default.logger.warn("HashTreeParser#getAllVisibleDataSetsFromLocus --> ".concat(this.debugId, " No visibleDataSetsUrl, cannot get data sets information"));
|
|
283
303
|
return _promise.default.resolve([]);
|
|
284
304
|
}
|
|
285
305
|
return this.webexRequest({
|
|
286
|
-
method:
|
|
306
|
+
method: _constants2.HTTP_VERBS.GET,
|
|
287
307
|
uri: this.visibleDataSetsUrl
|
|
288
308
|
}).then(function (response) {
|
|
289
309
|
return response.body.dataSets;
|
|
290
310
|
}).catch(function (error) {
|
|
291
|
-
|
|
311
|
+
_this2.checkForSentinelHttpResponse(error);
|
|
292
312
|
throw error;
|
|
293
313
|
});
|
|
294
314
|
}
|
|
@@ -302,26 +322,26 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
302
322
|
}, {
|
|
303
323
|
key: "initializeFromMessage",
|
|
304
324
|
value: (function () {
|
|
305
|
-
var _initializeFromMessage = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
325
|
+
var _initializeFromMessage = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2(message) {
|
|
306
326
|
var visibleDataSets;
|
|
307
|
-
return _regenerator.default.wrap(function (
|
|
308
|
-
while (1) switch (
|
|
327
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
328
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
309
329
|
case 0:
|
|
310
330
|
this.visibleDataSetsUrl = message.visibleDataSetsUrl;
|
|
311
331
|
_loggerProxy.default.logger.info("HashTreeParser#initializeFromMessage --> ".concat(this.debugId, " visibleDataSetsUrl=").concat(this.visibleDataSetsUrl));
|
|
312
|
-
|
|
332
|
+
_context2.next = 1;
|
|
313
333
|
return this.getAllVisibleDataSetsFromLocus();
|
|
314
334
|
case 1:
|
|
315
|
-
visibleDataSets =
|
|
316
|
-
|
|
335
|
+
visibleDataSets = _context2.sent;
|
|
336
|
+
_context2.next = 2;
|
|
317
337
|
return this.initializeDataSets(visibleDataSets, 'initialization from message');
|
|
318
338
|
case 2:
|
|
319
339
|
case "end":
|
|
320
|
-
return
|
|
340
|
+
return _context2.stop();
|
|
321
341
|
}
|
|
322
|
-
},
|
|
342
|
+
}, _callee2, this);
|
|
323
343
|
}));
|
|
324
|
-
function initializeFromMessage(
|
|
344
|
+
function initializeFromMessage(_x3) {
|
|
325
345
|
return _initializeFromMessage.apply(this, arguments);
|
|
326
346
|
}
|
|
327
347
|
return initializeFromMessage;
|
|
@@ -339,34 +359,34 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
339
359
|
}, {
|
|
340
360
|
key: "initializeFromGetLociResponse",
|
|
341
361
|
value: (function () {
|
|
342
|
-
var _initializeFromGetLociResponse = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
362
|
+
var _initializeFromGetLociResponse = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3(locus) {
|
|
343
363
|
var _locus$links2, _locus$links2$resourc, _locus$links2$resourc2;
|
|
344
364
|
var visibleDataSets;
|
|
345
|
-
return _regenerator.default.wrap(function (
|
|
346
|
-
while (1) switch (
|
|
365
|
+
return _regenerator.default.wrap(function (_context3) {
|
|
366
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
347
367
|
case 0:
|
|
348
368
|
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) {
|
|
349
|
-
|
|
369
|
+
_context3.next = 1;
|
|
350
370
|
break;
|
|
351
371
|
}
|
|
352
372
|
_loggerProxy.default.logger.warn("HashTreeParser#initializeFromGetLociResponse --> ".concat(this.debugId, " missing visibleDataSets url in GET Loci response, cannot initialize hash trees"));
|
|
353
|
-
return
|
|
373
|
+
return _context3.abrupt("return");
|
|
354
374
|
case 1:
|
|
355
375
|
this.visibleDataSetsUrl = locus.links.resources.visibleDataSets.url;
|
|
356
376
|
_loggerProxy.default.logger.info("HashTreeParser#initializeFromGetLociResponse --> ".concat(this.debugId, " visibleDataSets url: ").concat(this.visibleDataSetsUrl));
|
|
357
|
-
|
|
377
|
+
_context3.next = 2;
|
|
358
378
|
return this.getAllVisibleDataSetsFromLocus();
|
|
359
379
|
case 2:
|
|
360
|
-
visibleDataSets =
|
|
361
|
-
|
|
380
|
+
visibleDataSets = _context3.sent;
|
|
381
|
+
_context3.next = 3;
|
|
362
382
|
return this.initializeDataSets(visibleDataSets, 'initialization from GET /loci response');
|
|
363
383
|
case 3:
|
|
364
384
|
case "end":
|
|
365
|
-
return
|
|
385
|
+
return _context3.stop();
|
|
366
386
|
}
|
|
367
|
-
},
|
|
387
|
+
}, _callee3, this);
|
|
368
388
|
}));
|
|
369
|
-
function initializeFromGetLociResponse(
|
|
389
|
+
function initializeFromGetLociResponse(_x4) {
|
|
370
390
|
return _initializeFromGetLociResponse.apply(this, arguments);
|
|
371
391
|
}
|
|
372
392
|
return initializeFromGetLociResponse;
|
|
@@ -382,24 +402,23 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
382
402
|
}, {
|
|
383
403
|
key: "initializeDataSets",
|
|
384
404
|
value: (function () {
|
|
385
|
-
var _initializeDataSets = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
386
|
-
var
|
|
387
|
-
return _regenerator.default.wrap(function (
|
|
388
|
-
while (1) switch (
|
|
405
|
+
var _initializeDataSets = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4(visibleDataSets, debugText) {
|
|
406
|
+
var _iterator2, _step2, dataSet, name, leafCount, url, _t;
|
|
407
|
+
return _regenerator.default.wrap(function (_context4) {
|
|
408
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
389
409
|
case 0:
|
|
390
410
|
if (!(this.state === 'stopped')) {
|
|
391
|
-
|
|
411
|
+
_context4.next = 1;
|
|
392
412
|
break;
|
|
393
413
|
}
|
|
394
|
-
return
|
|
414
|
+
return _context4.abrupt("return");
|
|
395
415
|
case 1:
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
_context3.prev = 2;
|
|
416
|
+
_iterator2 = _createForOfIteratorHelper((0, _utils.sortByInitPriority)(visibleDataSets, _constants3.DATA_SET_INIT_PRIORITY));
|
|
417
|
+
_context4.prev = 2;
|
|
399
418
|
_iterator2.s();
|
|
400
419
|
case 3:
|
|
401
420
|
if ((_step2 = _iterator2.n()).done) {
|
|
402
|
-
|
|
421
|
+
_context4.next = 6;
|
|
403
422
|
break;
|
|
404
423
|
}
|
|
405
424
|
dataSet = _step2.value;
|
|
@@ -411,59 +430,47 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
411
430
|
_loggerProxy.default.logger.info("HashTreeParser#initializeDataSets --> ".concat(this.debugId, " dataset \"").concat(name, "\" already exists (").concat(debugText, ")"));
|
|
412
431
|
}
|
|
413
432
|
if (this.isVisibleDataSet(name)) {
|
|
414
|
-
|
|
433
|
+
_context4.next = 4;
|
|
415
434
|
break;
|
|
416
435
|
}
|
|
417
436
|
if (this.addToVisibleDataSetsList({
|
|
418
437
|
name: name,
|
|
419
438
|
url: url
|
|
420
439
|
})) {
|
|
421
|
-
|
|
440
|
+
_context4.next = 4;
|
|
422
441
|
break;
|
|
423
442
|
}
|
|
424
|
-
return
|
|
443
|
+
return _context4.abrupt("continue", 5);
|
|
425
444
|
case 4:
|
|
426
|
-
if (this.dataSets[name].hashTree) {
|
|
427
|
-
|
|
428
|
-
|
|
445
|
+
if (!this.dataSets[name].hashTree) {
|
|
446
|
+
_loggerProxy.default.logger.info("HashTreeParser#initializeDataSets --> ".concat(this.debugId, " creating hash tree for visible dataset \"").concat(name, "\" (").concat(debugText, ")"));
|
|
447
|
+
this.dataSets[name].hashTree = new _hashTree.default([], leafCount);
|
|
448
|
+
this.enqueueSyncForDataset(name, "initialization sync for ".concat(debugText), true);
|
|
429
449
|
}
|
|
430
|
-
_loggerProxy.default.logger.info("HashTreeParser#initializeDataSets --> ".concat(this.debugId, " creating hash tree for visible dataset \"").concat(name, "\" (").concat(debugText, ")"));
|
|
431
|
-
this.dataSets[name].hashTree = new _hashTree.default([], leafCount);
|
|
432
|
-
|
|
433
|
-
// eslint-disable-next-line no-await-in-loop
|
|
434
|
-
_context3.next = 5;
|
|
435
|
-
return this.sendInitializationSyncRequestToLocus(name, debugText);
|
|
436
450
|
case 5:
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
updatedObjects.push.apply(updatedObjects, (0, _toConsumableArray2.default)(data.updatedObjects || []));
|
|
440
|
-
}
|
|
451
|
+
_context4.next = 3;
|
|
452
|
+
break;
|
|
441
453
|
case 6:
|
|
442
|
-
|
|
454
|
+
_context4.next = 8;
|
|
443
455
|
break;
|
|
444
456
|
case 7:
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
case 8:
|
|
448
|
-
_context3.prev = 8;
|
|
449
|
-
_t = _context3["catch"](2);
|
|
457
|
+
_context4.prev = 7;
|
|
458
|
+
_t = _context4["catch"](2);
|
|
450
459
|
_iterator2.e(_t);
|
|
451
|
-
case
|
|
452
|
-
|
|
460
|
+
case 8:
|
|
461
|
+
_context4.prev = 8;
|
|
453
462
|
_iterator2.f();
|
|
454
|
-
return
|
|
463
|
+
return _context4.finish(8);
|
|
464
|
+
case 9:
|
|
465
|
+
_context4.next = 10;
|
|
466
|
+
return this.syncQueueProcessingPromise;
|
|
455
467
|
case 10:
|
|
456
|
-
this.callLocusInfoUpdateCallback({
|
|
457
|
-
updateType: LocusInfoUpdateType.OBJECTS_UPDATED,
|
|
458
|
-
updatedObjects: updatedObjects
|
|
459
|
-
});
|
|
460
|
-
case 11:
|
|
461
468
|
case "end":
|
|
462
|
-
return
|
|
469
|
+
return _context4.stop();
|
|
463
470
|
}
|
|
464
|
-
},
|
|
471
|
+
}, _callee4, this, [[2, 7, 8, 9]]);
|
|
465
472
|
}));
|
|
466
|
-
function initializeDataSets(
|
|
473
|
+
function initializeDataSets(_x5, _x6) {
|
|
467
474
|
return _initializeDataSets.apply(this, arguments);
|
|
468
475
|
}
|
|
469
476
|
return initializeDataSets;
|
|
@@ -599,9 +606,9 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
599
606
|
}, {
|
|
600
607
|
key: "isEndMessage",
|
|
601
608
|
value: function isEndMessage(message) {
|
|
602
|
-
var
|
|
609
|
+
var _this3 = this;
|
|
603
610
|
return message.dataSets.some(function (dataSet) {
|
|
604
|
-
if (dataSet.leafCount === 1 && dataSet.root ===
|
|
611
|
+
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())) {
|
|
605
612
|
// this is a special way for Locus to indicate that this meeting has ended
|
|
606
613
|
return true;
|
|
607
614
|
}
|
|
@@ -618,7 +625,7 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
618
625
|
}, {
|
|
619
626
|
key: "handleRootHashHeartBeatMessage",
|
|
620
627
|
value: function handleRootHashHeartBeatMessage(message) {
|
|
621
|
-
var
|
|
628
|
+
var _this4 = this;
|
|
622
629
|
var dataSets = message.dataSets;
|
|
623
630
|
_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) {
|
|
624
631
|
var name = _ref2.name,
|
|
@@ -632,12 +639,40 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
632
639
|
version: version
|
|
633
640
|
};
|
|
634
641
|
}))));
|
|
642
|
+
this.cancelPendingSyncsForDataSets(dataSets.map(function (ds) {
|
|
643
|
+
return ds.name;
|
|
644
|
+
}));
|
|
635
645
|
dataSets.forEach(function (dataSet) {
|
|
636
|
-
|
|
637
|
-
|
|
646
|
+
_this4.updateDataSetInfo(dataSet);
|
|
647
|
+
_this4.runSyncAlgorithm(dataSet);
|
|
638
648
|
});
|
|
639
649
|
}
|
|
640
650
|
|
|
651
|
+
/**
|
|
652
|
+
* Handles known errors that can happen during syncs
|
|
653
|
+
*
|
|
654
|
+
* @param {any} error - The error to handle
|
|
655
|
+
* @returns {boolean} true if the error was recognized and handled, false otherwise
|
|
656
|
+
*/
|
|
657
|
+
}, {
|
|
658
|
+
key: "handleSyncErrors",
|
|
659
|
+
value: function handleSyncErrors(error) {
|
|
660
|
+
if (error instanceof MeetingEndedError) {
|
|
661
|
+
this.callLocusInfoUpdateCallback({
|
|
662
|
+
updateType: LocusInfoUpdateType.MEETING_ENDED
|
|
663
|
+
});
|
|
664
|
+
return true;
|
|
665
|
+
}
|
|
666
|
+
if (error instanceof LocusNotFoundError) {
|
|
667
|
+
this.callLocusInfoUpdateCallback({
|
|
668
|
+
updateType: LocusInfoUpdateType.LOCUS_NOT_FOUND
|
|
669
|
+
});
|
|
670
|
+
this.stop();
|
|
671
|
+
return true;
|
|
672
|
+
}
|
|
673
|
+
return false;
|
|
674
|
+
}
|
|
675
|
+
|
|
641
676
|
/**
|
|
642
677
|
* Asynchronously initializes new visible data sets
|
|
643
678
|
*
|
|
@@ -647,18 +682,14 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
647
682
|
}, {
|
|
648
683
|
key: "queueInitForNewVisibleDataSets",
|
|
649
684
|
value: function queueInitForNewVisibleDataSets(dataSetsRequiringInitialization) {
|
|
650
|
-
var
|
|
685
|
+
var _this5 = this;
|
|
651
686
|
_loggerProxy.default.logger.info("HashTreeParser#queueInitForNewVisibleDataSets --> ".concat(this.debugId, " queuing initialization of new visible datasets: ").concat(dataSetsRequiringInitialization.map(function (ds) {
|
|
652
687
|
return ds.name;
|
|
653
688
|
}).join(', ')));
|
|
654
689
|
queueMicrotask(function () {
|
|
655
|
-
|
|
656
|
-
if (error
|
|
657
|
-
|
|
658
|
-
updateType: LocusInfoUpdateType.MEETING_ENDED
|
|
659
|
-
});
|
|
660
|
-
} else {
|
|
661
|
-
_loggerProxy.default.logger.warn("HashTreeParser#queueInitForNewVisibleDataSets --> ".concat(_this6.debugId, " error while initializing new visible datasets: ").concat(dataSetsRequiringInitialization.map(function (ds) {
|
|
690
|
+
_this5.initializeNewVisibleDataSets(dataSetsRequiringInitialization).catch(function (error) {
|
|
691
|
+
if (!_this5.handleSyncErrors(error)) {
|
|
692
|
+
_loggerProxy.default.logger.warn("HashTreeParser#queueInitForNewVisibleDataSets --> ".concat(_this5.debugId, " error while initializing new visible datasets: ").concat(dataSetsRequiringInitialization.map(function (ds) {
|
|
662
693
|
return ds.name;
|
|
663
694
|
}).join(', '), ": "), error);
|
|
664
695
|
}
|
|
@@ -718,14 +749,18 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
718
749
|
}, {
|
|
719
750
|
key: "handleLocusUpdate",
|
|
720
751
|
value: function handleLocusUpdate(update) {
|
|
721
|
-
var
|
|
752
|
+
var _this6 = this;
|
|
722
753
|
if (this.state === 'stopped') {
|
|
723
754
|
return;
|
|
724
755
|
}
|
|
725
756
|
var dataSets = update.dataSets,
|
|
726
757
|
locus = update.locus,
|
|
727
758
|
metadata = update.metadata;
|
|
759
|
+
_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) {
|
|
760
|
+
return ds.name;
|
|
761
|
+
}).join(','), " metadata=").concat(metadata ? 'yes' : 'no'));
|
|
728
762
|
if (!dataSets) {
|
|
763
|
+
// this happens for example when we handle GET /loci response
|
|
729
764
|
_loggerProxy.default.logger.info("HashTreeParser#handleLocusUpdate --> ".concat(this.debugId, " received hash tree update without dataSets"));
|
|
730
765
|
} else {
|
|
731
766
|
var _iterator5 = _createForOfIteratorHelper(dataSets),
|
|
@@ -755,9 +790,9 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
755
790
|
|
|
756
791
|
// then process the data in hash trees, if it is a new version, then add it to updatedObjects
|
|
757
792
|
(0, _keys.default)(leafInfo).forEach(function (dataSetName) {
|
|
758
|
-
if (
|
|
759
|
-
if (
|
|
760
|
-
var appliedChangesList =
|
|
793
|
+
if (_this6.dataSets[dataSetName]) {
|
|
794
|
+
if (_this6.dataSets[dataSetName].hashTree) {
|
|
795
|
+
var appliedChangesList = _this6.dataSets[dataSetName].hashTree.putItems(leafInfo[dataSetName].map(function (leaf) {
|
|
761
796
|
return {
|
|
762
797
|
id: leaf.id,
|
|
763
798
|
type: leaf.type,
|
|
@@ -784,10 +819,10 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
784
819
|
});
|
|
785
820
|
} else {
|
|
786
821
|
// no hash tree means that the data set is not visible
|
|
787
|
-
_loggerProxy.default.logger.warn("HashTreeParser#handleLocusUpdate --> ".concat(
|
|
822
|
+
_loggerProxy.default.logger.warn("HashTreeParser#handleLocusUpdate --> ".concat(_this6.debugId, " received leaf data for data set \"").concat(dataSetName, "\" that has no hash tree created, ignoring"));
|
|
788
823
|
}
|
|
789
824
|
} else {
|
|
790
|
-
_loggerProxy.default.logger.info("HashTreeParser#handleLocusUpdate --> ".concat(
|
|
825
|
+
_loggerProxy.default.logger.info("HashTreeParser#handleLocusUpdate --> ".concat(_this6.debugId, " received leaf data for unknown data set \"").concat(dataSetName, "\", ignoring"));
|
|
791
826
|
}
|
|
792
827
|
});
|
|
793
828
|
if (updatedObjects.length === 0) {
|
|
@@ -823,10 +858,26 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
823
858
|
maxMs: receivedDataSet.backoff.maxMs,
|
|
824
859
|
exponent: receivedDataSet.backoff.exponent
|
|
825
860
|
};
|
|
861
|
+
this.dataSets[receivedDataSet.name].heartbeatIntervalMs = receivedDataSet.heartbeatIntervalMs;
|
|
826
862
|
_loggerProxy.default.logger.info("HashTreeParser#updateDataSetInfo --> ".concat(this.debugId, " updated \"").concat(receivedDataSet.name, "\" dataset to version=").concat(receivedDataSet.version, ", root=").concat(receivedDataSet.root));
|
|
827
863
|
}
|
|
828
864
|
}
|
|
829
865
|
|
|
866
|
+
/**
|
|
867
|
+
* Updates the leaf count for a data set, resizing its hash tree accordingly.
|
|
868
|
+
*
|
|
869
|
+
* @param {InternalDataSet} dataSet - The data set to update
|
|
870
|
+
* @param {number} newLeafCount - The new leaf count
|
|
871
|
+
* @returns {void}
|
|
872
|
+
*/
|
|
873
|
+
}, {
|
|
874
|
+
key: "updateDataSetLeafCount",
|
|
875
|
+
value: function updateDataSetLeafCount(dataSet, newLeafCount) {
|
|
876
|
+
var _dataSet$hashTree;
|
|
877
|
+
(_dataSet$hashTree = dataSet.hashTree) === null || _dataSet$hashTree === void 0 ? void 0 : _dataSet$hashTree.resize(newLeafCount);
|
|
878
|
+
dataSet.leafCount = newLeafCount;
|
|
879
|
+
}
|
|
880
|
+
|
|
830
881
|
/**
|
|
831
882
|
* Checks for changes in the visible data sets based on the updated objects.
|
|
832
883
|
* @param {HashTreeObject[]} updatedObjects - The list of updated hash tree objects.
|
|
@@ -835,7 +886,7 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
835
886
|
}, {
|
|
836
887
|
key: "checkForVisibleDataSetChanges",
|
|
837
888
|
value: function checkForVisibleDataSetChanges(updatedObjects) {
|
|
838
|
-
var
|
|
889
|
+
var _this7 = this;
|
|
839
890
|
var removedDataSets = [];
|
|
840
891
|
var addedDataSets = [];
|
|
841
892
|
|
|
@@ -844,20 +895,20 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
844
895
|
var _object$data;
|
|
845
896
|
if ((0, _utils.isMetadata)(object) && (_object$data = object.data) !== null && _object$data !== void 0 && _object$data.visibleDataSets) {
|
|
846
897
|
var newVisibleDataSets = object.data.visibleDataSets.filter(function (vds) {
|
|
847
|
-
return !
|
|
898
|
+
return !_this7.isExcludedDataSet(vds.name);
|
|
848
899
|
});
|
|
849
|
-
removedDataSets =
|
|
900
|
+
removedDataSets = _this7.visibleDataSets.filter(function (ds) {
|
|
850
901
|
return !newVisibleDataSets.some(function (nvs) {
|
|
851
902
|
return nvs.name === ds.name;
|
|
852
903
|
});
|
|
853
904
|
});
|
|
854
905
|
addedDataSets = newVisibleDataSets.filter(function (nvs) {
|
|
855
|
-
return
|
|
906
|
+
return _this7.visibleDataSets.every(function (ds) {
|
|
856
907
|
return ds.name !== nvs.name;
|
|
857
908
|
});
|
|
858
909
|
});
|
|
859
910
|
if (removedDataSets.length > 0 || addedDataSets.length > 0) {
|
|
860
|
-
_loggerProxy.default.logger.info("HashTreeParser#checkForVisibleDataSetChanges --> ".concat(
|
|
911
|
+
_loggerProxy.default.logger.info("HashTreeParser#checkForVisibleDataSetChanges --> ".concat(_this7.debugId, " visible data sets change: removed: ").concat(removedDataSets.map(function (ds) {
|
|
861
912
|
return ds.name;
|
|
862
913
|
}).join(', '), ", added: ").concat(addedDataSets.map(function (ds) {
|
|
863
914
|
return ds.name;
|
|
@@ -881,7 +932,10 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
881
932
|
}, {
|
|
882
933
|
key: "deleteHashTree",
|
|
883
934
|
value: function deleteHashTree(dataSetName) {
|
|
935
|
+
var _this$dataSets$dataSe;
|
|
884
936
|
this.dataSets[dataSetName].hashTree = undefined;
|
|
937
|
+
(_this$dataSets$dataSe = this.dataSets[dataSetName].syncAbortController) === null || _this$dataSets$dataSe === void 0 ? void 0 : _this$dataSets$dataSe.abort();
|
|
938
|
+
this.dataSets[dataSetName].syncAbortController = undefined;
|
|
885
939
|
|
|
886
940
|
// we also need to stop the timers as there is no hash tree anymore to sync
|
|
887
941
|
if (this.dataSets[dataSetName].timer) {
|
|
@@ -911,16 +965,16 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
911
965
|
}, {
|
|
912
966
|
key: "processVisibleDataSetChanges",
|
|
913
967
|
value: function processVisibleDataSetChanges(removedDataSets, addedDataSets, updatedObjects) {
|
|
914
|
-
var
|
|
968
|
+
var _this8 = this;
|
|
915
969
|
var dataSetsRequiringInitialization = [];
|
|
916
970
|
|
|
917
971
|
// if a visible data set was removed, we need to tell our client that all objects from it are removed
|
|
918
972
|
var removedObjects = [];
|
|
919
973
|
removedDataSets.forEach(function (ds) {
|
|
920
|
-
var
|
|
921
|
-
if ((
|
|
922
|
-
for (var i = 0; i <
|
|
923
|
-
removedObjects.push.apply(removedObjects, (0, _toConsumableArray2.default)(
|
|
974
|
+
var _this8$dataSets$ds$na;
|
|
975
|
+
if ((_this8$dataSets$ds$na = _this8.dataSets[ds.name]) !== null && _this8$dataSets$ds$na !== void 0 && _this8$dataSets$ds$na.hashTree) {
|
|
976
|
+
for (var i = 0; i < _this8.dataSets[ds.name].hashTree.numLeaves; i += 1) {
|
|
977
|
+
removedObjects.push.apply(removedObjects, (0, _toConsumableArray2.default)(_this8.dataSets[ds.name].hashTree.getLeafData(i).map(function (elementId) {
|
|
924
978
|
return {
|
|
925
979
|
htMeta: {
|
|
926
980
|
elementId: elementId,
|
|
@@ -930,7 +984,7 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
930
984
|
};
|
|
931
985
|
})));
|
|
932
986
|
}
|
|
933
|
-
|
|
987
|
+
_this8.deleteHashTree(ds.name);
|
|
934
988
|
}
|
|
935
989
|
});
|
|
936
990
|
this.visibleDataSets = this.visibleDataSets.filter(function (vds) {
|
|
@@ -991,81 +1045,78 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
991
1045
|
}, {
|
|
992
1046
|
key: "initializeNewVisibleDataSets",
|
|
993
1047
|
value: (function () {
|
|
994
|
-
var _initializeNewVisibleDataSets = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
995
|
-
var
|
|
1048
|
+
var _initializeNewVisibleDataSets = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5(addedDataSets) {
|
|
1049
|
+
var _this9 = this;
|
|
996
1050
|
var allDataSets, _iterator7, _step7, _loop, _t2;
|
|
997
|
-
return _regenerator.default.wrap(function (
|
|
998
|
-
while (1) switch (
|
|
1051
|
+
return _regenerator.default.wrap(function (_context6) {
|
|
1052
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
999
1053
|
case 0:
|
|
1000
1054
|
if (!(this.state === 'stopped')) {
|
|
1001
|
-
|
|
1055
|
+
_context6.next = 1;
|
|
1002
1056
|
break;
|
|
1003
1057
|
}
|
|
1004
|
-
return
|
|
1058
|
+
return _context6.abrupt("return");
|
|
1005
1059
|
case 1:
|
|
1006
|
-
|
|
1060
|
+
_context6.next = 2;
|
|
1007
1061
|
return this.getAllVisibleDataSetsFromLocus();
|
|
1008
1062
|
case 2:
|
|
1009
|
-
allDataSets =
|
|
1010
|
-
_iterator7 = _createForOfIteratorHelper((0, _utils.sortByInitPriority)(addedDataSets,
|
|
1011
|
-
|
|
1063
|
+
allDataSets = _context6.sent;
|
|
1064
|
+
_iterator7 = _createForOfIteratorHelper((0, _utils.sortByInitPriority)(addedDataSets, _constants3.DATA_SET_INIT_PRIORITY));
|
|
1065
|
+
_context6.prev = 3;
|
|
1012
1066
|
_loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
|
|
1013
|
-
var ds, dataSetInfo
|
|
1014
|
-
return _regenerator.default.wrap(function (
|
|
1015
|
-
while (1) switch (
|
|
1067
|
+
var ds, dataSetInfo;
|
|
1068
|
+
return _regenerator.default.wrap(function (_context5) {
|
|
1069
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
1016
1070
|
case 0:
|
|
1017
1071
|
ds = _step7.value;
|
|
1018
1072
|
dataSetInfo = allDataSets.find(function (d) {
|
|
1019
1073
|
return d.name === ds.name;
|
|
1020
1074
|
});
|
|
1021
|
-
_loggerProxy.default.logger.info("HashTreeParser#initializeNewVisibleDataSets --> ".concat(
|
|
1075
|
+
_loggerProxy.default.logger.info("HashTreeParser#initializeNewVisibleDataSets --> ".concat(_this9.debugId, " initializing data set \"").concat(ds.name, "\""));
|
|
1022
1076
|
if (dataSetInfo) {
|
|
1023
|
-
|
|
1077
|
+
_context5.next = 1;
|
|
1024
1078
|
break;
|
|
1025
1079
|
}
|
|
1026
|
-
_loggerProxy.default.logger.warn("HashTreeParser#initializeNewVisibleDataSets --> ".concat(
|
|
1027
|
-
|
|
1080
|
+
_loggerProxy.default.logger.warn("HashTreeParser#initializeNewVisibleDataSets --> ".concat(_this9.debugId, " missing info about data set \"").concat(ds.name, "\" in Locus response from visibleDataSetsUrl"));
|
|
1081
|
+
_context5.next = 2;
|
|
1028
1082
|
break;
|
|
1029
1083
|
case 1:
|
|
1030
|
-
|
|
1031
|
-
return
|
|
1084
|
+
_context5.next = 2;
|
|
1085
|
+
return _this9.initializeNewVisibleDataSet(ds, dataSetInfo);
|
|
1032
1086
|
case 2:
|
|
1033
|
-
updates = _context4.sent;
|
|
1034
|
-
_this0.callLocusInfoUpdateCallback(updates);
|
|
1035
|
-
case 3:
|
|
1036
1087
|
case "end":
|
|
1037
|
-
return
|
|
1088
|
+
return _context5.stop();
|
|
1038
1089
|
}
|
|
1039
1090
|
}, _loop);
|
|
1040
1091
|
});
|
|
1041
1092
|
_iterator7.s();
|
|
1042
1093
|
case 4:
|
|
1043
1094
|
if ((_step7 = _iterator7.n()).done) {
|
|
1044
|
-
|
|
1095
|
+
_context6.next = 6;
|
|
1045
1096
|
break;
|
|
1046
1097
|
}
|
|
1047
|
-
return
|
|
1098
|
+
return _context6.delegateYield(_loop(), "t0", 5);
|
|
1048
1099
|
case 5:
|
|
1049
|
-
|
|
1100
|
+
_context6.next = 4;
|
|
1050
1101
|
break;
|
|
1051
1102
|
case 6:
|
|
1052
|
-
|
|
1103
|
+
_context6.next = 8;
|
|
1053
1104
|
break;
|
|
1054
1105
|
case 7:
|
|
1055
|
-
|
|
1056
|
-
_t2 =
|
|
1106
|
+
_context6.prev = 7;
|
|
1107
|
+
_t2 = _context6["catch"](3);
|
|
1057
1108
|
_iterator7.e(_t2);
|
|
1058
1109
|
case 8:
|
|
1059
|
-
|
|
1110
|
+
_context6.prev = 8;
|
|
1060
1111
|
_iterator7.f();
|
|
1061
|
-
return
|
|
1112
|
+
return _context6.finish(8);
|
|
1062
1113
|
case 9:
|
|
1063
1114
|
case "end":
|
|
1064
|
-
return
|
|
1115
|
+
return _context6.stop();
|
|
1065
1116
|
}
|
|
1066
|
-
},
|
|
1117
|
+
}, _callee5, this, [[3, 7, 8, 9]]);
|
|
1067
1118
|
}));
|
|
1068
|
-
function initializeNewVisibleDataSets(
|
|
1119
|
+
function initializeNewVisibleDataSets(_x7) {
|
|
1069
1120
|
return _initializeNewVisibleDataSets.apply(this, arguments);
|
|
1070
1121
|
}
|
|
1071
1122
|
return initializeNewVisibleDataSets;
|
|
@@ -1081,24 +1132,37 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1081
1132
|
}, {
|
|
1082
1133
|
key: "parseMessage",
|
|
1083
1134
|
value: function parseMessage(message, debugText) {
|
|
1084
|
-
var _message$
|
|
1085
|
-
|
|
1135
|
+
var _message$dataSets,
|
|
1136
|
+
_message$locusStateEl,
|
|
1137
|
+
_message$locusStateEl2,
|
|
1138
|
+
_this0 = this;
|
|
1086
1139
|
if (this.state === 'stopped') {
|
|
1087
1140
|
return [];
|
|
1088
1141
|
}
|
|
1089
1142
|
var dataSets = message.dataSets,
|
|
1090
1143
|
visibleDataSetsUrl = message.visibleDataSetsUrl;
|
|
1091
|
-
_loggerProxy.default.logger.info("HashTreeParser#parseMessage --> ".concat(this.debugId, "
|
|
1092
|
-
|
|
1144
|
+
_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) {
|
|
1145
|
+
var name = _ref5.name,
|
|
1146
|
+
version = _ref5.version;
|
|
1147
|
+
return "".concat(name, ":").concat(version);
|
|
1148
|
+
}).join(','), ", elements: ").concat((_message$locusStateEl = message.locusStateElements) === null || _message$locusStateEl === void 0 ? void 0 : _message$locusStateEl.map(function (el) {
|
|
1149
|
+
return "".concat(el.htMeta.elementId.type, ":").concat(el.htMeta.elementId.id, ":").concat(el.htMeta.elementId.version).concat(el.data ? '+' : '-');
|
|
1150
|
+
}).join(',')));
|
|
1151
|
+
if (((_message$locusStateEl2 = message.locusStateElements) === null || _message$locusStateEl2 === void 0 ? void 0 : _message$locusStateEl2.length) === 0) {
|
|
1093
1152
|
_loggerProxy.default.logger.warn("HashTreeParser#parseMessage --> ".concat(this.debugId, " got empty locusStateElements!!!"));
|
|
1094
|
-
|
|
1153
|
+
_metrics.default.sendBehavioralMetric(_constants.default.HASH_TREE_EMPTY_LOCUS_STATE_ELEMENTS, {
|
|
1154
|
+
debugId: this.debugId
|
|
1155
|
+
});
|
|
1095
1156
|
}
|
|
1096
1157
|
|
|
1097
1158
|
// first, update our metadata about the datasets with info from the message
|
|
1098
1159
|
this.visibleDataSetsUrl = visibleDataSetsUrl;
|
|
1099
1160
|
dataSets.forEach(function (dataSet) {
|
|
1100
|
-
return
|
|
1161
|
+
return _this0.updateDataSetInfo(dataSet);
|
|
1101
1162
|
});
|
|
1163
|
+
this.cancelPendingSyncsForDataSets(dataSets.map(function (ds) {
|
|
1164
|
+
return ds.name;
|
|
1165
|
+
}));
|
|
1102
1166
|
var updatedObjects = [];
|
|
1103
1167
|
|
|
1104
1168
|
// when we detect new visible datasets, it may be that the metadata about them is not
|
|
@@ -1117,9 +1181,9 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1117
1181
|
_step8;
|
|
1118
1182
|
try {
|
|
1119
1183
|
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
1120
|
-
var
|
|
1184
|
+
var _this0$dataSets$dataS;
|
|
1121
1185
|
var dataSetName = _step8.value;
|
|
1122
|
-
var hashTree = (
|
|
1186
|
+
var hashTree = (_this0$dataSets$dataS = _this0.dataSets[dataSetName]) === null || _this0$dataSets$dataS === void 0 ? void 0 : _this0$dataSets$dataS.hashTree;
|
|
1123
1187
|
if (hashTree && object.data) {
|
|
1124
1188
|
if (hashTree.putItem(object.htMeta.elementId)) {
|
|
1125
1189
|
updatedMetadataObjects.push(object);
|
|
@@ -1146,8 +1210,8 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1146
1210
|
// and hash trees created for the new visible data sets,
|
|
1147
1211
|
// so we can now process all the updates from the message
|
|
1148
1212
|
dataSets.forEach(function (dataSet) {
|
|
1149
|
-
if (
|
|
1150
|
-
var hashTree =
|
|
1213
|
+
if (_this0.dataSets[dataSet.name]) {
|
|
1214
|
+
var hashTree = _this0.dataSets[dataSet.name].hashTree;
|
|
1151
1215
|
if (hashTree) {
|
|
1152
1216
|
var locusStateElementsForThisSet = message.locusStateElements.filter(function (object) {
|
|
1153
1217
|
return object.htMeta.dataSetNames.includes(dataSet.name);
|
|
@@ -1161,20 +1225,20 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1161
1225
|
item: object.htMeta.elementId
|
|
1162
1226
|
};
|
|
1163
1227
|
}));
|
|
1164
|
-
(0, _lodash.zip)(appliedChangesList, locusStateElementsForThisSet).forEach(function (
|
|
1165
|
-
var
|
|
1166
|
-
changeApplied =
|
|
1167
|
-
object =
|
|
1228
|
+
(0, _lodash.zip)(appliedChangesList, locusStateElementsForThisSet).forEach(function (_ref6) {
|
|
1229
|
+
var _ref7 = (0, _slicedToArray2.default)(_ref6, 2),
|
|
1230
|
+
changeApplied = _ref7[0],
|
|
1231
|
+
object = _ref7[1];
|
|
1168
1232
|
if (changeApplied) {
|
|
1169
1233
|
// add to updatedObjects so that our locus DTO will get updated with the new object
|
|
1170
1234
|
updatedObjects.push(object);
|
|
1171
1235
|
}
|
|
1172
1236
|
});
|
|
1173
1237
|
} else {
|
|
1174
|
-
_loggerProxy.default.logger.info("Locus-info:index#parseMessage --> ".concat(
|
|
1238
|
+
_loggerProxy.default.logger.info("Locus-info:index#parseMessage --> ".concat(_this0.debugId, " unexpected (not visible) dataSet ").concat(dataSet.name, " received in hash tree message"));
|
|
1175
1239
|
}
|
|
1176
1240
|
}
|
|
1177
|
-
|
|
1241
|
+
_this0.runSyncAlgorithm(dataSet);
|
|
1178
1242
|
});
|
|
1179
1243
|
}
|
|
1180
1244
|
if (dataSetsRequiringInitialization.length > 0) {
|
|
@@ -1200,8 +1264,8 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1200
1264
|
if (this.state === 'stopped') {
|
|
1201
1265
|
return;
|
|
1202
1266
|
}
|
|
1203
|
-
if (message.heartbeatIntervalMs) {
|
|
1204
|
-
this.
|
|
1267
|
+
if (message.heartbeatIntervalMs !== undefined) {
|
|
1268
|
+
this.topLevelHeartbeatIntervalMs = message.heartbeatIntervalMs;
|
|
1205
1269
|
}
|
|
1206
1270
|
if (this.isEndMessage(message)) {
|
|
1207
1271
|
_loggerProxy.default.logger.info("HashTreeParser#handleMessage --> ".concat(this.debugId, " received sentinel END MEETING message"));
|
|
@@ -1213,15 +1277,46 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1213
1277
|
this.handleRootHashHeartBeatMessage(message);
|
|
1214
1278
|
this.resetHeartbeatWatchdogs(message.dataSets);
|
|
1215
1279
|
} else {
|
|
1280
|
+
// Completion of the sync latency metric (client.locus.sync.complete) is driven solely from
|
|
1281
|
+
// Meeting#processLocusLLMEvent once the matching LLM message arrives. body-mode syncs return
|
|
1282
|
+
// the locus state elements in the /sync HTTP response body, but per design the CA metric is
|
|
1283
|
+
// emitted only from the LLM message path, so no completion happens here.
|
|
1216
1284
|
var updatedObjects = this.parseMessage(message, debugText);
|
|
1217
|
-
this.resetHeartbeatWatchdogs(message.dataSets);
|
|
1218
1285
|
this.callLocusInfoUpdateCallback({
|
|
1219
1286
|
updateType: LocusInfoUpdateType.OBJECTS_UPDATED,
|
|
1220
1287
|
updatedObjects: updatedObjects
|
|
1221
1288
|
});
|
|
1289
|
+
this.resetHeartbeatWatchdogs(message.dataSets);
|
|
1222
1290
|
}
|
|
1223
1291
|
}
|
|
1224
1292
|
|
|
1293
|
+
/**
|
|
1294
|
+
* Checks if Locus sync latency metrics should be collected for a dataset.
|
|
1295
|
+
*
|
|
1296
|
+
* @param {string} dataSetName dataset name
|
|
1297
|
+
* @param {boolean} [isInitialization=false] whether this is an initialization sync
|
|
1298
|
+
* @returns {boolean}
|
|
1299
|
+
*/
|
|
1300
|
+
}, {
|
|
1301
|
+
key: "shouldCollectSyncMetrics",
|
|
1302
|
+
value: function shouldCollectSyncMetrics(dataSetName) {
|
|
1303
|
+
var isInitialization = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1304
|
+
return Boolean(this.callbacks.syncLatencyTracker && !isInitialization && SYNC_METRICS_DATA_SETS.includes(dataSetName));
|
|
1305
|
+
}
|
|
1306
|
+
}, {
|
|
1307
|
+
key: "saveSyncBackoffLatency",
|
|
1308
|
+
value: function saveSyncBackoffLatency(dataSetName, randomBackoffTime) {
|
|
1309
|
+
var _this$callbacks$syncL;
|
|
1310
|
+
var isInitialization = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1311
|
+
if (!this.shouldCollectSyncMetrics(dataSetName, isInitialization)) {
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
(_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), {
|
|
1315
|
+
meetingId: this.syncLatencyMeetingId,
|
|
1316
|
+
dataSetName: dataSetName
|
|
1317
|
+
});
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1225
1320
|
/**
|
|
1226
1321
|
* Calls the updateInfo callback if there are any updates to report
|
|
1227
1322
|
*
|
|
@@ -1232,7 +1327,7 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1232
1327
|
key: "callLocusInfoUpdateCallback",
|
|
1233
1328
|
value: function callLocusInfoUpdateCallback(updates) {
|
|
1234
1329
|
var _updates$updatedObjec,
|
|
1235
|
-
|
|
1330
|
+
_this1 = this;
|
|
1236
1331
|
if (this.state === 'stopped') {
|
|
1237
1332
|
return;
|
|
1238
1333
|
}
|
|
@@ -1247,9 +1342,9 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1247
1342
|
version = elementId.version;
|
|
1248
1343
|
|
|
1249
1344
|
// Check all datasets
|
|
1250
|
-
for (var _i2 = 0, _Object$keys3 = (0, _keys.default)(
|
|
1345
|
+
for (var _i2 = 0, _Object$keys3 = (0, _keys.default)(_this1.dataSets); _i2 < _Object$keys3.length; _i2++) {
|
|
1251
1346
|
var dataSetName = _Object$keys3[_i2];
|
|
1252
|
-
var dataSet =
|
|
1347
|
+
var dataSet = _this1.dataSets[dataSetName];
|
|
1253
1348
|
|
|
1254
1349
|
// only visible datasets have hash trees set
|
|
1255
1350
|
if (dataSet !== null && dataSet !== void 0 && dataSet.hashTree) {
|
|
@@ -1258,12 +1353,12 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1258
1353
|
if (object.data) {
|
|
1259
1354
|
// For updates: filter out if any dataset has a higher version
|
|
1260
1355
|
if (existingVersion > version) {
|
|
1261
|
-
_loggerProxy.default.logger.info("HashTreeParser#callLocusInfoUpdateCallback --> ".concat(
|
|
1356
|
+
_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));
|
|
1262
1357
|
return false;
|
|
1263
1358
|
}
|
|
1264
1359
|
} else if (existingVersion >= version) {
|
|
1265
1360
|
// For removals: filter out if the object still exists in any dataset
|
|
1266
|
-
_loggerProxy.default.logger.info("HashTreeParser#callLocusInfoUpdateCallback --> ".concat(
|
|
1361
|
+
_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));
|
|
1267
1362
|
return false;
|
|
1268
1363
|
}
|
|
1269
1364
|
}
|
|
@@ -1272,13 +1367,13 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1272
1367
|
return true;
|
|
1273
1368
|
});
|
|
1274
1369
|
if (filteredUpdates.length > 0) {
|
|
1275
|
-
this.locusInfoUpdateCallback({
|
|
1370
|
+
this.callbacks.locusInfoUpdateCallback({
|
|
1276
1371
|
updateType: updateType,
|
|
1277
1372
|
updatedObjects: filteredUpdates
|
|
1278
1373
|
});
|
|
1279
1374
|
}
|
|
1280
1375
|
} else if (updateType !== LocusInfoUpdateType.OBJECTS_UPDATED) {
|
|
1281
|
-
this.locusInfoUpdateCallback({
|
|
1376
|
+
this.callbacks.locusInfoUpdateCallback({
|
|
1282
1377
|
updateType: updateType
|
|
1283
1378
|
});
|
|
1284
1379
|
}
|
|
@@ -1299,168 +1394,596 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1299
1394
|
return Math.round(Math.pow(randomValue, exponent) * maxMs);
|
|
1300
1395
|
}
|
|
1301
1396
|
|
|
1397
|
+
/**
|
|
1398
|
+
* Returns a copy of a hash tree message restricted to a single dataset, keeping only the
|
|
1399
|
+
* requested dataset and the elements belonging to it. Used to strip out datasets that Locus
|
|
1400
|
+
* may include in a sync response but that we didn't request (e.g. "unjoined" sharing elements
|
|
1401
|
+
* with "main"), which would otherwise be applied once per dataset.
|
|
1402
|
+
*
|
|
1403
|
+
* @param {HashTreeMessage} message the sync response message
|
|
1404
|
+
* @param {string} dataSetName the dataset that was requested
|
|
1405
|
+
* @returns {HashTreeMessage} a new message containing only the requested dataset
|
|
1406
|
+
*/
|
|
1407
|
+
}, {
|
|
1408
|
+
key: "filterMessageToDataSet",
|
|
1409
|
+
value: function filterMessageToDataSet(message, dataSetName) {
|
|
1410
|
+
var _message$dataSets$fil, _message$dataSets2, _message$locusStateEl3, _message$locusStateEl4, _message$dataSets3, _message$locusStateEl5;
|
|
1411
|
+
var filteredOutDataSets = (_message$dataSets$fil = (_message$dataSets2 = message.dataSets) === null || _message$dataSets2 === void 0 ? void 0 : _message$dataSets2.filter(function (ds) {
|
|
1412
|
+
return ds.name !== dataSetName;
|
|
1413
|
+
})) !== null && _message$dataSets$fil !== void 0 ? _message$dataSets$fil : [];
|
|
1414
|
+
var filteredOutElements = (_message$locusStateEl3 = (_message$locusStateEl4 = message.locusStateElements) === null || _message$locusStateEl4 === void 0 ? void 0 : _message$locusStateEl4.filter(function (el) {
|
|
1415
|
+
var _el$htMeta$dataSetNam;
|
|
1416
|
+
return !((_el$htMeta$dataSetNam = el.htMeta.dataSetNames) !== null && _el$htMeta$dataSetNam !== void 0 && _el$htMeta$dataSetNam.includes(dataSetName));
|
|
1417
|
+
})) !== null && _message$locusStateEl3 !== void 0 ? _message$locusStateEl3 : [];
|
|
1418
|
+
if (filteredOutDataSets.length > 0 || filteredOutElements.length > 0) {
|
|
1419
|
+
_loggerProxy.default.logger.info("HashTreeParser#filterMessageToDataSet --> ".concat(this.debugId, " keeping only dataset \"").concat(dataSetName, "\", filtering out datasets: [").concat(filteredOutDataSets.map(function (ds) {
|
|
1420
|
+
return "".concat(ds.name, ":").concat(ds.version);
|
|
1421
|
+
}).join(','), "], elements: [").concat(filteredOutElements.map(function (el) {
|
|
1422
|
+
var _el$htMeta, _el$htMeta$elementId, _el$htMeta2, _el$htMeta2$elementId, _el$htMeta3, _el$htMeta3$elementId;
|
|
1423
|
+
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);
|
|
1424
|
+
}).join(','), "]"));
|
|
1425
|
+
}
|
|
1426
|
+
return _objectSpread(_objectSpread({}, message), {}, {
|
|
1427
|
+
dataSets: (_message$dataSets3 = message.dataSets) === null || _message$dataSets3 === void 0 ? void 0 : _message$dataSets3.filter(function (ds) {
|
|
1428
|
+
return ds.name === dataSetName;
|
|
1429
|
+
}),
|
|
1430
|
+
locusStateElements: (_message$locusStateEl5 = message.locusStateElements) === null || _message$locusStateEl5 === void 0 ? void 0 : _message$locusStateEl5.filter(function (el) {
|
|
1431
|
+
var _el$htMeta$dataSetNam2;
|
|
1432
|
+
return (_el$htMeta$dataSetNam2 = el.htMeta.dataSetNames) === null || _el$htMeta$dataSetNam2 === void 0 ? void 0 : _el$htMeta$dataSetNam2.includes(dataSetName);
|
|
1433
|
+
})
|
|
1434
|
+
});
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1302
1437
|
/**
|
|
1303
1438
|
* Performs a sync for the given data set.
|
|
1304
1439
|
*
|
|
1305
1440
|
* @param {InternalDataSet} dataSet - The data set to sync
|
|
1306
|
-
* @param {string} rootHash - Our current root hash for this data set
|
|
1307
1441
|
* @param {string} reason - The reason for the sync (used for logging)
|
|
1442
|
+
* @param {boolean} [isInitialization] - Whether this is an initialization sync (sends empty leaves data instead of comparing hashes)
|
|
1308
1443
|
* @returns {Promise<void>}
|
|
1309
1444
|
*/
|
|
1310
1445
|
}, {
|
|
1311
1446
|
key: "performSync",
|
|
1312
1447
|
value: (function () {
|
|
1313
|
-
var _performSync = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1314
|
-
var
|
|
1315
|
-
|
|
1316
|
-
|
|
1448
|
+
var _performSync = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6(dataSet, reason, isInitialization) {
|
|
1449
|
+
var _dataSet$syncAbortCon, _this$callbacks$gener, _this$callbacks, _this$callbacks$gener2, _this$callbacks2;
|
|
1450
|
+
var abortController, hashTree, rootHash, shouldCollectMetrics, hashtreeTrackingId, syncTrackingId, syncRequestSent, _this$callbacks$syncL2, leavesData, receivedHashes, hashesResult, mismatchedLeaveIndexes, syncResponse, filteredResponse, _this$callbacks$syncL3, _t3, _t4;
|
|
1451
|
+
return _regenerator.default.wrap(function (_context7) {
|
|
1452
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
1317
1453
|
case 0:
|
|
1318
1454
|
if (dataSet.hashTree) {
|
|
1319
|
-
|
|
1455
|
+
_context7.next = 1;
|
|
1320
1456
|
break;
|
|
1321
1457
|
}
|
|
1322
|
-
return
|
|
1458
|
+
return _context7.abrupt("return");
|
|
1323
1459
|
case 1:
|
|
1324
|
-
|
|
1460
|
+
abortController = (_dataSet$syncAbortCon = dataSet.syncAbortController) !== null && _dataSet$syncAbortCon !== void 0 ? _dataSet$syncAbortCon : new AbortController();
|
|
1461
|
+
dataSet.syncAbortController = abortController;
|
|
1462
|
+
hashTree = dataSet.hashTree;
|
|
1463
|
+
rootHash = hashTree.getRootHash();
|
|
1464
|
+
shouldCollectMetrics = this.shouldCollectSyncMetrics(dataSet.name, isInitialization); // Generate two distinct tracking ids up-front. Each Locus request must carry its own unique
|
|
1465
|
+
// tracking id, so the /hashtree and /sync requests must not share one. hashtreeTrackingId is
|
|
1466
|
+
// generated first so that syncTrackingId (forced onto the /sync request, stored in metrics, and
|
|
1467
|
+
// used to match the LLM broadcast message) ends up with the later/higher sequence number,
|
|
1468
|
+
// matching the order in which Locus sees the requests. If we never call /hashtree (single-leaf
|
|
1469
|
+
// or initialization syncs), hashtreeTrackingId is simply unused.
|
|
1470
|
+
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;
|
|
1471
|
+
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;
|
|
1472
|
+
syncRequestSent = false;
|
|
1473
|
+
if (shouldCollectMetrics) {
|
|
1474
|
+
(_this$callbacks$syncL2 = this.callbacks.syncLatencyTracker) === null || _this$callbacks$syncL2 === void 0 ? void 0 : _this$callbacks$syncL2.saveTimestamp({
|
|
1475
|
+
key: 'internal.client.locus.sync.start',
|
|
1476
|
+
options: {
|
|
1477
|
+
meetingId: this.syncLatencyMeetingId,
|
|
1478
|
+
dataSetName: dataSet.name,
|
|
1479
|
+
trackingId: syncTrackingId
|
|
1480
|
+
}
|
|
1481
|
+
});
|
|
1482
|
+
}
|
|
1483
|
+
_context7.prev = 2;
|
|
1325
1484
|
_loggerProxy.default.logger.info("HashTreeParser#performSync --> ".concat(this.debugId, " ").concat(reason, ", syncing data set \"").concat(dataSet.name, "\""));
|
|
1326
|
-
|
|
1485
|
+
leavesData = {};
|
|
1486
|
+
if (isInitialization) {
|
|
1487
|
+
_context7.next = 10;
|
|
1488
|
+
break;
|
|
1489
|
+
}
|
|
1327
1490
|
if (!(dataSet.leafCount !== 1)) {
|
|
1328
|
-
|
|
1491
|
+
_context7.next = 9;
|
|
1329
1492
|
break;
|
|
1330
1493
|
}
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
return this.getHashesFromLocus(dataSet.name, rootHash
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
latestDataSetInfo = _yield$this$getHashes.dataSet;
|
|
1338
|
-
receivedHashes = hashes;
|
|
1339
|
-
dataSet.hashTree.resize(latestDataSetInfo.leafCount);
|
|
1340
|
-
_context6.next = 6;
|
|
1341
|
-
break;
|
|
1494
|
+
_context7.prev = 3;
|
|
1495
|
+
_context7.next = 4;
|
|
1496
|
+
return this.getHashesFromLocus(dataSet.name, rootHash, {
|
|
1497
|
+
requestTrackingId: hashtreeTrackingId,
|
|
1498
|
+
metricTrackingId: syncTrackingId
|
|
1499
|
+
});
|
|
1342
1500
|
case 4:
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1501
|
+
hashesResult = _context7.sent;
|
|
1502
|
+
if (hashesResult) {
|
|
1503
|
+
_context7.next = 5;
|
|
1504
|
+
break;
|
|
1505
|
+
}
|
|
1506
|
+
return _context7.abrupt("return");
|
|
1507
|
+
case 5:
|
|
1508
|
+
receivedHashes = hashesResult.hashes;
|
|
1509
|
+
this.updateDataSetLeafCount(dataSet, hashesResult.dataSet.leafCount);
|
|
1510
|
+
_context7.next = 8;
|
|
1511
|
+
break;
|
|
1512
|
+
case 6:
|
|
1513
|
+
_context7.prev = 6;
|
|
1514
|
+
_t3 = _context7["catch"](3);
|
|
1515
|
+
if (!((_t3 === null || _t3 === void 0 ? void 0 : _t3.statusCode) === 409)) {
|
|
1516
|
+
_context7.next = 7;
|
|
1347
1517
|
break;
|
|
1348
1518
|
}
|
|
1349
1519
|
// this is a leaf count mismatch, we should do nothing, just wait for another heartbeat message from Locus
|
|
1350
1520
|
_loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(this.debugId, " Got 409 when fetching hashes for data set \"").concat(dataSet.name, "\": ").concat(_t3.message));
|
|
1351
|
-
return
|
|
1352
|
-
case
|
|
1521
|
+
return _context7.abrupt("return");
|
|
1522
|
+
case 7:
|
|
1353
1523
|
throw _t3;
|
|
1354
|
-
case
|
|
1524
|
+
case 8:
|
|
1355
1525
|
// identify mismatched leaves
|
|
1356
|
-
mismatchedLeaveIndexes =
|
|
1526
|
+
mismatchedLeaveIndexes = hashTree.diffHashes(receivedHashes);
|
|
1357
1527
|
mismatchedLeaveIndexes.forEach(function (index) {
|
|
1358
|
-
|
|
1528
|
+
leavesData[index] = hashTree.getLeafData(index);
|
|
1359
1529
|
});
|
|
1360
|
-
|
|
1530
|
+
_context7.next = 10;
|
|
1361
1531
|
break;
|
|
1362
|
-
case
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1532
|
+
case 9:
|
|
1533
|
+
leavesData = {
|
|
1534
|
+
0: hashTree.getLeafData(0)
|
|
1535
|
+
};
|
|
1536
|
+
case 10:
|
|
1537
|
+
if (!abortController.signal.aborted) {
|
|
1538
|
+
_context7.next = 11;
|
|
1367
1539
|
break;
|
|
1368
1540
|
}
|
|
1369
|
-
|
|
1370
|
-
return
|
|
1371
|
-
case
|
|
1372
|
-
|
|
1541
|
+
_loggerProxy.default.logger.info("HashTreeParser#performSync --> ".concat(this.debugId, " abandoning sync for \"").concat(dataSet.name, "\" before /sync - message received during sync"));
|
|
1542
|
+
return _context7.abrupt("return");
|
|
1543
|
+
case 11:
|
|
1544
|
+
// request sync for mismatched leaves
|
|
1545
|
+
syncResponse = null;
|
|
1546
|
+
if (!isInitialization) {
|
|
1547
|
+
_context7.next = 13;
|
|
1548
|
+
break;
|
|
1549
|
+
}
|
|
1550
|
+
_context7.next = 12;
|
|
1551
|
+
return this.sendSyncRequestToLocus(dataSet, {
|
|
1552
|
+
isInitialization: true
|
|
1553
|
+
}, syncTrackingId);
|
|
1554
|
+
case 12:
|
|
1555
|
+
syncResponse = _context7.sent;
|
|
1556
|
+
syncRequestSent = true;
|
|
1557
|
+
_context7.next = 15;
|
|
1558
|
+
break;
|
|
1559
|
+
case 13:
|
|
1560
|
+
if (!((0, _keys.default)(leavesData).length > 0)) {
|
|
1561
|
+
_context7.next = 15;
|
|
1562
|
+
break;
|
|
1563
|
+
}
|
|
1564
|
+
_context7.next = 14;
|
|
1565
|
+
return this.sendSyncRequestToLocus(dataSet, {
|
|
1566
|
+
mismatchedLeavesData: leavesData
|
|
1567
|
+
}, syncTrackingId);
|
|
1568
|
+
case 14:
|
|
1569
|
+
syncResponse = _context7.sent;
|
|
1570
|
+
syncRequestSent = true;
|
|
1571
|
+
case 15:
|
|
1373
1572
|
// sync API may return nothing (in that case data will arrive via messages)
|
|
1374
1573
|
// or it may return a response in the same format as messages
|
|
1574
|
+
// We still need to restart the sync timer as a safety net in case the messages don't arrive.
|
|
1575
|
+
this.runSyncAlgorithm(dataSet);
|
|
1375
1576
|
if (syncResponse) {
|
|
1376
|
-
|
|
1577
|
+
// clear the abort controller before processing the response so that
|
|
1578
|
+
// parseMessage() -> cancelPendingSyncsForDataSets() doesn't log a
|
|
1579
|
+
// misleading "aborting sync" message for this already-completed sync
|
|
1580
|
+
dataSet.syncAbortController = undefined;
|
|
1581
|
+
|
|
1582
|
+
// we only requested this dataset, so restrict the response to it before processing
|
|
1583
|
+
// (Locus may include shared datasets like "unjoined" alongside "main")
|
|
1584
|
+
filteredResponse = this.filterMessageToDataSet(syncResponse, dataSet.name); // the format of sync response is the same as messages, so we can reuse the same handler
|
|
1585
|
+
this.handleMessage(filteredResponse, "via sync API (".concat(isInitialization ? 'init' : "".concat((0, _keys.default)(leavesData).length, " mismatched leaves"), ")"));
|
|
1377
1586
|
}
|
|
1378
|
-
|
|
1379
|
-
_context6.next = 12;
|
|
1587
|
+
_context7.next = 17;
|
|
1380
1588
|
break;
|
|
1381
|
-
case
|
|
1382
|
-
|
|
1383
|
-
_t4 =
|
|
1384
|
-
if (_t4
|
|
1385
|
-
this.callLocusInfoUpdateCallback({
|
|
1386
|
-
updateType: LocusInfoUpdateType.MEETING_ENDED
|
|
1387
|
-
});
|
|
1388
|
-
} else {
|
|
1589
|
+
case 16:
|
|
1590
|
+
_context7.prev = 16;
|
|
1591
|
+
_t4 = _context7["catch"](2);
|
|
1592
|
+
if (!this.handleSyncErrors(_t4)) {
|
|
1389
1593
|
_loggerProxy.default.logger.warn("HashTreeParser#performSync --> ".concat(this.debugId, " error during sync for data set \"").concat(dataSet.name, "\":"), _t4);
|
|
1390
1594
|
}
|
|
1391
|
-
case
|
|
1595
|
+
case 17:
|
|
1596
|
+
_context7.prev = 17;
|
|
1597
|
+
if (shouldCollectMetrics && !syncRequestSent) {
|
|
1598
|
+
// Drop only this sync's in-progress record (matched by its tracking id) rather than the
|
|
1599
|
+
// whole dataset, so a still-pending record from an earlier successful sync isn't wiped.
|
|
1600
|
+
// This mirrors the native client's onSyncError(syncId) which discards a single record.
|
|
1601
|
+
(_this$callbacks$syncL3 = this.callbacks.syncLatencyTracker) === null || _this$callbacks$syncL3 === void 0 ? void 0 : _this$callbacks$syncL3.clearLocusSyncLatency(dataSet.name, this.syncLatencyMeetingId, syncTrackingId);
|
|
1602
|
+
}
|
|
1603
|
+
dataSet.syncAbortController = undefined;
|
|
1604
|
+
return _context7.finish(17);
|
|
1605
|
+
case 18:
|
|
1392
1606
|
case "end":
|
|
1393
|
-
return
|
|
1607
|
+
return _context7.stop();
|
|
1394
1608
|
}
|
|
1395
|
-
},
|
|
1609
|
+
}, _callee6, this, [[2, 16, 17, 18], [3, 6]]);
|
|
1396
1610
|
}));
|
|
1397
|
-
function performSync(
|
|
1611
|
+
function performSync(_x8, _x9, _x0) {
|
|
1398
1612
|
return _performSync.apply(this, arguments);
|
|
1399
1613
|
}
|
|
1400
1614
|
return performSync;
|
|
1401
1615
|
}()
|
|
1616
|
+
/**
|
|
1617
|
+
* Cancels any pending or in-flight syncs for the specified data sets.
|
|
1618
|
+
* This removes matching entries from the sync queue and aborts any in-flight sync HTTP requests.
|
|
1619
|
+
*
|
|
1620
|
+
* @param {string[]} dataSetNames - The names of the data sets to cancel syncs for
|
|
1621
|
+
* @returns {void}
|
|
1622
|
+
*/
|
|
1623
|
+
)
|
|
1624
|
+
}, {
|
|
1625
|
+
key: "cancelPendingSyncsForDataSets",
|
|
1626
|
+
value: function cancelPendingSyncsForDataSets(dataSetNames) {
|
|
1627
|
+
var previousLength = this.syncQueue.length;
|
|
1628
|
+
this.syncQueue = this.syncQueue.filter(function (entry) {
|
|
1629
|
+
return !dataSetNames.includes(entry.dataSetName);
|
|
1630
|
+
});
|
|
1631
|
+
if (previousLength !== this.syncQueue.length) {
|
|
1632
|
+
_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(', ')));
|
|
1633
|
+
}
|
|
1634
|
+
this.markDataSetsForSyncAllBackoffSkip(dataSetNames);
|
|
1635
|
+
this.abortInFlightSyncs(dataSetNames);
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
/**
|
|
1639
|
+
* If a syncAllDatasets backoff sleep is in progress, marks the given data sets to be skipped
|
|
1640
|
+
* after the sleep completes.
|
|
1641
|
+
*
|
|
1642
|
+
* @param {string[]} dataSetNames - The names of the data sets to mark
|
|
1643
|
+
* @returns {void}
|
|
1644
|
+
*/
|
|
1645
|
+
}, {
|
|
1646
|
+
key: "markDataSetsForSyncAllBackoffSkip",
|
|
1647
|
+
value: function markDataSetsForSyncAllBackoffSkip(dataSetNames) {
|
|
1648
|
+
if (this.syncAllBackoffType !== SyncAllBackoffType.NONE) {
|
|
1649
|
+
var _iterator9 = _createForOfIteratorHelper(dataSetNames),
|
|
1650
|
+
_step9;
|
|
1651
|
+
try {
|
|
1652
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
1653
|
+
var name = _step9.value;
|
|
1654
|
+
this.dataSetsSyncedDuringBackoff.add(name);
|
|
1655
|
+
}
|
|
1656
|
+
} catch (err) {
|
|
1657
|
+
_iterator9.e(err);
|
|
1658
|
+
} finally {
|
|
1659
|
+
_iterator9.f();
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
/**
|
|
1665
|
+
* Aborts any in-flight sync HTTP requests for the specified data sets.
|
|
1666
|
+
*
|
|
1667
|
+
* @param {string[]} dataSetNames - The names of the data sets whose syncs should be aborted
|
|
1668
|
+
* @returns {void}
|
|
1669
|
+
*/
|
|
1670
|
+
}, {
|
|
1671
|
+
key: "abortInFlightSyncs",
|
|
1672
|
+
value: function abortInFlightSyncs(dataSetNames) {
|
|
1673
|
+
var _iterator0 = _createForOfIteratorHelper(dataSetNames),
|
|
1674
|
+
_step0;
|
|
1675
|
+
try {
|
|
1676
|
+
for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
|
|
1677
|
+
var _this$dataSets$name;
|
|
1678
|
+
var name = _step0.value;
|
|
1679
|
+
if ((_this$dataSets$name = this.dataSets[name]) !== null && _this$dataSets$name !== void 0 && _this$dataSets$name.syncAbortController) {
|
|
1680
|
+
_loggerProxy.default.logger.info("HashTreeParser#cancelPendingSyncsForDataSets --> ".concat(this.debugId, " aborting in-flight sync for data set \"").concat(name, "\""));
|
|
1681
|
+
this.dataSets[name].syncAbortController.abort();
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
} catch (err) {
|
|
1685
|
+
_iterator0.e(err);
|
|
1686
|
+
} finally {
|
|
1687
|
+
_iterator0.f();
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
/**
|
|
1692
|
+
* Enqueues a sync for the given data set. If the data set is already in the queue, the request is ignored.
|
|
1693
|
+
* This ensures that all syncs are executed sequentially and no more than 1 sync runs at a time.
|
|
1694
|
+
*
|
|
1695
|
+
* @param {string} dataSetName - The name of the data set to sync
|
|
1696
|
+
* @param {string} reason - The reason for the sync (used for logging)
|
|
1697
|
+
* @param {boolean} [isInitialization=false] - Whether this is an initialization sync (uses empty leaves data instead of hash comparison)
|
|
1698
|
+
* @returns {void}
|
|
1699
|
+
*/
|
|
1700
|
+
}, {
|
|
1701
|
+
key: "enqueueSyncForDataset",
|
|
1702
|
+
value: function enqueueSyncForDataset(dataSetName, reason) {
|
|
1703
|
+
var isInitialization = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1704
|
+
if (this.state === 'stopped') return;
|
|
1705
|
+
var existingEntry = this.syncQueue.find(function (entry) {
|
|
1706
|
+
return entry.dataSetName === dataSetName;
|
|
1707
|
+
});
|
|
1708
|
+
if (existingEntry) {
|
|
1709
|
+
if (isInitialization) {
|
|
1710
|
+
existingEntry.isInitialization = true;
|
|
1711
|
+
}
|
|
1712
|
+
_loggerProxy.default.logger.info("HashTreeParser#enqueueSyncForDataset --> ".concat(this.debugId, " data set \"").concat(dataSetName, "\" already in sync queue, skipping"));
|
|
1713
|
+
return;
|
|
1714
|
+
}
|
|
1715
|
+
this.syncQueue.push({
|
|
1716
|
+
dataSetName: dataSetName,
|
|
1717
|
+
reason: reason,
|
|
1718
|
+
isInitialization: isInitialization
|
|
1719
|
+
});
|
|
1720
|
+
if (!this.isSyncInProgress) {
|
|
1721
|
+
this.syncQueueProcessingPromise = this.processSyncQueue();
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
/**
|
|
1726
|
+
* Processes the sync queue sequentially. Only one instance of this method runs at a time.
|
|
1727
|
+
*
|
|
1728
|
+
* @returns {Promise<void>}
|
|
1729
|
+
*/
|
|
1730
|
+
}, {
|
|
1731
|
+
key: "processSyncQueue",
|
|
1732
|
+
value: (function () {
|
|
1733
|
+
var _processSyncQueue = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7() {
|
|
1734
|
+
var _ref8, dataSetName, reason, isInitialization, dataSet;
|
|
1735
|
+
return _regenerator.default.wrap(function (_context8) {
|
|
1736
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
1737
|
+
case 0:
|
|
1738
|
+
if (!this.isSyncInProgress) {
|
|
1739
|
+
_context8.next = 1;
|
|
1740
|
+
break;
|
|
1741
|
+
}
|
|
1742
|
+
return _context8.abrupt("return");
|
|
1743
|
+
case 1:
|
|
1744
|
+
this.isSyncInProgress = true;
|
|
1745
|
+
_context8.prev = 2;
|
|
1746
|
+
case 3:
|
|
1747
|
+
if (!(this.syncQueue.length > 0 && this.state !== 'stopped')) {
|
|
1748
|
+
_context8.next = 6;
|
|
1749
|
+
break;
|
|
1750
|
+
}
|
|
1751
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1752
|
+
_ref8 = this.syncQueue.shift(), dataSetName = _ref8.dataSetName, reason = _ref8.reason, isInitialization = _ref8.isInitialization;
|
|
1753
|
+
dataSet = this.dataSets[dataSetName];
|
|
1754
|
+
if (dataSet !== null && dataSet !== void 0 && dataSet.hashTree) {
|
|
1755
|
+
_context8.next = 4;
|
|
1756
|
+
break;
|
|
1757
|
+
}
|
|
1758
|
+
return _context8.abrupt("continue", 3);
|
|
1759
|
+
case 4:
|
|
1760
|
+
_context8.next = 5;
|
|
1761
|
+
return this.performSync(dataSet, reason, isInitialization);
|
|
1762
|
+
case 5:
|
|
1763
|
+
_context8.next = 3;
|
|
1764
|
+
break;
|
|
1765
|
+
case 6:
|
|
1766
|
+
_context8.prev = 6;
|
|
1767
|
+
this.isSyncInProgress = false;
|
|
1768
|
+
return _context8.finish(6);
|
|
1769
|
+
case 7:
|
|
1770
|
+
case "end":
|
|
1771
|
+
return _context8.stop();
|
|
1772
|
+
}
|
|
1773
|
+
}, _callee7, this, [[2,, 6, 7]]);
|
|
1774
|
+
}));
|
|
1775
|
+
function processSyncQueue() {
|
|
1776
|
+
return _processSyncQueue.apply(this, arguments);
|
|
1777
|
+
}
|
|
1778
|
+
return processSyncQueue;
|
|
1779
|
+
}()
|
|
1780
|
+
/**
|
|
1781
|
+
* sets the backoff type for syncAllDatasets calls, which determines the scope of datasets that will be synced after the backoff delay.
|
|
1782
|
+
*
|
|
1783
|
+
* @param {boolean} onlyLLM - Whether the backoff is for a syncAllDatasets call that is syncing only LLM datasets
|
|
1784
|
+
* @returns {void}
|
|
1785
|
+
*/
|
|
1786
|
+
)
|
|
1787
|
+
}, {
|
|
1788
|
+
key: "setSyncAllBackoffType",
|
|
1789
|
+
value: function setSyncAllBackoffType(onlyLLM) {
|
|
1790
|
+
this.syncAllBackoffType = onlyLLM ? SyncAllBackoffType.ONLY_LLM : SyncAllBackoffType.ALL;
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
/**
|
|
1794
|
+
* Checks if a syncAll backoff is already in progress. If so, upgrades the scope from
|
|
1795
|
+
* onlyLLM to all datasets when the new call has a broader scope.
|
|
1796
|
+
*
|
|
1797
|
+
* @param {boolean} onlyLLM - Whether the current call is for LLM datasets only
|
|
1798
|
+
* @returns {boolean} true if a backoff is already pending (caller should return early)
|
|
1799
|
+
*/
|
|
1800
|
+
}, {
|
|
1801
|
+
key: "tryUpgradePendingBackoff",
|
|
1802
|
+
value: function tryUpgradePendingBackoff(onlyLLM) {
|
|
1803
|
+
if (this.syncAllBackoffType !== SyncAllBackoffType.NONE) {
|
|
1804
|
+
if (!onlyLLM && this.syncAllBackoffType === SyncAllBackoffType.ONLY_LLM) {
|
|
1805
|
+
this.setSyncAllBackoffType(false);
|
|
1806
|
+
_loggerProxy.default.logger.info("HashTreeParser#syncAllDatasets --> ".concat(this.debugId, " upgraded pending syncAll from onlyLLM to all datasets"));
|
|
1807
|
+
}
|
|
1808
|
+
return true;
|
|
1809
|
+
}
|
|
1810
|
+
return false;
|
|
1811
|
+
}
|
|
1812
|
+
|
|
1813
|
+
/**
|
|
1814
|
+
* Syncs all data sets that have hash trees, one by one in sequence, using the priority order
|
|
1815
|
+
* provided by sortByInitPriority().
|
|
1816
|
+
*
|
|
1817
|
+
* If a call is already waiting in the backoff delay phase, a new call with a broader scope
|
|
1818
|
+
* (onlyLLM=false) will upgrade the pending scope, and the dataset list will be computed after
|
|
1819
|
+
* the backoff using the upgraded scope. After the backoff, the sync queue handles deduplication
|
|
1820
|
+
* so no guard is needed.
|
|
1821
|
+
*
|
|
1822
|
+
* @param {Object} [options={}] - Options for syncing
|
|
1823
|
+
* @param {boolean} [options.onlyLLM=false] - Whether to sync only LLM based data sets
|
|
1824
|
+
* @returns {Promise<void>}
|
|
1825
|
+
*/
|
|
1826
|
+
}, {
|
|
1827
|
+
key: "syncAllDatasets",
|
|
1828
|
+
value: (function () {
|
|
1829
|
+
var _syncAllDatasets = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8() {
|
|
1830
|
+
var options,
|
|
1831
|
+
_options$onlyLLM,
|
|
1832
|
+
onlyLLM,
|
|
1833
|
+
dataSetsToSync,
|
|
1834
|
+
delay,
|
|
1835
|
+
effectiveBackoffType,
|
|
1836
|
+
skippedDataSets,
|
|
1837
|
+
effectiveDataSetsToSync,
|
|
1838
|
+
_iterator1,
|
|
1839
|
+
_step1,
|
|
1840
|
+
ds,
|
|
1841
|
+
_args9 = arguments;
|
|
1842
|
+
return _regenerator.default.wrap(function (_context9) {
|
|
1843
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
1844
|
+
case 0:
|
|
1845
|
+
options = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
|
|
1846
|
+
_options$onlyLLM = options.onlyLLM, onlyLLM = _options$onlyLLM === void 0 ? false : _options$onlyLLM;
|
|
1847
|
+
if (!(this.state === 'stopped')) {
|
|
1848
|
+
_context9.next = 1;
|
|
1849
|
+
break;
|
|
1850
|
+
}
|
|
1851
|
+
return _context9.abrupt("return");
|
|
1852
|
+
case 1:
|
|
1853
|
+
if (!this.tryUpgradePendingBackoff(onlyLLM)) {
|
|
1854
|
+
_context9.next = 2;
|
|
1855
|
+
break;
|
|
1856
|
+
}
|
|
1857
|
+
return _context9.abrupt("return");
|
|
1858
|
+
case 2:
|
|
1859
|
+
dataSetsToSync = this.getSortedDataSetsWithHashTrees(onlyLLM);
|
|
1860
|
+
if (!(dataSetsToSync.length === 0)) {
|
|
1861
|
+
_context9.next = 3;
|
|
1862
|
+
break;
|
|
1863
|
+
}
|
|
1864
|
+
return _context9.abrupt("return");
|
|
1865
|
+
case 3:
|
|
1866
|
+
this.setSyncAllBackoffType(onlyLLM);
|
|
1867
|
+
delay = this.getWeightedBackoffTime(dataSetsToSync[0].backoff);
|
|
1868
|
+
_loggerProxy.default.logger.info("HashTreeParser#syncAllDatasets --> ".concat(this.debugId, " starting backoff delay of ").concat(delay, "ms (onlyLLM=").concat(onlyLLM, ")"));
|
|
1869
|
+
|
|
1870
|
+
// delay the start of the syncs - this is a Locus requirement to avoid thundering herd issues
|
|
1871
|
+
_context9.next = 4;
|
|
1872
|
+
return (0, _utils.sleep)(delay);
|
|
1873
|
+
case 4:
|
|
1874
|
+
// read the (possibly upgraded) scope and clear the backoff flag
|
|
1875
|
+
effectiveBackoffType = this.syncAllBackoffType;
|
|
1876
|
+
skippedDataSets = this.dataSetsSyncedDuringBackoff;
|
|
1877
|
+
this.syncAllBackoffType = SyncAllBackoffType.NONE;
|
|
1878
|
+
this.dataSetsSyncedDuringBackoff = new _set.default();
|
|
1879
|
+
if (!(this.state === 'stopped')) {
|
|
1880
|
+
_context9.next = 5;
|
|
1881
|
+
break;
|
|
1882
|
+
}
|
|
1883
|
+
return _context9.abrupt("return");
|
|
1884
|
+
case 5:
|
|
1885
|
+
// re-evaluate the dataset list after the sleep, since the scope may have been upgraded
|
|
1886
|
+
// and exclude datasets that received messages during the backoff sleep
|
|
1887
|
+
effectiveDataSetsToSync = this.getSortedDataSetsWithHashTrees(effectiveBackoffType === SyncAllBackoffType.ONLY_LLM).filter(function (ds) {
|
|
1888
|
+
return !skippedDataSets.has(ds.name);
|
|
1889
|
+
});
|
|
1890
|
+
if (skippedDataSets.size > 0) {
|
|
1891
|
+
_loggerProxy.default.logger.info("HashTreeParser#syncAllDatasets --> ".concat(this.debugId, " skipping datasets that received messages during backoff: ").concat((0, _toConsumableArray2.default)(skippedDataSets).join(', ')));
|
|
1892
|
+
}
|
|
1893
|
+
_loggerProxy.default.logger.info("HashTreeParser#syncAllDatasets --> ".concat(this.debugId, " syncing ").concat(effectiveBackoffType === SyncAllBackoffType.ONLY_LLM ? 'only LLM' : 'all', " datasets: ").concat(effectiveDataSetsToSync.map(function (ds) {
|
|
1894
|
+
return ds.name;
|
|
1895
|
+
}).join(', ')));
|
|
1896
|
+
_iterator1 = _createForOfIteratorHelper(effectiveDataSetsToSync);
|
|
1897
|
+
try {
|
|
1898
|
+
for (_iterator1.s(); !(_step1 = _iterator1.n()).done;) {
|
|
1899
|
+
ds = _step1.value;
|
|
1900
|
+
this.saveSyncBackoffLatency(ds.name, delay);
|
|
1901
|
+
this.enqueueSyncForDataset(ds.name, 'syncAllDatasets');
|
|
1902
|
+
}
|
|
1903
|
+
} catch (err) {
|
|
1904
|
+
_iterator1.e(err);
|
|
1905
|
+
} finally {
|
|
1906
|
+
_iterator1.f();
|
|
1907
|
+
}
|
|
1908
|
+
_context9.next = 6;
|
|
1909
|
+
return this.syncQueueProcessingPromise;
|
|
1910
|
+
case 6:
|
|
1911
|
+
case "end":
|
|
1912
|
+
return _context9.stop();
|
|
1913
|
+
}
|
|
1914
|
+
}, _callee8, this);
|
|
1915
|
+
}));
|
|
1916
|
+
function syncAllDatasets() {
|
|
1917
|
+
return _syncAllDatasets.apply(this, arguments);
|
|
1918
|
+
}
|
|
1919
|
+
return syncAllDatasets;
|
|
1920
|
+
}()
|
|
1921
|
+
/**
|
|
1922
|
+
* Returns the list of data sets that have hash trees, sorted by the priority order provided by sortByInitPriority().
|
|
1923
|
+
*
|
|
1924
|
+
* @param {boolean} onlyLLM - Whether to include only LLM based data sets
|
|
1925
|
+
* @returns {Array<{name: string, backoff: {maxMs: number, exponent: number}}>} The sorted list of data sets with their backoff configurations
|
|
1926
|
+
*/
|
|
1927
|
+
)
|
|
1928
|
+
}, {
|
|
1929
|
+
key: "getSortedDataSetsWithHashTrees",
|
|
1930
|
+
value: function getSortedDataSetsWithHashTrees(onlyLLM) {
|
|
1931
|
+
var dataSets = (0, _values.default)(this.dataSets).filter(function (dataSet) {
|
|
1932
|
+
return dataSet === null || dataSet === void 0 ? void 0 : dataSet.hashTree;
|
|
1933
|
+
}).map(function (dataSet) {
|
|
1934
|
+
return {
|
|
1935
|
+
name: dataSet.name,
|
|
1936
|
+
backoff: dataSet.backoff
|
|
1937
|
+
};
|
|
1938
|
+
});
|
|
1939
|
+
if (onlyLLM) {
|
|
1940
|
+
dataSets = dataSets.filter(function (ds) {
|
|
1941
|
+
return _constants3.LLM_DATASET_NAMES.includes(ds.name);
|
|
1942
|
+
});
|
|
1943
|
+
}
|
|
1944
|
+
return (0, _utils.sortByInitPriority)(dataSets, _constants3.DATA_SET_INIT_PRIORITY);
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1402
1947
|
/**
|
|
1403
1948
|
* Runs the sync algorithm for the given data set.
|
|
1404
1949
|
*
|
|
1405
1950
|
* @param {DataSet} receivedDataSet - The data set to run the sync algorithm for.
|
|
1406
1951
|
* @returns {void}
|
|
1407
1952
|
*/
|
|
1408
|
-
)
|
|
1409
1953
|
}, {
|
|
1410
1954
|
key: "runSyncAlgorithm",
|
|
1411
1955
|
value: function runSyncAlgorithm(receivedDataSet) {
|
|
1412
|
-
var
|
|
1956
|
+
var _this10 = this;
|
|
1413
1957
|
var dataSet = this.dataSets[receivedDataSet.name];
|
|
1414
1958
|
if (!dataSet) {
|
|
1415
1959
|
_loggerProxy.default.logger.warn("HashTreeParser#runSyncAlgorithm --> ".concat(this.debugId, " No data set found for ").concat(receivedDataSet.name, ", skipping sync algorithm"));
|
|
1416
1960
|
return;
|
|
1417
1961
|
}
|
|
1418
1962
|
if (!dataSet.hashTree) {
|
|
1419
|
-
|
|
1963
|
+
// no hash tree, so no need to do any syncing
|
|
1964
|
+
// we fall into this branch often, because Locus sends dataSets in messages that are not visible to us
|
|
1965
|
+
|
|
1420
1966
|
return;
|
|
1421
1967
|
}
|
|
1422
1968
|
dataSet.hashTree.resize(receivedDataSet.leafCount);
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
var ourCurrentRootHash = dataSet.hashTree.getRootHash();
|
|
1426
|
-
_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));
|
|
1427
|
-
var delay = dataSet.idleMs + this.getWeightedBackoffTime(dataSet.backoff);
|
|
1969
|
+
var randomBackoffTime = this.getWeightedBackoffTime(dataSet.backoff);
|
|
1970
|
+
var delay = dataSet.idleMs + randomBackoffTime;
|
|
1428
1971
|
if (delay > 0) {
|
|
1429
1972
|
if (dataSet.timer) {
|
|
1430
1973
|
clearTimeout(dataSet.timer);
|
|
1431
1974
|
}
|
|
1432
|
-
|
|
1433
|
-
dataSet.timer = setTimeout(
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
return _context7.abrupt("return");
|
|
1445
|
-
case 1:
|
|
1446
|
-
rootHash = dataSet.hashTree.getRootHash();
|
|
1447
|
-
if (!(dataSet.root !== rootHash)) {
|
|
1448
|
-
_context7.next = 3;
|
|
1449
|
-
break;
|
|
1450
|
-
}
|
|
1451
|
-
_context7.next = 2;
|
|
1452
|
-
return _this11.performSync(dataSet, rootHash, "Root hash mismatch: received=".concat(dataSet.root, ", ours=").concat(rootHash));
|
|
1453
|
-
case 2:
|
|
1454
|
-
_context7.next = 4;
|
|
1455
|
-
break;
|
|
1456
|
-
case 3:
|
|
1457
|
-
_loggerProxy.default.logger.info("HashTreeParser#runSyncAlgorithm --> ".concat(_this11.debugId, " \"").concat(dataSet.name, "\" root hash matching: ").concat(rootHash, ", version=").concat(dataSet.version));
|
|
1458
|
-
case 4:
|
|
1459
|
-
case "end":
|
|
1460
|
-
return _context7.stop();
|
|
1461
|
-
}
|
|
1462
|
-
}, _callee6);
|
|
1463
|
-
})), delay);
|
|
1975
|
+
this.saveSyncBackoffLatency(dataSet.name, randomBackoffTime);
|
|
1976
|
+
dataSet.timer = setTimeout(function () {
|
|
1977
|
+
dataSet.timer = undefined;
|
|
1978
|
+
if (!dataSet.hashTree) {
|
|
1979
|
+
_loggerProxy.default.logger.warn("HashTreeParser#runSyncAlgorithm --> ".concat(_this10.debugId, " Data set \"").concat(dataSet.name, "\" no longer has a hash tree, cannot run sync algorithm"));
|
|
1980
|
+
return;
|
|
1981
|
+
}
|
|
1982
|
+
var rootHash = dataSet.hashTree.getRootHash();
|
|
1983
|
+
if (dataSet.root !== rootHash) {
|
|
1984
|
+
_this10.enqueueSyncForDataset(dataSet.name, "Root hash mismatch: received=".concat(dataSet.root, ", ours=").concat(rootHash));
|
|
1985
|
+
}
|
|
1986
|
+
}, delay);
|
|
1464
1987
|
} else {
|
|
1465
1988
|
_loggerProxy.default.logger.info("HashTreeParser#runSyncAlgorithm --> ".concat(this.debugId, " No delay for \"").concat(dataSet.name, "\" data set, skipping sync timer reset/setup"));
|
|
1466
1989
|
}
|
|
@@ -1478,48 +2001,95 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1478
2001
|
}, {
|
|
1479
2002
|
key: "resetHeartbeatWatchdogs",
|
|
1480
2003
|
value: function resetHeartbeatWatchdogs(receivedDataSets) {
|
|
1481
|
-
var
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
}
|
|
1485
|
-
var _iterator9 = _createForOfIteratorHelper(receivedDataSets),
|
|
1486
|
-
_step9;
|
|
2004
|
+
var _this11 = this;
|
|
2005
|
+
var _iterator10 = _createForOfIteratorHelper(receivedDataSets),
|
|
2006
|
+
_step10;
|
|
1487
2007
|
try {
|
|
1488
2008
|
var _loop2 = function _loop2() {
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
2009
|
+
var _dataSet$heartbeatInt;
|
|
2010
|
+
var receivedDataSet = _step10.value;
|
|
2011
|
+
var dataSet = _this11.dataSets[receivedDataSet.name];
|
|
2012
|
+
if (dataSet.heartbeatWatchdogTimer) {
|
|
2013
|
+
clearTimeout(dataSet.heartbeatWatchdogTimer);
|
|
2014
|
+
dataSet.heartbeatWatchdogTimer = undefined;
|
|
2015
|
+
}
|
|
2016
|
+
|
|
2017
|
+
// dataset-level heartbeatIntervalMs takes priority; fall back to top-level common value
|
|
2018
|
+
var heartbeatIntervalMs = (_dataSet$heartbeatInt = dataSet === null || dataSet === void 0 ? void 0 : dataSet.heartbeatIntervalMs) !== null && _dataSet$heartbeatInt !== void 0 ? _dataSet$heartbeatInt : _this11.topLevelHeartbeatIntervalMs;
|
|
2019
|
+
if (!(dataSet !== null && dataSet !== void 0 && dataSet.hashTree) || !_this11.isVisibleDataSet(dataSet.name) || !heartbeatIntervalMs) {
|
|
2020
|
+
// eslint-disable-next-line no-continue
|
|
2021
|
+
return 0; // continue
|
|
2022
|
+
}
|
|
2023
|
+
if (_constants3.LLM_DATASET_NAMES.includes(dataSet.name) && _this11.callbacks.isLlmExpected && !_this11.callbacks.isLlmExpected()) {
|
|
2024
|
+
_loggerProxy.default.logger.info("HashTreeParser#resetHeartbeatWatchdogs --> ".concat(_this11.debugId, " skipping heartbeat watchdog timer for data set \"").concat(dataSet.name, "\" because LLM is disconnected"));
|
|
2025
|
+
|
|
2026
|
+
// remember it so reevaluateLlmWatchdogs() can arm the watchdog once LLM becomes expected
|
|
2027
|
+
_this11.pendingLlmWatchdogDataSetNames.add(dataSet.name);
|
|
2028
|
+
// eslint-disable-next-line no-continue
|
|
2029
|
+
return 0; // continue
|
|
2030
|
+
}
|
|
2031
|
+
var backoffTime = _this11.getWeightedBackoffTime(dataSet.backoff);
|
|
2032
|
+
var delay = heartbeatIntervalMs + backoffTime;
|
|
2033
|
+
dataSet.heartbeatWatchdogTimer = setTimeout(function () {
|
|
2034
|
+
dataSet.heartbeatWatchdogTimer = undefined;
|
|
2035
|
+
_loggerProxy.default.logger.warn("HashTreeParser#resetHeartbeatWatchdogs --> ".concat(_this11.debugId, " Heartbeat watchdog fired for data set \"").concat(dataSet.name, "\" - no heartbeat received within expected interval(heartbeatIntervalMs=").concat(heartbeatIntervalMs, ", backoffTime=").concat(backoffTime, "), initiating sync"));
|
|
2036
|
+
_metrics.default.sendBehavioralMetric(_constants.default.HASH_TREE_HEARTBEAT_WATCHDOG_EXPIRED, {
|
|
2037
|
+
debugId: _this11.debugId,
|
|
2038
|
+
dataSetName: dataSet.name
|
|
2039
|
+
});
|
|
2040
|
+
_this11.saveSyncBackoffLatency(dataSet.name, backoffTime);
|
|
2041
|
+
_this11.enqueueSyncForDataset(dataSet.name, "heartbeat watchdog expired");
|
|
2042
|
+
_this11.resetHeartbeatWatchdogs([dataSet]);
|
|
2043
|
+
}, delay);
|
|
2044
|
+
},
|
|
2045
|
+
_ret;
|
|
2046
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
2047
|
+
_ret = _loop2();
|
|
2048
|
+
if (_ret === 0) continue;
|
|
1518
2049
|
}
|
|
1519
2050
|
} catch (err) {
|
|
1520
|
-
|
|
2051
|
+
_iterator10.e(err);
|
|
1521
2052
|
} finally {
|
|
1522
|
-
|
|
2053
|
+
_iterator10.f();
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
/**
|
|
2058
|
+
* Re-evaluates heartbeat watchdog timers for LLM data sets. While LLM is not expected,
|
|
2059
|
+
* resetHeartbeatWatchdogs skips setting watchdog timers for LLM data sets and records them in
|
|
2060
|
+
* pendingLlmWatchdogDataSetNames. This must be called when LLM transitions to expected (e.g. self
|
|
2061
|
+
* reports JOINED) to arm the watchdogs for those pending data sets (avoids a timing issue where
|
|
2062
|
+
* the "main"/"atd-active"/"atd-unmuted" data set arrives before the self update). The pending set
|
|
2063
|
+
* is consumed and cleared here.
|
|
2064
|
+
* @returns {void}
|
|
2065
|
+
*/
|
|
2066
|
+
}, {
|
|
2067
|
+
key: "reevaluateLlmWatchdogs",
|
|
2068
|
+
value: function reevaluateLlmWatchdogs() {
|
|
2069
|
+
var _this12 = this;
|
|
2070
|
+
if (this.state === 'stopped') {
|
|
2071
|
+
return;
|
|
2072
|
+
}
|
|
2073
|
+
if (this.pendingLlmWatchdogDataSetNames.size === 0) {
|
|
2074
|
+
return;
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
// consume the pending set - these LLM data sets were received while LLM was not expected
|
|
2078
|
+
var pendingDataSetNames = (0, _toConsumableArray2.default)(this.pendingLlmWatchdogDataSetNames);
|
|
2079
|
+
this.pendingLlmWatchdogDataSetNames.clear();
|
|
2080
|
+
var dataSetsNeedingWatchdog = pendingDataSetNames.map(function (name) {
|
|
2081
|
+
return _this12.dataSets[name];
|
|
2082
|
+
}).filter(function (dataSet) {
|
|
2083
|
+
if (!(dataSet !== null && dataSet !== void 0 && dataSet.hashTree) || dataSet.heartbeatWatchdogTimer) {
|
|
2084
|
+
return false;
|
|
2085
|
+
}
|
|
2086
|
+
return _this12.isVisibleDataSet(dataSet.name);
|
|
2087
|
+
});
|
|
2088
|
+
if (dataSetsNeedingWatchdog.length > 0) {
|
|
2089
|
+
_loggerProxy.default.logger.info("HashTreeParser#reevaluateLlmWatchdogs --> ".concat(this.debugId, " LLM became expected, setting heartbeat watchdog timers for data sets: ").concat(dataSetsNeedingWatchdog.map(function (ds) {
|
|
2090
|
+
return ds.name;
|
|
2091
|
+
}).join(', ')));
|
|
2092
|
+
this.resetHeartbeatWatchdogs(dataSetsNeedingWatchdog);
|
|
1523
2093
|
}
|
|
1524
2094
|
}
|
|
1525
2095
|
|
|
@@ -1553,7 +2123,15 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1553
2123
|
value: function stop() {
|
|
1554
2124
|
_loggerProxy.default.logger.info("HashTreeParser#stop --> ".concat(this.debugId, " Stopping HashTreeParser, clearing timers and hash trees"));
|
|
1555
2125
|
this.stopAllTimers();
|
|
2126
|
+
this.syncQueue = [];
|
|
2127
|
+
this.topLevelHeartbeatIntervalMs = undefined;
|
|
2128
|
+
this.syncAllBackoffType = SyncAllBackoffType.NONE;
|
|
2129
|
+
this.dataSetsSyncedDuringBackoff = new _set.default();
|
|
2130
|
+
this.pendingLlmWatchdogDataSetNames = new _set.default();
|
|
1556
2131
|
(0, _values.default)(this.dataSets).forEach(function (dataSet) {
|
|
2132
|
+
var _dataSet$syncAbortCon2;
|
|
2133
|
+
(_dataSet$syncAbortCon2 = dataSet.syncAbortController) === null || _dataSet$syncAbortCon2 === void 0 ? void 0 : _dataSet$syncAbortCon2.abort();
|
|
2134
|
+
dataSet.syncAbortController = undefined;
|
|
1557
2135
|
dataSet.hashTree = undefined;
|
|
1558
2136
|
});
|
|
1559
2137
|
this.visibleDataSets = [];
|
|
@@ -1573,29 +2151,28 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1573
2151
|
}
|
|
1574
2152
|
|
|
1575
2153
|
/**
|
|
1576
|
-
* Resumes the HashTreeParser that was previously stopped.
|
|
2154
|
+
* Resumes the HashTreeParser that was previously stopped, using a hash tree message.
|
|
1577
2155
|
* @param {HashTreeMessage} message - The message to resume with, it must contain metadata with visible data sets info
|
|
1578
2156
|
* @returns {void}
|
|
1579
2157
|
*/
|
|
1580
2158
|
}, {
|
|
1581
|
-
key: "
|
|
1582
|
-
value: function
|
|
1583
|
-
var _message$
|
|
1584
|
-
|
|
1585
|
-
var metadataObject = (_message$locusStateEl2 = message.locusStateElements) === null || _message$locusStateEl2 === void 0 ? void 0 : _message$locusStateEl2.find(function (el) {
|
|
2159
|
+
key: "resumeFromMessage",
|
|
2160
|
+
value: function resumeFromMessage(message) {
|
|
2161
|
+
var _message$locusStateEl6, _metadataObject$data;
|
|
2162
|
+
var metadataObject = (_message$locusStateEl6 = message.locusStateElements) === null || _message$locusStateEl6 === void 0 ? void 0 : _message$locusStateEl6.find(function (el) {
|
|
1586
2163
|
return (0, _utils.isMetadata)(el);
|
|
1587
2164
|
});
|
|
1588
2165
|
if (!(metadataObject !== null && metadataObject !== void 0 && (_metadataObject$data = metadataObject.data) !== null && _metadataObject$data !== void 0 && _metadataObject$data.visibleDataSets)) {
|
|
1589
|
-
_loggerProxy.default.logger.warn("HashTreeParser#
|
|
2166
|
+
_loggerProxy.default.logger.warn("HashTreeParser#resumeFromMessage --> ".concat(this.debugId, " Cannot resume HashTreeParser because the message is missing metadata with visible data sets info"));
|
|
1590
2167
|
return;
|
|
1591
2168
|
}
|
|
1592
2169
|
this.setVisibleDataSets(metadataObject.data.visibleDataSets, message.dataSets);
|
|
1593
2170
|
this.dataSets = {};
|
|
1594
|
-
var
|
|
1595
|
-
|
|
2171
|
+
var _iterator11 = _createForOfIteratorHelper(message.dataSets),
|
|
2172
|
+
_step11;
|
|
1596
2173
|
try {
|
|
1597
|
-
for (
|
|
1598
|
-
var dataSet =
|
|
2174
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
2175
|
+
var dataSet = _step11.value;
|
|
1599
2176
|
var name = dataSet.name,
|
|
1600
2177
|
leafCount = dataSet.leafCount;
|
|
1601
2178
|
this.dataSets[name] = _objectSpread(_objectSpread({}, dataSet), {}, {
|
|
@@ -1603,23 +2180,62 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1603
2180
|
});
|
|
1604
2181
|
}
|
|
1605
2182
|
} catch (err) {
|
|
1606
|
-
|
|
2183
|
+
_iterator11.e(err);
|
|
1607
2184
|
} finally {
|
|
1608
|
-
|
|
2185
|
+
_iterator11.f();
|
|
1609
2186
|
}
|
|
1610
|
-
_loggerProxy.default.logger.info("HashTreeParser#
|
|
2187
|
+
_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) {
|
|
1611
2188
|
return ds.name;
|
|
1612
2189
|
}).join(', ')));
|
|
1613
2190
|
this.state = 'active';
|
|
1614
2191
|
this.handleMessage(message, 'on resume');
|
|
1615
2192
|
}
|
|
2193
|
+
|
|
2194
|
+
/**
|
|
2195
|
+
* Resumes the HashTreeParser that was previously stopped, using a Locus API response.
|
|
2196
|
+
* Unlike resumeFromMessage(), this does not require metadata/dataSets in the input,
|
|
2197
|
+
* as it fetches all necessary information from Locus via initializeFromGetLociResponse.
|
|
2198
|
+
* @param {LocusDTO} locus - locus object from an API response
|
|
2199
|
+
* @returns {Promise}
|
|
2200
|
+
*/
|
|
2201
|
+
}, {
|
|
2202
|
+
key: "resumeFromApiResponse",
|
|
2203
|
+
value: (function () {
|
|
2204
|
+
var _resumeFromApiResponse = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9(locus) {
|
|
2205
|
+
return _regenerator.default.wrap(function (_context0) {
|
|
2206
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
2207
|
+
case 0:
|
|
2208
|
+
this.state = 'active';
|
|
2209
|
+
this.dataSets = {};
|
|
2210
|
+
_loggerProxy.default.logger.info("HashTreeParser#resumeFromApiResponse --> ".concat(this.debugId, " Resuming HashTreeParser from API response"));
|
|
2211
|
+
_context0.next = 1;
|
|
2212
|
+
return this.initializeFromGetLociResponse(locus);
|
|
2213
|
+
case 1:
|
|
2214
|
+
case "end":
|
|
2215
|
+
return _context0.stop();
|
|
2216
|
+
}
|
|
2217
|
+
}, _callee9, this);
|
|
2218
|
+
}));
|
|
2219
|
+
function resumeFromApiResponse(_x1) {
|
|
2220
|
+
return _resumeFromApiResponse.apply(this, arguments);
|
|
2221
|
+
}
|
|
2222
|
+
return resumeFromApiResponse;
|
|
2223
|
+
}())
|
|
1616
2224
|
}, {
|
|
1617
2225
|
key: "checkForSentinelHttpResponse",
|
|
1618
2226
|
value: function checkForSentinelHttpResponse(error, dataSetName) {
|
|
1619
2227
|
var _error$body;
|
|
2228
|
+
// 404 for any dataset means the locus is no longer available at this URL - could be replaced or ended
|
|
2229
|
+
// if a dataset is just not visible, we would get a 400
|
|
2230
|
+
if (error.statusCode === 404) {
|
|
2231
|
+
_loggerProxy.default.logger.info("HashTreeParser#checkForSentinelHttpResponse --> ".concat(this.debugId, " Received 404 for data set \"").concat(dataSetName, "\", locus not found"));
|
|
2232
|
+
this.stopAllTimers();
|
|
2233
|
+
throw new LocusNotFoundError();
|
|
2234
|
+
}
|
|
1620
2235
|
var isValidDataSetForSentinel = dataSetName === undefined || PossibleSentinelMessageDataSetNames.includes(dataSetName.toLowerCase());
|
|
1621
|
-
if (
|
|
1622
|
-
|
|
2236
|
+
if (error.statusCode === 409 && ((_error$body = error.body) === null || _error$body === void 0 ? void 0 : _error$body.errorCode) === _types2.LocusErrorCodes.LOCUS_INACTIVE && isValidDataSetForSentinel) {
|
|
2237
|
+
var _error$body2;
|
|
2238
|
+
_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"));
|
|
1623
2239
|
this.stopAllTimers();
|
|
1624
2240
|
throw new MeetingEndedError();
|
|
1625
2241
|
}
|
|
@@ -1629,23 +2245,60 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1629
2245
|
* Gets the current hashes from the locus for a specific data set.
|
|
1630
2246
|
* @param {string} dataSetName
|
|
1631
2247
|
* @param {string} currentRootHash
|
|
1632
|
-
* @
|
|
2248
|
+
* @param {Object} [trackingIds] tracking ids for the /hashtree request
|
|
2249
|
+
* @param {string} [trackingIds.requestTrackingId] tracking id forced onto the /hashtree HTTP request header (kept distinct from the /sync request's tracking id)
|
|
2250
|
+
* @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
|
|
2251
|
+
* @returns {Object|null} An object containing the hashes and leaf count, or null if the hashes match and no sync is needed
|
|
1633
2252
|
*/
|
|
1634
2253
|
}, {
|
|
1635
2254
|
key: "getHashesFromLocus",
|
|
1636
|
-
value: function getHashesFromLocus(dataSetName, currentRootHash) {
|
|
2255
|
+
value: function getHashesFromLocus(dataSetName, currentRootHash, trackingIds) {
|
|
1637
2256
|
var _this13 = this;
|
|
2257
|
+
var _ref9 = trackingIds !== null && trackingIds !== void 0 ? trackingIds : {},
|
|
2258
|
+
requestTrackingId = _ref9.requestTrackingId,
|
|
2259
|
+
metricTrackingId = _ref9.metricTrackingId;
|
|
1638
2260
|
_loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(this.debugId, " Requesting hashes for data set \"").concat(dataSetName, "\""));
|
|
1639
2261
|
var dataSet = this.dataSets[dataSetName];
|
|
1640
2262
|
var url = "".concat(dataSet.url, "/hashtree");
|
|
1641
|
-
|
|
1642
|
-
|
|
2263
|
+
if (this.shouldCollectSyncMetrics(dataSetName)) {
|
|
2264
|
+
var _this$callbacks$syncL4;
|
|
2265
|
+
(_this$callbacks$syncL4 = this.callbacks.syncLatencyTracker) === null || _this$callbacks$syncL4 === void 0 ? void 0 : _this$callbacks$syncL4.saveTimestamp({
|
|
2266
|
+
key: 'internal.client.locus.hashtree.request',
|
|
2267
|
+
options: {
|
|
2268
|
+
meetingId: this.syncLatencyMeetingId,
|
|
2269
|
+
dataSetName: dataSetName,
|
|
2270
|
+
trackingId: metricTrackingId
|
|
2271
|
+
}
|
|
2272
|
+
});
|
|
2273
|
+
}
|
|
2274
|
+
return this.webexRequest(_objectSpread({
|
|
2275
|
+
method: _constants2.HTTP_VERBS.GET,
|
|
1643
2276
|
uri: url,
|
|
1644
2277
|
qs: {
|
|
1645
2278
|
rootHash: currentRootHash
|
|
1646
2279
|
}
|
|
1647
|
-
}
|
|
2280
|
+
}, requestTrackingId ? {
|
|
2281
|
+
headers: {
|
|
2282
|
+
trackingid: requestTrackingId
|
|
2283
|
+
}
|
|
2284
|
+
} : {})).then(function (response) {
|
|
1648
2285
|
var _response$body, _response$body2;
|
|
2286
|
+
if (_this13.shouldCollectSyncMetrics(dataSetName)) {
|
|
2287
|
+
var _this13$callbacks$syn;
|
|
2288
|
+
(_this13$callbacks$syn = _this13.callbacks.syncLatencyTracker) === null || _this13$callbacks$syn === void 0 ? void 0 : _this13$callbacks$syn.saveTimestamp({
|
|
2289
|
+
key: 'internal.client.locus.hashtree.response',
|
|
2290
|
+
options: {
|
|
2291
|
+
meetingId: _this13.syncLatencyMeetingId,
|
|
2292
|
+
dataSetName: dataSetName,
|
|
2293
|
+
trackingId: metricTrackingId
|
|
2294
|
+
}
|
|
2295
|
+
});
|
|
2296
|
+
}
|
|
2297
|
+
if (!response.body || (0, _lodash.isEmpty)(response.body)) {
|
|
2298
|
+
// 204 with empty body means our hashes match Locus, no sync needed
|
|
2299
|
+
_loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(_this13.debugId, " Got ").concat(response.statusCode, " with empty body for data set \"").concat(dataSetName, "\", hashes match - no sync needed"));
|
|
2300
|
+
return null;
|
|
2301
|
+
}
|
|
1649
2302
|
var hashes = (_response$body = response.body) === null || _response$body === void 0 ? void 0 : _response$body.hashes;
|
|
1650
2303
|
var dataSetFromResponse = (_response$body2 = response.body) === null || _response$body2 === void 0 ? void 0 : _response$body2.dataSet;
|
|
1651
2304
|
if (!hashes || !(0, _isArray.default)(hashes)) {
|
|
@@ -1660,6 +2313,13 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1660
2313
|
}).catch(function (error) {
|
|
1661
2314
|
_loggerProxy.default.logger.error("HashTreeParser#getHashesFromLocus --> ".concat(_this13.debugId, " Error ").concat(error.statusCode, " fetching hashes for data set \"").concat(dataSetName, "\":"), error);
|
|
1662
2315
|
_this13.checkForSentinelHttpResponse(error, dataSet.name);
|
|
2316
|
+
_metrics.default.sendBehavioralMetric(_constants.default.HASH_TREE_SYNC_FAILURE, {
|
|
2317
|
+
debugId: _this13.debugId,
|
|
2318
|
+
dataSetName: dataSetName,
|
|
2319
|
+
request: 'GET /hashtree',
|
|
2320
|
+
statusCode: error.statusCode,
|
|
2321
|
+
reason: error.message
|
|
2322
|
+
});
|
|
1663
2323
|
throw error;
|
|
1664
2324
|
});
|
|
1665
2325
|
}
|
|
@@ -1668,36 +2328,74 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1668
2328
|
* Sends a sync request to Locus for the specified data set.
|
|
1669
2329
|
*
|
|
1670
2330
|
* @param {InternalDataSet} dataSet The data set to sync.
|
|
1671
|
-
* @param {
|
|
1672
|
-
* @
|
|
2331
|
+
* @param {Object} options Either `{ isInitialization: true }` for init syncs (uses leafCount=1 with empty leaf data) or `{ mismatchedLeavesData }` for normal syncs.
|
|
2332
|
+
* @param {string} [trackingId] tracking id
|
|
2333
|
+
* @returns {Promise<HashTreeMessage | null>}
|
|
1673
2334
|
*/
|
|
1674
2335
|
}, {
|
|
1675
2336
|
key: "sendSyncRequestToLocus",
|
|
1676
|
-
value: function sendSyncRequestToLocus(dataSet,
|
|
2337
|
+
value: function sendSyncRequestToLocus(dataSet, options, trackingId) {
|
|
1677
2338
|
var _this14 = this;
|
|
1678
2339
|
_loggerProxy.default.logger.info("HashTreeParser#sendSyncRequestToLocus --> ".concat(this.debugId, " Sending sync request for data set \"").concat(dataSet.name, "\""));
|
|
2340
|
+
var isInitialization = 'isInitialization' in options;
|
|
1679
2341
|
var url = "".concat(dataSet.url, "/sync");
|
|
1680
2342
|
var body = {
|
|
1681
|
-
leafCount: dataSet.leafCount,
|
|
2343
|
+
leafCount: isInitialization ? 1 : dataSet.leafCount,
|
|
1682
2344
|
leafDataEntries: []
|
|
1683
2345
|
};
|
|
1684
|
-
|
|
1685
|
-
|
|
2346
|
+
if (isInitialization) {
|
|
2347
|
+
// initialization sync: Locus requires leafCount=1 with a single empty leaf
|
|
1686
2348
|
body.leafDataEntries.push({
|
|
1687
|
-
leafIndex:
|
|
1688
|
-
elementIds:
|
|
2349
|
+
leafIndex: 0,
|
|
2350
|
+
elementIds: []
|
|
1689
2351
|
});
|
|
1690
|
-
}
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
2352
|
+
} else {
|
|
2353
|
+
var mismatchedLeavesData = options.mismatchedLeavesData;
|
|
2354
|
+
(0, _keys.default)(mismatchedLeavesData).forEach(function (index) {
|
|
2355
|
+
var leafIndex = (0, _parseInt2.default)(index, 10);
|
|
2356
|
+
body.leafDataEntries.push({
|
|
2357
|
+
leafIndex: leafIndex,
|
|
2358
|
+
elementIds: mismatchedLeavesData[leafIndex]
|
|
2359
|
+
});
|
|
2360
|
+
});
|
|
2361
|
+
}
|
|
2362
|
+
var ourCurrentRootHash = dataSet.hashTree ? dataSet.hashTree.getRootHash() : _constants3.EMPTY_HASH;
|
|
2363
|
+
var shouldCollectMetrics = this.shouldCollectSyncMetrics(dataSet.name, isInitialization);
|
|
2364
|
+
if (shouldCollectMetrics) {
|
|
2365
|
+
var _this$callbacks$syncL5;
|
|
2366
|
+
(_this$callbacks$syncL5 = this.callbacks.syncLatencyTracker) === null || _this$callbacks$syncL5 === void 0 ? void 0 : _this$callbacks$syncL5.saveTimestamp({
|
|
2367
|
+
key: 'internal.client.locus.sync.request',
|
|
2368
|
+
options: {
|
|
2369
|
+
meetingId: this.syncLatencyMeetingId,
|
|
2370
|
+
dataSetName: dataSet.name,
|
|
2371
|
+
trackingId: trackingId
|
|
2372
|
+
}
|
|
2373
|
+
});
|
|
2374
|
+
}
|
|
2375
|
+
return this.webexRequest(_objectSpread(_objectSpread({
|
|
2376
|
+
method: _constants2.HTTP_VERBS.POST,
|
|
1694
2377
|
uri: url,
|
|
1695
2378
|
qs: {
|
|
1696
2379
|
rootHash: ourCurrentRootHash
|
|
1697
|
-
}
|
|
2380
|
+
}
|
|
2381
|
+
}, trackingId ? {
|
|
2382
|
+
headers: {
|
|
2383
|
+
trackingid: trackingId
|
|
2384
|
+
}
|
|
2385
|
+
} : {}), {}, {
|
|
1698
2386
|
body: body
|
|
1699
|
-
}).then(function (resp) {
|
|
1700
|
-
|
|
2387
|
+
})).then(function (resp) {
|
|
2388
|
+
if (shouldCollectMetrics) {
|
|
2389
|
+
var _this14$callbacks$syn;
|
|
2390
|
+
(_this14$callbacks$syn = _this14.callbacks.syncLatencyTracker) === null || _this14$callbacks$syn === void 0 ? void 0 : _this14$callbacks$syn.saveTimestamp({
|
|
2391
|
+
key: 'internal.client.locus.sync.response',
|
|
2392
|
+
options: {
|
|
2393
|
+
meetingId: _this14.syncLatencyMeetingId,
|
|
2394
|
+
dataSetName: dataSet.name,
|
|
2395
|
+
trackingId: trackingId
|
|
2396
|
+
}
|
|
2397
|
+
});
|
|
2398
|
+
}
|
|
1701
2399
|
if (!resp.body || (0, _lodash.isEmpty)(resp.body)) {
|
|
1702
2400
|
_loggerProxy.default.logger.info("HashTreeParser#sendSyncRequestToLocus --> ".concat(_this14.debugId, " Got ").concat(resp.statusCode, " with empty body for sync request for data set \"").concat(dataSet.name, "\", data should arrive via messages"));
|
|
1703
2401
|
return null;
|
|
@@ -1706,6 +2404,13 @@ var HashTreeParser = /*#__PURE__*/function () {
|
|
|
1706
2404
|
}).catch(function (error) {
|
|
1707
2405
|
_loggerProxy.default.logger.error("HashTreeParser#sendSyncRequestToLocus --> ".concat(_this14.debugId, " Error ").concat(error.statusCode, " sending sync request for data set \"").concat(dataSet.name, "\":"), error);
|
|
1708
2406
|
_this14.checkForSentinelHttpResponse(error, dataSet.name);
|
|
2407
|
+
_metrics.default.sendBehavioralMetric(_constants.default.HASH_TREE_SYNC_FAILURE, {
|
|
2408
|
+
debugId: _this14.debugId,
|
|
2409
|
+
dataSetName: dataSet.name,
|
|
2410
|
+
request: 'POST /sync',
|
|
2411
|
+
statusCode: error.statusCode,
|
|
2412
|
+
reason: error.message
|
|
2413
|
+
});
|
|
1709
2414
|
throw error;
|
|
1710
2415
|
});
|
|
1711
2416
|
}
|