@fluidframework/task-manager 2.61.0-356312 → 2.61.0
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/CHANGELOG.md +4 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/taskManager.d.ts.map +1 -1
- package/dist/taskManager.js +13 -13
- package/dist/taskManager.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/taskManager.d.ts.map +1 -1
- package/lib/taskManager.js +13 -13
- package/lib/taskManager.js.map +1 -1
- package/package.json +16 -16
- package/src/packageVersion.ts +1 -1
- package/src/taskManager.ts +16 -13
package/CHANGELOG.md
CHANGED
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/task-manager";
|
|
8
|
-
export declare const pkgVersion = "2.61.0
|
|
8
|
+
export declare const pkgVersion = "2.61.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,iCAAiC,CAAC;AACtD,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,iCAAiC,CAAC;AACtD,eAAO,MAAM,UAAU,WAAW,CAAC"}
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/task-manager";
|
|
11
|
-
exports.pkgVersion = "2.61.0
|
|
11
|
+
exports.pkgVersion = "2.61.0";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,8BAA8B,CAAC;AACzC,QAAA,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,8BAA8B,CAAC;AACzC,QAAA,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/task-manager\";\nexport const pkgVersion = \"2.61.0\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taskManager.d.ts","sourceRoot":"","sources":["../src/taskManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,KAAK,EACX,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AAG7F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AACpF,OAAO,EACN,YAAY,EAEZ,MAAM,6CAA6C,CA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B5B;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IAIlB,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAOhD;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;CAkBpE"}
|
package/dist/taskManager.js
CHANGED
|
@@ -17,7 +17,7 @@ function assertIsTaskManagerOperation(op) {
|
|
|
17
17
|
"taskId" in op &&
|
|
18
18
|
typeof op.taskId === "string" &&
|
|
19
19
|
"type" in op &&
|
|
20
|
-
(op.type === "volunteer" || op.type === "abandon" || op.type === "complete"),
|
|
20
|
+
(op.type === "volunteer" || op.type === "abandon" || op.type === "complete"), 0xc3b /* Not a TaskManager operation */);
|
|
21
21
|
}
|
|
22
22
|
const snapshotFileName = "header";
|
|
23
23
|
/**
|
|
@@ -81,9 +81,9 @@ class TaskManagerClass extends internal_5.SharedObject {
|
|
|
81
81
|
this.opWatcher.on("volunteer", (taskId, clientId, local, messageId) => {
|
|
82
82
|
if (local) {
|
|
83
83
|
const latestPendingOps = this.latestPendingOps.get(taskId);
|
|
84
|
-
(0, internal_2.assert)(latestPendingOps !== undefined,
|
|
84
|
+
(0, internal_2.assert)(latestPendingOps !== undefined, 0xc3c /* No pending ops for task */);
|
|
85
85
|
const pendingOp = latestPendingOps.shift();
|
|
86
|
-
(0, internal_2.assert)(pendingOp !== undefined && pendingOp.messageId === messageId,
|
|
86
|
+
(0, internal_2.assert)(pendingOp !== undefined && pendingOp.messageId === messageId, 0xc3d /* Unexpected op */);
|
|
87
87
|
(0, internal_2.assert)(pendingOp.type === "volunteer", 0x07c /* "Unexpected op type" */);
|
|
88
88
|
if (latestPendingOps.length === 0) {
|
|
89
89
|
this.latestPendingOps.delete(taskId);
|
|
@@ -94,9 +94,9 @@ class TaskManagerClass extends internal_5.SharedObject {
|
|
|
94
94
|
this.opWatcher.on("abandon", (taskId, clientId, local, messageId) => {
|
|
95
95
|
if (local) {
|
|
96
96
|
const latestPendingOps = this.latestPendingOps.get(taskId);
|
|
97
|
-
(0, internal_2.assert)(latestPendingOps !== undefined,
|
|
97
|
+
(0, internal_2.assert)(latestPendingOps !== undefined, 0xc3e /* No pending ops for task */);
|
|
98
98
|
const pendingOp = latestPendingOps.shift();
|
|
99
|
-
(0, internal_2.assert)(pendingOp !== undefined && pendingOp.messageId === messageId,
|
|
99
|
+
(0, internal_2.assert)(pendingOp !== undefined && pendingOp.messageId === messageId, 0xc3f /* Unexpected op */);
|
|
100
100
|
(0, internal_2.assert)(pendingOp.type === "abandon", 0x07e /* "Unexpected op type" */);
|
|
101
101
|
if (latestPendingOps.length === 0) {
|
|
102
102
|
this.latestPendingOps.delete(taskId);
|
|
@@ -108,9 +108,9 @@ class TaskManagerClass extends internal_5.SharedObject {
|
|
|
108
108
|
this.opWatcher.on("complete", (taskId, clientId, local, messageId) => {
|
|
109
109
|
if (local) {
|
|
110
110
|
const latestPendingOps = this.latestPendingOps.get(taskId);
|
|
111
|
-
(0, internal_2.assert)(latestPendingOps !== undefined,
|
|
111
|
+
(0, internal_2.assert)(latestPendingOps !== undefined, 0xc40 /* No pending ops for task */);
|
|
112
112
|
const pendingOp = latestPendingOps.shift();
|
|
113
|
-
(0, internal_2.assert)(pendingOp !== undefined && pendingOp.messageId === messageId,
|
|
113
|
+
(0, internal_2.assert)(pendingOp !== undefined && pendingOp.messageId === messageId, 0xc41 /* Unexpected op */);
|
|
114
114
|
(0, internal_2.assert)(pendingOp.type === "complete", 0x401 /* Unexpected op type */);
|
|
115
115
|
if (latestPendingOps.length === 0) {
|
|
116
116
|
this.latestPendingOps.delete(taskId);
|
|
@@ -541,9 +541,9 @@ class TaskManagerClass extends internal_5.SharedObject {
|
|
|
541
541
|
reSubmitCore(content, localOpMetadata) {
|
|
542
542
|
assertIsTaskManagerOperation(content);
|
|
543
543
|
const pendingOps = this.latestPendingOps.get(content.taskId);
|
|
544
|
-
(0, internal_2.assert)(pendingOps !== undefined,
|
|
544
|
+
(0, internal_2.assert)(pendingOps !== undefined, 0xc42 /* No pending ops for task on resubmit attempt */);
|
|
545
545
|
const pendingOpIndex = pendingOps.findIndex((op) => op.messageId === localOpMetadata && op.type === content.type);
|
|
546
|
-
(0, internal_2.assert)(pendingOpIndex !== -1,
|
|
546
|
+
(0, internal_2.assert)(pendingOpIndex !== -1, 0xc43 /* Could not match pending op on resubmit attempt */);
|
|
547
547
|
pendingOps.splice(pendingOpIndex, 1);
|
|
548
548
|
if (pendingOps.length === 0) {
|
|
549
549
|
this.latestPendingOps.delete(content.taskId);
|
|
@@ -673,7 +673,7 @@ class TaskManagerClass extends internal_5.SharedObject {
|
|
|
673
673
|
if (this.isAttached() && !this.connected) {
|
|
674
674
|
return false;
|
|
675
675
|
}
|
|
676
|
-
(0, internal_2.assert)(this.clientId !== undefined,
|
|
676
|
+
(0, internal_2.assert)(this.clientId !== undefined, 0xc44 /* clientId undefined */);
|
|
677
677
|
const inQueue = this.taskQueues.get(taskId)?.includes(this.clientId) ?? false;
|
|
678
678
|
const latestPendingOps = this.latestPendingOps.get(taskId);
|
|
679
679
|
const latestPendingOp = latestPendingOps !== undefined && latestPendingOps.length > 0
|
|
@@ -704,12 +704,12 @@ class TaskManagerClass extends internal_5.SharedObject {
|
|
|
704
704
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}
|
|
705
705
|
*/
|
|
706
706
|
rollback(content, localOpMetadata) {
|
|
707
|
-
(0, internal_2.assert)(typeof localOpMetadata === "number",
|
|
707
|
+
(0, internal_2.assert)(typeof localOpMetadata === "number", 0xc45 /* Expect localOpMetadata to be a number */);
|
|
708
708
|
assertIsTaskManagerOperation(content);
|
|
709
709
|
const latestPendingOps = this.latestPendingOps.get(content.taskId);
|
|
710
|
-
(0, internal_2.assert)(latestPendingOps !== undefined,
|
|
710
|
+
(0, internal_2.assert)(latestPendingOps !== undefined, 0xc46 /* No pending ops when trying to rollback */);
|
|
711
711
|
const pendingOpToRollback = latestPendingOps.pop();
|
|
712
|
-
(0, internal_2.assert)(pendingOpToRollback !== undefined && pendingOpToRollback.messageId === localOpMetadata,
|
|
712
|
+
(0, internal_2.assert)(pendingOpToRollback !== undefined && pendingOpToRollback.messageId === localOpMetadata, 0xc47 /* pending op mismatch */);
|
|
713
713
|
if (latestPendingOps.length === 0) {
|
|
714
714
|
this.latestPendingOps.delete(content.taskId);
|
|
715
715
|
}
|
package/dist/taskManager.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taskManager.js","sourceRoot":"","sources":["../src/taskManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA4D;AAC5D,6EAGwD;AACxD,kEAA6D;AAO7D,0EAA0E;AAC1E,oEAAqE;AAGrE,0EAGqD;AAgCrD,SAAS,4BAA4B,CAAC,EAAW;IAChD,IAAA,iBAAM,EACL,OAAO,EAAE,KAAK,QAAQ;QACrB,EAAE,KAAK,IAAI;QACX,QAAQ,IAAI,EAAE;QACd,OAAO,EAAE,CAAC,MAAM,KAAK,QAAQ;QAC7B,MAAM,IAAI,EAAE;QACZ,CAAC,EAAE,CAAC,IAAI,KAAK,WAAW,IAAI,EAAE,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,CAAC,IAAI,KAAK,UAAU,CAAC,EAC7E,6BAA6B,CAC7B,CAAC;AACH,CAAC;AAED,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;GAEG;AACH,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAE1C;;;;;GAKG;AACH,MAAa,gBACZ,SAAQ,uBAAgC;IAiCxC;;OAEG;IACH,IAAY,QAAQ;QACnB,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC;IACxE,CAAC;IAED;;OAEG;IACH,IAAY,YAAY;QACvB,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC;IAC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5D,IAAA,iBAAM,EAAC,OAAO,eAAe,KAAK,QAAQ,EAAE,uCAAuC,CAAC,CAAC;QACrF,4BAA4B,CAAC,OAAO,CAAC,CAAC;QACtC,MAAM,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACnE,IAAA,iBAAM,EAAC,gBAAgB,KAAK,SAAS,EAAE,wCAAwC,CAAC,CAAC;QACjF,MAAM,mBAAmB,GAAG,gBAAgB,CAAC,GAAG,EAAE,CAAC;QACnD,IAAA,iBAAM,EACL,mBAAmB,KAAK,SAAS,IAAI,mBAAmB,CAAC,SAAS,KAAK,eAAe,EACtF,qBAAqB,CACrB,CAAC;QACF,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC9C,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACvD,CAAC;CACD;AA9yBD,4CA8yBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"@fluid-internal/client-utils\";\nimport {\n\tAttachState,\n\ttype ReadOnlyInfo,\n} from \"@fluidframework/container-definitions/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport { MessageType } from \"@fluidframework/driver-definitions/internal\";\nimport { readAndParse } from \"@fluidframework/driver-utils/internal\";\nimport type { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport {\n\tSharedObject,\n\tcreateSingleBlobSummary,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ITaskManager, ITaskManagerEvents } from \"./interfaces.js\";\n\n/**\n * Description of a task manager operation\n */\ntype ITaskManagerOperation =\n\t| ITaskManagerVolunteerOperation\n\t| ITaskManagerAbandonOperation\n\t| ITaskManagerCompletedOperation;\n\ninterface ITaskManagerVolunteerOperation {\n\ttype: \"volunteer\";\n\ttaskId: string;\n}\n\ninterface ITaskManagerAbandonOperation {\n\ttype: \"abandon\";\n\ttaskId: string;\n}\n\ninterface ITaskManagerCompletedOperation {\n\ttype: \"complete\";\n\ttaskId: string;\n}\n\ninterface IPendingOp {\n\ttype: \"volunteer\" | \"abandon\" | \"complete\";\n\tmessageId: number;\n}\n\nfunction assertIsTaskManagerOperation(op: unknown): asserts op is ITaskManagerOperation {\n\tassert(\n\t\ttypeof op === \"object\" &&\n\t\t\top !== null &&\n\t\t\t\"taskId\" in op &&\n\t\t\ttypeof op.taskId === \"string\" &&\n\t\t\t\"type\" in op &&\n\t\t\t(op.type === \"volunteer\" || op.type === \"abandon\" || op.type === \"complete\"),\n\t\t\"Not a TaskManager operation\",\n\t);\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * Placeholder clientId for detached scenarios.\n */\nconst placeholderClientId = \"placeholder\";\n\n/**\n * {@inheritDoc ITaskManager}\n *\n * @sealed\n * @legacy @beta\n */\nexport class TaskManagerClass\n\textends SharedObject<ITaskManagerEvents>\n\timplements ITaskManager\n{\n\t/**\n\t * Mapping of taskId to a queue of clientIds that are waiting on the task. Maintains the consensus state of the\n\t * queue, even if we know we've submitted an op that should eventually modify the queue.\n\t */\n\tprivate readonly taskQueues = new Map<string, string[]>();\n\n\t// opWatcher emits for every op on this data store. This is just a repackaging of processCore into events.\n\tprivate readonly opWatcher: EventEmitter = new EventEmitter();\n\t// queueWatcher emits an event whenever the consensus state of the task queues changes\n\tprivate readonly queueWatcher: EventEmitter = new EventEmitter();\n\t// abandonWatcher emits an event whenever the local client calls abandon() on a task.\n\tprivate readonly abandonWatcher: EventEmitter = new EventEmitter();\n\t// connectionWatcher emits an event whenever we get connected or disconnected.\n\tprivate readonly connectionWatcher: EventEmitter = new EventEmitter();\n\t// completedWatcher emits an event whenever the local client receives a completed op.\n\tprivate readonly completedWatcher: EventEmitter = new EventEmitter();\n\t// rollbackWatcher emits an event whenever a pending op is rolled back.\n\tprivate readonly rollbackWatcher: EventEmitter = new EventEmitter();\n\n\tprivate nextPendingMessageId: number = 0;\n\t/**\n\t * Tracks the most recent pending op for a given task\n\t */\n\tprivate readonly latestPendingOps = new Map<string, IPendingOp[]>();\n\n\t/**\n\t * Tracks tasks that are this client is currently subscribed to.\n\t */\n\tprivate readonly subscribedTasks = new Set<string>();\n\n\t/**\n\t * Returns the clientId. Will return a placeholder if the runtime is detached and not yet assigned a clientId.\n\t */\n\tprivate get clientId(): string | undefined {\n\t\treturn this.isAttached() ? this.runtime.clientId : placeholderClientId;\n\t}\n\n\t/**\n\t * Returns a ReadOnlyInfo object to determine current read/write permissions.\n\t */\n\tprivate get readOnlyInfo(): ReadOnlyInfo {\n\t\treturn this.deltaManager.readOnlyInfo;\n\t}\n\n\t/**\n\t * Constructs a new task manager. If the object is non-local an id and service interfaces will\n\t * be provided\n\t *\n\t * @param runtime - data store runtime the task queue belongs to\n\t * @param id - optional name of the task queue\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_taskManager_\");\n\n\t\tthis.opWatcher.on(\n\t\t\t\"volunteer\",\n\t\t\t(taskId: string, clientId: string, local: boolean, messageId: number | undefined) => {\n\t\t\t\tif (local) {\n\t\t\t\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\t\t\t\tassert(latestPendingOps !== undefined, \"No pending ops for task\");\n\t\t\t\t\tconst pendingOp = latestPendingOps.shift();\n\t\t\t\t\tassert(\n\t\t\t\t\t\tpendingOp !== undefined && pendingOp.messageId === messageId,\n\t\t\t\t\t\t\"Unexpected op\",\n\t\t\t\t\t);\n\t\t\t\t\tassert(pendingOp.type === \"volunteer\", 0x07c /* \"Unexpected op type\" */);\n\t\t\t\t\tif (latestPendingOps.length === 0) {\n\t\t\t\t\t\tthis.latestPendingOps.delete(taskId);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.addClientToQueue(taskId, clientId);\n\t\t\t},\n\t\t);\n\n\t\tthis.opWatcher.on(\n\t\t\t\"abandon\",\n\t\t\t(taskId: string, clientId: string, local: boolean, messageId: number | undefined) => {\n\t\t\t\tif (local) {\n\t\t\t\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\t\t\t\tassert(latestPendingOps !== undefined, \"No pending ops for task\");\n\t\t\t\t\tconst pendingOp = latestPendingOps.shift();\n\t\t\t\t\tassert(\n\t\t\t\t\t\tpendingOp !== undefined && pendingOp.messageId === messageId,\n\t\t\t\t\t\t\"Unexpected op\",\n\t\t\t\t\t);\n\t\t\t\t\tassert(pendingOp.type === \"abandon\", 0x07e /* \"Unexpected op type\" */);\n\t\t\t\t\tif (latestPendingOps.length === 0) {\n\t\t\t\t\t\tthis.latestPendingOps.delete(taskId);\n\t\t\t\t\t}\n\t\t\t\t\tthis.abandonWatcher.emit(\"abandon\", taskId, messageId);\n\t\t\t\t}\n\n\t\t\t\tthis.removeClientFromQueue(taskId, clientId);\n\t\t\t},\n\t\t);\n\n\t\tthis.opWatcher.on(\n\t\t\t\"complete\",\n\t\t\t(taskId: string, clientId: string, local: boolean, messageId: number | undefined) => {\n\t\t\t\tif (local) {\n\t\t\t\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\t\t\t\tassert(latestPendingOps !== undefined, \"No pending ops for task\");\n\t\t\t\t\tconst pendingOp = latestPendingOps.shift();\n\t\t\t\t\tassert(\n\t\t\t\t\t\tpendingOp !== undefined && pendingOp.messageId === messageId,\n\t\t\t\t\t\t\"Unexpected op\",\n\t\t\t\t\t);\n\t\t\t\t\tassert(pendingOp.type === \"complete\", 0x401 /* Unexpected op type */);\n\t\t\t\t\tif (latestPendingOps.length === 0) {\n\t\t\t\t\t\tthis.latestPendingOps.delete(taskId);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.taskQueues.delete(taskId);\n\t\t\t\tthis.completedWatcher.emit(\"completed\", taskId, messageId);\n\t\t\t\tthis.emit(\"completed\", taskId);\n\t\t\t},\n\t\t);\n\n\t\truntime.getQuorum().on(\"removeMember\", (clientId: string) => {\n\t\t\tthis.removeClientFromAllQueues(clientId);\n\t\t});\n\n\t\tthis.queueWatcher.on(\n\t\t\t\"queueChange\",\n\t\t\t(taskId: string, oldLockHolder: string, newLockHolder: string) => {\n\t\t\t\t// If oldLockHolder is placeholderClientId we need to emit the task was lost during the attach process\n\t\t\t\tif (oldLockHolder === placeholderClientId) {\n\t\t\t\t\tthis.emit(\"lost\", taskId);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Exit early if we are still catching up on reconnect -- we can't be the leader yet anyway.\n\t\t\t\tif (this.clientId === undefined) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (oldLockHolder !== this.clientId && newLockHolder === this.clientId) {\n\t\t\t\t\tthis.emit(\"assigned\", taskId);\n\t\t\t\t} else if (oldLockHolder === this.clientId && newLockHolder !== this.clientId) {\n\t\t\t\t\tthis.emit(\"lost\", taskId);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tthis.connectionWatcher.on(\"disconnect\", () => {\n\t\t\tassert(this.clientId !== undefined, 0x1d3 /* \"Missing client id on disconnect\" */);\n\n\t\t\t// Emit \"lost\" for any tasks we were assigned to.\n\t\t\tfor (const [taskId, clientQueue] of this.taskQueues.entries()) {\n\t\t\t\tif (this.isAttached() && clientQueue[0] === this.clientId) {\n\t\t\t\t\tthis.emit(\"lost\", taskId);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Remove this client from all queues to reflect the new state, since being disconnected automatically removes\n\t\t\t// this client from all queues.\n\t\t\tthis.removeClientFromAllQueues(this.clientId);\n\t\t});\n\t}\n\n\tprivate submitVolunteerOp(taskId: string): void {\n\t\tconst op: ITaskManagerVolunteerOperation = {\n\t\t\ttype: \"volunteer\",\n\t\t\ttaskId,\n\t\t};\n\t\tconst pendingOp: IPendingOp = {\n\t\t\ttype: \"volunteer\",\n\t\t\tmessageId: this.nextPendingMessageId++,\n\t\t};\n\t\tthis.submitLocalMessage(op, pendingOp.messageId);\n\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\tif (latestPendingOps === undefined) {\n\t\t\tthis.latestPendingOps.set(taskId, [pendingOp]);\n\t\t} else {\n\t\t\tlatestPendingOps.push(pendingOp);\n\t\t}\n\t}\n\n\tprivate submitAbandonOp(taskId: string): void {\n\t\tconst op: ITaskManagerAbandonOperation = {\n\t\t\ttype: \"abandon\",\n\t\t\ttaskId,\n\t\t};\n\t\tconst pendingOp: IPendingOp = {\n\t\t\ttype: \"abandon\",\n\t\t\tmessageId: this.nextPendingMessageId++,\n\t\t};\n\t\tthis.submitLocalMessage(op, pendingOp.messageId);\n\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\tif (latestPendingOps === undefined) {\n\t\t\tthis.latestPendingOps.set(taskId, [pendingOp]);\n\t\t} else {\n\t\t\tlatestPendingOps.push(pendingOp);\n\t\t}\n\t}\n\n\tprivate submitCompleteOp(taskId: string): void {\n\t\tconst op: ITaskManagerCompletedOperation = {\n\t\t\ttype: \"complete\",\n\t\t\ttaskId,\n\t\t};\n\t\tconst pendingOp: IPendingOp = {\n\t\t\ttype: \"complete\",\n\t\t\tmessageId: this.nextPendingMessageId++,\n\t\t};\n\n\t\tthis.submitLocalMessage(op, pendingOp.messageId);\n\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\tif (latestPendingOps === undefined) {\n\t\t\tthis.latestPendingOps.set(taskId, [pendingOp]);\n\t\t} else {\n\t\t\tlatestPendingOps.push(pendingOp);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.volunteerForTask}\n\t */\n\tpublic async volunteerForTask(taskId: string): Promise<boolean> {\n\t\t// If we are both queued and assigned, then we have the lock and do not\n\t\t// have any pending abandon/complete ops. In this case we can resolve\n\t\t// true immediately.\n\t\tif (this.queuedOptimistically(taskId) && this.assigned(taskId)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (this.readOnlyInfo.readonly === true) {\n\t\t\tconst error =\n\t\t\t\tthis.readOnlyInfo.permissions === true\n\t\t\t\t\t? new Error(\"Attempted to volunteer with read-only permissions\")\n\t\t\t\t\t: new Error(\"Attempted to volunteer in read-only state\");\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (this.isDetached()) {\n\t\t\t// Simulate auto-ack in detached scenario\n\t\t\tassert(this.clientId !== undefined, 0x472 /* clientId should not be undefined */);\n\t\t\tthis.addClientToQueue(taskId, this.clientId);\n\t\t\treturn true;\n\t\t}\n\n\t\tif (!this.connected) {\n\t\t\tthrow new Error(\"Attempted to volunteer in disconnected state\");\n\t\t}\n\n\t\t// This promise works even if we already have an outstanding volunteer op.\n\t\tconst lockAcquireP = new Promise<boolean>((resolve, reject) => {\n\t\t\t// If we don't send an op (meaning the latest pending op is \"volunteer\"), nextPendingMessageId\n\t\t\t// will be greater than that prior \"volunteer\" op's messageId. This is OK because\n\t\t\t// we only use it to filter stale abandon/complete, and not when determining if we\n\t\t\t// acquired the lock.\n\t\t\tconst nextPendingMessageId = this.nextPendingMessageId;\n\t\t\tconst setupListeners = (): void => {\n\t\t\t\tthis.queueWatcher.on(\"queueChange\", checkIfAcquiredLock);\n\t\t\t\tthis.abandonWatcher.on(\"abandon\", checkIfAbandoned);\n\t\t\t\tthis.connectionWatcher.on(\"disconnect\", rejectOnDisconnect);\n\t\t\t\tthis.completedWatcher.on(\"completed\", checkIfCompleted);\n\t\t\t\tthis.rollbackWatcher.on(\"rollback\", checkIfRolledBack);\n\t\t\t};\n\t\t\tconst removeListeners = (): void => {\n\t\t\t\tthis.queueWatcher.off(\"queueChange\", checkIfAcquiredLock);\n\t\t\t\tthis.abandonWatcher.off(\"abandon\", checkIfAbandoned);\n\t\t\t\tthis.connectionWatcher.off(\"disconnect\", rejectOnDisconnect);\n\t\t\t\tthis.completedWatcher.off(\"completed\", checkIfCompleted);\n\t\t\t\tthis.rollbackWatcher.off(\"rollback\", checkIfRolledBack);\n\t\t\t};\n\n\t\t\tconst checkIfAcquiredLock = (eventTaskId: string): void => {\n\t\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Also check pending ops here because it's possible we are currently in the queue from a previous\n\t\t\t\t// lock attempt, but have an outstanding abandon AND the outstanding volunteer for this lock attempt.\n\t\t\t\t// If we reach the head of the queue based on the previous lock attempt, we don't want to resolve.\n\t\t\t\tif (this.assigned(taskId)) {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tresolve(true);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst checkIfAbandoned = (eventTaskId: string, messageId: number | undefined): void => {\n\t\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (messageId !== undefined && messageId <= nextPendingMessageId) {\n\t\t\t\t\t// Ignore abandon events that were for abandon ops that were sent prior to our current volunteer attempt.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tremoveListeners();\n\t\t\t\treject(new Error(\"Abandoned before acquiring task assignment\"));\n\t\t\t};\n\n\t\t\tconst rejectOnDisconnect = (): void => {\n\t\t\t\tremoveListeners();\n\t\t\t\treject(new Error(\"Disconnected before acquiring task assignment\"));\n\t\t\t};\n\n\t\t\tconst checkIfCompleted = (eventTaskId: string, messageId: number | undefined): void => {\n\t\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (messageId !== undefined && messageId <= nextPendingMessageId) {\n\t\t\t\t\t// Ignore abandon events that were for abandon ops that were sent prior to our current volunteer attempt.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tremoveListeners();\n\t\t\t\tresolve(false);\n\t\t\t};\n\n\t\t\tconst checkIfRolledBack = (eventTaskId: string): void => {\n\t\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tremoveListeners();\n\t\t\t\tresolve(false);\n\t\t\t};\n\n\t\t\tsetupListeners();\n\t\t});\n\n\t\tif (!this.queuedOptimistically(taskId)) {\n\t\t\t// Only send the volunteer op if we are not already queued.\n\t\t\tthis.submitVolunteerOp(taskId);\n\t\t}\n\t\treturn lockAcquireP;\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.subscribeToTask}\n\t */\n\tpublic subscribeToTask(taskId: string): void {\n\t\tif (this.subscribed(taskId)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.readOnlyInfo.readonly === true && this.readOnlyInfo.permissions === true) {\n\t\t\tthrow new Error(\"Attempted to subscribe with read-only permissions\");\n\t\t}\n\n\t\tlet volunteerOpMessageId: number | undefined;\n\n\t\tconst submitVolunteerOp = (): void => {\n\t\t\tvolunteerOpMessageId = this.nextPendingMessageId;\n\t\t\tthis.submitVolunteerOp(taskId);\n\t\t};\n\n\t\tconst setupListeners = (): void => {\n\t\t\tthis.abandonWatcher.on(\"abandon\", checkIfAbandoned);\n\t\t\tthis.connectionWatcher.on(\"disconnect\", disconnectHandler);\n\t\t\tthis.completedWatcher.on(\"completed\", checkIfCompleted);\n\t\t\tthis.rollbackWatcher.on(\"rollback\", checkIfRolledBack);\n\t\t};\n\t\tconst removeListeners = (): void => {\n\t\t\tthis.abandonWatcher.off(\"abandon\", checkIfAbandoned);\n\t\t\tthis.connectionWatcher.off(\"disconnect\", disconnectHandler);\n\t\t\tthis.connectionWatcher.off(\"connect\", submitVolunteerOp);\n\t\t\tthis.completedWatcher.off(\"completed\", checkIfCompleted);\n\t\t\tthis.rollbackWatcher.off(\"rollback\", checkIfRolledBack);\n\t\t};\n\n\t\tconst disconnectHandler = (): void => {\n\t\t\t// Wait to be connected again and then re-submit volunteer op\n\t\t\tthis.connectionWatcher.once(\"connect\", submitVolunteerOp);\n\t\t};\n\n\t\tconst checkIfAbandoned = (eventTaskId: string, messageId: number | undefined): void => {\n\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// abandonWatcher emits twice for a local abandon() call. When initially called it\n\t\t\t// will emit with undefined messageId. It will emit a second time when the op is\n\t\t\t// ack'd and processed, this time with the messageId for the ack.\n\t\t\t// This condition accounts ensures we don't ignore the initial abandon() emit and\n\t\t\t// only ignore emits associated with ack'd abandon ops that were sent prior to the\n\t\t\t// current volunteer attempt.\n\t\t\tif (\n\t\t\t\tmessageId !== undefined &&\n\t\t\t\tvolunteerOpMessageId !== undefined &&\n\t\t\t\tmessageId <= volunteerOpMessageId\n\t\t\t) {\n\t\t\t\t// Ignore abandon events that were for abandon ops that were sent prior to our current volunteer attempt.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tremoveListeners();\n\t\t\tthis.subscribedTasks.delete(taskId);\n\t\t};\n\n\t\tconst checkIfCompleted = (eventTaskId: string, messageId: number | undefined): void => {\n\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tmessageId !== undefined &&\n\t\t\t\tvolunteerOpMessageId !== undefined &&\n\t\t\t\tmessageId <= volunteerOpMessageId\n\t\t\t) {\n\t\t\t\t// Ignore abandon events that were for abandon ops that were sent prior to our current volunteer attempt.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tremoveListeners();\n\t\t\tthis.subscribedTasks.delete(taskId);\n\t\t};\n\n\t\tconst checkIfRolledBack = (eventTaskId: string): void => {\n\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tremoveListeners();\n\t\t\tthis.subscribedTasks.delete(taskId);\n\t\t};\n\n\t\tsetupListeners();\n\n\t\tif (this.isDetached()) {\n\t\t\t// Simulate auto-ack in detached scenario\n\t\t\tassert(this.clientId !== undefined, 0x473 /* clientId should not be undefined */);\n\t\t\tthis.addClientToQueue(taskId, this.clientId);\n\t\t\t// Because we volunteered with placeholderClientId, we need to wait for when we attach and are assigned\n\t\t\t// a real clientId. At that point we should re-enter the queue with a real volunteer op (assuming we are\n\t\t\t// connected).\n\t\t\tthis.runtime.once(\"attached\", () => {\n\t\t\t\t// We call scrubClientsNotInQuorum() in case our clientId changed during the attach process.\n\t\t\t\tthis.scrubClientsNotInQuorum();\n\t\t\t\tif (this.connected) {\n\t\t\t\t\tsubmitVolunteerOp();\n\t\t\t\t} else {\n\t\t\t\t\tthis.connectionWatcher.once(\"connect\", submitVolunteerOp);\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (!this.connected) {\n\t\t\t// If we are disconnected (and attached), wait to be connected and submit volunteer op\n\t\t\tdisconnectHandler();\n\t\t} else if (!this.queuedOptimistically(taskId)) {\n\t\t\t// We don't need to send a second volunteer op if we just sent one.\n\t\t\tsubmitVolunteerOp();\n\t\t}\n\t\tthis.subscribedTasks.add(taskId);\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.abandon}\n\t */\n\tpublic abandon(taskId: string): void {\n\t\t// Always allow abandon if the client is subscribed to allow clients to unsubscribe while disconnected.\n\t\t// Otherwise, we should check to make sure the client is optimistically queued for the task before trying to abandon.\n\t\tif (!this.queuedOptimistically(taskId) && !this.subscribed(taskId)) {\n\t\t\t// Nothing to do\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.isDetached()) {\n\t\t\t// Simulate auto-ack in detached scenario\n\t\t\tassert(this.clientId !== undefined, 0x474 /* clientId is undefined */);\n\t\t\tthis.removeClientFromQueue(taskId, this.clientId);\n\t\t\tthis.abandonWatcher.emit(\"abandon\", taskId);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitAbandonOp(taskId);\n\t\tthis.abandonWatcher.emit(\"abandon\", taskId);\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.assigned}\n\t */\n\tpublic assigned(taskId: string): boolean {\n\t\tif (this.isAttached() && !this.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst currentAssignee = this.taskQueues.get(taskId)?.[0];\n\t\treturn currentAssignee !== undefined && currentAssignee === this.clientId;\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.queued}\n\t */\n\tpublic queued(taskId: string): boolean {\n\t\tif (this.isAttached() && !this.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\tassert(this.clientId !== undefined, 0x07f /* \"clientId undefined\" */);\n\t\treturn this.taskQueues.get(taskId)?.includes(this.clientId) ?? false;\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.subscribed}\n\t */\n\tpublic subscribed(taskId: string): boolean {\n\t\treturn this.subscribedTasks.has(taskId);\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.complete}\n\t */\n\tpublic complete(taskId: string): void {\n\t\tif (!this.assigned(taskId)) {\n\t\t\tthrow new Error(\"Attempted to mark task as complete while not being assigned\");\n\t\t}\n\n\t\t// If we are detached we will simulate auto-ack for the complete op. Therefore we only need to send the op if\n\t\t// we are attached. Additionally, we don't need to check if we are connected while detached.\n\t\tif (this.isDetached()) {\n\t\t\tthis.taskQueues.delete(taskId);\n\t\t\tthis.completedWatcher.emit(\"completed\", taskId);\n\t\t\tthis.emit(\"completed\", taskId);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!this.connected) {\n\t\t\tthrow new Error(\"Attempted to complete task in disconnected state\");\n\t\t}\n\t\tthis.submitCompleteOp(taskId);\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.canVolunteer}\n\t */\n\tpublic canVolunteer(): boolean {\n\t\t// A client can volunteer for a task if it's both connected to the delta stream and in write mode.\n\t\t// this.connected reflects that condition, but is unintuitive and may be changed in the future. This API allows\n\t\t// us to make changes to this.connected without affecting our guidance on how to check if a client is eligible\n\t\t// to volunteer for a task.\n\t\treturn this.connected;\n\t}\n\n\t/**\n\t * Create a summary for the task manager\n\t *\n\t * @returns the summary of the current state of the task manager\n\t */\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tif (this.runtime.clientId === undefined) {\n\t\t\t// If the runtime has still not been assigned a clientId, we should not summarize with the placeholder\n\t\t\t// clientIds and instead remove them from the queues and require the client to re-volunteer when assigned\n\t\t\t// a new clientId.\n\t\t\tthis.removeClientFromAllQueues(placeholderClientId);\n\t\t} else {\n\t\t\t// If the runtime has been assigned an actual clientId by now, we can replace the placeholder clientIds\n\t\t\t// and maintain the task assignment.\n\t\t\tthis.replacePlaceholderInAllQueues();\n\t\t}\n\n\t\t// Only include tasks if there are clients in the queue.\n\t\tconst filteredMap = new Map<string, string[]>();\n\t\tfor (const [taskId, queue] of this.taskQueues) {\n\t\t\tif (queue.length > 0) {\n\t\t\t\tfilteredMap.set(taskId, queue);\n\t\t\t}\n\t\t}\n\t\tconst content = [...filteredMap.entries()];\n\t\treturn createSingleBlobSummary(snapshotFileName, JSON.stringify(content));\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst content = await readAndParse<[string, string[]][]>(storage, snapshotFileName);\n\t\tfor (const [taskId, clientIdQueue] of content) {\n\t\t\tthis.taskQueues.set(taskId, clientIdQueue);\n\t\t}\n\t\tthis.scrubClientsNotInQuorum();\n\t}\n\n\t/***/\n\tprotected initializeLocalCore(): void {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n\t */\n\tprotected onDisconnect(): void {\n\t\tthis.connectionWatcher.emit(\"disconnect\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onConnect}\n\t */\n\tprotected onConnect(): void {\n\t\tthis.connectionWatcher.emit(\"connect\");\n\t}\n\n\t/**\n\t * Override resubmit core to avoid resubmission on reconnect. On disconnect we accept our removal from the\n\t * queues, and leave it up to the user to decide whether they want to attempt to re-enter a queue on reconnect.\n\t * However, we do need to update latestPendingOps to account for the ops we will no longer be processing.\n\t */\n\tprotected reSubmitCore(content: unknown, localOpMetadata: number): void {\n\t\tassertIsTaskManagerOperation(content);\n\t\tconst pendingOps = this.latestPendingOps.get(content.taskId);\n\t\tassert(pendingOps !== undefined, \"No pending ops for task on resubmit attempt\");\n\t\tconst pendingOpIndex = pendingOps.findIndex(\n\t\t\t(op) => op.messageId === localOpMetadata && op.type === content.type,\n\t\t);\n\t\tassert(pendingOpIndex !== -1, \"Could not match pending op on resubmit attempt\");\n\t\tpendingOps.splice(pendingOpIndex, 1);\n\t\tif (pendingOps.length === 0) {\n\t\t\tthis.latestPendingOps.delete(content.taskId);\n\t\t}\n\t}\n\n\t/**\n\t * Process a task manager operation\n\t *\n\t * @param message - the message to prepare\n\t * @param local - whether the message was sent by the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t */\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: number | undefined,\n\t): void {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\tif (message.type === MessageType.Operation) {\n\t\t\tconst op = message.contents as ITaskManagerOperation;\n\t\t\tconst messageId = localOpMetadata;\n\n\t\t\tswitch (op.type) {\n\t\t\t\tcase \"volunteer\": {\n\t\t\t\t\tthis.opWatcher.emit(\"volunteer\", op.taskId, message.clientId, local, messageId);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"abandon\": {\n\t\t\t\t\tthis.opWatcher.emit(\"abandon\", op.taskId, message.clientId, local, messageId);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"complete\": {\n\t\t\t\t\tthis.opWatcher.emit(\"complete\", op.taskId, message.clientId, local, messageId);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate addClientToQueue(taskId: string, clientId: string): void {\n\t\t// Ensure that the clientId exists in the quorum, or it is placeholderClientId (detached scenario)\n\t\tif (\n\t\t\tthis.runtime.getQuorum().getMembers().has(clientId) ||\n\t\t\tthis.clientId === placeholderClientId\n\t\t) {\n\t\t\t// Create the queue if it doesn't exist, and push the client on the back.\n\t\t\tlet clientQueue = this.taskQueues.get(taskId);\n\t\t\tif (clientQueue === undefined) {\n\t\t\t\tclientQueue = [];\n\t\t\t\tthis.taskQueues.set(taskId, clientQueue);\n\t\t\t}\n\n\t\t\tif (clientQueue.includes(clientId)) {\n\t\t\t\t// We shouldn't re-add the client if it's already in the queue.\n\t\t\t\t// This may be possible in scenarios where a client was added in\n\t\t\t\t// while detached.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst oldLockHolder = clientQueue[0];\n\t\t\tclientQueue.push(clientId);\n\t\t\tconst newLockHolder = clientQueue[0];\n\t\t\tif (newLockHolder !== oldLockHolder) {\n\t\t\t\tthis.queueWatcher.emit(\"queueChange\", taskId, oldLockHolder, newLockHolder);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate removeClientFromQueue(taskId: string, clientId: string): void {\n\t\tconst clientQueue = this.taskQueues.get(taskId);\n\t\tif (clientQueue === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst oldLockHolder =\n\t\t\tclientId === placeholderClientId ? placeholderClientId : clientQueue[0];\n\t\tconst clientIdIndex = clientQueue.indexOf(clientId);\n\t\tif (clientIdIndex !== -1) {\n\t\t\tclientQueue.splice(clientIdIndex, 1);\n\t\t\t// Clean up the queue if there are no more clients in it.\n\t\t\tif (clientQueue.length === 0) {\n\t\t\t\tthis.taskQueues.delete(taskId);\n\t\t\t}\n\t\t}\n\t\tconst newLockHolder = clientQueue[0];\n\t\tif (newLockHolder !== oldLockHolder) {\n\t\t\tthis.queueWatcher.emit(\"queueChange\", taskId, oldLockHolder, newLockHolder);\n\t\t}\n\t}\n\n\tprivate removeClientFromAllQueues(clientId: string): void {\n\t\tfor (const taskId of this.taskQueues.keys()) {\n\t\t\tthis.removeClientFromQueue(taskId, clientId);\n\t\t}\n\t}\n\n\t/**\n\t * Will replace all instances of the placeholderClientId with the current clientId. This should only be called when\n\t * transitioning from detached to attached and this.runtime.clientId is defined.\n\t */\n\tprivate replacePlaceholderInAllQueues(): void {\n\t\tassert(\n\t\t\tthis.runtime.clientId !== undefined,\n\t\t\t0x475 /* this.runtime.clientId should be defined */,\n\t\t);\n\t\tfor (const clientQueue of this.taskQueues.values()) {\n\t\t\tconst clientIdIndex = clientQueue.indexOf(placeholderClientId);\n\t\t\tif (clientIdIndex !== -1) {\n\t\t\t\tif (clientQueue.includes(this.runtime.clientId)) {\n\t\t\t\t\t// If the real clientId is already in the queue, just remove the placeholder.\n\t\t\t\t\tclientQueue.splice(clientIdIndex, 1);\n\t\t\t\t} else {\n\t\t\t\t\tclientQueue[clientIdIndex] = this.runtime.clientId;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// This seems like it should be unnecessary if we can trust to receive the join/leave messages and\n\t// also have an accurate snapshot.\n\tprivate scrubClientsNotInQuorum(): void {\n\t\tconst quorum = this.runtime.getQuorum();\n\t\tfor (const [taskId, clientQueue] of this.taskQueues) {\n\t\t\tconst filteredClientQueue = clientQueue.filter(\n\t\t\t\t(clientId) => quorum.getMember(clientId) !== undefined,\n\t\t\t);\n\t\t\tif (clientQueue.length !== filteredClientQueue.length) {\n\t\t\t\tif (filteredClientQueue.length === 0) {\n\t\t\t\t\tthis.taskQueues.delete(taskId);\n\t\t\t\t} else {\n\t\t\t\t\tthis.taskQueues.set(taskId, filteredClientQueue);\n\t\t\t\t}\n\t\t\t\tthis.queueWatcher.emit(\"queueChange\", taskId);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Checks whether this client is currently assigned or in queue to become assigned, while also accounting\n\t * for the latest pending ops.\n\t */\n\tprivate queuedOptimistically(taskId: string): boolean {\n\t\tif (this.isAttached() && !this.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\tassert(this.clientId !== undefined, 0x07f /* \"clientId undefined\" */);\n\n\t\tconst inQueue = this.taskQueues.get(taskId)?.includes(this.clientId) ?? false;\n\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\n\t\tconst latestPendingOp =\n\t\t\tlatestPendingOps !== undefined && latestPendingOps.length > 0\n\t\t\t\t? latestPendingOps[latestPendingOps.length - 1]\n\t\t\t\t: undefined;\n\t\tconst isPendingVolunteer = latestPendingOp?.type === \"volunteer\";\n\t\tconst isPendingAbandonOrComplete =\n\t\t\tlatestPendingOp?.type === \"abandon\" || latestPendingOp?.type === \"complete\";\n\t\t// We return true if the client is either in queue already or the latest pending op for this task is a volunteer op.\n\t\t// But we should always return false if the latest pending op is an abandon or complete op.\n\t\treturn (inQueue && !isPendingAbandonOrComplete) || isPendingVolunteer;\n\t}\n\n\t/**\n\t * Returns true if the client is detached.\n\t * This is distinct from !this.isAttached() because `isAttached()` also checks if `this._isBoundToContext`\n\t * is true. We use `isDetached()` to determine if we should simulate auto-ack behavior for ops, which is\n\t * mainly concerned with if we have been assigned a real clientId yet.\n\t */\n\tprivate isDetached(): boolean {\n\t\treturn this.runtime.attachState === AttachState.Detached;\n\t}\n\n\tprotected applyStashedOp(content: unknown): void {\n\t\t// We don't apply any stashed ops since during the rehydration process. Since we lose any assigned tasks\n\t\t// during rehydration we cannot be assigned any tasks. Additionally, without the in-memory state of the\n\t\t// previous dds, we also cannot re-volunteer based on a previous subscribeToTask() call. Since we are\n\t\t// unable to be assigned to any tasks, there is no reason to process abandon/complete ops either.\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n\t */\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tassert(typeof localOpMetadata === \"number\", \"Expect localOpMetadata to be a number\");\n\t\tassertIsTaskManagerOperation(content);\n\t\tconst latestPendingOps = this.latestPendingOps.get(content.taskId);\n\t\tassert(latestPendingOps !== undefined, \"No pending ops when trying to rollback\");\n\t\tconst pendingOpToRollback = latestPendingOps.pop();\n\t\tassert(\n\t\t\tpendingOpToRollback !== undefined && pendingOpToRollback.messageId === localOpMetadata,\n\t\t\t\"pending op mismatch\",\n\t\t);\n\t\tif (latestPendingOps.length === 0) {\n\t\t\tthis.latestPendingOps.delete(content.taskId);\n\t\t}\n\t\tthis.rollbackWatcher.emit(\"rollback\", content.taskId);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"taskManager.js","sourceRoot":"","sources":["../src/taskManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA4D;AAC5D,6EAGwD;AACxD,kEAA6D;AAO7D,0EAA0E;AAC1E,oEAAqE;AAGrE,0EAGqD;AAgCrD,SAAS,4BAA4B,CAAC,EAAW;IAChD,IAAA,iBAAM,EACL,OAAO,EAAE,KAAK,QAAQ;QACrB,EAAE,KAAK,IAAI;QACX,QAAQ,IAAI,EAAE;QACd,OAAO,EAAE,CAAC,MAAM,KAAK,QAAQ;QAC7B,MAAM,IAAI,EAAE;QACZ,CAAC,EAAE,CAAC,IAAI,KAAK,WAAW,IAAI,EAAE,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,CAAC,IAAI,KAAK,UAAU,CAAC,EAC7E,KAAK,CAAC,iCAAiC,CACvC,CAAC;AACH,CAAC;AAED,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;GAEG;AACH,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAE1C;;;;;GAKG;AACH,MAAa,gBACZ,SAAQ,uBAAgC;IAiCxC;;OAEG;IACH,IAAY,QAAQ;QACnB,OAAO,IAAI,CAAC,UAAU,EA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,kBAAkB,CAAC;IACvE,CAAC;IAED;;;;;OAKG;IACK,UAAU;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,KAAK,sBAAW,CAAC,QAAQ,CAAC;IAC1D,CAAC;IAES,cAAc,CAAC,OAAgB;QACxC,wGAAwG;QACxG,uGAAuG;QACvG,qGAAqG;QACrG,iGAAiG;IAClG,CAAC;IAED;;OAEG;IACO,QAAQ,CAAC,OAAgB,EAAE,eAAwB;QAC5D,IAAA,iBAAM,EACL,OAAO,eAAe,KAAK,QAAQ,EACnC,KAAK,CAAC,2CAA2C,CACjD,CAAC;QACF,4BAA4B,CAAC,OAAO,CAAC,CAAC;QACtC,MAAM,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACnE,IAAA,iBAAM,EAAC,gBAAgB,KAAK,SAAS,EAAE,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAC3F,MAAM,mBAAmB,GAAG,gBAAgB,CAAC,GAAG,EAAE,CAAC;QACnD,IAAA,iBAAM,EACL,mBAAmB,KAAK,SAAS,IAAI,mBAAmB,CAAC,SAAS,KAAK,eAAe,EACtF,KAAK,CAAC,yBAAyB,CAC/B,CAAC;QACF,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC9C,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACvD,CAAC;CACD;AAjzBD,4CAizBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"@fluid-internal/client-utils\";\nimport {\n\tAttachState,\n\ttype ReadOnlyInfo,\n} from \"@fluidframework/container-definitions/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport { MessageType } from \"@fluidframework/driver-definitions/internal\";\nimport { readAndParse } from \"@fluidframework/driver-utils/internal\";\nimport type { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport {\n\tSharedObject,\n\tcreateSingleBlobSummary,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ITaskManager, ITaskManagerEvents } from \"./interfaces.js\";\n\n/**\n * Description of a task manager operation\n */\ntype ITaskManagerOperation =\n\t| ITaskManagerVolunteerOperation\n\t| ITaskManagerAbandonOperation\n\t| ITaskManagerCompletedOperation;\n\ninterface ITaskManagerVolunteerOperation {\n\ttype: \"volunteer\";\n\ttaskId: string;\n}\n\ninterface ITaskManagerAbandonOperation {\n\ttype: \"abandon\";\n\ttaskId: string;\n}\n\ninterface ITaskManagerCompletedOperation {\n\ttype: \"complete\";\n\ttaskId: string;\n}\n\ninterface IPendingOp {\n\ttype: \"volunteer\" | \"abandon\" | \"complete\";\n\tmessageId: number;\n}\n\nfunction assertIsTaskManagerOperation(op: unknown): asserts op is ITaskManagerOperation {\n\tassert(\n\t\ttypeof op === \"object\" &&\n\t\t\top !== null &&\n\t\t\t\"taskId\" in op &&\n\t\t\ttypeof op.taskId === \"string\" &&\n\t\t\t\"type\" in op &&\n\t\t\t(op.type === \"volunteer\" || op.type === \"abandon\" || op.type === \"complete\"),\n\t\t0xc3b /* Not a TaskManager operation */,\n\t);\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * Placeholder clientId for detached scenarios.\n */\nconst placeholderClientId = \"placeholder\";\n\n/**\n * {@inheritDoc ITaskManager}\n *\n * @sealed\n * @legacy @beta\n */\nexport class TaskManagerClass\n\textends SharedObject<ITaskManagerEvents>\n\timplements ITaskManager\n{\n\t/**\n\t * Mapping of taskId to a queue of clientIds that are waiting on the task. Maintains the consensus state of the\n\t * queue, even if we know we've submitted an op that should eventually modify the queue.\n\t */\n\tprivate readonly taskQueues = new Map<string, string[]>();\n\n\t// opWatcher emits for every op on this data store. This is just a repackaging of processCore into events.\n\tprivate readonly opWatcher: EventEmitter = new EventEmitter();\n\t// queueWatcher emits an event whenever the consensus state of the task queues changes\n\tprivate readonly queueWatcher: EventEmitter = new EventEmitter();\n\t// abandonWatcher emits an event whenever the local client calls abandon() on a task.\n\tprivate readonly abandonWatcher: EventEmitter = new EventEmitter();\n\t// connectionWatcher emits an event whenever we get connected or disconnected.\n\tprivate readonly connectionWatcher: EventEmitter = new EventEmitter();\n\t// completedWatcher emits an event whenever the local client receives a completed op.\n\tprivate readonly completedWatcher: EventEmitter = new EventEmitter();\n\t// rollbackWatcher emits an event whenever a pending op is rolled back.\n\tprivate readonly rollbackWatcher: EventEmitter = new EventEmitter();\n\n\tprivate nextPendingMessageId: number = 0;\n\t/**\n\t * Tracks the most recent pending op for a given task\n\t */\n\tprivate readonly latestPendingOps = new Map<string, IPendingOp[]>();\n\n\t/**\n\t * Tracks tasks that are this client is currently subscribed to.\n\t */\n\tprivate readonly subscribedTasks = new Set<string>();\n\n\t/**\n\t * Returns the clientId. Will return a placeholder if the runtime is detached and not yet assigned a clientId.\n\t */\n\tprivate get clientId(): string | undefined {\n\t\treturn this.isAttached() ? this.runtime.clientId : placeholderClientId;\n\t}\n\n\t/**\n\t * Returns a ReadOnlyInfo object to determine current read/write permissions.\n\t */\n\tprivate get readOnlyInfo(): ReadOnlyInfo {\n\t\treturn this.deltaManager.readOnlyInfo;\n\t}\n\n\t/**\n\t * Constructs a new task manager. If the object is non-local an id and service interfaces will\n\t * be provided\n\t *\n\t * @param runtime - data store runtime the task queue belongs to\n\t * @param id - optional name of the task queue\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_taskManager_\");\n\n\t\tthis.opWatcher.on(\n\t\t\t\"volunteer\",\n\t\t\t(taskId: string, clientId: string, local: boolean, messageId: number | undefined) => {\n\t\t\t\tif (local) {\n\t\t\t\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\t\t\t\tassert(latestPendingOps !== undefined, 0xc3c /* No pending ops for task */);\n\t\t\t\t\tconst pendingOp = latestPendingOps.shift();\n\t\t\t\t\tassert(\n\t\t\t\t\t\tpendingOp !== undefined && pendingOp.messageId === messageId,\n\t\t\t\t\t\t0xc3d /* Unexpected op */,\n\t\t\t\t\t);\n\t\t\t\t\tassert(pendingOp.type === \"volunteer\", 0x07c /* \"Unexpected op type\" */);\n\t\t\t\t\tif (latestPendingOps.length === 0) {\n\t\t\t\t\t\tthis.latestPendingOps.delete(taskId);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.addClientToQueue(taskId, clientId);\n\t\t\t},\n\t\t);\n\n\t\tthis.opWatcher.on(\n\t\t\t\"abandon\",\n\t\t\t(taskId: string, clientId: string, local: boolean, messageId: number | undefined) => {\n\t\t\t\tif (local) {\n\t\t\t\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\t\t\t\tassert(latestPendingOps !== undefined, 0xc3e /* No pending ops for task */);\n\t\t\t\t\tconst pendingOp = latestPendingOps.shift();\n\t\t\t\t\tassert(\n\t\t\t\t\t\tpendingOp !== undefined && pendingOp.messageId === messageId,\n\t\t\t\t\t\t0xc3f /* Unexpected op */,\n\t\t\t\t\t);\n\t\t\t\t\tassert(pendingOp.type === \"abandon\", 0x07e /* \"Unexpected op type\" */);\n\t\t\t\t\tif (latestPendingOps.length === 0) {\n\t\t\t\t\t\tthis.latestPendingOps.delete(taskId);\n\t\t\t\t\t}\n\t\t\t\t\tthis.abandonWatcher.emit(\"abandon\", taskId, messageId);\n\t\t\t\t}\n\n\t\t\t\tthis.removeClientFromQueue(taskId, clientId);\n\t\t\t},\n\t\t);\n\n\t\tthis.opWatcher.on(\n\t\t\t\"complete\",\n\t\t\t(taskId: string, clientId: string, local: boolean, messageId: number | undefined) => {\n\t\t\t\tif (local) {\n\t\t\t\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\t\t\t\tassert(latestPendingOps !== undefined, 0xc40 /* No pending ops for task */);\n\t\t\t\t\tconst pendingOp = latestPendingOps.shift();\n\t\t\t\t\tassert(\n\t\t\t\t\t\tpendingOp !== undefined && pendingOp.messageId === messageId,\n\t\t\t\t\t\t0xc41 /* Unexpected op */,\n\t\t\t\t\t);\n\t\t\t\t\tassert(pendingOp.type === \"complete\", 0x401 /* Unexpected op type */);\n\t\t\t\t\tif (latestPendingOps.length === 0) {\n\t\t\t\t\t\tthis.latestPendingOps.delete(taskId);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.taskQueues.delete(taskId);\n\t\t\t\tthis.completedWatcher.emit(\"completed\", taskId, messageId);\n\t\t\t\tthis.emit(\"completed\", taskId);\n\t\t\t},\n\t\t);\n\n\t\truntime.getQuorum().on(\"removeMember\", (clientId: string) => {\n\t\t\tthis.removeClientFromAllQueues(clientId);\n\t\t});\n\n\t\tthis.queueWatcher.on(\n\t\t\t\"queueChange\",\n\t\t\t(taskId: string, oldLockHolder: string, newLockHolder: string) => {\n\t\t\t\t// If oldLockHolder is placeholderClientId we need to emit the task was lost during the attach process\n\t\t\t\tif (oldLockHolder === placeholderClientId) {\n\t\t\t\t\tthis.emit(\"lost\", taskId);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Exit early if we are still catching up on reconnect -- we can't be the leader yet anyway.\n\t\t\t\tif (this.clientId === undefined) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (oldLockHolder !== this.clientId && newLockHolder === this.clientId) {\n\t\t\t\t\tthis.emit(\"assigned\", taskId);\n\t\t\t\t} else if (oldLockHolder === this.clientId && newLockHolder !== this.clientId) {\n\t\t\t\t\tthis.emit(\"lost\", taskId);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tthis.connectionWatcher.on(\"disconnect\", () => {\n\t\t\tassert(this.clientId !== undefined, 0x1d3 /* \"Missing client id on disconnect\" */);\n\n\t\t\t// Emit \"lost\" for any tasks we were assigned to.\n\t\t\tfor (const [taskId, clientQueue] of this.taskQueues.entries()) {\n\t\t\t\tif (this.isAttached() && clientQueue[0] === this.clientId) {\n\t\t\t\t\tthis.emit(\"lost\", taskId);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Remove this client from all queues to reflect the new state, since being disconnected automatically removes\n\t\t\t// this client from all queues.\n\t\t\tthis.removeClientFromAllQueues(this.clientId);\n\t\t});\n\t}\n\n\tprivate submitVolunteerOp(taskId: string): void {\n\t\tconst op: ITaskManagerVolunteerOperation = {\n\t\t\ttype: \"volunteer\",\n\t\t\ttaskId,\n\t\t};\n\t\tconst pendingOp: IPendingOp = {\n\t\t\ttype: \"volunteer\",\n\t\t\tmessageId: this.nextPendingMessageId++,\n\t\t};\n\t\tthis.submitLocalMessage(op, pendingOp.messageId);\n\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\tif (latestPendingOps === undefined) {\n\t\t\tthis.latestPendingOps.set(taskId, [pendingOp]);\n\t\t} else {\n\t\t\tlatestPendingOps.push(pendingOp);\n\t\t}\n\t}\n\n\tprivate submitAbandonOp(taskId: string): void {\n\t\tconst op: ITaskManagerAbandonOperation = {\n\t\t\ttype: \"abandon\",\n\t\t\ttaskId,\n\t\t};\n\t\tconst pendingOp: IPendingOp = {\n\t\t\ttype: \"abandon\",\n\t\t\tmessageId: this.nextPendingMessageId++,\n\t\t};\n\t\tthis.submitLocalMessage(op, pendingOp.messageId);\n\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\tif (latestPendingOps === undefined) {\n\t\t\tthis.latestPendingOps.set(taskId, [pendingOp]);\n\t\t} else {\n\t\t\tlatestPendingOps.push(pendingOp);\n\t\t}\n\t}\n\n\tprivate submitCompleteOp(taskId: string): void {\n\t\tconst op: ITaskManagerCompletedOperation = {\n\t\t\ttype: \"complete\",\n\t\t\ttaskId,\n\t\t};\n\t\tconst pendingOp: IPendingOp = {\n\t\t\ttype: \"complete\",\n\t\t\tmessageId: this.nextPendingMessageId++,\n\t\t};\n\n\t\tthis.submitLocalMessage(op, pendingOp.messageId);\n\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\tif (latestPendingOps === undefined) {\n\t\t\tthis.latestPendingOps.set(taskId, [pendingOp]);\n\t\t} else {\n\t\t\tlatestPendingOps.push(pendingOp);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.volunteerForTask}\n\t */\n\tpublic async volunteerForTask(taskId: string): Promise<boolean> {\n\t\t// If we are both queued and assigned, then we have the lock and do not\n\t\t// have any pending abandon/complete ops. In this case we can resolve\n\t\t// true immediately.\n\t\tif (this.queuedOptimistically(taskId) && this.assigned(taskId)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (this.readOnlyInfo.readonly === true) {\n\t\t\tconst error =\n\t\t\t\tthis.readOnlyInfo.permissions === true\n\t\t\t\t\t? new Error(\"Attempted to volunteer with read-only permissions\")\n\t\t\t\t\t: new Error(\"Attempted to volunteer in read-only state\");\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (this.isDetached()) {\n\t\t\t// Simulate auto-ack in detached scenario\n\t\t\tassert(this.clientId !== undefined, 0x472 /* clientId should not be undefined */);\n\t\t\tthis.addClientToQueue(taskId, this.clientId);\n\t\t\treturn true;\n\t\t}\n\n\t\tif (!this.connected) {\n\t\t\tthrow new Error(\"Attempted to volunteer in disconnected state\");\n\t\t}\n\n\t\t// This promise works even if we already have an outstanding volunteer op.\n\t\tconst lockAcquireP = new Promise<boolean>((resolve, reject) => {\n\t\t\t// If we don't send an op (meaning the latest pending op is \"volunteer\"), nextPendingMessageId\n\t\t\t// will be greater than that prior \"volunteer\" op's messageId. This is OK because\n\t\t\t// we only use it to filter stale abandon/complete, and not when determining if we\n\t\t\t// acquired the lock.\n\t\t\tconst nextPendingMessageId = this.nextPendingMessageId;\n\t\t\tconst setupListeners = (): void => {\n\t\t\t\tthis.queueWatcher.on(\"queueChange\", checkIfAcquiredLock);\n\t\t\t\tthis.abandonWatcher.on(\"abandon\", checkIfAbandoned);\n\t\t\t\tthis.connectionWatcher.on(\"disconnect\", rejectOnDisconnect);\n\t\t\t\tthis.completedWatcher.on(\"completed\", checkIfCompleted);\n\t\t\t\tthis.rollbackWatcher.on(\"rollback\", checkIfRolledBack);\n\t\t\t};\n\t\t\tconst removeListeners = (): void => {\n\t\t\t\tthis.queueWatcher.off(\"queueChange\", checkIfAcquiredLock);\n\t\t\t\tthis.abandonWatcher.off(\"abandon\", checkIfAbandoned);\n\t\t\t\tthis.connectionWatcher.off(\"disconnect\", rejectOnDisconnect);\n\t\t\t\tthis.completedWatcher.off(\"completed\", checkIfCompleted);\n\t\t\t\tthis.rollbackWatcher.off(\"rollback\", checkIfRolledBack);\n\t\t\t};\n\n\t\t\tconst checkIfAcquiredLock = (eventTaskId: string): void => {\n\t\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Also check pending ops here because it's possible we are currently in the queue from a previous\n\t\t\t\t// lock attempt, but have an outstanding abandon AND the outstanding volunteer for this lock attempt.\n\t\t\t\t// If we reach the head of the queue based on the previous lock attempt, we don't want to resolve.\n\t\t\t\tif (this.assigned(taskId)) {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tresolve(true);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst checkIfAbandoned = (eventTaskId: string, messageId: number | undefined): void => {\n\t\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (messageId !== undefined && messageId <= nextPendingMessageId) {\n\t\t\t\t\t// Ignore abandon events that were for abandon ops that were sent prior to our current volunteer attempt.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tremoveListeners();\n\t\t\t\treject(new Error(\"Abandoned before acquiring task assignment\"));\n\t\t\t};\n\n\t\t\tconst rejectOnDisconnect = (): void => {\n\t\t\t\tremoveListeners();\n\t\t\t\treject(new Error(\"Disconnected before acquiring task assignment\"));\n\t\t\t};\n\n\t\t\tconst checkIfCompleted = (eventTaskId: string, messageId: number | undefined): void => {\n\t\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (messageId !== undefined && messageId <= nextPendingMessageId) {\n\t\t\t\t\t// Ignore abandon events that were for abandon ops that were sent prior to our current volunteer attempt.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tremoveListeners();\n\t\t\t\tresolve(false);\n\t\t\t};\n\n\t\t\tconst checkIfRolledBack = (eventTaskId: string): void => {\n\t\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tremoveListeners();\n\t\t\t\tresolve(false);\n\t\t\t};\n\n\t\t\tsetupListeners();\n\t\t});\n\n\t\tif (!this.queuedOptimistically(taskId)) {\n\t\t\t// Only send the volunteer op if we are not already queued.\n\t\t\tthis.submitVolunteerOp(taskId);\n\t\t}\n\t\treturn lockAcquireP;\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.subscribeToTask}\n\t */\n\tpublic subscribeToTask(taskId: string): void {\n\t\tif (this.subscribed(taskId)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.readOnlyInfo.readonly === true && this.readOnlyInfo.permissions === true) {\n\t\t\tthrow new Error(\"Attempted to subscribe with read-only permissions\");\n\t\t}\n\n\t\tlet volunteerOpMessageId: number | undefined;\n\n\t\tconst submitVolunteerOp = (): void => {\n\t\t\tvolunteerOpMessageId = this.nextPendingMessageId;\n\t\t\tthis.submitVolunteerOp(taskId);\n\t\t};\n\n\t\tconst setupListeners = (): void => {\n\t\t\tthis.abandonWatcher.on(\"abandon\", checkIfAbandoned);\n\t\t\tthis.connectionWatcher.on(\"disconnect\", disconnectHandler);\n\t\t\tthis.completedWatcher.on(\"completed\", checkIfCompleted);\n\t\t\tthis.rollbackWatcher.on(\"rollback\", checkIfRolledBack);\n\t\t};\n\t\tconst removeListeners = (): void => {\n\t\t\tthis.abandonWatcher.off(\"abandon\", checkIfAbandoned);\n\t\t\tthis.connectionWatcher.off(\"disconnect\", disconnectHandler);\n\t\t\tthis.connectionWatcher.off(\"connect\", submitVolunteerOp);\n\t\t\tthis.completedWatcher.off(\"completed\", checkIfCompleted);\n\t\t\tthis.rollbackWatcher.off(\"rollback\", checkIfRolledBack);\n\t\t};\n\n\t\tconst disconnectHandler = (): void => {\n\t\t\t// Wait to be connected again and then re-submit volunteer op\n\t\t\tthis.connectionWatcher.once(\"connect\", submitVolunteerOp);\n\t\t};\n\n\t\tconst checkIfAbandoned = (eventTaskId: string, messageId: number | undefined): void => {\n\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// abandonWatcher emits twice for a local abandon() call. When initially called it\n\t\t\t// will emit with undefined messageId. It will emit a second time when the op is\n\t\t\t// ack'd and processed, this time with the messageId for the ack.\n\t\t\t// This condition accounts ensures we don't ignore the initial abandon() emit and\n\t\t\t// only ignore emits associated with ack'd abandon ops that were sent prior to the\n\t\t\t// current volunteer attempt.\n\t\t\tif (\n\t\t\t\tmessageId !== undefined &&\n\t\t\t\tvolunteerOpMessageId !== undefined &&\n\t\t\t\tmessageId <= volunteerOpMessageId\n\t\t\t) {\n\t\t\t\t// Ignore abandon events that were for abandon ops that were sent prior to our current volunteer attempt.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tremoveListeners();\n\t\t\tthis.subscribedTasks.delete(taskId);\n\t\t};\n\n\t\tconst checkIfCompleted = (eventTaskId: string, messageId: number | undefined): void => {\n\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tmessageId !== undefined &&\n\t\t\t\tvolunteerOpMessageId !== undefined &&\n\t\t\t\tmessageId <= volunteerOpMessageId\n\t\t\t) {\n\t\t\t\t// Ignore abandon events that were for abandon ops that were sent prior to our current volunteer attempt.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tremoveListeners();\n\t\t\tthis.subscribedTasks.delete(taskId);\n\t\t};\n\n\t\tconst checkIfRolledBack = (eventTaskId: string): void => {\n\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tremoveListeners();\n\t\t\tthis.subscribedTasks.delete(taskId);\n\t\t};\n\n\t\tsetupListeners();\n\n\t\tif (this.isDetached()) {\n\t\t\t// Simulate auto-ack in detached scenario\n\t\t\tassert(this.clientId !== undefined, 0x473 /* clientId should not be undefined */);\n\t\t\tthis.addClientToQueue(taskId, this.clientId);\n\t\t\t// Because we volunteered with placeholderClientId, we need to wait for when we attach and are assigned\n\t\t\t// a real clientId. At that point we should re-enter the queue with a real volunteer op (assuming we are\n\t\t\t// connected).\n\t\t\tthis.runtime.once(\"attached\", () => {\n\t\t\t\t// We call scrubClientsNotInQuorum() in case our clientId changed during the attach process.\n\t\t\t\tthis.scrubClientsNotInQuorum();\n\t\t\t\tif (this.connected) {\n\t\t\t\t\tsubmitVolunteerOp();\n\t\t\t\t} else {\n\t\t\t\t\tthis.connectionWatcher.once(\"connect\", submitVolunteerOp);\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (!this.connected) {\n\t\t\t// If we are disconnected (and attached), wait to be connected and submit volunteer op\n\t\t\tdisconnectHandler();\n\t\t} else if (!this.queuedOptimistically(taskId)) {\n\t\t\t// We don't need to send a second volunteer op if we just sent one.\n\t\t\tsubmitVolunteerOp();\n\t\t}\n\t\tthis.subscribedTasks.add(taskId);\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.abandon}\n\t */\n\tpublic abandon(taskId: string): void {\n\t\t// Always allow abandon if the client is subscribed to allow clients to unsubscribe while disconnected.\n\t\t// Otherwise, we should check to make sure the client is optimistically queued for the task before trying to abandon.\n\t\tif (!this.queuedOptimistically(taskId) && !this.subscribed(taskId)) {\n\t\t\t// Nothing to do\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.isDetached()) {\n\t\t\t// Simulate auto-ack in detached scenario\n\t\t\tassert(this.clientId !== undefined, 0x474 /* clientId is undefined */);\n\t\t\tthis.removeClientFromQueue(taskId, this.clientId);\n\t\t\tthis.abandonWatcher.emit(\"abandon\", taskId);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitAbandonOp(taskId);\n\t\tthis.abandonWatcher.emit(\"abandon\", taskId);\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.assigned}\n\t */\n\tpublic assigned(taskId: string): boolean {\n\t\tif (this.isAttached() && !this.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst currentAssignee = this.taskQueues.get(taskId)?.[0];\n\t\treturn currentAssignee !== undefined && currentAssignee === this.clientId;\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.queued}\n\t */\n\tpublic queued(taskId: string): boolean {\n\t\tif (this.isAttached() && !this.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\tassert(this.clientId !== undefined, 0x07f /* \"clientId undefined\" */);\n\t\treturn this.taskQueues.get(taskId)?.includes(this.clientId) ?? false;\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.subscribed}\n\t */\n\tpublic subscribed(taskId: string): boolean {\n\t\treturn this.subscribedTasks.has(taskId);\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.complete}\n\t */\n\tpublic complete(taskId: string): void {\n\t\tif (!this.assigned(taskId)) {\n\t\t\tthrow new Error(\"Attempted to mark task as complete while not being assigned\");\n\t\t}\n\n\t\t// If we are detached we will simulate auto-ack for the complete op. Therefore we only need to send the op if\n\t\t// we are attached. Additionally, we don't need to check if we are connected while detached.\n\t\tif (this.isDetached()) {\n\t\t\tthis.taskQueues.delete(taskId);\n\t\t\tthis.completedWatcher.emit(\"completed\", taskId);\n\t\t\tthis.emit(\"completed\", taskId);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!this.connected) {\n\t\t\tthrow new Error(\"Attempted to complete task in disconnected state\");\n\t\t}\n\t\tthis.submitCompleteOp(taskId);\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.canVolunteer}\n\t */\n\tpublic canVolunteer(): boolean {\n\t\t// A client can volunteer for a task if it's both connected to the delta stream and in write mode.\n\t\t// this.connected reflects that condition, but is unintuitive and may be changed in the future. This API allows\n\t\t// us to make changes to this.connected without affecting our guidance on how to check if a client is eligible\n\t\t// to volunteer for a task.\n\t\treturn this.connected;\n\t}\n\n\t/**\n\t * Create a summary for the task manager\n\t *\n\t * @returns the summary of the current state of the task manager\n\t */\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tif (this.runtime.clientId === undefined) {\n\t\t\t// If the runtime has still not been assigned a clientId, we should not summarize with the placeholder\n\t\t\t// clientIds and instead remove them from the queues and require the client to re-volunteer when assigned\n\t\t\t// a new clientId.\n\t\t\tthis.removeClientFromAllQueues(placeholderClientId);\n\t\t} else {\n\t\t\t// If the runtime has been assigned an actual clientId by now, we can replace the placeholder clientIds\n\t\t\t// and maintain the task assignment.\n\t\t\tthis.replacePlaceholderInAllQueues();\n\t\t}\n\n\t\t// Only include tasks if there are clients in the queue.\n\t\tconst filteredMap = new Map<string, string[]>();\n\t\tfor (const [taskId, queue] of this.taskQueues) {\n\t\t\tif (queue.length > 0) {\n\t\t\t\tfilteredMap.set(taskId, queue);\n\t\t\t}\n\t\t}\n\t\tconst content = [...filteredMap.entries()];\n\t\treturn createSingleBlobSummary(snapshotFileName, JSON.stringify(content));\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst content = await readAndParse<[string, string[]][]>(storage, snapshotFileName);\n\t\tfor (const [taskId, clientIdQueue] of content) {\n\t\t\tthis.taskQueues.set(taskId, clientIdQueue);\n\t\t}\n\t\tthis.scrubClientsNotInQuorum();\n\t}\n\n\t/***/\n\tprotected initializeLocalCore(): void {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n\t */\n\tprotected onDisconnect(): void {\n\t\tthis.connectionWatcher.emit(\"disconnect\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onConnect}\n\t */\n\tprotected onConnect(): void {\n\t\tthis.connectionWatcher.emit(\"connect\");\n\t}\n\n\t/**\n\t * Override resubmit core to avoid resubmission on reconnect. On disconnect we accept our removal from the\n\t * queues, and leave it up to the user to decide whether they want to attempt to re-enter a queue on reconnect.\n\t * However, we do need to update latestPendingOps to account for the ops we will no longer be processing.\n\t */\n\tprotected reSubmitCore(content: unknown, localOpMetadata: number): void {\n\t\tassertIsTaskManagerOperation(content);\n\t\tconst pendingOps = this.latestPendingOps.get(content.taskId);\n\t\tassert(pendingOps !== undefined, 0xc42 /* No pending ops for task on resubmit attempt */);\n\t\tconst pendingOpIndex = pendingOps.findIndex(\n\t\t\t(op) => op.messageId === localOpMetadata && op.type === content.type,\n\t\t);\n\t\tassert(pendingOpIndex !== -1, 0xc43 /* Could not match pending op on resubmit attempt */);\n\t\tpendingOps.splice(pendingOpIndex, 1);\n\t\tif (pendingOps.length === 0) {\n\t\t\tthis.latestPendingOps.delete(content.taskId);\n\t\t}\n\t}\n\n\t/**\n\t * Process a task manager operation\n\t *\n\t * @param message - the message to prepare\n\t * @param local - whether the message was sent by the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t */\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: number | undefined,\n\t): void {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\tif (message.type === MessageType.Operation) {\n\t\t\tconst op = message.contents as ITaskManagerOperation;\n\t\t\tconst messageId = localOpMetadata;\n\n\t\t\tswitch (op.type) {\n\t\t\t\tcase \"volunteer\": {\n\t\t\t\t\tthis.opWatcher.emit(\"volunteer\", op.taskId, message.clientId, local, messageId);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"abandon\": {\n\t\t\t\t\tthis.opWatcher.emit(\"abandon\", op.taskId, message.clientId, local, messageId);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"complete\": {\n\t\t\t\t\tthis.opWatcher.emit(\"complete\", op.taskId, message.clientId, local, messageId);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate addClientToQueue(taskId: string, clientId: string): void {\n\t\t// Ensure that the clientId exists in the quorum, or it is placeholderClientId (detached scenario)\n\t\tif (\n\t\t\tthis.runtime.getQuorum().getMembers().has(clientId) ||\n\t\t\tthis.clientId === placeholderClientId\n\t\t) {\n\t\t\t// Create the queue if it doesn't exist, and push the client on the back.\n\t\t\tlet clientQueue = this.taskQueues.get(taskId);\n\t\t\tif (clientQueue === undefined) {\n\t\t\t\tclientQueue = [];\n\t\t\t\tthis.taskQueues.set(taskId, clientQueue);\n\t\t\t}\n\n\t\t\tif (clientQueue.includes(clientId)) {\n\t\t\t\t// We shouldn't re-add the client if it's already in the queue.\n\t\t\t\t// This may be possible in scenarios where a client was added in\n\t\t\t\t// while detached.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst oldLockHolder = clientQueue[0];\n\t\t\tclientQueue.push(clientId);\n\t\t\tconst newLockHolder = clientQueue[0];\n\t\t\tif (newLockHolder !== oldLockHolder) {\n\t\t\t\tthis.queueWatcher.emit(\"queueChange\", taskId, oldLockHolder, newLockHolder);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate removeClientFromQueue(taskId: string, clientId: string): void {\n\t\tconst clientQueue = this.taskQueues.get(taskId);\n\t\tif (clientQueue === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst oldLockHolder =\n\t\t\tclientId === placeholderClientId ? placeholderClientId : clientQueue[0];\n\t\tconst clientIdIndex = clientQueue.indexOf(clientId);\n\t\tif (clientIdIndex !== -1) {\n\t\t\tclientQueue.splice(clientIdIndex, 1);\n\t\t\t// Clean up the queue if there are no more clients in it.\n\t\t\tif (clientQueue.length === 0) {\n\t\t\t\tthis.taskQueues.delete(taskId);\n\t\t\t}\n\t\t}\n\t\tconst newLockHolder = clientQueue[0];\n\t\tif (newLockHolder !== oldLockHolder) {\n\t\t\tthis.queueWatcher.emit(\"queueChange\", taskId, oldLockHolder, newLockHolder);\n\t\t}\n\t}\n\n\tprivate removeClientFromAllQueues(clientId: string): void {\n\t\tfor (const taskId of this.taskQueues.keys()) {\n\t\t\tthis.removeClientFromQueue(taskId, clientId);\n\t\t}\n\t}\n\n\t/**\n\t * Will replace all instances of the placeholderClientId with the current clientId. This should only be called when\n\t * transitioning from detached to attached and this.runtime.clientId is defined.\n\t */\n\tprivate replacePlaceholderInAllQueues(): void {\n\t\tassert(\n\t\t\tthis.runtime.clientId !== undefined,\n\t\t\t0x475 /* this.runtime.clientId should be defined */,\n\t\t);\n\t\tfor (const clientQueue of this.taskQueues.values()) {\n\t\t\tconst clientIdIndex = clientQueue.indexOf(placeholderClientId);\n\t\t\tif (clientIdIndex !== -1) {\n\t\t\t\tif (clientQueue.includes(this.runtime.clientId)) {\n\t\t\t\t\t// If the real clientId is already in the queue, just remove the placeholder.\n\t\t\t\t\tclientQueue.splice(clientIdIndex, 1);\n\t\t\t\t} else {\n\t\t\t\t\tclientQueue[clientIdIndex] = this.runtime.clientId;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// This seems like it should be unnecessary if we can trust to receive the join/leave messages and\n\t// also have an accurate snapshot.\n\tprivate scrubClientsNotInQuorum(): void {\n\t\tconst quorum = this.runtime.getQuorum();\n\t\tfor (const [taskId, clientQueue] of this.taskQueues) {\n\t\t\tconst filteredClientQueue = clientQueue.filter(\n\t\t\t\t(clientId) => quorum.getMember(clientId) !== undefined,\n\t\t\t);\n\t\t\tif (clientQueue.length !== filteredClientQueue.length) {\n\t\t\t\tif (filteredClientQueue.length === 0) {\n\t\t\t\t\tthis.taskQueues.delete(taskId);\n\t\t\t\t} else {\n\t\t\t\t\tthis.taskQueues.set(taskId, filteredClientQueue);\n\t\t\t\t}\n\t\t\t\tthis.queueWatcher.emit(\"queueChange\", taskId);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Checks whether this client is currently assigned or in queue to become assigned, while also accounting\n\t * for the latest pending ops.\n\t */\n\tprivate queuedOptimistically(taskId: string): boolean {\n\t\tif (this.isAttached() && !this.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\tassert(this.clientId !== undefined, 0xc44 /* clientId undefined */);\n\n\t\tconst inQueue = this.taskQueues.get(taskId)?.includes(this.clientId) ?? false;\n\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\n\t\tconst latestPendingOp =\n\t\t\tlatestPendingOps !== undefined && latestPendingOps.length > 0\n\t\t\t\t? latestPendingOps[latestPendingOps.length - 1]\n\t\t\t\t: undefined;\n\t\tconst isPendingVolunteer = latestPendingOp?.type === \"volunteer\";\n\t\tconst isPendingAbandonOrComplete =\n\t\t\tlatestPendingOp?.type === \"abandon\" || latestPendingOp?.type === \"complete\";\n\t\t// We return true if the client is either in queue already or the latest pending op for this task is a volunteer op.\n\t\t// But we should always return false if the latest pending op is an abandon or complete op.\n\t\treturn (inQueue && !isPendingAbandonOrComplete) || isPendingVolunteer;\n\t}\n\n\t/**\n\t * Returns true if the client is detached.\n\t * This is distinct from !this.isAttached() because `isAttached()` also checks if `this._isBoundToContext`\n\t * is true. We use `isDetached()` to determine if we should simulate auto-ack behavior for ops, which is\n\t * mainly concerned with if we have been assigned a real clientId yet.\n\t */\n\tprivate isDetached(): boolean {\n\t\treturn this.runtime.attachState === AttachState.Detached;\n\t}\n\n\tprotected applyStashedOp(content: unknown): void {\n\t\t// We don't apply any stashed ops since during the rehydration process. Since we lose any assigned tasks\n\t\t// during rehydration we cannot be assigned any tasks. Additionally, without the in-memory state of the\n\t\t// previous dds, we also cannot re-volunteer based on a previous subscribeToTask() call. Since we are\n\t\t// unable to be assigned to any tasks, there is no reason to process abandon/complete ops either.\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n\t */\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tassert(\n\t\t\ttypeof localOpMetadata === \"number\",\n\t\t\t0xc45 /* Expect localOpMetadata to be a number */,\n\t\t);\n\t\tassertIsTaskManagerOperation(content);\n\t\tconst latestPendingOps = this.latestPendingOps.get(content.taskId);\n\t\tassert(latestPendingOps !== undefined, 0xc46 /* No pending ops when trying to rollback */);\n\t\tconst pendingOpToRollback = latestPendingOps.pop();\n\t\tassert(\n\t\t\tpendingOpToRollback !== undefined && pendingOpToRollback.messageId === localOpMetadata,\n\t\t\t0xc47 /* pending op mismatch */,\n\t\t);\n\t\tif (latestPendingOps.length === 0) {\n\t\t\tthis.latestPendingOps.delete(content.taskId);\n\t\t}\n\t\tthis.rollbackWatcher.emit(\"rollback\", content.taskId);\n\t}\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/task-manager";
|
|
8
|
-
export declare const pkgVersion = "2.61.0
|
|
8
|
+
export declare const pkgVersion = "2.61.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,iCAAiC,CAAC;AACtD,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,iCAAiC,CAAC;AACtD,eAAO,MAAM,UAAU,WAAW,CAAC"}
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,8BAA8B,CAAC;AACtD,MAAM,CAAC,MAAM,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,8BAA8B,CAAC;AACtD,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/task-manager\";\nexport const pkgVersion = \"2.61.0\";\n"]}
|
package/lib/taskManager.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taskManager.d.ts","sourceRoot":"","sources":["../src/taskManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,KAAK,EACX,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AAG7F,OAAO,KAA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AAqB;IAsB7B,OAAO,CAAC,yBAAyB;IAMjC;;;OAGG;IACH,OAAO,CAAC,6BAA6B;IAoBrC,OAAO,CAAC,uBAAuB;IAiB/B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAsB5B;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IAIlB,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAOhD;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;CAkBpE"}
|
package/lib/taskManager.js
CHANGED
|
@@ -14,7 +14,7 @@ function assertIsTaskManagerOperation(op) {
|
|
|
14
14
|
"taskId" in op &&
|
|
15
15
|
typeof op.taskId === "string" &&
|
|
16
16
|
"type" in op &&
|
|
17
|
-
(op.type === "volunteer" || op.type === "abandon" || op.type === "complete"),
|
|
17
|
+
(op.type === "volunteer" || op.type === "abandon" || op.type === "complete"), 0xc3b /* Not a TaskManager operation */);
|
|
18
18
|
}
|
|
19
19
|
const snapshotFileName = "header";
|
|
20
20
|
/**
|
|
@@ -78,9 +78,9 @@ export class TaskManagerClass extends SharedObject {
|
|
|
78
78
|
this.opWatcher.on("volunteer", (taskId, clientId, local, messageId) => {
|
|
79
79
|
if (local) {
|
|
80
80
|
const latestPendingOps = this.latestPendingOps.get(taskId);
|
|
81
|
-
assert(latestPendingOps !== undefined,
|
|
81
|
+
assert(latestPendingOps !== undefined, 0xc3c /* No pending ops for task */);
|
|
82
82
|
const pendingOp = latestPendingOps.shift();
|
|
83
|
-
assert(pendingOp !== undefined && pendingOp.messageId === messageId,
|
|
83
|
+
assert(pendingOp !== undefined && pendingOp.messageId === messageId, 0xc3d /* Unexpected op */);
|
|
84
84
|
assert(pendingOp.type === "volunteer", 0x07c /* "Unexpected op type" */);
|
|
85
85
|
if (latestPendingOps.length === 0) {
|
|
86
86
|
this.latestPendingOps.delete(taskId);
|
|
@@ -91,9 +91,9 @@ export class TaskManagerClass extends SharedObject {
|
|
|
91
91
|
this.opWatcher.on("abandon", (taskId, clientId, local, messageId) => {
|
|
92
92
|
if (local) {
|
|
93
93
|
const latestPendingOps = this.latestPendingOps.get(taskId);
|
|
94
|
-
assert(latestPendingOps !== undefined,
|
|
94
|
+
assert(latestPendingOps !== undefined, 0xc3e /* No pending ops for task */);
|
|
95
95
|
const pendingOp = latestPendingOps.shift();
|
|
96
|
-
assert(pendingOp !== undefined && pendingOp.messageId === messageId,
|
|
96
|
+
assert(pendingOp !== undefined && pendingOp.messageId === messageId, 0xc3f /* Unexpected op */);
|
|
97
97
|
assert(pendingOp.type === "abandon", 0x07e /* "Unexpected op type" */);
|
|
98
98
|
if (latestPendingOps.length === 0) {
|
|
99
99
|
this.latestPendingOps.delete(taskId);
|
|
@@ -105,9 +105,9 @@ export class TaskManagerClass extends SharedObject {
|
|
|
105
105
|
this.opWatcher.on("complete", (taskId, clientId, local, messageId) => {
|
|
106
106
|
if (local) {
|
|
107
107
|
const latestPendingOps = this.latestPendingOps.get(taskId);
|
|
108
|
-
assert(latestPendingOps !== undefined,
|
|
108
|
+
assert(latestPendingOps !== undefined, 0xc40 /* No pending ops for task */);
|
|
109
109
|
const pendingOp = latestPendingOps.shift();
|
|
110
|
-
assert(pendingOp !== undefined && pendingOp.messageId === messageId,
|
|
110
|
+
assert(pendingOp !== undefined && pendingOp.messageId === messageId, 0xc41 /* Unexpected op */);
|
|
111
111
|
assert(pendingOp.type === "complete", 0x401 /* Unexpected op type */);
|
|
112
112
|
if (latestPendingOps.length === 0) {
|
|
113
113
|
this.latestPendingOps.delete(taskId);
|
|
@@ -538,9 +538,9 @@ export class TaskManagerClass extends SharedObject {
|
|
|
538
538
|
reSubmitCore(content, localOpMetadata) {
|
|
539
539
|
assertIsTaskManagerOperation(content);
|
|
540
540
|
const pendingOps = this.latestPendingOps.get(content.taskId);
|
|
541
|
-
assert(pendingOps !== undefined,
|
|
541
|
+
assert(pendingOps !== undefined, 0xc42 /* No pending ops for task on resubmit attempt */);
|
|
542
542
|
const pendingOpIndex = pendingOps.findIndex((op) => op.messageId === localOpMetadata && op.type === content.type);
|
|
543
|
-
assert(pendingOpIndex !== -1,
|
|
543
|
+
assert(pendingOpIndex !== -1, 0xc43 /* Could not match pending op on resubmit attempt */);
|
|
544
544
|
pendingOps.splice(pendingOpIndex, 1);
|
|
545
545
|
if (pendingOps.length === 0) {
|
|
546
546
|
this.latestPendingOps.delete(content.taskId);
|
|
@@ -670,7 +670,7 @@ export class TaskManagerClass extends SharedObject {
|
|
|
670
670
|
if (this.isAttached() && !this.connected) {
|
|
671
671
|
return false;
|
|
672
672
|
}
|
|
673
|
-
assert(this.clientId !== undefined,
|
|
673
|
+
assert(this.clientId !== undefined, 0xc44 /* clientId undefined */);
|
|
674
674
|
const inQueue = this.taskQueues.get(taskId)?.includes(this.clientId) ?? false;
|
|
675
675
|
const latestPendingOps = this.latestPendingOps.get(taskId);
|
|
676
676
|
const latestPendingOp = latestPendingOps !== undefined && latestPendingOps.length > 0
|
|
@@ -701,12 +701,12 @@ export class TaskManagerClass extends SharedObject {
|
|
|
701
701
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}
|
|
702
702
|
*/
|
|
703
703
|
rollback(content, localOpMetadata) {
|
|
704
|
-
assert(typeof localOpMetadata === "number",
|
|
704
|
+
assert(typeof localOpMetadata === "number", 0xc45 /* Expect localOpMetadata to be a number */);
|
|
705
705
|
assertIsTaskManagerOperation(content);
|
|
706
706
|
const latestPendingOps = this.latestPendingOps.get(content.taskId);
|
|
707
|
-
assert(latestPendingOps !== undefined,
|
|
707
|
+
assert(latestPendingOps !== undefined, 0xc46 /* No pending ops when trying to rollback */);
|
|
708
708
|
const pendingOpToRollback = latestPendingOps.pop();
|
|
709
|
-
assert(pendingOpToRollback !== undefined && pendingOpToRollback.messageId === localOpMetadata,
|
|
709
|
+
assert(pendingOpToRollback !== undefined && pendingOpToRollback.messageId === localOpMetadata, 0xc47 /* pending op mismatch */);
|
|
710
710
|
if (latestPendingOps.length === 0) {
|
|
711
711
|
this.latestPendingOps.delete(content.taskId);
|
|
712
712
|
}
|
package/lib/taskManager.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taskManager.js","sourceRoot":"","sources":["../src/taskManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EACN,WAAW,GAEX,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAO7D,OAAO,EAAE,WAAW,EAAE,MAAM,6CAA6C,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAGrE,OAAO,EACN,YAAY,EACZ,uBAAuB,GACvB,MAAM,6CAA6C,CAAC;AAgCrD,SAAS,4BAA4B,CAAC,EAAW;IAChD,MAAM,CACL,OAAO,EAAE,KAAK,QAAQ;QACrB,EAAE,KAAK,IAAI;QACX,QAAQ,IAAI,EAAE;QACd,OAAO,EAAE,CAAC,MAAM,KAAK,QAAQ;QAC7B,MAAM,IAAI,EAAE;QACZ,CAAC,EAAE,CAAC,IAAI,KAAK,WAAW,IAAI,EAAE,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,CAAC,IAAI,KAAK,UAAU,CAAC,EAC7E,6BAA6B,CAC7B,CAAC;AACH,CAAC;AAED,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;GAEG;AACH,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,OAAO,gBACZ,SAAQ,YAAgC;IAiCxC;;OAEG;IACH,IAAY,QAAQ;QACnB,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC;IACxE,CAAC;IAED;;OAEG;IACH,IAAY,YAA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CAAC;QACtC,MAAM,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACnE,MAAM,CAAC,gBAAgB,KAAK,SAAS,EAAE,wCAAwC,CAAC,CAAC;QACjF,MAAM,mBAAmB,GAAG,gBAAgB,CAAC,GAAG,EAAE,CAAC;QACnD,MAAM,CACL,mBAAmB,KAAK,SAAS,IAAI,mBAAmB,CAAC,SAAS,KAAK,eAAe,EACtF,qBAAqB,CACrB,CAAC;QACF,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC9C,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACvD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"@fluid-internal/client-utils\";\nimport {\n\tAttachState,\n\ttype ReadOnlyInfo,\n} from \"@fluidframework/container-definitions/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport { MessageType } from \"@fluidframework/driver-definitions/internal\";\nimport { readAndParse } from \"@fluidframework/driver-utils/internal\";\nimport type { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport {\n\tSharedObject,\n\tcreateSingleBlobSummary,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ITaskManager, ITaskManagerEvents } from \"./interfaces.js\";\n\n/**\n * Description of a task manager operation\n */\ntype ITaskManagerOperation =\n\t| ITaskManagerVolunteerOperation\n\t| ITaskManagerAbandonOperation\n\t| ITaskManagerCompletedOperation;\n\ninterface ITaskManagerVolunteerOperation {\n\ttype: \"volunteer\";\n\ttaskId: string;\n}\n\ninterface ITaskManagerAbandonOperation {\n\ttype: \"abandon\";\n\ttaskId: string;\n}\n\ninterface ITaskManagerCompletedOperation {\n\ttype: \"complete\";\n\ttaskId: string;\n}\n\ninterface IPendingOp {\n\ttype: \"volunteer\" | \"abandon\" | \"complete\";\n\tmessageId: number;\n}\n\nfunction assertIsTaskManagerOperation(op: unknown): asserts op is ITaskManagerOperation {\n\tassert(\n\t\ttypeof op === \"object\" &&\n\t\t\top !== null &&\n\t\t\t\"taskId\" in op &&\n\t\t\ttypeof op.taskId === \"string\" &&\n\t\t\t\"type\" in op &&\n\t\t\t(op.type === \"volunteer\" || op.type === \"abandon\" || op.type === \"complete\"),\n\t\t\"Not a TaskManager operation\",\n\t);\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * Placeholder clientId for detached scenarios.\n */\nconst placeholderClientId = \"placeholder\";\n\n/**\n * {@inheritDoc ITaskManager}\n *\n * @sealed\n * @legacy @beta\n */\nexport class TaskManagerClass\n\textends SharedObject<ITaskManagerEvents>\n\timplements ITaskManager\n{\n\t/**\n\t * Mapping of taskId to a queue of clientIds that are waiting on the task. Maintains the consensus state of the\n\t * queue, even if we know we've submitted an op that should eventually modify the queue.\n\t */\n\tprivate readonly taskQueues = new Map<string, string[]>();\n\n\t// opWatcher emits for every op on this data store. This is just a repackaging of processCore into events.\n\tprivate readonly opWatcher: EventEmitter = new EventEmitter();\n\t// queueWatcher emits an event whenever the consensus state of the task queues changes\n\tprivate readonly queueWatcher: EventEmitter = new EventEmitter();\n\t// abandonWatcher emits an event whenever the local client calls abandon() on a task.\n\tprivate readonly abandonWatcher: EventEmitter = new EventEmitter();\n\t// connectionWatcher emits an event whenever we get connected or disconnected.\n\tprivate readonly connectionWatcher: EventEmitter = new EventEmitter();\n\t// completedWatcher emits an event whenever the local client receives a completed op.\n\tprivate readonly completedWatcher: EventEmitter = new EventEmitter();\n\t// rollbackWatcher emits an event whenever a pending op is rolled back.\n\tprivate readonly rollbackWatcher: EventEmitter = new EventEmitter();\n\n\tprivate nextPendingMessageId: number = 0;\n\t/**\n\t * Tracks the most recent pending op for a given task\n\t */\n\tprivate readonly latestPendingOps = new Map<string, IPendingOp[]>();\n\n\t/**\n\t * Tracks tasks that are this client is currently subscribed to.\n\t */\n\tprivate readonly subscribedTasks = new Set<string>();\n\n\t/**\n\t * Returns the clientId. Will return a placeholder if the runtime is detached and not yet assigned a clientId.\n\t */\n\tprivate get clientId(): string | undefined {\n\t\treturn this.isAttached() ? this.runtime.clientId : placeholderClientId;\n\t}\n\n\t/**\n\t * Returns a ReadOnlyInfo object to determine current read/write permissions.\n\t */\n\tprivate get readOnlyInfo(): ReadOnlyInfo {\n\t\treturn this.deltaManager.readOnlyInfo;\n\t}\n\n\t/**\n\t * Constructs a new task manager. If the object is non-local an id and service interfaces will\n\t * be provided\n\t *\n\t * @param runtime - data store runtime the task queue belongs to\n\t * @param id - optional name of the task queue\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_taskManager_\");\n\n\t\tthis.opWatcher.on(\n\t\t\t\"volunteer\",\n\t\t\t(taskId: string, clientId: string, local: boolean, messageId: number | undefined) => {\n\t\t\t\tif (local) {\n\t\t\t\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\t\t\t\tassert(latestPendingOps !== undefined, \"No pending ops for task\");\n\t\t\t\t\tconst pendingOp = latestPendingOps.shift();\n\t\t\t\t\tassert(\n\t\t\t\t\t\tpendingOp !== undefined && pendingOp.messageId === messageId,\n\t\t\t\t\t\t\"Unexpected op\",\n\t\t\t\t\t);\n\t\t\t\t\tassert(pendingOp.type === \"volunteer\", 0x07c /* \"Unexpected op type\" */);\n\t\t\t\t\tif (latestPendingOps.length === 0) {\n\t\t\t\t\t\tthis.latestPendingOps.delete(taskId);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.addClientToQueue(taskId, clientId);\n\t\t\t},\n\t\t);\n\n\t\tthis.opWatcher.on(\n\t\t\t\"abandon\",\n\t\t\t(taskId: string, clientId: string, local: boolean, messageId: number | undefined) => {\n\t\t\t\tif (local) {\n\t\t\t\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\t\t\t\tassert(latestPendingOps !== undefined, \"No pending ops for task\");\n\t\t\t\t\tconst pendingOp = latestPendingOps.shift();\n\t\t\t\t\tassert(\n\t\t\t\t\t\tpendingOp !== undefined && pendingOp.messageId === messageId,\n\t\t\t\t\t\t\"Unexpected op\",\n\t\t\t\t\t);\n\t\t\t\t\tassert(pendingOp.type === \"abandon\", 0x07e /* \"Unexpected op type\" */);\n\t\t\t\t\tif (latestPendingOps.length === 0) {\n\t\t\t\t\t\tthis.latestPendingOps.delete(taskId);\n\t\t\t\t\t}\n\t\t\t\t\tthis.abandonWatcher.emit(\"abandon\", taskId, messageId);\n\t\t\t\t}\n\n\t\t\t\tthis.removeClientFromQueue(taskId, clientId);\n\t\t\t},\n\t\t);\n\n\t\tthis.opWatcher.on(\n\t\t\t\"complete\",\n\t\t\t(taskId: string, clientId: string, local: boolean, messageId: number | undefined) => {\n\t\t\t\tif (local) {\n\t\t\t\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\t\t\t\tassert(latestPendingOps !== undefined, \"No pending ops for task\");\n\t\t\t\t\tconst pendingOp = latestPendingOps.shift();\n\t\t\t\t\tassert(\n\t\t\t\t\t\tpendingOp !== undefined && pendingOp.messageId === messageId,\n\t\t\t\t\t\t\"Unexpected op\",\n\t\t\t\t\t);\n\t\t\t\t\tassert(pendingOp.type === \"complete\", 0x401 /* Unexpected op type */);\n\t\t\t\t\tif (latestPendingOps.length === 0) {\n\t\t\t\t\t\tthis.latestPendingOps.delete(taskId);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.taskQueues.delete(taskId);\n\t\t\t\tthis.completedWatcher.emit(\"completed\", taskId, messageId);\n\t\t\t\tthis.emit(\"completed\", taskId);\n\t\t\t},\n\t\t);\n\n\t\truntime.getQuorum().on(\"removeMember\", (clientId: string) => {\n\t\t\tthis.removeClientFromAllQueues(clientId);\n\t\t});\n\n\t\tthis.queueWatcher.on(\n\t\t\t\"queueChange\",\n\t\t\t(taskId: string, oldLockHolder: string, newLockHolder: string) => {\n\t\t\t\t// If oldLockHolder is placeholderClientId we need to emit the task was lost during the attach process\n\t\t\t\tif (oldLockHolder === placeholderClientId) {\n\t\t\t\t\tthis.emit(\"lost\", taskId);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Exit early if we are still catching up on reconnect -- we can't be the leader yet anyway.\n\t\t\t\tif (this.clientId === undefined) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (oldLockHolder !== this.clientId && newLockHolder === this.clientId) {\n\t\t\t\t\tthis.emit(\"assigned\", taskId);\n\t\t\t\t} else if (oldLockHolder === this.clientId && newLockHolder !== this.clientId) {\n\t\t\t\t\tthis.emit(\"lost\", taskId);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tthis.connectionWatcher.on(\"disconnect\", () => {\n\t\t\tassert(this.clientId !== undefined, 0x1d3 /* \"Missing client id on disconnect\" */);\n\n\t\t\t// Emit \"lost\" for any tasks we were assigned to.\n\t\t\tfor (const [taskId, clientQueue] of this.taskQueues.entries()) {\n\t\t\t\tif (this.isAttached() && clientQueue[0] === this.clientId) {\n\t\t\t\t\tthis.emit(\"lost\", taskId);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Remove this client from all queues to reflect the new state, since being disconnected automatically removes\n\t\t\t// this client from all queues.\n\t\t\tthis.removeClientFromAllQueues(this.clientId);\n\t\t});\n\t}\n\n\tprivate submitVolunteerOp(taskId: string): void {\n\t\tconst op: ITaskManagerVolunteerOperation = {\n\t\t\ttype: \"volunteer\",\n\t\t\ttaskId,\n\t\t};\n\t\tconst pendingOp: IPendingOp = {\n\t\t\ttype: \"volunteer\",\n\t\t\tmessageId: this.nextPendingMessageId++,\n\t\t};\n\t\tthis.submitLocalMessage(op, pendingOp.messageId);\n\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\tif (latestPendingOps === undefined) {\n\t\t\tthis.latestPendingOps.set(taskId, [pendingOp]);\n\t\t} else {\n\t\t\tlatestPendingOps.push(pendingOp);\n\t\t}\n\t}\n\n\tprivate submitAbandonOp(taskId: string): void {\n\t\tconst op: ITaskManagerAbandonOperation = {\n\t\t\ttype: \"abandon\",\n\t\t\ttaskId,\n\t\t};\n\t\tconst pendingOp: IPendingOp = {\n\t\t\ttype: \"abandon\",\n\t\t\tmessageId: this.nextPendingMessageId++,\n\t\t};\n\t\tthis.submitLocalMessage(op, pendingOp.messageId);\n\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\tif (latestPendingOps === undefined) {\n\t\t\tthis.latestPendingOps.set(taskId, [pendingOp]);\n\t\t} else {\n\t\t\tlatestPendingOps.push(pendingOp);\n\t\t}\n\t}\n\n\tprivate submitCompleteOp(taskId: string): void {\n\t\tconst op: ITaskManagerCompletedOperation = {\n\t\t\ttype: \"complete\",\n\t\t\ttaskId,\n\t\t};\n\t\tconst pendingOp: IPendingOp = {\n\t\t\ttype: \"complete\",\n\t\t\tmessageId: this.nextPendingMessageId++,\n\t\t};\n\n\t\tthis.submitLocalMessage(op, pendingOp.messageId);\n\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\tif (latestPendingOps === undefined) {\n\t\t\tthis.latestPendingOps.set(taskId, [pendingOp]);\n\t\t} else {\n\t\t\tlatestPendingOps.push(pendingOp);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.volunteerForTask}\n\t */\n\tpublic async volunteerForTask(taskId: string): Promise<boolean> {\n\t\t// If we are both queued and assigned, then we have the lock and do not\n\t\t// have any pending abandon/complete ops. In this case we can resolve\n\t\t// true immediately.\n\t\tif (this.queuedOptimistically(taskId) && this.assigned(taskId)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (this.readOnlyInfo.readonly === true) {\n\t\t\tconst error =\n\t\t\t\tthis.readOnlyInfo.permissions === true\n\t\t\t\t\t? new Error(\"Attempted to volunteer with read-only permissions\")\n\t\t\t\t\t: new Error(\"Attempted to volunteer in read-only state\");\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (this.isDetached()) {\n\t\t\t// Simulate auto-ack in detached scenario\n\t\t\tassert(this.clientId !== undefined, 0x472 /* clientId should not be undefined */);\n\t\t\tthis.addClientToQueue(taskId, this.clientId);\n\t\t\treturn true;\n\t\t}\n\n\t\tif (!this.connected) {\n\t\t\tthrow new Error(\"Attempted to volunteer in disconnected state\");\n\t\t}\n\n\t\t// This promise works even if we already have an outstanding volunteer op.\n\t\tconst lockAcquireP = new Promise<boolean>((resolve, reject) => {\n\t\t\t// If we don't send an op (meaning the latest pending op is \"volunteer\"), nextPendingMessageId\n\t\t\t// will be greater than that prior \"volunteer\" op's messageId. This is OK because\n\t\t\t// we only use it to filter stale abandon/complete, and not when determining if we\n\t\t\t// acquired the lock.\n\t\t\tconst nextPendingMessageId = this.nextPendingMessageId;\n\t\t\tconst setupListeners = (): void => {\n\t\t\t\tthis.queueWatcher.on(\"queueChange\", checkIfAcquiredLock);\n\t\t\t\tthis.abandonWatcher.on(\"abandon\", checkIfAbandoned);\n\t\t\t\tthis.connectionWatcher.on(\"disconnect\", rejectOnDisconnect);\n\t\t\t\tthis.completedWatcher.on(\"completed\", checkIfCompleted);\n\t\t\t\tthis.rollbackWatcher.on(\"rollback\", checkIfRolledBack);\n\t\t\t};\n\t\t\tconst removeListeners = (): void => {\n\t\t\t\tthis.queueWatcher.off(\"queueChange\", checkIfAcquiredLock);\n\t\t\t\tthis.abandonWatcher.off(\"abandon\", checkIfAbandoned);\n\t\t\t\tthis.connectionWatcher.off(\"disconnect\", rejectOnDisconnect);\n\t\t\t\tthis.completedWatcher.off(\"completed\", checkIfCompleted);\n\t\t\t\tthis.rollbackWatcher.off(\"rollback\", checkIfRolledBack);\n\t\t\t};\n\n\t\t\tconst checkIfAcquiredLock = (eventTaskId: string): void => {\n\t\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Also check pending ops here because it's possible we are currently in the queue from a previous\n\t\t\t\t// lock attempt, but have an outstanding abandon AND the outstanding volunteer for this lock attempt.\n\t\t\t\t// If we reach the head of the queue based on the previous lock attempt, we don't want to resolve.\n\t\t\t\tif (this.assigned(taskId)) {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tresolve(true);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst checkIfAbandoned = (eventTaskId: string, messageId: number | undefined): void => {\n\t\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (messageId !== undefined && messageId <= nextPendingMessageId) {\n\t\t\t\t\t// Ignore abandon events that were for abandon ops that were sent prior to our current volunteer attempt.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tremoveListeners();\n\t\t\t\treject(new Error(\"Abandoned before acquiring task assignment\"));\n\t\t\t};\n\n\t\t\tconst rejectOnDisconnect = (): void => {\n\t\t\t\tremoveListeners();\n\t\t\t\treject(new Error(\"Disconnected before acquiring task assignment\"));\n\t\t\t};\n\n\t\t\tconst checkIfCompleted = (eventTaskId: string, messageId: number | undefined): void => {\n\t\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (messageId !== undefined && messageId <= nextPendingMessageId) {\n\t\t\t\t\t// Ignore abandon events that were for abandon ops that were sent prior to our current volunteer attempt.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tremoveListeners();\n\t\t\t\tresolve(false);\n\t\t\t};\n\n\t\t\tconst checkIfRolledBack = (eventTaskId: string): void => {\n\t\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tremoveListeners();\n\t\t\t\tresolve(false);\n\t\t\t};\n\n\t\t\tsetupListeners();\n\t\t});\n\n\t\tif (!this.queuedOptimistically(taskId)) {\n\t\t\t// Only send the volunteer op if we are not already queued.\n\t\t\tthis.submitVolunteerOp(taskId);\n\t\t}\n\t\treturn lockAcquireP;\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.subscribeToTask}\n\t */\n\tpublic subscribeToTask(taskId: string): void {\n\t\tif (this.subscribed(taskId)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.readOnlyInfo.readonly === true && this.readOnlyInfo.permissions === true) {\n\t\t\tthrow new Error(\"Attempted to subscribe with read-only permissions\");\n\t\t}\n\n\t\tlet volunteerOpMessageId: number | undefined;\n\n\t\tconst submitVolunteerOp = (): void => {\n\t\t\tvolunteerOpMessageId = this.nextPendingMessageId;\n\t\t\tthis.submitVolunteerOp(taskId);\n\t\t};\n\n\t\tconst setupListeners = (): void => {\n\t\t\tthis.abandonWatcher.on(\"abandon\", checkIfAbandoned);\n\t\t\tthis.connectionWatcher.on(\"disconnect\", disconnectHandler);\n\t\t\tthis.completedWatcher.on(\"completed\", checkIfCompleted);\n\t\t\tthis.rollbackWatcher.on(\"rollback\", checkIfRolledBack);\n\t\t};\n\t\tconst removeListeners = (): void => {\n\t\t\tthis.abandonWatcher.off(\"abandon\", checkIfAbandoned);\n\t\t\tthis.connectionWatcher.off(\"disconnect\", disconnectHandler);\n\t\t\tthis.connectionWatcher.off(\"connect\", submitVolunteerOp);\n\t\t\tthis.completedWatcher.off(\"completed\", checkIfCompleted);\n\t\t\tthis.rollbackWatcher.off(\"rollback\", checkIfRolledBack);\n\t\t};\n\n\t\tconst disconnectHandler = (): void => {\n\t\t\t// Wait to be connected again and then re-submit volunteer op\n\t\t\tthis.connectionWatcher.once(\"connect\", submitVolunteerOp);\n\t\t};\n\n\t\tconst checkIfAbandoned = (eventTaskId: string, messageId: number | undefined): void => {\n\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// abandonWatcher emits twice for a local abandon() call. When initially called it\n\t\t\t// will emit with undefined messageId. It will emit a second time when the op is\n\t\t\t// ack'd and processed, this time with the messageId for the ack.\n\t\t\t// This condition accounts ensures we don't ignore the initial abandon() emit and\n\t\t\t// only ignore emits associated with ack'd abandon ops that were sent prior to the\n\t\t\t// current volunteer attempt.\n\t\t\tif (\n\t\t\t\tmessageId !== undefined &&\n\t\t\t\tvolunteerOpMessageId !== undefined &&\n\t\t\t\tmessageId <= volunteerOpMessageId\n\t\t\t) {\n\t\t\t\t// Ignore abandon events that were for abandon ops that were sent prior to our current volunteer attempt.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tremoveListeners();\n\t\t\tthis.subscribedTasks.delete(taskId);\n\t\t};\n\n\t\tconst checkIfCompleted = (eventTaskId: string, messageId: number | undefined): void => {\n\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tmessageId !== undefined &&\n\t\t\t\tvolunteerOpMessageId !== undefined &&\n\t\t\t\tmessageId <= volunteerOpMessageId\n\t\t\t) {\n\t\t\t\t// Ignore abandon events that were for abandon ops that were sent prior to our current volunteer attempt.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tremoveListeners();\n\t\t\tthis.subscribedTasks.delete(taskId);\n\t\t};\n\n\t\tconst checkIfRolledBack = (eventTaskId: string): void => {\n\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tremoveListeners();\n\t\t\tthis.subscribedTasks.delete(taskId);\n\t\t};\n\n\t\tsetupListeners();\n\n\t\tif (this.isDetached()) {\n\t\t\t// Simulate auto-ack in detached scenario\n\t\t\tassert(this.clientId !== undefined, 0x473 /* clientId should not be undefined */);\n\t\t\tthis.addClientToQueue(taskId, this.clientId);\n\t\t\t// Because we volunteered with placeholderClientId, we need to wait for when we attach and are assigned\n\t\t\t// a real clientId. At that point we should re-enter the queue with a real volunteer op (assuming we are\n\t\t\t// connected).\n\t\t\tthis.runtime.once(\"attached\", () => {\n\t\t\t\t// We call scrubClientsNotInQuorum() in case our clientId changed during the attach process.\n\t\t\t\tthis.scrubClientsNotInQuorum();\n\t\t\t\tif (this.connected) {\n\t\t\t\t\tsubmitVolunteerOp();\n\t\t\t\t} else {\n\t\t\t\t\tthis.connectionWatcher.once(\"connect\", submitVolunteerOp);\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (!this.connected) {\n\t\t\t// If we are disconnected (and attached), wait to be connected and submit volunteer op\n\t\t\tdisconnectHandler();\n\t\t} else if (!this.queuedOptimistically(taskId)) {\n\t\t\t// We don't need to send a second volunteer op if we just sent one.\n\t\t\tsubmitVolunteerOp();\n\t\t}\n\t\tthis.subscribedTasks.add(taskId);\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.abandon}\n\t */\n\tpublic abandon(taskId: string): void {\n\t\t// Always allow abandon if the client is subscribed to allow clients to unsubscribe while disconnected.\n\t\t// Otherwise, we should check to make sure the client is optimistically queued for the task before trying to abandon.\n\t\tif (!this.queuedOptimistically(taskId) && !this.subscribed(taskId)) {\n\t\t\t// Nothing to do\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.isDetached()) {\n\t\t\t// Simulate auto-ack in detached scenario\n\t\t\tassert(this.clientId !== undefined, 0x474 /* clientId is undefined */);\n\t\t\tthis.removeClientFromQueue(taskId, this.clientId);\n\t\t\tthis.abandonWatcher.emit(\"abandon\", taskId);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitAbandonOp(taskId);\n\t\tthis.abandonWatcher.emit(\"abandon\", taskId);\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.assigned}\n\t */\n\tpublic assigned(taskId: string): boolean {\n\t\tif (this.isAttached() && !this.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst currentAssignee = this.taskQueues.get(taskId)?.[0];\n\t\treturn currentAssignee !== undefined && currentAssignee === this.clientId;\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.queued}\n\t */\n\tpublic queued(taskId: string): boolean {\n\t\tif (this.isAttached() && !this.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\tassert(this.clientId !== undefined, 0x07f /* \"clientId undefined\" */);\n\t\treturn this.taskQueues.get(taskId)?.includes(this.clientId) ?? false;\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.subscribed}\n\t */\n\tpublic subscribed(taskId: string): boolean {\n\t\treturn this.subscribedTasks.has(taskId);\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.complete}\n\t */\n\tpublic complete(taskId: string): void {\n\t\tif (!this.assigned(taskId)) {\n\t\t\tthrow new Error(\"Attempted to mark task as complete while not being assigned\");\n\t\t}\n\n\t\t// If we are detached we will simulate auto-ack for the complete op. Therefore we only need to send the op if\n\t\t// we are attached. Additionally, we don't need to check if we are connected while detached.\n\t\tif (this.isDetached()) {\n\t\t\tthis.taskQueues.delete(taskId);\n\t\t\tthis.completedWatcher.emit(\"completed\", taskId);\n\t\t\tthis.emit(\"completed\", taskId);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!this.connected) {\n\t\t\tthrow new Error(\"Attempted to complete task in disconnected state\");\n\t\t}\n\t\tthis.submitCompleteOp(taskId);\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.canVolunteer}\n\t */\n\tpublic canVolunteer(): boolean {\n\t\t// A client can volunteer for a task if it's both connected to the delta stream and in write mode.\n\t\t// this.connected reflects that condition, but is unintuitive and may be changed in the future. This API allows\n\t\t// us to make changes to this.connected without affecting our guidance on how to check if a client is eligible\n\t\t// to volunteer for a task.\n\t\treturn this.connected;\n\t}\n\n\t/**\n\t * Create a summary for the task manager\n\t *\n\t * @returns the summary of the current state of the task manager\n\t */\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tif (this.runtime.clientId === undefined) {\n\t\t\t// If the runtime has still not been assigned a clientId, we should not summarize with the placeholder\n\t\t\t// clientIds and instead remove them from the queues and require the client to re-volunteer when assigned\n\t\t\t// a new clientId.\n\t\t\tthis.removeClientFromAllQueues(placeholderClientId);\n\t\t} else {\n\t\t\t// If the runtime has been assigned an actual clientId by now, we can replace the placeholder clientIds\n\t\t\t// and maintain the task assignment.\n\t\t\tthis.replacePlaceholderInAllQueues();\n\t\t}\n\n\t\t// Only include tasks if there are clients in the queue.\n\t\tconst filteredMap = new Map<string, string[]>();\n\t\tfor (const [taskId, queue] of this.taskQueues) {\n\t\t\tif (queue.length > 0) {\n\t\t\t\tfilteredMap.set(taskId, queue);\n\t\t\t}\n\t\t}\n\t\tconst content = [...filteredMap.entries()];\n\t\treturn createSingleBlobSummary(snapshotFileName, JSON.stringify(content));\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst content = await readAndParse<[string, string[]][]>(storage, snapshotFileName);\n\t\tfor (const [taskId, clientIdQueue] of content) {\n\t\t\tthis.taskQueues.set(taskId, clientIdQueue);\n\t\t}\n\t\tthis.scrubClientsNotInQuorum();\n\t}\n\n\t/***/\n\tprotected initializeLocalCore(): void {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n\t */\n\tprotected onDisconnect(): void {\n\t\tthis.connectionWatcher.emit(\"disconnect\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onConnect}\n\t */\n\tprotected onConnect(): void {\n\t\tthis.connectionWatcher.emit(\"connect\");\n\t}\n\n\t/**\n\t * Override resubmit core to avoid resubmission on reconnect. On disconnect we accept our removal from the\n\t * queues, and leave it up to the user to decide whether they want to attempt to re-enter a queue on reconnect.\n\t * However, we do need to update latestPendingOps to account for the ops we will no longer be processing.\n\t */\n\tprotected reSubmitCore(content: unknown, localOpMetadata: number): void {\n\t\tassertIsTaskManagerOperation(content);\n\t\tconst pendingOps = this.latestPendingOps.get(content.taskId);\n\t\tassert(pendingOps !== undefined, \"No pending ops for task on resubmit attempt\");\n\t\tconst pendingOpIndex = pendingOps.findIndex(\n\t\t\t(op) => op.messageId === localOpMetadata && op.type === content.type,\n\t\t);\n\t\tassert(pendingOpIndex !== -1, \"Could not match pending op on resubmit attempt\");\n\t\tpendingOps.splice(pendingOpIndex, 1);\n\t\tif (pendingOps.length === 0) {\n\t\t\tthis.latestPendingOps.delete(content.taskId);\n\t\t}\n\t}\n\n\t/**\n\t * Process a task manager operation\n\t *\n\t * @param message - the message to prepare\n\t * @param local - whether the message was sent by the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t */\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: number | undefined,\n\t): void {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\tif (message.type === MessageType.Operation) {\n\t\t\tconst op = message.contents as ITaskManagerOperation;\n\t\t\tconst messageId = localOpMetadata;\n\n\t\t\tswitch (op.type) {\n\t\t\t\tcase \"volunteer\": {\n\t\t\t\t\tthis.opWatcher.emit(\"volunteer\", op.taskId, message.clientId, local, messageId);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"abandon\": {\n\t\t\t\t\tthis.opWatcher.emit(\"abandon\", op.taskId, message.clientId, local, messageId);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"complete\": {\n\t\t\t\t\tthis.opWatcher.emit(\"complete\", op.taskId, message.clientId, local, messageId);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate addClientToQueue(taskId: string, clientId: string): void {\n\t\t// Ensure that the clientId exists in the quorum, or it is placeholderClientId (detached scenario)\n\t\tif (\n\t\t\tthis.runtime.getQuorum().getMembers().has(clientId) ||\n\t\t\tthis.clientId === placeholderClientId\n\t\t) {\n\t\t\t// Create the queue if it doesn't exist, and push the client on the back.\n\t\t\tlet clientQueue = this.taskQueues.get(taskId);\n\t\t\tif (clientQueue === undefined) {\n\t\t\t\tclientQueue = [];\n\t\t\t\tthis.taskQueues.set(taskId, clientQueue);\n\t\t\t}\n\n\t\t\tif (clientQueue.includes(clientId)) {\n\t\t\t\t// We shouldn't re-add the client if it's already in the queue.\n\t\t\t\t// This may be possible in scenarios where a client was added in\n\t\t\t\t// while detached.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst oldLockHolder = clientQueue[0];\n\t\t\tclientQueue.push(clientId);\n\t\t\tconst newLockHolder = clientQueue[0];\n\t\t\tif (newLockHolder !== oldLockHolder) {\n\t\t\t\tthis.queueWatcher.emit(\"queueChange\", taskId, oldLockHolder, newLockHolder);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate removeClientFromQueue(taskId: string, clientId: string): void {\n\t\tconst clientQueue = this.taskQueues.get(taskId);\n\t\tif (clientQueue === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst oldLockHolder =\n\t\t\tclientId === placeholderClientId ? placeholderClientId : clientQueue[0];\n\t\tconst clientIdIndex = clientQueue.indexOf(clientId);\n\t\tif (clientIdIndex !== -1) {\n\t\t\tclientQueue.splice(clientIdIndex, 1);\n\t\t\t// Clean up the queue if there are no more clients in it.\n\t\t\tif (clientQueue.length === 0) {\n\t\t\t\tthis.taskQueues.delete(taskId);\n\t\t\t}\n\t\t}\n\t\tconst newLockHolder = clientQueue[0];\n\t\tif (newLockHolder !== oldLockHolder) {\n\t\t\tthis.queueWatcher.emit(\"queueChange\", taskId, oldLockHolder, newLockHolder);\n\t\t}\n\t}\n\n\tprivate removeClientFromAllQueues(clientId: string): void {\n\t\tfor (const taskId of this.taskQueues.keys()) {\n\t\t\tthis.removeClientFromQueue(taskId, clientId);\n\t\t}\n\t}\n\n\t/**\n\t * Will replace all instances of the placeholderClientId with the current clientId. This should only be called when\n\t * transitioning from detached to attached and this.runtime.clientId is defined.\n\t */\n\tprivate replacePlaceholderInAllQueues(): void {\n\t\tassert(\n\t\t\tthis.runtime.clientId !== undefined,\n\t\t\t0x475 /* this.runtime.clientId should be defined */,\n\t\t);\n\t\tfor (const clientQueue of this.taskQueues.values()) {\n\t\t\tconst clientIdIndex = clientQueue.indexOf(placeholderClientId);\n\t\t\tif (clientIdIndex !== -1) {\n\t\t\t\tif (clientQueue.includes(this.runtime.clientId)) {\n\t\t\t\t\t// If the real clientId is already in the queue, just remove the placeholder.\n\t\t\t\t\tclientQueue.splice(clientIdIndex, 1);\n\t\t\t\t} else {\n\t\t\t\t\tclientQueue[clientIdIndex] = this.runtime.clientId;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// This seems like it should be unnecessary if we can trust to receive the join/leave messages and\n\t// also have an accurate snapshot.\n\tprivate scrubClientsNotInQuorum(): void {\n\t\tconst quorum = this.runtime.getQuorum();\n\t\tfor (const [taskId, clientQueue] of this.taskQueues) {\n\t\t\tconst filteredClientQueue = clientQueue.filter(\n\t\t\t\t(clientId) => quorum.getMember(clientId) !== undefined,\n\t\t\t);\n\t\t\tif (clientQueue.length !== filteredClientQueue.length) {\n\t\t\t\tif (filteredClientQueue.length === 0) {\n\t\t\t\t\tthis.taskQueues.delete(taskId);\n\t\t\t\t} else {\n\t\t\t\t\tthis.taskQueues.set(taskId, filteredClientQueue);\n\t\t\t\t}\n\t\t\t\tthis.queueWatcher.emit(\"queueChange\", taskId);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Checks whether this client is currently assigned or in queue to become assigned, while also accounting\n\t * for the latest pending ops.\n\t */\n\tprivate queuedOptimistically(taskId: string): boolean {\n\t\tif (this.isAttached() && !this.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\tassert(this.clientId !== undefined, 0x07f /* \"clientId undefined\" */);\n\n\t\tconst inQueue = this.taskQueues.get(taskId)?.includes(this.clientId) ?? false;\n\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\n\t\tconst latestPendingOp =\n\t\t\tlatestPendingOps !== undefined && latestPendingOps.length > 0\n\t\t\t\t? latestPendingOps[latestPendingOps.length - 1]\n\t\t\t\t: undefined;\n\t\tconst isPendingVolunteer = latestPendingOp?.type === \"volunteer\";\n\t\tconst isPendingAbandonOrComplete =\n\t\t\tlatestPendingOp?.type === \"abandon\" || latestPendingOp?.type === \"complete\";\n\t\t// We return true if the client is either in queue already or the latest pending op for this task is a volunteer op.\n\t\t// But we should always return false if the latest pending op is an abandon or complete op.\n\t\treturn (inQueue && !isPendingAbandonOrComplete) || isPendingVolunteer;\n\t}\n\n\t/**\n\t * Returns true if the client is detached.\n\t * This is distinct from !this.isAttached() because `isAttached()` also checks if `this._isBoundToContext`\n\t * is true. We use `isDetached()` to determine if we should simulate auto-ack behavior for ops, which is\n\t * mainly concerned with if we have been assigned a real clientId yet.\n\t */\n\tprivate isDetached(): boolean {\n\t\treturn this.runtime.attachState === AttachState.Detached;\n\t}\n\n\tprotected applyStashedOp(content: unknown): void {\n\t\t// We don't apply any stashed ops since during the rehydration process. Since we lose any assigned tasks\n\t\t// during rehydration we cannot be assigned any tasks. Additionally, without the in-memory state of the\n\t\t// previous dds, we also cannot re-volunteer based on a previous subscribeToTask() call. Since we are\n\t\t// unable to be assigned to any tasks, there is no reason to process abandon/complete ops either.\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n\t */\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tassert(typeof localOpMetadata === \"number\", \"Expect localOpMetadata to be a number\");\n\t\tassertIsTaskManagerOperation(content);\n\t\tconst latestPendingOps = this.latestPendingOps.get(content.taskId);\n\t\tassert(latestPendingOps !== undefined, \"No pending ops when trying to rollback\");\n\t\tconst pendingOpToRollback = latestPendingOps.pop();\n\t\tassert(\n\t\t\tpendingOpToRollback !== undefined && pendingOpToRollback.messageId === localOpMetadata,\n\t\t\t\"pending op mismatch\",\n\t\t);\n\t\tif (latestPendingOps.length === 0) {\n\t\t\tthis.latestPendingOps.delete(content.taskId);\n\t\t}\n\t\tthis.rollbackWatcher.emit(\"rollback\", content.taskId);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"taskManager.js","sourceRoot":"","sources":["../src/taskManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EACN,WAAW,GAEX,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAO7D,OAAO,EAAE,WAAW,EAAE,MAAM,6CAA6C,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAGrE,OAAO,EACN,YAAY,EACZ,uBAAuB,GACvB,MAAM,6CAA6C,CAAC;AAgCrD,SAAS,4BAA4B,CAAC,EAAW;IAChD,MAAM,CACL,OAAO,EAAE,KAAK,QAAQ;QACrB,EAAE,KAAK,IAAI;QACX,QAAQ,IAAI,EAAE;QACd,OAAO,EAAE,CAAC,MAAM,KAAK,QAAQ;QAC7B,MAAM,IAAI,EAAE;QACZ,CAAC,EAAE,CAAC,IAAI,KAAK,WAAW,IAAI,EAAE,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,CAAC,IAAI,KAAK,UAAU,CAAC,EAC7E,KAAK,CAAC,iCAAiC,CACvC,CAAC;AACH,CAAC;AAED,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;GAEG;AACH,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,OAAO,gBAC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AAI,CAAC,OAAO,CAAC,WAAW,KAAK,WAAW,CAAC,QAAQ,CAAC;IAC1D,CAAC;IAES,cAAc,CAAC,OAAgB;QACxC,wGAAwG;QACxG,uGAAuG;QACvG,qGAAqG;QACrG,iGAAiG;IAClG,CAAC;IAED;;OAEG;IACO,QAAQ,CAAC,OAAgB,EAAE,eAAwB;QAC5D,MAAM,CACL,OAAO,eAAe,KAAK,QAAQ,EACnC,KAAK,CAAC,2CAA2C,CACjD,CAAC;QACF,4BAA4B,CAAC,OAAO,CAAC,CAAC;QACtC,MAAM,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACnE,MAAM,CAAC,gBAAgB,KAAK,SAAS,EAAE,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAC3F,MAAM,mBAAmB,GAAG,gBAAgB,CAAC,GAAG,EAAE,CAAC;QACnD,MAAM,CACL,mBAAmB,KAAK,SAAS,IAAI,mBAAmB,CAAC,SAAS,KAAK,eAAe,EACtF,KAAK,CAAC,yBAAyB,CAC/B,CAAC;QACF,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC9C,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACvD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"@fluid-internal/client-utils\";\nimport {\n\tAttachState,\n\ttype ReadOnlyInfo,\n} from \"@fluidframework/container-definitions/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport { MessageType } from \"@fluidframework/driver-definitions/internal\";\nimport { readAndParse } from \"@fluidframework/driver-utils/internal\";\nimport type { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport {\n\tSharedObject,\n\tcreateSingleBlobSummary,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ITaskManager, ITaskManagerEvents } from \"./interfaces.js\";\n\n/**\n * Description of a task manager operation\n */\ntype ITaskManagerOperation =\n\t| ITaskManagerVolunteerOperation\n\t| ITaskManagerAbandonOperation\n\t| ITaskManagerCompletedOperation;\n\ninterface ITaskManagerVolunteerOperation {\n\ttype: \"volunteer\";\n\ttaskId: string;\n}\n\ninterface ITaskManagerAbandonOperation {\n\ttype: \"abandon\";\n\ttaskId: string;\n}\n\ninterface ITaskManagerCompletedOperation {\n\ttype: \"complete\";\n\ttaskId: string;\n}\n\ninterface IPendingOp {\n\ttype: \"volunteer\" | \"abandon\" | \"complete\";\n\tmessageId: number;\n}\n\nfunction assertIsTaskManagerOperation(op: unknown): asserts op is ITaskManagerOperation {\n\tassert(\n\t\ttypeof op === \"object\" &&\n\t\t\top !== null &&\n\t\t\t\"taskId\" in op &&\n\t\t\ttypeof op.taskId === \"string\" &&\n\t\t\t\"type\" in op &&\n\t\t\t(op.type === \"volunteer\" || op.type === \"abandon\" || op.type === \"complete\"),\n\t\t0xc3b /* Not a TaskManager operation */,\n\t);\n}\n\nconst snapshotFileName = \"header\";\n\n/**\n * Placeholder clientId for detached scenarios.\n */\nconst placeholderClientId = \"placeholder\";\n\n/**\n * {@inheritDoc ITaskManager}\n *\n * @sealed\n * @legacy @beta\n */\nexport class TaskManagerClass\n\textends SharedObject<ITaskManagerEvents>\n\timplements ITaskManager\n{\n\t/**\n\t * Mapping of taskId to a queue of clientIds that are waiting on the task. Maintains the consensus state of the\n\t * queue, even if we know we've submitted an op that should eventually modify the queue.\n\t */\n\tprivate readonly taskQueues = new Map<string, string[]>();\n\n\t// opWatcher emits for every op on this data store. This is just a repackaging of processCore into events.\n\tprivate readonly opWatcher: EventEmitter = new EventEmitter();\n\t// queueWatcher emits an event whenever the consensus state of the task queues changes\n\tprivate readonly queueWatcher: EventEmitter = new EventEmitter();\n\t// abandonWatcher emits an event whenever the local client calls abandon() on a task.\n\tprivate readonly abandonWatcher: EventEmitter = new EventEmitter();\n\t// connectionWatcher emits an event whenever we get connected or disconnected.\n\tprivate readonly connectionWatcher: EventEmitter = new EventEmitter();\n\t// completedWatcher emits an event whenever the local client receives a completed op.\n\tprivate readonly completedWatcher: EventEmitter = new EventEmitter();\n\t// rollbackWatcher emits an event whenever a pending op is rolled back.\n\tprivate readonly rollbackWatcher: EventEmitter = new EventEmitter();\n\n\tprivate nextPendingMessageId: number = 0;\n\t/**\n\t * Tracks the most recent pending op for a given task\n\t */\n\tprivate readonly latestPendingOps = new Map<string, IPendingOp[]>();\n\n\t/**\n\t * Tracks tasks that are this client is currently subscribed to.\n\t */\n\tprivate readonly subscribedTasks = new Set<string>();\n\n\t/**\n\t * Returns the clientId. Will return a placeholder if the runtime is detached and not yet assigned a clientId.\n\t */\n\tprivate get clientId(): string | undefined {\n\t\treturn this.isAttached() ? this.runtime.clientId : placeholderClientId;\n\t}\n\n\t/**\n\t * Returns a ReadOnlyInfo object to determine current read/write permissions.\n\t */\n\tprivate get readOnlyInfo(): ReadOnlyInfo {\n\t\treturn this.deltaManager.readOnlyInfo;\n\t}\n\n\t/**\n\t * Constructs a new task manager. If the object is non-local an id and service interfaces will\n\t * be provided\n\t *\n\t * @param runtime - data store runtime the task queue belongs to\n\t * @param id - optional name of the task queue\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_taskManager_\");\n\n\t\tthis.opWatcher.on(\n\t\t\t\"volunteer\",\n\t\t\t(taskId: string, clientId: string, local: boolean, messageId: number | undefined) => {\n\t\t\t\tif (local) {\n\t\t\t\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\t\t\t\tassert(latestPendingOps !== undefined, 0xc3c /* No pending ops for task */);\n\t\t\t\t\tconst pendingOp = latestPendingOps.shift();\n\t\t\t\t\tassert(\n\t\t\t\t\t\tpendingOp !== undefined && pendingOp.messageId === messageId,\n\t\t\t\t\t\t0xc3d /* Unexpected op */,\n\t\t\t\t\t);\n\t\t\t\t\tassert(pendingOp.type === \"volunteer\", 0x07c /* \"Unexpected op type\" */);\n\t\t\t\t\tif (latestPendingOps.length === 0) {\n\t\t\t\t\t\tthis.latestPendingOps.delete(taskId);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.addClientToQueue(taskId, clientId);\n\t\t\t},\n\t\t);\n\n\t\tthis.opWatcher.on(\n\t\t\t\"abandon\",\n\t\t\t(taskId: string, clientId: string, local: boolean, messageId: number | undefined) => {\n\t\t\t\tif (local) {\n\t\t\t\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\t\t\t\tassert(latestPendingOps !== undefined, 0xc3e /* No pending ops for task */);\n\t\t\t\t\tconst pendingOp = latestPendingOps.shift();\n\t\t\t\t\tassert(\n\t\t\t\t\t\tpendingOp !== undefined && pendingOp.messageId === messageId,\n\t\t\t\t\t\t0xc3f /* Unexpected op */,\n\t\t\t\t\t);\n\t\t\t\t\tassert(pendingOp.type === \"abandon\", 0x07e /* \"Unexpected op type\" */);\n\t\t\t\t\tif (latestPendingOps.length === 0) {\n\t\t\t\t\t\tthis.latestPendingOps.delete(taskId);\n\t\t\t\t\t}\n\t\t\t\t\tthis.abandonWatcher.emit(\"abandon\", taskId, messageId);\n\t\t\t\t}\n\n\t\t\t\tthis.removeClientFromQueue(taskId, clientId);\n\t\t\t},\n\t\t);\n\n\t\tthis.opWatcher.on(\n\t\t\t\"complete\",\n\t\t\t(taskId: string, clientId: string, local: boolean, messageId: number | undefined) => {\n\t\t\t\tif (local) {\n\t\t\t\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\t\t\t\tassert(latestPendingOps !== undefined, 0xc40 /* No pending ops for task */);\n\t\t\t\t\tconst pendingOp = latestPendingOps.shift();\n\t\t\t\t\tassert(\n\t\t\t\t\t\tpendingOp !== undefined && pendingOp.messageId === messageId,\n\t\t\t\t\t\t0xc41 /* Unexpected op */,\n\t\t\t\t\t);\n\t\t\t\t\tassert(pendingOp.type === \"complete\", 0x401 /* Unexpected op type */);\n\t\t\t\t\tif (latestPendingOps.length === 0) {\n\t\t\t\t\t\tthis.latestPendingOps.delete(taskId);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.taskQueues.delete(taskId);\n\t\t\t\tthis.completedWatcher.emit(\"completed\", taskId, messageId);\n\t\t\t\tthis.emit(\"completed\", taskId);\n\t\t\t},\n\t\t);\n\n\t\truntime.getQuorum().on(\"removeMember\", (clientId: string) => {\n\t\t\tthis.removeClientFromAllQueues(clientId);\n\t\t});\n\n\t\tthis.queueWatcher.on(\n\t\t\t\"queueChange\",\n\t\t\t(taskId: string, oldLockHolder: string, newLockHolder: string) => {\n\t\t\t\t// If oldLockHolder is placeholderClientId we need to emit the task was lost during the attach process\n\t\t\t\tif (oldLockHolder === placeholderClientId) {\n\t\t\t\t\tthis.emit(\"lost\", taskId);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Exit early if we are still catching up on reconnect -- we can't be the leader yet anyway.\n\t\t\t\tif (this.clientId === undefined) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (oldLockHolder !== this.clientId && newLockHolder === this.clientId) {\n\t\t\t\t\tthis.emit(\"assigned\", taskId);\n\t\t\t\t} else if (oldLockHolder === this.clientId && newLockHolder !== this.clientId) {\n\t\t\t\t\tthis.emit(\"lost\", taskId);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tthis.connectionWatcher.on(\"disconnect\", () => {\n\t\t\tassert(this.clientId !== undefined, 0x1d3 /* \"Missing client id on disconnect\" */);\n\n\t\t\t// Emit \"lost\" for any tasks we were assigned to.\n\t\t\tfor (const [taskId, clientQueue] of this.taskQueues.entries()) {\n\t\t\t\tif (this.isAttached() && clientQueue[0] === this.clientId) {\n\t\t\t\t\tthis.emit(\"lost\", taskId);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Remove this client from all queues to reflect the new state, since being disconnected automatically removes\n\t\t\t// this client from all queues.\n\t\t\tthis.removeClientFromAllQueues(this.clientId);\n\t\t});\n\t}\n\n\tprivate submitVolunteerOp(taskId: string): void {\n\t\tconst op: ITaskManagerVolunteerOperation = {\n\t\t\ttype: \"volunteer\",\n\t\t\ttaskId,\n\t\t};\n\t\tconst pendingOp: IPendingOp = {\n\t\t\ttype: \"volunteer\",\n\t\t\tmessageId: this.nextPendingMessageId++,\n\t\t};\n\t\tthis.submitLocalMessage(op, pendingOp.messageId);\n\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\tif (latestPendingOps === undefined) {\n\t\t\tthis.latestPendingOps.set(taskId, [pendingOp]);\n\t\t} else {\n\t\t\tlatestPendingOps.push(pendingOp);\n\t\t}\n\t}\n\n\tprivate submitAbandonOp(taskId: string): void {\n\t\tconst op: ITaskManagerAbandonOperation = {\n\t\t\ttype: \"abandon\",\n\t\t\ttaskId,\n\t\t};\n\t\tconst pendingOp: IPendingOp = {\n\t\t\ttype: \"abandon\",\n\t\t\tmessageId: this.nextPendingMessageId++,\n\t\t};\n\t\tthis.submitLocalMessage(op, pendingOp.messageId);\n\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\tif (latestPendingOps === undefined) {\n\t\t\tthis.latestPendingOps.set(taskId, [pendingOp]);\n\t\t} else {\n\t\t\tlatestPendingOps.push(pendingOp);\n\t\t}\n\t}\n\n\tprivate submitCompleteOp(taskId: string): void {\n\t\tconst op: ITaskManagerCompletedOperation = {\n\t\t\ttype: \"complete\",\n\t\t\ttaskId,\n\t\t};\n\t\tconst pendingOp: IPendingOp = {\n\t\t\ttype: \"complete\",\n\t\t\tmessageId: this.nextPendingMessageId++,\n\t\t};\n\n\t\tthis.submitLocalMessage(op, pendingOp.messageId);\n\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\t\tif (latestPendingOps === undefined) {\n\t\t\tthis.latestPendingOps.set(taskId, [pendingOp]);\n\t\t} else {\n\t\t\tlatestPendingOps.push(pendingOp);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.volunteerForTask}\n\t */\n\tpublic async volunteerForTask(taskId: string): Promise<boolean> {\n\t\t// If we are both queued and assigned, then we have the lock and do not\n\t\t// have any pending abandon/complete ops. In this case we can resolve\n\t\t// true immediately.\n\t\tif (this.queuedOptimistically(taskId) && this.assigned(taskId)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (this.readOnlyInfo.readonly === true) {\n\t\t\tconst error =\n\t\t\t\tthis.readOnlyInfo.permissions === true\n\t\t\t\t\t? new Error(\"Attempted to volunteer with read-only permissions\")\n\t\t\t\t\t: new Error(\"Attempted to volunteer in read-only state\");\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (this.isDetached()) {\n\t\t\t// Simulate auto-ack in detached scenario\n\t\t\tassert(this.clientId !== undefined, 0x472 /* clientId should not be undefined */);\n\t\t\tthis.addClientToQueue(taskId, this.clientId);\n\t\t\treturn true;\n\t\t}\n\n\t\tif (!this.connected) {\n\t\t\tthrow new Error(\"Attempted to volunteer in disconnected state\");\n\t\t}\n\n\t\t// This promise works even if we already have an outstanding volunteer op.\n\t\tconst lockAcquireP = new Promise<boolean>((resolve, reject) => {\n\t\t\t// If we don't send an op (meaning the latest pending op is \"volunteer\"), nextPendingMessageId\n\t\t\t// will be greater than that prior \"volunteer\" op's messageId. This is OK because\n\t\t\t// we only use it to filter stale abandon/complete, and not when determining if we\n\t\t\t// acquired the lock.\n\t\t\tconst nextPendingMessageId = this.nextPendingMessageId;\n\t\t\tconst setupListeners = (): void => {\n\t\t\t\tthis.queueWatcher.on(\"queueChange\", checkIfAcquiredLock);\n\t\t\t\tthis.abandonWatcher.on(\"abandon\", checkIfAbandoned);\n\t\t\t\tthis.connectionWatcher.on(\"disconnect\", rejectOnDisconnect);\n\t\t\t\tthis.completedWatcher.on(\"completed\", checkIfCompleted);\n\t\t\t\tthis.rollbackWatcher.on(\"rollback\", checkIfRolledBack);\n\t\t\t};\n\t\t\tconst removeListeners = (): void => {\n\t\t\t\tthis.queueWatcher.off(\"queueChange\", checkIfAcquiredLock);\n\t\t\t\tthis.abandonWatcher.off(\"abandon\", checkIfAbandoned);\n\t\t\t\tthis.connectionWatcher.off(\"disconnect\", rejectOnDisconnect);\n\t\t\t\tthis.completedWatcher.off(\"completed\", checkIfCompleted);\n\t\t\t\tthis.rollbackWatcher.off(\"rollback\", checkIfRolledBack);\n\t\t\t};\n\n\t\t\tconst checkIfAcquiredLock = (eventTaskId: string): void => {\n\t\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Also check pending ops here because it's possible we are currently in the queue from a previous\n\t\t\t\t// lock attempt, but have an outstanding abandon AND the outstanding volunteer for this lock attempt.\n\t\t\t\t// If we reach the head of the queue based on the previous lock attempt, we don't want to resolve.\n\t\t\t\tif (this.assigned(taskId)) {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tresolve(true);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst checkIfAbandoned = (eventTaskId: string, messageId: number | undefined): void => {\n\t\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (messageId !== undefined && messageId <= nextPendingMessageId) {\n\t\t\t\t\t// Ignore abandon events that were for abandon ops that were sent prior to our current volunteer attempt.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tremoveListeners();\n\t\t\t\treject(new Error(\"Abandoned before acquiring task assignment\"));\n\t\t\t};\n\n\t\t\tconst rejectOnDisconnect = (): void => {\n\t\t\t\tremoveListeners();\n\t\t\t\treject(new Error(\"Disconnected before acquiring task assignment\"));\n\t\t\t};\n\n\t\t\tconst checkIfCompleted = (eventTaskId: string, messageId: number | undefined): void => {\n\t\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (messageId !== undefined && messageId <= nextPendingMessageId) {\n\t\t\t\t\t// Ignore abandon events that were for abandon ops that were sent prior to our current volunteer attempt.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tremoveListeners();\n\t\t\t\tresolve(false);\n\t\t\t};\n\n\t\t\tconst checkIfRolledBack = (eventTaskId: string): void => {\n\t\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tremoveListeners();\n\t\t\t\tresolve(false);\n\t\t\t};\n\n\t\t\tsetupListeners();\n\t\t});\n\n\t\tif (!this.queuedOptimistically(taskId)) {\n\t\t\t// Only send the volunteer op if we are not already queued.\n\t\t\tthis.submitVolunteerOp(taskId);\n\t\t}\n\t\treturn lockAcquireP;\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.subscribeToTask}\n\t */\n\tpublic subscribeToTask(taskId: string): void {\n\t\tif (this.subscribed(taskId)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.readOnlyInfo.readonly === true && this.readOnlyInfo.permissions === true) {\n\t\t\tthrow new Error(\"Attempted to subscribe with read-only permissions\");\n\t\t}\n\n\t\tlet volunteerOpMessageId: number | undefined;\n\n\t\tconst submitVolunteerOp = (): void => {\n\t\t\tvolunteerOpMessageId = this.nextPendingMessageId;\n\t\t\tthis.submitVolunteerOp(taskId);\n\t\t};\n\n\t\tconst setupListeners = (): void => {\n\t\t\tthis.abandonWatcher.on(\"abandon\", checkIfAbandoned);\n\t\t\tthis.connectionWatcher.on(\"disconnect\", disconnectHandler);\n\t\t\tthis.completedWatcher.on(\"completed\", checkIfCompleted);\n\t\t\tthis.rollbackWatcher.on(\"rollback\", checkIfRolledBack);\n\t\t};\n\t\tconst removeListeners = (): void => {\n\t\t\tthis.abandonWatcher.off(\"abandon\", checkIfAbandoned);\n\t\t\tthis.connectionWatcher.off(\"disconnect\", disconnectHandler);\n\t\t\tthis.connectionWatcher.off(\"connect\", submitVolunteerOp);\n\t\t\tthis.completedWatcher.off(\"completed\", checkIfCompleted);\n\t\t\tthis.rollbackWatcher.off(\"rollback\", checkIfRolledBack);\n\t\t};\n\n\t\tconst disconnectHandler = (): void => {\n\t\t\t// Wait to be connected again and then re-submit volunteer op\n\t\t\tthis.connectionWatcher.once(\"connect\", submitVolunteerOp);\n\t\t};\n\n\t\tconst checkIfAbandoned = (eventTaskId: string, messageId: number | undefined): void => {\n\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// abandonWatcher emits twice for a local abandon() call. When initially called it\n\t\t\t// will emit with undefined messageId. It will emit a second time when the op is\n\t\t\t// ack'd and processed, this time with the messageId for the ack.\n\t\t\t// This condition accounts ensures we don't ignore the initial abandon() emit and\n\t\t\t// only ignore emits associated with ack'd abandon ops that were sent prior to the\n\t\t\t// current volunteer attempt.\n\t\t\tif (\n\t\t\t\tmessageId !== undefined &&\n\t\t\t\tvolunteerOpMessageId !== undefined &&\n\t\t\t\tmessageId <= volunteerOpMessageId\n\t\t\t) {\n\t\t\t\t// Ignore abandon events that were for abandon ops that were sent prior to our current volunteer attempt.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tremoveListeners();\n\t\t\tthis.subscribedTasks.delete(taskId);\n\t\t};\n\n\t\tconst checkIfCompleted = (eventTaskId: string, messageId: number | undefined): void => {\n\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tmessageId !== undefined &&\n\t\t\t\tvolunteerOpMessageId !== undefined &&\n\t\t\t\tmessageId <= volunteerOpMessageId\n\t\t\t) {\n\t\t\t\t// Ignore abandon events that were for abandon ops that were sent prior to our current volunteer attempt.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tremoveListeners();\n\t\t\tthis.subscribedTasks.delete(taskId);\n\t\t};\n\n\t\tconst checkIfRolledBack = (eventTaskId: string): void => {\n\t\t\tif (eventTaskId !== taskId) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tremoveListeners();\n\t\t\tthis.subscribedTasks.delete(taskId);\n\t\t};\n\n\t\tsetupListeners();\n\n\t\tif (this.isDetached()) {\n\t\t\t// Simulate auto-ack in detached scenario\n\t\t\tassert(this.clientId !== undefined, 0x473 /* clientId should not be undefined */);\n\t\t\tthis.addClientToQueue(taskId, this.clientId);\n\t\t\t// Because we volunteered with placeholderClientId, we need to wait for when we attach and are assigned\n\t\t\t// a real clientId. At that point we should re-enter the queue with a real volunteer op (assuming we are\n\t\t\t// connected).\n\t\t\tthis.runtime.once(\"attached\", () => {\n\t\t\t\t// We call scrubClientsNotInQuorum() in case our clientId changed during the attach process.\n\t\t\t\tthis.scrubClientsNotInQuorum();\n\t\t\t\tif (this.connected) {\n\t\t\t\t\tsubmitVolunteerOp();\n\t\t\t\t} else {\n\t\t\t\t\tthis.connectionWatcher.once(\"connect\", submitVolunteerOp);\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (!this.connected) {\n\t\t\t// If we are disconnected (and attached), wait to be connected and submit volunteer op\n\t\t\tdisconnectHandler();\n\t\t} else if (!this.queuedOptimistically(taskId)) {\n\t\t\t// We don't need to send a second volunteer op if we just sent one.\n\t\t\tsubmitVolunteerOp();\n\t\t}\n\t\tthis.subscribedTasks.add(taskId);\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.abandon}\n\t */\n\tpublic abandon(taskId: string): void {\n\t\t// Always allow abandon if the client is subscribed to allow clients to unsubscribe while disconnected.\n\t\t// Otherwise, we should check to make sure the client is optimistically queued for the task before trying to abandon.\n\t\tif (!this.queuedOptimistically(taskId) && !this.subscribed(taskId)) {\n\t\t\t// Nothing to do\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.isDetached()) {\n\t\t\t// Simulate auto-ack in detached scenario\n\t\t\tassert(this.clientId !== undefined, 0x474 /* clientId is undefined */);\n\t\t\tthis.removeClientFromQueue(taskId, this.clientId);\n\t\t\tthis.abandonWatcher.emit(\"abandon\", taskId);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitAbandonOp(taskId);\n\t\tthis.abandonWatcher.emit(\"abandon\", taskId);\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.assigned}\n\t */\n\tpublic assigned(taskId: string): boolean {\n\t\tif (this.isAttached() && !this.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst currentAssignee = this.taskQueues.get(taskId)?.[0];\n\t\treturn currentAssignee !== undefined && currentAssignee === this.clientId;\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.queued}\n\t */\n\tpublic queued(taskId: string): boolean {\n\t\tif (this.isAttached() && !this.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\tassert(this.clientId !== undefined, 0x07f /* \"clientId undefined\" */);\n\t\treturn this.taskQueues.get(taskId)?.includes(this.clientId) ?? false;\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.subscribed}\n\t */\n\tpublic subscribed(taskId: string): boolean {\n\t\treturn this.subscribedTasks.has(taskId);\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.complete}\n\t */\n\tpublic complete(taskId: string): void {\n\t\tif (!this.assigned(taskId)) {\n\t\t\tthrow new Error(\"Attempted to mark task as complete while not being assigned\");\n\t\t}\n\n\t\t// If we are detached we will simulate auto-ack for the complete op. Therefore we only need to send the op if\n\t\t// we are attached. Additionally, we don't need to check if we are connected while detached.\n\t\tif (this.isDetached()) {\n\t\t\tthis.taskQueues.delete(taskId);\n\t\t\tthis.completedWatcher.emit(\"completed\", taskId);\n\t\t\tthis.emit(\"completed\", taskId);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!this.connected) {\n\t\t\tthrow new Error(\"Attempted to complete task in disconnected state\");\n\t\t}\n\t\tthis.submitCompleteOp(taskId);\n\t}\n\n\t/**\n\t * {@inheritDoc ITaskManager.canVolunteer}\n\t */\n\tpublic canVolunteer(): boolean {\n\t\t// A client can volunteer for a task if it's both connected to the delta stream and in write mode.\n\t\t// this.connected reflects that condition, but is unintuitive and may be changed in the future. This API allows\n\t\t// us to make changes to this.connected without affecting our guidance on how to check if a client is eligible\n\t\t// to volunteer for a task.\n\t\treturn this.connected;\n\t}\n\n\t/**\n\t * Create a summary for the task manager\n\t *\n\t * @returns the summary of the current state of the task manager\n\t */\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tif (this.runtime.clientId === undefined) {\n\t\t\t// If the runtime has still not been assigned a clientId, we should not summarize with the placeholder\n\t\t\t// clientIds and instead remove them from the queues and require the client to re-volunteer when assigned\n\t\t\t// a new clientId.\n\t\t\tthis.removeClientFromAllQueues(placeholderClientId);\n\t\t} else {\n\t\t\t// If the runtime has been assigned an actual clientId by now, we can replace the placeholder clientIds\n\t\t\t// and maintain the task assignment.\n\t\t\tthis.replacePlaceholderInAllQueues();\n\t\t}\n\n\t\t// Only include tasks if there are clients in the queue.\n\t\tconst filteredMap = new Map<string, string[]>();\n\t\tfor (const [taskId, queue] of this.taskQueues) {\n\t\t\tif (queue.length > 0) {\n\t\t\t\tfilteredMap.set(taskId, queue);\n\t\t\t}\n\t\t}\n\t\tconst content = [...filteredMap.entries()];\n\t\treturn createSingleBlobSummary(snapshotFileName, JSON.stringify(content));\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst content = await readAndParse<[string, string[]][]>(storage, snapshotFileName);\n\t\tfor (const [taskId, clientIdQueue] of content) {\n\t\t\tthis.taskQueues.set(taskId, clientIdQueue);\n\t\t}\n\t\tthis.scrubClientsNotInQuorum();\n\t}\n\n\t/***/\n\tprotected initializeLocalCore(): void {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n\t */\n\tprotected onDisconnect(): void {\n\t\tthis.connectionWatcher.emit(\"disconnect\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onConnect}\n\t */\n\tprotected onConnect(): void {\n\t\tthis.connectionWatcher.emit(\"connect\");\n\t}\n\n\t/**\n\t * Override resubmit core to avoid resubmission on reconnect. On disconnect we accept our removal from the\n\t * queues, and leave it up to the user to decide whether they want to attempt to re-enter a queue on reconnect.\n\t * However, we do need to update latestPendingOps to account for the ops we will no longer be processing.\n\t */\n\tprotected reSubmitCore(content: unknown, localOpMetadata: number): void {\n\t\tassertIsTaskManagerOperation(content);\n\t\tconst pendingOps = this.latestPendingOps.get(content.taskId);\n\t\tassert(pendingOps !== undefined, 0xc42 /* No pending ops for task on resubmit attempt */);\n\t\tconst pendingOpIndex = pendingOps.findIndex(\n\t\t\t(op) => op.messageId === localOpMetadata && op.type === content.type,\n\t\t);\n\t\tassert(pendingOpIndex !== -1, 0xc43 /* Could not match pending op on resubmit attempt */);\n\t\tpendingOps.splice(pendingOpIndex, 1);\n\t\tif (pendingOps.length === 0) {\n\t\t\tthis.latestPendingOps.delete(content.taskId);\n\t\t}\n\t}\n\n\t/**\n\t * Process a task manager operation\n\t *\n\t * @param message - the message to prepare\n\t * @param local - whether the message was sent by the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t */\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: number | undefined,\n\t): void {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\tif (message.type === MessageType.Operation) {\n\t\t\tconst op = message.contents as ITaskManagerOperation;\n\t\t\tconst messageId = localOpMetadata;\n\n\t\t\tswitch (op.type) {\n\t\t\t\tcase \"volunteer\": {\n\t\t\t\t\tthis.opWatcher.emit(\"volunteer\", op.taskId, message.clientId, local, messageId);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"abandon\": {\n\t\t\t\t\tthis.opWatcher.emit(\"abandon\", op.taskId, message.clientId, local, messageId);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"complete\": {\n\t\t\t\t\tthis.opWatcher.emit(\"complete\", op.taskId, message.clientId, local, messageId);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate addClientToQueue(taskId: string, clientId: string): void {\n\t\t// Ensure that the clientId exists in the quorum, or it is placeholderClientId (detached scenario)\n\t\tif (\n\t\t\tthis.runtime.getQuorum().getMembers().has(clientId) ||\n\t\t\tthis.clientId === placeholderClientId\n\t\t) {\n\t\t\t// Create the queue if it doesn't exist, and push the client on the back.\n\t\t\tlet clientQueue = this.taskQueues.get(taskId);\n\t\t\tif (clientQueue === undefined) {\n\t\t\t\tclientQueue = [];\n\t\t\t\tthis.taskQueues.set(taskId, clientQueue);\n\t\t\t}\n\n\t\t\tif (clientQueue.includes(clientId)) {\n\t\t\t\t// We shouldn't re-add the client if it's already in the queue.\n\t\t\t\t// This may be possible in scenarios where a client was added in\n\t\t\t\t// while detached.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst oldLockHolder = clientQueue[0];\n\t\t\tclientQueue.push(clientId);\n\t\t\tconst newLockHolder = clientQueue[0];\n\t\t\tif (newLockHolder !== oldLockHolder) {\n\t\t\t\tthis.queueWatcher.emit(\"queueChange\", taskId, oldLockHolder, newLockHolder);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate removeClientFromQueue(taskId: string, clientId: string): void {\n\t\tconst clientQueue = this.taskQueues.get(taskId);\n\t\tif (clientQueue === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst oldLockHolder =\n\t\t\tclientId === placeholderClientId ? placeholderClientId : clientQueue[0];\n\t\tconst clientIdIndex = clientQueue.indexOf(clientId);\n\t\tif (clientIdIndex !== -1) {\n\t\t\tclientQueue.splice(clientIdIndex, 1);\n\t\t\t// Clean up the queue if there are no more clients in it.\n\t\t\tif (clientQueue.length === 0) {\n\t\t\t\tthis.taskQueues.delete(taskId);\n\t\t\t}\n\t\t}\n\t\tconst newLockHolder = clientQueue[0];\n\t\tif (newLockHolder !== oldLockHolder) {\n\t\t\tthis.queueWatcher.emit(\"queueChange\", taskId, oldLockHolder, newLockHolder);\n\t\t}\n\t}\n\n\tprivate removeClientFromAllQueues(clientId: string): void {\n\t\tfor (const taskId of this.taskQueues.keys()) {\n\t\t\tthis.removeClientFromQueue(taskId, clientId);\n\t\t}\n\t}\n\n\t/**\n\t * Will replace all instances of the placeholderClientId with the current clientId. This should only be called when\n\t * transitioning from detached to attached and this.runtime.clientId is defined.\n\t */\n\tprivate replacePlaceholderInAllQueues(): void {\n\t\tassert(\n\t\t\tthis.runtime.clientId !== undefined,\n\t\t\t0x475 /* this.runtime.clientId should be defined */,\n\t\t);\n\t\tfor (const clientQueue of this.taskQueues.values()) {\n\t\t\tconst clientIdIndex = clientQueue.indexOf(placeholderClientId);\n\t\t\tif (clientIdIndex !== -1) {\n\t\t\t\tif (clientQueue.includes(this.runtime.clientId)) {\n\t\t\t\t\t// If the real clientId is already in the queue, just remove the placeholder.\n\t\t\t\t\tclientQueue.splice(clientIdIndex, 1);\n\t\t\t\t} else {\n\t\t\t\t\tclientQueue[clientIdIndex] = this.runtime.clientId;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// This seems like it should be unnecessary if we can trust to receive the join/leave messages and\n\t// also have an accurate snapshot.\n\tprivate scrubClientsNotInQuorum(): void {\n\t\tconst quorum = this.runtime.getQuorum();\n\t\tfor (const [taskId, clientQueue] of this.taskQueues) {\n\t\t\tconst filteredClientQueue = clientQueue.filter(\n\t\t\t\t(clientId) => quorum.getMember(clientId) !== undefined,\n\t\t\t);\n\t\t\tif (clientQueue.length !== filteredClientQueue.length) {\n\t\t\t\tif (filteredClientQueue.length === 0) {\n\t\t\t\t\tthis.taskQueues.delete(taskId);\n\t\t\t\t} else {\n\t\t\t\t\tthis.taskQueues.set(taskId, filteredClientQueue);\n\t\t\t\t}\n\t\t\t\tthis.queueWatcher.emit(\"queueChange\", taskId);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Checks whether this client is currently assigned or in queue to become assigned, while also accounting\n\t * for the latest pending ops.\n\t */\n\tprivate queuedOptimistically(taskId: string): boolean {\n\t\tif (this.isAttached() && !this.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\tassert(this.clientId !== undefined, 0xc44 /* clientId undefined */);\n\n\t\tconst inQueue = this.taskQueues.get(taskId)?.includes(this.clientId) ?? false;\n\t\tconst latestPendingOps = this.latestPendingOps.get(taskId);\n\n\t\tconst latestPendingOp =\n\t\t\tlatestPendingOps !== undefined && latestPendingOps.length > 0\n\t\t\t\t? latestPendingOps[latestPendingOps.length - 1]\n\t\t\t\t: undefined;\n\t\tconst isPendingVolunteer = latestPendingOp?.type === \"volunteer\";\n\t\tconst isPendingAbandonOrComplete =\n\t\t\tlatestPendingOp?.type === \"abandon\" || latestPendingOp?.type === \"complete\";\n\t\t// We return true if the client is either in queue already or the latest pending op for this task is a volunteer op.\n\t\t// But we should always return false if the latest pending op is an abandon or complete op.\n\t\treturn (inQueue && !isPendingAbandonOrComplete) || isPendingVolunteer;\n\t}\n\n\t/**\n\t * Returns true if the client is detached.\n\t * This is distinct from !this.isAttached() because `isAttached()` also checks if `this._isBoundToContext`\n\t * is true. We use `isDetached()` to determine if we should simulate auto-ack behavior for ops, which is\n\t * mainly concerned with if we have been assigned a real clientId yet.\n\t */\n\tprivate isDetached(): boolean {\n\t\treturn this.runtime.attachState === AttachState.Detached;\n\t}\n\n\tprotected applyStashedOp(content: unknown): void {\n\t\t// We don't apply any stashed ops since during the rehydration process. Since we lose any assigned tasks\n\t\t// during rehydration we cannot be assigned any tasks. Additionally, without the in-memory state of the\n\t\t// previous dds, we also cannot re-volunteer based on a previous subscribeToTask() call. Since we are\n\t\t// unable to be assigned to any tasks, there is no reason to process abandon/complete ops either.\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n\t */\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tassert(\n\t\t\ttypeof localOpMetadata === \"number\",\n\t\t\t0xc45 /* Expect localOpMetadata to be a number */,\n\t\t);\n\t\tassertIsTaskManagerOperation(content);\n\t\tconst latestPendingOps = this.latestPendingOps.get(content.taskId);\n\t\tassert(latestPendingOps !== undefined, 0xc46 /* No pending ops when trying to rollback */);\n\t\tconst pendingOpToRollback = latestPendingOps.pop();\n\t\tassert(\n\t\t\tpendingOpToRollback !== undefined && pendingOpToRollback.messageId === localOpMetadata,\n\t\t\t0xc47 /* pending op mismatch */,\n\t\t);\n\t\tif (latestPendingOps.length === 0) {\n\t\t\tthis.latestPendingOps.delete(content.taskId);\n\t\t}\n\t\tthis.rollbackWatcher.emit(\"rollback\", content.taskId);\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/task-manager",
|
|
3
|
-
"version": "2.61.0
|
|
3
|
+
"version": "2.61.0",
|
|
4
4
|
"description": "Distributed data structure for queueing exclusive tasks",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -81,30 +81,30 @@
|
|
|
81
81
|
"temp-directory": "nyc/.nyc_output"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"@fluid-internal/client-utils": "2.61.0
|
|
85
|
-
"@fluidframework/container-definitions": "2.61.0
|
|
86
|
-
"@fluidframework/container-runtime-definitions": "2.61.0
|
|
87
|
-
"@fluidframework/core-interfaces": "2.61.0
|
|
88
|
-
"@fluidframework/core-utils": "2.61.0
|
|
89
|
-
"@fluidframework/datastore-definitions": "2.61.0
|
|
90
|
-
"@fluidframework/driver-definitions": "2.61.0
|
|
91
|
-
"@fluidframework/driver-utils": "2.61.0
|
|
92
|
-
"@fluidframework/runtime-definitions": "2.61.0
|
|
93
|
-
"@fluidframework/shared-object-base": "2.61.0
|
|
84
|
+
"@fluid-internal/client-utils": "~2.61.0",
|
|
85
|
+
"@fluidframework/container-definitions": "~2.61.0",
|
|
86
|
+
"@fluidframework/container-runtime-definitions": "~2.61.0",
|
|
87
|
+
"@fluidframework/core-interfaces": "~2.61.0",
|
|
88
|
+
"@fluidframework/core-utils": "~2.61.0",
|
|
89
|
+
"@fluidframework/datastore-definitions": "~2.61.0",
|
|
90
|
+
"@fluidframework/driver-definitions": "~2.61.0",
|
|
91
|
+
"@fluidframework/driver-utils": "~2.61.0",
|
|
92
|
+
"@fluidframework/runtime-definitions": "~2.61.0",
|
|
93
|
+
"@fluidframework/shared-object-base": "~2.61.0"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
96
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
97
97
|
"@biomejs/biome": "~1.9.3",
|
|
98
|
-
"@fluid-internal/mocha-test-setup": "2.61.0
|
|
99
|
-
"@fluid-private/stochastic-test-utils": "2.61.0
|
|
100
|
-
"@fluid-private/test-dds-utils": "2.61.0
|
|
98
|
+
"@fluid-internal/mocha-test-setup": "~2.61.0",
|
|
99
|
+
"@fluid-private/stochastic-test-utils": "~2.61.0",
|
|
100
|
+
"@fluid-private/test-dds-utils": "~2.61.0",
|
|
101
101
|
"@fluid-tools/build-cli": "^0.58.3",
|
|
102
102
|
"@fluidframework/build-common": "^2.0.3",
|
|
103
103
|
"@fluidframework/build-tools": "^0.58.3",
|
|
104
104
|
"@fluidframework/eslint-config-fluid": "^6.0.0",
|
|
105
105
|
"@fluidframework/task-manager-previous": "npm:@fluidframework/task-manager@2.60.0",
|
|
106
|
-
"@fluidframework/test-runtime-utils": "2.61.0
|
|
107
|
-
"@fluidframework/test-utils": "2.61.0
|
|
106
|
+
"@fluidframework/test-runtime-utils": "~2.61.0",
|
|
107
|
+
"@fluidframework/test-utils": "~2.61.0",
|
|
108
108
|
"@microsoft/api-extractor": "7.52.11",
|
|
109
109
|
"@types/mocha": "^10.0.10",
|
|
110
110
|
"@types/node": "^18.19.0",
|
package/src/packageVersion.ts
CHANGED
package/src/taskManager.ts
CHANGED
|
@@ -62,7 +62,7 @@ function assertIsTaskManagerOperation(op: unknown): asserts op is ITaskManagerOp
|
|
|
62
62
|
typeof op.taskId === "string" &&
|
|
63
63
|
"type" in op &&
|
|
64
64
|
(op.type === "volunteer" || op.type === "abandon" || op.type === "complete"),
|
|
65
|
-
|
|
65
|
+
0xc3b /* Not a TaskManager operation */,
|
|
66
66
|
);
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -146,11 +146,11 @@ export class TaskManagerClass
|
|
|
146
146
|
(taskId: string, clientId: string, local: boolean, messageId: number | undefined) => {
|
|
147
147
|
if (local) {
|
|
148
148
|
const latestPendingOps = this.latestPendingOps.get(taskId);
|
|
149
|
-
assert(latestPendingOps !== undefined,
|
|
149
|
+
assert(latestPendingOps !== undefined, 0xc3c /* No pending ops for task */);
|
|
150
150
|
const pendingOp = latestPendingOps.shift();
|
|
151
151
|
assert(
|
|
152
152
|
pendingOp !== undefined && pendingOp.messageId === messageId,
|
|
153
|
-
|
|
153
|
+
0xc3d /* Unexpected op */,
|
|
154
154
|
);
|
|
155
155
|
assert(pendingOp.type === "volunteer", 0x07c /* "Unexpected op type" */);
|
|
156
156
|
if (latestPendingOps.length === 0) {
|
|
@@ -167,11 +167,11 @@ export class TaskManagerClass
|
|
|
167
167
|
(taskId: string, clientId: string, local: boolean, messageId: number | undefined) => {
|
|
168
168
|
if (local) {
|
|
169
169
|
const latestPendingOps = this.latestPendingOps.get(taskId);
|
|
170
|
-
assert(latestPendingOps !== undefined,
|
|
170
|
+
assert(latestPendingOps !== undefined, 0xc3e /* No pending ops for task */);
|
|
171
171
|
const pendingOp = latestPendingOps.shift();
|
|
172
172
|
assert(
|
|
173
173
|
pendingOp !== undefined && pendingOp.messageId === messageId,
|
|
174
|
-
|
|
174
|
+
0xc3f /* Unexpected op */,
|
|
175
175
|
);
|
|
176
176
|
assert(pendingOp.type === "abandon", 0x07e /* "Unexpected op type" */);
|
|
177
177
|
if (latestPendingOps.length === 0) {
|
|
@@ -189,11 +189,11 @@ export class TaskManagerClass
|
|
|
189
189
|
(taskId: string, clientId: string, local: boolean, messageId: number | undefined) => {
|
|
190
190
|
if (local) {
|
|
191
191
|
const latestPendingOps = this.latestPendingOps.get(taskId);
|
|
192
|
-
assert(latestPendingOps !== undefined,
|
|
192
|
+
assert(latestPendingOps !== undefined, 0xc40 /* No pending ops for task */);
|
|
193
193
|
const pendingOp = latestPendingOps.shift();
|
|
194
194
|
assert(
|
|
195
195
|
pendingOp !== undefined && pendingOp.messageId === messageId,
|
|
196
|
-
|
|
196
|
+
0xc41 /* Unexpected op */,
|
|
197
197
|
);
|
|
198
198
|
assert(pendingOp.type === "complete", 0x401 /* Unexpected op type */);
|
|
199
199
|
if (latestPendingOps.length === 0) {
|
|
@@ -682,11 +682,11 @@ export class TaskManagerClass
|
|
|
682
682
|
protected reSubmitCore(content: unknown, localOpMetadata: number): void {
|
|
683
683
|
assertIsTaskManagerOperation(content);
|
|
684
684
|
const pendingOps = this.latestPendingOps.get(content.taskId);
|
|
685
|
-
assert(pendingOps !== undefined,
|
|
685
|
+
assert(pendingOps !== undefined, 0xc42 /* No pending ops for task on resubmit attempt */);
|
|
686
686
|
const pendingOpIndex = pendingOps.findIndex(
|
|
687
687
|
(op) => op.messageId === localOpMetadata && op.type === content.type,
|
|
688
688
|
);
|
|
689
|
-
assert(pendingOpIndex !== -1,
|
|
689
|
+
assert(pendingOpIndex !== -1, 0xc43 /* Could not match pending op on resubmit attempt */);
|
|
690
690
|
pendingOps.splice(pendingOpIndex, 1);
|
|
691
691
|
if (pendingOps.length === 0) {
|
|
692
692
|
this.latestPendingOps.delete(content.taskId);
|
|
@@ -841,7 +841,7 @@ export class TaskManagerClass
|
|
|
841
841
|
return false;
|
|
842
842
|
}
|
|
843
843
|
|
|
844
|
-
assert(this.clientId !== undefined,
|
|
844
|
+
assert(this.clientId !== undefined, 0xc44 /* clientId undefined */);
|
|
845
845
|
|
|
846
846
|
const inQueue = this.taskQueues.get(taskId)?.includes(this.clientId) ?? false;
|
|
847
847
|
const latestPendingOps = this.latestPendingOps.get(taskId);
|
|
@@ -879,14 +879,17 @@ export class TaskManagerClass
|
|
|
879
879
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}
|
|
880
880
|
*/
|
|
881
881
|
protected rollback(content: unknown, localOpMetadata: unknown): void {
|
|
882
|
-
assert(
|
|
882
|
+
assert(
|
|
883
|
+
typeof localOpMetadata === "number",
|
|
884
|
+
0xc45 /* Expect localOpMetadata to be a number */,
|
|
885
|
+
);
|
|
883
886
|
assertIsTaskManagerOperation(content);
|
|
884
887
|
const latestPendingOps = this.latestPendingOps.get(content.taskId);
|
|
885
|
-
assert(latestPendingOps !== undefined,
|
|
888
|
+
assert(latestPendingOps !== undefined, 0xc46 /* No pending ops when trying to rollback */);
|
|
886
889
|
const pendingOpToRollback = latestPendingOps.pop();
|
|
887
890
|
assert(
|
|
888
891
|
pendingOpToRollback !== undefined && pendingOpToRollback.messageId === localOpMetadata,
|
|
889
|
-
|
|
892
|
+
0xc47 /* pending op mismatch */,
|
|
890
893
|
);
|
|
891
894
|
if (latestPendingOps.length === 0) {
|
|
892
895
|
this.latestPendingOps.delete(content.taskId);
|