@fluidframework/container-runtime 1.3.0 → 2.0.0-dev.1.4.5.105745
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 +8 -22
- 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 +110 -125
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +360 -549
- 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 +248 -169
- 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 +135 -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 +69 -27
- 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 +98 -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 +110 -125
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +366 -554
- 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 +237 -159
- 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 +130 -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 +69 -27
- 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 +98 -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 +68 -25
- package/src/batchManager.ts +91 -0
- package/src/batchTracker.ts +2 -3
- package/src/blobManager.ts +385 -118
- package/src/containerRuntime.ts +523 -732
- 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 +296 -205
- package/src/gcSweepReadyUsageDetection.ts +147 -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 +76 -23
- package/src/scheduleManager.ts +314 -0
- package/src/summarizer.ts +1 -18
- package/src/summarizerHeuristics.ts +136 -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/lib/dataStore.js
CHANGED
|
@@ -31,6 +31,7 @@ class DataStore {
|
|
|
31
31
|
this.datastores = datastores;
|
|
32
32
|
this.logger = logger;
|
|
33
33
|
this.aliasState = AliasState.None;
|
|
34
|
+
this.pendingAliases = datastores.pendingAliases;
|
|
34
35
|
}
|
|
35
36
|
async trySetAlias(alias) {
|
|
36
37
|
if (alias.includes("/")) {
|
|
@@ -47,13 +48,22 @@ class DataStore {
|
|
|
47
48
|
// is a repeated call for the same alias
|
|
48
49
|
case AliasState.Aliased:
|
|
49
50
|
return this.alias === alias ? "Success" : "AlreadyAliased";
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
case AliasState.None: {
|
|
52
|
+
const existingAlias = this.pendingAliases.get(alias);
|
|
53
|
+
if (existingAlias !== undefined) {
|
|
54
|
+
// There is already another datastore which will be aliased
|
|
55
|
+
// to the same name
|
|
56
|
+
return "Conflict";
|
|
57
|
+
}
|
|
58
|
+
// There is no current or past alias operation for this datastore,
|
|
59
|
+
// or for this alias, so it is safe to continue execution
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
53
62
|
default: unreachableCase(this.aliasState);
|
|
54
63
|
}
|
|
55
64
|
this.aliasState = AliasState.Aliasing;
|
|
56
65
|
this.aliasResult = this.trySetAliasInternal(alias);
|
|
66
|
+
this.pendingAliases.set(alias, this.aliasResult);
|
|
57
67
|
return this.aliasResult;
|
|
58
68
|
}
|
|
59
69
|
async trySetAliasInternal(alias) {
|
|
@@ -61,14 +71,7 @@ class DataStore {
|
|
|
61
71
|
internalId: this.internalId,
|
|
62
72
|
alias,
|
|
63
73
|
};
|
|
64
|
-
|
|
65
|
-
// older versions, we still have to call bindToContext.
|
|
66
|
-
if (this.fluidDataStoreChannel.makeVisibleAndAttachGraph !== undefined) {
|
|
67
|
-
this.fluidDataStoreChannel.makeVisibleAndAttachGraph();
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
this.fluidDataStoreChannel.bindToContext();
|
|
71
|
-
}
|
|
74
|
+
this.fluidDataStoreChannel.makeVisibleAndAttachGraph();
|
|
72
75
|
if (this.runtime.attachState === AttachState.Detached) {
|
|
73
76
|
const localResult = this.datastores.processAliasMessageCore(message);
|
|
74
77
|
// Explicitly lock-out future attempts of aliasing,
|
|
@@ -76,17 +79,11 @@ class DataStore {
|
|
|
76
79
|
this.aliasState = AliasState.Aliased;
|
|
77
80
|
return localResult ? "Success" : "Conflict";
|
|
78
81
|
}
|
|
79
|
-
const aliased = await this
|
|
82
|
+
const aliased = await this
|
|
83
|
+
.ackBasedPromise((resolve) => {
|
|
80
84
|
this.runtime.submitDataStoreAliasOp(message, resolve);
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
// regardless of result
|
|
84
|
-
this.aliasState = AliasState.Aliased;
|
|
85
|
-
if (succeeded) {
|
|
86
|
-
this.alias = alias;
|
|
87
|
-
}
|
|
88
|
-
return succeeded;
|
|
89
|
-
}).catch((error) => {
|
|
85
|
+
})
|
|
86
|
+
.catch((error) => {
|
|
90
87
|
this.logger.sendErrorEvent({
|
|
91
88
|
eventName: "AliasingException",
|
|
92
89
|
alias: {
|
|
@@ -95,13 +92,21 @@ class DataStore {
|
|
|
95
92
|
},
|
|
96
93
|
internalId: {
|
|
97
94
|
value: this.internalId,
|
|
98
|
-
tag: TelemetryDataTag.
|
|
95
|
+
tag: TelemetryDataTag.CodeArtifact,
|
|
99
96
|
},
|
|
100
97
|
}, error);
|
|
101
|
-
this.aliasState = AliasState.None;
|
|
102
98
|
return false;
|
|
99
|
+
}).finally(() => {
|
|
100
|
+
this.pendingAliases.delete(alias);
|
|
103
101
|
});
|
|
104
|
-
|
|
102
|
+
if (!aliased) {
|
|
103
|
+
this.aliasState = AliasState.None;
|
|
104
|
+
this.aliasResult = undefined;
|
|
105
|
+
return "Conflict";
|
|
106
|
+
}
|
|
107
|
+
this.alias = alias;
|
|
108
|
+
this.aliasState = AliasState.Aliased;
|
|
109
|
+
return "Success";
|
|
105
110
|
}
|
|
106
111
|
async request(request) {
|
|
107
112
|
return this.fluidDataStoreChannel.request(request);
|
package/lib/dataStore.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataStore.js","s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CAAC,CAAC;QAEH,OAAO,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC;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,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAG7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAenE;;;;;GAKG;AACH,MAAM,CAAC,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;AAEF,MAAM,CAAC,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;AAE/F,IAAK,UAIJ;AAJD,WAAK,UAAU;IACX,iCAAmB,CAAA;IACnB,mCAAqB,CAAA;IACrB,2BAAa,CAAA;A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,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"]}
|
|
@@ -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,E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AMtE"}
|
package/lib/dataStoreContext.js
CHANGED
|
@@ -2,36 +2,33 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { AttachState, } from "@fluidframework/container-definitions";
|
|
6
6
|
import { assert, Deferred, LazyPromise, TypedEventEmitter, } from "@fluidframework/common-utils";
|
|
7
7
|
import { readAndParse } from "@fluidframework/driver-utils";
|
|
8
8
|
import { BlobTreeEntry } from "@fluidframework/protocol-base";
|
|
9
|
-
import { channelsTreeName, gcBlobKey, } from "@fluidframework/runtime-definitions";
|
|
9
|
+
import { BindState, channelsTreeName, gcBlobKey, } from "@fluidframework/runtime-definitions";
|
|
10
10
|
import { addBlobToSummary, convertSummaryTreeToITree } from "@fluidframework/runtime-utils";
|
|
11
11
|
import { ChildLogger, LoggingError, TelemetryDataTag, ThresholdCounter, } from "@fluidframework/telemetry-utils";
|
|
12
12
|
import { DataProcessingError } from "@fluidframework/container-utils";
|
|
13
13
|
import { dataStoreAttributesBlobName, hasIsolatedChannels, wrapSummaryInChannelsTree, getAttributesFormatVersion, getFluidDataStoreAttributes, } from "./summaryFormat";
|
|
14
|
-
function createAttributes(pkg, isRootDataStore
|
|
14
|
+
function createAttributes(pkg, isRootDataStore) {
|
|
15
15
|
const stringifiedPkg = JSON.stringify(pkg);
|
|
16
|
-
return
|
|
17
|
-
pkg: stringifiedPkg,
|
|
18
|
-
snapshotFormatVersion: "0.1",
|
|
19
|
-
isRootDataStore,
|
|
20
|
-
} : {
|
|
16
|
+
return {
|
|
21
17
|
pkg: stringifiedPkg,
|
|
22
18
|
summaryFormatVersion: 2,
|
|
23
19
|
isRootDataStore,
|
|
24
20
|
};
|
|
25
21
|
}
|
|
26
|
-
export function createAttributesBlob(pkg, isRootDataStore
|
|
27
|
-
const attributes = createAttributes(pkg, isRootDataStore
|
|
22
|
+
export function createAttributesBlob(pkg, isRootDataStore) {
|
|
23
|
+
const attributes = createAttributes(pkg, isRootDataStore);
|
|
28
24
|
return new BlobTreeEntry(dataStoreAttributesBlobName, JSON.stringify(attributes));
|
|
29
25
|
}
|
|
30
26
|
/**
|
|
31
27
|
* Represents the context for the store. This context is passed to the store runtime.
|
|
32
28
|
*/
|
|
33
29
|
export class FluidDataStoreContext extends TypedEventEmitter {
|
|
34
|
-
constructor(props, existing, bindState,
|
|
30
|
+
constructor(props, existing, bindState, // Used to assert for state tracking purposes
|
|
31
|
+
isLocalDataStore, makeLocallyVisibleFn) {
|
|
35
32
|
super();
|
|
36
33
|
this.existing = existing;
|
|
37
34
|
this.bindState = bindState;
|
|
@@ -47,7 +44,6 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
47
44
|
this.storage = props.storage;
|
|
48
45
|
this.scope = props.scope;
|
|
49
46
|
this.writeGCDataAtRoot = props.writeGCDataAtRoot;
|
|
50
|
-
this.disableIsolatedChannels = props.disableIsolatedChannels;
|
|
51
47
|
this.pkg = props.pkg;
|
|
52
48
|
// URIs use slashes as delimiters. Handles use URIs.
|
|
53
49
|
// Thus having slashes in types almost guarantees trouble down the road!
|
|
@@ -140,7 +136,7 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
140
136
|
}
|
|
141
137
|
}
|
|
142
138
|
rejectDeferredRealize(reason, packageName) {
|
|
143
|
-
throw new LoggingError(reason, { packageName: { value: packageName, tag: TelemetryDataTag.
|
|
139
|
+
throw new LoggingError(reason, { packageName: { value: packageName, tag: TelemetryDataTag.CodeArtifact } });
|
|
144
140
|
}
|
|
145
141
|
async realize() {
|
|
146
142
|
assert(!this.detachedRuntimeCreation, 0x13d /* "Detached runtime creation on realize()" */);
|
|
@@ -149,7 +145,12 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
149
145
|
this.realizeCore(this.existing).catch((error) => {
|
|
150
146
|
var _a;
|
|
151
147
|
const errorWrapped = DataProcessingError.wrapIfUnrecognized(error, "realizeFluidDataStoreContext");
|
|
152
|
-
errorWrapped.addTelemetryProperties({
|
|
148
|
+
errorWrapped.addTelemetryProperties({
|
|
149
|
+
fluidDataStoreId: {
|
|
150
|
+
value: this.id,
|
|
151
|
+
tag: TelemetryDataTag.CodeArtifact,
|
|
152
|
+
},
|
|
153
|
+
});
|
|
153
154
|
(_a = this.channelDeferred) === null || _a === void 0 ? void 0 : _a.reject(errorWrapped);
|
|
154
155
|
this.logger.sendErrorEvent({ eventName: "RealizeError" }, errorWrapped);
|
|
155
156
|
});
|
|
@@ -198,8 +199,8 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
198
199
|
/**
|
|
199
200
|
* Notifies this object about changes in the connection state.
|
|
200
201
|
* @param value - New connection state.
|
|
201
|
-
* @param clientId - ID of the client.
|
|
202
|
-
*
|
|
202
|
+
* @param clientId - ID of the client. Its old ID when in disconnected state and
|
|
203
|
+
* its new client ID when we are connecting or connected.
|
|
203
204
|
*/
|
|
204
205
|
setConnectionState(connected, clientId) {
|
|
205
206
|
this.verifyNotClosed();
|
|
@@ -255,16 +256,13 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
255
256
|
await this.realize();
|
|
256
257
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
257
258
|
const summarizeResult = await this.channel.summarize(fullTree, trackState, telemetryContext);
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
wrapSummaryInChannelsTree(summarizeResult);
|
|
262
|
-
pathPartsForChildren = [channelsTreeName];
|
|
263
|
-
}
|
|
259
|
+
// Wrap dds summaries in .channels subtree.
|
|
260
|
+
wrapSummaryInChannelsTree(summarizeResult);
|
|
261
|
+
const pathPartsForChildren = [channelsTreeName];
|
|
264
262
|
// Add data store's attributes to the summary.
|
|
265
263
|
const { pkg } = await this.getInitialSnapshotDetails();
|
|
266
264
|
const isRoot = await this.isRoot();
|
|
267
|
-
const attributes = createAttributes(pkg, isRoot
|
|
265
|
+
const attributes = createAttributes(pkg, isRoot);
|
|
268
266
|
addBlobToSummary(summarizeResult, dataStoreAttributesBlobName, JSON.stringify(attributes));
|
|
269
267
|
// Add GC data to the summary if it's not written at the root.
|
|
270
268
|
if (!this.writeGCDataAtRoot) {
|
|
@@ -301,12 +299,18 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
301
299
|
}
|
|
302
300
|
/**
|
|
303
301
|
* After GC has run, called to notify the data store of routes used in it. These are used for the following:
|
|
302
|
+
*
|
|
304
303
|
* 1. To identify if this data store is being referenced in the document or not.
|
|
304
|
+
*
|
|
305
305
|
* 2. To determine if it needs to re-summarize in case used routes changed since last summary.
|
|
306
|
+
*
|
|
306
307
|
* 3. These are added to the summary generated by the data store.
|
|
307
|
-
*
|
|
308
|
-
*
|
|
308
|
+
*
|
|
309
|
+
* 4. To notify child contexts of their used routes. This is done immediately if the data store is loaded.
|
|
310
|
+
* Else, it is done when realizing the data store.
|
|
311
|
+
*
|
|
309
312
|
* 5. To update the timestamp when this data store or any children are marked as unreferenced.
|
|
313
|
+
*
|
|
310
314
|
* @param usedRoutes - The routes that are used in this data store.
|
|
311
315
|
* @param gcTimestamp - The time when GC was run that generated these used routes. If any node becomes unreferenced
|
|
312
316
|
* as part of this GC run, this should be used to update the time when it happens.
|
|
@@ -438,7 +442,10 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
438
442
|
}
|
|
439
443
|
catch (error) {
|
|
440
444
|
(_a = this.channelDeferred) === null || _a === void 0 ? void 0 : _a.reject(error);
|
|
441
|
-
this.logger.sendErrorEvent({ eventName: "BindRuntimeError", fluidDataStoreId: {
|
|
445
|
+
this.logger.sendErrorEvent({ eventName: "BindRuntimeError", fluidDataStoreId: {
|
|
446
|
+
value: this.id,
|
|
447
|
+
tag: TelemetryDataTag.CodeArtifact,
|
|
448
|
+
} }, error);
|
|
442
449
|
}
|
|
443
450
|
}
|
|
444
451
|
async getAbsoluteUrl(relativeUrl) {
|
|
@@ -448,7 +455,7 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
448
455
|
return this._containerRuntime.getAbsoluteUrl(relativeUrl);
|
|
449
456
|
}
|
|
450
457
|
/**
|
|
451
|
-
* @deprecated
|
|
458
|
+
* @deprecated Sets the datastore as root, for aliasing purposes: #7948
|
|
452
459
|
* This method should not be used outside of the aliasing context.
|
|
453
460
|
* It will be removed, as the source of truth for this flag will be the aliasing blob.
|
|
454
461
|
*/
|
|
@@ -511,11 +518,7 @@ export class RemoteFluidDataStoreContext extends FluidDataStoreContext {
|
|
|
511
518
|
}
|
|
512
519
|
const localReadAndParse = async (id) => readAndParse(this.storage, id);
|
|
513
520
|
if (tree) {
|
|
514
|
-
|
|
515
|
-
tree = loadedSummary.baseSummary;
|
|
516
|
-
// Prepend outstanding ops to pending queue of ops to process.
|
|
517
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
518
|
-
this.pending = loadedSummary.outstandingOps.concat(this.pending);
|
|
521
|
+
tree = await this.summarizerNode.loadBaseSummary(tree, localReadAndParse);
|
|
519
522
|
}
|
|
520
523
|
if (!!tree && tree.blobs[dataStoreAttributesBlobName] !== undefined) {
|
|
521
524
|
// Need to get through snapshot and use that to populate extraBlobs
|
|
@@ -525,12 +528,9 @@ export class RemoteFluidDataStoreContext extends FluidDataStoreContext {
|
|
|
525
528
|
// For snapshotFormatVersion = "0.1" (1) or above, pkg is jsonified, otherwise it is just a string.
|
|
526
529
|
const formatVersion = getAttributesFormatVersion(attributes);
|
|
527
530
|
if (formatVersion < 1) {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
else {
|
|
532
|
-
pkgFromSnapshot = [attributes.pkg];
|
|
533
|
-
}
|
|
531
|
+
pkgFromSnapshot = attributes.pkg.startsWith("[\"") && attributes.pkg.endsWith("\"]")
|
|
532
|
+
? JSON.parse(attributes.pkg)
|
|
533
|
+
: [attributes.pkg];
|
|
534
534
|
}
|
|
535
535
|
else {
|
|
536
536
|
pkgFromSnapshot = JSON.parse(attributes.pkg);
|
|
@@ -564,7 +564,7 @@ export class RemoteFluidDataStoreContext extends FluidDataStoreContext {
|
|
|
564
564
|
return this.initialSnapshotDetailsP;
|
|
565
565
|
}
|
|
566
566
|
/**
|
|
567
|
-
* @deprecated
|
|
567
|
+
* @deprecated Renamed to {@link RemoteFluidDataStoreContext.getBaseGCDetails}.
|
|
568
568
|
*/
|
|
569
569
|
async getInitialGCSummaryDetails() {
|
|
570
570
|
return this.getBaseGCDetails();
|
|
@@ -603,12 +603,10 @@ export class LocalFluidDataStoreContextBase extends FluidDataStoreContext {
|
|
|
603
603
|
assert(this.channel !== undefined, 0x14f /* "There should be a channel when generating attach message" */);
|
|
604
604
|
assert(this.pkg !== undefined, 0x150 /* "pkg should be available in local data store context" */);
|
|
605
605
|
const summarizeResult = this.channel.getAttachSummary();
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
wrapSummaryInChannelsTree(summarizeResult);
|
|
609
|
-
}
|
|
606
|
+
// Wrap dds summaries in .channels subtree.
|
|
607
|
+
wrapSummaryInChannelsTree(summarizeResult);
|
|
610
608
|
// Add data store's attributes to the summary.
|
|
611
|
-
const attributes = createAttributes(this.pkg, this.isInMemoryRoot()
|
|
609
|
+
const attributes = createAttributes(this.pkg, this.isInMemoryRoot());
|
|
612
610
|
addBlobToSummary(summarizeResult, dataStoreAttributesBlobName, JSON.stringify(attributes));
|
|
613
611
|
// Attach message needs the summary in ITree format. Convert the ISummaryTree into an ITree.
|
|
614
612
|
const snapshot = convertSummaryTreeToITree(summarizeResult.summary);
|
|
@@ -651,7 +649,7 @@ export class LocalFluidDataStoreContextBase extends FluidDataStoreContext {
|
|
|
651
649
|
};
|
|
652
650
|
}
|
|
653
651
|
/**
|
|
654
|
-
* @deprecated
|
|
652
|
+
* @deprecated Renamed to {@link LocalFluidDataStoreContextBase.getBaseGCDetails}.
|
|
655
653
|
*/
|
|
656
654
|
async getInitialGCSummaryDetails() {
|
|
657
655
|
// Local data store does not have initial summary.
|
|
@@ -686,24 +684,17 @@ export class LocalDetachedFluidDataStoreContext extends LocalFluidDataStoreConte
|
|
|
686
684
|
}
|
|
687
685
|
async attachRuntime(registry, dataStoreChannel) {
|
|
688
686
|
assert(this.detachedRuntimeCreation, 0x154 /* "runtime creation is already attached" */);
|
|
687
|
+
this.detachedRuntimeCreation = false;
|
|
689
688
|
assert(this.channelDeferred === undefined, 0x155 /* "channel deferral is already set" */);
|
|
689
|
+
this.channelDeferred = new Deferred();
|
|
690
690
|
const factory = registry.IFluidDataStoreFactory;
|
|
691
691
|
const entry = await this.factoryFromPackagePath(this.pkg);
|
|
692
692
|
assert(entry.factory === factory, 0x156 /* "Unexpected factory for package path" */);
|
|
693
693
|
assert(this.registry === undefined, 0x157 /* "datastore registry already attached" */);
|
|
694
694
|
this.registry = entry.registry;
|
|
695
|
-
this.detachedRuntimeCreation = false;
|
|
696
|
-
this.channelDeferred = new Deferred();
|
|
697
695
|
super.bindRuntime(dataStoreChannel);
|
|
698
696
|
if (await this.isRoot()) {
|
|
699
|
-
|
|
700
|
-
// For older versions, we still have to call bindToContext.
|
|
701
|
-
if (dataStoreChannel.makeVisibleAndAttachGraph !== undefined) {
|
|
702
|
-
dataStoreChannel.makeVisibleAndAttachGraph();
|
|
703
|
-
}
|
|
704
|
-
else {
|
|
705
|
-
dataStoreChannel.bindToContext();
|
|
706
|
-
}
|
|
697
|
+
dataStoreChannel.makeVisibleAndAttachGraph();
|
|
707
698
|
}
|
|
708
699
|
}
|
|
709
700
|
async getInitialSnapshotDetails() {
|