@fluidframework/container-runtime 2.73.0 → 2.74.0-365691
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/container-runtime.test-files.tar +0 -0
- package/dist/blobManager/blobManager.d.ts.map +1 -1
- package/dist/blobManager/blobManager.js +1 -0
- package/dist/blobManager/blobManager.js.map +1 -1
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +1 -0
- package/dist/containerRuntime.js.map +1 -1
- 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/runtimeLayerCompatState.d.ts +1 -1
- package/dist/summary/orderedClientElection.js.map +1 -1
- package/lib/blobManager/blobManager.d.ts.map +1 -1
- package/lib/blobManager/blobManager.js +1 -0
- package/lib/blobManager/blobManager.js.map +1 -1
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +1 -0
- package/lib/containerRuntime.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/runtimeLayerCompatState.d.ts +1 -1
- package/lib/summary/orderedClientElection.js.map +1 -1
- package/package.json +19 -19
- package/src/blobManager/blobManager.ts +1 -0
- package/src/containerRuntime.ts +1 -0
- package/src/packageVersion.ts +1 -1
- package/src/summary/orderedClientElection.ts +1 -1
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/container-runtime";
|
|
8
|
-
export declare const pkgVersion = "2.
|
|
8
|
+
export declare const pkgVersion = "2.74.0-365691";
|
|
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,sCAAsC,CAAC;AAC3D,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,sCAAsC,CAAC;AAC3D,eAAO,MAAM,UAAU,kBAAkB,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/container-runtime";
|
|
11
|
-
exports.pkgVersion = "2.
|
|
11
|
+
exports.pkgVersion = "2.74.0-365691";
|
|
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,mCAAmC,CAAC;AAC9C,QAAA,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,mCAAmC,CAAC;AAC9C,QAAA,UAAU,GAAG,eAAe,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/container-runtime\";\nexport const pkgVersion = \"2.74.0-365691\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"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\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @rushstack/no-new-null */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport type {\n\tIEvent,\n\tIEventProvider,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIClient,\n\tIQuorumClients,\n\tISequencedClient,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tUsageError,\n\tcreateChildLogger,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { summarizerClientType } from \"./summarizerTypes.js\";\n\n// helper types for recursive readonly.\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type, @typescript-eslint/ban-types\nexport type ImmutablePrimitives = undefined | null | boolean | string | number | Function;\nexport type Immutable<T> = T extends ImmutablePrimitives\n\t? T\n\t: T extends (infer A)[]\n\t\t? readonly Immutable<A>[]\n\t\t: T extends Map<infer K, infer V>\n\t\t\t? ReadonlyMap<Immutable<K>, Immutable<V>>\n\t\t\t: T extends Set<infer V>\n\t\t\t\t? ReadonlySet<Immutable<V>>\n\t\t\t\t: { readonly [K in keyof T]: Immutable<T[K]> };\n\n/**\n * Minimum information for a client tracked for election consideration.\n */\nexport interface ITrackedClient {\n\treadonly clientId: string;\n\treadonly sequenceNumber: number;\n\treadonly client: Immutable<IClient>;\n}\n\n/**\n * Common contract for link nodes within an OrderedClientCollection.\n */\nexport interface ILinkNode {\n\treadonly sequenceNumber: number;\n\tyoungerClient: ILinkedClient | undefined;\n}\n\n/**\n * Placeholder root node within an OrderedClientCollection; does not represent a client.\n */\nexport interface IRootLinkNode extends ILinkNode {\n\treadonly sequenceNumber: -1;\n\treadonly olderClient: undefined;\n}\n\n/**\n * Additional information required to keep track of the client within the doubly-linked list.\n */\nexport interface ILinkedClient extends ILinkNode, ITrackedClient {\n\tolderClient: LinkNode;\n}\n\n/**\n * Any link node within OrderedClientCollection including the placeholder root node.\n */\nexport type LinkNode = IRootLinkNode | ILinkedClient;\n\n/**\n * Events raised by an OrderedClientCollection.\n */\nexport interface IOrderedClientCollectionEvents extends IEvent {\n\t/**\n\t * Event fires when client is being added.\n\t */\n\t(\n\t\tevent: \"addClient\" | \"removeClient\",\n\t\tlistener: (client: ILinkedClient, sequenceNumber: number) => void,\n\t);\n}\n\n/**\n * Contract for a sorted collection of all clients in the quorum.\n */\nexport interface IOrderedClientCollection\n\textends IEventProvider<IOrderedClientCollectionEvents> {\n\t/**\n\t * Count of clients in the collection.\n\t */\n\treadonly count: number;\n\t/**\n\t * Pointer to the oldest client in the collection.\n\t */\n\treadonly oldestClient: ILinkedClient | undefined;\n\t/**\n\t * Returns a sorted array of all the clients in the collection.\n\t */\n\tgetAllClients(): ILinkedClient[];\n}\n\n/**\n * Tracks clients in the Quorum. It maintains their order using their join op\n * sequence numbers.\n * Internally, the collection of clients is maintained in a doubly-linked list,\n * with pointers to both the first and last nodes.\n * The first (root) node is a placeholder to simplify logic and reduce null checking.\n */\nexport class OrderedClientCollection\n\textends TypedEventEmitter<IOrderedClientCollectionEvents>\n\timplements IOrderedClientCollection\n{\n\t/**\n\t * Collection of ALL clients currently in the quorum, with client ids as keys.\n\t */\n\tprivate readonly clientMap = new Map<string, ILinkedClient>();\n\t/**\n\t * Placeholder head node of linked list, for simplified null checking.\n\t */\n\tprivate readonly rootNode: IRootLinkNode = {\n\t\tsequenceNumber: -1,\n\t\tolderClient: undefined,\n\t\tyoungerClient: undefined,\n\t};\n\t/**\n\t * Pointer to end of linked list, for optimized client adds.\n\t */\n\tprivate _youngestClient: LinkNode = this.rootNode;\n\tprivate readonly logger: ITelemetryLoggerExt;\n\n\tpublic get count(): number {\n\t\treturn this.clientMap.size;\n\t}\n\tpublic get oldestClient(): ILinkedClient | undefined {\n\t\treturn this.rootNode.youngerClient;\n\t}\n\n\tconstructor(\n\t\tlogger: ITelemetryBaseLogger,\n\t\tdeltaManager: Pick<IDeltaManager<unknown, unknown>, \"lastSequenceNumber\">,\n\t\tquorum: Pick<IQuorumClients, \"getMembers\" | \"on\">,\n\t) {\n\t\tsuper();\n\t\tthis.logger = createChildLogger({ logger, namespace: \"OrderedClientCollection\" });\n\t\tconst members = quorum.getMembers();\n\t\tfor (const [clientId, client] of members) {\n\t\t\tthis.addClient(clientId, client);\n\t\t}\n\n\t\tquorum.on(\"addMember\", (clientId, client) => {\n\t\t\tconst newClient = this.addClient(clientId, client);\n\t\t\tthis.emit(\"addClient\", newClient, deltaManager.lastSequenceNumber);\n\t\t});\n\t\tquorum.on(\"removeMember\", (clientId) => {\n\t\t\tconst sequenceNumber = deltaManager.lastSequenceNumber;\n\t\t\tconst removeClient = this.removeClient(clientId);\n\t\t\tif (removeClient === undefined) {\n\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"ClientNotFound\",\n\t\t\t\t\tclientId,\n\t\t\t\t\tsequenceNumber,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tthis.emit(\"removeClient\", removeClient, sequenceNumber);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate addClient(clientId: string, client: ISequencedClient): ITrackedClient {\n\t\t// Normal case is adding the latest client, which will bypass loop.\n\t\t// Find where it belongs otherwise (maybe possible during initial load?).\n\t\tassert(\n\t\t\tclient.sequenceNumber > -1,\n\t\t\t0x1f6 /* \"Negative client sequence number not allowed\" */,\n\t\t);\n\t\tlet currClient = this._youngestClient;\n\t\twhile (currClient.sequenceNumber > client.sequenceNumber) {\n\t\t\tassert(\n\t\t\t\tcurrClient.olderClient !== undefined,\n\t\t\t\t0x1f7 /* \"Previous client should always be defined\" */,\n\t\t\t);\n\t\t\t// Note: If adding a client older than the elected client, it will not be automatically elected.\n\t\t\tcurrClient = currClient.olderClient;\n\t\t}\n\n\t\t// Now currClient is the node right before where the new client node should be.\n\t\tconst newClient: ILinkedClient = {\n\t\t\tclientId,\n\t\t\tsequenceNumber: client.sequenceNumber,\n\t\t\tclient: { ...client.client }, // shallow clone\n\t\t\tolderClient: currClient,\n\t\t\tyoungerClient: currClient.youngerClient,\n\t\t};\n\n\t\t// Update prev node to point to this new node.\n\t\tnewClient.olderClient.youngerClient = newClient;\n\n\t\tif (newClient.youngerClient === undefined) {\n\t\t\t// Update linked list end pointer to youngest client.\n\t\t\tthis._youngestClient = newClient;\n\t\t} else {\n\t\t\t// Update next node to point back to this new node.\n\t\t\tnewClient.youngerClient.olderClient = newClient;\n\t\t}\n\n\t\tthis.clientMap.set(clientId, newClient);\n\t\treturn newClient;\n\t}\n\n\tprivate removeClient(clientId: string): ITrackedClient | undefined {\n\t\tconst removeClient = this.clientMap.get(clientId);\n\t\tif (removeClient === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Update prev node to point to next node.\n\t\tremoveClient.olderClient.youngerClient = removeClient.youngerClient;\n\n\t\tif (removeClient.youngerClient === undefined) {\n\t\t\t// Update linked list end pointer to youngest client.\n\t\t\tthis._youngestClient = removeClient.olderClient;\n\t\t} else {\n\t\t\t// Update next node to point back to previous node.\n\t\t\tremoveClient.youngerClient.olderClient = removeClient.olderClient;\n\t\t}\n\n\t\tthis.clientMap.delete(clientId);\n\t\treturn removeClient;\n\t}\n\n\t/**\n\t * Returns an array of all clients being tracked in order from oldest to newest.\n\t */\n\tpublic getAllClients(): ILinkedClient[] {\n\t\tconst result: ILinkedClient[] = [];\n\t\tlet currClient: LinkNode = this.rootNode;\n\t\twhile (currClient.youngerClient !== undefined) {\n\t\t\tresult.push(currClient.youngerClient);\n\t\t\tcurrClient = currClient.youngerClient;\n\t\t}\n\t\treturn result;\n\t}\n}\n\n/**\n * Events raised by an OrderedClientElection.\n */\nexport interface IOrderedClientElectionEvents extends IEvent {\n\t/**\n\t * Event fires when the currently elected client changes.\n\t */\n\t(\n\t\tevent: \"election\",\n\t\tlistener: (\n\t\t\t/**\n\t\t\t * Newly elected client.\n\t\t\t */\n\t\t\tclient: ITrackedClient | undefined,\n\t\t\t/**\n\t\t\t * Sequence number where election took place.\n\t\t\t */\n\t\t\tsequenceNumber: number,\n\t\t\t/**\n\t\t\t * Previously elected client.\n\t\t\t */\n\t\t\tprevClient: ITrackedClient | undefined,\n\t\t) => void,\n\t);\n}\n\n/**\n * Serialized state of IOrderedClientElection.\n * @internal\n */\nexport interface ISerializedElection {\n\t/**\n\t * Sequence number at the time of the latest election.\n\t */\n\treadonly electionSequenceNumber: number;\n\n\t/**\n\t * Most recently elected client id. This is either:\n\t *\n\t * 1. the interactive elected parent client, in which case electedClientId === electedParentId,\n\t * and the SummaryManager on the elected client will spawn a summarizer client, or\n\t *\n\t * 2. the non-interactive summarizer client itself.\n\t */\n\treadonly electedClientId: string | undefined;\n\n\t/**\n\t * Most recently elected parent client id. This is always an interactive client.\n\t */\n\treadonly electedParentId: string | undefined;\n}\n\n/**\n * Contract for maintaining a deterministic client election based on eligibility.\n */\nexport interface IOrderedClientElection extends IEventProvider<IOrderedClientElectionEvents> {\n\t/**\n\t * Count of eligible clients in the collection.\n\t */\n\treadonly eligibleCount: number;\n\n\t/**\n\t * Currently elected client. This is either:\n\t *\n\t * 1. the interactive elected parent client, in which case electedClientId === electedParentId,\n\t * and the SummaryManager on the elected client will spawn a summarizer client, or\n\t *\n\t * 2. the non-interactive summarizer client itself.\n\t */\n\treadonly electedClient: ITrackedClient | undefined;\n\t/**\n\t * Currently elected parent client. This is always an interactive client.\n\t */\n\treadonly electedParent: ITrackedClient | undefined;\n\t/**\n\t * Sequence number of most recent election.\n\t */\n\treadonly electionSequenceNumber: number;\n\t/**\n\t * Resets the currently elected client back to the oldest eligible client.\n\t */\n\tresetElectedClient(sequenceNumber: number): void;\n\t/**\n\t * Peeks at what the next elected client would be if incrementElectedClient were called.\n\t */\n\tpeekNextElectedClient(): ITrackedClient | undefined;\n\t/**\n\t * Returns a sorted array of all the eligible clients in the collection.\n\t */\n\tgetAllEligibleClients(): ITrackedClient[];\n\t/**\n\t * Serialize election data\n\t */\n\tserialize(): ISerializedElection;\n}\n\n/**\n * Adapter for OrderedClientCollection, with the purpose of deterministically maintaining\n * a currently elected client, excluding ineligible clients, in a distributed fashion.\n * This can be true as long as incrementElectedClient and resetElectedClient calls\n * are called under the same conditions for all clients.\n */\nexport class OrderedClientElection\n\textends TypedEventEmitter<IOrderedClientElectionEvents>\n\timplements IOrderedClientElection\n{\n\tprivate _eligibleCount: number = 0;\n\tprivate _electedClient: ILinkedClient | undefined;\n\tprivate _electedParent: ILinkedClient | undefined;\n\tprivate _electionSequenceNumber: number;\n\n\tpublic get eligibleCount(): number {\n\t\treturn this._eligibleCount;\n\t}\n\tpublic get electionSequenceNumber(): number {\n\t\treturn this._electionSequenceNumber;\n\t}\n\n\t/**\n\t * OrderedClientCollection tracks electedClient and electedParent separately. This allows us to handle the case\n\t * where a new interactive parent client has been elected, but the summarizer is still doing work, so\n\t * a new summarizer should not yet be spawned. In this case, changing electedParent will cause SummaryManager\n\t * to stop the current summarizer, but a new summarizer will not be spawned until the old summarizer client has\n\t * left the quorum.\n\t *\n\t * Details:\n\t *\n\t * electedParent is the interactive client that has been elected to spawn a summarizer. It is typically the oldest\n\t * eligible interactive client in the quorum. Only the electedParent is permitted to spawn a summarizer.\n\t * Once elected, this client will remain the electedParent until it leaves the quorum or the summarizer that\n\t * it spawned stops producing summaries, at which point a new electedParent will be chosen.\n\t *\n\t * electedClient is the non-interactive summarizer client if one exists. If not, then electedClient is equal to\n\t * electedParent. If electedParent === electedClient, this is the signal for electedParent to spawn a new\n\t * electedClient. Once a summarizer client becomes electedClient, a new summarizer will not be spawned until\n\t * electedClient leaves the quorum.\n\t *\n\t * A typical sequence looks like this:\n\t *\n\t * i. Begin by electing A. electedParent === A, electedClient === A.\n\t *\n\t * ii. SummaryManager running on A spawns a summarizer client, A'. electedParent === A, electedClient === A'\n\t *\n\t * iii. A' stops producing summaries. A new parent client, B, is elected. electedParent === B, electedClient === A'\n\t *\n\t * iv. SummaryManager running on A detects the change to electedParent and tells the summarizer to stop, but A'\n\t * is in mid-summarization. No new summarizer is spawned, as electedParent !== electedClient.\n\t *\n\t * v. A' completes its summary, and the summarizer and backing client are torn down.\n\t *\n\t * vi. A' leaves the quorum, and B takes its place as electedClient. electedParent === B, electedClient === B\n\t *\n\t * vii. SummaryManager running on B spawns a summarizer client, B'. electedParent === B, electedClient === B'\n\t */\n\tpublic get electedClient(): ILinkedClient | undefined {\n\t\treturn this._electedClient;\n\t}\n\tpublic get electedParent(): ILinkedClient | undefined {\n\t\treturn this._electedParent;\n\t}\n\n\tconstructor(\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly orderedClientCollection: IOrderedClientCollection,\n\t\t/**\n\t\t * Serialized state from summary or current sequence number at time of load if new.\n\t\t */\n\t\tinitialState: ISerializedElection | number,\n\t\tprivate readonly isEligibleFn: (c: ITrackedClient) => boolean,\n\t\tprivate readonly recordPerformanceEvents: boolean = false,\n\t) {\n\t\tsuper();\n\t\tlet initialClient: ILinkedClient | undefined;\n\t\tlet initialParent: ILinkedClient | undefined;\n\t\tfor (const client of orderedClientCollection.getAllClients()) {\n\t\t\tthis.addClient(client, 0);\n\t\t\tif (typeof initialState !== \"number\") {\n\t\t\t\tif (client.clientId === initialState.electedClientId) {\n\t\t\t\t\tinitialClient = client;\n\t\t\t\t\tif (\n\t\t\t\t\t\tinitialState.electedParentId === undefined &&\n\t\t\t\t\t\tclient.client.details.type !== summarizerClientType\n\t\t\t\t\t) {\n\t\t\t\t\t\t// If there was no elected parent in the serialized data, use this one.\n\t\t\t\t\t\tinitialParent = client;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (client.clientId === initialState.electedParentId) {\n\t\t\t\t\tinitialParent = client;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\torderedClientCollection.on(\"addClient\", (client, seq) => this.addClient(client, seq));\n\t\torderedClientCollection.on(\"removeClient\", (client, seq) =>\n\t\t\tthis.removeClient(client, seq),\n\t\t);\n\n\t\tif (typeof initialState === \"number\") {\n\t\t\tthis._electionSequenceNumber = initialState;\n\t\t} else {\n\t\t\t// Override the initially elected client with the initial state.\n\t\t\tif (initialClient?.clientId !== initialState.electedClientId) {\n\t\t\t\t// Cannot find initially elected client, so elect undefined.\n\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"InitialElectedClientNotFound\",\n\t\t\t\t\telectionSequenceNumber: initialState.electionSequenceNumber,\n\t\t\t\t\texpectedClientId: initialState.electedClientId,\n\t\t\t\t\telectedClientId: initialClient?.clientId,\n\t\t\t\t\tclientCount: orderedClientCollection.count,\n\t\t\t\t});\n\t\t\t} else if (initialClient !== undefined && !isEligibleFn(initialClient)) {\n\t\t\t\t// Initially elected client is ineligible, so elect next eligible client.\n\t\t\t\tinitialClient = initialParent = this.findFirstEligibleParent(initialParent);\n\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"InitialElectedClientIneligible\",\n\t\t\t\t\telectionSequenceNumber: initialState.electionSequenceNumber,\n\t\t\t\t\texpectedClientId: initialState.electedClientId,\n\t\t\t\t\telectedClientId: initialClient?.clientId,\n\t\t\t\t});\n\t\t\t}\n\t\t\tthis._electedParent = initialParent;\n\t\t\tthis._electedClient = initialClient;\n\t\t\tthis._electionSequenceNumber = initialState.electionSequenceNumber;\n\t\t}\n\t}\n\n\t/**\n\t * Tries changing the elected client, raising an event if it is different.\n\t * Note that this function does no eligibility or suitability checks. If we get here, then\n\t * we will set _electedClient, and we will set _electedParent if this is an interactive client.\n\t */\n\tprivate tryElectingClient(\n\t\tclient: ILinkedClient | undefined,\n\t\tsequenceNumber: number,\n\t\treason: string,\n\t): void {\n\t\tthis.sendPerformanceEvent(\n\t\t\t\"TryElectingClient\",\n\t\t\tclient,\n\t\t\tsequenceNumber,\n\t\t\tfalse /* forceSend */,\n\t\t\treason,\n\t\t);\n\t\tlet change = false;\n\t\tconst isSummarizerClient = client?.client.details.type === summarizerClientType;\n\t\tconst prevClient = this._electedClient;\n\t\tif (this._electedClient !== client) {\n\t\t\tthis.sendPerformanceEvent(\n\t\t\t\t\"ClientElected\",\n\t\t\t\tclient,\n\t\t\t\tsequenceNumber,\n\t\t\t\ttrue /* forceSend */,\n\t\t\t\treason,\n\t\t\t);\n\t\t\t// Changing the elected client. Record the sequence number and note that we have to fire an event.\n\t\t\tthis._electionSequenceNumber = sequenceNumber;\n\t\t\tthis._electedClient = client;\n\t\t\tchange = true;\n\t\t}\n\t\tif (this._electedParent !== client && !isSummarizerClient) {\n\t\t\tthis.sendPerformanceEvent(\n\t\t\t\t\"InteractiveClientElected\",\n\t\t\t\tclient,\n\t\t\t\tsequenceNumber,\n\t\t\t\ttrue /* forceSend */,\n\t\t\t\treason,\n\t\t\t);\n\t\t\t// Changing the elected parent as well.\n\t\t\tthis._electedParent = client;\n\t\t\tchange = true;\n\t\t}\n\t\tif (change) {\n\t\t\tthis.emit(\"election\", client, sequenceNumber, prevClient);\n\t\t}\n\t}\n\n\tprivate tryElectingParent(\n\t\tclient: ILinkedClient | undefined,\n\t\tsequenceNumber: number,\n\t\treason: string,\n\t): void {\n\t\tthis.sendPerformanceEvent(\n\t\t\t\"TryElectingParent\",\n\t\t\tclient,\n\t\t\tsequenceNumber,\n\t\t\tfalse /* forceSend */,\n\t\t\treason,\n\t\t);\n\t\tif (this._electedParent !== client) {\n\t\t\tthis.sendPerformanceEvent(\n\t\t\t\t\"ParentElected\",\n\t\t\t\tclient,\n\t\t\t\tsequenceNumber,\n\t\t\t\ttrue /* forceSend */,\n\t\t\t\treason,\n\t\t\t);\n\t\t\tthis._electedParent = client;\n\t\t\tthis.emit(\"election\", this._electedClient, sequenceNumber, this._electedClient);\n\t\t}\n\t}\n\n\t/**\n\t * Helper function to find the first eligible parent client starting with the passed in client,\n\t * or undefined if none are eligible.\n\t * @param client - client to start checking\n\t * @returns oldest eligible client starting with passed in client or undefined if none.\n\t */\n\tprivate findFirstEligibleParent(\n\t\tclient: ILinkedClient | undefined,\n\t): ILinkedClient | undefined {\n\t\tlet candidateClient = client;\n\t\twhile (\n\t\t\tcandidateClient !== undefined &&\n\t\t\t(!this.isEligibleFn(candidateClient) ||\n\t\t\t\tcandidateClient.client.details.type === summarizerClientType)\n\t\t) {\n\t\t\tcandidateClient = candidateClient.youngerClient;\n\t\t}\n\t\treturn candidateClient;\n\t}\n\n\t/**\n\t * Updates tracking for when a new client is added to the collection.\n\t * Will automatically elect that new client if none is elected currently.\n\t * @param client - client added to the collection\n\t * @param sequenceNumber - sequence number when client was added\n\t */\n\tprivate addClient(client: ILinkedClient, sequenceNumber: number): void {\n\t\tthis.sendPerformanceEvent(\"AddClient\", client, sequenceNumber);\n\t\tif (this.isEligibleFn(client)) {\n\t\t\tthis._eligibleCount++;\n\t\t\tconst newClientIsSummarizer = client.client.details.type === summarizerClientType;\n\t\t\tconst electedClientIsSummarizer =\n\t\t\t\tthis._electedClient?.client.details.type === summarizerClientType;\n\t\t\t// Note that we allow a summarizer client to supersede an interactive client as elected client.\n\t\t\tif (\n\t\t\t\tthis._electedClient === undefined ||\n\t\t\t\t(!electedClientIsSummarizer && newClientIsSummarizer)\n\t\t\t) {\n\t\t\t\tthis.tryElectingClient(client, sequenceNumber, \"AddClient\");\n\t\t\t} else if (this._electedParent === undefined && !newClientIsSummarizer) {\n\t\t\t\t// This is an odd case. If the _electedClient is set, the _electedParent should be as well.\n\t\t\t\tthis.tryElectingParent(client, sequenceNumber, \"AddClient\");\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Updates tracking for when an existing client is removed from the collection.\n\t * Will automatically elect next oldest client if currently elected is removed.\n\t * @param client - client removed from the collection\n\t * @param sequenceNumber - sequence number when client was removed\n\t */\n\tprivate removeClient(client: ILinkedClient, sequenceNumber: number): void {\n\t\tthis.sendPerformanceEvent(\"RemoveClient\", client, sequenceNumber);\n\t\tif (this.isEligibleFn(client)) {\n\t\t\tthis._eligibleCount--;\n\t\t\tif (this._electedClient === client) {\n\t\t\t\t// Removing the _electedClient. There are 2 possible cases:\n\t\t\t\tif (this._electedParent === client) {\n\t\t\t\t\t// 1. The _electedClient is an interactive client that has left the quorum.\n\t\t\t\t\t// Automatically shift to next oldest client.\n\t\t\t\t\tconst nextClient =\n\t\t\t\t\t\tthis.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n\t\t\t\t\t\tthis.findFirstEligibleParent(this.orderedClientCollection.oldestClient);\n\t\t\t\t\tthis.tryElectingClient(nextClient, sequenceNumber, \"RemoveClient\");\n\t\t\t\t} else {\n\t\t\t\t\t// 2. The _electedClient is a summarizer that we've been allowing to finish its work.\n\t\t\t\t\t// Let the _electedParent become the _electedClient so that it can start its own summarizer.\n\t\t\t\t\tif (this._electedClient.client.details.type !== summarizerClientType) {\n\t\t\t\t\t\tthrow new UsageError(\"Elected client should be a summarizer client 1\");\n\t\t\t\t\t}\n\t\t\t\t\tthis.tryElectingClient(\n\t\t\t\t\t\tthis._electedParent,\n\t\t\t\t\t\tsequenceNumber,\n\t\t\t\t\t\t\"RemoveSummarizerClient\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else if (this._electedParent === client) {\n\t\t\t\t// Removing the _electedParent (but not _electedClient).\n\t\t\t\t// Shift to the next oldest parent, but do not replace the _electedClient,\n\t\t\t\t// which is a summarizer that is still doing work.\n\t\t\t\tif (this._electedClient?.client.details.type !== summarizerClientType) {\n\t\t\t\t\tthrow new UsageError(\"Elected client should be a summarizer client 2\");\n\t\t\t\t}\n\t\t\t\tconst nextParent =\n\t\t\t\t\tthis.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n\t\t\t\t\tthis.findFirstEligibleParent(this.orderedClientCollection.oldestClient);\n\t\t\t\tthis.tryElectingParent(nextParent, sequenceNumber, \"RemoveClient\");\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic getAllEligibleClients(): ITrackedClient[] {\n\t\treturn this.orderedClientCollection\n\t\t\t.getAllClients()\n\t\t\t.filter((client) => this.isEligibleFn(client));\n\t}\n\n\t/**\n\t * (Re-)start election with the oldest client in the quorum. This is called if we need to summarize\n\t * and no client has been elected.\n\t */\n\tpublic resetElectedClient(sequenceNumber: number): void {\n\t\tconst firstClient = this.findFirstEligibleParent(\n\t\t\tthis.orderedClientCollection.oldestClient,\n\t\t);\n\t\tif (this._electedClient === undefined || this._electedClient === this._electedParent) {\n\t\t\tthis.tryElectingClient(firstClient, sequenceNumber, \"ResetElectedClient\");\n\t\t} else {\n\t\t\t// The _electedClient is a summarizer and should not be replaced until it leaves the quorum.\n\t\t\t// Changing the _electedParent will stop the summarizer.\n\t\t\tthis.tryElectingParent(firstClient, sequenceNumber, \"ResetElectedClient\");\n\t\t}\n\t}\n\n\tpublic peekNextElectedClient(): ITrackedClient | undefined {\n\t\treturn (\n\t\t\tthis.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n\t\t\tthis.findFirstEligibleParent(this.orderedClientCollection.oldestClient)\n\t\t);\n\t}\n\n\tpublic serialize(): ISerializedElection {\n\t\treturn {\n\t\t\telectionSequenceNumber: this.electionSequenceNumber,\n\t\t\telectedClientId: this.electedClient?.clientId,\n\t\t\telectedParentId: this.electedParent?.clientId,\n\t\t};\n\t}\n\n\tprivate sendPerformanceEvent(\n\t\teventName: string,\n\t\tclient: ILinkedClient | undefined,\n\t\tsequenceNumber: number,\n\t\tforceSend: boolean = false,\n\t\treason?: string,\n\t): void {\n\t\tif (this.recordPerformanceEvents || forceSend) {\n\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\teventName,\n\t\t\t\tclientId: client?.clientId,\n\t\t\t\tsequenceNumber,\n\t\t\t\telectedClientId: this.electedClient?.clientId,\n\t\t\t\telectedParentId: this.electedParent?.clientId,\n\t\t\t\tisEligible: client === undefined ? false : this.isEligibleFn(client),\n\t\t\t\tisSummarizerClient: client?.client.details.type === summarizerClientType,\n\t\t\t\treason,\n\t\t\t});\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"orderedClientElection.js","sourceRoot":"","sources":["../../src/summary/orderedClientElection.ts"],"names":[],"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AA4F;YAC5F,wDAAwD;YACxD,IAAI,CAAC,iBAAiB,CAAC,WAAW,EAAE,cAAc,EAAE,oBAAoB,CAAC,CAAC;QAC3E,CAAC;IACF,CAAC;IAEM,qBAAqB;QAC3B,OAAO,CACN,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,cAAc,EAAE,aAAa,CAAC;YAChE,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,uBAAuB,CAAC,YAAY,CAAC,CACvE,CAAC;IACH,CAAC;IAEM,SAAS;QACf,OAAO;YACN,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;YACnD,eAAe,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ;YAC7C,eAAe,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ;SAC7C,CAAC;IACH,CAAC;IAEO,oBAAoB,CAC3B,SAAiB,EACjB,MAAiC,EACjC,cAAsB,EACtB,YAAqB,KAAK,EAC1B,MAAe;QAEf,IAAI,IAAI,CAAC,uBAAuB,IAAI,SAAS,EAAE,CAAC;YAC/C,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;gBAChC,SAAS;gBACT,QAAQ,EAAE,MAAM,EAAE,QAAQ;gBAC1B,cAAc;gBACd,eAAe,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ;gBAC7C,eAAe,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ;gBAC7C,UAAU,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;gBACpE,kBAAkB,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,yCAAoB;gBACxE,MAAM;aACN,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;CACD;AA7VD,sDA6VC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @rushstack/no-new-null */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport type {\n\tIEvent,\n\tIEventProvider,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIClient,\n\tIQuorumClients,\n\tISequencedClient,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tUsageError,\n\tcreateChildLogger,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { summarizerClientType } from \"./summarizerTypes.js\";\n\n// helper types for recursive readonly.\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport type ImmutablePrimitives = undefined | null | boolean | string | number | Function;\nexport type Immutable<T> = T extends ImmutablePrimitives\n\t? T\n\t: T extends (infer A)[]\n\t\t? readonly Immutable<A>[]\n\t\t: T extends Map<infer K, infer V>\n\t\t\t? ReadonlyMap<Immutable<K>, Immutable<V>>\n\t\t\t: T extends Set<infer V>\n\t\t\t\t? ReadonlySet<Immutable<V>>\n\t\t\t\t: { readonly [K in keyof T]: Immutable<T[K]> };\n\n/**\n * Minimum information for a client tracked for election consideration.\n */\nexport interface ITrackedClient {\n\treadonly clientId: string;\n\treadonly sequenceNumber: number;\n\treadonly client: Immutable<IClient>;\n}\n\n/**\n * Common contract for link nodes within an OrderedClientCollection.\n */\nexport interface ILinkNode {\n\treadonly sequenceNumber: number;\n\tyoungerClient: ILinkedClient | undefined;\n}\n\n/**\n * Placeholder root node within an OrderedClientCollection; does not represent a client.\n */\nexport interface IRootLinkNode extends ILinkNode {\n\treadonly sequenceNumber: -1;\n\treadonly olderClient: undefined;\n}\n\n/**\n * Additional information required to keep track of the client within the doubly-linked list.\n */\nexport interface ILinkedClient extends ILinkNode, ITrackedClient {\n\tolderClient: LinkNode;\n}\n\n/**\n * Any link node within OrderedClientCollection including the placeholder root node.\n */\nexport type LinkNode = IRootLinkNode | ILinkedClient;\n\n/**\n * Events raised by an OrderedClientCollection.\n */\nexport interface IOrderedClientCollectionEvents extends IEvent {\n\t/**\n\t * Event fires when client is being added.\n\t */\n\t(\n\t\tevent: \"addClient\" | \"removeClient\",\n\t\tlistener: (client: ILinkedClient, sequenceNumber: number) => void,\n\t);\n}\n\n/**\n * Contract for a sorted collection of all clients in the quorum.\n */\nexport interface IOrderedClientCollection\n\textends IEventProvider<IOrderedClientCollectionEvents> {\n\t/**\n\t * Count of clients in the collection.\n\t */\n\treadonly count: number;\n\t/**\n\t * Pointer to the oldest client in the collection.\n\t */\n\treadonly oldestClient: ILinkedClient | undefined;\n\t/**\n\t * Returns a sorted array of all the clients in the collection.\n\t */\n\tgetAllClients(): ILinkedClient[];\n}\n\n/**\n * Tracks clients in the Quorum. It maintains their order using their join op\n * sequence numbers.\n * Internally, the collection of clients is maintained in a doubly-linked list,\n * with pointers to both the first and last nodes.\n * The first (root) node is a placeholder to simplify logic and reduce null checking.\n */\nexport class OrderedClientCollection\n\textends TypedEventEmitter<IOrderedClientCollectionEvents>\n\timplements IOrderedClientCollection\n{\n\t/**\n\t * Collection of ALL clients currently in the quorum, with client ids as keys.\n\t */\n\tprivate readonly clientMap = new Map<string, ILinkedClient>();\n\t/**\n\t * Placeholder head node of linked list, for simplified null checking.\n\t */\n\tprivate readonly rootNode: IRootLinkNode = {\n\t\tsequenceNumber: -1,\n\t\tolderClient: undefined,\n\t\tyoungerClient: undefined,\n\t};\n\t/**\n\t * Pointer to end of linked list, for optimized client adds.\n\t */\n\tprivate _youngestClient: LinkNode = this.rootNode;\n\tprivate readonly logger: ITelemetryLoggerExt;\n\n\tpublic get count(): number {\n\t\treturn this.clientMap.size;\n\t}\n\tpublic get oldestClient(): ILinkedClient | undefined {\n\t\treturn this.rootNode.youngerClient;\n\t}\n\n\tconstructor(\n\t\tlogger: ITelemetryBaseLogger,\n\t\tdeltaManager: Pick<IDeltaManager<unknown, unknown>, \"lastSequenceNumber\">,\n\t\tquorum: Pick<IQuorumClients, \"getMembers\" | \"on\">,\n\t) {\n\t\tsuper();\n\t\tthis.logger = createChildLogger({ logger, namespace: \"OrderedClientCollection\" });\n\t\tconst members = quorum.getMembers();\n\t\tfor (const [clientId, client] of members) {\n\t\t\tthis.addClient(clientId, client);\n\t\t}\n\n\t\tquorum.on(\"addMember\", (clientId, client) => {\n\t\t\tconst newClient = this.addClient(clientId, client);\n\t\t\tthis.emit(\"addClient\", newClient, deltaManager.lastSequenceNumber);\n\t\t});\n\t\tquorum.on(\"removeMember\", (clientId) => {\n\t\t\tconst sequenceNumber = deltaManager.lastSequenceNumber;\n\t\t\tconst removeClient = this.removeClient(clientId);\n\t\t\tif (removeClient === undefined) {\n\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"ClientNotFound\",\n\t\t\t\t\tclientId,\n\t\t\t\t\tsequenceNumber,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tthis.emit(\"removeClient\", removeClient, sequenceNumber);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate addClient(clientId: string, client: ISequencedClient): ITrackedClient {\n\t\t// Normal case is adding the latest client, which will bypass loop.\n\t\t// Find where it belongs otherwise (maybe possible during initial load?).\n\t\tassert(\n\t\t\tclient.sequenceNumber > -1,\n\t\t\t0x1f6 /* \"Negative client sequence number not allowed\" */,\n\t\t);\n\t\tlet currClient = this._youngestClient;\n\t\twhile (currClient.sequenceNumber > client.sequenceNumber) {\n\t\t\tassert(\n\t\t\t\tcurrClient.olderClient !== undefined,\n\t\t\t\t0x1f7 /* \"Previous client should always be defined\" */,\n\t\t\t);\n\t\t\t// Note: If adding a client older than the elected client, it will not be automatically elected.\n\t\t\tcurrClient = currClient.olderClient;\n\t\t}\n\n\t\t// Now currClient is the node right before where the new client node should be.\n\t\tconst newClient: ILinkedClient = {\n\t\t\tclientId,\n\t\t\tsequenceNumber: client.sequenceNumber,\n\t\t\tclient: { ...client.client }, // shallow clone\n\t\t\tolderClient: currClient,\n\t\t\tyoungerClient: currClient.youngerClient,\n\t\t};\n\n\t\t// Update prev node to point to this new node.\n\t\tnewClient.olderClient.youngerClient = newClient;\n\n\t\tif (newClient.youngerClient === undefined) {\n\t\t\t// Update linked list end pointer to youngest client.\n\t\t\tthis._youngestClient = newClient;\n\t\t} else {\n\t\t\t// Update next node to point back to this new node.\n\t\t\tnewClient.youngerClient.olderClient = newClient;\n\t\t}\n\n\t\tthis.clientMap.set(clientId, newClient);\n\t\treturn newClient;\n\t}\n\n\tprivate removeClient(clientId: string): ITrackedClient | undefined {\n\t\tconst removeClient = this.clientMap.get(clientId);\n\t\tif (removeClient === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Update prev node to point to next node.\n\t\tremoveClient.olderClient.youngerClient = removeClient.youngerClient;\n\n\t\tif (removeClient.youngerClient === undefined) {\n\t\t\t// Update linked list end pointer to youngest client.\n\t\t\tthis._youngestClient = removeClient.olderClient;\n\t\t} else {\n\t\t\t// Update next node to point back to previous node.\n\t\t\tremoveClient.youngerClient.olderClient = removeClient.olderClient;\n\t\t}\n\n\t\tthis.clientMap.delete(clientId);\n\t\treturn removeClient;\n\t}\n\n\t/**\n\t * Returns an array of all clients being tracked in order from oldest to newest.\n\t */\n\tpublic getAllClients(): ILinkedClient[] {\n\t\tconst result: ILinkedClient[] = [];\n\t\tlet currClient: LinkNode = this.rootNode;\n\t\twhile (currClient.youngerClient !== undefined) {\n\t\t\tresult.push(currClient.youngerClient);\n\t\t\tcurrClient = currClient.youngerClient;\n\t\t}\n\t\treturn result;\n\t}\n}\n\n/**\n * Events raised by an OrderedClientElection.\n */\nexport interface IOrderedClientElectionEvents extends IEvent {\n\t/**\n\t * Event fires when the currently elected client changes.\n\t */\n\t(\n\t\tevent: \"election\",\n\t\tlistener: (\n\t\t\t/**\n\t\t\t * Newly elected client.\n\t\t\t */\n\t\t\tclient: ITrackedClient | undefined,\n\t\t\t/**\n\t\t\t * Sequence number where election took place.\n\t\t\t */\n\t\t\tsequenceNumber: number,\n\t\t\t/**\n\t\t\t * Previously elected client.\n\t\t\t */\n\t\t\tprevClient: ITrackedClient | undefined,\n\t\t) => void,\n\t);\n}\n\n/**\n * Serialized state of IOrderedClientElection.\n * @internal\n */\nexport interface ISerializedElection {\n\t/**\n\t * Sequence number at the time of the latest election.\n\t */\n\treadonly electionSequenceNumber: number;\n\n\t/**\n\t * Most recently elected client id. This is either:\n\t *\n\t * 1. the interactive elected parent client, in which case electedClientId === electedParentId,\n\t * and the SummaryManager on the elected client will spawn a summarizer client, or\n\t *\n\t * 2. the non-interactive summarizer client itself.\n\t */\n\treadonly electedClientId: string | undefined;\n\n\t/**\n\t * Most recently elected parent client id. This is always an interactive client.\n\t */\n\treadonly electedParentId: string | undefined;\n}\n\n/**\n * Contract for maintaining a deterministic client election based on eligibility.\n */\nexport interface IOrderedClientElection extends IEventProvider<IOrderedClientElectionEvents> {\n\t/**\n\t * Count of eligible clients in the collection.\n\t */\n\treadonly eligibleCount: number;\n\n\t/**\n\t * Currently elected client. This is either:\n\t *\n\t * 1. the interactive elected parent client, in which case electedClientId === electedParentId,\n\t * and the SummaryManager on the elected client will spawn a summarizer client, or\n\t *\n\t * 2. the non-interactive summarizer client itself.\n\t */\n\treadonly electedClient: ITrackedClient | undefined;\n\t/**\n\t * Currently elected parent client. This is always an interactive client.\n\t */\n\treadonly electedParent: ITrackedClient | undefined;\n\t/**\n\t * Sequence number of most recent election.\n\t */\n\treadonly electionSequenceNumber: number;\n\t/**\n\t * Resets the currently elected client back to the oldest eligible client.\n\t */\n\tresetElectedClient(sequenceNumber: number): void;\n\t/**\n\t * Peeks at what the next elected client would be if incrementElectedClient were called.\n\t */\n\tpeekNextElectedClient(): ITrackedClient | undefined;\n\t/**\n\t * Returns a sorted array of all the eligible clients in the collection.\n\t */\n\tgetAllEligibleClients(): ITrackedClient[];\n\t/**\n\t * Serialize election data\n\t */\n\tserialize(): ISerializedElection;\n}\n\n/**\n * Adapter for OrderedClientCollection, with the purpose of deterministically maintaining\n * a currently elected client, excluding ineligible clients, in a distributed fashion.\n * This can be true as long as incrementElectedClient and resetElectedClient calls\n * are called under the same conditions for all clients.\n */\nexport class OrderedClientElection\n\textends TypedEventEmitter<IOrderedClientElectionEvents>\n\timplements IOrderedClientElection\n{\n\tprivate _eligibleCount: number = 0;\n\tprivate _electedClient: ILinkedClient | undefined;\n\tprivate _electedParent: ILinkedClient | undefined;\n\tprivate _electionSequenceNumber: number;\n\n\tpublic get eligibleCount(): number {\n\t\treturn this._eligibleCount;\n\t}\n\tpublic get electionSequenceNumber(): number {\n\t\treturn this._electionSequenceNumber;\n\t}\n\n\t/**\n\t * OrderedClientCollection tracks electedClient and electedParent separately. This allows us to handle the case\n\t * where a new interactive parent client has been elected, but the summarizer is still doing work, so\n\t * a new summarizer should not yet be spawned. In this case, changing electedParent will cause SummaryManager\n\t * to stop the current summarizer, but a new summarizer will not be spawned until the old summarizer client has\n\t * left the quorum.\n\t *\n\t * Details:\n\t *\n\t * electedParent is the interactive client that has been elected to spawn a summarizer. It is typically the oldest\n\t * eligible interactive client in the quorum. Only the electedParent is permitted to spawn a summarizer.\n\t * Once elected, this client will remain the electedParent until it leaves the quorum or the summarizer that\n\t * it spawned stops producing summaries, at which point a new electedParent will be chosen.\n\t *\n\t * electedClient is the non-interactive summarizer client if one exists. If not, then electedClient is equal to\n\t * electedParent. If electedParent === electedClient, this is the signal for electedParent to spawn a new\n\t * electedClient. Once a summarizer client becomes electedClient, a new summarizer will not be spawned until\n\t * electedClient leaves the quorum.\n\t *\n\t * A typical sequence looks like this:\n\t *\n\t * i. Begin by electing A. electedParent === A, electedClient === A.\n\t *\n\t * ii. SummaryManager running on A spawns a summarizer client, A'. electedParent === A, electedClient === A'\n\t *\n\t * iii. A' stops producing summaries. A new parent client, B, is elected. electedParent === B, electedClient === A'\n\t *\n\t * iv. SummaryManager running on A detects the change to electedParent and tells the summarizer to stop, but A'\n\t * is in mid-summarization. No new summarizer is spawned, as electedParent !== electedClient.\n\t *\n\t * v. A' completes its summary, and the summarizer and backing client are torn down.\n\t *\n\t * vi. A' leaves the quorum, and B takes its place as electedClient. electedParent === B, electedClient === B\n\t *\n\t * vii. SummaryManager running on B spawns a summarizer client, B'. electedParent === B, electedClient === B'\n\t */\n\tpublic get electedClient(): ILinkedClient | undefined {\n\t\treturn this._electedClient;\n\t}\n\tpublic get electedParent(): ILinkedClient | undefined {\n\t\treturn this._electedParent;\n\t}\n\n\tconstructor(\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly orderedClientCollection: IOrderedClientCollection,\n\t\t/**\n\t\t * Serialized state from summary or current sequence number at time of load if new.\n\t\t */\n\t\tinitialState: ISerializedElection | number,\n\t\tprivate readonly isEligibleFn: (c: ITrackedClient) => boolean,\n\t\tprivate readonly recordPerformanceEvents: boolean = false,\n\t) {\n\t\tsuper();\n\t\tlet initialClient: ILinkedClient | undefined;\n\t\tlet initialParent: ILinkedClient | undefined;\n\t\tfor (const client of orderedClientCollection.getAllClients()) {\n\t\t\tthis.addClient(client, 0);\n\t\t\tif (typeof initialState !== \"number\") {\n\t\t\t\tif (client.clientId === initialState.electedClientId) {\n\t\t\t\t\tinitialClient = client;\n\t\t\t\t\tif (\n\t\t\t\t\t\tinitialState.electedParentId === undefined &&\n\t\t\t\t\t\tclient.client.details.type !== summarizerClientType\n\t\t\t\t\t) {\n\t\t\t\t\t\t// If there was no elected parent in the serialized data, use this one.\n\t\t\t\t\t\tinitialParent = client;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (client.clientId === initialState.electedParentId) {\n\t\t\t\t\tinitialParent = client;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\torderedClientCollection.on(\"addClient\", (client, seq) => this.addClient(client, seq));\n\t\torderedClientCollection.on(\"removeClient\", (client, seq) =>\n\t\t\tthis.removeClient(client, seq),\n\t\t);\n\n\t\tif (typeof initialState === \"number\") {\n\t\t\tthis._electionSequenceNumber = initialState;\n\t\t} else {\n\t\t\t// Override the initially elected client with the initial state.\n\t\t\tif (initialClient?.clientId !== initialState.electedClientId) {\n\t\t\t\t// Cannot find initially elected client, so elect undefined.\n\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"InitialElectedClientNotFound\",\n\t\t\t\t\telectionSequenceNumber: initialState.electionSequenceNumber,\n\t\t\t\t\texpectedClientId: initialState.electedClientId,\n\t\t\t\t\telectedClientId: initialClient?.clientId,\n\t\t\t\t\tclientCount: orderedClientCollection.count,\n\t\t\t\t});\n\t\t\t} else if (initialClient !== undefined && !isEligibleFn(initialClient)) {\n\t\t\t\t// Initially elected client is ineligible, so elect next eligible client.\n\t\t\t\tinitialClient = initialParent = this.findFirstEligibleParent(initialParent);\n\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"InitialElectedClientIneligible\",\n\t\t\t\t\telectionSequenceNumber: initialState.electionSequenceNumber,\n\t\t\t\t\texpectedClientId: initialState.electedClientId,\n\t\t\t\t\telectedClientId: initialClient?.clientId,\n\t\t\t\t});\n\t\t\t}\n\t\t\tthis._electedParent = initialParent;\n\t\t\tthis._electedClient = initialClient;\n\t\t\tthis._electionSequenceNumber = initialState.electionSequenceNumber;\n\t\t}\n\t}\n\n\t/**\n\t * Tries changing the elected client, raising an event if it is different.\n\t * Note that this function does no eligibility or suitability checks. If we get here, then\n\t * we will set _electedClient, and we will set _electedParent if this is an interactive client.\n\t */\n\tprivate tryElectingClient(\n\t\tclient: ILinkedClient | undefined,\n\t\tsequenceNumber: number,\n\t\treason: string,\n\t): void {\n\t\tthis.sendPerformanceEvent(\n\t\t\t\"TryElectingClient\",\n\t\t\tclient,\n\t\t\tsequenceNumber,\n\t\t\tfalse /* forceSend */,\n\t\t\treason,\n\t\t);\n\t\tlet change = false;\n\t\tconst isSummarizerClient = client?.client.details.type === summarizerClientType;\n\t\tconst prevClient = this._electedClient;\n\t\tif (this._electedClient !== client) {\n\t\t\tthis.sendPerformanceEvent(\n\t\t\t\t\"ClientElected\",\n\t\t\t\tclient,\n\t\t\t\tsequenceNumber,\n\t\t\t\ttrue /* forceSend */,\n\t\t\t\treason,\n\t\t\t);\n\t\t\t// Changing the elected client. Record the sequence number and note that we have to fire an event.\n\t\t\tthis._electionSequenceNumber = sequenceNumber;\n\t\t\tthis._electedClient = client;\n\t\t\tchange = true;\n\t\t}\n\t\tif (this._electedParent !== client && !isSummarizerClient) {\n\t\t\tthis.sendPerformanceEvent(\n\t\t\t\t\"InteractiveClientElected\",\n\t\t\t\tclient,\n\t\t\t\tsequenceNumber,\n\t\t\t\ttrue /* forceSend */,\n\t\t\t\treason,\n\t\t\t);\n\t\t\t// Changing the elected parent as well.\n\t\t\tthis._electedParent = client;\n\t\t\tchange = true;\n\t\t}\n\t\tif (change) {\n\t\t\tthis.emit(\"election\", client, sequenceNumber, prevClient);\n\t\t}\n\t}\n\n\tprivate tryElectingParent(\n\t\tclient: ILinkedClient | undefined,\n\t\tsequenceNumber: number,\n\t\treason: string,\n\t): void {\n\t\tthis.sendPerformanceEvent(\n\t\t\t\"TryElectingParent\",\n\t\t\tclient,\n\t\t\tsequenceNumber,\n\t\t\tfalse /* forceSend */,\n\t\t\treason,\n\t\t);\n\t\tif (this._electedParent !== client) {\n\t\t\tthis.sendPerformanceEvent(\n\t\t\t\t\"ParentElected\",\n\t\t\t\tclient,\n\t\t\t\tsequenceNumber,\n\t\t\t\ttrue /* forceSend */,\n\t\t\t\treason,\n\t\t\t);\n\t\t\tthis._electedParent = client;\n\t\t\tthis.emit(\"election\", this._electedClient, sequenceNumber, this._electedClient);\n\t\t}\n\t}\n\n\t/**\n\t * Helper function to find the first eligible parent client starting with the passed in client,\n\t * or undefined if none are eligible.\n\t * @param client - client to start checking\n\t * @returns oldest eligible client starting with passed in client or undefined if none.\n\t */\n\tprivate findFirstEligibleParent(\n\t\tclient: ILinkedClient | undefined,\n\t): ILinkedClient | undefined {\n\t\tlet candidateClient = client;\n\t\twhile (\n\t\t\tcandidateClient !== undefined &&\n\t\t\t(!this.isEligibleFn(candidateClient) ||\n\t\t\t\tcandidateClient.client.details.type === summarizerClientType)\n\t\t) {\n\t\t\tcandidateClient = candidateClient.youngerClient;\n\t\t}\n\t\treturn candidateClient;\n\t}\n\n\t/**\n\t * Updates tracking for when a new client is added to the collection.\n\t * Will automatically elect that new client if none is elected currently.\n\t * @param client - client added to the collection\n\t * @param sequenceNumber - sequence number when client was added\n\t */\n\tprivate addClient(client: ILinkedClient, sequenceNumber: number): void {\n\t\tthis.sendPerformanceEvent(\"AddClient\", client, sequenceNumber);\n\t\tif (this.isEligibleFn(client)) {\n\t\t\tthis._eligibleCount++;\n\t\t\tconst newClientIsSummarizer = client.client.details.type === summarizerClientType;\n\t\t\tconst electedClientIsSummarizer =\n\t\t\t\tthis._electedClient?.client.details.type === summarizerClientType;\n\t\t\t// Note that we allow a summarizer client to supersede an interactive client as elected client.\n\t\t\tif (\n\t\t\t\tthis._electedClient === undefined ||\n\t\t\t\t(!electedClientIsSummarizer && newClientIsSummarizer)\n\t\t\t) {\n\t\t\t\tthis.tryElectingClient(client, sequenceNumber, \"AddClient\");\n\t\t\t} else if (this._electedParent === undefined && !newClientIsSummarizer) {\n\t\t\t\t// This is an odd case. If the _electedClient is set, the _electedParent should be as well.\n\t\t\t\tthis.tryElectingParent(client, sequenceNumber, \"AddClient\");\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Updates tracking for when an existing client is removed from the collection.\n\t * Will automatically elect next oldest client if currently elected is removed.\n\t * @param client - client removed from the collection\n\t * @param sequenceNumber - sequence number when client was removed\n\t */\n\tprivate removeClient(client: ILinkedClient, sequenceNumber: number): void {\n\t\tthis.sendPerformanceEvent(\"RemoveClient\", client, sequenceNumber);\n\t\tif (this.isEligibleFn(client)) {\n\t\t\tthis._eligibleCount--;\n\t\t\tif (this._electedClient === client) {\n\t\t\t\t// Removing the _electedClient. There are 2 possible cases:\n\t\t\t\tif (this._electedParent === client) {\n\t\t\t\t\t// 1. The _electedClient is an interactive client that has left the quorum.\n\t\t\t\t\t// Automatically shift to next oldest client.\n\t\t\t\t\tconst nextClient =\n\t\t\t\t\t\tthis.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n\t\t\t\t\t\tthis.findFirstEligibleParent(this.orderedClientCollection.oldestClient);\n\t\t\t\t\tthis.tryElectingClient(nextClient, sequenceNumber, \"RemoveClient\");\n\t\t\t\t} else {\n\t\t\t\t\t// 2. The _electedClient is a summarizer that we've been allowing to finish its work.\n\t\t\t\t\t// Let the _electedParent become the _electedClient so that it can start its own summarizer.\n\t\t\t\t\tif (this._electedClient.client.details.type !== summarizerClientType) {\n\t\t\t\t\t\tthrow new UsageError(\"Elected client should be a summarizer client 1\");\n\t\t\t\t\t}\n\t\t\t\t\tthis.tryElectingClient(\n\t\t\t\t\t\tthis._electedParent,\n\t\t\t\t\t\tsequenceNumber,\n\t\t\t\t\t\t\"RemoveSummarizerClient\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else if (this._electedParent === client) {\n\t\t\t\t// Removing the _electedParent (but not _electedClient).\n\t\t\t\t// Shift to the next oldest parent, but do not replace the _electedClient,\n\t\t\t\t// which is a summarizer that is still doing work.\n\t\t\t\tif (this._electedClient?.client.details.type !== summarizerClientType) {\n\t\t\t\t\tthrow new UsageError(\"Elected client should be a summarizer client 2\");\n\t\t\t\t}\n\t\t\t\tconst nextParent =\n\t\t\t\t\tthis.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n\t\t\t\t\tthis.findFirstEligibleParent(this.orderedClientCollection.oldestClient);\n\t\t\t\tthis.tryElectingParent(nextParent, sequenceNumber, \"RemoveClient\");\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic getAllEligibleClients(): ITrackedClient[] {\n\t\treturn this.orderedClientCollection\n\t\t\t.getAllClients()\n\t\t\t.filter((client) => this.isEligibleFn(client));\n\t}\n\n\t/**\n\t * (Re-)start election with the oldest client in the quorum. This is called if we need to summarize\n\t * and no client has been elected.\n\t */\n\tpublic resetElectedClient(sequenceNumber: number): void {\n\t\tconst firstClient = this.findFirstEligibleParent(\n\t\t\tthis.orderedClientCollection.oldestClient,\n\t\t);\n\t\tif (this._electedClient === undefined || this._electedClient === this._electedParent) {\n\t\t\tthis.tryElectingClient(firstClient, sequenceNumber, \"ResetElectedClient\");\n\t\t} else {\n\t\t\t// The _electedClient is a summarizer and should not be replaced until it leaves the quorum.\n\t\t\t// Changing the _electedParent will stop the summarizer.\n\t\t\tthis.tryElectingParent(firstClient, sequenceNumber, \"ResetElectedClient\");\n\t\t}\n\t}\n\n\tpublic peekNextElectedClient(): ITrackedClient | undefined {\n\t\treturn (\n\t\t\tthis.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n\t\t\tthis.findFirstEligibleParent(this.orderedClientCollection.oldestClient)\n\t\t);\n\t}\n\n\tpublic serialize(): ISerializedElection {\n\t\treturn {\n\t\t\telectionSequenceNumber: this.electionSequenceNumber,\n\t\t\telectedClientId: this.electedClient?.clientId,\n\t\t\telectedParentId: this.electedParent?.clientId,\n\t\t};\n\t}\n\n\tprivate sendPerformanceEvent(\n\t\teventName: string,\n\t\tclient: ILinkedClient | undefined,\n\t\tsequenceNumber: number,\n\t\tforceSend: boolean = false,\n\t\treason?: string,\n\t): void {\n\t\tif (this.recordPerformanceEvents || forceSend) {\n\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\teventName,\n\t\t\t\tclientId: client?.clientId,\n\t\t\t\tsequenceNumber,\n\t\t\t\telectedClientId: this.electedClient?.clientId,\n\t\t\t\telectedParentId: this.electedParent?.clientId,\n\t\t\t\tisEligible: client === undefined ? false : this.isEligibleFn(client),\n\t\t\t\tisSummarizerClient: client?.client.details.type === summarizerClientType,\n\t\t\t\treason,\n\t\t\t});\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blobManager.d.ts","sourceRoot":"","sources":["../../src/blobManager/blobManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAEN,KAAK,wBAAwB,E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,CAAC,eAAe,CAuL9B;IAEF;;;;OAIG;IACI,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,IAAI;IAsB7D,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IA4BlF,SAAS,CAAC,gBAAgB,CAAC,EAAE,iBAAiB,GAAG,qBAAqB;IAI7E;;;;;OAKG;IACI,SAAS,CAAC,MAAM,GAAE,OAAe,GAAG,sBAAsB;IAcjE;;;;;;;;;;;;;;;;OAgBG;IACI,qBAAqB,CAAC,oBAAoB,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE;IA2CxF;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAqB5B;;;;;OAKG;IACH,SAAgB,kBAAkB,yBAA0B,IAAI,MAAM,EAAE,MAAM,CAAC,KAAG,IAAI,CAuBpF;IAEF;;;;;OAKG;IACH,SAAgB,iBAAiB,QAAa,QAAQ,IAAI,CAAC,CAMzD;IAEF;;;;OAIG;IACI,eAAe,IAAI,aAAa,GAAG,SAAS;CA4BnD;AAED;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,YAAa,MAAM,KAAG,MACtB,CAAC;AAWtC;;GAEG;AACH,eAAO,MAAM,UAAU,SAAU,MAAM,gCACL,CAAC"}
|
|
@@ -165,6 +165,7 @@ export class BlobManager {
|
|
|
165
165
|
// If the storage call errors, we can't recover. Reject to throw back to the caller.
|
|
166
166
|
this.localBlobCache.delete(localId);
|
|
167
167
|
this.pendingBlobsWithAttachedHandles.delete(localId);
|
|
168
|
+
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
|
|
168
169
|
reject(error);
|
|
169
170
|
}
|
|
170
171
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blobManager.js","sourceRoot":"","sources":["../../src/blobManager/blobManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH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AAe,CAAC,KAAK,KAAK,WAAW;oBAC7E,CAAC,CAAC;wBACA,KAAK,EAAE,WAAW;wBAClB,IAAI,EAAE,cAAc,CAAC,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC;qBACpD;oBACF,CAAC,CAAC;wBACA,GAAG,eAAe;wBAClB,KAAK,EAAE,UAAU;wBACjB,IAAI,EAAE,cAAc,CAAC,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC;qBACpD,CAAC;QACN,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC;IACxE,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,OAAe,EAAU,EAAE,CACnE,IAAI,mBAAmB,IAAI,OAAO,EAAE,CAAC;AAEtC;;GAEG;AACH,MAAM,wBAAwB,GAAG,CAAC,QAAgB,EAAU,EAAE;IAC7D,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,4BAA4B,CAAC,CAAC;IACxE,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC;AACrB,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAsD,EAAE,CAC9F,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAEnC,MAAM,gBAAgB,GAAG,CACxB,SAAmB,EACqC,EAAE,CAC1D,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,mBAAmB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString, createEmitter, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport {\n\tAttachState,\n\ttype IContainerStorageService,\n} from \"@fluidframework/container-definitions/internal\";\nimport type {\n\tIContainerRuntime,\n\tIContainerRuntimeEvents,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport type {\n\tIEmitter,\n\tIEventProvider,\n\tIFluidHandleContext,\n\tIFluidHandleInternalPayloadPending,\n\tILocalFluidHandle,\n\tILocalFluidHandleEvents,\n\tListenable,\n\tPayloadState,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { ICreateBlobResponse } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tIGarbageCollectionData,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\tISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tFluidHandleBase,\n\tcreateResponseError,\n\tgenerateHandleContextPath,\n\tresponseToException,\n} from \"@fluidframework/runtime-utils/internal\";\nimport {\n\tLoggingError,\n\ttype MonitoringContext,\n\tPerformanceEvent,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { isBlobMetadata } from \"../metadata.js\";\n\nimport {\n\tsummarizeBlobManagerState,\n\ttoRedirectTable,\n\ttype IBlobManagerLoadInfo,\n} from \"./blobManagerSnapSum.js\";\n\n/**\n * This class represents blob (long string)\n * This object is used only when creating (writing) new blob and serialization purposes.\n * De-serialization process goes through FluidObjectHandle and request flow:\n * DataObject.request() recognizes requests in the form of `/blobs/<id>`\n * and loads blob.\n */\nexport class BlobHandle\n\textends FluidHandleBase<ArrayBufferLike>\n\timplements\n\t\tILocalFluidHandle<ArrayBufferLike>,\n\t\tIFluidHandleInternalPayloadPending<ArrayBufferLike>\n{\n\tprivate attached: boolean = false;\n\n\tpublic get isAttached(): boolean {\n\t\treturn this.routeContext.isAttached && this.attached;\n\t}\n\n\tprivate _events:\n\t\t| (Listenable<ILocalFluidHandleEvents> & IEmitter<ILocalFluidHandleEvents>)\n\t\t| undefined;\n\tpublic get events(): Listenable<ILocalFluidHandleEvents> {\n\t\treturn (this._events ??= createEmitter<ILocalFluidHandleEvents>());\n\t}\n\n\tprivate _payloadState: PayloadState;\n\tpublic get payloadState(): PayloadState {\n\t\treturn this._payloadState;\n\t}\n\n\t/**\n\t * The error property starts undefined, signalling that there has been no error yet.\n\t * If an error occurs, the property will contain the error.\n\t */\n\tprivate _payloadShareError: unknown;\n\tpublic get payloadShareError(): unknown {\n\t\treturn this._payloadShareError;\n\t}\n\n\tpublic readonly absolutePath: string;\n\n\tpublic constructor(\n\t\tpublic readonly path: string,\n\t\tpublic readonly routeContext: IFluidHandleContext,\n\t\t// TODO: just take the blob rather than a get function?\n\t\tpublic get: () => Promise<ArrayBufferLike>,\n\t\tpublic readonly payloadPending: boolean,\n\t\tprivate readonly onAttachGraph?: () => void,\n\t) {\n\t\tsuper();\n\t\tthis._payloadState = payloadPending ? \"pending\" : \"shared\";\n\t\tthis.absolutePath = generateHandleContextPath(path, this.routeContext);\n\t}\n\n\tpublic readonly notifyShared = (): void => {\n\t\tthis._payloadState = \"shared\";\n\t\tthis._events?.emit(\"payloadShared\");\n\t};\n\n\tpublic readonly notifyFailed = (error: unknown): void => {\n\t\tthis._payloadShareError = error;\n\t\tthis._events?.emit(\"payloadShareFailed\", error);\n\t};\n\n\tpublic attachGraph(): void {\n\t\tif (!this.attached) {\n\t\t\tthis.attached = true;\n\t\t\tthis.onAttachGraph?.();\n\t\t}\n\t}\n}\n\n// Restrict the IContainerRuntime interface to the subset required by BlobManager. This helps to make\n// the contract explicit and reduces the amount of mocking required for tests.\nexport type IBlobManagerRuntime = Pick<\n\tIContainerRuntime,\n\t\"attachState\" | \"baseLogger\" | \"disposed\"\n> &\n\tIEventProvider<IContainerRuntimeEvents>;\n\nexport type ICreateBlobResponseWithTTL = ICreateBlobResponse &\n\tPartial<Record<\"minTTLInSeconds\", number>>;\n\n/**\n * A blob tracked by BlobManager that is only available on the local client. It is not currently\n * attempting an upload.\n */\ninterface LocalOnlyBlob {\n\tstate: \"localOnly\";\n\tblob: ArrayBufferLike;\n}\n\n/**\n * A blob tracked by BlobManager that is only known to be available on the local client, but is in\n * the process of being uploaded to storage.\n */\ninterface UploadingBlob {\n\tstate: \"uploading\";\n\tblob: ArrayBufferLike;\n}\n\n/**\n * A blob tracked by BlobManager that has been uploaded to storage. If the TTL has not expired, it\n * should still be available in storage. It is not currently attempting to send a BlobAttach op.\n */\ninterface UploadedBlob {\n\tstate: \"uploaded\";\n\tblob: ArrayBufferLike;\n\tstorageId: string;\n\tuploadTime: number;\n\tminTTLInSeconds: number | undefined;\n}\n\n/**\n * A blob tracked by BlobManager that has been uploaded to storage and is in the process of sending\n * a BlobAttach message and waiting for the ack.\n */\ninterface AttachingBlob {\n\tstate: \"attaching\";\n\tblob: ArrayBufferLike;\n\tstorageId: string;\n\tuploadTime: number;\n\tminTTLInSeconds: number | undefined;\n}\n\n/**\n * A blob tracked by BlobManager that has been uploaded to storage and its BlobAttach message has been\n * ack'd. It is fully shared and available to all clients, and is no longer considered pending.\n */\ninterface AttachedBlob {\n\tstate: \"attached\";\n\tblob: ArrayBufferLike;\n}\n\n/**\n * Blobs that were created locally are tracked, and may be in one of these states. When first\n * created, they are in localOnly state. The process of sharing has two steps, blob upload and\n * sending a BlobAttach op. Progress through the stages may regress back to localOnly if we\n * determine the storage may have deleted the blob before we could finish attaching it.\n */\ntype LocalBlobRecord =\n\t| LocalOnlyBlob\n\t| UploadingBlob\n\t| UploadedBlob\n\t| AttachingBlob\n\t| AttachedBlob;\n\n/**\n * Serializable form of the LocalBlobRecord that can be used to save and restore pending state.\n * Omits attached blobs since they are fully uploaded and don't need to be saved and restored.\n * Omits uploading and attaching states since upon restore we will need to restart those processes.\n */\nexport type SerializableLocalBlobRecord =\n\t| (Omit<LocalOnlyBlob, \"blob\"> & { blob: string })\n\t| (Omit<UploadedBlob, \"blob\"> & { blob: string });\n\nexport interface IPendingBlobs {\n\t[localId: string]: SerializableLocalBlobRecord;\n}\n\n/**\n * Check if for a given uploaded or attaching blob, the TTL is too close to expiry to safely attempt\n * an attach. Currently using a heuristic of half the TTL duration having passed since upload.\n */\nconst isTTLTooCloseToExpiry = (blobRecord: UploadedBlob | AttachingBlob): boolean =>\n\tblobRecord.minTTLInSeconds !== undefined &&\n\tDate.now() - blobRecord.uploadTime > (blobRecord.minTTLInSeconds / 2) * 1000;\n\ninterface IBlobManagerInternalEvents {\n\tblobExpired: (localId: string) => void;\n\thandleAttached: (pending: LocalBlobRecord) => void;\n\tprocessedBlobAttach: (localId: string, storageId: string) => void;\n}\n\nconst createAbortError = (): LoggingError => new LoggingError(\"uploadBlob aborted\");\n\nexport const blobManagerBasePath = \"_blobs\";\n\nexport class BlobManager {\n\tprivate readonly mc: MonitoringContext;\n\n\tprivate readonly internalEvents = createEmitter<IBlobManagerInternalEvents>();\n\n\t/**\n\t * Map of local IDs to storage IDs. Also includes identity mappings of storage ID to storage ID for all known\n\t * storage IDs. All requested IDs must be a key in this map. Blobs created while the container is detached are\n\t * stored in IDetachedBlobStorage which gives pseudo storage IDs; the real storage IDs are filled in at attach\n\t * time via setRedirectTable().\n\t */\n\tprivate readonly redirectTable: Map<string, string>;\n\n\t/**\n\t * The localBlobCache has a dual role of caching locally-created blobs, as well as tracking their state as they\n\t * are shared. Keys are localIds.\n\t */\n\tprivate readonly localBlobCache: Map<string, LocalBlobRecord> = new Map();\n\t/**\n\t * Blobs with an attached handle that have not finished blob-attaching are the set we need to provide from\n\t * getPendingState(). This stores their local IDs, and then we can look them up against the localBlobCache.\n\t */\n\tprivate readonly pendingBlobsWithAttachedHandles: Set<string> = new Set();\n\t/**\n\t * Local IDs for any pending blobs we loaded with and have not yet started the upload/attach flow for.\n\t */\n\tprivate readonly pendingOnlyLocalIds: Set<string> = new Set();\n\n\tprivate readonly sendBlobAttachMessage: (localId: string, storageId: string) => void;\n\n\tprivate readonly routeContext: IFluidHandleContext;\n\tprivate readonly storage: Pick<IContainerStorageService, \"createBlob\" | \"readBlob\">;\n\t// Called when a blob node is requested. blobPath is the path of the blob's node in GC's graph.\n\t// blobPath's format - `/<basePath>/<localId>`.\n\tprivate readonly blobRequested: (blobPath: string) => void;\n\t// Called to check if a blob has been deleted by GC.\n\t// blobPath's format - `/<basePath>/<localId>`.\n\tprivate readonly isBlobDeleted: (blobPath: string) => boolean;\n\tprivate readonly runtime: IBlobManagerRuntime;\n\tprivate readonly localIdGenerator: () => string;\n\n\tprivate readonly createBlobPayloadPending: boolean;\n\n\tpublic constructor(props: {\n\t\treadonly routeContext: IFluidHandleContext;\n\n\t\tblobManagerLoadInfo: IBlobManagerLoadInfo;\n\t\treadonly storage: Pick<IContainerStorageService, \"createBlob\" | \"readBlob\">;\n\t\t/**\n\t\t * Submit a BlobAttach message. When a blob is uploaded, there is a short grace period before which the blob is\n\t\t * deleted. The BlobAttach message notifies the server that blob is in use. The server will then not delete the\n\t\t * the blob as long as it is listed as referenced in future summaries. The summarizing client will know to\n\t\t * include the storage ID in the summary when it sees the message.\n\t\t *\n\t\t * The message will also include a local ID to inform all clients of the relation to the storage ID, without\n\t\t * knowledge of which they cannot request the blob from storage. It's important that this message is sequenced\n\t\t * before any messages that reference the local ID, otherwise, an invalid handle could be added to the document.\n\t\t */\n\t\tsendBlobAttachMessage: (localId: string, storageId: string) => void;\n\t\t// Called when a blob node is requested. blobPath is the path of the blob's node in GC's graph.\n\t\t// blobPath's format - `/<basePath>/<localId>`.\n\t\treadonly blobRequested: (blobPath: string) => void;\n\t\t// Called to check if a blob has been deleted by GC.\n\t\t// blobPath's format - `/<basePath>/<localId>`.\n\t\treadonly isBlobDeleted: (blobPath: string) => boolean;\n\t\treadonly runtime: IBlobManagerRuntime;\n\t\tpendingBlobs: IPendingBlobs | undefined;\n\t\treadonly localIdGenerator?: (() => string) | undefined;\n\t\treadonly createBlobPayloadPending: boolean;\n\t}) {\n\t\tconst {\n\t\t\trouteContext,\n\t\t\tblobManagerLoadInfo,\n\t\t\tstorage,\n\t\t\tsendBlobAttachMessage,\n\t\t\tblobRequested,\n\t\t\tisBlobDeleted,\n\t\t\truntime,\n\t\t\tpendingBlobs,\n\t\t\tlocalIdGenerator,\n\t\t\tcreateBlobPayloadPending,\n\t\t} = props;\n\t\tthis.routeContext = routeContext;\n\t\tthis.storage = storage;\n\t\tthis.sendBlobAttachMessage = sendBlobAttachMessage;\n\t\tthis.blobRequested = blobRequested;\n\t\tthis.isBlobDeleted = isBlobDeleted;\n\t\tthis.runtime = runtime;\n\t\tthis.localIdGenerator = localIdGenerator ?? uuid;\n\t\tthis.createBlobPayloadPending = createBlobPayloadPending;\n\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger: this.runtime.baseLogger,\n\t\t\tnamespace: \"BlobManager\",\n\t\t});\n\n\t\tthis.redirectTable = toRedirectTable(blobManagerLoadInfo, this.mc.logger);\n\n\t\t// We populate the localBlobCache with any pending blobs we are provided, which makes them available\n\t\t// to access even though they are not shared yet. However, we don't start the share flow until it is\n\t\t// explicitly invoked via sharePendingBlobs() in case we are loaded in a frozen container.\n\t\tif (pendingBlobs !== undefined) {\n\t\t\tfor (const [localId, serializableBlobRecord] of Object.entries(pendingBlobs)) {\n\t\t\t\tassert(\n\t\t\t\t\t!this.redirectTable.has(localId),\n\t\t\t\t\t0xc7e /* Pending blob already in redirect table */,\n\t\t\t\t);\n\t\t\t\tconst localBlobRecord = {\n\t\t\t\t\t...serializableBlobRecord,\n\t\t\t\t\tblob: stringToBuffer(serializableBlobRecord.blob, \"base64\"),\n\t\t\t\t};\n\t\t\t\tthis.localBlobCache.set(localId, localBlobRecord);\n\t\t\t\t// Since we received these blobs from pending state, we'll assume they were only added to the\n\t\t\t\t// pending state at generation time because their handles were attached. We add them back here\n\t\t\t\t// in case we need to round-trip them back out again due to another getPendingBlobs() call.\n\t\t\t\tthis.pendingBlobsWithAttachedHandles.add(localId);\n\t\t\t\tthis.pendingOnlyLocalIds.add(localId);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns whether a blob with the given localId can be retrieved by the BlobManager via getBlob().\n\t */\n\tpublic hasBlob(localId: string): boolean {\n\t\treturn this.redirectTable.has(localId) || this.localBlobCache.has(localId);\n\t}\n\n\t/**\n\t * Lookup the blob storage ID for a given local blob id.\n\t * @param localId - The local blob id. Likely coming from a handle.\n\t * @returns The storage ID if found and the blob is not pending, undefined otherwise.\n\t * @remarks\n\t * For blobs with pending payloads (localId exists but upload hasn't finished), this is expected to return undefined.\n\t * Consumers should use the observability APIs on the handle (handle.payloadState, payloadShared event)\n\t * to understand/wait for storage ID availability.\n\t * Similarly, when the runtime is detached, this will return undefined as no blobs have been uploaded to storage.\n\t */\n\tpublic lookupTemporaryBlobStorageId(localId: string): string | undefined {\n\t\tif (this.runtime.attachState === AttachState.Detached) {\n\t\t\treturn undefined;\n\t\t}\n\t\t// Get the storage ID from the redirect table\n\t\treturn this.redirectTable.get(localId);\n\t}\n\n\t/**\n\t * Retrieve the blob with the given local blob id.\n\t * @param localId - The local blob id. Likely coming from a handle.\n\t * @param payloadPending - Whether we suspect the payload may be pending and not available yet.\n\t * @returns A promise which resolves to the blob contents\n\t */\n\tpublic async getBlob(localId: string, payloadPending: boolean): Promise<ArrayBufferLike> {\n\t\t// Verify that the blob is not deleted, i.e., it has not been garbage collected. If it is, this will throw\n\t\t// an error, failing the call.\n\t\tthis.verifyBlobNotDeleted(localId);\n\t\t// Let runtime know that the corresponding GC node was requested.\n\t\t// Note that this will throw if the blob is inactive or tombstoned and throwing on incorrect usage\n\t\t// is configured.\n\t\tthis.blobRequested(getGCNodePathFromLocalId(localId));\n\n\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\tif (localBlobRecord !== undefined) {\n\t\t\treturn localBlobRecord.blob;\n\t\t}\n\n\t\tlet storageId = this.redirectTable.get(localId);\n\t\tif (storageId === undefined) {\n\t\t\t// Only blob handles explicitly marked with pending payload are permitted to exist without\n\t\t\t// yet knowing their storage id. Otherwise they must already be associated with a storage id.\n\t\t\t// Handles for detached blobs are not payload pending, though they should also always be present\n\t\t\t// in the localBlobCache and therefore should never need to refer to storage.\n\t\t\tassert(payloadPending, 0x11f /* \"requesting unknown blobs\" */);\n\t\t\t// If we didn't find it in the redirectTable and it's payloadPending, assume the attach message is coming\n\t\t\t// eventually and wait. We do this even if the local client doesn't have the blob payloadPending flag\n\t\t\t// enabled, in case a remote client does have it enabled. This wait may be infinite if the uploading\n\t\t\t// client failed the upload and doesn't exist anymore.\n\t\t\t// TODO: Fix this violation and remove the disable\n\t\t\t// eslint-disable-next-line require-atomic-updates\n\t\t\tstorageId = await new Promise<string>((resolve) => {\n\t\t\t\tconst onProcessBlobAttach = (_localId: string, _storageId: string): void => {\n\t\t\t\t\tif (_localId === localId) {\n\t\t\t\t\t\tthis.internalEvents.off(\"processedBlobAttach\", onProcessBlobAttach);\n\t\t\t\t\t\tresolve(_storageId);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tthis.internalEvents.on(\"processedBlobAttach\", onProcessBlobAttach);\n\t\t\t});\n\t\t}\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.mc.logger,\n\t\t\t{ eventName: \"AttachmentReadBlob\", id: storageId },\n\t\t\tasync (event) => {\n\t\t\t\treturn this.storage.readBlob(storageId).catch((error) => {\n\t\t\t\t\tif (this.runtime.disposed) {\n\t\t\t\t\t\t// If the runtime is disposed, this is not an error we care to track, it's expected behavior.\n\t\t\t\t\t\tevent.cancel({ category: \"generic\" });\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t\t},\n\t\t\t{ end: true, cancel: \"error\" },\n\t\t);\n\t}\n\n\tprivate getNonPayloadPendingBlobHandle(localId: string): BlobHandle {\n\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\tassert(localBlobRecord !== undefined, 0x384 /* requesting handle for unknown blob */);\n\t\tassert(localBlobRecord.state === \"attached\", 0xc7f /* Expected blob to be attached */);\n\n\t\treturn new BlobHandle(\n\t\t\tgetGCNodePathFromLocalId(localId),\n\t\t\tthis.routeContext,\n\t\t\tasync () => this.getBlob(localId, false),\n\t\t\tfalse, // payloadPending\n\t\t);\n\t}\n\n\tpublic async createBlob(\n\t\tblob: ArrayBufferLike,\n\t\tsignal?: AbortSignal,\n\t): Promise<IFluidHandleInternalPayloadPending<ArrayBufferLike>> {\n\t\tif (this.runtime.attachState === AttachState.Detached) {\n\t\t\treturn this.createBlobDetached(blob, signal);\n\t\t}\n\t\tif (this.runtime.attachState === AttachState.Attaching) {\n\t\t\t// blob upload is not supported in \"Attaching\" state\n\t\t\tthis.mc.logger.sendTelemetryEvent({ eventName: \"CreateBlobWhileAttaching\" });\n\t\t\tawait new Promise<void>((resolve) => this.runtime.once(\"attached\", resolve));\n\t\t}\n\t\tassert(\n\t\t\tthis.runtime.attachState === AttachState.Attached,\n\t\t\t0x385 /* For clarity and paranoid defense against adding future attachment states */,\n\t\t);\n\n\t\treturn this.createBlobPayloadPending\n\t\t\t? this.createBlobWithPayloadPending(blob, signal)\n\t\t\t: this.createBlobLegacy(blob, signal);\n\t}\n\n\tprivate async createBlobDetached(\n\t\tblob: ArrayBufferLike,\n\t\tsignal?: AbortSignal,\n\t): Promise<IFluidHandleInternalPayloadPending<ArrayBufferLike>> {\n\t\tif (signal?.aborted === true) {\n\t\t\tthrow createAbortError();\n\t\t}\n\t\tconst localId = this.localIdGenerator();\n\t\tthis.localBlobCache.set(localId, { state: \"uploading\", blob });\n\t\t// Blobs created while the container is detached are stored in IDetachedBlobStorage.\n\t\t// The 'IContainerStorageService.createBlob()' call below will respond with a pseudo storage ID.\n\t\t// That pseudo storage ID will be replaced with the real storage ID at attach time.\n\t\tconst { id: detachedStorageId } = await this.storage.createBlob(blob);\n\t\t// From the perspective of the BlobManager, the blob is now fully attached. The actual\n\t\t// upload/attach process at container attach time is treated as opaque to this tracking.\n\t\tthis.localBlobCache.set(localId, { state: \"attached\", blob });\n\t\tthis.redirectTable.set(localId, detachedStorageId);\n\t\treturn this.getNonPayloadPendingBlobHandle(localId);\n\t}\n\n\tprivate async createBlobLegacy(\n\t\tblob: ArrayBufferLike,\n\t\tsignal?: AbortSignal,\n\t): Promise<IFluidHandleInternalPayloadPending<ArrayBufferLike>> {\n\t\tconst localId = this.localIdGenerator();\n\t\tthis.localBlobCache.set(localId, { state: \"localOnly\", blob });\n\t\tawait this.uploadAndAttach(localId, signal);\n\t\treturn this.getNonPayloadPendingBlobHandle(localId);\n\t}\n\n\tprivate createBlobWithPayloadPending(\n\t\tblob: ArrayBufferLike,\n\t\tsignal?: AbortSignal,\n\t): IFluidHandleInternalPayloadPending<ArrayBufferLike> {\n\t\tconst localId = this.localIdGenerator();\n\t\tthis.localBlobCache.set(localId, { state: \"localOnly\", blob });\n\n\t\tconst blobHandle = new BlobHandle(\n\t\t\tgetGCNodePathFromLocalId(localId),\n\t\t\tthis.routeContext,\n\t\t\tasync () => blob,\n\t\t\ttrue, // payloadPending\n\t\t\t() => {\n\t\t\t\tthis.pendingBlobsWithAttachedHandles.add(localId);\n\t\t\t\tconst uploadAndAttachP = this.uploadAndAttach(localId, signal);\n\t\t\t\tuploadAndAttachP.then(blobHandle.notifyShared).catch((error) => {\n\t\t\t\t\t// TODO: notifyShared won't fail directly, but it emits an event to the customer.\n\t\t\t\t\t// Consider what to do if the customer's code throws. reportError is nice.\n\t\t\t\t});\n\t\t\t\tuploadAndAttachP.catch(blobHandle.notifyFailed);\n\t\t\t},\n\t\t);\n\n\t\treturn blobHandle;\n\t}\n\n\t/**\n\t * Upload and attach the localBlobCache entry for the given localId.\n\t *\n\t * Expects the localBlobCache entry for the given localId to be in either localOnly or uploaded state\n\t * when called. Returns a promise that resolves when the blob completes uploading and attaching, or else\n\t * rejects if an error is encountered or the signal is aborted.\n\t */\n\tprivate readonly uploadAndAttach = async (\n\t\tlocalId: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<void> => {\n\t\tif (signal?.aborted === true) {\n\t\t\tthis.localBlobCache.delete(localId);\n\t\t\tthis.pendingBlobsWithAttachedHandles.delete(localId);\n\t\t\tthrow createAbortError();\n\t\t}\n\t\tconst localBlobRecordInitial = this.localBlobCache.get(localId);\n\t\tassert(\n\t\t\tlocalBlobRecordInitial?.state === \"localOnly\" ||\n\t\t\t\tlocalBlobRecordInitial?.state === \"uploaded\",\n\t\t\t0xc80 /* Expect uploadAndAttach to be called with either localOnly or uploaded state */,\n\t\t);\n\t\tconst { blob } = localBlobRecordInitial;\n\n\t\t/**\n\t\t * Expects the localBlobCache entry for the given localId to be in either localOnly or uploaded state\n\t\t * when called. Returns a promise that resolves when the blob is in uploaded or attached state, or else\n\t\t * rejects on error during upload or if the signal is aborted.\n\t\t *\n\t\t * Most of the time this should be expected to exit in uploaded state, but if we are loading from pending\n\t\t * state we may see an attach message from the client that generated the pending state, which can complete the\n\t\t * attach while the upload is outstanding.\n\t\t */\n\t\tconst ensureUploaded = async (): Promise<void> => {\n\t\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\t\tif (localBlobRecord?.state === \"uploaded\") {\n\t\t\t\t// In normal creation flows, the blob will be in localOnly state here. But in the case of loading\n\t\t\t\t// with pending state we can call it with an uploaded-but-not-attached blob. Start the upload\n\t\t\t\t// flow only if it's localOnly.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tassert(\n\t\t\t\tlocalBlobRecord?.state === \"localOnly\",\n\t\t\t\t0xc81 /* Attempting to upload from unexpected state */,\n\t\t\t);\n\n\t\t\tthis.localBlobCache.set(localId, { state: \"uploading\", blob });\n\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\t// If we eventually have driver-level support for abort, then this can simplify a bit as we won't\n\t\t\t\t// need to track upload completion and abort separately. Until then, we need to handle the case that\n\t\t\t\t// the upload continues and settles after becoming irrelevant due to signal abort or blob attach.\n\t\t\t\tlet uploadHasBecomeIrrelevant = false;\n\t\t\t\tconst onSignalAbort = (): void => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tuploadHasBecomeIrrelevant = true;\n\t\t\t\t\tthis.localBlobCache.delete(localId);\n\t\t\t\t\tthis.pendingBlobsWithAttachedHandles.delete(localId);\n\t\t\t\t\treject(createAbortError());\n\t\t\t\t};\n\t\t\t\tconst onProcessedBlobAttach = (_localId: string, _storageId: string): void => {\n\t\t\t\t\tif (_localId === localId) {\n\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\tuploadHasBecomeIrrelevant = true;\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tconst removeListeners = (): void => {\n\t\t\t\t\tthis.internalEvents.off(\"processedBlobAttach\", onProcessedBlobAttach);\n\t\t\t\t\tsignal?.removeEventListener(\"abort\", onSignalAbort);\n\t\t\t\t};\n\t\t\t\tthis.internalEvents.on(\"processedBlobAttach\", onProcessedBlobAttach);\n\t\t\t\tsignal?.addEventListener(\"abort\", onSignalAbort);\n\n\t\t\t\tthis.storage\n\t\t\t\t\t.createBlob(blob)\n\t\t\t\t\t.then((createBlobResponse: ICreateBlobResponseWithTTL) => {\n\t\t\t\t\t\tif (!uploadHasBecomeIrrelevant) {\n\t\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\t\tthis.localBlobCache.set(localId, {\n\t\t\t\t\t\t\t\tstate: \"uploaded\",\n\t\t\t\t\t\t\t\tblob,\n\t\t\t\t\t\t\t\tstorageId: createBlobResponse.id,\n\t\t\t\t\t\t\t\tuploadTime: Date.now(),\n\t\t\t\t\t\t\t\tminTTLInSeconds: createBlobResponse.minTTLInSeconds,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t.catch((error) => {\n\t\t\t\t\t\tif (!uploadHasBecomeIrrelevant) {\n\t\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\t\t// If the storage call errors, we can't recover. Reject to throw back to the caller.\n\t\t\t\t\t\t\tthis.localBlobCache.delete(localId);\n\t\t\t\t\t\t\tthis.pendingBlobsWithAttachedHandles.delete(localId);\n\t\t\t\t\t\t\treject(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t});\n\t\t};\n\n\t\t/**\n\t\t * Expects the localBlobCache entry for the given localId to be in uploaded or attached state when called.\n\t\t * Returns a promise that resolves to true if the blob is successfully attached, or false if it cannot be\n\t\t * attached and the upload flow needs to be restarted from the top (currently only if the TTL expires before\n\t\t * attach can be completed). In the latter case, the localBlobRecord will also be reset to localOnly state.\n\t\t * The promise rejects if the signal is aborted.\n\t\t */\n\t\tconst tryAttach = async (): Promise<boolean> => {\n\t\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\t\tif (localBlobRecord?.state === \"attached\") {\n\t\t\t\t// In normal creation flows, the blob will be in uploaded state here. But if we are loading from pending\n\t\t\t\t// state and see an attach message from the client that generated the pending state, we may have reached\n\t\t\t\t// attached state in the middle of the upload attempt. In that case there's no more work to do and we\n\t\t\t\t// can just return.\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tassert(\n\t\t\t\tlocalBlobRecord?.state === \"uploaded\",\n\t\t\t\t0xc82 /* Attempting to attach from unexpected state */,\n\t\t\t);\n\n\t\t\t// If we just uploaded the blob TTL really shouldn't be expired at this location. But if we loaded from\n\t\t\t// pending state, the upload may have happened some time far in the past and could be expired here.\n\t\t\tif (isTTLTooCloseToExpiry(localBlobRecord)) {\n\t\t\t\t// If the TTL is expired, we assume it's gone from the storage and so is effectively localOnly again.\n\t\t\t\t// Then when we re-enter the loop, we'll re-upload it.\n\t\t\t\tthis.localBlobCache.set(localId, { state: \"localOnly\", blob });\n\t\t\t\t// Emitting here isn't really necessary since the only listener would be attached below. Including here\n\t\t\t\t// for completeness though, in case we add other listeners in the future.\n\t\t\t\tthis.internalEvents.emit(\"blobExpired\", localId);\n\t\t\t\treturn false;\n\t\t\t} else {\n\t\t\t\tthis.localBlobCache.set(localId, {\n\t\t\t\t\t...localBlobRecord,\n\t\t\t\t\tstate: \"attaching\",\n\t\t\t\t});\n\n\t\t\t\t// Send and await a blob attach op. This serves two purposes:\n\t\t\t\t// 1. If its a new blob, i.e., it isn't de-duped, the server will keep the blob alive if it sees this op\n\t\t\t\t// until its storage ID is added to the next summary.\n\t\t\t\t// 2. It will create a local ID to storage ID mapping in all clients which is needed to retrieve the\n\t\t\t\t// blob from the server via the storage ID.\n\t\t\t\treturn new Promise<boolean>((resolve, reject) => {\n\t\t\t\t\tconst onProcessedBlobAttach = (_localId: string, _storageId: string): void => {\n\t\t\t\t\t\tif (_localId === localId) {\n\t\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\t// Although we already checked for TTL expiry above, the message we're about to send may later be asked\n\t\t\t\t\t// to resubmit. Before we resubmit, we check again for TTL expiry - this listener is how we learn if\n\t\t\t\t\t// we discovered expiry in the resubmit flow.\n\t\t\t\t\tconst onBlobExpired = (_localId: string): void => {\n\t\t\t\t\t\tif (_localId === localId) {\n\t\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\t\tresolve(false);\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\tconst onSignalAbort = (): void => {\n\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\tthis.localBlobCache.delete(localId);\n\t\t\t\t\t\tthis.pendingBlobsWithAttachedHandles.delete(localId);\n\t\t\t\t\t\treject(createAbortError());\n\t\t\t\t\t};\n\t\t\t\t\tconst removeListeners = (): void => {\n\t\t\t\t\t\tthis.internalEvents.off(\"processedBlobAttach\", onProcessedBlobAttach);\n\t\t\t\t\t\tthis.internalEvents.off(\"blobExpired\", onBlobExpired);\n\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onSignalAbort);\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.internalEvents.on(\"processedBlobAttach\", onProcessedBlobAttach);\n\t\t\t\t\tthis.internalEvents.on(\"blobExpired\", onBlobExpired);\n\t\t\t\t\tsignal?.addEventListener(\"abort\", onSignalAbort);\n\t\t\t\t\tthis.sendBlobAttachMessage(localId, localBlobRecord.storageId);\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\n\t\tlet attachCompleted = false;\n\t\twhile (!attachCompleted) {\n\t\t\tawait ensureUploaded();\n\t\t\tattachCompleted = await tryAttach();\n\n\t\t\t// If something stopped the attach from completing successfully (currently just TTL expiry),\n\t\t\t// we expect that the blob was already updated to reflect the updated state (i.e. back to localOnly)\n\t\t\t// and we'll try the loop again from the top.\n\t\t}\n\t\t// When the blob successfully attaches, the localBlobRecord will have been updated to attached state\n\t\t// at the time we processed the op, so there's nothing else to do here.\n\t};\n\n\t/**\n\t * Resubmit a BlobAttach op. Used to add storage IDs to messages that were\n\t * submitted to runtime while disconnected.\n\t * @param metadata - message metadata containing storage and/or local IDs\n\t */\n\tpublic reSubmit(metadata: Record<string, unknown> | undefined): void {\n\t\tassert(isBlobMetadata(metadata), 0xc01 /* Expected blob metadata for a BlobAttach op */);\n\t\tconst { localId, blobId: storageId } = metadata;\n\t\t// Any blob that we're actively trying to advance to attached state must be in attaching state.\n\t\t// Decline to resubmit for anything else.\n\t\t// For example, we might be asked to resubmit stashed messages for blobs that never had their handle\n\t\t// attached - these won't have a localBlobCache entry because we filter them out when generating\n\t\t// pending state. We shouldn't try to attach them since they won't be accessible to the customer\n\t\t// and would just be considered garbage immediately.\n\t\t// TODO: Is it possible that we'd be asked to resubmit for a pending blob before we call sharePendingBlobs?\n\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\tif (localBlobRecord?.state === \"attaching\") {\n\t\t\t// If the TTL is expired, we assume it's gone from the storage and so is effectively localOnly again.\n\t\t\tif (isTTLTooCloseToExpiry(localBlobRecord)) {\n\t\t\t\tthis.localBlobCache.set(localId, { state: \"localOnly\", blob: localBlobRecord.blob });\n\t\t\t\tthis.internalEvents.emit(\"blobExpired\", localId);\n\t\t\t} else {\n\t\t\t\tthis.sendBlobAttachMessage(localId, storageId);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic processBlobAttachMessage(message: ISequencedMessageEnvelope, local: boolean): void {\n\t\tassert(\n\t\t\tisBlobMetadata(message.metadata),\n\t\t\t0xc02 /* Expected blob metadata for a BlobAttach op */,\n\t\t);\n\t\tconst { localId, blobId: storageId } = message.metadata;\n\t\tconst maybeLocalBlobRecord = this.localBlobCache.get(localId);\n\t\tif (maybeLocalBlobRecord !== undefined) {\n\t\t\tconst attachedBlobRecord: AttachedBlob = {\n\t\t\t\tstate: \"attached\",\n\t\t\t\tblob: maybeLocalBlobRecord.blob,\n\t\t\t};\n\t\t\t// Processing a blob attach message is authoritative and may stomp on any existing state. Other\n\t\t\t// callsites that update localBlobCache entries must take proper caution to handle the case\n\t\t\t// that a blob attach message is processed concurrently.\n\t\t\tthis.localBlobCache.set(localId, attachedBlobRecord);\n\t\t\t// Note there may or may not be an entry in pendingBlobsWithAttachedHandles for this localId,\n\t\t\t// in particular for the non-payloadPending case since we should be reaching this point\n\t\t\t// before even returning a handle to the caller.\n\t\t\tthis.pendingBlobsWithAttachedHandles.delete(localId);\n\t\t\tthis.pendingOnlyLocalIds.delete(localId);\n\t\t}\n\t\tthis.redirectTable.set(localId, storageId);\n\t\t// set identity (id -> id) entry\n\t\tthis.redirectTable.set(storageId, storageId);\n\t\tthis.internalEvents.emit(\"processedBlobAttach\", localId, storageId);\n\t}\n\n\tpublic summarize(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats {\n\t\treturn summarizeBlobManagerState(this.redirectTable);\n\t}\n\n\t/**\n\t * Generates data used for garbage collection. Each blob uploaded represents a node in the GC graph as it can be\n\t * individually referenced by storing its handle in a referenced DDS. Returns the list of blob ids as GC nodes.\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data. BlobManager doesn't care\n\t * about this for now because the data is a simple list of blob ids.\n\t */\n\tpublic getGCData(fullGC: boolean = false): IGarbageCollectionData {\n\t\tconst gcData: IGarbageCollectionData = { gcNodes: {} };\n\t\tfor (const [localId, storageId] of this.redirectTable) {\n\t\t\t// Don't report the identity mappings to GC - these exist to service old handles that referenced the storage\n\t\t\t// IDs directly. We'll implicitly clean them up if all of their localId references get GC'd first.\n\t\t\tif (localId !== storageId) {\n\t\t\t\t// The outbound routes are empty because a blob node cannot reference other nodes. It can only be referenced\n\t\t\t\t// by adding its handle to a referenced DDS.\n\t\t\t\tgcData.gcNodes[getGCNodePathFromLocalId(localId)] = [];\n\t\t\t}\n\t\t}\n\t\treturn gcData;\n\t}\n\n\t/**\n\t * Delete blobs with the given routes from the redirect table.\n\t * @returns The routes of blobs that were deleted.\n\t *\n\t * @remarks\n\t * The routes are GC nodes paths of format -`/<blobManagerBasePath>/<localId>`.\n\t * Deleting the blobs involves 2 steps:\n\t *\n\t * 1. The redirect table entry for the local ids are deleted.\n\t *\n\t * 2. If the storage ids corresponding to the deleted local ids are not referenced by any further local ids, the\n\t * identity mappings in the redirect table are deleted as well.\n\t *\n\t * Note that this does not delete the blobs from storage service immediately. Deleting the blobs from redirect table\n\t * will ensure we don't create an attachment blob for them at the next summary. The service would then delete them\n\t * some time in the future.\n\t */\n\tpublic deleteSweepReadyNodes(sweepReadyBlobRoutes: readonly string[]): readonly string[] {\n\t\t// maybeUnusedStorageIds is used to compute the set of storage IDs that *used to have a local ID*, but that\n\t\t// local ID is being deleted.\n\t\tconst maybeUnusedStorageIds: Set<string> = new Set();\n\t\tfor (const route of sweepReadyBlobRoutes) {\n\t\t\tconst localId = getLocalIdFromGCNodePath(route);\n\t\t\t// If the blob hasn't already been deleted, log an error because this should never happen.\n\t\t\t// If the blob has already been deleted, log a telemetry event. This can happen because multiple GC\n\t\t\t// sweep messages can contain the same data store. It would be interesting to track how often this happens.\n\t\t\tconst alreadyDeleted = this.isBlobDeleted(route);\n\t\t\tconst storageId = this.redirectTable.get(localId);\n\t\t\tif (storageId === undefined) {\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"DeletedAttachmentBlobNotFound\",\n\t\t\t\t\tcategory: alreadyDeleted ? \"generic\" : \"error\",\n\t\t\t\t\tblobId: localId,\n\t\t\t\t\tdetails: { alreadyDeleted },\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tmaybeUnusedStorageIds.add(storageId);\n\t\t\tthis.redirectTable.delete(localId);\n\t\t}\n\n\t\t// Remove any storage IDs that still have local IDs referring to them (excluding the identity mapping).\n\t\tfor (const [localId, storageId] of this.redirectTable) {\n\t\t\tif (localId !== storageId) {\n\t\t\t\tmaybeUnusedStorageIds.delete(storageId);\n\t\t\t}\n\t\t}\n\n\t\t// Now delete any identity mappings (storage ID -> storage ID) from the redirect table that used to be\n\t\t// referenced by a distinct local ID. This way they'll be absent from the next summary, and the service\n\t\t// is free to delete them from storage.\n\t\t// WARNING: This can potentially delete identity mappings that are still referenced, if storage deduping\n\t\t// has let us add a local ID -> storage ID mapping that is later deleted. AB#47337 tracks this issue\n\t\t// and possible solutions.\n\t\tfor (const storageId of maybeUnusedStorageIds) {\n\t\t\tthis.redirectTable.delete(storageId);\n\t\t}\n\t\treturn [...sweepReadyBlobRoutes];\n\t}\n\n\t/**\n\t * Verifies that the blob with given id is not deleted, i.e., it has not been garbage collected. If the blob is GC'd,\n\t * log an error and throw if necessary.\n\t */\n\tprivate verifyBlobNotDeleted(localId: string): void {\n\t\tif (!this.isBlobDeleted(getGCNodePathFromLocalId(localId))) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst request = { url: localId };\n\t\tconst error = responseToException(\n\t\t\tcreateResponseError(404, `Blob was deleted`, request),\n\t\t\trequest,\n\t\t);\n\t\t// Only log deleted events. Tombstone events are logged by garbage collector.\n\t\tthis.mc.logger.sendErrorEvent(\n\t\t\t{\n\t\t\t\teventName: \"GC_Deleted_Blob_Requested\",\n\t\t\t\tpkg: blobManagerBasePath,\n\t\t\t},\n\t\t\terror,\n\t\t);\n\t\tthrow error;\n\t}\n\n\t/**\n\t * Called in detached state just prior to attaching, this will update the redirect table by\n\t * converting the pseudo storage IDs into real storage IDs using the provided detachedStorageTable.\n\t * The provided table must have exactly the same set of pseudo storage IDs as are found in the redirect table.\n\t * @param detachedStorageTable - A map of pseudo storage IDs to real storage IDs.\n\t */\n\tpublic readonly patchRedirectTable = (detachedStorageTable: Map<string, string>): void => {\n\t\tassert(\n\t\t\tthis.runtime.attachState === AttachState.Detached,\n\t\t\t0x252 /* \"redirect table can only be set in detached container\" */,\n\t\t);\n\t\t// The values of the redirect table are the pseudo storage IDs, which are the keys of the\n\t\t// detachedStorageTable. We expect to have a many:1 mapping from local IDs to pseudo\n\t\t// storage IDs (many in the case that the storage dedupes the blob).\n\t\tassert(\n\t\t\tnew Set(this.redirectTable.values()).size === detachedStorageTable.size,\n\t\t\t0x391 /* Redirect table size must match BlobManager's local ID count */,\n\t\t);\n\t\t// Taking a snapshot of the redirect table entries before iterating, because\n\t\t// we will be adding identity mappings to the the redirect table as we iterate\n\t\t// and we don't want to include those in the iteration.\n\t\tconst redirectTableEntries = [...this.redirectTable.entries()];\n\t\tfor (const [localId, detachedStorageId] of redirectTableEntries) {\n\t\t\tconst newStorageId = detachedStorageTable.get(detachedStorageId);\n\t\t\tassert(newStorageId !== undefined, 0xc53 /* Couldn't find a matching storage ID */);\n\t\t\tthis.redirectTable.set(localId, newStorageId);\n\t\t\t// set identity (id -> id) entry\n\t\t\tthis.redirectTable.set(newStorageId, newStorageId);\n\t\t}\n\t};\n\n\t/**\n\t * Upload and attach any pending blobs that the BlobManager was loaded with that have not already\n\t * been attached in the meantime.\n\t * @returns A promise that resolves when all the uploads and attaches have completed, or rejects\n\t * if any of them fail.\n\t */\n\tpublic readonly sharePendingBlobs = async (): Promise<void> => {\n\t\tconst localIdsToUpload = [...this.pendingOnlyLocalIds];\n\t\tthis.pendingOnlyLocalIds.clear();\n\t\tawait Promise.all<void>(\n\t\t\tlocalIdsToUpload.map(async (localId) => this.uploadAndAttach(localId)),\n\t\t);\n\t};\n\n\t/**\n\t * To be used in getPendingLocalState flow. Get a serializable record of the blobs that are\n\t * pending upload and/or their BlobAttach op, which can be given to a new BlobManager to\n\t * resume work.\n\t */\n\tpublic getPendingBlobs(): IPendingBlobs | undefined {\n\t\tconst pendingBlobs: IPendingBlobs = {};\n\t\tfor (const localId of this.pendingBlobsWithAttachedHandles) {\n\t\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\t\tassert(localBlobRecord !== undefined, 0xc83 /* Pending blob must be in local cache */);\n\t\t\tassert(\n\t\t\t\tlocalBlobRecord.state !== \"attached\",\n\t\t\t\t0xc84 /* Pending blob must not be in attached state */,\n\t\t\t);\n\t\t\t// We downgrade uploading blobs to localOnly, and attaching blobs to uploaded. In the case of\n\t\t\t// uploading blobs, we don't have a way to retrieve the eventual storageId so the upload will\n\t\t\t// need to be restarted anyway. In the case of attaching blobs, we can't know whether the\n\t\t\t// BlobAttach message will eventually be ack'd. So we assume we'll need to send another message, but also\n\t\t\t// remain prepared to handle seeing the ack of the original message after loading from pending state.\n\t\t\tpendingBlobs[localId] =\n\t\t\t\tlocalBlobRecord.state === \"localOnly\" || localBlobRecord.state === \"uploading\"\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tstate: \"localOnly\",\n\t\t\t\t\t\t\tblob: bufferToString(localBlobRecord.blob, \"base64\"),\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\t...localBlobRecord,\n\t\t\t\t\t\t\tstate: \"uploaded\",\n\t\t\t\t\t\t\tblob: bufferToString(localBlobRecord.blob, \"base64\"),\n\t\t\t\t\t\t};\n\t\t}\n\t\treturn Object.keys(pendingBlobs).length > 0 ? pendingBlobs : undefined;\n\t}\n}\n\n/**\n * For a localId, returns its path in GC's graph. The node path is of the format `/<blobManagerBasePath>/<localId>`.\n * This path must match the path of the blob handle returned by the createBlob API because blobs are marked\n * referenced by storing these handles in a referenced DDS.\n */\nexport const getGCNodePathFromLocalId = (localId: string): string =>\n\t`/${blobManagerBasePath}/${localId}`;\n\n/**\n * For a given GC node path, return the localId. The node path is of the format `/<basePath>/<localId>`.\n */\nconst getLocalIdFromGCNodePath = (nodePath: string): string => {\n\tconst pathParts = nodePath.split(\"/\");\n\tassert(areBlobPathParts(pathParts), 0x5bd /* Invalid blob node path */);\n\treturn pathParts[2];\n};\n\n/**\n * Returns whether a given path is for attachment blobs that are in the format - \"/blobManagerBasePath/...\".\n */\nexport const isBlobPath = (path: string): path is `/${typeof blobManagerBasePath}/${string}` =>\n\tareBlobPathParts(path.split(\"/\"));\n\nconst areBlobPathParts = (\n\tpathParts: string[],\n): pathParts is [\"\", typeof blobManagerBasePath, string] =>\n\tpathParts.length === 3 && pathParts[1] === blobManagerBasePath;\n"]}
|
|
1
|
+
{"version":3,"file":"blobManager.js","sourceRoot":"","sources":["../../src/blobManager/blobManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC7F,OAAO,EACN,WAAW,GAEX,MAAM,gDAAgD,CAAC;AAexD,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAQ7D,OAAO,EACN,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,GACnB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACN,YAAY,EAEZ,gBAAgB,EAChB,4BAA4B,GAC5B,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EACN,yBAAyB,EACzB,eAAe,GAEf,MAAM,yBAAyB,CAAC;AAEjC;;;;;;GAMG;AACH,MAAM,OAAO,UACZ,SAAQ,eAAgC;IAOxC,IAAW,UAAU;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,IAAI,IAAI,CAAC,QAAQ,CAAC;IACtD,CAAC;IAKD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AAK,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,4BAA4B,CAAC,CAAC;IACxE,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC;AACrB,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAsD,EAAE,CAC9F,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAEnC,MAAM,gBAAgB,GAAG,CACxB,SAAmB,EACqC,EAAE,CAC1D,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,mBAAmB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString, createEmitter, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport {\n\tAttachState,\n\ttype IContainerStorageService,\n} from \"@fluidframework/container-definitions/internal\";\nimport type {\n\tIContainerRuntime,\n\tIContainerRuntimeEvents,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport type {\n\tIEmitter,\n\tIEventProvider,\n\tIFluidHandleContext,\n\tIFluidHandleInternalPayloadPending,\n\tILocalFluidHandle,\n\tILocalFluidHandleEvents,\n\tListenable,\n\tPayloadState,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { ICreateBlobResponse } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tIGarbageCollectionData,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\tISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tFluidHandleBase,\n\tcreateResponseError,\n\tgenerateHandleContextPath,\n\tresponseToException,\n} from \"@fluidframework/runtime-utils/internal\";\nimport {\n\tLoggingError,\n\ttype MonitoringContext,\n\tPerformanceEvent,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { isBlobMetadata } from \"../metadata.js\";\n\nimport {\n\tsummarizeBlobManagerState,\n\ttoRedirectTable,\n\ttype IBlobManagerLoadInfo,\n} from \"./blobManagerSnapSum.js\";\n\n/**\n * This class represents blob (long string)\n * This object is used only when creating (writing) new blob and serialization purposes.\n * De-serialization process goes through FluidObjectHandle and request flow:\n * DataObject.request() recognizes requests in the form of `/blobs/<id>`\n * and loads blob.\n */\nexport class BlobHandle\n\textends FluidHandleBase<ArrayBufferLike>\n\timplements\n\t\tILocalFluidHandle<ArrayBufferLike>,\n\t\tIFluidHandleInternalPayloadPending<ArrayBufferLike>\n{\n\tprivate attached: boolean = false;\n\n\tpublic get isAttached(): boolean {\n\t\treturn this.routeContext.isAttached && this.attached;\n\t}\n\n\tprivate _events:\n\t\t| (Listenable<ILocalFluidHandleEvents> & IEmitter<ILocalFluidHandleEvents>)\n\t\t| undefined;\n\tpublic get events(): Listenable<ILocalFluidHandleEvents> {\n\t\treturn (this._events ??= createEmitter<ILocalFluidHandleEvents>());\n\t}\n\n\tprivate _payloadState: PayloadState;\n\tpublic get payloadState(): PayloadState {\n\t\treturn this._payloadState;\n\t}\n\n\t/**\n\t * The error property starts undefined, signalling that there has been no error yet.\n\t * If an error occurs, the property will contain the error.\n\t */\n\tprivate _payloadShareError: unknown;\n\tpublic get payloadShareError(): unknown {\n\t\treturn this._payloadShareError;\n\t}\n\n\tpublic readonly absolutePath: string;\n\n\tpublic constructor(\n\t\tpublic readonly path: string,\n\t\tpublic readonly routeContext: IFluidHandleContext,\n\t\t// TODO: just take the blob rather than a get function?\n\t\tpublic get: () => Promise<ArrayBufferLike>,\n\t\tpublic readonly payloadPending: boolean,\n\t\tprivate readonly onAttachGraph?: () => void,\n\t) {\n\t\tsuper();\n\t\tthis._payloadState = payloadPending ? \"pending\" : \"shared\";\n\t\tthis.absolutePath = generateHandleContextPath(path, this.routeContext);\n\t}\n\n\tpublic readonly notifyShared = (): void => {\n\t\tthis._payloadState = \"shared\";\n\t\tthis._events?.emit(\"payloadShared\");\n\t};\n\n\tpublic readonly notifyFailed = (error: unknown): void => {\n\t\tthis._payloadShareError = error;\n\t\tthis._events?.emit(\"payloadShareFailed\", error);\n\t};\n\n\tpublic attachGraph(): void {\n\t\tif (!this.attached) {\n\t\t\tthis.attached = true;\n\t\t\tthis.onAttachGraph?.();\n\t\t}\n\t}\n}\n\n// Restrict the IContainerRuntime interface to the subset required by BlobManager. This helps to make\n// the contract explicit and reduces the amount of mocking required for tests.\nexport type IBlobManagerRuntime = Pick<\n\tIContainerRuntime,\n\t\"attachState\" | \"baseLogger\" | \"disposed\"\n> &\n\tIEventProvider<IContainerRuntimeEvents>;\n\nexport type ICreateBlobResponseWithTTL = ICreateBlobResponse &\n\tPartial<Record<\"minTTLInSeconds\", number>>;\n\n/**\n * A blob tracked by BlobManager that is only available on the local client. It is not currently\n * attempting an upload.\n */\ninterface LocalOnlyBlob {\n\tstate: \"localOnly\";\n\tblob: ArrayBufferLike;\n}\n\n/**\n * A blob tracked by BlobManager that is only known to be available on the local client, but is in\n * the process of being uploaded to storage.\n */\ninterface UploadingBlob {\n\tstate: \"uploading\";\n\tblob: ArrayBufferLike;\n}\n\n/**\n * A blob tracked by BlobManager that has been uploaded to storage. If the TTL has not expired, it\n * should still be available in storage. It is not currently attempting to send a BlobAttach op.\n */\ninterface UploadedBlob {\n\tstate: \"uploaded\";\n\tblob: ArrayBufferLike;\n\tstorageId: string;\n\tuploadTime: number;\n\tminTTLInSeconds: number | undefined;\n}\n\n/**\n * A blob tracked by BlobManager that has been uploaded to storage and is in the process of sending\n * a BlobAttach message and waiting for the ack.\n */\ninterface AttachingBlob {\n\tstate: \"attaching\";\n\tblob: ArrayBufferLike;\n\tstorageId: string;\n\tuploadTime: number;\n\tminTTLInSeconds: number | undefined;\n}\n\n/**\n * A blob tracked by BlobManager that has been uploaded to storage and its BlobAttach message has been\n * ack'd. It is fully shared and available to all clients, and is no longer considered pending.\n */\ninterface AttachedBlob {\n\tstate: \"attached\";\n\tblob: ArrayBufferLike;\n}\n\n/**\n * Blobs that were created locally are tracked, and may be in one of these states. When first\n * created, they are in localOnly state. The process of sharing has two steps, blob upload and\n * sending a BlobAttach op. Progress through the stages may regress back to localOnly if we\n * determine the storage may have deleted the blob before we could finish attaching it.\n */\ntype LocalBlobRecord =\n\t| LocalOnlyBlob\n\t| UploadingBlob\n\t| UploadedBlob\n\t| AttachingBlob\n\t| AttachedBlob;\n\n/**\n * Serializable form of the LocalBlobRecord that can be used to save and restore pending state.\n * Omits attached blobs since they are fully uploaded and don't need to be saved and restored.\n * Omits uploading and attaching states since upon restore we will need to restart those processes.\n */\nexport type SerializableLocalBlobRecord =\n\t| (Omit<LocalOnlyBlob, \"blob\"> & { blob: string })\n\t| (Omit<UploadedBlob, \"blob\"> & { blob: string });\n\nexport interface IPendingBlobs {\n\t[localId: string]: SerializableLocalBlobRecord;\n}\n\n/**\n * Check if for a given uploaded or attaching blob, the TTL is too close to expiry to safely attempt\n * an attach. Currently using a heuristic of half the TTL duration having passed since upload.\n */\nconst isTTLTooCloseToExpiry = (blobRecord: UploadedBlob | AttachingBlob): boolean =>\n\tblobRecord.minTTLInSeconds !== undefined &&\n\tDate.now() - blobRecord.uploadTime > (blobRecord.minTTLInSeconds / 2) * 1000;\n\ninterface IBlobManagerInternalEvents {\n\tblobExpired: (localId: string) => void;\n\thandleAttached: (pending: LocalBlobRecord) => void;\n\tprocessedBlobAttach: (localId: string, storageId: string) => void;\n}\n\nconst createAbortError = (): LoggingError => new LoggingError(\"uploadBlob aborted\");\n\nexport const blobManagerBasePath = \"_blobs\";\n\nexport class BlobManager {\n\tprivate readonly mc: MonitoringContext;\n\n\tprivate readonly internalEvents = createEmitter<IBlobManagerInternalEvents>();\n\n\t/**\n\t * Map of local IDs to storage IDs. Also includes identity mappings of storage ID to storage ID for all known\n\t * storage IDs. All requested IDs must be a key in this map. Blobs created while the container is detached are\n\t * stored in IDetachedBlobStorage which gives pseudo storage IDs; the real storage IDs are filled in at attach\n\t * time via setRedirectTable().\n\t */\n\tprivate readonly redirectTable: Map<string, string>;\n\n\t/**\n\t * The localBlobCache has a dual role of caching locally-created blobs, as well as tracking their state as they\n\t * are shared. Keys are localIds.\n\t */\n\tprivate readonly localBlobCache: Map<string, LocalBlobRecord> = new Map();\n\t/**\n\t * Blobs with an attached handle that have not finished blob-attaching are the set we need to provide from\n\t * getPendingState(). This stores their local IDs, and then we can look them up against the localBlobCache.\n\t */\n\tprivate readonly pendingBlobsWithAttachedHandles: Set<string> = new Set();\n\t/**\n\t * Local IDs for any pending blobs we loaded with and have not yet started the upload/attach flow for.\n\t */\n\tprivate readonly pendingOnlyLocalIds: Set<string> = new Set();\n\n\tprivate readonly sendBlobAttachMessage: (localId: string, storageId: string) => void;\n\n\tprivate readonly routeContext: IFluidHandleContext;\n\tprivate readonly storage: Pick<IContainerStorageService, \"createBlob\" | \"readBlob\">;\n\t// Called when a blob node is requested. blobPath is the path of the blob's node in GC's graph.\n\t// blobPath's format - `/<basePath>/<localId>`.\n\tprivate readonly blobRequested: (blobPath: string) => void;\n\t// Called to check if a blob has been deleted by GC.\n\t// blobPath's format - `/<basePath>/<localId>`.\n\tprivate readonly isBlobDeleted: (blobPath: string) => boolean;\n\tprivate readonly runtime: IBlobManagerRuntime;\n\tprivate readonly localIdGenerator: () => string;\n\n\tprivate readonly createBlobPayloadPending: boolean;\n\n\tpublic constructor(props: {\n\t\treadonly routeContext: IFluidHandleContext;\n\n\t\tblobManagerLoadInfo: IBlobManagerLoadInfo;\n\t\treadonly storage: Pick<IContainerStorageService, \"createBlob\" | \"readBlob\">;\n\t\t/**\n\t\t * Submit a BlobAttach message. When a blob is uploaded, there is a short grace period before which the blob is\n\t\t * deleted. The BlobAttach message notifies the server that blob is in use. The server will then not delete the\n\t\t * the blob as long as it is listed as referenced in future summaries. The summarizing client will know to\n\t\t * include the storage ID in the summary when it sees the message.\n\t\t *\n\t\t * The message will also include a local ID to inform all clients of the relation to the storage ID, without\n\t\t * knowledge of which they cannot request the blob from storage. It's important that this message is sequenced\n\t\t * before any messages that reference the local ID, otherwise, an invalid handle could be added to the document.\n\t\t */\n\t\tsendBlobAttachMessage: (localId: string, storageId: string) => void;\n\t\t// Called when a blob node is requested. blobPath is the path of the blob's node in GC's graph.\n\t\t// blobPath's format - `/<basePath>/<localId>`.\n\t\treadonly blobRequested: (blobPath: string) => void;\n\t\t// Called to check if a blob has been deleted by GC.\n\t\t// blobPath's format - `/<basePath>/<localId>`.\n\t\treadonly isBlobDeleted: (blobPath: string) => boolean;\n\t\treadonly runtime: IBlobManagerRuntime;\n\t\tpendingBlobs: IPendingBlobs | undefined;\n\t\treadonly localIdGenerator?: (() => string) | undefined;\n\t\treadonly createBlobPayloadPending: boolean;\n\t}) {\n\t\tconst {\n\t\t\trouteContext,\n\t\t\tblobManagerLoadInfo,\n\t\t\tstorage,\n\t\t\tsendBlobAttachMessage,\n\t\t\tblobRequested,\n\t\t\tisBlobDeleted,\n\t\t\truntime,\n\t\t\tpendingBlobs,\n\t\t\tlocalIdGenerator,\n\t\t\tcreateBlobPayloadPending,\n\t\t} = props;\n\t\tthis.routeContext = routeContext;\n\t\tthis.storage = storage;\n\t\tthis.sendBlobAttachMessage = sendBlobAttachMessage;\n\t\tthis.blobRequested = blobRequested;\n\t\tthis.isBlobDeleted = isBlobDeleted;\n\t\tthis.runtime = runtime;\n\t\tthis.localIdGenerator = localIdGenerator ?? uuid;\n\t\tthis.createBlobPayloadPending = createBlobPayloadPending;\n\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger: this.runtime.baseLogger,\n\t\t\tnamespace: \"BlobManager\",\n\t\t});\n\n\t\tthis.redirectTable = toRedirectTable(blobManagerLoadInfo, this.mc.logger);\n\n\t\t// We populate the localBlobCache with any pending blobs we are provided, which makes them available\n\t\t// to access even though they are not shared yet. However, we don't start the share flow until it is\n\t\t// explicitly invoked via sharePendingBlobs() in case we are loaded in a frozen container.\n\t\tif (pendingBlobs !== undefined) {\n\t\t\tfor (const [localId, serializableBlobRecord] of Object.entries(pendingBlobs)) {\n\t\t\t\tassert(\n\t\t\t\t\t!this.redirectTable.has(localId),\n\t\t\t\t\t0xc7e /* Pending blob already in redirect table */,\n\t\t\t\t);\n\t\t\t\tconst localBlobRecord = {\n\t\t\t\t\t...serializableBlobRecord,\n\t\t\t\t\tblob: stringToBuffer(serializableBlobRecord.blob, \"base64\"),\n\t\t\t\t};\n\t\t\t\tthis.localBlobCache.set(localId, localBlobRecord);\n\t\t\t\t// Since we received these blobs from pending state, we'll assume they were only added to the\n\t\t\t\t// pending state at generation time because their handles were attached. We add them back here\n\t\t\t\t// in case we need to round-trip them back out again due to another getPendingBlobs() call.\n\t\t\t\tthis.pendingBlobsWithAttachedHandles.add(localId);\n\t\t\t\tthis.pendingOnlyLocalIds.add(localId);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns whether a blob with the given localId can be retrieved by the BlobManager via getBlob().\n\t */\n\tpublic hasBlob(localId: string): boolean {\n\t\treturn this.redirectTable.has(localId) || this.localBlobCache.has(localId);\n\t}\n\n\t/**\n\t * Lookup the blob storage ID for a given local blob id.\n\t * @param localId - The local blob id. Likely coming from a handle.\n\t * @returns The storage ID if found and the blob is not pending, undefined otherwise.\n\t * @remarks\n\t * For blobs with pending payloads (localId exists but upload hasn't finished), this is expected to return undefined.\n\t * Consumers should use the observability APIs on the handle (handle.payloadState, payloadShared event)\n\t * to understand/wait for storage ID availability.\n\t * Similarly, when the runtime is detached, this will return undefined as no blobs have been uploaded to storage.\n\t */\n\tpublic lookupTemporaryBlobStorageId(localId: string): string | undefined {\n\t\tif (this.runtime.attachState === AttachState.Detached) {\n\t\t\treturn undefined;\n\t\t}\n\t\t// Get the storage ID from the redirect table\n\t\treturn this.redirectTable.get(localId);\n\t}\n\n\t/**\n\t * Retrieve the blob with the given local blob id.\n\t * @param localId - The local blob id. Likely coming from a handle.\n\t * @param payloadPending - Whether we suspect the payload may be pending and not available yet.\n\t * @returns A promise which resolves to the blob contents\n\t */\n\tpublic async getBlob(localId: string, payloadPending: boolean): Promise<ArrayBufferLike> {\n\t\t// Verify that the blob is not deleted, i.e., it has not been garbage collected. If it is, this will throw\n\t\t// an error, failing the call.\n\t\tthis.verifyBlobNotDeleted(localId);\n\t\t// Let runtime know that the corresponding GC node was requested.\n\t\t// Note that this will throw if the blob is inactive or tombstoned and throwing on incorrect usage\n\t\t// is configured.\n\t\tthis.blobRequested(getGCNodePathFromLocalId(localId));\n\n\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\tif (localBlobRecord !== undefined) {\n\t\t\treturn localBlobRecord.blob;\n\t\t}\n\n\t\tlet storageId = this.redirectTable.get(localId);\n\t\tif (storageId === undefined) {\n\t\t\t// Only blob handles explicitly marked with pending payload are permitted to exist without\n\t\t\t// yet knowing their storage id. Otherwise they must already be associated with a storage id.\n\t\t\t// Handles for detached blobs are not payload pending, though they should also always be present\n\t\t\t// in the localBlobCache and therefore should never need to refer to storage.\n\t\t\tassert(payloadPending, 0x11f /* \"requesting unknown blobs\" */);\n\t\t\t// If we didn't find it in the redirectTable and it's payloadPending, assume the attach message is coming\n\t\t\t// eventually and wait. We do this even if the local client doesn't have the blob payloadPending flag\n\t\t\t// enabled, in case a remote client does have it enabled. This wait may be infinite if the uploading\n\t\t\t// client failed the upload and doesn't exist anymore.\n\t\t\t// TODO: Fix this violation and remove the disable\n\t\t\t// eslint-disable-next-line require-atomic-updates\n\t\t\tstorageId = await new Promise<string>((resolve) => {\n\t\t\t\tconst onProcessBlobAttach = (_localId: string, _storageId: string): void => {\n\t\t\t\t\tif (_localId === localId) {\n\t\t\t\t\t\tthis.internalEvents.off(\"processedBlobAttach\", onProcessBlobAttach);\n\t\t\t\t\t\tresolve(_storageId);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tthis.internalEvents.on(\"processedBlobAttach\", onProcessBlobAttach);\n\t\t\t});\n\t\t}\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.mc.logger,\n\t\t\t{ eventName: \"AttachmentReadBlob\", id: storageId },\n\t\t\tasync (event) => {\n\t\t\t\treturn this.storage.readBlob(storageId).catch((error) => {\n\t\t\t\t\tif (this.runtime.disposed) {\n\t\t\t\t\t\t// If the runtime is disposed, this is not an error we care to track, it's expected behavior.\n\t\t\t\t\t\tevent.cancel({ category: \"generic\" });\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t\t},\n\t\t\t{ end: true, cancel: \"error\" },\n\t\t);\n\t}\n\n\tprivate getNonPayloadPendingBlobHandle(localId: string): BlobHandle {\n\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\tassert(localBlobRecord !== undefined, 0x384 /* requesting handle for unknown blob */);\n\t\tassert(localBlobRecord.state === \"attached\", 0xc7f /* Expected blob to be attached */);\n\n\t\treturn new BlobHandle(\n\t\t\tgetGCNodePathFromLocalId(localId),\n\t\t\tthis.routeContext,\n\t\t\tasync () => this.getBlob(localId, false),\n\t\t\tfalse, // payloadPending\n\t\t);\n\t}\n\n\tpublic async createBlob(\n\t\tblob: ArrayBufferLike,\n\t\tsignal?: AbortSignal,\n\t): Promise<IFluidHandleInternalPayloadPending<ArrayBufferLike>> {\n\t\tif (this.runtime.attachState === AttachState.Detached) {\n\t\t\treturn this.createBlobDetached(blob, signal);\n\t\t}\n\t\tif (this.runtime.attachState === AttachState.Attaching) {\n\t\t\t// blob upload is not supported in \"Attaching\" state\n\t\t\tthis.mc.logger.sendTelemetryEvent({ eventName: \"CreateBlobWhileAttaching\" });\n\t\t\tawait new Promise<void>((resolve) => this.runtime.once(\"attached\", resolve));\n\t\t}\n\t\tassert(\n\t\t\tthis.runtime.attachState === AttachState.Attached,\n\t\t\t0x385 /* For clarity and paranoid defense against adding future attachment states */,\n\t\t);\n\n\t\treturn this.createBlobPayloadPending\n\t\t\t? this.createBlobWithPayloadPending(blob, signal)\n\t\t\t: this.createBlobLegacy(blob, signal);\n\t}\n\n\tprivate async createBlobDetached(\n\t\tblob: ArrayBufferLike,\n\t\tsignal?: AbortSignal,\n\t): Promise<IFluidHandleInternalPayloadPending<ArrayBufferLike>> {\n\t\tif (signal?.aborted === true) {\n\t\t\tthrow createAbortError();\n\t\t}\n\t\tconst localId = this.localIdGenerator();\n\t\tthis.localBlobCache.set(localId, { state: \"uploading\", blob });\n\t\t// Blobs created while the container is detached are stored in IDetachedBlobStorage.\n\t\t// The 'IContainerStorageService.createBlob()' call below will respond with a pseudo storage ID.\n\t\t// That pseudo storage ID will be replaced with the real storage ID at attach time.\n\t\tconst { id: detachedStorageId } = await this.storage.createBlob(blob);\n\t\t// From the perspective of the BlobManager, the blob is now fully attached. The actual\n\t\t// upload/attach process at container attach time is treated as opaque to this tracking.\n\t\tthis.localBlobCache.set(localId, { state: \"attached\", blob });\n\t\tthis.redirectTable.set(localId, detachedStorageId);\n\t\treturn this.getNonPayloadPendingBlobHandle(localId);\n\t}\n\n\tprivate async createBlobLegacy(\n\t\tblob: ArrayBufferLike,\n\t\tsignal?: AbortSignal,\n\t): Promise<IFluidHandleInternalPayloadPending<ArrayBufferLike>> {\n\t\tconst localId = this.localIdGenerator();\n\t\tthis.localBlobCache.set(localId, { state: \"localOnly\", blob });\n\t\tawait this.uploadAndAttach(localId, signal);\n\t\treturn this.getNonPayloadPendingBlobHandle(localId);\n\t}\n\n\tprivate createBlobWithPayloadPending(\n\t\tblob: ArrayBufferLike,\n\t\tsignal?: AbortSignal,\n\t): IFluidHandleInternalPayloadPending<ArrayBufferLike> {\n\t\tconst localId = this.localIdGenerator();\n\t\tthis.localBlobCache.set(localId, { state: \"localOnly\", blob });\n\n\t\tconst blobHandle = new BlobHandle(\n\t\t\tgetGCNodePathFromLocalId(localId),\n\t\t\tthis.routeContext,\n\t\t\tasync () => blob,\n\t\t\ttrue, // payloadPending\n\t\t\t() => {\n\t\t\t\tthis.pendingBlobsWithAttachedHandles.add(localId);\n\t\t\t\tconst uploadAndAttachP = this.uploadAndAttach(localId, signal);\n\t\t\t\tuploadAndAttachP.then(blobHandle.notifyShared).catch((error) => {\n\t\t\t\t\t// TODO: notifyShared won't fail directly, but it emits an event to the customer.\n\t\t\t\t\t// Consider what to do if the customer's code throws. reportError is nice.\n\t\t\t\t});\n\t\t\t\tuploadAndAttachP.catch(blobHandle.notifyFailed);\n\t\t\t},\n\t\t);\n\n\t\treturn blobHandle;\n\t}\n\n\t/**\n\t * Upload and attach the localBlobCache entry for the given localId.\n\t *\n\t * Expects the localBlobCache entry for the given localId to be in either localOnly or uploaded state\n\t * when called. Returns a promise that resolves when the blob completes uploading and attaching, or else\n\t * rejects if an error is encountered or the signal is aborted.\n\t */\n\tprivate readonly uploadAndAttach = async (\n\t\tlocalId: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<void> => {\n\t\tif (signal?.aborted === true) {\n\t\t\tthis.localBlobCache.delete(localId);\n\t\t\tthis.pendingBlobsWithAttachedHandles.delete(localId);\n\t\t\tthrow createAbortError();\n\t\t}\n\t\tconst localBlobRecordInitial = this.localBlobCache.get(localId);\n\t\tassert(\n\t\t\tlocalBlobRecordInitial?.state === \"localOnly\" ||\n\t\t\t\tlocalBlobRecordInitial?.state === \"uploaded\",\n\t\t\t0xc80 /* Expect uploadAndAttach to be called with either localOnly or uploaded state */,\n\t\t);\n\t\tconst { blob } = localBlobRecordInitial;\n\n\t\t/**\n\t\t * Expects the localBlobCache entry for the given localId to be in either localOnly or uploaded state\n\t\t * when called. Returns a promise that resolves when the blob is in uploaded or attached state, or else\n\t\t * rejects on error during upload or if the signal is aborted.\n\t\t *\n\t\t * Most of the time this should be expected to exit in uploaded state, but if we are loading from pending\n\t\t * state we may see an attach message from the client that generated the pending state, which can complete the\n\t\t * attach while the upload is outstanding.\n\t\t */\n\t\tconst ensureUploaded = async (): Promise<void> => {\n\t\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\t\tif (localBlobRecord?.state === \"uploaded\") {\n\t\t\t\t// In normal creation flows, the blob will be in localOnly state here. But in the case of loading\n\t\t\t\t// with pending state we can call it with an uploaded-but-not-attached blob. Start the upload\n\t\t\t\t// flow only if it's localOnly.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tassert(\n\t\t\t\tlocalBlobRecord?.state === \"localOnly\",\n\t\t\t\t0xc81 /* Attempting to upload from unexpected state */,\n\t\t\t);\n\n\t\t\tthis.localBlobCache.set(localId, { state: \"uploading\", blob });\n\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\t// If we eventually have driver-level support for abort, then this can simplify a bit as we won't\n\t\t\t\t// need to track upload completion and abort separately. Until then, we need to handle the case that\n\t\t\t\t// the upload continues and settles after becoming irrelevant due to signal abort or blob attach.\n\t\t\t\tlet uploadHasBecomeIrrelevant = false;\n\t\t\t\tconst onSignalAbort = (): void => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tuploadHasBecomeIrrelevant = true;\n\t\t\t\t\tthis.localBlobCache.delete(localId);\n\t\t\t\t\tthis.pendingBlobsWithAttachedHandles.delete(localId);\n\t\t\t\t\treject(createAbortError());\n\t\t\t\t};\n\t\t\t\tconst onProcessedBlobAttach = (_localId: string, _storageId: string): void => {\n\t\t\t\t\tif (_localId === localId) {\n\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\tuploadHasBecomeIrrelevant = true;\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tconst removeListeners = (): void => {\n\t\t\t\t\tthis.internalEvents.off(\"processedBlobAttach\", onProcessedBlobAttach);\n\t\t\t\t\tsignal?.removeEventListener(\"abort\", onSignalAbort);\n\t\t\t\t};\n\t\t\t\tthis.internalEvents.on(\"processedBlobAttach\", onProcessedBlobAttach);\n\t\t\t\tsignal?.addEventListener(\"abort\", onSignalAbort);\n\n\t\t\t\tthis.storage\n\t\t\t\t\t.createBlob(blob)\n\t\t\t\t\t.then((createBlobResponse: ICreateBlobResponseWithTTL) => {\n\t\t\t\t\t\tif (!uploadHasBecomeIrrelevant) {\n\t\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\t\tthis.localBlobCache.set(localId, {\n\t\t\t\t\t\t\t\tstate: \"uploaded\",\n\t\t\t\t\t\t\t\tblob,\n\t\t\t\t\t\t\t\tstorageId: createBlobResponse.id,\n\t\t\t\t\t\t\t\tuploadTime: Date.now(),\n\t\t\t\t\t\t\t\tminTTLInSeconds: createBlobResponse.minTTLInSeconds,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t.catch((error) => {\n\t\t\t\t\t\tif (!uploadHasBecomeIrrelevant) {\n\t\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\t\t// If the storage call errors, we can't recover. Reject to throw back to the caller.\n\t\t\t\t\t\t\tthis.localBlobCache.delete(localId);\n\t\t\t\t\t\t\tthis.pendingBlobsWithAttachedHandles.delete(localId);\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n\t\t\t\t\t\t\treject(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t});\n\t\t};\n\n\t\t/**\n\t\t * Expects the localBlobCache entry for the given localId to be in uploaded or attached state when called.\n\t\t * Returns a promise that resolves to true if the blob is successfully attached, or false if it cannot be\n\t\t * attached and the upload flow needs to be restarted from the top (currently only if the TTL expires before\n\t\t * attach can be completed). In the latter case, the localBlobRecord will also be reset to localOnly state.\n\t\t * The promise rejects if the signal is aborted.\n\t\t */\n\t\tconst tryAttach = async (): Promise<boolean> => {\n\t\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\t\tif (localBlobRecord?.state === \"attached\") {\n\t\t\t\t// In normal creation flows, the blob will be in uploaded state here. But if we are loading from pending\n\t\t\t\t// state and see an attach message from the client that generated the pending state, we may have reached\n\t\t\t\t// attached state in the middle of the upload attempt. In that case there's no more work to do and we\n\t\t\t\t// can just return.\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tassert(\n\t\t\t\tlocalBlobRecord?.state === \"uploaded\",\n\t\t\t\t0xc82 /* Attempting to attach from unexpected state */,\n\t\t\t);\n\n\t\t\t// If we just uploaded the blob TTL really shouldn't be expired at this location. But if we loaded from\n\t\t\t// pending state, the upload may have happened some time far in the past and could be expired here.\n\t\t\tif (isTTLTooCloseToExpiry(localBlobRecord)) {\n\t\t\t\t// If the TTL is expired, we assume it's gone from the storage and so is effectively localOnly again.\n\t\t\t\t// Then when we re-enter the loop, we'll re-upload it.\n\t\t\t\tthis.localBlobCache.set(localId, { state: \"localOnly\", blob });\n\t\t\t\t// Emitting here isn't really necessary since the only listener would be attached below. Including here\n\t\t\t\t// for completeness though, in case we add other listeners in the future.\n\t\t\t\tthis.internalEvents.emit(\"blobExpired\", localId);\n\t\t\t\treturn false;\n\t\t\t} else {\n\t\t\t\tthis.localBlobCache.set(localId, {\n\t\t\t\t\t...localBlobRecord,\n\t\t\t\t\tstate: \"attaching\",\n\t\t\t\t});\n\n\t\t\t\t// Send and await a blob attach op. This serves two purposes:\n\t\t\t\t// 1. If its a new blob, i.e., it isn't de-duped, the server will keep the blob alive if it sees this op\n\t\t\t\t// until its storage ID is added to the next summary.\n\t\t\t\t// 2. It will create a local ID to storage ID mapping in all clients which is needed to retrieve the\n\t\t\t\t// blob from the server via the storage ID.\n\t\t\t\treturn new Promise<boolean>((resolve, reject) => {\n\t\t\t\t\tconst onProcessedBlobAttach = (_localId: string, _storageId: string): void => {\n\t\t\t\t\t\tif (_localId === localId) {\n\t\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\t// Although we already checked for TTL expiry above, the message we're about to send may later be asked\n\t\t\t\t\t// to resubmit. Before we resubmit, we check again for TTL expiry - this listener is how we learn if\n\t\t\t\t\t// we discovered expiry in the resubmit flow.\n\t\t\t\t\tconst onBlobExpired = (_localId: string): void => {\n\t\t\t\t\t\tif (_localId === localId) {\n\t\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\t\tresolve(false);\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\tconst onSignalAbort = (): void => {\n\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\tthis.localBlobCache.delete(localId);\n\t\t\t\t\t\tthis.pendingBlobsWithAttachedHandles.delete(localId);\n\t\t\t\t\t\treject(createAbortError());\n\t\t\t\t\t};\n\t\t\t\t\tconst removeListeners = (): void => {\n\t\t\t\t\t\tthis.internalEvents.off(\"processedBlobAttach\", onProcessedBlobAttach);\n\t\t\t\t\t\tthis.internalEvents.off(\"blobExpired\", onBlobExpired);\n\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onSignalAbort);\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.internalEvents.on(\"processedBlobAttach\", onProcessedBlobAttach);\n\t\t\t\t\tthis.internalEvents.on(\"blobExpired\", onBlobExpired);\n\t\t\t\t\tsignal?.addEventListener(\"abort\", onSignalAbort);\n\t\t\t\t\tthis.sendBlobAttachMessage(localId, localBlobRecord.storageId);\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\n\t\tlet attachCompleted = false;\n\t\twhile (!attachCompleted) {\n\t\t\tawait ensureUploaded();\n\t\t\tattachCompleted = await tryAttach();\n\n\t\t\t// If something stopped the attach from completing successfully (currently just TTL expiry),\n\t\t\t// we expect that the blob was already updated to reflect the updated state (i.e. back to localOnly)\n\t\t\t// and we'll try the loop again from the top.\n\t\t}\n\t\t// When the blob successfully attaches, the localBlobRecord will have been updated to attached state\n\t\t// at the time we processed the op, so there's nothing else to do here.\n\t};\n\n\t/**\n\t * Resubmit a BlobAttach op. Used to add storage IDs to messages that were\n\t * submitted to runtime while disconnected.\n\t * @param metadata - message metadata containing storage and/or local IDs\n\t */\n\tpublic reSubmit(metadata: Record<string, unknown> | undefined): void {\n\t\tassert(isBlobMetadata(metadata), 0xc01 /* Expected blob metadata for a BlobAttach op */);\n\t\tconst { localId, blobId: storageId } = metadata;\n\t\t// Any blob that we're actively trying to advance to attached state must be in attaching state.\n\t\t// Decline to resubmit for anything else.\n\t\t// For example, we might be asked to resubmit stashed messages for blobs that never had their handle\n\t\t// attached - these won't have a localBlobCache entry because we filter them out when generating\n\t\t// pending state. We shouldn't try to attach them since they won't be accessible to the customer\n\t\t// and would just be considered garbage immediately.\n\t\t// TODO: Is it possible that we'd be asked to resubmit for a pending blob before we call sharePendingBlobs?\n\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\tif (localBlobRecord?.state === \"attaching\") {\n\t\t\t// If the TTL is expired, we assume it's gone from the storage and so is effectively localOnly again.\n\t\t\tif (isTTLTooCloseToExpiry(localBlobRecord)) {\n\t\t\t\tthis.localBlobCache.set(localId, { state: \"localOnly\", blob: localBlobRecord.blob });\n\t\t\t\tthis.internalEvents.emit(\"blobExpired\", localId);\n\t\t\t} else {\n\t\t\t\tthis.sendBlobAttachMessage(localId, storageId);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic processBlobAttachMessage(message: ISequencedMessageEnvelope, local: boolean): void {\n\t\tassert(\n\t\t\tisBlobMetadata(message.metadata),\n\t\t\t0xc02 /* Expected blob metadata for a BlobAttach op */,\n\t\t);\n\t\tconst { localId, blobId: storageId } = message.metadata;\n\t\tconst maybeLocalBlobRecord = this.localBlobCache.get(localId);\n\t\tif (maybeLocalBlobRecord !== undefined) {\n\t\t\tconst attachedBlobRecord: AttachedBlob = {\n\t\t\t\tstate: \"attached\",\n\t\t\t\tblob: maybeLocalBlobRecord.blob,\n\t\t\t};\n\t\t\t// Processing a blob attach message is authoritative and may stomp on any existing state. Other\n\t\t\t// callsites that update localBlobCache entries must take proper caution to handle the case\n\t\t\t// that a blob attach message is processed concurrently.\n\t\t\tthis.localBlobCache.set(localId, attachedBlobRecord);\n\t\t\t// Note there may or may not be an entry in pendingBlobsWithAttachedHandles for this localId,\n\t\t\t// in particular for the non-payloadPending case since we should be reaching this point\n\t\t\t// before even returning a handle to the caller.\n\t\t\tthis.pendingBlobsWithAttachedHandles.delete(localId);\n\t\t\tthis.pendingOnlyLocalIds.delete(localId);\n\t\t}\n\t\tthis.redirectTable.set(localId, storageId);\n\t\t// set identity (id -> id) entry\n\t\tthis.redirectTable.set(storageId, storageId);\n\t\tthis.internalEvents.emit(\"processedBlobAttach\", localId, storageId);\n\t}\n\n\tpublic summarize(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats {\n\t\treturn summarizeBlobManagerState(this.redirectTable);\n\t}\n\n\t/**\n\t * Generates data used for garbage collection. Each blob uploaded represents a node in the GC graph as it can be\n\t * individually referenced by storing its handle in a referenced DDS. Returns the list of blob ids as GC nodes.\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data. BlobManager doesn't care\n\t * about this for now because the data is a simple list of blob ids.\n\t */\n\tpublic getGCData(fullGC: boolean = false): IGarbageCollectionData {\n\t\tconst gcData: IGarbageCollectionData = { gcNodes: {} };\n\t\tfor (const [localId, storageId] of this.redirectTable) {\n\t\t\t// Don't report the identity mappings to GC - these exist to service old handles that referenced the storage\n\t\t\t// IDs directly. We'll implicitly clean them up if all of their localId references get GC'd first.\n\t\t\tif (localId !== storageId) {\n\t\t\t\t// The outbound routes are empty because a blob node cannot reference other nodes. It can only be referenced\n\t\t\t\t// by adding its handle to a referenced DDS.\n\t\t\t\tgcData.gcNodes[getGCNodePathFromLocalId(localId)] = [];\n\t\t\t}\n\t\t}\n\t\treturn gcData;\n\t}\n\n\t/**\n\t * Delete blobs with the given routes from the redirect table.\n\t * @returns The routes of blobs that were deleted.\n\t *\n\t * @remarks\n\t * The routes are GC nodes paths of format -`/<blobManagerBasePath>/<localId>`.\n\t * Deleting the blobs involves 2 steps:\n\t *\n\t * 1. The redirect table entry for the local ids are deleted.\n\t *\n\t * 2. If the storage ids corresponding to the deleted local ids are not referenced by any further local ids, the\n\t * identity mappings in the redirect table are deleted as well.\n\t *\n\t * Note that this does not delete the blobs from storage service immediately. Deleting the blobs from redirect table\n\t * will ensure we don't create an attachment blob for them at the next summary. The service would then delete them\n\t * some time in the future.\n\t */\n\tpublic deleteSweepReadyNodes(sweepReadyBlobRoutes: readonly string[]): readonly string[] {\n\t\t// maybeUnusedStorageIds is used to compute the set of storage IDs that *used to have a local ID*, but that\n\t\t// local ID is being deleted.\n\t\tconst maybeUnusedStorageIds: Set<string> = new Set();\n\t\tfor (const route of sweepReadyBlobRoutes) {\n\t\t\tconst localId = getLocalIdFromGCNodePath(route);\n\t\t\t// If the blob hasn't already been deleted, log an error because this should never happen.\n\t\t\t// If the blob has already been deleted, log a telemetry event. This can happen because multiple GC\n\t\t\t// sweep messages can contain the same data store. It would be interesting to track how often this happens.\n\t\t\tconst alreadyDeleted = this.isBlobDeleted(route);\n\t\t\tconst storageId = this.redirectTable.get(localId);\n\t\t\tif (storageId === undefined) {\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"DeletedAttachmentBlobNotFound\",\n\t\t\t\t\tcategory: alreadyDeleted ? \"generic\" : \"error\",\n\t\t\t\t\tblobId: localId,\n\t\t\t\t\tdetails: { alreadyDeleted },\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tmaybeUnusedStorageIds.add(storageId);\n\t\t\tthis.redirectTable.delete(localId);\n\t\t}\n\n\t\t// Remove any storage IDs that still have local IDs referring to them (excluding the identity mapping).\n\t\tfor (const [localId, storageId] of this.redirectTable) {\n\t\t\tif (localId !== storageId) {\n\t\t\t\tmaybeUnusedStorageIds.delete(storageId);\n\t\t\t}\n\t\t}\n\n\t\t// Now delete any identity mappings (storage ID -> storage ID) from the redirect table that used to be\n\t\t// referenced by a distinct local ID. This way they'll be absent from the next summary, and the service\n\t\t// is free to delete them from storage.\n\t\t// WARNING: This can potentially delete identity mappings that are still referenced, if storage deduping\n\t\t// has let us add a local ID -> storage ID mapping that is later deleted. AB#47337 tracks this issue\n\t\t// and possible solutions.\n\t\tfor (const storageId of maybeUnusedStorageIds) {\n\t\t\tthis.redirectTable.delete(storageId);\n\t\t}\n\t\treturn [...sweepReadyBlobRoutes];\n\t}\n\n\t/**\n\t * Verifies that the blob with given id is not deleted, i.e., it has not been garbage collected. If the blob is GC'd,\n\t * log an error and throw if necessary.\n\t */\n\tprivate verifyBlobNotDeleted(localId: string): void {\n\t\tif (!this.isBlobDeleted(getGCNodePathFromLocalId(localId))) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst request = { url: localId };\n\t\tconst error = responseToException(\n\t\t\tcreateResponseError(404, `Blob was deleted`, request),\n\t\t\trequest,\n\t\t);\n\t\t// Only log deleted events. Tombstone events are logged by garbage collector.\n\t\tthis.mc.logger.sendErrorEvent(\n\t\t\t{\n\t\t\t\teventName: \"GC_Deleted_Blob_Requested\",\n\t\t\t\tpkg: blobManagerBasePath,\n\t\t\t},\n\t\t\terror,\n\t\t);\n\t\tthrow error;\n\t}\n\n\t/**\n\t * Called in detached state just prior to attaching, this will update the redirect table by\n\t * converting the pseudo storage IDs into real storage IDs using the provided detachedStorageTable.\n\t * The provided table must have exactly the same set of pseudo storage IDs as are found in the redirect table.\n\t * @param detachedStorageTable - A map of pseudo storage IDs to real storage IDs.\n\t */\n\tpublic readonly patchRedirectTable = (detachedStorageTable: Map<string, string>): void => {\n\t\tassert(\n\t\t\tthis.runtime.attachState === AttachState.Detached,\n\t\t\t0x252 /* \"redirect table can only be set in detached container\" */,\n\t\t);\n\t\t// The values of the redirect table are the pseudo storage IDs, which are the keys of the\n\t\t// detachedStorageTable. We expect to have a many:1 mapping from local IDs to pseudo\n\t\t// storage IDs (many in the case that the storage dedupes the blob).\n\t\tassert(\n\t\t\tnew Set(this.redirectTable.values()).size === detachedStorageTable.size,\n\t\t\t0x391 /* Redirect table size must match BlobManager's local ID count */,\n\t\t);\n\t\t// Taking a snapshot of the redirect table entries before iterating, because\n\t\t// we will be adding identity mappings to the the redirect table as we iterate\n\t\t// and we don't want to include those in the iteration.\n\t\tconst redirectTableEntries = [...this.redirectTable.entries()];\n\t\tfor (const [localId, detachedStorageId] of redirectTableEntries) {\n\t\t\tconst newStorageId = detachedStorageTable.get(detachedStorageId);\n\t\t\tassert(newStorageId !== undefined, 0xc53 /* Couldn't find a matching storage ID */);\n\t\t\tthis.redirectTable.set(localId, newStorageId);\n\t\t\t// set identity (id -> id) entry\n\t\t\tthis.redirectTable.set(newStorageId, newStorageId);\n\t\t}\n\t};\n\n\t/**\n\t * Upload and attach any pending blobs that the BlobManager was loaded with that have not already\n\t * been attached in the meantime.\n\t * @returns A promise that resolves when all the uploads and attaches have completed, or rejects\n\t * if any of them fail.\n\t */\n\tpublic readonly sharePendingBlobs = async (): Promise<void> => {\n\t\tconst localIdsToUpload = [...this.pendingOnlyLocalIds];\n\t\tthis.pendingOnlyLocalIds.clear();\n\t\tawait Promise.all<void>(\n\t\t\tlocalIdsToUpload.map(async (localId) => this.uploadAndAttach(localId)),\n\t\t);\n\t};\n\n\t/**\n\t * To be used in getPendingLocalState flow. Get a serializable record of the blobs that are\n\t * pending upload and/or their BlobAttach op, which can be given to a new BlobManager to\n\t * resume work.\n\t */\n\tpublic getPendingBlobs(): IPendingBlobs | undefined {\n\t\tconst pendingBlobs: IPendingBlobs = {};\n\t\tfor (const localId of this.pendingBlobsWithAttachedHandles) {\n\t\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\t\tassert(localBlobRecord !== undefined, 0xc83 /* Pending blob must be in local cache */);\n\t\t\tassert(\n\t\t\t\tlocalBlobRecord.state !== \"attached\",\n\t\t\t\t0xc84 /* Pending blob must not be in attached state */,\n\t\t\t);\n\t\t\t// We downgrade uploading blobs to localOnly, and attaching blobs to uploaded. In the case of\n\t\t\t// uploading blobs, we don't have a way to retrieve the eventual storageId so the upload will\n\t\t\t// need to be restarted anyway. In the case of attaching blobs, we can't know whether the\n\t\t\t// BlobAttach message will eventually be ack'd. So we assume we'll need to send another message, but also\n\t\t\t// remain prepared to handle seeing the ack of the original message after loading from pending state.\n\t\t\tpendingBlobs[localId] =\n\t\t\t\tlocalBlobRecord.state === \"localOnly\" || localBlobRecord.state === \"uploading\"\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tstate: \"localOnly\",\n\t\t\t\t\t\t\tblob: bufferToString(localBlobRecord.blob, \"base64\"),\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\t...localBlobRecord,\n\t\t\t\t\t\t\tstate: \"uploaded\",\n\t\t\t\t\t\t\tblob: bufferToString(localBlobRecord.blob, \"base64\"),\n\t\t\t\t\t\t};\n\t\t}\n\t\treturn Object.keys(pendingBlobs).length > 0 ? pendingBlobs : undefined;\n\t}\n}\n\n/**\n * For a localId, returns its path in GC's graph. The node path is of the format `/<blobManagerBasePath>/<localId>`.\n * This path must match the path of the blob handle returned by the createBlob API because blobs are marked\n * referenced by storing these handles in a referenced DDS.\n */\nexport const getGCNodePathFromLocalId = (localId: string): string =>\n\t`/${blobManagerBasePath}/${localId}`;\n\n/**\n * For a given GC node path, return the localId. The node path is of the format `/<basePath>/<localId>`.\n */\nconst getLocalIdFromGCNodePath = (nodePath: string): string => {\n\tconst pathParts = nodePath.split(\"/\");\n\tassert(areBlobPathParts(pathParts), 0x5bd /* Invalid blob node path */);\n\treturn pathParts[2];\n};\n\n/**\n * Returns whether a given path is for attachment blobs that are in the format - \"/blobManagerBasePath/...\".\n */\nexport const isBlobPath = (path: string): path is `/${typeof blobManagerBasePath}/${string}` =>\n\tareBlobPathParts(path.split(\"/\"));\n\nconst areBlobPathParts = (\n\tpathParts: string[],\n): pathParts is [\"\", typeof blobManagerBasePath, string] =>\n\tpathParts.length === 3 && pathParts[1] === blobManagerBasePath;\n"]}
|