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