@fluidframework/container-runtime 1.2.7 → 2.0.0-dev.1.3.0.96595
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/.mocharc.js +12 -0
- package/dist/batchManager.d.ts +37 -0
- package/dist/batchManager.d.ts.map +1 -0
- package/dist/batchManager.js +73 -0
- package/dist/batchManager.js.map +1 -0
- package/dist/batchTracker.d.ts +1 -2
- package/dist/batchTracker.d.ts.map +1 -1
- package/dist/batchTracker.js +2 -3
- package/dist/batchTracker.js.map +1 -1
- package/dist/blobManager.d.ts +87 -25
- package/dist/blobManager.d.ts.map +1 -1
- package/dist/blobManager.js +317 -99
- package/dist/blobManager.js.map +1 -1
- package/dist/containerRuntime.d.ts +109 -124
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +349 -542
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStore.js +29 -24
- package/dist/dataStore.js.map +1 -1
- package/dist/dataStoreContext.d.ts +20 -14
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js +49 -58
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/dataStores.d.ts +12 -5
- package/dist/dataStores.d.ts.map +1 -1
- package/dist/dataStores.js +21 -20
- package/dist/dataStores.js.map +1 -1
- package/dist/deltaScheduler.d.ts +6 -4
- package/dist/deltaScheduler.d.ts.map +1 -1
- package/dist/deltaScheduler.js +6 -4
- package/dist/deltaScheduler.js.map +1 -1
- package/dist/garbageCollection.d.ts +74 -14
- package/dist/garbageCollection.d.ts.map +1 -1
- package/dist/garbageCollection.js +249 -170
- package/dist/garbageCollection.js.map +1 -1
- package/dist/gcSweepReadyUsageDetection.d.ts +53 -0
- package/dist/gcSweepReadyUsageDetection.d.ts.map +1 -0
- package/dist/gcSweepReadyUsageDetection.js +126 -0
- package/dist/gcSweepReadyUsageDetection.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/opProperties.d.ts +7 -0
- package/dist/opProperties.d.ts.map +1 -0
- package/dist/opProperties.js +20 -0
- package/dist/opProperties.js.map +1 -0
- package/dist/orderedClientElection.d.ts +28 -10
- package/dist/orderedClientElection.d.ts.map +1 -1
- package/dist/orderedClientElection.js +14 -4
- package/dist/orderedClientElection.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/pendingStateManager.d.ts +0 -11
- package/dist/pendingStateManager.d.ts.map +1 -1
- package/dist/pendingStateManager.js +24 -46
- package/dist/pendingStateManager.js.map +1 -1
- package/dist/runningSummarizer.d.ts +14 -4
- package/dist/runningSummarizer.d.ts.map +1 -1
- package/dist/runningSummarizer.js +68 -26
- package/dist/runningSummarizer.js.map +1 -1
- package/dist/scheduleManager.d.ts +31 -0
- package/dist/scheduleManager.d.ts.map +1 -0
- package/dist/scheduleManager.js +243 -0
- package/dist/scheduleManager.js.map +1 -0
- package/dist/summarizer.d.ts +0 -2
- package/dist/summarizer.d.ts.map +1 -1
- package/dist/summarizer.js +1 -12
- package/dist/summarizer.js.map +1 -1
- package/dist/summarizerHeuristics.d.ts +26 -4
- package/dist/summarizerHeuristics.d.ts.map +1 -1
- package/dist/summarizerHeuristics.js +95 -18
- package/dist/summarizerHeuristics.js.map +1 -1
- package/dist/summarizerTypes.d.ts +45 -18
- package/dist/summarizerTypes.d.ts.map +1 -1
- package/dist/summarizerTypes.js +1 -1
- package/dist/summarizerTypes.js.map +1 -1
- package/dist/summaryCollection.d.ts +1 -0
- package/dist/summaryCollection.d.ts.map +1 -1
- package/dist/summaryCollection.js +31 -15
- package/dist/summaryCollection.js.map +1 -1
- package/dist/summaryFormat.d.ts +0 -5
- package/dist/summaryFormat.d.ts.map +1 -1
- package/dist/summaryFormat.js.map +1 -1
- package/dist/summaryGenerator.d.ts +1 -0
- package/dist/summaryGenerator.d.ts.map +1 -1
- package/dist/summaryGenerator.js +11 -9
- package/dist/summaryGenerator.js.map +1 -1
- package/dist/summaryManager.d.ts +2 -2
- package/dist/summaryManager.d.ts.map +1 -1
- package/dist/summaryManager.js +22 -7
- package/dist/summaryManager.js.map +1 -1
- package/lib/batchManager.d.ts +37 -0
- package/lib/batchManager.d.ts.map +1 -0
- package/lib/batchManager.js +69 -0
- package/lib/batchManager.js.map +1 -0
- package/lib/batchTracker.d.ts +1 -2
- package/lib/batchTracker.d.ts.map +1 -1
- package/lib/batchTracker.js +2 -3
- package/lib/batchTracker.js.map +1 -1
- package/lib/blobManager.d.ts +87 -25
- package/lib/blobManager.d.ts.map +1 -1
- package/lib/blobManager.js +319 -101
- package/lib/blobManager.js.map +1 -1
- package/lib/containerRuntime.d.ts +109 -124
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +355 -547
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStore.js +29 -24
- package/lib/dataStore.js.map +1 -1
- package/lib/dataStoreContext.d.ts +20 -14
- package/lib/dataStoreContext.d.ts.map +1 -1
- package/lib/dataStoreContext.js +46 -55
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/dataStores.d.ts +12 -5
- package/lib/dataStores.d.ts.map +1 -1
- package/lib/dataStores.js +21 -20
- package/lib/dataStores.js.map +1 -1
- package/lib/deltaScheduler.d.ts +6 -4
- package/lib/deltaScheduler.d.ts.map +1 -1
- package/lib/deltaScheduler.js +6 -4
- package/lib/deltaScheduler.js.map +1 -1
- package/lib/garbageCollection.d.ts +74 -14
- package/lib/garbageCollection.d.ts.map +1 -1
- package/lib/garbageCollection.js +238 -160
- package/lib/garbageCollection.js.map +1 -1
- package/lib/gcSweepReadyUsageDetection.d.ts +53 -0
- package/lib/gcSweepReadyUsageDetection.d.ts.map +1 -0
- package/lib/gcSweepReadyUsageDetection.js +121 -0
- package/lib/gcSweepReadyUsageDetection.js.map +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/opProperties.d.ts +7 -0
- package/lib/opProperties.d.ts.map +1 -0
- package/lib/opProperties.js +16 -0
- package/lib/opProperties.js.map +1 -0
- package/lib/orderedClientElection.d.ts +28 -10
- package/lib/orderedClientElection.d.ts.map +1 -1
- package/lib/orderedClientElection.js +14 -4
- package/lib/orderedClientElection.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/pendingStateManager.d.ts +0 -11
- package/lib/pendingStateManager.d.ts.map +1 -1
- package/lib/pendingStateManager.js +24 -46
- package/lib/pendingStateManager.js.map +1 -1
- package/lib/runningSummarizer.d.ts +14 -4
- package/lib/runningSummarizer.d.ts.map +1 -1
- package/lib/runningSummarizer.js +68 -26
- package/lib/runningSummarizer.js.map +1 -1
- package/lib/scheduleManager.d.ts +31 -0
- package/lib/scheduleManager.d.ts.map +1 -0
- package/lib/scheduleManager.js +239 -0
- package/lib/scheduleManager.js.map +1 -0
- package/lib/summarizer.d.ts +0 -2
- package/lib/summarizer.d.ts.map +1 -1
- package/lib/summarizer.js +1 -12
- package/lib/summarizer.js.map +1 -1
- package/lib/summarizerHeuristics.d.ts +26 -4
- package/lib/summarizerHeuristics.d.ts.map +1 -1
- package/lib/summarizerHeuristics.js +95 -18
- package/lib/summarizerHeuristics.js.map +1 -1
- package/lib/summarizerTypes.d.ts +45 -18
- package/lib/summarizerTypes.d.ts.map +1 -1
- package/lib/summarizerTypes.js +1 -1
- package/lib/summarizerTypes.js.map +1 -1
- package/lib/summaryCollection.d.ts +1 -0
- package/lib/summaryCollection.d.ts.map +1 -1
- package/lib/summaryCollection.js +31 -15
- package/lib/summaryCollection.js.map +1 -1
- package/lib/summaryFormat.d.ts +0 -5
- package/lib/summaryFormat.d.ts.map +1 -1
- package/lib/summaryFormat.js.map +1 -1
- package/lib/summaryGenerator.d.ts +1 -0
- package/lib/summaryGenerator.d.ts.map +1 -1
- package/lib/summaryGenerator.js +11 -9
- package/lib/summaryGenerator.js.map +1 -1
- package/lib/summaryManager.d.ts +2 -2
- package/lib/summaryManager.d.ts.map +1 -1
- package/lib/summaryManager.js +22 -7
- package/lib/summaryManager.js.map +1 -1
- package/package.json +65 -24
- package/src/batchManager.ts +91 -0
- package/src/batchTracker.ts +2 -3
- package/src/blobManager.ts +385 -118
- package/src/containerRuntime.ts +529 -740
- package/src/dataStore.ts +49 -37
- package/src/dataStoreContext.ts +44 -56
- package/src/dataStores.ts +34 -30
- package/src/deltaScheduler.ts +6 -4
- package/src/garbageCollection.ts +297 -206
- package/src/gcSweepReadyUsageDetection.ts +139 -0
- package/src/index.ts +1 -2
- package/src/opProperties.ts +19 -0
- package/src/orderedClientElection.ts +31 -10
- package/src/packageVersion.ts +1 -1
- package/src/pendingStateManager.ts +27 -59
- package/src/runningSummarizer.ts +75 -22
- package/src/scheduleManager.ts +314 -0
- package/src/summarizer.ts +1 -18
- package/src/summarizerHeuristics.ts +133 -19
- package/src/summarizerTypes.ts +53 -18
- package/src/summaryCollection.ts +33 -18
- package/src/summaryFormat.ts +0 -6
- package/src/summaryGenerator.ts +40 -22
- package/src/summaryManager.ts +22 -7
- package/dist/opTelemetry.d.ts +0 -22
- package/dist/opTelemetry.d.ts.map +0 -1
- package/dist/opTelemetry.js +0 -59
- package/dist/opTelemetry.js.map +0 -1
- package/lib/opTelemetry.d.ts +0 -22
- package/lib/opTelemetry.d.ts.map +0 -1
- package/lib/opTelemetry.js +0 -55
- package/lib/opTelemetry.js.map +0 -1
- package/src/opTelemetry.ts +0 -71
package/dist/dataStore.js
CHANGED
|
@@ -36,6 +36,7 @@ class DataStore {
|
|
|
36
36
|
this.datastores = datastores;
|
|
37
37
|
this.logger = logger;
|
|
38
38
|
this.aliasState = AliasState.None;
|
|
39
|
+
this.pendingAliases = datastores.pendingAliases;
|
|
39
40
|
}
|
|
40
41
|
async trySetAlias(alias) {
|
|
41
42
|
if (alias.includes("/")) {
|
|
@@ -52,13 +53,22 @@ class DataStore {
|
|
|
52
53
|
// is a repeated call for the same alias
|
|
53
54
|
case AliasState.Aliased:
|
|
54
55
|
return this.alias === alias ? "Success" : "AlreadyAliased";
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
case AliasState.None: {
|
|
57
|
+
const existingAlias = this.pendingAliases.get(alias);
|
|
58
|
+
if (existingAlias !== undefined) {
|
|
59
|
+
// There is already another datastore which will be aliased
|
|
60
|
+
// to the same name
|
|
61
|
+
return "Conflict";
|
|
62
|
+
}
|
|
63
|
+
// There is no current or past alias operation for this datastore,
|
|
64
|
+
// or for this alias, so it is safe to continue execution
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
58
67
|
default: (0, common_utils_1.unreachableCase)(this.aliasState);
|
|
59
68
|
}
|
|
60
69
|
this.aliasState = AliasState.Aliasing;
|
|
61
70
|
this.aliasResult = this.trySetAliasInternal(alias);
|
|
71
|
+
this.pendingAliases.set(alias, this.aliasResult);
|
|
62
72
|
return this.aliasResult;
|
|
63
73
|
}
|
|
64
74
|
async trySetAliasInternal(alias) {
|
|
@@ -66,14 +76,7 @@ class DataStore {
|
|
|
66
76
|
internalId: this.internalId,
|
|
67
77
|
alias,
|
|
68
78
|
};
|
|
69
|
-
|
|
70
|
-
// older versions, we still have to call bindToContext.
|
|
71
|
-
if (this.fluidDataStoreChannel.makeVisibleAndAttachGraph !== undefined) {
|
|
72
|
-
this.fluidDataStoreChannel.makeVisibleAndAttachGraph();
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
this.fluidDataStoreChannel.bindToContext();
|
|
76
|
-
}
|
|
79
|
+
this.fluidDataStoreChannel.makeVisibleAndAttachGraph();
|
|
77
80
|
if (this.runtime.attachState === container_definitions_1.AttachState.Detached) {
|
|
78
81
|
const localResult = this.datastores.processAliasMessageCore(message);
|
|
79
82
|
// Explicitly lock-out future attempts of aliasing,
|
|
@@ -81,17 +84,11 @@ class DataStore {
|
|
|
81
84
|
this.aliasState = AliasState.Aliased;
|
|
82
85
|
return localResult ? "Success" : "Conflict";
|
|
83
86
|
}
|
|
84
|
-
const aliased = await this
|
|
87
|
+
const aliased = await this
|
|
88
|
+
.ackBasedPromise((resolve) => {
|
|
85
89
|
this.runtime.submitDataStoreAliasOp(message, resolve);
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
// regardless of result
|
|
89
|
-
this.aliasState = AliasState.Aliased;
|
|
90
|
-
if (succeeded) {
|
|
91
|
-
this.alias = alias;
|
|
92
|
-
}
|
|
93
|
-
return succeeded;
|
|
94
|
-
}).catch((error) => {
|
|
90
|
+
})
|
|
91
|
+
.catch((error) => {
|
|
95
92
|
this.logger.sendErrorEvent({
|
|
96
93
|
eventName: "AliasingException",
|
|
97
94
|
alias: {
|
|
@@ -100,13 +97,21 @@ class DataStore {
|
|
|
100
97
|
},
|
|
101
98
|
internalId: {
|
|
102
99
|
value: this.internalId,
|
|
103
|
-
tag: telemetry_utils_1.TelemetryDataTag.
|
|
100
|
+
tag: telemetry_utils_1.TelemetryDataTag.CodeArtifact,
|
|
104
101
|
},
|
|
105
102
|
}, error);
|
|
106
|
-
this.aliasState = AliasState.None;
|
|
107
103
|
return false;
|
|
104
|
+
}).finally(() => {
|
|
105
|
+
this.pendingAliases.delete(alias);
|
|
108
106
|
});
|
|
109
|
-
|
|
107
|
+
if (!aliased) {
|
|
108
|
+
this.aliasState = AliasState.None;
|
|
109
|
+
this.aliasResult = undefined;
|
|
110
|
+
return "Conflict";
|
|
111
|
+
}
|
|
112
|
+
this.alias = alias;
|
|
113
|
+
this.aliasState = AliasState.Aliased;
|
|
114
|
+
return "Success";
|
|
110
115
|
}
|
|
111
116
|
async request(request) {
|
|
112
117
|
return this.fluidDataStoreChannel.request(request);
|
package/dist/dataStore.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
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AC;IAC5C,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAiB;QAC3B,OAAO,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvD,CAAC;IASD,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 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 // There is no current or past alias operation for this datastore,\n // it is safe to continue execution\n case AliasState.None: break;\n default: unreachableCase(this.aliasState);\n }\n\n this.aliasState = AliasState.Aliasing;\n this.aliasResult = this.trySetAliasInternal(alias);\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 // back-compat 0.58.2000 - makeVisibleAndAttachGraph was added in this version to IFluidDataStoreChannel. For\n // older versions, we still have to call bindToContext.\n if (this.fluidDataStoreChannel.makeVisibleAndAttachGraph !== undefined) {\n this.fluidDataStoreChannel.makeVisibleAndAttachGraph();\n } else {\n this.fluidDataStoreChannel.bindToContext();\n }\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.ackBasedPromise<boolean>((resolve) => {\n this.runtime.submitDataStoreAliasOp(message, resolve);\n }).then((succeeded) => {\n // Explicitly Lock-out future attempts of aliasing,\n // regardless of result\n this.aliasState = AliasState.Aliased;\n if (succeeded) {\n this.alias = alias;\n }\n\n return succeeded;\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.PackageData,\n },\n }, error);\n this.aliasState = AliasState.None;\n return false;\n });\n\n return aliased ? \"Success\" : \"Conflict\";\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 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;AAG7D,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;IAoGX,YACqB,qBAA6C,EAC7C,UAAkB,EAClB,OAAyB,EACzB,UAAsB,EACtB,MAAwB;QAJxB,0BAAqB,GAArB,qBAAqB,CAAwB;QAC7C,eAAU,GAAV,UAAU,CAAQ;QA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ACP,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"]}
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { IDisposable, ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
6
6
|
import { FluidObject, IRequest, IResponse, IFluidHandle } from "@fluidframework/core-interfaces";
|
|
7
|
-
import { IAudience, IDeltaManager,
|
|
7
|
+
import { IAudience, IDeltaManager, AttachState, ILoaderOptions } from "@fluidframework/container-definitions";
|
|
8
8
|
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 { CreateChildSummarizerNodeFn, CreateChildSummarizerNodeParam, IAttachMessage, IFluidDataStoreChannel, IFluidDataStoreContext, IFluidDataStoreContextDetached, IFluidDataStoreContextEvents, IFluidDataStoreRegistry, IGarbageCollectionData, IGarbageCollectionDetailsBase, IGarbageCollectionSummaryDetails, IInboundSignalMessage, IProvideFluidDataStoreFactory, ISummarizeResult, ISummarizerNodeWithGC, SummarizeInternalFn, ITelemetryContext } from "@fluidframework/runtime-definitions";
|
|
12
|
+
import { BindState, CreateChildSummarizerNodeFn, CreateChildSummarizerNodeParam, IAttachMessage, IFluidDataStoreChannel, IFluidDataStoreContext, IFluidDataStoreContextDetached, IFluidDataStoreContextEvents, IFluidDataStoreRegistry, IGarbageCollectionData, IGarbageCollectionDetailsBase, IGarbageCollectionSummaryDetails, IInboundSignalMessage, IProvideFluidDataStoreFactory, ISummarizeResult, ISummarizerNodeWithGC, SummarizeInternalFn, ITelemetryContext } from "@fluidframework/runtime-definitions";
|
|
13
13
|
import { ContainerRuntime } from "./containerRuntime";
|
|
14
|
-
export declare function createAttributesBlob(pkg: readonly string[], isRootDataStore: boolean
|
|
14
|
+
export declare function createAttributesBlob(pkg: readonly string[], isRootDataStore: boolean): ITreeEntry;
|
|
15
15
|
interface ISnapshotDetails {
|
|
16
16
|
pkg: readonly string[];
|
|
17
17
|
isRootDataStore: boolean;
|
|
@@ -25,7 +25,6 @@ export interface IFluidDataStoreContextProps {
|
|
|
25
25
|
readonly scope: FluidObject;
|
|
26
26
|
readonly createSummarizerNodeFn: CreateChildSummarizerNodeFn;
|
|
27
27
|
readonly writeGCDataAtRoot: boolean;
|
|
28
|
-
readonly disableIsolatedChannels: boolean;
|
|
29
28
|
readonly pkg?: Readonly<string[]>;
|
|
30
29
|
}
|
|
31
30
|
/** Properties necessary for creating a local FluidDataStoreContext */
|
|
@@ -84,6 +83,7 @@ export declare abstract class FluidDataStoreContext extends TypedEventEmitter<IF
|
|
|
84
83
|
protected isInMemoryRoot(): boolean;
|
|
85
84
|
protected registry: IFluidDataStoreRegistry | undefined;
|
|
86
85
|
protected detachedRuntimeCreation: boolean;
|
|
86
|
+
/** @deprecated - To be replaced by calling makeLocallyVisible directly */
|
|
87
87
|
readonly bindToContext: () => void;
|
|
88
88
|
protected channel: IFluidDataStoreChannel | undefined;
|
|
89
89
|
private loaded;
|
|
@@ -102,9 +102,9 @@ export declare abstract class FluidDataStoreContext extends TypedEventEmitter<IF
|
|
|
102
102
|
readonly storage: IDocumentStorageService;
|
|
103
103
|
readonly scope: FluidObject;
|
|
104
104
|
private readonly writeGCDataAtRoot;
|
|
105
|
-
protected readonly disableIsolatedChannels: boolean;
|
|
106
105
|
protected pkg?: readonly string[];
|
|
107
|
-
constructor(props: IFluidDataStoreContextProps, existing: boolean, bindState: BindState,
|
|
106
|
+
constructor(props: IFluidDataStoreContextProps, existing: boolean, bindState: BindState, // Used to assert for state tracking purposes
|
|
107
|
+
isLocalDataStore: boolean, makeLocallyVisibleFn: () => void);
|
|
108
108
|
dispose(): void;
|
|
109
109
|
private rejectDeferredRealize;
|
|
110
110
|
realize(): Promise<IFluidDataStoreChannel>;
|
|
@@ -116,8 +116,8 @@ export declare abstract class FluidDataStoreContext extends TypedEventEmitter<IF
|
|
|
116
116
|
/**
|
|
117
117
|
* Notifies this object about changes in the connection state.
|
|
118
118
|
* @param value - New connection state.
|
|
119
|
-
* @param clientId - ID of the client.
|
|
120
|
-
*
|
|
119
|
+
* @param clientId - ID of the client. Its old ID when in disconnected state and
|
|
120
|
+
* its new client ID when we are connecting or connected.
|
|
121
121
|
*/
|
|
122
122
|
setConnectionState(connected: boolean, clientId?: string): void;
|
|
123
123
|
process(messageArg: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
|
|
@@ -149,12 +149,18 @@ export declare abstract class FluidDataStoreContext extends TypedEventEmitter<IF
|
|
|
149
149
|
private getGCDataInternal;
|
|
150
150
|
/**
|
|
151
151
|
* After GC has run, called to notify the data store of routes used in it. These are used for the following:
|
|
152
|
+
*
|
|
152
153
|
* 1. To identify if this data store is being referenced in the document or not.
|
|
154
|
+
*
|
|
153
155
|
* 2. To determine if it needs to re-summarize in case used routes changed since last summary.
|
|
156
|
+
*
|
|
154
157
|
* 3. These are added to the summary generated by the data store.
|
|
155
|
-
*
|
|
156
|
-
*
|
|
158
|
+
*
|
|
159
|
+
* 4. To notify child contexts of their used routes. This is done immediately if the data store is loaded.
|
|
160
|
+
* Else, it is done when realizing the data store.
|
|
161
|
+
*
|
|
157
162
|
* 5. To update the timestamp when this data store or any children are marked as unreferenced.
|
|
163
|
+
*
|
|
158
164
|
* @param usedRoutes - The routes that are used in this data store.
|
|
159
165
|
* @param gcTimestamp - The time when GC was run that generated these used routes. If any node becomes unreferenced
|
|
160
166
|
* as part of this GC run, this should be used to update the time when it happens.
|
|
@@ -200,13 +206,13 @@ export declare abstract class FluidDataStoreContext extends TypedEventEmitter<IF
|
|
|
200
206
|
abstract generateAttachMessage(): IAttachMessage;
|
|
201
207
|
abstract getInitialSnapshotDetails(): Promise<ISnapshotDetails>;
|
|
202
208
|
/**
|
|
203
|
-
* @deprecated
|
|
209
|
+
* @deprecated Sets the datastore as root, for aliasing purposes: #7948
|
|
204
210
|
* This method should not be used outside of the aliasing context.
|
|
205
211
|
* It will be removed, as the source of truth for this flag will be the aliasing blob.
|
|
206
212
|
*/
|
|
207
213
|
setInMemoryRoot(): void;
|
|
208
214
|
/**
|
|
209
|
-
* @deprecated
|
|
215
|
+
* @deprecated Renamed to `{@link FluidDataStoreContext.getBaseGCDetails}()`.
|
|
210
216
|
*/
|
|
211
217
|
abstract getInitialGCSummaryDetails(): Promise<IGarbageCollectionSummaryDetails>;
|
|
212
218
|
abstract getBaseGCDetails(): Promise<IGarbageCollectionDetailsBase>;
|
|
@@ -224,7 +230,7 @@ export declare class RemoteFluidDataStoreContext extends FluidDataStoreContext {
|
|
|
224
230
|
private readonly initialSnapshotDetailsP;
|
|
225
231
|
getInitialSnapshotDetails(): Promise<ISnapshotDetails>;
|
|
226
232
|
/**
|
|
227
|
-
* @deprecated
|
|
233
|
+
* @deprecated Renamed to {@link RemoteFluidDataStoreContext.getBaseGCDetails}.
|
|
228
234
|
*/
|
|
229
235
|
getInitialGCSummaryDetails(): Promise<IGarbageCollectionSummaryDetails>;
|
|
230
236
|
getBaseGCDetails(): Promise<IGarbageCollectionDetailsBase>;
|
|
@@ -244,7 +250,7 @@ export declare class LocalFluidDataStoreContextBase extends FluidDataStoreContex
|
|
|
244
250
|
generateAttachMessage(): IAttachMessage;
|
|
245
251
|
getInitialSnapshotDetails(): Promise<ISnapshotDetails>;
|
|
246
252
|
/**
|
|
247
|
-
* @deprecated
|
|
253
|
+
* @deprecated Renamed to {@link LocalFluidDataStoreContextBase.getBaseGCDetails}.
|
|
248
254
|
*/
|
|
249
255
|
getInitialGCSummaryDetails(): Promise<IGarbageCollectionSummaryDetails>;
|
|
250
256
|
getBaseGCDetails(): Promise<IGarbageCollectionDetailsBase>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataStoreContext.d.ts","sourceRoot":"","sources":["../src/dataStoreContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EACH,WAAW,EACX,QAAQ,EACR,SAAS,EACT,YAAY,EACf,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,SAAS,EACT,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"dataStoreContext.d.ts","sourceRoot":"","sources":["../src/dataStoreContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACnF,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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,CAAC,QAAQ,CAAC,iBAAiB,CAAqC;IACvE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAyC;gBAE5D,KAAK,EAAE,iCAAiC;IAiBpD,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAsDrC;IAEU,yBAAyB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAInE;;OAEG;IACU,0BAA0B,IAAI,OAAO,CAAC,gCAAgC,CAAC;IAIvE,gBAAgB,IAAI,OAAO,CAAC,6BAA6B,CAAC;IAIhE,qBAAqB,IAAI,cAAc;CAGjD;AAED;;GAEG;AACH,qBAAa,8BAA+B,SAAQ,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;IAiCnE;;OAEG;IACU,0BAA0B,IAAI,OAAO,CAAC,gCAAgC,CAAC;IAKvE,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;IAsB/B,yBAAyB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAMtE"}
|
package/dist/dataStoreContext.js
CHANGED
|
@@ -14,20 +14,16 @@ 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
|
-
function createAttributes(pkg, isRootDataStore
|
|
17
|
+
function createAttributes(pkg, isRootDataStore) {
|
|
18
18
|
const stringifiedPkg = JSON.stringify(pkg);
|
|
19
|
-
return
|
|
20
|
-
pkg: stringifiedPkg,
|
|
21
|
-
snapshotFormatVersion: "0.1",
|
|
22
|
-
isRootDataStore,
|
|
23
|
-
} : {
|
|
19
|
+
return {
|
|
24
20
|
pkg: stringifiedPkg,
|
|
25
21
|
summaryFormatVersion: 2,
|
|
26
22
|
isRootDataStore,
|
|
27
23
|
};
|
|
28
24
|
}
|
|
29
|
-
function createAttributesBlob(pkg, isRootDataStore
|
|
30
|
-
const attributes = createAttributes(pkg, isRootDataStore
|
|
25
|
+
function createAttributesBlob(pkg, isRootDataStore) {
|
|
26
|
+
const attributes = createAttributes(pkg, isRootDataStore);
|
|
31
27
|
return new protocol_base_1.BlobTreeEntry(summaryFormat_1.dataStoreAttributesBlobName, JSON.stringify(attributes));
|
|
32
28
|
}
|
|
33
29
|
exports.createAttributesBlob = createAttributesBlob;
|
|
@@ -35,7 +31,8 @@ exports.createAttributesBlob = createAttributesBlob;
|
|
|
35
31
|
* Represents the context for the store. This context is passed to the store runtime.
|
|
36
32
|
*/
|
|
37
33
|
class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
38
|
-
constructor(props, existing, bindState,
|
|
34
|
+
constructor(props, existing, bindState, // Used to assert for state tracking purposes
|
|
35
|
+
isLocalDataStore, makeLocallyVisibleFn) {
|
|
39
36
|
super();
|
|
40
37
|
this.existing = existing;
|
|
41
38
|
this.bindState = bindState;
|
|
@@ -51,7 +48,6 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
51
48
|
this.storage = props.storage;
|
|
52
49
|
this.scope = props.scope;
|
|
53
50
|
this.writeGCDataAtRoot = props.writeGCDataAtRoot;
|
|
54
|
-
this.disableIsolatedChannels = props.disableIsolatedChannels;
|
|
55
51
|
this.pkg = props.pkg;
|
|
56
52
|
// URIs use slashes as delimiters. Handles use URIs.
|
|
57
53
|
// Thus having slashes in types almost guarantees trouble down the road!
|
|
@@ -59,11 +55,11 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
59
55
|
this._attachState = this.containerRuntime.attachState !== container_definitions_1.AttachState.Detached && this.existing ?
|
|
60
56
|
this.containerRuntime.attachState : container_definitions_1.AttachState.Detached;
|
|
61
57
|
this.bindToContext = () => {
|
|
62
|
-
(0, common_utils_1.assert)(this.bindState ===
|
|
63
|
-
this.bindState =
|
|
58
|
+
(0, common_utils_1.assert)(this.bindState === runtime_definitions_1.BindState.NotBound, 0x13b /* "datastore context is already in bound state" */);
|
|
59
|
+
this.bindState = runtime_definitions_1.BindState.Binding;
|
|
64
60
|
(0, common_utils_1.assert)(this.channel !== undefined, 0x13c /* "undefined channel on datastore context" */);
|
|
65
61
|
this.makeLocallyVisible();
|
|
66
|
-
this.bindState =
|
|
62
|
+
this.bindState = runtime_definitions_1.BindState.Bound;
|
|
67
63
|
};
|
|
68
64
|
const thisSummarizeInternal = async (fullTree, trackState, telemetryContext) => this.summarizeInternal(fullTree, trackState, telemetryContext);
|
|
69
65
|
this.summarizerNode = props.createSummarizerNodeFn(thisSummarizeInternal, async (fullGC) => this.getGCDataInternal(fullGC), async () => this.getBaseGCDetails());
|
|
@@ -144,7 +140,7 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
144
140
|
}
|
|
145
141
|
}
|
|
146
142
|
rejectDeferredRealize(reason, packageName) {
|
|
147
|
-
throw new telemetry_utils_1.LoggingError(reason, { packageName: { value: packageName, tag: telemetry_utils_1.TelemetryDataTag.
|
|
143
|
+
throw new telemetry_utils_1.LoggingError(reason, { packageName: { value: packageName, tag: telemetry_utils_1.TelemetryDataTag.CodeArtifact } });
|
|
148
144
|
}
|
|
149
145
|
async realize() {
|
|
150
146
|
(0, common_utils_1.assert)(!this.detachedRuntimeCreation, 0x13d /* "Detached runtime creation on realize()" */);
|
|
@@ -153,7 +149,12 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
153
149
|
this.realizeCore(this.existing).catch((error) => {
|
|
154
150
|
var _a;
|
|
155
151
|
const errorWrapped = container_utils_1.DataProcessingError.wrapIfUnrecognized(error, "realizeFluidDataStoreContext");
|
|
156
|
-
errorWrapped.addTelemetryProperties({
|
|
152
|
+
errorWrapped.addTelemetryProperties({
|
|
153
|
+
fluidDataStoreId: {
|
|
154
|
+
value: this.id,
|
|
155
|
+
tag: telemetry_utils_1.TelemetryDataTag.CodeArtifact,
|
|
156
|
+
},
|
|
157
|
+
});
|
|
157
158
|
(_a = this.channelDeferred) === null || _a === void 0 ? void 0 : _a.reject(errorWrapped);
|
|
158
159
|
this.logger.sendErrorEvent({ eventName: "RealizeError" }, errorWrapped);
|
|
159
160
|
});
|
|
@@ -202,8 +203,8 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
202
203
|
/**
|
|
203
204
|
* Notifies this object about changes in the connection state.
|
|
204
205
|
* @param value - New connection state.
|
|
205
|
-
* @param clientId - ID of the client.
|
|
206
|
-
*
|
|
206
|
+
* @param clientId - ID of the client. Its old ID when in disconnected state and
|
|
207
|
+
* its new client ID when we are connecting or connected.
|
|
207
208
|
*/
|
|
208
209
|
setConnectionState(connected, clientId) {
|
|
209
210
|
this.verifyNotClosed();
|
|
@@ -259,16 +260,13 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
259
260
|
await this.realize();
|
|
260
261
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
261
262
|
const summarizeResult = await this.channel.summarize(fullTree, trackState, telemetryContext);
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
(0, summaryFormat_1.wrapSummaryInChannelsTree)(summarizeResult);
|
|
266
|
-
pathPartsForChildren = [runtime_definitions_1.channelsTreeName];
|
|
267
|
-
}
|
|
263
|
+
// Wrap dds summaries in .channels subtree.
|
|
264
|
+
(0, summaryFormat_1.wrapSummaryInChannelsTree)(summarizeResult);
|
|
265
|
+
const pathPartsForChildren = [runtime_definitions_1.channelsTreeName];
|
|
268
266
|
// Add data store's attributes to the summary.
|
|
269
267
|
const { pkg } = await this.getInitialSnapshotDetails();
|
|
270
268
|
const isRoot = await this.isRoot();
|
|
271
|
-
const attributes = createAttributes(pkg, isRoot
|
|
269
|
+
const attributes = createAttributes(pkg, isRoot);
|
|
272
270
|
(0, runtime_utils_1.addBlobToSummary)(summarizeResult, summaryFormat_1.dataStoreAttributesBlobName, JSON.stringify(attributes));
|
|
273
271
|
// Add GC data to the summary if it's not written at the root.
|
|
274
272
|
if (!this.writeGCDataAtRoot) {
|
|
@@ -305,12 +303,18 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
305
303
|
}
|
|
306
304
|
/**
|
|
307
305
|
* After GC has run, called to notify the data store of routes used in it. These are used for the following:
|
|
306
|
+
*
|
|
308
307
|
* 1. To identify if this data store is being referenced in the document or not.
|
|
308
|
+
*
|
|
309
309
|
* 2. To determine if it needs to re-summarize in case used routes changed since last summary.
|
|
310
|
+
*
|
|
310
311
|
* 3. These are added to the summary generated by the data store.
|
|
311
|
-
*
|
|
312
|
-
*
|
|
312
|
+
*
|
|
313
|
+
* 4. To notify child contexts of their used routes. This is done immediately if the data store is loaded.
|
|
314
|
+
* Else, it is done when realizing the data store.
|
|
315
|
+
*
|
|
313
316
|
* 5. To update the timestamp when this data store or any children are marked as unreferenced.
|
|
317
|
+
*
|
|
314
318
|
* @param usedRoutes - The routes that are used in this data store.
|
|
315
319
|
* @param gcTimestamp - The time when GC was run that generated these used routes. If any node becomes unreferenced
|
|
316
320
|
* as part of this GC run, this should be used to update the time when it happens.
|
|
@@ -442,7 +446,10 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
442
446
|
}
|
|
443
447
|
catch (error) {
|
|
444
448
|
(_a = this.channelDeferred) === null || _a === void 0 ? void 0 : _a.reject(error);
|
|
445
|
-
this.logger.sendErrorEvent({ eventName: "BindRuntimeError", fluidDataStoreId: {
|
|
449
|
+
this.logger.sendErrorEvent({ eventName: "BindRuntimeError", fluidDataStoreId: {
|
|
450
|
+
value: this.id,
|
|
451
|
+
tag: telemetry_utils_1.TelemetryDataTag.CodeArtifact,
|
|
452
|
+
} }, error);
|
|
446
453
|
}
|
|
447
454
|
}
|
|
448
455
|
async getAbsoluteUrl(relativeUrl) {
|
|
@@ -452,7 +459,7 @@ class FluidDataStoreContext extends common_utils_1.TypedEventEmitter {
|
|
|
452
459
|
return this._containerRuntime.getAbsoluteUrl(relativeUrl);
|
|
453
460
|
}
|
|
454
461
|
/**
|
|
455
|
-
* @deprecated
|
|
462
|
+
* @deprecated Sets the datastore as root, for aliasing purposes: #7948
|
|
456
463
|
* This method should not be used outside of the aliasing context.
|
|
457
464
|
* It will be removed, as the source of truth for this flag will be the aliasing blob.
|
|
458
465
|
*/
|
|
@@ -500,7 +507,7 @@ exports.FluidDataStoreContext = FluidDataStoreContext;
|
|
|
500
507
|
FluidDataStoreContext.pendingOpsCountThreshold = 1000;
|
|
501
508
|
class RemoteFluidDataStoreContext extends FluidDataStoreContext {
|
|
502
509
|
constructor(props) {
|
|
503
|
-
super(props, true /* existing */,
|
|
510
|
+
super(props, true /* existing */, runtime_definitions_1.BindState.Bound, false /* isLocalDataStore */, () => {
|
|
504
511
|
throw new Error("Already attached");
|
|
505
512
|
});
|
|
506
513
|
this.initialSnapshotDetailsP = new common_utils_1.LazyPromise(async () => {
|
|
@@ -516,11 +523,7 @@ class RemoteFluidDataStoreContext extends FluidDataStoreContext {
|
|
|
516
523
|
}
|
|
517
524
|
const localReadAndParse = async (id) => (0, driver_utils_1.readAndParse)(this.storage, id);
|
|
518
525
|
if (tree) {
|
|
519
|
-
|
|
520
|
-
tree = loadedSummary.baseSummary;
|
|
521
|
-
// Prepend outstanding ops to pending queue of ops to process.
|
|
522
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
523
|
-
this.pending = loadedSummary.outstandingOps.concat(this.pending);
|
|
526
|
+
tree = await this.summarizerNode.loadBaseSummary(tree, localReadAndParse);
|
|
524
527
|
}
|
|
525
528
|
if (!!tree && tree.blobs[summaryFormat_1.dataStoreAttributesBlobName] !== undefined) {
|
|
526
529
|
// Need to get through snapshot and use that to populate extraBlobs
|
|
@@ -530,12 +533,9 @@ class RemoteFluidDataStoreContext extends FluidDataStoreContext {
|
|
|
530
533
|
// For snapshotFormatVersion = "0.1" (1) or above, pkg is jsonified, otherwise it is just a string.
|
|
531
534
|
const formatVersion = (0, summaryFormat_1.getAttributesFormatVersion)(attributes);
|
|
532
535
|
if (formatVersion < 1) {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
else {
|
|
537
|
-
pkgFromSnapshot = [attributes.pkg];
|
|
538
|
-
}
|
|
536
|
+
pkgFromSnapshot = attributes.pkg.startsWith("[\"") && attributes.pkg.endsWith("\"]")
|
|
537
|
+
? JSON.parse(attributes.pkg)
|
|
538
|
+
: [attributes.pkg];
|
|
539
539
|
}
|
|
540
540
|
else {
|
|
541
541
|
pkgFromSnapshot = JSON.parse(attributes.pkg);
|
|
@@ -569,7 +569,7 @@ class RemoteFluidDataStoreContext extends FluidDataStoreContext {
|
|
|
569
569
|
return this.initialSnapshotDetailsP;
|
|
570
570
|
}
|
|
571
571
|
/**
|
|
572
|
-
* @deprecated
|
|
572
|
+
* @deprecated Renamed to {@link RemoteFluidDataStoreContext.getBaseGCDetails}.
|
|
573
573
|
*/
|
|
574
574
|
async getInitialGCSummaryDetails() {
|
|
575
575
|
return this.getBaseGCDetails();
|
|
@@ -587,7 +587,7 @@ exports.RemoteFluidDataStoreContext = RemoteFluidDataStoreContext;
|
|
|
587
587
|
*/
|
|
588
588
|
class LocalFluidDataStoreContextBase extends FluidDataStoreContext {
|
|
589
589
|
constructor(props) {
|
|
590
|
-
super(props, props.snapshotTree !== undefined ? true : false /* existing */, props.snapshotTree ?
|
|
590
|
+
super(props, props.snapshotTree !== undefined ? true : false /* existing */, props.snapshotTree ? runtime_definitions_1.BindState.Bound : runtime_definitions_1.BindState.NotBound, true /* isLocalDataStore */, props.makeLocallyVisibleFn);
|
|
591
591
|
this.snapshotTree = props.snapshotTree;
|
|
592
592
|
if (props.isRootDataStore === true) {
|
|
593
593
|
this.setInMemoryRoot();
|
|
@@ -609,12 +609,10 @@ class LocalFluidDataStoreContextBase extends FluidDataStoreContext {
|
|
|
609
609
|
(0, common_utils_1.assert)(this.channel !== undefined, 0x14f /* "There should be a channel when generating attach message" */);
|
|
610
610
|
(0, common_utils_1.assert)(this.pkg !== undefined, 0x150 /* "pkg should be available in local data store context" */);
|
|
611
611
|
const summarizeResult = this.channel.getAttachSummary();
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
(0, summaryFormat_1.wrapSummaryInChannelsTree)(summarizeResult);
|
|
615
|
-
}
|
|
612
|
+
// Wrap dds summaries in .channels subtree.
|
|
613
|
+
(0, summaryFormat_1.wrapSummaryInChannelsTree)(summarizeResult);
|
|
616
614
|
// Add data store's attributes to the summary.
|
|
617
|
-
const attributes = createAttributes(this.pkg, this.isInMemoryRoot()
|
|
615
|
+
const attributes = createAttributes(this.pkg, this.isInMemoryRoot());
|
|
618
616
|
(0, runtime_utils_1.addBlobToSummary)(summarizeResult, summaryFormat_1.dataStoreAttributesBlobName, JSON.stringify(attributes));
|
|
619
617
|
// Attach message needs the summary in ITree format. Convert the ISummaryTree into an ITree.
|
|
620
618
|
const snapshot = (0, runtime_utils_1.convertSummaryTreeToITree)(summarizeResult.summary);
|
|
@@ -657,7 +655,7 @@ class LocalFluidDataStoreContextBase extends FluidDataStoreContext {
|
|
|
657
655
|
};
|
|
658
656
|
}
|
|
659
657
|
/**
|
|
660
|
-
* @deprecated
|
|
658
|
+
* @deprecated Renamed to {@link LocalFluidDataStoreContextBase.getBaseGCDetails}.
|
|
661
659
|
*/
|
|
662
660
|
async getInitialGCSummaryDetails() {
|
|
663
661
|
// Local data store does not have initial summary.
|
|
@@ -694,24 +692,17 @@ class LocalDetachedFluidDataStoreContext extends LocalFluidDataStoreContextBase
|
|
|
694
692
|
}
|
|
695
693
|
async attachRuntime(registry, dataStoreChannel) {
|
|
696
694
|
(0, common_utils_1.assert)(this.detachedRuntimeCreation, 0x154 /* "runtime creation is already attached" */);
|
|
695
|
+
this.detachedRuntimeCreation = false;
|
|
697
696
|
(0, common_utils_1.assert)(this.channelDeferred === undefined, 0x155 /* "channel deferral is already set" */);
|
|
697
|
+
this.channelDeferred = new common_utils_1.Deferred();
|
|
698
698
|
const factory = registry.IFluidDataStoreFactory;
|
|
699
699
|
const entry = await this.factoryFromPackagePath(this.pkg);
|
|
700
700
|
(0, common_utils_1.assert)(entry.factory === factory, 0x156 /* "Unexpected factory for package path" */);
|
|
701
701
|
(0, common_utils_1.assert)(this.registry === undefined, 0x157 /* "datastore registry already attached" */);
|
|
702
702
|
this.registry = entry.registry;
|
|
703
|
-
this.detachedRuntimeCreation = false;
|
|
704
|
-
this.channelDeferred = new common_utils_1.Deferred();
|
|
705
703
|
super.bindRuntime(dataStoreChannel);
|
|
706
704
|
if (await this.isRoot()) {
|
|
707
|
-
|
|
708
|
-
// For older versions, we still have to call bindToContext.
|
|
709
|
-
if (dataStoreChannel.makeVisibleAndAttachGraph !== undefined) {
|
|
710
|
-
dataStoreChannel.makeVisibleAndAttachGraph();
|
|
711
|
-
}
|
|
712
|
-
else {
|
|
713
|
-
dataStoreChannel.bindToContext();
|
|
714
|
-
}
|
|
705
|
+
dataStoreChannel.makeVisibleAndAttachGraph();
|
|
715
706
|
}
|
|
716
707
|
}
|
|
717
708
|
async getInitialSnapshotDetails() {
|