@fluidframework/container-runtime 2.0.0-dev.1.4.6.106135 → 2.0.0-dev.2.2.0.111723
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/.eslintrc.js +1 -1
- package/dist/batchManager.d.ts +11 -6
- package/dist/batchManager.d.ts.map +1 -1
- package/dist/batchManager.js +23 -13
- package/dist/batchManager.js.map +1 -1
- package/dist/containerRuntime.d.ts +74 -20
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +190 -137
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStore.d.ts.map +1 -1
- package/dist/dataStore.js +6 -0
- package/dist/dataStore.js.map +1 -1
- package/dist/dataStoreContext.d.ts +14 -21
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js +71 -57
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/dataStoreContexts.js +1 -1
- package/dist/dataStoreContexts.js.map +1 -1
- package/dist/dataStores.d.ts +11 -10
- package/dist/dataStores.d.ts.map +1 -1
- package/dist/dataStores.js +50 -20
- package/dist/dataStores.js.map +1 -1
- package/dist/garbageCollection.d.ts +36 -19
- package/dist/garbageCollection.d.ts.map +1 -1
- package/dist/garbageCollection.js +207 -121
- package/dist/garbageCollection.js.map +1 -1
- package/dist/gcSweepReadyUsageDetection.d.ts.map +1 -1
- package/dist/gcSweepReadyUsageDetection.js +3 -12
- package/dist/gcSweepReadyUsageDetection.js.map +1 -1
- package/dist/index.d.ts +4 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -5
- package/dist/index.js.map +1 -1
- package/dist/opCompressor.d.ts +18 -0
- package/dist/opCompressor.d.ts.map +1 -0
- package/dist/opCompressor.js +50 -0
- package/dist/opCompressor.js.map +1 -0
- package/dist/opDecompressor.d.ts +20 -0
- package/dist/opDecompressor.d.ts.map +1 -0
- package/dist/opDecompressor.js +72 -0
- package/dist/opDecompressor.js.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/pendingStateManager.d.ts +6 -26
- package/dist/pendingStateManager.d.ts.map +1 -1
- package/dist/pendingStateManager.js +42 -62
- package/dist/pendingStateManager.js.map +1 -1
- package/dist/runningSummarizer.d.ts +3 -2
- package/dist/runningSummarizer.d.ts.map +1 -1
- package/dist/runningSummarizer.js +10 -3
- package/dist/runningSummarizer.js.map +1 -1
- package/dist/scheduleManager.js.map +1 -1
- package/dist/summarizer.js +7 -2
- package/dist/summarizer.js.map +1 -1
- package/dist/summarizerClientElection.js +1 -1
- package/dist/summarizerClientElection.js.map +1 -1
- package/dist/summarizerHeuristics.d.ts.map +1 -1
- package/dist/summarizerHeuristics.js +0 -3
- package/dist/summarizerHeuristics.js.map +1 -1
- package/dist/summarizerTypes.d.ts +19 -2
- package/dist/summarizerTypes.d.ts.map +1 -1
- package/dist/summarizerTypes.js.map +1 -1
- package/dist/summaryFormat.d.ts +4 -2
- package/dist/summaryFormat.d.ts.map +1 -1
- package/dist/summaryFormat.js.map +1 -1
- package/dist/summaryGenerator.d.ts.map +1 -1
- package/dist/summaryGenerator.js +3 -2
- package/dist/summaryGenerator.js.map +1 -1
- package/dist/summaryManager.d.ts.map +1 -1
- package/dist/summaryManager.js +10 -6
- package/dist/summaryManager.js.map +1 -1
- package/garbageCollection.md +27 -22
- package/lib/batchManager.d.ts +11 -6
- package/lib/batchManager.d.ts.map +1 -1
- package/lib/batchManager.js +23 -13
- package/lib/batchManager.js.map +1 -1
- package/lib/containerRuntime.d.ts +74 -20
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +189 -136
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStore.d.ts.map +1 -1
- package/lib/dataStore.js +6 -0
- package/lib/dataStore.js.map +1 -1
- package/lib/dataStoreContext.d.ts +14 -21
- package/lib/dataStoreContext.d.ts.map +1 -1
- package/lib/dataStoreContext.js +75 -61
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/dataStoreContexts.js +1 -1
- package/lib/dataStoreContexts.js.map +1 -1
- package/lib/dataStores.d.ts +11 -10
- package/lib/dataStores.d.ts.map +1 -1
- package/lib/dataStores.js +53 -23
- package/lib/dataStores.js.map +1 -1
- package/lib/garbageCollection.d.ts +36 -19
- package/lib/garbageCollection.d.ts.map +1 -1
- package/lib/garbageCollection.js +207 -121
- package/lib/garbageCollection.js.map +1 -1
- package/lib/gcSweepReadyUsageDetection.d.ts.map +1 -1
- package/lib/gcSweepReadyUsageDetection.js +3 -12
- package/lib/gcSweepReadyUsageDetection.js.map +1 -1
- package/lib/index.d.ts +4 -6
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -4
- package/lib/index.js.map +1 -1
- package/lib/opCompressor.d.ts +18 -0
- package/lib/opCompressor.d.ts.map +1 -0
- package/lib/opCompressor.js +46 -0
- package/lib/opCompressor.js.map +1 -0
- package/lib/opDecompressor.d.ts +20 -0
- package/lib/opDecompressor.d.ts.map +1 -0
- package/lib/opDecompressor.js +68 -0
- package/lib/opDecompressor.js.map +1 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/pendingStateManager.d.ts +6 -26
- package/lib/pendingStateManager.d.ts.map +1 -1
- package/lib/pendingStateManager.js +42 -62
- package/lib/pendingStateManager.js.map +1 -1
- package/lib/runningSummarizer.d.ts +3 -2
- package/lib/runningSummarizer.d.ts.map +1 -1
- package/lib/runningSummarizer.js +10 -3
- package/lib/runningSummarizer.js.map +1 -1
- package/lib/scheduleManager.js.map +1 -1
- package/lib/summarizer.js +7 -2
- package/lib/summarizer.js.map +1 -1
- package/lib/summarizerClientElection.js +1 -1
- package/lib/summarizerClientElection.js.map +1 -1
- package/lib/summarizerHeuristics.d.ts.map +1 -1
- package/lib/summarizerHeuristics.js +0 -3
- package/lib/summarizerHeuristics.js.map +1 -1
- package/lib/summarizerTypes.d.ts +19 -2
- package/lib/summarizerTypes.d.ts.map +1 -1
- package/lib/summarizerTypes.js.map +1 -1
- package/lib/summaryFormat.d.ts +4 -2
- package/lib/summaryFormat.d.ts.map +1 -1
- package/lib/summaryFormat.js.map +1 -1
- package/lib/summaryGenerator.d.ts.map +1 -1
- package/lib/summaryGenerator.js +3 -2
- package/lib/summaryGenerator.js.map +1 -1
- package/lib/summaryManager.d.ts.map +1 -1
- package/lib/summaryManager.js +10 -6
- package/lib/summaryManager.js.map +1 -1
- package/package.json +37 -63
- package/prettier.config.cjs +8 -0
- package/src/batchManager.ts +32 -15
- package/src/containerRuntime.ts +260 -156
- package/src/dataStore.ts +13 -1
- package/src/dataStoreContext.ts +100 -76
- package/src/dataStoreContexts.ts +1 -1
- package/src/dataStores.ts +61 -23
- package/src/garbageCollection.ts +255 -126
- package/src/gcSweepReadyUsageDetection.ts +2 -10
- package/src/index.ts +4 -4
- package/src/opCompressor.ts +59 -0
- package/src/opDecompressor.ts +82 -0
- package/src/packageVersion.ts +1 -1
- package/src/pendingStateManager.ts +57 -96
- package/src/runningSummarizer.ts +11 -3
- package/src/scheduleManager.ts +1 -0
- package/src/summarizer.ts +6 -6
- package/src/summarizerClientElection.ts +1 -1
- package/src/summarizerHeuristics.ts +0 -3
- package/src/summarizerTypes.ts +20 -7
- package/src/summaryFormat.ts +4 -2
- package/src/summaryGenerator.ts +3 -2
- package/src/summaryManager.ts +18 -7
package/dist/dataStore.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataStore.d.ts","sourceRoot":"","sources":["../src/dataStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"dataStore.d.ts","sourceRoot":"","sources":["../src/dataStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAUtE,OAAO,EAAe,UAAU,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAEtG,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACnC,uCAAuC;IACvC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,qDAAqD;IACrD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,+BACJ,GAAG,yDAIlC,CAAC;AAEF,eAAO,MAAM,kBAAkB,0BACJ,sBAAsB,cACjC,MAAM,WACT,gBAAgB,cACb,UAAU,UACd,gBAAgB,KACzB,UAA2F,CAAC"}
|
package/dist/dataStore.js
CHANGED
|
@@ -116,6 +116,12 @@ class DataStore {
|
|
|
116
116
|
async request(request) {
|
|
117
117
|
return this.fluidDataStoreChannel.request(request);
|
|
118
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* {@inheritDoc @fluidframework/runtime-definitions#IDataStore.entryPoint}
|
|
121
|
+
*/
|
|
122
|
+
get entryPoint() {
|
|
123
|
+
return this.fluidDataStoreChannel.entryPoint;
|
|
124
|
+
}
|
|
119
125
|
get IFluidRouter() { return this.fluidDataStoreChannel; }
|
|
120
126
|
async ackBasedPromise(executor) {
|
|
121
127
|
let rejectBecauseDispose;
|
package/dist/dataStore.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataStore.js","sourceRoot":"","sources":["../src/dataStore.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAAuE;AACvE,iFAAoE;AACpE,qEAA6D;AAG7D,qEAAmE;AAenE;;;;;GAKG;AACI,MAAM,uBAAuB,GAAG,CACnC,0BAA+B,EACqB,EAAE;IACtD,OAAO,OAAO,CAAA,0BAA0B,aAA1B,0BAA0B,uBAA1B,0BA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CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvD,CAAC;IAYD,IAAW,YAAY,KAAK,OAAO,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAExD,KAAK,CAAC,eAAe,CACzB,QAC2C;QAE3C,IAAI,oBAAgC,CAAC;QACrC,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACtC,oBAAoB;gBAChB,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC,CAAC;YAElG,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;gBACvB,oBAAoB,EAAE,CAAC;gBACvB,OAAO;aACV;YAED,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;YACjD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE;YACZ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, unreachableCase } from \"@fluidframework/common-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport { IRequest, IResponse } from \"@fluidframework/core-interfaces\";\nimport { AliasResult, IDataStore, IFluidDataStoreChannel } from \"@fluidframework/runtime-definitions\";\nimport { TelemetryDataTag } from \"@fluidframework/telemetry-utils\";\nimport { ContainerRuntime } from \"./containerRuntime\";\nimport { DataStores } from \"./dataStores\";\n\n/**\n * Interface for an op to be used for assigning an\n * alias to a datastore\n */\nexport interface IDataStoreAliasMessage {\n /** The internal id of the datastore */\n readonly internalId: string;\n /** The alias name to be assigned to the datastore */\n readonly alias: string;\n}\n\n/**\n * Type guard that returns true if the given alias message is actually an instance of\n * a class which implements {@link IDataStoreAliasMessage}\n * @param maybeDataStoreAliasMessage - message object to be validated\n * @returns True if the {@link IDataStoreAliasMessage} is fully implemented, false otherwise\n */\nexport const isDataStoreAliasMessage = (\n maybeDataStoreAliasMessage: any,\n): maybeDataStoreAliasMessage is IDataStoreAliasMessage => {\n return typeof maybeDataStoreAliasMessage?.internalId === \"string\"\n && typeof maybeDataStoreAliasMessage?.alias === \"string\";\n};\n\nexport const channelToDataStore = (\n fluidDataStoreChannel: IFluidDataStoreChannel,\n internalId: string,\n runtime: ContainerRuntime,\n datastores: DataStores,\n logger: ITelemetryLogger,\n): IDataStore => new DataStore(fluidDataStoreChannel, internalId, runtime, datastores, logger);\n\nenum AliasState {\n Aliased = \"Aliased\",\n Aliasing = \"Aliasing\",\n None = \"None\",\n}\n\nclass DataStore implements IDataStore {\n private aliasState: AliasState = AliasState.None;\n private alias: string | undefined;\n private readonly pendingAliases: Map<string, Promise<AliasResult>>;\n private aliasResult: Promise<AliasResult> | undefined;\n\n async trySetAlias(alias: string): Promise<AliasResult> {\n if (alias.includes(\"/\")) {\n throw new UsageError(`The alias cannot contain slashes: '${alias}'`);\n }\n\n switch (this.aliasState) {\n // If we're already aliasing, check if it's for the same value and return\n // the stored promise, otherwise return 'AlreadyAliased'\n case AliasState.Aliasing:\n assert(this.aliasResult !== undefined,\n 0x316 /* There should be a cached promise of in-progress aliasing */);\n await this.aliasResult;\n return this.alias === alias ? \"Success\" : \"AlreadyAliased\";\n\n // If this datastore is already aliased, return true only if this\n // is a repeated call for the same alias\n case AliasState.Aliased:\n return this.alias === alias ? \"Success\" : \"AlreadyAliased\";\n\n case AliasState.None: {\n const existingAlias = this.pendingAliases.get(alias);\n if (existingAlias !== undefined) {\n // There is already another datastore which will be aliased\n // to the same name\n return \"Conflict\";\n }\n\n // There is no current or past alias operation for this datastore,\n // or for this alias, so it is safe to continue execution\n break;\n }\n\n default: unreachableCase(this.aliasState);\n }\n\n this.aliasState = AliasState.Aliasing;\n this.aliasResult = this.trySetAliasInternal(alias);\n this.pendingAliases.set(alias, this.aliasResult);\n return this.aliasResult;\n }\n\n async trySetAliasInternal(alias: string): Promise<AliasResult> {\n const message: IDataStoreAliasMessage = {\n internalId: this.internalId,\n alias,\n };\n\n this.fluidDataStoreChannel.makeVisibleAndAttachGraph();\n\n if (this.runtime.attachState === AttachState.Detached) {\n const localResult = this.datastores.processAliasMessageCore(message);\n // Explicitly lock-out future attempts of aliasing,\n // regardless of result\n this.aliasState = AliasState.Aliased;\n return localResult ? \"Success\" : \"Conflict\";\n }\n\n const aliased = await this\n .ackBasedPromise<boolean>((resolve) => {\n this.runtime.submitDataStoreAliasOp(message, resolve);\n })\n .catch((error) => {\n this.logger.sendErrorEvent({\n eventName: \"AliasingException\",\n alias: {\n value: alias,\n tag: TelemetryDataTag.UserData,\n },\n internalId: {\n value: this.internalId,\n tag: TelemetryDataTag.CodeArtifact,\n },\n }, error);\n\n return false;\n }).finally(() => {\n this.pendingAliases.delete(alias);\n });\n\n if (!aliased) {\n this.aliasState = AliasState.None;\n this.aliasResult = undefined;\n return \"Conflict\";\n }\n\n this.alias = alias;\n this.aliasState = AliasState.Aliased;\n return \"Success\";\n }\n\n async request(request: IRequest): Promise<IResponse> {\n return this.fluidDataStoreChannel.request(request);\n }\n\n constructor(\n private readonly fluidDataStoreChannel: IFluidDataStoreChannel,\n private readonly internalId: string,\n private readonly runtime: ContainerRuntime,\n private readonly datastores: DataStores,\n private readonly logger: ITelemetryLogger,\n ) {\n this.pendingAliases = datastores.pendingAliases;\n }\n\n public get IFluidRouter() { return this.fluidDataStoreChannel; }\n\n private async ackBasedPromise<T>(\n executor: (resolve: (value: T | PromiseLike<T>) => void,\n reject: (reason?: any) => void) => void,\n ): Promise<T> {\n let rejectBecauseDispose: () => void;\n return new Promise<T>((resolve, reject) => {\n rejectBecauseDispose =\n () => reject(new Error(\"ContainerRuntime disposed while this ack-based Promise was pending\"));\n\n if (this.runtime.disposed) {\n rejectBecauseDispose();\n return;\n }\n\n this.runtime.on(\"dispose\", rejectBecauseDispose);\n executor(resolve, reject);\n }).finally(() => {\n this.runtime.off(\"dispose\", rejectBecauseDispose);\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dataStore.js","sourceRoot":"","sources":["../src/dataStore.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAAuE;AACvE,iFAAoE;AACpE,qEAA6D;AAQ7D,qEAAmE;AAenE;;;;;GAKG;AACI,MAAM,uBAAuB,GAAG,CACnC,0BAA+B,EACqB,EAAE;IACtD,OAAO,OAAO,CAAA,0BAA0B,aAA1B,0BAA0B,uBAA1B,0BAA0B,CAAE,UAAU,CAAA,KAAK,QAAQ;WAC1D,OAAO,CAAA,0BAA0B,aAA1B,0BAA0B,uBAA1B,0BAA0B,CAAE,KAAK,CAAA,KAAK,QAAQ,CAAC;AACjE,CAAC,CAAC;AALW,QAAA,uBAAuB,2BAKlC;AAEK,MAAM,kBAAkB,GAAG,CAC9B,qBAA6C,EAC7C,UAAkB,EAClB,OAAyB,EACzB,UAAsB,EACtB,MAAwB,EACd,EAAE,CAAC,IAAI,SAAS,CAAC,qBAAqB,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;AANlF,QAAA,kBAAkB,sBAMgE;AAE/F,IAAK,UAIJ;AAJD,WAAK,UAAU;IACX,iCAAmB,CAAA;IACnB,mCAAqB,CAAA;IACrB,2BAAa,CAAA;AACjB,CAAC,EAJI,UAAU,KAAV,UAAU,QAId;AAED,MAAM,SAAS;IA2GX,YACqB,qBAA6C,EAC7C,UAAkB,EAClB,OAAyB,EACzB,UAAsB,EACtB,MAAwB;QAJxB,0BAAqB,GAArB,qBAAqB,CAAwB;QAC7C,eAAU,GAAV,UAAU,CAAQ;QAClB,YAAO,GAAP,OAAO,CAAkB;QACzB,eAAU,GAAV,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AAoB,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, unreachableCase } from \"@fluidframework/common-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport {\n FluidObject,\n IFluidHandle,\n IRequest,\n IResponse,\n} from \"@fluidframework/core-interfaces\";\nimport { AliasResult, IDataStore, IFluidDataStoreChannel } from \"@fluidframework/runtime-definitions\";\nimport { TelemetryDataTag } from \"@fluidframework/telemetry-utils\";\nimport { ContainerRuntime } from \"./containerRuntime\";\nimport { DataStores } from \"./dataStores\";\n\n/**\n * Interface for an op to be used for assigning an\n * alias to a datastore\n */\nexport interface IDataStoreAliasMessage {\n /** The internal id of the datastore */\n readonly internalId: string;\n /** The alias name to be assigned to the datastore */\n readonly alias: string;\n}\n\n/**\n * Type guard that returns true if the given alias message is actually an instance of\n * a class which implements {@link IDataStoreAliasMessage}\n * @param maybeDataStoreAliasMessage - message object to be validated\n * @returns True if the {@link IDataStoreAliasMessage} is fully implemented, false otherwise\n */\nexport const isDataStoreAliasMessage = (\n maybeDataStoreAliasMessage: any,\n): maybeDataStoreAliasMessage is IDataStoreAliasMessage => {\n return typeof maybeDataStoreAliasMessage?.internalId === \"string\"\n && typeof maybeDataStoreAliasMessage?.alias === \"string\";\n};\n\nexport const channelToDataStore = (\n fluidDataStoreChannel: IFluidDataStoreChannel,\n internalId: string,\n runtime: ContainerRuntime,\n datastores: DataStores,\n logger: ITelemetryLogger,\n): IDataStore => new DataStore(fluidDataStoreChannel, internalId, runtime, datastores, logger);\n\nenum AliasState {\n Aliased = \"Aliased\",\n Aliasing = \"Aliasing\",\n None = \"None\",\n}\n\nclass DataStore implements IDataStore {\n private aliasState: AliasState = AliasState.None;\n private alias: string | undefined;\n private readonly pendingAliases: Map<string, Promise<AliasResult>>;\n private aliasResult: Promise<AliasResult> | undefined;\n\n async trySetAlias(alias: string): Promise<AliasResult> {\n if (alias.includes(\"/\")) {\n throw new UsageError(`The alias cannot contain slashes: '${alias}'`);\n }\n\n switch (this.aliasState) {\n // If we're already aliasing, check if it's for the same value and return\n // the stored promise, otherwise return 'AlreadyAliased'\n case AliasState.Aliasing:\n assert(this.aliasResult !== undefined,\n 0x316 /* There should be a cached promise of in-progress aliasing */);\n await this.aliasResult;\n return this.alias === alias ? \"Success\" : \"AlreadyAliased\";\n\n // If this datastore is already aliased, return true only if this\n // is a repeated call for the same alias\n case AliasState.Aliased:\n return this.alias === alias ? \"Success\" : \"AlreadyAliased\";\n\n case AliasState.None: {\n const existingAlias = this.pendingAliases.get(alias);\n if (existingAlias !== undefined) {\n // There is already another datastore which will be aliased\n // to the same name\n return \"Conflict\";\n }\n\n // There is no current or past alias operation for this datastore,\n // or for this alias, so it is safe to continue execution\n break;\n }\n\n default: unreachableCase(this.aliasState);\n }\n\n this.aliasState = AliasState.Aliasing;\n this.aliasResult = this.trySetAliasInternal(alias);\n this.pendingAliases.set(alias, this.aliasResult);\n return this.aliasResult;\n }\n\n async trySetAliasInternal(alias: string): Promise<AliasResult> {\n const message: IDataStoreAliasMessage = {\n internalId: this.internalId,\n alias,\n };\n\n this.fluidDataStoreChannel.makeVisibleAndAttachGraph();\n\n if (this.runtime.attachState === AttachState.Detached) {\n const localResult = this.datastores.processAliasMessageCore(message);\n // Explicitly lock-out future attempts of aliasing,\n // regardless of result\n this.aliasState = AliasState.Aliased;\n return localResult ? \"Success\" : \"Conflict\";\n }\n\n const aliased = await this\n .ackBasedPromise<boolean>((resolve) => {\n this.runtime.submitDataStoreAliasOp(message, resolve);\n })\n .catch((error) => {\n this.logger.sendErrorEvent({\n eventName: \"AliasingException\",\n alias: {\n value: alias,\n tag: TelemetryDataTag.UserData,\n },\n internalId: {\n value: this.internalId,\n tag: TelemetryDataTag.CodeArtifact,\n },\n }, error);\n\n return false;\n }).finally(() => {\n this.pendingAliases.delete(alias);\n });\n\n if (!aliased) {\n this.aliasState = AliasState.None;\n this.aliasResult = undefined;\n return \"Conflict\";\n }\n\n this.alias = alias;\n this.aliasState = AliasState.Aliased;\n return \"Success\";\n }\n\n async request(request: IRequest): Promise<IResponse> {\n return this.fluidDataStoreChannel.request(request);\n }\n\n /**\n * {@inheritDoc @fluidframework/runtime-definitions#IDataStore.entryPoint}\n */\n get entryPoint(): IFluidHandle<FluidObject> | undefined {\n return this.fluidDataStoreChannel.entryPoint;\n }\n\n constructor(\n private readonly fluidDataStoreChannel: IFluidDataStoreChannel,\n private readonly internalId: string,\n private readonly runtime: ContainerRuntime,\n private readonly datastores: DataStores,\n private readonly logger: ITelemetryLogger,\n ) {\n this.pendingAliases = datastores.pendingAliases;\n }\n\n public get IFluidRouter() { return this.fluidDataStoreChannel; }\n\n private async ackBasedPromise<T>(\n executor: (resolve: (value: T | PromiseLike<T>) => void,\n reject: (reason?: any) => void) => void,\n ): Promise<T> {\n let rejectBecauseDispose: () => void;\n return new Promise<T>((resolve, reject) => {\n rejectBecauseDispose =\n () => reject(new Error(\"ContainerRuntime disposed while this ack-based Promise was pending\"));\n\n if (this.runtime.disposed) {\n rejectBecauseDispose();\n return;\n }\n\n this.runtime.on(\"dispose\", rejectBecauseDispose);\n executor(resolve, reject);\n }).finally(() => {\n this.runtime.off(\"dispose\", rejectBecauseDispose);\n });\n }\n}\n"]}
|
|
@@ -9,7 +9,7 @@ import { Deferred, TypedEventEmitter } from "@fluidframework/common-utils";
|
|
|
9
9
|
import { IDocumentStorageService } from "@fluidframework/driver-definitions";
|
|
10
10
|
import { IClientDetails, IDocumentMessage, IQuorumClients, ISequencedDocumentMessage, ISnapshotTree, ITreeEntry } from "@fluidframework/protocol-definitions";
|
|
11
11
|
import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
|
|
12
|
-
import { BindState, CreateChildSummarizerNodeFn, CreateChildSummarizerNodeParam, IAttachMessage, IFluidDataStoreChannel, IFluidDataStoreContext, IFluidDataStoreContextDetached, IFluidDataStoreContextEvents, IFluidDataStoreRegistry, IGarbageCollectionData, IGarbageCollectionDetailsBase,
|
|
12
|
+
import { BindState, CreateChildSummarizerNodeFn, CreateChildSummarizerNodeParam, IAttachMessage, IFluidDataStoreChannel, IFluidDataStoreContext, IFluidDataStoreContextDetached, IFluidDataStoreContextEvents, IFluidDataStoreRegistry, IGarbageCollectionData, IGarbageCollectionDetailsBase, IInboundSignalMessage, IProvideFluidDataStoreFactory, ISummarizeResult, ISummarizerNodeWithGC, SummarizeInternalFn, ITelemetryContext } from "@fluidframework/runtime-definitions";
|
|
13
13
|
import { ContainerRuntime } from "./containerRuntime";
|
|
14
14
|
export declare function createAttributesBlob(pkg: readonly string[], isRootDataStore: boolean): ITreeEntry;
|
|
15
15
|
interface ISnapshotDetails {
|
|
@@ -24,7 +24,6 @@ export interface IFluidDataStoreContextProps {
|
|
|
24
24
|
readonly storage: IDocumentStorageService;
|
|
25
25
|
readonly scope: FluidObject;
|
|
26
26
|
readonly createSummarizerNodeFn: CreateChildSummarizerNodeFn;
|
|
27
|
-
readonly writeGCDataAtRoot: boolean;
|
|
28
27
|
readonly pkg?: Readonly<string[]>;
|
|
29
28
|
}
|
|
30
29
|
/** Properties necessary for creating a local FluidDataStoreContext */
|
|
@@ -40,7 +39,7 @@ export interface ILocalFluidDataStoreContextProps extends IFluidDataStoreContext
|
|
|
40
39
|
}
|
|
41
40
|
/** Properties necessary for creating a remote FluidDataStoreContext */
|
|
42
41
|
export interface IRemoteFluidDataStoreContextProps extends IFluidDataStoreContextProps {
|
|
43
|
-
readonly snapshotTree: ISnapshotTree |
|
|
42
|
+
readonly snapshotTree: ISnapshotTree | undefined;
|
|
44
43
|
readonly getBaseGCDetails: () => Promise<IGarbageCollectionDetailsBase | undefined>;
|
|
45
44
|
}
|
|
46
45
|
/**
|
|
@@ -64,6 +63,14 @@ export declare abstract class FluidDataStoreContext extends TypedEventEmitter<IF
|
|
|
64
63
|
get baseSnapshot(): ISnapshotTree | undefined;
|
|
65
64
|
private _disposed;
|
|
66
65
|
get disposed(): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Tombstone is a temporary feature that prevents a data store from sending / receiving ops, signals and from
|
|
68
|
+
* loading.
|
|
69
|
+
*/
|
|
70
|
+
private _tombstoned;
|
|
71
|
+
get tombstoned(): boolean;
|
|
72
|
+
/** If true, throw an error when a tombstone data store is used. */
|
|
73
|
+
private readonly throwOnTombstoneUsage;
|
|
67
74
|
get attachState(): AttachState;
|
|
68
75
|
get IFluidDataStoreRegistry(): IFluidDataStoreRegistry | undefined;
|
|
69
76
|
/**
|
|
@@ -93,19 +100,19 @@ export declare abstract class FluidDataStoreContext extends TypedEventEmitter<IF
|
|
|
93
100
|
protected _attachState: AttachState;
|
|
94
101
|
private _isInMemoryRoot;
|
|
95
102
|
protected readonly summarizerNode: ISummarizerNodeWithGC;
|
|
96
|
-
private readonly
|
|
103
|
+
private readonly mc;
|
|
97
104
|
private readonly thresholdOpsCounter;
|
|
98
105
|
private static readonly pendingOpsCountThreshold;
|
|
99
|
-
private
|
|
106
|
+
private lastUsedRoutes;
|
|
100
107
|
readonly id: string;
|
|
101
108
|
private readonly _containerRuntime;
|
|
102
109
|
readonly storage: IDocumentStorageService;
|
|
103
110
|
readonly scope: FluidObject;
|
|
104
|
-
private readonly writeGCDataAtRoot;
|
|
105
111
|
protected pkg?: readonly string[];
|
|
106
112
|
constructor(props: IFluidDataStoreContextProps, existing: boolean, bindState: BindState, // Used to assert for state tracking purposes
|
|
107
113
|
isLocalDataStore: boolean, makeLocallyVisibleFn: () => void);
|
|
108
114
|
dispose(): void;
|
|
115
|
+
setTombstone(tombstone: boolean): void;
|
|
109
116
|
private rejectDeferredRealize;
|
|
110
117
|
realize(): Promise<IFluidDataStoreChannel>;
|
|
111
118
|
protected factoryFromPackagePath(packages?: readonly string[]): Promise<{
|
|
@@ -162,10 +169,8 @@ export declare abstract class FluidDataStoreContext extends TypedEventEmitter<IF
|
|
|
162
169
|
* 5. To update the timestamp when this data store or any children are marked as unreferenced.
|
|
163
170
|
*
|
|
164
171
|
* @param usedRoutes - The routes that are used in this data store.
|
|
165
|
-
* @param gcTimestamp - The time when GC was run that generated these used routes. If any node becomes unreferenced
|
|
166
|
-
* as part of this GC run, this should be used to update the time when it happens.
|
|
167
172
|
*/
|
|
168
|
-
updateUsedRoutes(usedRoutes: string[]
|
|
173
|
+
updateUsedRoutes(usedRoutes: string[]): void;
|
|
169
174
|
/**
|
|
170
175
|
* Called when a new outbound reference is added to another node. This is used by garbage collection to identify
|
|
171
176
|
* all references added in the system.
|
|
@@ -211,10 +216,6 @@ export declare abstract class FluidDataStoreContext extends TypedEventEmitter<IF
|
|
|
211
216
|
* It will be removed, as the source of truth for this flag will be the aliasing blob.
|
|
212
217
|
*/
|
|
213
218
|
setInMemoryRoot(): void;
|
|
214
|
-
/**
|
|
215
|
-
* @deprecated Renamed to `{@link FluidDataStoreContext.getBaseGCDetails}()`.
|
|
216
|
-
*/
|
|
217
|
-
abstract getInitialGCSummaryDetails(): Promise<IGarbageCollectionSummaryDetails>;
|
|
218
219
|
abstract getBaseGCDetails(): Promise<IGarbageCollectionDetailsBase>;
|
|
219
220
|
reSubmit(contents: any, localOpMetadata: unknown): void;
|
|
220
221
|
rollback(contents: any, localOpMetadata: unknown): void;
|
|
@@ -229,10 +230,6 @@ export declare class RemoteFluidDataStoreContext extends FluidDataStoreContext {
|
|
|
229
230
|
constructor(props: IRemoteFluidDataStoreContextProps);
|
|
230
231
|
private readonly initialSnapshotDetailsP;
|
|
231
232
|
getInitialSnapshotDetails(): Promise<ISnapshotDetails>;
|
|
232
|
-
/**
|
|
233
|
-
* @deprecated Renamed to {@link RemoteFluidDataStoreContext.getBaseGCDetails}.
|
|
234
|
-
*/
|
|
235
|
-
getInitialGCSummaryDetails(): Promise<IGarbageCollectionSummaryDetails>;
|
|
236
233
|
getBaseGCDetails(): Promise<IGarbageCollectionDetailsBase>;
|
|
237
234
|
generateAttachMessage(): IAttachMessage;
|
|
238
235
|
}
|
|
@@ -249,10 +246,6 @@ export declare class LocalFluidDataStoreContextBase extends FluidDataStoreContex
|
|
|
249
246
|
private attachListeners;
|
|
250
247
|
generateAttachMessage(): IAttachMessage;
|
|
251
248
|
getInitialSnapshotDetails(): Promise<ISnapshotDetails>;
|
|
252
|
-
/**
|
|
253
|
-
* @deprecated Renamed to {@link LocalFluidDataStoreContextBase.getBaseGCDetails}.
|
|
254
|
-
*/
|
|
255
|
-
getInitialGCSummaryDetails(): Promise<IGarbageCollectionSummaryDetails>;
|
|
256
249
|
getBaseGCDetails(): Promise<IGarbageCollectionDetailsBase>;
|
|
257
250
|
}
|
|
258
251
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataStoreContext.d.ts","sourceRoot":"","sources":["../src/dataStoreContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"dataStoreContext.d.ts","sourceRoot":"","sources":["../src/dataStoreContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAwB,MAAM,oCAAoC,CAAC;AACzG,OAAO,EACH,WAAW,EACX,QAAQ,EACR,SAAS,EACT,YAAY,EACf,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,SAAS,EACT,aAAa,EACb,WAAW,EACX,cAAc,EACjB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEH,QAAQ,EAER,iBAAiB,EACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAG7E,OAAO,EACH,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,yBAAyB,EACzB,aAAa,EACb,UAAU,EACb,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACH,iBAAiB,EACpB,MAAM,+CAA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AAQ,qBAAqB;IACrE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA4B;IACzD;;OAEG;IACH,SAAgB,WAAW,CAAC,EAAE,GAAG,CAAC;gBAEtB,KAAK,EAAE,gCAAgC;IAiBnD,OAAO,CAAC,eAAe;IAWhB,qBAAqB,IAAI,cAAc;IA4BjC,yBAAyB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAiCtD,gBAAgB,IAAI,OAAO,CAAC,6BAA6B,CAAC;CAI1E;AAED;;;;;GAKG;AACH,qBAAa,0BAA2B,SAAQ,8BAA8B;gBAC9D,KAAK,EAAE,gCAAgC;CAGtD;AAED;;;;;GAKG;AACH,qBAAa,kCACT,SAAQ,8BACR,YAAW,8BAA8B;gBAC7B,KAAK,EAAE,gCAAgC;IAKtC,aAAa,CACtB,QAAQ,EAAE,6BAA6B,EACvC,gBAAgB,EAAE,sBAAsB;IA+B/B,yBAAyB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAMtE"}
|
package/dist/dataStoreContext.js
CHANGED
|
@@ -14,6 +14,8 @@ const runtime_utils_1 = require("@fluidframework/runtime-utils");
|
|
|
14
14
|
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
15
15
|
const container_utils_1 = require("@fluidframework/container-utils");
|
|
16
16
|
const summaryFormat_1 = require("./summaryFormat");
|
|
17
|
+
const garbageCollection_1 = require("./garbageCollection");
|
|
18
|
+
const summarizerClientElection_1 = require("./summarizerClientElection");
|
|
17
19
|
function createAttributes(pkg, isRootDataStore) {
|
|
18
20
|
const stringifiedPkg = JSON.stringify(pkg);
|
|
19
21
|
return {
|
|
@@ -39,6 +41,11 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
39
41
|
this.isLocalDataStore = isLocalDataStore;
|
|
40
42
|
this.makeLocallyVisibleFn = makeLocallyVisibleFn;
|
|
41
43
|
this._disposed = false;
|
|
44
|
+
/**
|
|
45
|
+
* Tombstone is a temporary feature that prevents a data store from sending / receiving ops, signals and from
|
|
46
|
+
* loading.
|
|
47
|
+
*/
|
|
48
|
+
this._tombstoned = false;
|
|
42
49
|
this.detachedRuntimeCreation = false;
|
|
43
50
|
this.loaded = false;
|
|
44
51
|
this.pending = [];
|
|
@@ -47,7 +54,6 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
47
54
|
this.id = props.id;
|
|
48
55
|
this.storage = props.storage;
|
|
49
56
|
this.scope = props.scope;
|
|
50
|
-
this.writeGCDataAtRoot = props.writeGCDataAtRoot;
|
|
51
57
|
this.pkg = props.pkg;
|
|
52
58
|
// URIs use slashes as delimiters. Handles use URIs.
|
|
53
59
|
// Thus having slashes in types almost guarantees trouble down the road!
|
|
@@ -63,8 +69,12 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
63
69
|
};
|
|
64
70
|
const thisSummarizeInternal = async (fullTree, trackState, telemetryContext) => this.summarizeInternal(fullTree, trackState, telemetryContext);
|
|
65
71
|
this.summarizerNode = props.createSummarizerNodeFn(thisSummarizeInternal, async (fullGC) => this.getGCDataInternal(fullGC), async () => this.getBaseGCDetails());
|
|
66
|
-
this.
|
|
67
|
-
this.thresholdOpsCounter = new telemetry_utils_1.ThresholdCounter(FluidDataStoreContext.pendingOpsCountThreshold, this.
|
|
72
|
+
this.mc = (0, telemetry_utils_1.loggerToMonitoringContext)(telemetry_utils_1.ChildLogger.create(this.logger, "FluidDataStoreContext"));
|
|
73
|
+
this.thresholdOpsCounter = new telemetry_utils_1.ThresholdCounter(FluidDataStoreContext.pendingOpsCountThreshold, this.mc.logger);
|
|
74
|
+
// Tombstone should only throw when the feature flag is enabled and the client isn't a summarizer
|
|
75
|
+
this.throwOnTombstoneUsage =
|
|
76
|
+
this.mc.config.getBoolean(garbageCollection_1.throwOnTombstoneUsageKey) === true &&
|
|
77
|
+
this.clientDetails.type !== summarizerClientElection_1.summarizerClientType;
|
|
68
78
|
}
|
|
69
79
|
get packagePath() {
|
|
70
80
|
(0, common_utils_1.assert)(this.pkg !== undefined, 0x139 /* "Undefined package path" */);
|
|
@@ -101,6 +111,7 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
101
111
|
return this._baseSnapshot;
|
|
102
112
|
}
|
|
103
113
|
get disposed() { return this._disposed; }
|
|
114
|
+
get tombstoned() { return this._tombstoned; }
|
|
104
115
|
get attachState() {
|
|
105
116
|
return this._attachState;
|
|
106
117
|
}
|
|
@@ -139,6 +150,12 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
139
150
|
}).catch((error) => { });
|
|
140
151
|
}
|
|
141
152
|
}
|
|
153
|
+
setTombstone(tombstone) {
|
|
154
|
+
if (this.tombstoned === tombstone) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
this._tombstoned = tombstone;
|
|
158
|
+
}
|
|
142
159
|
rejectDeferredRealize(reason, packageName) {
|
|
143
160
|
throw new telemetry_utils_1.LoggingError(reason, { packageName: { value: packageName, tag: telemetry_utils_1.TelemetryDataTag.CodeArtifact } });
|
|
144
161
|
}
|
|
@@ -207,7 +224,8 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
207
224
|
* its new client ID when we are connecting or connected.
|
|
208
225
|
*/
|
|
209
226
|
setConnectionState(connected, clientId) {
|
|
210
|
-
this
|
|
227
|
+
// ConnectionState should not fail in tombstone mode as this is internally run
|
|
228
|
+
this.verifyNotClosed("setConnectionState", false /* checkTombstone */);
|
|
211
229
|
// Connection events are ignored if the store is not yet loaded
|
|
212
230
|
if (!this.loaded) {
|
|
213
231
|
return;
|
|
@@ -218,7 +236,7 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
218
236
|
}
|
|
219
237
|
process(messageArg, local, localOpMetadata) {
|
|
220
238
|
var _a;
|
|
221
|
-
this.verifyNotClosed();
|
|
239
|
+
this.verifyNotClosed("process", true, (0, container_utils_1.extractSafePropertiesFromMessage)(messageArg));
|
|
222
240
|
const innerContents = messageArg.contents;
|
|
223
241
|
const message = Object.assign(Object.assign({}, messageArg), { type: innerContents.type, contents: innerContents.content });
|
|
224
242
|
this.summarizerNode.recordChange(message);
|
|
@@ -234,7 +252,7 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
234
252
|
}
|
|
235
253
|
processSignal(message, local) {
|
|
236
254
|
var _a;
|
|
237
|
-
this.verifyNotClosed();
|
|
255
|
+
this.verifyNotClosed("processSignal");
|
|
238
256
|
// Signals are ignored if the store is not yet loaded
|
|
239
257
|
if (!this.loaded) {
|
|
240
258
|
return;
|
|
@@ -268,10 +286,6 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
268
286
|
const isRoot = await this.isRoot();
|
|
269
287
|
const attributes = createAttributes(pkg, isRoot);
|
|
270
288
|
(0, runtime_utils_1.addBlobToSummary)(summarizeResult, summaryFormat_1.dataStoreAttributesBlobName, JSON.stringify(attributes));
|
|
271
|
-
// Add GC data to the summary if it's not written at the root.
|
|
272
|
-
if (!this.writeGCDataAtRoot) {
|
|
273
|
-
(0, runtime_utils_1.addBlobToSummary)(summarizeResult, runtime_definitions_1.gcBlobKey, JSON.stringify(this.summarizerNode.getGCSummaryDetails()));
|
|
274
|
-
}
|
|
275
289
|
// If we are not referenced, mark the summary tree as unreferenced. Also, update unreferenced blob
|
|
276
290
|
// size in the summary stats with the blobs size of this data store.
|
|
277
291
|
if (!this.summarizerNode.isReferenced()) {
|
|
@@ -316,20 +330,16 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
316
330
|
* 5. To update the timestamp when this data store or any children are marked as unreferenced.
|
|
317
331
|
*
|
|
318
332
|
* @param usedRoutes - The routes that are used in this data store.
|
|
319
|
-
* @param gcTimestamp - The time when GC was run that generated these used routes. If any node becomes unreferenced
|
|
320
|
-
* as part of this GC run, this should be used to update the time when it happens.
|
|
321
333
|
*/
|
|
322
|
-
updateUsedRoutes(usedRoutes
|
|
334
|
+
updateUsedRoutes(usedRoutes) {
|
|
323
335
|
// Update the used routes in this data store's summarizer node.
|
|
324
|
-
this.summarizerNode.updateUsedRoutes(usedRoutes
|
|
336
|
+
this.summarizerNode.updateUsedRoutes(usedRoutes);
|
|
325
337
|
/**
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
* child's reference state changes, the gcTimestamp has to be used to update its unreferencedTimestamp. Since
|
|
330
|
-
* it will result in a change in this data store's used routes, it will be realized to regenerate its summary.
|
|
338
|
+
* Store the used routes to update the channel if the data store is not loaded yet. If the used routes changed
|
|
339
|
+
* since the previous run, the data store will be loaded during summarize since the used state changed. So, it's
|
|
340
|
+
* safe to only store the last used routes.
|
|
331
341
|
*/
|
|
332
|
-
this.
|
|
342
|
+
this.lastUsedRoutes = usedRoutes;
|
|
333
343
|
// If we are loaded, call the channel so it can update the used routes of the child contexts.
|
|
334
344
|
// If we are not loaded, we will update this when we are realized.
|
|
335
345
|
if (this.loaded) {
|
|
@@ -354,13 +364,13 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
354
364
|
updateChannelUsedRoutes() {
|
|
355
365
|
(0, common_utils_1.assert)(this.loaded, 0x144 /* "Channel should be loaded when updating used routes" */);
|
|
356
366
|
(0, common_utils_1.assert)(this.channel !== undefined, 0x145 /* "Channel should be present when data store is loaded" */);
|
|
357
|
-
// If there is no
|
|
358
|
-
if (this.
|
|
367
|
+
// If there is no lastUsedRoutes, GC has not run up until this point.
|
|
368
|
+
if (this.lastUsedRoutes === undefined) {
|
|
359
369
|
return;
|
|
360
370
|
}
|
|
361
371
|
// Remove the route to this data store, if it exists.
|
|
362
|
-
const usedChannelRoutes = this.
|
|
363
|
-
this.channel.updateUsedRoutes(usedChannelRoutes
|
|
372
|
+
const usedChannelRoutes = this.lastUsedRoutes.filter((id) => { return id !== "/" && id !== ""; });
|
|
373
|
+
this.channel.updateUsedRoutes(usedChannelRoutes);
|
|
364
374
|
}
|
|
365
375
|
/**
|
|
366
376
|
* @deprecated 0.18.Should call request on the runtime directly
|
|
@@ -370,7 +380,7 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
370
380
|
return runtime.request(request);
|
|
371
381
|
}
|
|
372
382
|
submitMessage(type, content, localOpMetadata) {
|
|
373
|
-
this.verifyNotClosed();
|
|
383
|
+
this.verifyNotClosed("submitMessage");
|
|
374
384
|
(0, common_utils_1.assert)(!!this.channel, 0x146 /* "Channel must exist when submitting message" */);
|
|
375
385
|
const fluidDataStoreContent = {
|
|
376
386
|
content,
|
|
@@ -388,7 +398,7 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
388
398
|
*
|
|
389
399
|
*/
|
|
390
400
|
setChannelDirty(address) {
|
|
391
|
-
this.verifyNotClosed();
|
|
401
|
+
this.verifyNotClosed("setChannelDirty");
|
|
392
402
|
// Get the latest sequence number.
|
|
393
403
|
const latestSequenceNumber = this.deltaManager.lastSequenceNumber;
|
|
394
404
|
this.summarizerNode.invalidate(latestSequenceNumber);
|
|
@@ -398,7 +408,7 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
398
408
|
}
|
|
399
409
|
}
|
|
400
410
|
submitSignal(type, content) {
|
|
401
|
-
this.verifyNotClosed();
|
|
411
|
+
this.verifyNotClosed("submitSignal");
|
|
402
412
|
(0, common_utils_1.assert)(!!this.channel, 0x147 /* "Channel must exist on submitting signal" */);
|
|
403
413
|
return this._containerRuntime.submitDataStoreSignal(this.id, type, content);
|
|
404
414
|
}
|
|
@@ -489,9 +499,25 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
489
499
|
const innerContents = contents;
|
|
490
500
|
return this.channel.applyStashedOp(innerContents.content);
|
|
491
501
|
}
|
|
492
|
-
verifyNotClosed() {
|
|
502
|
+
verifyNotClosed(callSite, checkTombstone = true, safeTelemetryProps = {}) {
|
|
493
503
|
if (this._disposed) {
|
|
494
|
-
throw new Error(
|
|
504
|
+
throw new Error(`Context is closed! Call site [${callSite}]`);
|
|
505
|
+
}
|
|
506
|
+
if (checkTombstone && this.tombstoned) {
|
|
507
|
+
const messageString = `Context is tombstoned! Call site [${callSite}]`;
|
|
508
|
+
const error = new container_utils_1.DataCorruptionError(messageString, Object.assign({ errorMessage: messageString }, safeTelemetryProps));
|
|
509
|
+
// Always log an error when tombstoned data store is used. However, throw an error only if
|
|
510
|
+
// throwOnTombstoneUsage is set.
|
|
511
|
+
this.mc.logger.sendErrorEvent({
|
|
512
|
+
eventName: "GC_Tombstone_DataStore_Changed",
|
|
513
|
+
callSite,
|
|
514
|
+
pkg: (0, runtime_utils_1.packagePathToTelemetryProperty)(this.pkg),
|
|
515
|
+
}, error);
|
|
516
|
+
// Always log an error when tombstoned data store is used. However, throw an error only if
|
|
517
|
+
// throwOnTombstoneUsage is set and the client is not a summarizer.
|
|
518
|
+
if (this.throwOnTombstoneUsage) {
|
|
519
|
+
throw error;
|
|
520
|
+
}
|
|
495
521
|
}
|
|
496
522
|
}
|
|
497
523
|
getCreateChildSummarizerNodeFn(id, createParam) {
|
|
@@ -511,23 +537,12 @@ class RemoteFluidDataStoreContext extends FluidDataStoreContext {
|
|
|
511
537
|
throw new Error("Already attached");
|
|
512
538
|
});
|
|
513
539
|
this.initialSnapshotDetailsP = new common_utils_1.LazyPromise(async () => {
|
|
514
|
-
var _a
|
|
515
|
-
let tree;
|
|
540
|
+
var _a;
|
|
541
|
+
let tree = this.initSnapshotValue;
|
|
516
542
|
let isRootDataStore = true;
|
|
517
|
-
if (typeof this.initSnapshotValue === "string") {
|
|
518
|
-
const commit = (await this.storage.getVersions(this.initSnapshotValue, 1))[0];
|
|
519
|
-
tree = (_a = await this.storage.getSnapshotTree(commit)) !== null && _a !== void 0 ? _a : undefined;
|
|
520
|
-
}
|
|
521
|
-
else {
|
|
522
|
-
tree = this.initSnapshotValue;
|
|
523
|
-
}
|
|
524
|
-
const localReadAndParse = async (id) => (0, driver_utils_1.readAndParse)(this.storage, id);
|
|
525
|
-
if (tree) {
|
|
526
|
-
tree = await this.summarizerNode.loadBaseSummary(tree, localReadAndParse);
|
|
527
|
-
}
|
|
528
543
|
if (!!tree && tree.blobs[summaryFormat_1.dataStoreAttributesBlobName] !== undefined) {
|
|
529
544
|
// Need to get through snapshot and use that to populate extraBlobs
|
|
530
|
-
const attributes = await
|
|
545
|
+
const attributes = await (0, driver_utils_1.readAndParse)(this.storage, tree.blobs[summaryFormat_1.dataStoreAttributesBlobName]);
|
|
531
546
|
let pkgFromSnapshot;
|
|
532
547
|
// Use the snapshotFormatVersion to determine how the pkg is encoded in the snapshot.
|
|
533
548
|
// For snapshotFormatVersion = "0.1" (1) or above, pkg is jsonified, otherwise it is just a string.
|
|
@@ -546,7 +561,7 @@ class RemoteFluidDataStoreContext extends FluidDataStoreContext {
|
|
|
546
561
|
* data stores in older documents are not garbage collected incorrectly. This may lead to additional
|
|
547
562
|
* roots in the document but they won't break.
|
|
548
563
|
*/
|
|
549
|
-
isRootDataStore = (
|
|
564
|
+
isRootDataStore = (_a = attributes.isRootDataStore) !== null && _a !== void 0 ? _a : true;
|
|
550
565
|
if ((0, summaryFormat_1.hasIsolatedChannels)(attributes)) {
|
|
551
566
|
tree = tree.trees[runtime_definitions_1.channelsTreeName];
|
|
552
567
|
(0, common_utils_1.assert)(tree !== undefined, 0x1fe /* "isolated channels subtree should exist in remote datastore snapshot" */);
|
|
@@ -564,16 +579,13 @@ class RemoteFluidDataStoreContext extends FluidDataStoreContext {
|
|
|
564
579
|
var _a;
|
|
565
580
|
return (_a = (await props.getBaseGCDetails())) !== null && _a !== void 0 ? _a : {};
|
|
566
581
|
});
|
|
582
|
+
if (props.snapshotTree !== undefined) {
|
|
583
|
+
this.summarizerNode.updateBaseSummaryState(props.snapshotTree);
|
|
584
|
+
}
|
|
567
585
|
}
|
|
568
586
|
async getInitialSnapshotDetails() {
|
|
569
587
|
return this.initialSnapshotDetailsP;
|
|
570
588
|
}
|
|
571
|
-
/**
|
|
572
|
-
* @deprecated Renamed to {@link RemoteFluidDataStoreContext.getBaseGCDetails}.
|
|
573
|
-
*/
|
|
574
|
-
async getInitialGCSummaryDetails() {
|
|
575
|
-
return this.getBaseGCDetails();
|
|
576
|
-
}
|
|
577
589
|
async getBaseGCDetails() {
|
|
578
590
|
return this.baseGCDetailsP;
|
|
579
591
|
}
|
|
@@ -654,13 +666,6 @@ class LocalFluidDataStoreContextBase extends FluidDataStoreContext {
|
|
|
654
666
|
snapshot,
|
|
655
667
|
};
|
|
656
668
|
}
|
|
657
|
-
/**
|
|
658
|
-
* @deprecated Renamed to {@link LocalFluidDataStoreContextBase.getBaseGCDetails}.
|
|
659
|
-
*/
|
|
660
|
-
async getInitialGCSummaryDetails() {
|
|
661
|
-
// Local data store does not have initial summary.
|
|
662
|
-
return {};
|
|
663
|
-
}
|
|
664
669
|
async getBaseGCDetails() {
|
|
665
670
|
// Local data store does not have initial summary.
|
|
666
671
|
return {};
|
|
@@ -691,6 +696,7 @@ class LocalDetachedFluidDataStoreContext extends LocalFluidDataStoreContextBase
|
|
|
691
696
|
this.detachedRuntimeCreation = true;
|
|
692
697
|
}
|
|
693
698
|
async attachRuntime(registry, dataStoreChannel) {
|
|
699
|
+
var _a;
|
|
694
700
|
(0, common_utils_1.assert)(this.detachedRuntimeCreation, 0x154 /* "runtime creation is already attached" */);
|
|
695
701
|
this.detachedRuntimeCreation = false;
|
|
696
702
|
(0, common_utils_1.assert)(this.channelDeferred === undefined, 0x155 /* "channel deferral is already set" */);
|
|
@@ -701,6 +707,14 @@ class LocalDetachedFluidDataStoreContext extends LocalFluidDataStoreContextBase
|
|
|
701
707
|
(0, common_utils_1.assert)(this.registry === undefined, 0x157 /* "datastore registry already attached" */);
|
|
702
708
|
this.registry = entry.registry;
|
|
703
709
|
super.bindRuntime(dataStoreChannel);
|
|
710
|
+
// Load the handle to the data store's entryPoint to make sure that for a detached data store, the entryPoint
|
|
711
|
+
// initialization function is called before the data store gets attached and potentially connected to the
|
|
712
|
+
// delta stream, so it gets a chance to do things while the data store is still "purely local".
|
|
713
|
+
// This preserves the behavior from before we introduced entryPoints, where the instantiateDataStore method
|
|
714
|
+
// of data store factories tends to construct the data object (at least kick off an async method that returns
|
|
715
|
+
// it); that code moved to the entryPoint initialization function, so we want to ensure it still executes
|
|
716
|
+
// before the data store is attached.
|
|
717
|
+
await ((_a = dataStoreChannel.entryPoint) === null || _a === void 0 ? void 0 : _a.get());
|
|
704
718
|
if (await this.isRoot()) {
|
|
705
719
|
dataStoreChannel.makeVisibleAndAttachGraph();
|
|
706
720
|
}
|