@fluidframework/container-runtime 2.0.0-internal.6.4.0 → 2.0.0-internal.7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +103 -0
- package/dist/blobManager.d.ts +1 -1
- package/dist/blobManager.d.ts.map +1 -1
- package/dist/blobManager.js +6 -6
- package/dist/blobManager.js.map +1 -1
- package/dist/containerHandleContext.js +3 -3
- package/dist/containerHandleContext.js.map +1 -1
- package/dist/containerRuntime.d.ts +8 -10
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +226 -231
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStore.js +9 -9
- package/dist/dataStore.js.map +1 -1
- package/dist/dataStoreContext.d.ts +1 -3
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js +54 -58
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/dataStoreRegistry.js +3 -3
- package/dist/dataStoreRegistry.js.map +1 -1
- package/dist/deltaManagerProxyBase.js +4 -4
- package/dist/deltaManagerProxyBase.js.map +1 -1
- package/dist/deltaManagerSummarizerProxy.js +6 -6
- package/dist/deltaManagerSummarizerProxy.js.map +1 -1
- package/dist/deltaScheduler.js.map +1 -1
- package/dist/gc/garbageCollection.js +13 -13
- package/dist/gc/garbageCollection.js.map +1 -1
- package/dist/gc/gcDefinitions.d.ts +4 -15
- package/dist/gc/gcDefinitions.d.ts.map +1 -1
- package/dist/gc/gcDefinitions.js.map +1 -1
- package/dist/gc/gcTelemetry.d.ts +1 -1
- package/dist/gc/gcTelemetry.d.ts.map +1 -1
- package/dist/gc/gcUnreferencedStateTracker.js +3 -3
- package/dist/gc/gcUnreferencedStateTracker.js.map +1 -1
- package/dist/id-compressor/appendOnlySortedMap.js.map +1 -1
- package/dist/id-compressor/idCompressor.js.map +1 -1
- package/dist/id-compressor/identifiers.d.ts +3 -3
- package/dist/id-compressor/identifiers.d.ts.map +1 -1
- package/dist/messageTypes.d.ts +17 -17
- package/dist/messageTypes.d.ts.map +1 -1
- package/dist/messageTypes.js +1 -1
- package/dist/messageTypes.js.map +1 -1
- package/dist/opLifecycle/batchManager.js +6 -6
- package/dist/opLifecycle/batchManager.js.map +1 -1
- package/dist/opLifecycle/definitions.d.ts +2 -2
- package/dist/opLifecycle/definitions.d.ts.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/pendingStateManager.d.ts +3 -19
- package/dist/pendingStateManager.d.ts.map +1 -1
- package/dist/pendingStateManager.js +20 -39
- package/dist/pendingStateManager.js.map +1 -1
- package/dist/summary/orderedClientElection.d.ts +3 -3
- package/dist/summary/orderedClientElection.d.ts.map +1 -1
- package/dist/summary/orderedClientElection.js +54 -54
- package/dist/summary/orderedClientElection.js.map +1 -1
- package/dist/summary/runWhileConnectedCoordinator.js +6 -6
- package/dist/summary/runWhileConnectedCoordinator.js.map +1 -1
- package/dist/summary/runningSummarizer.js +37 -37
- package/dist/summary/runningSummarizer.js.map +1 -1
- package/dist/summary/summarizer.d.ts.map +1 -1
- package/dist/summary/summarizer.js +8 -6
- package/dist/summary/summarizer.js.map +1 -1
- package/dist/summary/summarizerClientElection.js +6 -6
- package/dist/summary/summarizerClientElection.js.map +1 -1
- package/dist/summary/summarizerHeuristics.js +9 -9
- package/dist/summary/summarizerHeuristics.js.map +1 -1
- package/dist/summary/summarizerNode/summarizerNode.js +7 -7
- package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
- package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts +1 -1
- package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
- package/dist/summary/summarizerNode/summarizerNodeUtils.js +3 -3
- package/dist/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
- package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts +2 -2
- package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
- package/dist/summary/summarizerTypes.d.ts +12 -12
- package/dist/summary/summarizerTypes.d.ts.map +1 -1
- package/dist/summary/summaryCollection.d.ts +2 -2
- package/dist/summary/summaryCollection.d.ts.map +1 -1
- package/dist/summary/summaryCollection.js +21 -21
- package/dist/summary/summaryCollection.js.map +1 -1
- package/dist/summary/summaryFormat.d.ts +5 -5
- package/dist/summary/summaryFormat.d.ts.map +1 -1
- package/dist/summary/summaryGenerator.d.ts +3 -3
- package/dist/summary/summaryGenerator.d.ts.map +1 -1
- package/dist/summary/summaryManager.js +7 -7
- package/dist/summary/summaryManager.js.map +1 -1
- package/dist/throttler.js +16 -16
- package/dist/throttler.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/blobManager.d.ts +1 -1
- package/lib/blobManager.d.ts.map +1 -1
- package/lib/blobManager.js +6 -6
- package/lib/blobManager.js.map +1 -1
- package/lib/containerHandleContext.js +3 -3
- package/lib/containerHandleContext.js.map +1 -1
- package/lib/containerRuntime.d.ts +8 -10
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +221 -228
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStore.js +9 -9
- package/lib/dataStore.js.map +1 -1
- package/lib/dataStoreContext.d.ts +1 -3
- package/lib/dataStoreContext.d.ts.map +1 -1
- package/lib/dataStoreContext.js +54 -58
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/dataStoreRegistry.js +3 -3
- package/lib/dataStoreRegistry.js.map +1 -1
- package/lib/deltaManagerProxyBase.js +4 -4
- package/lib/deltaManagerProxyBase.js.map +1 -1
- package/lib/deltaManagerSummarizerProxy.js +6 -6
- package/lib/deltaManagerSummarizerProxy.js.map +1 -1
- package/lib/deltaScheduler.js.map +1 -1
- package/lib/gc/garbageCollection.js +13 -13
- package/lib/gc/garbageCollection.js.map +1 -1
- package/lib/gc/gcDefinitions.d.ts +4 -15
- package/lib/gc/gcDefinitions.d.ts.map +1 -1
- package/lib/gc/gcDefinitions.js.map +1 -1
- package/lib/gc/gcTelemetry.d.ts +1 -1
- package/lib/gc/gcTelemetry.d.ts.map +1 -1
- package/lib/gc/gcUnreferencedStateTracker.js +3 -3
- package/lib/gc/gcUnreferencedStateTracker.js.map +1 -1
- package/lib/id-compressor/appendOnlySortedMap.js.map +1 -1
- package/lib/id-compressor/idCompressor.js.map +1 -1
- package/lib/id-compressor/identifiers.d.ts +3 -3
- package/lib/id-compressor/identifiers.d.ts.map +1 -1
- package/lib/messageTypes.d.ts +17 -17
- package/lib/messageTypes.d.ts.map +1 -1
- package/lib/opLifecycle/batchManager.js +6 -6
- package/lib/opLifecycle/batchManager.js.map +1 -1
- package/lib/opLifecycle/definitions.d.ts +2 -2
- package/lib/opLifecycle/definitions.d.ts.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/pendingStateManager.d.ts +3 -19
- package/lib/pendingStateManager.d.ts.map +1 -1
- package/lib/pendingStateManager.js +20 -39
- package/lib/pendingStateManager.js.map +1 -1
- package/lib/summary/orderedClientElection.d.ts +3 -3
- package/lib/summary/orderedClientElection.d.ts.map +1 -1
- package/lib/summary/orderedClientElection.js +54 -54
- package/lib/summary/orderedClientElection.js.map +1 -1
- package/lib/summary/runWhileConnectedCoordinator.js +6 -6
- package/lib/summary/runWhileConnectedCoordinator.js.map +1 -1
- package/lib/summary/runningSummarizer.js +37 -37
- package/lib/summary/runningSummarizer.js.map +1 -1
- package/lib/summary/summarizer.d.ts.map +1 -1
- package/lib/summary/summarizer.js +8 -6
- package/lib/summary/summarizer.js.map +1 -1
- package/lib/summary/summarizerClientElection.js +6 -6
- package/lib/summary/summarizerClientElection.js.map +1 -1
- package/lib/summary/summarizerHeuristics.js +9 -9
- package/lib/summary/summarizerHeuristics.js.map +1 -1
- package/lib/summary/summarizerNode/summarizerNode.js +7 -7
- package/lib/summary/summarizerNode/summarizerNode.js.map +1 -1
- package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts +1 -1
- package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
- package/lib/summary/summarizerNode/summarizerNodeUtils.js +3 -3
- package/lib/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
- package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts +2 -2
- package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
- package/lib/summary/summarizerTypes.d.ts +12 -12
- package/lib/summary/summarizerTypes.d.ts.map +1 -1
- package/lib/summary/summaryCollection.d.ts +2 -2
- package/lib/summary/summaryCollection.d.ts.map +1 -1
- package/lib/summary/summaryCollection.js +21 -21
- package/lib/summary/summaryCollection.js.map +1 -1
- package/lib/summary/summaryFormat.d.ts +5 -5
- package/lib/summary/summaryFormat.d.ts.map +1 -1
- package/lib/summary/summaryGenerator.d.ts +3 -3
- package/lib/summary/summaryGenerator.d.ts.map +1 -1
- package/lib/summary/summaryManager.js +6 -6
- package/lib/summary/summaryManager.js.map +1 -1
- package/lib/throttler.js +16 -16
- package/lib/throttler.js.map +1 -1
- package/package.json +56 -21
- package/src/containerRuntime.ts +29 -33
- package/src/dataStore.ts +1 -1
- package/src/dataStoreContext.ts +1 -6
- package/src/gc/gcDefinitions.ts +1 -13
- package/src/gc/gcEarlyAdoption.md +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/pendingStateManager.ts +7 -46
- package/src/summary/summarizer.ts +3 -1
package/lib/containerRuntime.js
CHANGED
|
@@ -8,7 +8,9 @@ import { DriverHeader, FetchSource, } from "@fluidframework/driver-definitions";
|
|
|
8
8
|
import { readAndParse } from "@fluidframework/driver-utils";
|
|
9
9
|
import { MessageType, SummaryType, } from "@fluidframework/protocol-definitions";
|
|
10
10
|
import { FlushMode, FlushModeExperimental, gcTreeKey, channelsTreeName, } from "@fluidframework/runtime-definitions";
|
|
11
|
-
import { addBlobToSummary, addSummarizeResultToSummary, addTreeToSummary, RequestParser, create404Response, exceptionToResponse, GCDataBuilder,
|
|
11
|
+
import { addBlobToSummary, addSummarizeResultToSummary, addTreeToSummary, RequestParser, create404Response, exceptionToResponse, GCDataBuilder,
|
|
12
|
+
// eslint-disable-next-line import/no-deprecated
|
|
13
|
+
requestFluidObject, seqFromTree, calculateStats, TelemetryContext, } from "@fluidframework/runtime-utils";
|
|
12
14
|
import { v4 as uuid } from "uuid";
|
|
13
15
|
import { ContainerFluidHandleContext } from "./containerHandleContext";
|
|
14
16
|
import { FluidDataStoreRegistry } from "./dataStoreRegistry";
|
|
@@ -169,15 +171,227 @@ export const makeLegacySendBatchFn = (submitFn, deltaManager) => (batch) => {
|
|
|
169
171
|
* It will define the store level mappings.
|
|
170
172
|
*/
|
|
171
173
|
export class ContainerRuntime extends TypedEventEmitter {
|
|
174
|
+
/**
|
|
175
|
+
* @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
176
|
+
*/
|
|
177
|
+
get IFluidRouter() {
|
|
178
|
+
return this;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* @deprecated - use loadRuntime instead.
|
|
182
|
+
* Load the stores from a snapshot and returns the runtime.
|
|
183
|
+
* @param context - Context of the container.
|
|
184
|
+
* @param registryEntries - Mapping to the stores.
|
|
185
|
+
* @param requestHandler - Request handlers for the container runtime
|
|
186
|
+
* @param runtimeOptions - Additional options to be passed to the runtime
|
|
187
|
+
* @param existing - (optional) When loading from an existing snapshot. Precedes context.existing if provided
|
|
188
|
+
* @param containerRuntimeCtor - (optional) Constructor to use to create the ContainerRuntime instance. This
|
|
189
|
+
* allows mixin classes to leverage this method to define their own async initializer.
|
|
190
|
+
*/
|
|
191
|
+
static async load(context, registryEntries, requestHandler, runtimeOptions = {}, containerScope = context.scope, existing, containerRuntimeCtor = ContainerRuntime) {
|
|
192
|
+
let existingFlag = true;
|
|
193
|
+
if (!existing) {
|
|
194
|
+
existingFlag = false;
|
|
195
|
+
}
|
|
196
|
+
return this.loadRuntime({
|
|
197
|
+
context,
|
|
198
|
+
registryEntries,
|
|
199
|
+
existing: existingFlag,
|
|
200
|
+
runtimeOptions,
|
|
201
|
+
containerScope,
|
|
202
|
+
containerRuntimeCtor,
|
|
203
|
+
requestHandler,
|
|
204
|
+
provideEntryPoint: () => {
|
|
205
|
+
throw new UsageError("ContainerRuntime.load is deprecated and should no longer be used");
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Load the stores from a snapshot and returns the runtime.
|
|
211
|
+
* @param params - An object housing the runtime properties:
|
|
212
|
+
* - context - Context of the container.
|
|
213
|
+
* - registryEntries - Mapping from data store types to their corresponding factories.
|
|
214
|
+
* - existing - Pass 'true' if loading from an existing snapshot.
|
|
215
|
+
* - requestHandler - (optional) Request handler for the request() method of the container runtime.
|
|
216
|
+
* Only relevant for back-compat while we remove the request() method and move fully to entryPoint as the main pattern.
|
|
217
|
+
* - runtimeOptions - Additional options to be passed to the runtime
|
|
218
|
+
* - containerScope - runtime services provided with context
|
|
219
|
+
* - containerRuntimeCtor - Constructor to use to create the ContainerRuntime instance.
|
|
220
|
+
* This allows mixin classes to leverage this method to define their own async initializer.
|
|
221
|
+
* - provideEntryPoint - Promise that resolves to an object which will act as entryPoint for the Container.
|
|
222
|
+
* This object should provide all the functionality that the Container is expected to provide to the loader layer.
|
|
223
|
+
*/
|
|
224
|
+
static async loadRuntime(params) {
|
|
225
|
+
const { context, registryEntries, existing, requestHandler, provideEntryPoint, runtimeOptions = {}, containerScope = {}, containerRuntimeCtor = ContainerRuntime, } = params;
|
|
226
|
+
// If taggedLogger exists, use it. Otherwise, wrap the vanilla logger:
|
|
227
|
+
// back-compat: Remove the TaggedLoggerAdapter fallback once all the host are using loader > 0.45
|
|
228
|
+
const backCompatContext = context;
|
|
229
|
+
const passLogger = backCompatContext.taggedLogger ??
|
|
230
|
+
// eslint-disable-next-line import/no-deprecated
|
|
231
|
+
new TaggedLoggerAdapter(backCompatContext.logger);
|
|
232
|
+
const logger = createChildLogger({
|
|
233
|
+
logger: passLogger,
|
|
234
|
+
properties: {
|
|
235
|
+
all: {
|
|
236
|
+
runtimeVersion: pkgVersion,
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
});
|
|
240
|
+
const { summaryOptions = {}, gcOptions = {}, loadSequenceNumberVerification = "close", flushMode = defaultFlushMode, compressionOptions = defaultCompressionConfig, maxBatchSizeInBytes = defaultMaxBatchSizeInBytes, enableRuntimeIdCompressor = false, chunkSizeInBytes = defaultChunkSizeInBytes, enableOpReentryCheck = false, enableGroupedBatching = false, } = runtimeOptions;
|
|
241
|
+
const registry = new FluidDataStoreRegistry(registryEntries);
|
|
242
|
+
const tryFetchBlob = async (blobName) => {
|
|
243
|
+
const blobId = context.baseSnapshot?.blobs[blobName];
|
|
244
|
+
if (context.baseSnapshot && blobId) {
|
|
245
|
+
// IContainerContext storage api return type still has undefined in 0.39 package version.
|
|
246
|
+
// So once we release 0.40 container-defn package we can remove this check.
|
|
247
|
+
assert(context.storage !== undefined, 0x1f5 /* "Attached state should have storage" */);
|
|
248
|
+
return readAndParse(context.storage, blobId);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
const [chunks, metadata, electedSummarizerData, aliases, serializedIdCompressor] = await Promise.all([
|
|
252
|
+
tryFetchBlob(chunksBlobName),
|
|
253
|
+
tryFetchBlob(metadataBlobName),
|
|
254
|
+
tryFetchBlob(electedSummarizerBlobName),
|
|
255
|
+
tryFetchBlob(aliasBlobName),
|
|
256
|
+
tryFetchBlob(idCompressorBlobName),
|
|
257
|
+
]);
|
|
258
|
+
// read snapshot blobs needed for BlobManager to load
|
|
259
|
+
const blobManagerSnapshot = await BlobManager.load(context.baseSnapshot?.trees[blobsTreeName], async (id) => {
|
|
260
|
+
// IContainerContext storage api return type still has undefined in 0.39 package version.
|
|
261
|
+
// So once we release 0.40 container-defn package we can remove this check.
|
|
262
|
+
assert(context.storage !== undefined, 0x256 /* "storage undefined in attached container" */);
|
|
263
|
+
return readAndParse(context.storage, id);
|
|
264
|
+
});
|
|
265
|
+
// Verify summary runtime sequence number matches protocol sequence number.
|
|
266
|
+
const runtimeSequenceNumber = metadata?.message?.sequenceNumber;
|
|
267
|
+
// When we load with pending state, we reuse an old snapshot so we don't expect these numbers to match
|
|
268
|
+
if (!context.pendingLocalState && runtimeSequenceNumber !== undefined) {
|
|
269
|
+
const protocolSequenceNumber = context.deltaManager.initialSequenceNumber;
|
|
270
|
+
// Unless bypass is explicitly set, then take action when sequence numbers mismatch.
|
|
271
|
+
if (loadSequenceNumberVerification !== "bypass" &&
|
|
272
|
+
runtimeSequenceNumber !== protocolSequenceNumber) {
|
|
273
|
+
// "Load from summary, runtime metadata sequenceNumber !== initialSequenceNumber"
|
|
274
|
+
const error = new DataCorruptionError(
|
|
275
|
+
// pre-0.58 error message: SummaryMetadataMismatch
|
|
276
|
+
"Summary metadata mismatch", { runtimeVersion: pkgVersion, runtimeSequenceNumber, protocolSequenceNumber });
|
|
277
|
+
if (loadSequenceNumberVerification === "log") {
|
|
278
|
+
logger.sendErrorEvent({ eventName: "SequenceNumberMismatch" }, error);
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
context.closeFn(error);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
const idCompressorEnabled = metadata?.idCompressorEnabled ?? runtimeOptions.enableRuntimeIdCompressor ?? false;
|
|
286
|
+
let idCompressor;
|
|
287
|
+
if (idCompressorEnabled) {
|
|
288
|
+
const { IdCompressor, createSessionId } = await import("./id-compressor");
|
|
289
|
+
idCompressor =
|
|
290
|
+
serializedIdCompressor !== undefined
|
|
291
|
+
? IdCompressor.deserialize(serializedIdCompressor, createSessionId())
|
|
292
|
+
: IdCompressor.create(logger);
|
|
293
|
+
}
|
|
294
|
+
const runtime = new containerRuntimeCtor(context, registry, metadata, electedSummarizerData, chunks ?? [], aliases ?? [], {
|
|
295
|
+
summaryOptions,
|
|
296
|
+
gcOptions,
|
|
297
|
+
loadSequenceNumberVerification,
|
|
298
|
+
flushMode,
|
|
299
|
+
compressionOptions,
|
|
300
|
+
maxBatchSizeInBytes,
|
|
301
|
+
chunkSizeInBytes,
|
|
302
|
+
enableRuntimeIdCompressor,
|
|
303
|
+
enableOpReentryCheck,
|
|
304
|
+
enableGroupedBatching,
|
|
305
|
+
}, containerScope, logger, existing, blobManagerSnapshot, context.storage, idCompressor, provideEntryPoint, requestHandler, undefined);
|
|
306
|
+
// Apply stashed ops with a reference sequence number equal to the sequence number of the snapshot,
|
|
307
|
+
// or zero. This must be done before Container replays saved ops.
|
|
308
|
+
await runtime.pendingStateManager.applyStashedOpsAt(runtimeSequenceNumber ?? 0);
|
|
309
|
+
// Initialize the base state of the runtime before it's returned.
|
|
310
|
+
await runtime.initializeBaseState();
|
|
311
|
+
return runtime;
|
|
312
|
+
}
|
|
313
|
+
get clientId() {
|
|
314
|
+
return this._getClientId();
|
|
315
|
+
}
|
|
316
|
+
get storage() {
|
|
317
|
+
return this._storage;
|
|
318
|
+
}
|
|
319
|
+
get flushMode() {
|
|
320
|
+
return this._flushMode;
|
|
321
|
+
}
|
|
322
|
+
get scope() {
|
|
323
|
+
return this.containerScope;
|
|
324
|
+
}
|
|
325
|
+
get IFluidDataStoreRegistry() {
|
|
326
|
+
return this.registry;
|
|
327
|
+
}
|
|
328
|
+
get attachState() {
|
|
329
|
+
return this._getAttachState();
|
|
330
|
+
}
|
|
331
|
+
get IFluidHandleContext() {
|
|
332
|
+
return this.handleContext;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Invokes the given callback and expects that no ops are submitted
|
|
336
|
+
* until execution finishes. If an op is submitted, an error will be raised.
|
|
337
|
+
*
|
|
338
|
+
* Can be disabled by feature gate `Fluid.ContainerRuntime.DisableOpReentryCheck`
|
|
339
|
+
*
|
|
340
|
+
* @param callback - the callback to be invoked
|
|
341
|
+
*/
|
|
342
|
+
ensureNoDataModelChanges(callback) {
|
|
343
|
+
this.ensureNoDataModelChangesCalls++;
|
|
344
|
+
try {
|
|
345
|
+
return callback();
|
|
346
|
+
}
|
|
347
|
+
finally {
|
|
348
|
+
this.ensureNoDataModelChangesCalls--;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
get connected() {
|
|
352
|
+
return this._connected;
|
|
353
|
+
}
|
|
354
|
+
/** clientId of parent (non-summarizing) container that owns summarizer container */
|
|
355
|
+
get summarizerClientId() {
|
|
356
|
+
return this.summarizerClientElection?.electedClientId;
|
|
357
|
+
}
|
|
358
|
+
get disposed() {
|
|
359
|
+
return this._disposed;
|
|
360
|
+
}
|
|
361
|
+
get summarizer() {
|
|
362
|
+
assert(this._summarizer !== undefined, 0x257 /* "This is not summarizing container" */);
|
|
363
|
+
return this._summarizer;
|
|
364
|
+
}
|
|
365
|
+
isSummariesDisabled() {
|
|
366
|
+
return this.summaryConfiguration.state === "disabled";
|
|
367
|
+
}
|
|
368
|
+
isHeuristicsDisabled() {
|
|
369
|
+
return this.summaryConfiguration.state === "disableHeuristics";
|
|
370
|
+
}
|
|
371
|
+
getMaxOpsSinceLastSummary() {
|
|
372
|
+
return this.summaryConfiguration.state !== "disabled"
|
|
373
|
+
? this.summaryConfiguration.maxOpsSinceLastSummary
|
|
374
|
+
: 0;
|
|
375
|
+
}
|
|
376
|
+
getInitialSummarizerDelayMs() {
|
|
377
|
+
// back-compat: initialSummarizerDelayMs was moved from ISummaryRuntimeOptions
|
|
378
|
+
// to ISummaryConfiguration in 0.60.
|
|
379
|
+
if (this.runtimeOptions.summaryOptions.initialSummarizerDelayMs !== undefined) {
|
|
380
|
+
return this.runtimeOptions.summaryOptions.initialSummarizerDelayMs;
|
|
381
|
+
}
|
|
382
|
+
return this.summaryConfiguration.state !== "disabled"
|
|
383
|
+
? this.summaryConfiguration.initialSummarizerDelayMs
|
|
384
|
+
: 0;
|
|
385
|
+
}
|
|
172
386
|
/**
|
|
173
387
|
* @internal
|
|
174
388
|
*/
|
|
175
|
-
constructor(context, registry, metadata, electedSummarizerData, chunks, dataStoreAliasMap, runtimeOptions, containerScope, logger, existing, blobManagerSnapshot, _storage, idCompressor, requestHandler, summaryConfiguration = {
|
|
389
|
+
constructor(context, registry, metadata, electedSummarizerData, chunks, dataStoreAliasMap, runtimeOptions, containerScope, logger, existing, blobManagerSnapshot, _storage, idCompressor, provideEntryPoint, requestHandler, summaryConfiguration = {
|
|
176
390
|
// the defaults
|
|
177
391
|
...DefaultSummaryConfiguration,
|
|
178
392
|
// the runtime configuration overrides
|
|
179
393
|
...runtimeOptions.summaryOptions?.summaryConfigOverrides,
|
|
180
|
-
}
|
|
394
|
+
}) {
|
|
181
395
|
super();
|
|
182
396
|
this.registry = registry;
|
|
183
397
|
this.runtimeOptions = runtimeOptions;
|
|
@@ -514,233 +728,9 @@ export class ContainerRuntime extends TypedEventEmitter {
|
|
|
514
728
|
assert(this._summarizer !== undefined, 0x5bf /* Summarizer object is undefined in a summarizer client */);
|
|
515
729
|
return this._summarizer;
|
|
516
730
|
}
|
|
517
|
-
return
|
|
731
|
+
return provideEntryPoint(this);
|
|
518
732
|
});
|
|
519
733
|
}
|
|
520
|
-
/**
|
|
521
|
-
* @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
522
|
-
*/
|
|
523
|
-
get IFluidRouter() {
|
|
524
|
-
return this;
|
|
525
|
-
}
|
|
526
|
-
/**
|
|
527
|
-
* @deprecated - use loadRuntime instead.
|
|
528
|
-
* Load the stores from a snapshot and returns the runtime.
|
|
529
|
-
* @param context - Context of the container.
|
|
530
|
-
* @param registryEntries - Mapping to the stores.
|
|
531
|
-
* @param requestHandler - Request handlers for the container runtime
|
|
532
|
-
* @param runtimeOptions - Additional options to be passed to the runtime
|
|
533
|
-
* @param existing - (optional) When loading from an existing snapshot. Precedes context.existing if provided
|
|
534
|
-
* @param containerRuntimeCtor - (optional) Constructor to use to create the ContainerRuntime instance. This
|
|
535
|
-
* allows mixin classes to leverage this method to define their own async initializer.
|
|
536
|
-
*/
|
|
537
|
-
static async load(context, registryEntries, requestHandler, runtimeOptions = {}, containerScope = context.scope, existing, containerRuntimeCtor = ContainerRuntime) {
|
|
538
|
-
let existingFlag = true;
|
|
539
|
-
if (!existing) {
|
|
540
|
-
existingFlag = false;
|
|
541
|
-
}
|
|
542
|
-
return this.loadRuntime({
|
|
543
|
-
context,
|
|
544
|
-
registryEntries,
|
|
545
|
-
existing: existingFlag,
|
|
546
|
-
requestHandler,
|
|
547
|
-
runtimeOptions,
|
|
548
|
-
containerScope,
|
|
549
|
-
containerRuntimeCtor,
|
|
550
|
-
});
|
|
551
|
-
}
|
|
552
|
-
/**
|
|
553
|
-
* Load the stores from a snapshot and returns the runtime.
|
|
554
|
-
* @param params - An object housing the runtime properties:
|
|
555
|
-
* - context - Context of the container.
|
|
556
|
-
* - registryEntries - Mapping from data store types to their corresponding factories.
|
|
557
|
-
* - existing - Pass 'true' if loading from an existing snapshot.
|
|
558
|
-
* - requestHandler - (optional) Request handler for the request() method of the container runtime.
|
|
559
|
-
* Only relevant for back-compat while we remove the request() method and move fully to entryPoint as the main pattern.
|
|
560
|
-
* - runtimeOptions - Additional options to be passed to the runtime
|
|
561
|
-
* - containerScope - runtime services provided with context
|
|
562
|
-
* - containerRuntimeCtor - Constructor to use to create the ContainerRuntime instance.
|
|
563
|
-
* This allows mixin classes to leverage this method to define their own async initializer.
|
|
564
|
-
* - initializeEntryPoint - Promise that resolves to an object which will act as entryPoint for the Container.
|
|
565
|
-
* This object should provide all the functionality that the Container is expected to provide to the loader layer.
|
|
566
|
-
*/
|
|
567
|
-
static async loadRuntime(params) {
|
|
568
|
-
const { context, registryEntries, existing, requestHandler, runtimeOptions = {}, containerScope = {}, containerRuntimeCtor = ContainerRuntime, } = params;
|
|
569
|
-
const initializeEntryPoint = params.initializeEntryPoint ??
|
|
570
|
-
(async (containerRuntime) => ({
|
|
571
|
-
get IFluidRouter() {
|
|
572
|
-
return this;
|
|
573
|
-
},
|
|
574
|
-
async request(req) {
|
|
575
|
-
return containerRuntime.request(req);
|
|
576
|
-
},
|
|
577
|
-
}));
|
|
578
|
-
// If taggedLogger exists, use it. Otherwise, wrap the vanilla logger:
|
|
579
|
-
// back-compat: Remove the TaggedLoggerAdapter fallback once all the host are using loader > 0.45
|
|
580
|
-
const backCompatContext = context;
|
|
581
|
-
const passLogger = backCompatContext.taggedLogger ??
|
|
582
|
-
// eslint-disable-next-line import/no-deprecated
|
|
583
|
-
new TaggedLoggerAdapter(backCompatContext.logger);
|
|
584
|
-
const logger = createChildLogger({
|
|
585
|
-
logger: passLogger,
|
|
586
|
-
properties: {
|
|
587
|
-
all: {
|
|
588
|
-
runtimeVersion: pkgVersion,
|
|
589
|
-
},
|
|
590
|
-
},
|
|
591
|
-
});
|
|
592
|
-
const { summaryOptions = {}, gcOptions = {}, loadSequenceNumberVerification = "close", flushMode = defaultFlushMode, compressionOptions = defaultCompressionConfig, maxBatchSizeInBytes = defaultMaxBatchSizeInBytes, enableRuntimeIdCompressor = false, chunkSizeInBytes = defaultChunkSizeInBytes, enableOpReentryCheck = false, enableGroupedBatching = false, } = runtimeOptions;
|
|
593
|
-
const registry = new FluidDataStoreRegistry(registryEntries);
|
|
594
|
-
const tryFetchBlob = async (blobName) => {
|
|
595
|
-
const blobId = context.baseSnapshot?.blobs[blobName];
|
|
596
|
-
if (context.baseSnapshot && blobId) {
|
|
597
|
-
// IContainerContext storage api return type still has undefined in 0.39 package version.
|
|
598
|
-
// So once we release 0.40 container-defn package we can remove this check.
|
|
599
|
-
assert(context.storage !== undefined, 0x1f5 /* "Attached state should have storage" */);
|
|
600
|
-
return readAndParse(context.storage, blobId);
|
|
601
|
-
}
|
|
602
|
-
};
|
|
603
|
-
const [chunks, metadata, electedSummarizerData, aliases, serializedIdCompressor] = await Promise.all([
|
|
604
|
-
tryFetchBlob(chunksBlobName),
|
|
605
|
-
tryFetchBlob(metadataBlobName),
|
|
606
|
-
tryFetchBlob(electedSummarizerBlobName),
|
|
607
|
-
tryFetchBlob(aliasBlobName),
|
|
608
|
-
tryFetchBlob(idCompressorBlobName),
|
|
609
|
-
]);
|
|
610
|
-
// read snapshot blobs needed for BlobManager to load
|
|
611
|
-
const blobManagerSnapshot = await BlobManager.load(context.baseSnapshot?.trees[blobsTreeName], async (id) => {
|
|
612
|
-
// IContainerContext storage api return type still has undefined in 0.39 package version.
|
|
613
|
-
// So once we release 0.40 container-defn package we can remove this check.
|
|
614
|
-
assert(context.storage !== undefined, 0x256 /* "storage undefined in attached container" */);
|
|
615
|
-
return readAndParse(context.storage, id);
|
|
616
|
-
});
|
|
617
|
-
// Verify summary runtime sequence number matches protocol sequence number.
|
|
618
|
-
const runtimeSequenceNumber = metadata?.message?.sequenceNumber;
|
|
619
|
-
// When we load with pending state, we reuse an old snapshot so we don't expect these numbers to match
|
|
620
|
-
if (!context.pendingLocalState && runtimeSequenceNumber !== undefined) {
|
|
621
|
-
const protocolSequenceNumber = context.deltaManager.initialSequenceNumber;
|
|
622
|
-
// Unless bypass is explicitly set, then take action when sequence numbers mismatch.
|
|
623
|
-
if (loadSequenceNumberVerification !== "bypass" &&
|
|
624
|
-
runtimeSequenceNumber !== protocolSequenceNumber) {
|
|
625
|
-
// "Load from summary, runtime metadata sequenceNumber !== initialSequenceNumber"
|
|
626
|
-
const error = new DataCorruptionError(
|
|
627
|
-
// pre-0.58 error message: SummaryMetadataMismatch
|
|
628
|
-
"Summary metadata mismatch", { runtimeVersion: pkgVersion, runtimeSequenceNumber, protocolSequenceNumber });
|
|
629
|
-
if (loadSequenceNumberVerification === "log") {
|
|
630
|
-
logger.sendErrorEvent({ eventName: "SequenceNumberMismatch" }, error);
|
|
631
|
-
}
|
|
632
|
-
else {
|
|
633
|
-
context.closeFn(error);
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
const idCompressorEnabled = metadata?.idCompressorEnabled ?? runtimeOptions.enableRuntimeIdCompressor ?? false;
|
|
638
|
-
let idCompressor;
|
|
639
|
-
if (idCompressorEnabled) {
|
|
640
|
-
const { IdCompressor, createSessionId } = await import("./id-compressor");
|
|
641
|
-
idCompressor =
|
|
642
|
-
serializedIdCompressor !== undefined
|
|
643
|
-
? IdCompressor.deserialize(serializedIdCompressor, createSessionId())
|
|
644
|
-
: IdCompressor.create(logger);
|
|
645
|
-
}
|
|
646
|
-
const runtime = new containerRuntimeCtor(context, registry, metadata, electedSummarizerData, chunks ?? [], aliases ?? [], {
|
|
647
|
-
summaryOptions,
|
|
648
|
-
gcOptions,
|
|
649
|
-
loadSequenceNumberVerification,
|
|
650
|
-
flushMode,
|
|
651
|
-
compressionOptions,
|
|
652
|
-
maxBatchSizeInBytes,
|
|
653
|
-
chunkSizeInBytes,
|
|
654
|
-
enableRuntimeIdCompressor,
|
|
655
|
-
enableOpReentryCheck,
|
|
656
|
-
enableGroupedBatching,
|
|
657
|
-
}, containerScope, logger, existing, blobManagerSnapshot, context.storage, idCompressor, requestHandler, undefined, // summaryConfiguration
|
|
658
|
-
initializeEntryPoint);
|
|
659
|
-
// Apply stashed ops with a reference sequence number equal to the sequence number of the snapshot,
|
|
660
|
-
// or zero. This must be done before Container replays saved ops.
|
|
661
|
-
await runtime.pendingStateManager.applyStashedOpsAt(runtimeSequenceNumber ?? 0);
|
|
662
|
-
// Initialize the base state of the runtime before it's returned.
|
|
663
|
-
await runtime.initializeBaseState();
|
|
664
|
-
return runtime;
|
|
665
|
-
}
|
|
666
|
-
get clientId() {
|
|
667
|
-
return this._getClientId();
|
|
668
|
-
}
|
|
669
|
-
get storage() {
|
|
670
|
-
return this._storage;
|
|
671
|
-
}
|
|
672
|
-
/** @deprecated - The functionality is no longer exposed publicly */
|
|
673
|
-
get reSubmitFn() {
|
|
674
|
-
return (type, contents, localOpMetadata, opMetadata) => this.reSubmitCore({ type, contents }, localOpMetadata, opMetadata);
|
|
675
|
-
// Note: compatDetails is not included in this deprecated API
|
|
676
|
-
}
|
|
677
|
-
get flushMode() {
|
|
678
|
-
return this._flushMode;
|
|
679
|
-
}
|
|
680
|
-
get scope() {
|
|
681
|
-
return this.containerScope;
|
|
682
|
-
}
|
|
683
|
-
get IFluidDataStoreRegistry() {
|
|
684
|
-
return this.registry;
|
|
685
|
-
}
|
|
686
|
-
get attachState() {
|
|
687
|
-
return this._getAttachState();
|
|
688
|
-
}
|
|
689
|
-
get IFluidHandleContext() {
|
|
690
|
-
return this.handleContext;
|
|
691
|
-
}
|
|
692
|
-
/**
|
|
693
|
-
* Invokes the given callback and expects that no ops are submitted
|
|
694
|
-
* until execution finishes. If an op is submitted, an error will be raised.
|
|
695
|
-
*
|
|
696
|
-
* Can be disabled by feature gate `Fluid.ContainerRuntime.DisableOpReentryCheck`
|
|
697
|
-
*
|
|
698
|
-
* @param callback - the callback to be invoked
|
|
699
|
-
*/
|
|
700
|
-
ensureNoDataModelChanges(callback) {
|
|
701
|
-
this.ensureNoDataModelChangesCalls++;
|
|
702
|
-
try {
|
|
703
|
-
return callback();
|
|
704
|
-
}
|
|
705
|
-
finally {
|
|
706
|
-
this.ensureNoDataModelChangesCalls--;
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
get connected() {
|
|
710
|
-
return this._connected;
|
|
711
|
-
}
|
|
712
|
-
/** clientId of parent (non-summarizing) container that owns summarizer container */
|
|
713
|
-
get summarizerClientId() {
|
|
714
|
-
return this.summarizerClientElection?.electedClientId;
|
|
715
|
-
}
|
|
716
|
-
get disposed() {
|
|
717
|
-
return this._disposed;
|
|
718
|
-
}
|
|
719
|
-
get summarizer() {
|
|
720
|
-
assert(this._summarizer !== undefined, 0x257 /* "This is not summarizing container" */);
|
|
721
|
-
return this._summarizer;
|
|
722
|
-
}
|
|
723
|
-
isSummariesDisabled() {
|
|
724
|
-
return this.summaryConfiguration.state === "disabled";
|
|
725
|
-
}
|
|
726
|
-
isHeuristicsDisabled() {
|
|
727
|
-
return this.summaryConfiguration.state === "disableHeuristics";
|
|
728
|
-
}
|
|
729
|
-
getMaxOpsSinceLastSummary() {
|
|
730
|
-
return this.summaryConfiguration.state !== "disabled"
|
|
731
|
-
? this.summaryConfiguration.maxOpsSinceLastSummary
|
|
732
|
-
: 0;
|
|
733
|
-
}
|
|
734
|
-
getInitialSummarizerDelayMs() {
|
|
735
|
-
// back-compat: initialSummarizerDelayMs was moved from ISummaryRuntimeOptions
|
|
736
|
-
// to ISummaryConfiguration in 0.60.
|
|
737
|
-
if (this.runtimeOptions.summaryOptions.initialSummarizerDelayMs !== undefined) {
|
|
738
|
-
return this.runtimeOptions.summaryOptions.initialSummarizerDelayMs;
|
|
739
|
-
}
|
|
740
|
-
return this.summaryConfiguration.state !== "disabled"
|
|
741
|
-
? this.summaryConfiguration.initialSummarizerDelayMs
|
|
742
|
-
: 0;
|
|
743
|
-
}
|
|
744
734
|
/**
|
|
745
735
|
* Initializes the state from the base snapshot this container runtime loaded from.
|
|
746
736
|
*/
|
|
@@ -1283,6 +1273,7 @@ export class ContainerRuntime extends TypedEventEmitter {
|
|
|
1283
1273
|
* @param wait - True if you want to wait for it.
|
|
1284
1274
|
* @deprecated - Use getAliasedDataStoreEntryPoint instead to get an aliased data store's entry point.
|
|
1285
1275
|
*/
|
|
1276
|
+
// eslint-disable-next-line import/no-deprecated
|
|
1286
1277
|
async getRootDataStore(id, wait = true) {
|
|
1287
1278
|
return this.getRootDataStoreChannel(id, wait);
|
|
1288
1279
|
}
|
|
@@ -2469,6 +2460,7 @@ export class ContainerRuntime extends TypedEventEmitter {
|
|
|
2469
2460
|
* * Forms a function that will request a Summarizer.
|
|
2470
2461
|
* @param loaderRouter - the loader acting as an IFluidRouter
|
|
2471
2462
|
* */
|
|
2463
|
+
// eslint-disable-next-line import/no-deprecated
|
|
2472
2464
|
formRequestSummarizerFn(loaderRouter) {
|
|
2473
2465
|
return async () => {
|
|
2474
2466
|
const request = {
|
|
@@ -2483,6 +2475,7 @@ export class ContainerRuntime extends TypedEventEmitter {
|
|
|
2483
2475
|
},
|
|
2484
2476
|
url: "/_summarizer",
|
|
2485
2477
|
};
|
|
2478
|
+
// eslint-disable-next-line import/no-deprecated
|
|
2486
2479
|
const fluidObject = await requestFluidObject(loaderRouter, request);
|
|
2487
2480
|
const summarizer = fluidObject.ISummarizer;
|
|
2488
2481
|
if (!summarizer) {
|