@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summaryManager.js","sourceRoot":"","sources":["../../src/summary/summaryManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EACN,iBAAiB,EAEjB,gBAAgB,GAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,C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EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAC7D,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACvB,CAAC;;AA3RuB,kCAAmB,GAAG,CAAC,KAA0B,EAAE,EAAE,CAC5E,KAAK,KAAK,mBAAmB,CAAC,QAAQ,IAAI,KAAK,KAAK,mBAAmB,CAAC,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIDisposable,\n\tIEvent,\n\tIEventProvider,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport {\n\tcreateChildLogger,\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n} from \"@fluidframework/telemetry-utils\";\nimport { DriverErrorTypes } from \"@fluidframework/driver-definitions\";\nimport { IThrottler } from \"../throttler\";\nimport { ISummarizerClientElection } from \"./summarizerClientElection\";\nimport {\n\tEnqueueSummarizeResult,\n\tIEnqueueSummarizeOptions,\n\tIOnDemandSummarizeOptions,\n\tISummarizeEventProps,\n\tISummarizeResults,\n\tISummarizer,\n\tISummarizerEvents,\n\tSummarizerStopReason,\n} from \"./summarizerTypes\";\nimport { SummaryCollection } from \"./summaryCollection\";\nimport { Summarizer } from \"./summarizer\";\n\nconst defaultInitialDelayMs = 5000;\nconst defaultOpsToBypassInitialDelay = 4000;\n\nexport enum SummaryManagerState {\n\tOff = 0,\n\tStarting = 1,\n\tRunning = 2,\n\tStopping = 3,\n}\n\n// Please note that all reasons in this list are not errors,\n// and thus they are not raised today to parent container as error.\n// If this needs to be changed in future, we should re-evaluate what and how we raise to summarizer\ntype StopReason = Extract<\n\tSummarizerStopReason,\n\t\"parentNotConnected\" | \"notElectedParent\" | \"notElectedClient\"\n>;\ntype ShouldSummarizeState =\n\t| { shouldSummarize: true }\n\t| { shouldSummarize: false; stopReason: StopReason };\n\nexport interface IConnectedEvents extends IEvent {\n\t(event: \"connected\", listener: (clientId: string) => void);\n\t(event: \"disconnected\", listener: () => void);\n}\n\n/**\n * IConnectedState describes an object that SummaryManager can watch to observe connection/disconnection.\n *\n * Under current implementation, its role will be fulfilled by the ContainerRuntime, but this could be replaced\n * with anything else that fulfills the contract if we want to shift the layer that the SummaryManager lives at.\n */\nexport interface IConnectedState extends IEventProvider<IConnectedEvents> {\n\treadonly connected: boolean;\n\n\t/**\n\t * Under current implementation this is undefined if we've never connected, otherwise it's the clientId from our\n\t * latest connection (even if we've since disconnected!). Although this happens to be the behavior we want in\n\t * SummaryManager, I suspect that globally we may eventually want to modify this behavior (e.g. make clientId\n\t * undefined while disconnected). To protect against this, let's assume this field can't be trusted while\n\t * disconnected and instead separately track \"latest clientId\" in SummaryManager.\n\t */\n\treadonly clientId: string | undefined;\n}\n\nexport interface ISummaryManagerConfig {\n\tinitialDelayMs: number;\n\topsToBypassInitialDelay: number;\n}\n\n/**\n * SummaryManager is created by parent container (i.e. interactive container with clientType !== \"summarizer\") only.\n * It observes changes in calculated summarizer and reacts to changes by either creating summarizer client or\n * stopping existing summarizer client.\n */\nexport class SummaryManager extends TypedEventEmitter<ISummarizerEvents> implements IDisposable {\n\tprivate readonly logger: ITelemetryLoggerExt;\n\tprivate readonly opsToBypassInitialDelay: number;\n\tprivate readonly initialDelayMs: number;\n\tprivate latestClientId: string | undefined;\n\tprivate state = SummaryManagerState.Off;\n\tprivate summarizer?: ISummarizer;\n\tprivate _disposed = false;\n\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\n\tpublic get currentState() {\n\t\treturn this.state;\n\t}\n\n\tconstructor(\n\t\tprivate readonly clientElection: ISummarizerClientElection,\n\t\tprivate readonly connectedState: IConnectedState,\n\t\tprivate readonly summaryCollection: Pick<\n\t\t\tSummaryCollection,\n\t\t\t\"opsSinceLastAck\" | \"addOpListener\" | \"removeOpListener\"\n\t\t>,\n\t\tparentLogger: ITelemetryBaseLogger,\n\t\t/** Creates summarizer by asking interactive container to spawn summarizing container and\n\t\t * get back its Summarizer instance. */\n\t\tprivate readonly requestSummarizerFn: () => Promise<ISummarizer>,\n\t\tprivate readonly startThrottler: IThrottler,\n\t\t{\n\t\t\tinitialDelayMs = defaultInitialDelayMs,\n\t\t\topsToBypassInitialDelay = defaultOpsToBypassInitialDelay,\n\t\t}: Readonly<Partial<ISummaryManagerConfig>> = {},\n\t\tprivate readonly disableHeuristics?: boolean,\n\t) {\n\t\tsuper();\n\n\t\tthis.logger = createChildLogger({\n\t\t\tlogger: parentLogger,\n\t\t\tnamespace: \"SummaryManager\",\n\t\t\tproperties: {\n\t\t\t\tall: { clientId: () => this.latestClientId },\n\t\t\t},\n\t\t});\n\n\t\tthis.connectedState.on(\"connected\", this.handleConnected);\n\t\tthis.connectedState.on(\"disconnected\", this.handleDisconnected);\n\t\tthis.latestClientId = this.connectedState.clientId;\n\n\t\tthis.opsToBypassInitialDelay = opsToBypassInitialDelay;\n\t\tthis.initialDelayMs = initialDelayMs;\n\t}\n\n\t/**\n\t * Until start is called, the SummaryManager won't begin attempting to start summarization. This ensures there's\n\t * a window between construction and starting where the caller can attach listeners.\n\t */\n\tpublic start(): void {\n\t\tthis.clientElection.on(\"electedSummarizerChanged\", this.refreshSummarizer);\n\t\tthis.refreshSummarizer();\n\t}\n\n\tprivate readonly handleConnected = (clientId: string) => {\n\t\tthis.latestClientId = clientId;\n\t\t// If we have a summarizer, it should have been either cancelled on disconnected by now.\n\t\t// But because of lastSummary process, it can still hang around, so there is not much we can\n\t\t// check or assert.\n\t\tthis.refreshSummarizer();\n\t};\n\n\tprivate readonly handleDisconnected = () => {\n\t\tthis.refreshSummarizer();\n\t};\n\n\tprivate readonly handleSummarizeEvent = (eventProps: ISummarizeEventProps) => {\n\t\tthis.emit(\"summarize\", eventProps);\n\t};\n\n\tprivate static readonly isStartingOrRunning = (state: SummaryManagerState) =>\n\t\tstate === SummaryManagerState.Starting || state === SummaryManagerState.Running;\n\n\tprivate getShouldSummarizeState(): ShouldSummarizeState {\n\t\t// Note that if we're in the Running state, the electedClient may be a summarizer client, so we can't\n\t\t// enforce connectedState.clientId === clientElection.electedClientId. But once we're Running, we should\n\t\t// only transition to Stopping when the electedParentId changes. Stopping the summarizer without\n\t\t// changing the electedParent will just cause us to transition to Starting again.\n\n\t\t// New Parent has been elected and it is not the current client, or\n\t\tif (this.connectedState.clientId !== this.clientElection.electedParentId) {\n\t\t\treturn { shouldSummarize: false, stopReason: \"notElectedParent\" };\n\t\t}\n\n\t\t// We are not already running the summarizer and we are not the current elected client id.\n\t\tif (\n\t\t\tthis.state !== SummaryManagerState.Running &&\n\t\t\tthis.connectedState.clientId !== this.clientElection.electedClientId\n\t\t) {\n\t\t\treturn { shouldSummarize: false, stopReason: \"notElectedClient\" };\n\t\t}\n\n\t\tif (!this.connectedState.connected) {\n\t\t\treturn { shouldSummarize: false, stopReason: \"parentNotConnected\" };\n\t\t}\n\n\t\tif (this.disposed) {\n\t\t\tassert(false, 0x260 /* \"Disposed should mean disconnected!\" */);\n\t\t} else {\n\t\t\treturn { shouldSummarize: true };\n\t\t}\n\t}\n\n\tprivate readonly refreshSummarizer = () => {\n\t\t// Transition states depending on shouldSummarize, which is a calculated property\n\t\t// that is only true if this client is connected and is the elected summarizer.\n\t\tconst shouldSummarizeState = this.getShouldSummarizeState();\n\t\tswitch (this.state) {\n\t\t\tcase SummaryManagerState.Off: {\n\t\t\t\tif (shouldSummarizeState.shouldSummarize) {\n\t\t\t\t\tthis.startSummarization();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase SummaryManagerState.Starting: {\n\t\t\t\t// Cannot take any action until summarizer is created\n\t\t\t\t// state transition will occur after creation\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase SummaryManagerState.Running: {\n\t\t\t\tif (shouldSummarizeState.shouldSummarize === false) {\n\t\t\t\t\tthis.stop(shouldSummarizeState.stopReason);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase SummaryManagerState.Stopping: {\n\t\t\t\t// Cannot take any action until running summarizer finishes\n\t\t\t\t// state transition will occur after it stops\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate startSummarization() {\n\t\tassert(this.state === SummaryManagerState.Off, 0x261 /* \"Expected: off\" */);\n\t\tthis.state = SummaryManagerState.Starting;\n\n\t\tassert(this.summarizer === undefined, 0x262 /* \"Old summarizer is still working!\" */);\n\n\t\tthis.delayBeforeCreatingSummarizer()\n\t\t\t.then(async (startWithInitialDelay: boolean) => {\n\t\t\t\t// Re-validate that it need to be running. Due to asynchrony, it may be not the case anymore\n\t\t\t\t// but only if creation was delayed. If it was not, then we want to ensure we always create\n\t\t\t\t// a summarizer to kick off lastSummary. Without that, we would not be able to summarize and get\n\t\t\t\t// document out of broken state if it has too many ops and ordering service keeps nacking main\n\t\t\t\t// container (and thus it goes into cycle of reconnects)\n\t\t\t\t// If we can't run the LastSummary, simply return as to avoid paying the cost of launching\n\t\t\t\t// the summarizer at all.\n\t\t\t\tconst shouldSummarizeStateEarlyStage = this.getShouldSummarizeState();\n\t\t\t\tif (\n\t\t\t\t\tstartWithInitialDelay &&\n\t\t\t\t\tshouldSummarizeStateEarlyStage.shouldSummarize === false\n\t\t\t\t) {\n\t\t\t\t\treturn `early exit ${shouldSummarizeStateEarlyStage.stopReason}`;\n\t\t\t\t}\n\n\t\t\t\t// We transition to Running before requesting the summarizer, because after requesting we can't predict\n\t\t\t\t// when the electedClient will be replaced with the new summarizer client.\n\t\t\t\t// The alternative would be to let connectedState.clientId !== clientElection.electedClientId when\n\t\t\t\t// state === Starting || state === Running.\n\t\t\t\tassert(\n\t\t\t\t\tthis.state === SummaryManagerState.Starting,\n\t\t\t\t\t0x263 /* \"Expected: starting\" */,\n\t\t\t\t);\n\t\t\t\tthis.state = SummaryManagerState.Running;\n\n\t\t\t\tconst summarizer = await this.requestSummarizerFn();\n\t\t\t\tthis.summarizer = summarizer;\n\t\t\t\tthis.summarizer.on(\"summarize\", this.handleSummarizeEvent);\n\n\t\t\t\t// Re-validate that it need to be running. Due to asynchrony, it may be not the case anymore\n\t\t\t\t// If we can't run the LastSummary, simply return as to avoid paying the cost of launching\n\t\t\t\t// the summarizer at all.\n\t\t\t\tconst shouldSummarizeState = this.getShouldSummarizeState();\n\t\t\t\tif (shouldSummarizeState.shouldSummarize === false) {\n\t\t\t\t\t// In order to allow the last summary to run, we not only need a stop reason that would\n\t\t\t\t\t// allow it but also, startWithInitialDelay to be false (start the summarization immediately),\n\t\t\t\t\t// which would happen when we have a high enough number of unsummarized ops.\n\t\t\t\t\tif (\n\t\t\t\t\t\tstartWithInitialDelay ||\n\t\t\t\t\t\t!Summarizer.stopReasonCanRunLastSummary(shouldSummarizeState.stopReason)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.state = SummaryManagerState.Starting;\n\t\t\t\t\t\tsummarizer.stop(shouldSummarizeState.stopReason);\n\t\t\t\t\t\treturn `early exit after starting summarizer ${shouldSummarizeState.stopReason}`;\n\t\t\t\t\t}\n\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"LastAttemptToSummarize\",\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst clientId = this.latestClientId!;\n\n\t\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\t\tthis.logger,\n\t\t\t\t\t{ eventName: \"RunningSummarizer\", attempt: this.startThrottler.numAttempts },\n\t\t\t\t\tasync () => summarizer.run(clientId, this.disableHeuristics),\n\t\t\t\t);\n\t\t\t})\n\t\t\t.then((reason: string) => {\n\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"EndingSummarizer\",\n\t\t\t\t\treason,\n\t\t\t\t});\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"EndingSummarizer\",\n\t\t\t\t\t\treason: \"exception\",\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\n\t\t\t\t// Most of exceptions happen due to container being closed while loading it, due to\n\t\t\t\t// summarizer container loosing connection while load.\n\t\t\t\t// Not worth reporting such errors as errors. That said, we might miss some real errors if\n\t\t\t\t// we ignore blindly, so try to narrow signature we are looking for - skip logging\n\t\t\t\t// error only if this client should no longer be a summarizer (which in practice\n\t\t\t\t// means it also lost connection), and error happened on load (we do not have summarizer).\n\t\t\t\t// We could annotate the error raised in Container.load where the container closed during load with no error\n\t\t\t\t// and check for that case here, but that does not seem to be necessary.\n\t\t\t\tif (\n\t\t\t\t\tthis.getShouldSummarizeState().shouldSummarize ||\n\t\t\t\t\tthis.summarizer !== undefined\n\t\t\t\t) {\n\t\t\t\t\t// Report any failure as an error unless it was due to cancellation (like \"disconnected\" error)\n\t\t\t\t\t// If failure happened on container load, we may not yet realized that socket disconnected, so check\n\t\t\t\t\t// offlineError.\n\t\t\t\t\tconst category =\n\t\t\t\t\t\terror?.errorType === DriverErrorTypes.offlineError ? \"generic\" : \"error\";\n\t\t\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teventName: \"SummarizerException\",\n\t\t\t\t\t\t\tcategory,\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tassert(this.state !== SummaryManagerState.Off, 0x264 /* \"Expected: Not Off\" */);\n\t\t\t\tthis.state = SummaryManagerState.Off;\n\n\t\t\t\tthis.summarizer?.off(\"summarize\", this.handleSummarizeEvent);\n\t\t\t\tthis.summarizer?.close();\n\t\t\t\tthis.summarizer = undefined;\n\n\t\t\t\tif (this.getShouldSummarizeState().shouldSummarize) {\n\t\t\t\t\tthis.startSummarization();\n\t\t\t\t}\n\t\t\t});\n\t}\n\n\tprivate stop(reason: SummarizerStopReason) {\n\t\tif (!SummaryManager.isStartingOrRunning(this.state)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.state = SummaryManagerState.Stopping;\n\n\t\t// Stopping the running summarizer client should trigger a change\n\t\t// in states when the running summarizer closes\n\t\tthis.summarizer?.stop(reason);\n\t}\n\n\t/**\n\t * Implements initial delay before creating summarizer\n\t * @returns `true`, if creation is delayed due to heuristics (not many ops to summarize).\n\t * `false` if summarizer should start immediately due to too many unsummarized ops.\n\t */\n\tprivate async delayBeforeCreatingSummarizer(): Promise<boolean> {\n\t\t// throttle creation of new summarizer containers to prevent spamming the server with websocket connections\n\t\tlet delayMs = this.startThrottler.getDelay();\n\n\t\t// We have been elected the summarizer. Some day we may be able to summarize with a live document but for\n\t\t// now we play it safe and launch a second copy.\n\t\tthis.logger.sendTelemetryEvent({\n\t\t\teventName: \"CreatingSummarizer\",\n\t\t\tthrottlerDelay: delayMs,\n\t\t\tinitialDelay: this.initialDelayMs,\n\t\t\tstartThrottlerMaxDelayMs: this.startThrottler.maxDelayMs,\n\t\t\topsSinceLastAck: this.summaryCollection.opsSinceLastAck,\n\t\t\topsToBypassInitialDelay: this.opsToBypassInitialDelay,\n\t\t\telectedParentId: this.clientElection.electedParentId,\n\t\t\telectedClientId: this.clientElection.electedClientId,\n\t\t});\n\n\t\t// This delay helps ensure that last summarizer that might be left from previous client\n\t\t// has enough time to complete its last summary and thus new summarizer not conflict with previous one.\n\t\t// If, however, there are too many unsummarized ops, try to resolve it as quickly as possible, with\n\t\t// understanding that we may see nacks because of such quick action.\n\t\t// A better design would be for summarizer election logic to always select current summarizer as\n\t\t// summarizing client (i.e. clientType === \"summarizer\" can be elected) to ensure that nobody else can\n\t\t// summarizer while it finishes its work and moves to exit.\n\t\t// It also helps with pure boot scenario (single client) to offset expensive work a bit out from\n\t\t// critical boot sequence.\n\t\tlet startWithInitialDelay = false;\n\t\tif (this.summaryCollection.opsSinceLastAck < this.opsToBypassInitialDelay) {\n\t\t\tstartWithInitialDelay = true;\n\t\t\tdelayMs = Math.max(delayMs, this.initialDelayMs);\n\t\t}\n\n\t\tif (delayMs > 0) {\n\t\t\tlet timer;\n\t\t\tlet resolveOpPromiseFn;\n\t\t\t// Create a listener that will break the delay if we've exceeded the initial delay ops count.\n\t\t\tconst opsListenerFn = () => {\n\t\t\t\tif (this.summaryCollection.opsSinceLastAck >= this.opsToBypassInitialDelay) {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tresolveOpPromiseFn();\n\t\t\t\t}\n\t\t\t};\n\t\t\t// Create a Promise that will resolve when the delay expires.\n\t\t\tconst delayPromise = new Promise<void>((resolve) => {\n\t\t\t\ttimer = setTimeout(() => resolve(), delayMs);\n\t\t\t});\n\t\t\t// Create a Promise that will resolve if the ops count passes the threshold.\n\t\t\tconst opPromise = new Promise<void>((resolve) => {\n\t\t\t\tresolveOpPromiseFn = resolve;\n\t\t\t});\n\t\t\tthis.summaryCollection.addOpListener(opsListenerFn);\n\t\t\tawait Promise.race([delayPromise, opPromise]);\n\t\t\tthis.summaryCollection.removeOpListener(opsListenerFn);\n\t\t}\n\t\treturn startWithInitialDelay;\n\t}\n\n\tpublic summarizeOnDemand(options: IOnDemandSummarizeOptions): ISummarizeResults {\n\t\tif (this.summarizer === undefined) {\n\t\t\tthrow Error(\"No running summarizer client\");\n\t\t\t// TODO: could spawn a summarizer client temporarily.\n\t\t}\n\t\treturn this.summarizer.summarizeOnDemand(options);\n\t}\n\n\tpublic enqueueSummarize(options: IEnqueueSummarizeOptions): EnqueueSummarizeResult {\n\t\tif (this.summarizer === undefined) {\n\t\t\tthrow Error(\"No running summarizer client\");\n\t\t\t// TODO: could spawn a summarizer client temporarily.\n\t\t}\n\t\treturn this.summarizer.enqueueSummarize(options);\n\t}\n\n\tpublic dispose() {\n\t\tthis.clientElection.off(\"electedSummarizerChanged\", this.refreshSummarizer);\n\t\tthis.connectedState.off(\"connected\", this.handleConnected);\n\t\tthis.connectedState.off(\"disconnected\", this.handleDisconnected);\n\t\tthis.summarizer?.off(\"summarize\", this.handleSummarizeEvent);\n\t\tthis._disposed = true;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"summaryManager.js","sourceRoot":"","sources":["../../src/summary/summaryManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EACN,iBAAiB,EAEjB,gBAAgB,GAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AActE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,qBAAqB,GAAG,IAAI,CAAC;AACnC,MAAM,8BAA8B,GAAG,IAAI,CAAC;AAE5C,MAAM,CAAN,IAAY,mBAKX;AALD,WAAY,mBAAmB;IAC9B,2DAAO,CAAA;IACP,qEAAY,CAAA;IACZ,mEAAW,CAAA;IACX,qEAAY,CAAA;AACb,CAAC,EALW,mBAAmB,KAAnB,mBAAmB,QAK9B;AA0CD;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,iBAAoC;IASvE,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IAED,IAAW,YAAY;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAED,YACkB,cAAyC,EACzC,cAA+B,EAC/B,iBAGhB,EACD,YAAkC;IAClC;2CACuC;IACtB,mBAA+C,EAC/C,cAA0B,EAC3C,EACC,cAAc,GAAG,qBAAqB,EACtC,uBAAuB,GAAG,8BAA8B,MACX,EAAE,EAC/B,iBAA2B;QAE5C,KAAK,EAAE,CAAC;QAjBS,mBAAc,GAAd,cAAc,CAA2B;QACzC,mBAAc,GAAd,cAAc,CAAiB;QAC/B,sB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8BAA8B,CAAC,CAAC;YAC5C,qDAAqD;SACrD;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;IAEM,OAAO;QACb,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,0BAA0B,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC5E,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QAC3D,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACjE,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAC7D,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACvB,CAAC;;AA3RuB,kCAAmB,GAAG,CAAC,KAA0B,EAAE,EAAE,CAC5E,KAAK,KAAK,mBAAmB,CAAC,QAAQ,IAAI,KAAK,KAAK,mBAAmB,CAAC,OAAO,AADrC,CACsC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIDisposable,\n\tIEvent,\n\tIEventProvider,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport {\n\tcreateChildLogger,\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n} from \"@fluidframework/telemetry-utils\";\nimport { DriverErrorTypes } from \"@fluidframework/driver-definitions\";\nimport { IThrottler } from \"../throttler\";\nimport { ISummarizerClientElection } from \"./summarizerClientElection\";\nimport {\n\tEnqueueSummarizeResult,\n\tIEnqueueSummarizeOptions,\n\tIOnDemandSummarizeOptions,\n\tISummarizeEventProps,\n\tISummarizeResults,\n\tISummarizer,\n\tISummarizerEvents,\n\tSummarizerStopReason,\n} from \"./summarizerTypes\";\nimport { SummaryCollection } from \"./summaryCollection\";\nimport { Summarizer } from \"./summarizer\";\n\nconst defaultInitialDelayMs = 5000;\nconst defaultOpsToBypassInitialDelay = 4000;\n\nexport enum SummaryManagerState {\n\tOff = 0,\n\tStarting = 1,\n\tRunning = 2,\n\tStopping = 3,\n}\n\n// Please note that all reasons in this list are not errors,\n// and thus they are not raised today to parent container as error.\n// If this needs to be changed in future, we should re-evaluate what and how we raise to summarizer\ntype StopReason = Extract<\n\tSummarizerStopReason,\n\t\"parentNotConnected\" | \"notElectedParent\" | \"notElectedClient\"\n>;\ntype ShouldSummarizeState =\n\t| { shouldSummarize: true }\n\t| { shouldSummarize: false; stopReason: StopReason };\n\nexport interface IConnectedEvents extends IEvent {\n\t(event: \"connected\", listener: (clientId: string) => void);\n\t(event: \"disconnected\", listener: () => void);\n}\n\n/**\n * IConnectedState describes an object that SummaryManager can watch to observe connection/disconnection.\n *\n * Under current implementation, its role will be fulfilled by the ContainerRuntime, but this could be replaced\n * with anything else that fulfills the contract if we want to shift the layer that the SummaryManager lives at.\n */\nexport interface IConnectedState extends IEventProvider<IConnectedEvents> {\n\treadonly connected: boolean;\n\n\t/**\n\t * Under current implementation this is undefined if we've never connected, otherwise it's the clientId from our\n\t * latest connection (even if we've since disconnected!). Although this happens to be the behavior we want in\n\t * SummaryManager, I suspect that globally we may eventually want to modify this behavior (e.g. make clientId\n\t * undefined while disconnected). To protect against this, let's assume this field can't be trusted while\n\t * disconnected and instead separately track \"latest clientId\" in SummaryManager.\n\t */\n\treadonly clientId: string | undefined;\n}\n\nexport interface ISummaryManagerConfig {\n\tinitialDelayMs: number;\n\topsToBypassInitialDelay: number;\n}\n\n/**\n * SummaryManager is created by parent container (i.e. interactive container with clientType !== \"summarizer\") only.\n * It observes changes in calculated summarizer and reacts to changes by either creating summarizer client or\n * stopping existing summarizer client.\n */\nexport class SummaryManager extends TypedEventEmitter<ISummarizerEvents> implements IDisposable {\n\tprivate readonly logger: ITelemetryLoggerExt;\n\tprivate readonly opsToBypassInitialDelay: number;\n\tprivate readonly initialDelayMs: number;\n\tprivate latestClientId: string | undefined;\n\tprivate state = SummaryManagerState.Off;\n\tprivate summarizer?: ISummarizer;\n\tprivate _disposed = false;\n\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\n\tpublic get currentState() {\n\t\treturn this.state;\n\t}\n\n\tconstructor(\n\t\tprivate readonly clientElection: ISummarizerClientElection,\n\t\tprivate readonly connectedState: IConnectedState,\n\t\tprivate readonly summaryCollection: Pick<\n\t\t\tSummaryCollection,\n\t\t\t\"opsSinceLastAck\" | \"addOpListener\" | \"removeOpListener\"\n\t\t>,\n\t\tparentLogger: ITelemetryBaseLogger,\n\t\t/** Creates summarizer by asking interactive container to spawn summarizing container and\n\t\t * get back its Summarizer instance. */\n\t\tprivate readonly requestSummarizerFn: () => Promise<ISummarizer>,\n\t\tprivate readonly startThrottler: IThrottler,\n\t\t{\n\t\t\tinitialDelayMs = defaultInitialDelayMs,\n\t\t\topsToBypassInitialDelay = defaultOpsToBypassInitialDelay,\n\t\t}: Readonly<Partial<ISummaryManagerConfig>> = {},\n\t\tprivate readonly disableHeuristics?: boolean,\n\t) {\n\t\tsuper();\n\n\t\tthis.logger = createChildLogger({\n\t\t\tlogger: parentLogger,\n\t\t\tnamespace: \"SummaryManager\",\n\t\t\tproperties: {\n\t\t\t\tall: { clientId: () => this.latestClientId },\n\t\t\t},\n\t\t});\n\n\t\tthis.connectedState.on(\"connected\", this.handleConnected);\n\t\tthis.connectedState.on(\"disconnected\", this.handleDisconnected);\n\t\tthis.latestClientId = this.connectedState.clientId;\n\n\t\tthis.opsToBypassInitialDelay = opsToBypassInitialDelay;\n\t\tthis.initialDelayMs = initialDelayMs;\n\t}\n\n\t/**\n\t * Until start is called, the SummaryManager won't begin attempting to start summarization. This ensures there's\n\t * a window between construction and starting where the caller can attach listeners.\n\t */\n\tpublic start(): void {\n\t\tthis.clientElection.on(\"electedSummarizerChanged\", this.refreshSummarizer);\n\t\tthis.refreshSummarizer();\n\t}\n\n\tprivate readonly handleConnected = (clientId: string) => {\n\t\tthis.latestClientId = clientId;\n\t\t// If we have a summarizer, it should have been either cancelled on disconnected by now.\n\t\t// But because of lastSummary process, it can still hang around, so there is not much we can\n\t\t// check or assert.\n\t\tthis.refreshSummarizer();\n\t};\n\n\tprivate readonly handleDisconnected = () => {\n\t\tthis.refreshSummarizer();\n\t};\n\n\tprivate readonly handleSummarizeEvent = (eventProps: ISummarizeEventProps) => {\n\t\tthis.emit(\"summarize\", eventProps);\n\t};\n\n\tprivate static readonly isStartingOrRunning = (state: SummaryManagerState) =>\n\t\tstate === SummaryManagerState.Starting || state === SummaryManagerState.Running;\n\n\tprivate getShouldSummarizeState(): ShouldSummarizeState {\n\t\t// Note that if we're in the Running state, the electedClient may be a summarizer client, so we can't\n\t\t// enforce connectedState.clientId === clientElection.electedClientId. But once we're Running, we should\n\t\t// only transition to Stopping when the electedParentId changes. Stopping the summarizer without\n\t\t// changing the electedParent will just cause us to transition to Starting again.\n\n\t\t// New Parent has been elected and it is not the current client, or\n\t\tif (this.connectedState.clientId !== this.clientElection.electedParentId) {\n\t\t\treturn { shouldSummarize: false, stopReason: \"notElectedParent\" };\n\t\t}\n\n\t\t// We are not already running the summarizer and we are not the current elected client id.\n\t\tif (\n\t\t\tthis.state !== SummaryManagerState.Running &&\n\t\t\tthis.connectedState.clientId !== this.clientElection.electedClientId\n\t\t) {\n\t\t\treturn { shouldSummarize: false, stopReason: \"notElectedClient\" };\n\t\t}\n\n\t\tif (!this.connectedState.connected) {\n\t\t\treturn { shouldSummarize: false, stopReason: \"parentNotConnected\" };\n\t\t}\n\n\t\tif (this.disposed) {\n\t\t\tassert(false, 0x260 /* \"Disposed should mean disconnected!\" */);\n\t\t} else {\n\t\t\treturn { shouldSummarize: true };\n\t\t}\n\t}\n\n\tprivate readonly refreshSummarizer = () => {\n\t\t// Transition states depending on shouldSummarize, which is a calculated property\n\t\t// that is only true if this client is connected and is the elected summarizer.\n\t\tconst shouldSummarizeState = this.getShouldSummarizeState();\n\t\tswitch (this.state) {\n\t\t\tcase SummaryManagerState.Off: {\n\t\t\t\tif (shouldSummarizeState.shouldSummarize) {\n\t\t\t\t\tthis.startSummarization();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase SummaryManagerState.Starting: {\n\t\t\t\t// Cannot take any action until summarizer is created\n\t\t\t\t// state transition will occur after creation\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase SummaryManagerState.Running: {\n\t\t\t\tif (shouldSummarizeState.shouldSummarize === false) {\n\t\t\t\t\tthis.stop(shouldSummarizeState.stopReason);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase SummaryManagerState.Stopping: {\n\t\t\t\t// Cannot take any action until running summarizer finishes\n\t\t\t\t// state transition will occur after it stops\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate startSummarization() {\n\t\tassert(this.state === SummaryManagerState.Off, 0x261 /* \"Expected: off\" */);\n\t\tthis.state = SummaryManagerState.Starting;\n\n\t\tassert(this.summarizer === undefined, 0x262 /* \"Old summarizer is still working!\" */);\n\n\t\tthis.delayBeforeCreatingSummarizer()\n\t\t\t.then(async (startWithInitialDelay: boolean) => {\n\t\t\t\t// Re-validate that it need to be running. Due to asynchrony, it may be not the case anymore\n\t\t\t\t// but only if creation was delayed. If it was not, then we want to ensure we always create\n\t\t\t\t// a summarizer to kick off lastSummary. Without that, we would not be able to summarize and get\n\t\t\t\t// document out of broken state if it has too many ops and ordering service keeps nacking main\n\t\t\t\t// container (and thus it goes into cycle of reconnects)\n\t\t\t\t// If we can't run the LastSummary, simply return as to avoid paying the cost of launching\n\t\t\t\t// the summarizer at all.\n\t\t\t\tconst shouldSummarizeStateEarlyStage = this.getShouldSummarizeState();\n\t\t\t\tif (\n\t\t\t\t\tstartWithInitialDelay &&\n\t\t\t\t\tshouldSummarizeStateEarlyStage.shouldSummarize === false\n\t\t\t\t) {\n\t\t\t\t\treturn `early exit ${shouldSummarizeStateEarlyStage.stopReason}`;\n\t\t\t\t}\n\n\t\t\t\t// We transition to Running before requesting the summarizer, because after requesting we can't predict\n\t\t\t\t// when the electedClient will be replaced with the new summarizer client.\n\t\t\t\t// The alternative would be to let connectedState.clientId !== clientElection.electedClientId when\n\t\t\t\t// state === Starting || state === Running.\n\t\t\t\tassert(\n\t\t\t\t\tthis.state === SummaryManagerState.Starting,\n\t\t\t\t\t0x263 /* \"Expected: starting\" */,\n\t\t\t\t);\n\t\t\t\tthis.state = SummaryManagerState.Running;\n\n\t\t\t\tconst summarizer = await this.requestSummarizerFn();\n\t\t\t\tthis.summarizer = summarizer;\n\t\t\t\tthis.summarizer.on(\"summarize\", this.handleSummarizeEvent);\n\n\t\t\t\t// Re-validate that it need to be running. Due to asynchrony, it may be not the case anymore\n\t\t\t\t// If we can't run the LastSummary, simply return as to avoid paying the cost of launching\n\t\t\t\t// the summarizer at all.\n\t\t\t\tconst shouldSummarizeState = this.getShouldSummarizeState();\n\t\t\t\tif (shouldSummarizeState.shouldSummarize === false) {\n\t\t\t\t\t// In order to allow the last summary to run, we not only need a stop reason that would\n\t\t\t\t\t// allow it but also, startWithInitialDelay to be false (start the summarization immediately),\n\t\t\t\t\t// which would happen when we have a high enough number of unsummarized ops.\n\t\t\t\t\tif (\n\t\t\t\t\t\tstartWithInitialDelay ||\n\t\t\t\t\t\t!Summarizer.stopReasonCanRunLastSummary(shouldSummarizeState.stopReason)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.state = SummaryManagerState.Starting;\n\t\t\t\t\t\tsummarizer.stop(shouldSummarizeState.stopReason);\n\t\t\t\t\t\treturn `early exit after starting summarizer ${shouldSummarizeState.stopReason}`;\n\t\t\t\t\t}\n\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"LastAttemptToSummarize\",\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst clientId = this.latestClientId!;\n\n\t\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\t\tthis.logger,\n\t\t\t\t\t{ eventName: \"RunningSummarizer\", attempt: this.startThrottler.numAttempts },\n\t\t\t\t\tasync () => summarizer.run(clientId, this.disableHeuristics),\n\t\t\t\t);\n\t\t\t})\n\t\t\t.then((reason: string) => {\n\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"EndingSummarizer\",\n\t\t\t\t\treason,\n\t\t\t\t});\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"EndingSummarizer\",\n\t\t\t\t\t\treason: \"exception\",\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\n\t\t\t\t// Most of exceptions happen due to container being closed while loading it, due to\n\t\t\t\t// summarizer container loosing connection while load.\n\t\t\t\t// Not worth reporting such errors as errors. That said, we might miss some real errors if\n\t\t\t\t// we ignore blindly, so try to narrow signature we are looking for - skip logging\n\t\t\t\t// error only if this client should no longer be a summarizer (which in practice\n\t\t\t\t// means it also lost connection), and error happened on load (we do not have summarizer).\n\t\t\t\t// We could annotate the error raised in Container.load where the container closed during load with no error\n\t\t\t\t// and check for that case here, but that does not seem to be necessary.\n\t\t\t\tif (\n\t\t\t\t\tthis.getShouldSummarizeState().shouldSummarize ||\n\t\t\t\t\tthis.summarizer !== undefined\n\t\t\t\t) {\n\t\t\t\t\t// Report any failure as an error unless it was due to cancellation (like \"disconnected\" error)\n\t\t\t\t\t// If failure happened on container load, we may not yet realized that socket disconnected, so check\n\t\t\t\t\t// offlineError.\n\t\t\t\t\tconst category =\n\t\t\t\t\t\terror?.errorType === DriverErrorTypes.offlineError ? \"generic\" : \"error\";\n\t\t\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teventName: \"SummarizerException\",\n\t\t\t\t\t\t\tcategory,\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tassert(this.state !== SummaryManagerState.Off, 0x264 /* \"Expected: Not Off\" */);\n\t\t\t\tthis.state = SummaryManagerState.Off;\n\n\t\t\t\tthis.summarizer?.off(\"summarize\", this.handleSummarizeEvent);\n\t\t\t\tthis.summarizer?.close();\n\t\t\t\tthis.summarizer = undefined;\n\n\t\t\t\tif (this.getShouldSummarizeState().shouldSummarize) {\n\t\t\t\t\tthis.startSummarization();\n\t\t\t\t}\n\t\t\t});\n\t}\n\n\tprivate stop(reason: SummarizerStopReason) {\n\t\tif (!SummaryManager.isStartingOrRunning(this.state)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.state = SummaryManagerState.Stopping;\n\n\t\t// Stopping the running summarizer client should trigger a change\n\t\t// in states when the running summarizer closes\n\t\tthis.summarizer?.stop(reason);\n\t}\n\n\t/**\n\t * Implements initial delay before creating summarizer\n\t * @returns `true`, if creation is delayed due to heuristics (not many ops to summarize).\n\t * `false` if summarizer should start immediately due to too many unsummarized ops.\n\t */\n\tprivate async delayBeforeCreatingSummarizer(): Promise<boolean> {\n\t\t// throttle creation of new summarizer containers to prevent spamming the server with websocket connections\n\t\tlet delayMs = this.startThrottler.getDelay();\n\n\t\t// We have been elected the summarizer. Some day we may be able to summarize with a live document but for\n\t\t// now we play it safe and launch a second copy.\n\t\tthis.logger.sendTelemetryEvent({\n\t\t\teventName: \"CreatingSummarizer\",\n\t\t\tthrottlerDelay: delayMs,\n\t\t\tinitialDelay: this.initialDelayMs,\n\t\t\tstartThrottlerMaxDelayMs: this.startThrottler.maxDelayMs,\n\t\t\topsSinceLastAck: this.summaryCollection.opsSinceLastAck,\n\t\t\topsToBypassInitialDelay: this.opsToBypassInitialDelay,\n\t\t\telectedParentId: this.clientElection.electedParentId,\n\t\t\telectedClientId: this.clientElection.electedClientId,\n\t\t});\n\n\t\t// This delay helps ensure that last summarizer that might be left from previous client\n\t\t// has enough time to complete its last summary and thus new summarizer not conflict with previous one.\n\t\t// If, however, there are too many unsummarized ops, try to resolve it as quickly as possible, with\n\t\t// understanding that we may see nacks because of such quick action.\n\t\t// A better design would be for summarizer election logic to always select current summarizer as\n\t\t// summarizing client (i.e. clientType === \"summarizer\" can be elected) to ensure that nobody else can\n\t\t// summarizer while it finishes its work and moves to exit.\n\t\t// It also helps with pure boot scenario (single client) to offset expensive work a bit out from\n\t\t// critical boot sequence.\n\t\tlet startWithInitialDelay = false;\n\t\tif (this.summaryCollection.opsSinceLastAck < this.opsToBypassInitialDelay) {\n\t\t\tstartWithInitialDelay = true;\n\t\t\tdelayMs = Math.max(delayMs, this.initialDelayMs);\n\t\t}\n\n\t\tif (delayMs > 0) {\n\t\t\tlet timer;\n\t\t\tlet resolveOpPromiseFn;\n\t\t\t// Create a listener that will break the delay if we've exceeded the initial delay ops count.\n\t\t\tconst opsListenerFn = () => {\n\t\t\t\tif (this.summaryCollection.opsSinceLastAck >= this.opsToBypassInitialDelay) {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tresolveOpPromiseFn();\n\t\t\t\t}\n\t\t\t};\n\t\t\t// Create a Promise that will resolve when the delay expires.\n\t\t\tconst delayPromise = new Promise<void>((resolve) => {\n\t\t\t\ttimer = setTimeout(() => resolve(), delayMs);\n\t\t\t});\n\t\t\t// Create a Promise that will resolve if the ops count passes the threshold.\n\t\t\tconst opPromise = new Promise<void>((resolve) => {\n\t\t\t\tresolveOpPromiseFn = resolve;\n\t\t\t});\n\t\t\tthis.summaryCollection.addOpListener(opsListenerFn);\n\t\t\tawait Promise.race([delayPromise, opPromise]);\n\t\t\tthis.summaryCollection.removeOpListener(opsListenerFn);\n\t\t}\n\t\treturn startWithInitialDelay;\n\t}\n\n\tpublic summarizeOnDemand(options: IOnDemandSummarizeOptions): ISummarizeResults {\n\t\tif (this.summarizer === undefined) {\n\t\t\tthrow Error(\"No running summarizer client\");\n\t\t\t// TODO: could spawn a summarizer client temporarily.\n\t\t}\n\t\treturn this.summarizer.summarizeOnDemand(options);\n\t}\n\n\tpublic enqueueSummarize(options: IEnqueueSummarizeOptions): EnqueueSummarizeResult {\n\t\tif (this.summarizer === undefined) {\n\t\t\tthrow Error(\"No running summarizer client\");\n\t\t\t// TODO: could spawn a summarizer client temporarily.\n\t\t}\n\t\treturn this.summarizer.enqueueSummarize(options);\n\t}\n\n\tpublic dispose() {\n\t\tthis.clientElection.off(\"electedSummarizerChanged\", this.refreshSummarizer);\n\t\tthis.connectedState.off(\"connected\", this.handleConnected);\n\t\tthis.connectedState.off(\"disconnected\", this.handleDisconnected);\n\t\tthis.summarizer?.off(\"summarize\", this.handleSummarizeEvent);\n\t\tthis._disposed = true;\n\t}\n}\n"]}
|
package/lib/throttler.js
CHANGED
|
@@ -7,22 +7,6 @@
|
|
|
7
7
|
* Delay is based on previous attempts within specified time window, subtracting delay time.
|
|
8
8
|
*/
|
|
9
9
|
export class Throttler {
|
|
10
|
-
constructor(
|
|
11
|
-
/** Width of sliding delay window in milliseconds. */
|
|
12
|
-
delayWindowMs,
|
|
13
|
-
/** Maximum delay allowed in milliseconds. */
|
|
14
|
-
maxDelayMs,
|
|
15
|
-
/**
|
|
16
|
-
* Delay function used to calculate what the delay should be.
|
|
17
|
-
* The input is the number of attempts that occurred within the sliding window.
|
|
18
|
-
* The result is the calculated delay in milliseconds.
|
|
19
|
-
*/
|
|
20
|
-
delayFn) {
|
|
21
|
-
this.delayWindowMs = delayWindowMs;
|
|
22
|
-
this.maxDelayMs = maxDelayMs;
|
|
23
|
-
this.delayFn = delayFn;
|
|
24
|
-
this.startTimes = [];
|
|
25
|
-
}
|
|
26
10
|
get numAttempts() {
|
|
27
11
|
return this.startTimes.length;
|
|
28
12
|
}
|
|
@@ -40,6 +24,22 @@ export class Throttler {
|
|
|
40
24
|
get latestAttemptTime() {
|
|
41
25
|
return this.startTimes.length > 0 ? this.startTimes[this.startTimes.length - 1] : undefined;
|
|
42
26
|
}
|
|
27
|
+
constructor(
|
|
28
|
+
/** Width of sliding delay window in milliseconds. */
|
|
29
|
+
delayWindowMs,
|
|
30
|
+
/** Maximum delay allowed in milliseconds. */
|
|
31
|
+
maxDelayMs,
|
|
32
|
+
/**
|
|
33
|
+
* Delay function used to calculate what the delay should be.
|
|
34
|
+
* The input is the number of attempts that occurred within the sliding window.
|
|
35
|
+
* The result is the calculated delay in milliseconds.
|
|
36
|
+
*/
|
|
37
|
+
delayFn) {
|
|
38
|
+
this.delayWindowMs = delayWindowMs;
|
|
39
|
+
this.maxDelayMs = maxDelayMs;
|
|
40
|
+
this.delayFn = delayFn;
|
|
41
|
+
this.startTimes = [];
|
|
42
|
+
}
|
|
43
43
|
getDelay() {
|
|
44
44
|
const now = Date.now();
|
|
45
45
|
const latestAttemptTime = this.latestAttemptTime;
|
package/lib/throttler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"throttler.js","sourceRoot":"","sources":["../src/throttler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA2BH;;;GAGG;AACH,MAAM,OAAO,SAAS;
|
|
1
|
+
{"version":3,"file":"throttler.js","sourceRoot":"","sources":["../src/throttler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA2BH;;;GAGG;AACH,MAAM,OAAO,SAAS;IAGrB,IAAW,WAAW;QACrB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACI,WAAW;QACjB,OAAO,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACH,IAAW,iBAAiB;QAC3B,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,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,iDAAiD;AACjD,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC5C,aAAqB,EACrB,EAAE,WAAW,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,GAAG,EAAE,EACnC,EAAE,CACH,YAAY,CAAC;IACZ,WAAW;IACX,MAAM,EAAE,WAAW,GAAG,aAAa,GAAG,MAAM;CAC5C,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport interface IThrottler {\n\t/**\n\t * Computes what the throttle delay should be, and records an attempt\n\t * which will be used for calculating future attempt delays.\n\t */\n\tgetDelay(): number;\n\n\t/**\n\t * Number of attempts that occurred within the sliding window as of\n\t * the most recent delay computation.\n\t */\n\treadonly numAttempts: number;\n\n\t/** Width of sliding delay window in milliseconds. */\n\treadonly delayWindowMs: number;\n\t/** Maximum delay allowed in milliseconds. */\n\treadonly maxDelayMs: number;\n\t/**\n\t * Delay function used to calculate what the delay should be.\n\t * The input is the number of attempts that occurred within the sliding window.\n\t * The result is the calculated delay in milliseconds.\n\t */\n\treadonly delayFn: (numAttempts: number) => number;\n}\n\n/**\n * Used to give increasing delay times for throttling a single functionality.\n * Delay is based on previous attempts within specified time window, subtracting delay time.\n */\nexport class Throttler implements IThrottler {\n\tprivate startTimes: number[] = [];\n\n\tpublic get numAttempts() {\n\t\treturn this.startTimes.length;\n\t}\n\n\t/**\n\t * Gets all attempt start times after compensating for the delay times\n\t * by adding the delay times to the actual times.\n\t */\n\tpublic getAttempts(): readonly number[] {\n\t\treturn [...this.startTimes];\n\t}\n\n\t/**\n\t * Latest attempt time after compensating for the delay time itself\n\t * by adding the delay time to the actual time.\n\t */\n\tpublic get latestAttemptTime() {\n\t\treturn this.startTimes.length > 0 ? this.startTimes[this.startTimes.length - 1] : undefined;\n\t}\n\n\tconstructor(\n\t\t/** Width of sliding delay window in milliseconds. */\n\t\tpublic readonly delayWindowMs: number,\n\t\t/** Maximum delay allowed in milliseconds. */\n\t\tpublic readonly maxDelayMs: number,\n\t\t/**\n\t\t * Delay function used to calculate what the delay should be.\n\t\t * The input is the number of attempts that occurred within the sliding window.\n\t\t * The result is the calculated delay in milliseconds.\n\t\t */\n\t\tpublic readonly delayFn: (numAttempts: number) => number,\n\t) {}\n\n\tpublic getDelay() {\n\t\tconst now = Date.now();\n\n\t\tconst latestAttemptTime = this.latestAttemptTime;\n\t\tif (latestAttemptTime !== undefined) {\n\t\t\t// If getDelay was called sooner than the most recent delay,\n\t\t\t// subtract the remaining time, since we previously added it.\n\t\t\tconst earlyMs = latestAttemptTime - now;\n\t\t\tif (earlyMs > 0) {\n\t\t\t\tthis.startTimes = this.startTimes.map((t) => t - earlyMs);\n\t\t\t}\n\t\t}\n\n\t\t// Remove all attempts that have already fallen out of the window.\n\t\tthis.startTimes = this.startTimes.filter((t) => now - t < this.delayWindowMs);\n\n\t\t// Compute delay, but do not exceed the specified max delay.\n\t\tconst delayMs = Math.min(this.delayFn(this.startTimes.length), this.maxDelayMs);\n\n\t\t// Record this attempt start time.\n\t\tthis.startTimes.push(now);\n\n\t\t// Account for the delay time, by effectively removing it from the delay window.\n\t\tthis.startTimes = this.startTimes.map((t) => t + delayMs);\n\n\t\tif (delayMs === this.maxDelayMs) {\n\t\t\t// We hit max delay, so adding more won't affect anything.\n\t\t\t// Shift off oldest time to stop this array from growing forever.\n\t\t\tthis.startTimes.shift();\n\t\t}\n\n\t\treturn delayMs;\n\t}\n}\n\n/**\n * Helper function to generate simple exponential throttle functions.\n * f(n) = [coefficient] x ([multiplier]^n) + [flatOffset]\n * where n = number of attempts, and f(n) = delay time in milliseconds.\n * If not provided, coefficient will default to 1, multiplier to 2,\n * minimum delay to 0, and the offset to 0, yielding:\n * 0 ms, 2 ms, 4 ms, 8 ms, ..., 2^n ms\n * where M = multiplier; an exponential back-off.\n * Use initialDelay to decide what should happen when numAttempts is 0,\n * leave it undefined to not special case.\n */\nexport const formExponentialFn =\n\t({\n\t\tmultiplier = 2,\n\t\tcoefficient = 1,\n\t\toffset = 0,\n\t\tinitialDelay = undefined as number | undefined,\n\t} = {}): IThrottler[\"delayFn\"] =>\n\t(numAttempts) =>\n\t\tMath.max(\n\t\t\t0,\n\t\t\tnumAttempts <= 0 && initialDelay !== undefined\n\t\t\t\t? initialDelay\n\t\t\t\t: coefficient * Math.pow(multiplier, numAttempts) + offset,\n\t\t);\n\n/** f(n) = C x (B^(n+A)) + F = (C x B^A) x B^n + F */\nexport const formExponentialFnWithAttemptOffset = (\n\tattemptOffset: number,\n\t{\n\t\tmultiplier = 2,\n\t\tcoefficient = 1,\n\t\toffset = 0,\n\t\tinitialDelay = undefined as number | undefined,\n\t} = {},\n) =>\n\tformExponentialFn({\n\t\tmultiplier,\n\t\tcoefficient: coefficient * Math.pow(multiplier, attemptOffset),\n\t\toffset,\n\t\tinitialDelay,\n\t});\n\n/**\n * Helper function to generate simple linear throttle functions.\n * f(n) = [coefficient] x n + [flatOffset]\n * where n = number of attempts, and f(n) = delay time in milliseconds.\n * If not provided, coefficient will default to 1, and offset to 0, yielding:\n * 0 ms, 1 ms, 2 ms, 3 ms, ..., n ms delays; a linear back-off.\n */\nexport const formLinearFn =\n\t({ coefficient = 1, offset = 0 } = {}): IThrottler[\"delayFn\"] =>\n\t(numAttempts) =>\n\t\tMath.max(0, coefficient * numAttempts + offset);\n\n/** f(n) = C x (n+A) + F = C x n + (C x A + F) */\nexport const formLinearFnWithAttemptOffset = (\n\tattemptOffset: number,\n\t{ coefficient = 1, offset = 0 } = {},\n) =>\n\tformLinearFn({\n\t\tcoefficient,\n\t\toffset: coefficient * attemptOffset + offset,\n\t});\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/container-runtime",
|
|
3
|
-
"version": "2.0.0-internal.
|
|
3
|
+
"version": "2.0.0-internal.7.0.0",
|
|
4
4
|
"description": "Fluid container runtime",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -35,18 +35,18 @@
|
|
|
35
35
|
"temp-directory": "nyc/.nyc_output"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@fluid-internal/client-utils": ">=2.0.0-internal.
|
|
39
|
-
"@fluidframework/container-definitions": ">=2.0.0-internal.
|
|
40
|
-
"@fluidframework/container-runtime-definitions": ">=2.0.0-internal.
|
|
41
|
-
"@fluidframework/core-interfaces": ">=2.0.0-internal.
|
|
42
|
-
"@fluidframework/core-utils": ">=2.0.0-internal.
|
|
43
|
-
"@fluidframework/datastore": ">=2.0.0-internal.
|
|
44
|
-
"@fluidframework/driver-definitions": ">=2.0.0-internal.
|
|
45
|
-
"@fluidframework/driver-utils": ">=2.0.0-internal.
|
|
46
|
-
"@fluidframework/protocol-definitions": "^
|
|
47
|
-
"@fluidframework/runtime-definitions": ">=2.0.0-internal.
|
|
48
|
-
"@fluidframework/runtime-utils": ">=2.0.0-internal.
|
|
49
|
-
"@fluidframework/telemetry-utils": ">=2.0.0-internal.
|
|
38
|
+
"@fluid-internal/client-utils": ">=2.0.0-internal.7.0.0 <2.0.0-internal.7.1.0",
|
|
39
|
+
"@fluidframework/container-definitions": ">=2.0.0-internal.7.0.0 <2.0.0-internal.7.1.0",
|
|
40
|
+
"@fluidframework/container-runtime-definitions": ">=2.0.0-internal.7.0.0 <2.0.0-internal.7.1.0",
|
|
41
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.7.0.0 <2.0.0-internal.7.1.0",
|
|
42
|
+
"@fluidframework/core-utils": ">=2.0.0-internal.7.0.0 <2.0.0-internal.7.1.0",
|
|
43
|
+
"@fluidframework/datastore": ">=2.0.0-internal.7.0.0 <2.0.0-internal.7.1.0",
|
|
44
|
+
"@fluidframework/driver-definitions": ">=2.0.0-internal.7.0.0 <2.0.0-internal.7.1.0",
|
|
45
|
+
"@fluidframework/driver-utils": ">=2.0.0-internal.7.0.0 <2.0.0-internal.7.1.0",
|
|
46
|
+
"@fluidframework/protocol-definitions": "^3.0.0",
|
|
47
|
+
"@fluidframework/runtime-definitions": ">=2.0.0-internal.7.0.0 <2.0.0-internal.7.1.0",
|
|
48
|
+
"@fluidframework/runtime-utils": ">=2.0.0-internal.7.0.0 <2.0.0-internal.7.1.0",
|
|
49
|
+
"@fluidframework/telemetry-utils": ">=2.0.0-internal.7.0.0 <2.0.0-internal.7.1.0",
|
|
50
50
|
"double-ended-queue": "^2.1.0-0",
|
|
51
51
|
"events": "^3.1.0",
|
|
52
52
|
"lz4js": "^0.2.0",
|
|
@@ -54,16 +54,16 @@
|
|
|
54
54
|
"uuid": "^9.0.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@fluid-internal/stochastic-test-utils": ">=2.0.0-internal.
|
|
57
|
+
"@fluid-internal/stochastic-test-utils": ">=2.0.0-internal.7.0.0 <2.0.0-internal.7.1.0",
|
|
58
58
|
"@fluid-tools/benchmark": "^0.48.0",
|
|
59
|
-
"@fluid-tools/build-cli": "^0.
|
|
59
|
+
"@fluid-tools/build-cli": "^0.24.0",
|
|
60
60
|
"@fluidframework/build-common": "^2.0.0",
|
|
61
|
-
"@fluidframework/build-tools": "^0.
|
|
61
|
+
"@fluidframework/build-tools": "^0.24.0",
|
|
62
62
|
"@fluidframework/container-runtime-previous": "npm:@fluidframework/container-runtime@2.0.0-internal.6.3.0",
|
|
63
63
|
"@fluidframework/eslint-config-fluid": "^2.1.0",
|
|
64
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.
|
|
65
|
-
"@fluidframework/test-runtime-utils": ">=2.0.0-internal.
|
|
66
|
-
"@microsoft/api-extractor": "^7.
|
|
64
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.0.0 <2.0.0-internal.7.1.0",
|
|
65
|
+
"@fluidframework/test-runtime-utils": ">=2.0.0-internal.7.0.0 <2.0.0-internal.7.1.0",
|
|
66
|
+
"@microsoft/api-extractor": "^7.37.0",
|
|
67
67
|
"@types/double-ended-queue": "^2.1.0",
|
|
68
68
|
"@types/events": "^3.0.0",
|
|
69
69
|
"@types/mocha": "^9.1.1",
|
|
@@ -80,10 +80,45 @@
|
|
|
80
80
|
"prettier": "~2.6.2",
|
|
81
81
|
"rimraf": "^4.4.0",
|
|
82
82
|
"sinon": "^7.4.2",
|
|
83
|
-
"typescript": "~
|
|
83
|
+
"typescript": "~5.1.6"
|
|
84
84
|
},
|
|
85
85
|
"typeValidation": {
|
|
86
|
-
"broken": {
|
|
86
|
+
"broken": {
|
|
87
|
+
"ClassDeclaration_ContainerRuntime": {
|
|
88
|
+
"forwardCompat": false,
|
|
89
|
+
"backCompat": false
|
|
90
|
+
},
|
|
91
|
+
"InterfaceDeclaration_IAckedSummary": {
|
|
92
|
+
"backCompat": false
|
|
93
|
+
},
|
|
94
|
+
"InterfaceDeclaration_IAckSummaryResult": {
|
|
95
|
+
"backCompat": false
|
|
96
|
+
},
|
|
97
|
+
"InterfaceDeclaration_IBroadcastSummaryResult": {
|
|
98
|
+
"backCompat": false
|
|
99
|
+
},
|
|
100
|
+
"InterfaceDeclaration_ISummaryOpMessage": {
|
|
101
|
+
"backCompat": false
|
|
102
|
+
},
|
|
103
|
+
"InterfaceDeclaration_ISummaryNackMessage": {
|
|
104
|
+
"backCompat": false
|
|
105
|
+
},
|
|
106
|
+
"ClassDeclaration_Summarizer": {
|
|
107
|
+
"backCompat": false
|
|
108
|
+
},
|
|
109
|
+
"ClassDeclaration_SummaryCollection": {
|
|
110
|
+
"backCompat": false
|
|
111
|
+
},
|
|
112
|
+
"InterfaceDeclaration_ISummarizerRuntime": {
|
|
113
|
+
"backCompat": false
|
|
114
|
+
},
|
|
115
|
+
"InterfaceDeclaration_INackSummaryResult": {
|
|
116
|
+
"backCompat": false
|
|
117
|
+
},
|
|
118
|
+
"InterfaceDeclaration_ISummaryAckMessage": {
|
|
119
|
+
"backCompat": false
|
|
120
|
+
}
|
|
121
|
+
}
|
|
87
122
|
},
|
|
88
123
|
"scripts": {
|
|
89
124
|
"build": "fluid-build . --task build",
|
package/src/containerRuntime.ts
CHANGED
|
@@ -8,9 +8,11 @@ import {
|
|
|
8
8
|
FluidObject,
|
|
9
9
|
IFluidHandle,
|
|
10
10
|
IFluidHandleContext,
|
|
11
|
+
// eslint-disable-next-line import/no-deprecated
|
|
11
12
|
IFluidRouter,
|
|
12
13
|
IRequest,
|
|
13
14
|
IResponse,
|
|
15
|
+
IProvideFluidHandleContext,
|
|
14
16
|
} from "@fluidframework/core-interfaces";
|
|
15
17
|
import {
|
|
16
18
|
IAudience,
|
|
@@ -97,6 +99,7 @@ import {
|
|
|
97
99
|
create404Response,
|
|
98
100
|
exceptionToResponse,
|
|
99
101
|
GCDataBuilder,
|
|
102
|
+
// eslint-disable-next-line import/no-deprecated
|
|
100
103
|
requestFluidObject,
|
|
101
104
|
seqFromTree,
|
|
102
105
|
calculateStats,
|
|
@@ -632,7 +635,12 @@ type MessageWithContext =
|
|
|
632
635
|
*/
|
|
633
636
|
export class ContainerRuntime
|
|
634
637
|
extends TypedEventEmitter<IContainerRuntimeEvents & ISummarizerEvents>
|
|
635
|
-
implements
|
|
638
|
+
implements
|
|
639
|
+
IContainerRuntime,
|
|
640
|
+
IRuntime,
|
|
641
|
+
ISummarizerRuntime,
|
|
642
|
+
ISummarizerInternalsProvider,
|
|
643
|
+
IProvideFluidHandleContext
|
|
636
644
|
{
|
|
637
645
|
/**
|
|
638
646
|
* @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
@@ -669,10 +677,15 @@ export class ContainerRuntime
|
|
|
669
677
|
context,
|
|
670
678
|
registryEntries,
|
|
671
679
|
existing: existingFlag,
|
|
672
|
-
requestHandler,
|
|
673
680
|
runtimeOptions,
|
|
674
681
|
containerScope,
|
|
675
682
|
containerRuntimeCtor,
|
|
683
|
+
requestHandler,
|
|
684
|
+
provideEntryPoint: () => {
|
|
685
|
+
throw new UsageError(
|
|
686
|
+
"ContainerRuntime.load is deprecated and should no longer be used",
|
|
687
|
+
);
|
|
688
|
+
},
|
|
676
689
|
});
|
|
677
690
|
}
|
|
678
691
|
|
|
@@ -688,7 +701,7 @@ export class ContainerRuntime
|
|
|
688
701
|
* - containerScope - runtime services provided with context
|
|
689
702
|
* - containerRuntimeCtor - Constructor to use to create the ContainerRuntime instance.
|
|
690
703
|
* This allows mixin classes to leverage this method to define their own async initializer.
|
|
691
|
-
* -
|
|
704
|
+
* - provideEntryPoint - Promise that resolves to an object which will act as entryPoint for the Container.
|
|
692
705
|
* This object should provide all the functionality that the Container is expected to provide to the loader layer.
|
|
693
706
|
*/
|
|
694
707
|
public static async loadRuntime(params: {
|
|
@@ -698,30 +711,21 @@ export class ContainerRuntime
|
|
|
698
711
|
runtimeOptions?: IContainerRuntimeOptions;
|
|
699
712
|
containerScope?: FluidObject;
|
|
700
713
|
containerRuntimeCtor?: typeof ContainerRuntime;
|
|
714
|
+
/** @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md */
|
|
701
715
|
requestHandler?: (request: IRequest, runtime: IContainerRuntime) => Promise<IResponse>;
|
|
702
|
-
|
|
716
|
+
provideEntryPoint: (containerRuntime: IContainerRuntime) => Promise<FluidObject>;
|
|
703
717
|
}): Promise<ContainerRuntime> {
|
|
704
718
|
const {
|
|
705
719
|
context,
|
|
706
720
|
registryEntries,
|
|
707
721
|
existing,
|
|
708
722
|
requestHandler,
|
|
723
|
+
provideEntryPoint,
|
|
709
724
|
runtimeOptions = {},
|
|
710
725
|
containerScope = {},
|
|
711
726
|
containerRuntimeCtor = ContainerRuntime,
|
|
712
727
|
} = params;
|
|
713
728
|
|
|
714
|
-
const initializeEntryPoint =
|
|
715
|
-
params.initializeEntryPoint ??
|
|
716
|
-
(async (containerRuntime: IContainerRuntime) => ({
|
|
717
|
-
get IFluidRouter() {
|
|
718
|
-
return this;
|
|
719
|
-
},
|
|
720
|
-
async request(req) {
|
|
721
|
-
return containerRuntime.request(req);
|
|
722
|
-
},
|
|
723
|
-
}));
|
|
724
|
-
|
|
725
729
|
// If taggedLogger exists, use it. Otherwise, wrap the vanilla logger:
|
|
726
730
|
// back-compat: Remove the TaggedLoggerAdapter fallback once all the host are using loader > 0.45
|
|
727
731
|
const backCompatContext: IContainerContext | OldContainerContextWithLogger = context;
|
|
@@ -850,9 +854,9 @@ export class ContainerRuntime
|
|
|
850
854
|
blobManagerSnapshot,
|
|
851
855
|
context.storage,
|
|
852
856
|
idCompressor,
|
|
857
|
+
provideEntryPoint,
|
|
853
858
|
requestHandler,
|
|
854
859
|
undefined, // summaryConfiguration
|
|
855
|
-
initializeEntryPoint,
|
|
856
860
|
);
|
|
857
861
|
|
|
858
862
|
// Apply stashed ops with a reference sequence number equal to the sequence number of the snapshot,
|
|
@@ -878,17 +882,6 @@ export class ContainerRuntime
|
|
|
878
882
|
return this._storage;
|
|
879
883
|
}
|
|
880
884
|
|
|
881
|
-
/** @deprecated - The functionality is no longer exposed publicly */
|
|
882
|
-
public get reSubmitFn() {
|
|
883
|
-
return (
|
|
884
|
-
type: ContainerMessageType,
|
|
885
|
-
contents: any,
|
|
886
|
-
localOpMetadata: unknown,
|
|
887
|
-
opMetadata: Record<string, unknown> | undefined,
|
|
888
|
-
) => this.reSubmitCore({ type, contents }, localOpMetadata, opMetadata);
|
|
889
|
-
// Note: compatDetails is not included in this deprecated API
|
|
890
|
-
}
|
|
891
|
-
|
|
892
885
|
private readonly submitFn: (
|
|
893
886
|
type: MessageType,
|
|
894
887
|
contents: any,
|
|
@@ -1140,6 +1133,7 @@ export class ContainerRuntime
|
|
|
1140
1133
|
blobManagerSnapshot: IBlobManagerLoadInfo,
|
|
1141
1134
|
private readonly _storage: IDocumentStorageService,
|
|
1142
1135
|
idCompressor: (IIdCompressor & IIdCompressorCore) | undefined,
|
|
1136
|
+
provideEntryPoint: (containerRuntime: IContainerRuntime) => Promise<FluidObject>,
|
|
1143
1137
|
private readonly requestHandler?: (
|
|
1144
1138
|
request: IRequest,
|
|
1145
1139
|
runtime: IContainerRuntime,
|
|
@@ -1150,7 +1144,6 @@ export class ContainerRuntime
|
|
|
1150
1144
|
// the runtime configuration overrides
|
|
1151
1145
|
...runtimeOptions.summaryOptions?.summaryConfigOverrides,
|
|
1152
1146
|
},
|
|
1153
|
-
initializeEntryPoint?: (containerRuntime: IContainerRuntime) => Promise<FluidObject>,
|
|
1154
1147
|
) {
|
|
1155
1148
|
super();
|
|
1156
1149
|
|
|
@@ -1642,7 +1635,7 @@ export class ContainerRuntime
|
|
|
1642
1635
|
);
|
|
1643
1636
|
return this._summarizer;
|
|
1644
1637
|
}
|
|
1645
|
-
return
|
|
1638
|
+
return provideEntryPoint(this);
|
|
1646
1639
|
});
|
|
1647
1640
|
}
|
|
1648
1641
|
|
|
@@ -1753,10 +1746,10 @@ export class ContainerRuntime
|
|
|
1753
1746
|
/**
|
|
1754
1747
|
* {@inheritDoc @fluidframework/container-definitions#IRuntime.getEntryPoint}
|
|
1755
1748
|
*/
|
|
1756
|
-
public async getEntryPoint
|
|
1749
|
+
public async getEntryPoint(): Promise<FluidObject> {
|
|
1757
1750
|
return this.entryPoint;
|
|
1758
1751
|
}
|
|
1759
|
-
private readonly entryPoint: LazyPromise<FluidObject
|
|
1752
|
+
private readonly entryPoint: LazyPromise<FluidObject>;
|
|
1760
1753
|
|
|
1761
1754
|
private internalId(maybeAlias: string): string {
|
|
1762
1755
|
return this.dataStores.aliases.get(maybeAlias) ?? maybeAlias;
|
|
@@ -2338,6 +2331,7 @@ export class ContainerRuntime
|
|
|
2338
2331
|
* @param wait - True if you want to wait for it.
|
|
2339
2332
|
* @deprecated - Use getAliasedDataStoreEntryPoint instead to get an aliased data store's entry point.
|
|
2340
2333
|
*/
|
|
2334
|
+
// eslint-disable-next-line import/no-deprecated
|
|
2341
2335
|
public async getRootDataStore(id: string, wait = true): Promise<IFluidRouter> {
|
|
2342
2336
|
return this.getRootDataStoreChannel(id, wait);
|
|
2343
2337
|
}
|
|
@@ -2526,7 +2520,7 @@ export class ContainerRuntime
|
|
|
2526
2520
|
return false;
|
|
2527
2521
|
}
|
|
2528
2522
|
} else if (type === ContainerMessageType.FluidDataStoreOp) {
|
|
2529
|
-
const envelope = contents
|
|
2523
|
+
const envelope = contents;
|
|
2530
2524
|
if (envelope.address === agentSchedulerId) {
|
|
2531
2525
|
return false;
|
|
2532
2526
|
}
|
|
@@ -3664,7 +3658,7 @@ export class ContainerRuntime
|
|
|
3664
3658
|
case ContainerMessageType.FluidDataStoreOp:
|
|
3665
3659
|
// For operations, call rollbackDataStoreOp which will find the right store
|
|
3666
3660
|
// and trigger rollback on it.
|
|
3667
|
-
this.dataStores.rollbackDataStoreOp(contents
|
|
3661
|
+
this.dataStores.rollbackDataStoreOp(contents, localOpMetadata);
|
|
3668
3662
|
break;
|
|
3669
3663
|
default:
|
|
3670
3664
|
// Don't check message.compatDetails because this is for rolling back a local op so the type will be known
|
|
@@ -3914,6 +3908,7 @@ export class ContainerRuntime
|
|
|
3914
3908
|
* * Forms a function that will request a Summarizer.
|
|
3915
3909
|
* @param loaderRouter - the loader acting as an IFluidRouter
|
|
3916
3910
|
* */
|
|
3911
|
+
// eslint-disable-next-line import/no-deprecated
|
|
3917
3912
|
private formRequestSummarizerFn(loaderRouter: IFluidRouter) {
|
|
3918
3913
|
return async () => {
|
|
3919
3914
|
const request: IRequest = {
|
|
@@ -3929,6 +3924,7 @@ export class ContainerRuntime
|
|
|
3929
3924
|
url: "/_summarizer",
|
|
3930
3925
|
};
|
|
3931
3926
|
|
|
3927
|
+
// eslint-disable-next-line import/no-deprecated
|
|
3932
3928
|
const fluidObject = await requestFluidObject<FluidObject<ISummarizer>>(
|
|
3933
3929
|
loaderRouter,
|
|
3934
3930
|
request,
|
package/src/dataStore.ts
CHANGED
|
@@ -170,7 +170,7 @@ class DataStore implements IDataStore {
|
|
|
170
170
|
/**
|
|
171
171
|
* {@inheritDoc @fluidframework/runtime-definitions#IDataStore.entryPoint}
|
|
172
172
|
*/
|
|
173
|
-
get entryPoint(): IFluidHandle<FluidObject>
|
|
173
|
+
get entryPoint(): IFluidHandle<FluidObject> {
|
|
174
174
|
return this.fluidDataStoreChannel.entryPoint;
|
|
175
175
|
}
|
|
176
176
|
|
package/src/dataStoreContext.ts
CHANGED
|
@@ -740,11 +740,6 @@ export abstract class FluidDataStoreContext
|
|
|
740
740
|
this.makeLocallyVisibleFn();
|
|
741
741
|
}
|
|
742
742
|
|
|
743
|
-
/** @deprecated - To be replaced by calling makeLocallyVisible directly */
|
|
744
|
-
public bindToContext() {
|
|
745
|
-
this.makeLocallyVisibleFn();
|
|
746
|
-
}
|
|
747
|
-
|
|
748
743
|
protected bindRuntime(channel: IFluidDataStoreChannel) {
|
|
749
744
|
if (this.channel) {
|
|
750
745
|
throw new Error("Runtime already bound");
|
|
@@ -1206,7 +1201,7 @@ export class LocalDetachedFluidDataStoreContext
|
|
|
1206
1201
|
// of data store factories tends to construct the data object (at least kick off an async method that returns
|
|
1207
1202
|
// it); that code moved to the entryPoint initialization function, so we want to ensure it still executes
|
|
1208
1203
|
// before the data store is attached.
|
|
1209
|
-
await dataStoreChannel.entryPoint
|
|
1204
|
+
await dataStoreChannel.entryPoint.get();
|
|
1210
1205
|
|
|
1211
1206
|
if (await this.isRoot()) {
|
|
1212
1207
|
dataStoreChannel.makeVisibleAndAttachGraph();
|
package/src/gc/gcDefinitions.ts
CHANGED
|
@@ -267,24 +267,12 @@ export interface IGCRuntimeOptions {
|
|
|
267
267
|
* GC has mark phase and sweep phase. In mark phase, unreferenced objects are identified
|
|
268
268
|
* and marked as such in the summary. This option enables the mark phase.
|
|
269
269
|
* In sweep phase, unreferenced objects are eventually deleted from the container if they meet certain conditions.
|
|
270
|
-
* Sweep phase can be enabled
|
|
270
|
+
* Sweep phase can be enabled using the "gcSweepGeneration" option.
|
|
271
271
|
*
|
|
272
272
|
* Note: This setting is persisted in the container's summary and cannot be changed.
|
|
273
273
|
*/
|
|
274
274
|
gcAllowed?: boolean;
|
|
275
275
|
|
|
276
|
-
/**
|
|
277
|
-
* @deprecated - @see gcSweepGenerationOptionName and @see GCFeatureMatrix.sweepGeneration
|
|
278
|
-
*
|
|
279
|
-
* Flag that if true, enables GC's sweep phase for a new container.
|
|
280
|
-
*
|
|
281
|
-
* This will allow GC to eventually delete unreferenced objects from the container.
|
|
282
|
-
* This flag should only be set to true if "gcAllowed" is true.
|
|
283
|
-
*
|
|
284
|
-
* Note: This setting is persisted in the container's summary and cannot be changed.
|
|
285
|
-
*/
|
|
286
|
-
sweepAllowed?: boolean;
|
|
287
|
-
|
|
288
276
|
/**
|
|
289
277
|
* Flag that if true, will disable garbage collection for the session.
|
|
290
278
|
* Can be used to disable running GC on containers where it is allowed via the gcAllowed option.
|
|
@@ -78,7 +78,7 @@ For this to work, you must disable the `Fluid.GarbageCollection.ThrowOnTombstone
|
|
|
78
78
|
|
|
79
79
|
When a Tombstoned object (via `handle.get()`) fails to load, the 404 response error object has an `underlyingResponseHeaders` with the
|
|
80
80
|
`isTombstoned` flag set to true: i.e. `error.underlyingResponseHeaders?.isTombstoned === true`. In this case,
|
|
81
|
-
you may turn around and use `
|
|
81
|
+
you may turn around and use `IContainerRuntimeWithResolveHandle_Deprecated.resolveHandle` with `allowTombstone: true` in `IRequest.headers` to request
|
|
82
82
|
the object again - this time it will succeed.
|
|
83
83
|
|
|
84
84
|
To be very clear once again - This path uses deprecated APIs (`resolveHandle`) and comes with no guarantees of support.
|
package/src/packageVersion.ts
CHANGED