@fluidframework/container-runtime 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.224419
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +19 -29
- package/.mocharc.js +12 -0
- package/CHANGELOG.md +427 -0
- package/README.md +69 -0
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +2 -2
- package/api-report/container-runtime.api.md +863 -0
- package/dist/{batchTracker.js → batchTracker.cjs} +9 -8
- package/dist/batchTracker.cjs.map +1 -0
- package/dist/batchTracker.d.ts +6 -5
- package/dist/batchTracker.d.ts.map +1 -1
- package/dist/blobManager.cjs +704 -0
- package/dist/blobManager.cjs.map +1 -0
- package/dist/blobManager.d.ts +135 -39
- package/dist/blobManager.d.ts.map +1 -1
- package/dist/connectionTelemetry.cjs +230 -0
- package/dist/connectionTelemetry.cjs.map +1 -0
- package/dist/connectionTelemetry.d.ts +2 -2
- package/dist/connectionTelemetry.d.ts.map +1 -1
- package/dist/container-runtime-alpha.d.ts +1677 -0
- package/dist/container-runtime-beta.d.ts +250 -0
- package/dist/container-runtime-public.d.ts +250 -0
- package/dist/container-runtime-untrimmed.d.ts +1792 -0
- package/dist/{containerHandleContext.js → containerHandleContext.cjs} +4 -2
- package/dist/containerHandleContext.cjs.map +1 -0
- package/dist/containerHandleContext.d.ts.map +1 -1
- package/dist/containerRuntime.cjs +2531 -0
- package/dist/containerRuntime.cjs.map +1 -0
- package/dist/containerRuntime.d.ts +454 -256
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/{dataStore.js → dataStore.cjs} +54 -45
- package/dist/dataStore.cjs.map +1 -0
- package/dist/dataStore.d.ts +2 -2
- package/dist/dataStore.d.ts.map +1 -1
- package/dist/{dataStoreContext.js → dataStoreContext.cjs} +343 -247
- package/dist/dataStoreContext.cjs.map +1 -0
- package/dist/dataStoreContext.d.ts +73 -41
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/{dataStoreContexts.js → dataStoreContexts.cjs} +19 -15
- package/dist/dataStoreContexts.cjs.map +1 -0
- package/dist/dataStoreContexts.d.ts +1 -1
- package/dist/dataStoreContexts.d.ts.map +1 -1
- package/dist/{dataStoreRegistry.js → dataStoreRegistry.cjs} +9 -4
- package/dist/dataStoreRegistry.cjs.map +1 -0
- package/dist/dataStoreRegistry.d.ts +3 -0
- package/dist/dataStoreRegistry.d.ts.map +1 -1
- package/dist/{dataStores.js → dataStores.cjs} +273 -124
- package/dist/dataStores.cjs.map +1 -0
- package/dist/dataStores.d.ts +53 -23
- package/dist/dataStores.d.ts.map +1 -1
- package/dist/deltaManagerProxyBase.cjs +77 -0
- package/dist/deltaManagerProxyBase.cjs.map +1 -0
- package/dist/deltaManagerProxyBase.d.ts +35 -0
- package/dist/deltaManagerProxyBase.d.ts.map +1 -0
- package/dist/deltaManagerSummarizerProxy.cjs +42 -0
- package/dist/deltaManagerSummarizerProxy.cjs.map +1 -0
- package/dist/deltaManagerSummarizerProxy.d.ts +19 -0
- package/dist/deltaManagerSummarizerProxy.d.ts.map +1 -0
- package/dist/{deltaScheduler.js → deltaScheduler.cjs} +25 -18
- package/dist/deltaScheduler.cjs.map +1 -0
- package/dist/deltaScheduler.d.ts +8 -6
- package/dist/deltaScheduler.d.ts.map +1 -1
- package/dist/error.cjs +21 -0
- package/dist/error.cjs.map +1 -0
- package/dist/error.d.ts +14 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/gc/garbageCollection.cjs +861 -0
- package/dist/gc/garbageCollection.cjs.map +1 -0
- package/dist/gc/garbageCollection.d.ts +224 -0
- package/dist/gc/garbageCollection.d.ts.map +1 -0
- package/dist/gc/gcConfigs.cjs +153 -0
- package/dist/gc/gcConfigs.cjs.map +1 -0
- package/dist/gc/gcConfigs.d.ts +23 -0
- package/dist/gc/gcConfigs.d.ts.map +1 -0
- package/dist/gc/gcDefinitions.cjs +96 -0
- package/dist/gc/gcDefinitions.cjs.map +1 -0
- package/dist/gc/gcDefinitions.d.ts +437 -0
- package/dist/gc/gcDefinitions.d.ts.map +1 -0
- package/dist/gc/gcHelpers.cjs +235 -0
- package/dist/gc/gcHelpers.cjs.map +1 -0
- package/dist/gc/gcHelpers.d.ts +71 -0
- package/dist/gc/gcHelpers.d.ts.map +1 -0
- package/dist/gc/gcReferenceGraphAlgorithm.cjs +49 -0
- package/dist/gc/gcReferenceGraphAlgorithm.cjs.map +1 -0
- package/dist/gc/gcReferenceGraphAlgorithm.d.ts +16 -0
- package/dist/gc/gcReferenceGraphAlgorithm.d.ts.map +1 -0
- package/dist/{summarizerTypes.js → gc/gcSummaryDefinitions.cjs} +1 -6
- package/dist/gc/gcSummaryDefinitions.cjs.map +1 -0
- package/dist/gc/gcSummaryDefinitions.d.ts +52 -0
- package/dist/gc/gcSummaryDefinitions.d.ts.map +1 -0
- package/dist/gc/gcSummaryStateTracker.cjs +213 -0
- package/dist/gc/gcSummaryStateTracker.cjs.map +1 -0
- package/dist/gc/gcSummaryStateTracker.d.ts +94 -0
- package/dist/gc/gcSummaryStateTracker.d.ts.map +1 -0
- package/dist/gc/gcTelemetry.cjs +298 -0
- package/dist/gc/gcTelemetry.cjs.map +1 -0
- package/dist/gc/gcTelemetry.d.ts +92 -0
- package/dist/gc/gcTelemetry.d.ts.map +1 -0
- package/dist/gc/gcUnreferencedStateTracker.cjs +118 -0
- package/dist/gc/gcUnreferencedStateTracker.cjs.map +1 -0
- package/dist/gc/gcUnreferencedStateTracker.d.ts +40 -0
- package/dist/gc/gcUnreferencedStateTracker.d.ts.map +1 -0
- package/dist/gc/index.cjs +44 -0
- package/dist/gc/index.cjs.map +1 -0
- package/dist/gc/index.d.ts +13 -0
- package/dist/gc/index.d.ts.map +1 -0
- package/dist/index.cjs +47 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +19 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/messageTypes.cjs +37 -0
- package/dist/messageTypes.cjs.map +1 -0
- package/dist/messageTypes.d.ts +142 -0
- package/dist/messageTypes.d.ts.map +1 -0
- package/dist/metadata.cjs +7 -0
- package/dist/metadata.cjs.map +1 -0
- package/dist/metadata.d.ts +24 -0
- package/dist/metadata.d.ts.map +1 -0
- package/dist/opLifecycle/batchManager.cjs +139 -0
- package/dist/opLifecycle/batchManager.cjs.map +1 -0
- package/dist/opLifecycle/batchManager.d.ts +48 -0
- package/dist/opLifecycle/batchManager.d.ts.map +1 -0
- package/dist/opLifecycle/definitions.cjs +7 -0
- package/dist/opLifecycle/definitions.cjs.map +1 -0
- package/dist/opLifecycle/definitions.d.ts +83 -0
- package/dist/opLifecycle/definitions.d.ts.map +1 -0
- package/dist/opLifecycle/index.cjs +26 -0
- package/dist/opLifecycle/index.cjs.map +1 -0
- package/dist/opLifecycle/index.d.ts +13 -0
- package/dist/opLifecycle/index.d.ts.map +1 -0
- package/dist/opLifecycle/opCompressor.cjs +84 -0
- package/dist/opLifecycle/opCompressor.cjs.map +1 -0
- package/dist/opLifecycle/opCompressor.d.ts +18 -0
- package/dist/opLifecycle/opCompressor.d.ts.map +1 -0
- package/dist/opLifecycle/opDecompressor.cjs +132 -0
- package/dist/opLifecycle/opDecompressor.cjs.map +1 -0
- package/dist/opLifecycle/opDecompressor.d.ts +25 -0
- package/dist/opLifecycle/opDecompressor.d.ts.map +1 -0
- package/dist/opLifecycle/opGroupingManager.cjs +95 -0
- package/dist/opLifecycle/opGroupingManager.cjs.map +1 -0
- package/dist/opLifecycle/opGroupingManager.d.ts +22 -0
- package/dist/opLifecycle/opGroupingManager.d.ts.map +1 -0
- package/dist/opLifecycle/opSplitter.cjs +202 -0
- package/dist/opLifecycle/opSplitter.cjs.map +1 -0
- package/dist/opLifecycle/opSplitter.d.ts +61 -0
- package/dist/opLifecycle/opSplitter.d.ts.map +1 -0
- package/dist/opLifecycle/outbox.cjs +323 -0
- package/dist/opLifecycle/outbox.cjs.map +1 -0
- package/dist/opLifecycle/outbox.d.ts +104 -0
- package/dist/opLifecycle/outbox.d.ts.map +1 -0
- package/dist/opLifecycle/remoteMessageProcessor.cjs +136 -0
- package/dist/opLifecycle/remoteMessageProcessor.cjs.map +1 -0
- package/dist/opLifecycle/remoteMessageProcessor.d.ts +47 -0
- package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -0
- package/dist/opProperties.cjs +17 -0
- package/dist/opProperties.cjs.map +1 -0
- package/dist/opProperties.d.ts +7 -0
- package/dist/opProperties.d.ts.map +1 -0
- package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
- package/dist/packageVersion.cjs.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/pendingStateManager.cjs +282 -0
- package/dist/pendingStateManager.cjs.map +1 -0
- package/dist/pendingStateManager.d.ts +32 -69
- package/dist/pendingStateManager.d.ts.map +1 -1
- package/dist/scheduleManager.cjs +258 -0
- package/dist/scheduleManager.cjs.map +1 -0
- package/dist/scheduleManager.d.ts +31 -0
- package/dist/scheduleManager.d.ts.map +1 -0
- package/dist/storageServiceWithAttachBlobs.cjs +32 -0
- package/dist/storageServiceWithAttachBlobs.cjs.map +1 -0
- package/dist/storageServiceWithAttachBlobs.d.ts +17 -0
- package/dist/storageServiceWithAttachBlobs.d.ts.map +1 -0
- package/dist/summary/index.cjs +51 -0
- package/dist/summary/index.cjs.map +1 -0
- package/dist/summary/index.d.ts +17 -0
- package/dist/summary/index.d.ts.map +1 -0
- package/dist/{orderedClientElection.js → summary/orderedClientElection.cjs} +100 -84
- package/dist/summary/orderedClientElection.cjs.map +1 -0
- package/{lib → dist/summary}/orderedClientElection.d.ts +41 -18
- package/dist/summary/orderedClientElection.d.ts.map +1 -0
- package/dist/{runWhileConnectedCoordinator.js → summary/runWhileConnectedCoordinator.cjs} +12 -10
- package/dist/summary/runWhileConnectedCoordinator.cjs.map +1 -0
- package/{lib → dist/summary}/runWhileConnectedCoordinator.d.ts +8 -2
- package/dist/summary/runWhileConnectedCoordinator.d.ts.map +1 -0
- package/dist/summary/runningSummarizer.cjs +679 -0
- package/dist/summary/runningSummarizer.cjs.map +1 -0
- package/dist/summary/runningSummarizer.d.ts +128 -0
- package/dist/summary/runningSummarizer.d.ts.map +1 -0
- package/dist/summary/summarizer.cjs +263 -0
- package/dist/summary/summarizer.cjs.map +1 -0
- package/dist/{summarizer.d.ts → summary/summarizer.d.ts} +18 -33
- package/dist/summary/summarizer.d.ts.map +1 -0
- package/dist/{summarizerClientElection.js → summary/summarizerClientElection.cjs} +15 -46
- package/dist/summary/summarizerClientElection.cjs.map +1 -0
- package/{lib → dist/summary}/summarizerClientElection.d.ts +4 -4
- package/dist/summary/summarizerClientElection.d.ts.map +1 -0
- package/dist/summary/summarizerHeuristics.cjs +156 -0
- package/dist/summary/summarizerHeuristics.cjs.map +1 -0
- package/{lib → dist/summary}/summarizerHeuristics.d.ts +28 -6
- package/dist/summary/summarizerHeuristics.d.ts.map +1 -0
- package/dist/summary/summarizerNode/index.cjs +12 -0
- package/dist/summary/summarizerNode/index.cjs.map +1 -0
- package/dist/summary/summarizerNode/index.d.ts +8 -0
- package/dist/summary/summarizerNode/index.d.ts.map +1 -0
- package/dist/summary/summarizerNode/summarizerNode.cjs +526 -0
- package/dist/summary/summarizerNode/summarizerNode.cjs.map +1 -0
- package/dist/summary/summarizerNode/summarizerNode.d.ts +167 -0
- package/dist/summary/summarizerNode/summarizerNode.d.ts.map +1 -0
- package/dist/summary/summarizerNode/summarizerNodeUtils.cjs +130 -0
- package/dist/summary/summarizerNode/summarizerNodeUtils.cjs.map +1 -0
- package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts +121 -0
- package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -0
- package/dist/summary/summarizerNode/summarizerNodeWithGc.cjs +375 -0
- package/dist/summary/summarizerNode/summarizerNodeWithGc.cjs.map +1 -0
- package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts +153 -0
- package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -0
- package/dist/summary/summarizerTypes.cjs +7 -0
- package/dist/summary/summarizerTypes.cjs.map +1 -0
- package/{lib → dist/summary}/summarizerTypes.d.ts +233 -83
- package/dist/summary/summarizerTypes.d.ts.map +1 -0
- package/dist/{summaryCollection.js → summary/summaryCollection.cjs} +80 -49
- package/dist/summary/summaryCollection.cjs.map +1 -0
- package/dist/{summaryCollection.d.ts → summary/summaryCollection.d.ts} +23 -5
- package/dist/summary/summaryCollection.d.ts.map +1 -0
- package/dist/{summaryFormat.js → summary/summaryFormat.cjs} +29 -26
- package/dist/summary/summaryFormat.cjs.map +1 -0
- package/{lib → dist/summary}/summaryFormat.d.ts +25 -30
- package/dist/summary/summaryFormat.d.ts.map +1 -0
- package/dist/{summaryGenerator.js → summary/summaryGenerator.cjs} +162 -74
- package/dist/summary/summaryGenerator.cjs.map +1 -0
- package/dist/{summaryGenerator.d.ts → summary/summaryGenerator.d.ts} +53 -11
- package/dist/summary/summaryGenerator.d.ts.map +1 -0
- package/dist/{summaryManager.js → summary/summaryManager.cjs} +98 -55
- package/dist/summary/summaryManager.cjs.map +1 -0
- package/{lib → dist/summary}/summaryManager.d.ts +13 -11
- package/dist/summary/summaryManager.d.ts.map +1 -0
- package/dist/{throttler.js → throttler.cjs} +21 -21
- package/dist/throttler.cjs.map +1 -0
- package/dist/throttler.d.ts +2 -2
- package/dist/throttler.d.ts.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/lib/{batchTracker.d.ts → batchTracker.d.mts} +6 -5
- package/lib/batchTracker.d.mts.map +1 -0
- package/lib/{batchTracker.js → batchTracker.mjs} +9 -8
- package/lib/batchTracker.mjs.map +1 -0
- package/lib/blobManager.d.mts +191 -0
- package/lib/blobManager.d.mts.map +1 -0
- package/lib/blobManager.mjs +699 -0
- package/lib/blobManager.mjs.map +1 -0
- package/lib/{connectionTelemetry.d.ts → connectionTelemetry.d.mts} +2 -2
- package/lib/connectionTelemetry.d.mts.map +1 -0
- package/lib/connectionTelemetry.mjs +226 -0
- package/lib/connectionTelemetry.mjs.map +1 -0
- package/lib/container-runtime-alpha.d.mts +1677 -0
- package/lib/container-runtime-beta.d.mts +250 -0
- package/lib/container-runtime-public.d.mts +250 -0
- package/lib/container-runtime-untrimmed.d.mts +1792 -0
- package/lib/{containerHandleContext.d.ts → containerHandleContext.d.mts} +1 -1
- package/lib/containerHandleContext.d.mts.map +1 -0
- package/lib/{containerHandleContext.js → containerHandleContext.mjs} +4 -2
- package/lib/containerHandleContext.mjs.map +1 -0
- package/lib/containerRuntime.d.mts +809 -0
- package/lib/containerRuntime.d.mts.map +1 -0
- package/lib/containerRuntime.mjs +2526 -0
- package/lib/containerRuntime.mjs.map +1 -0
- package/lib/{dataStore.d.ts → dataStore.d.mts} +4 -4
- package/lib/dataStore.d.mts.map +1 -0
- package/lib/{dataStore.js → dataStore.mjs} +52 -43
- package/lib/dataStore.mjs.map +1 -0
- package/lib/{dataStoreContext.d.ts → dataStoreContext.d.mts} +74 -42
- package/lib/dataStoreContext.d.mts.map +1 -0
- package/lib/{dataStoreContext.js → dataStoreContext.mjs} +309 -213
- package/lib/dataStoreContext.mjs.map +1 -0
- package/lib/{dataStoreContexts.d.ts → dataStoreContexts.d.mts} +2 -2
- package/lib/dataStoreContexts.d.mts.map +1 -0
- package/lib/{dataStoreContexts.js → dataStoreContexts.mjs} +12 -8
- package/lib/dataStoreContexts.mjs.map +1 -0
- package/lib/{dataStoreRegistry.d.ts → dataStoreRegistry.d.mts} +3 -0
- package/lib/dataStoreRegistry.d.mts.map +1 -0
- package/lib/{dataStoreRegistry.js → dataStoreRegistry.mjs} +7 -6
- package/lib/dataStoreRegistry.mjs.map +1 -0
- package/lib/{dataStores.d.ts → dataStores.d.mts} +56 -26
- package/lib/dataStores.d.mts.map +1 -0
- package/lib/{dataStores.js → dataStores.mjs} +254 -105
- package/lib/dataStores.mjs.map +1 -0
- package/lib/deltaManagerProxyBase.d.mts +35 -0
- package/lib/deltaManagerProxyBase.d.mts.map +1 -0
- package/lib/deltaManagerProxyBase.mjs +73 -0
- package/lib/deltaManagerProxyBase.mjs.map +1 -0
- package/lib/deltaManagerSummarizerProxy.d.mts +19 -0
- package/lib/deltaManagerSummarizerProxy.d.mts.map +1 -0
- package/lib/deltaManagerSummarizerProxy.mjs +38 -0
- package/lib/deltaManagerSummarizerProxy.mjs.map +1 -0
- package/lib/{deltaScheduler.d.ts → deltaScheduler.d.mts} +8 -6
- package/lib/deltaScheduler.d.mts.map +1 -0
- package/lib/{deltaScheduler.js → deltaScheduler.mjs} +22 -15
- package/lib/deltaScheduler.mjs.map +1 -0
- package/lib/error.d.mts +14 -0
- package/lib/error.d.mts.map +1 -0
- package/lib/error.mjs +17 -0
- package/lib/error.mjs.map +1 -0
- package/lib/gc/garbageCollection.d.mts +224 -0
- package/lib/gc/garbageCollection.d.mts.map +1 -0
- package/lib/gc/garbageCollection.mjs +857 -0
- package/lib/gc/garbageCollection.mjs.map +1 -0
- package/lib/gc/gcConfigs.d.mts +23 -0
- package/lib/gc/gcConfigs.d.mts.map +1 -0
- package/lib/gc/gcConfigs.mjs +149 -0
- package/lib/gc/gcConfigs.mjs.map +1 -0
- package/lib/gc/gcDefinitions.d.mts +437 -0
- package/lib/gc/gcDefinitions.d.mts.map +1 -0
- package/lib/gc/gcDefinitions.mjs +93 -0
- package/lib/gc/gcDefinitions.mjs.map +1 -0
- package/lib/gc/gcHelpers.d.mts +71 -0
- package/lib/gc/gcHelpers.d.mts.map +1 -0
- package/lib/gc/gcHelpers.mjs +222 -0
- package/lib/gc/gcHelpers.mjs.map +1 -0
- package/lib/gc/gcReferenceGraphAlgorithm.d.mts +16 -0
- package/lib/gc/gcReferenceGraphAlgorithm.d.mts.map +1 -0
- package/lib/gc/gcReferenceGraphAlgorithm.mjs +45 -0
- package/lib/gc/gcReferenceGraphAlgorithm.mjs.map +1 -0
- package/lib/gc/gcSummaryDefinitions.d.mts +52 -0
- package/lib/gc/gcSummaryDefinitions.d.mts.map +1 -0
- package/lib/gc/gcSummaryDefinitions.mjs +6 -0
- package/lib/gc/gcSummaryDefinitions.mjs.map +1 -0
- package/lib/gc/gcSummaryStateTracker.d.mts +94 -0
- package/lib/gc/gcSummaryStateTracker.d.mts.map +1 -0
- package/lib/gc/gcSummaryStateTracker.mjs +209 -0
- package/lib/gc/gcSummaryStateTracker.mjs.map +1 -0
- package/lib/gc/gcTelemetry.d.mts +92 -0
- package/lib/gc/gcTelemetry.d.mts.map +1 -0
- package/lib/gc/gcTelemetry.mjs +293 -0
- package/lib/gc/gcTelemetry.mjs.map +1 -0
- package/lib/gc/gcUnreferencedStateTracker.d.mts +40 -0
- package/lib/gc/gcUnreferencedStateTracker.d.mts.map +1 -0
- package/lib/gc/gcUnreferencedStateTracker.mjs +114 -0
- package/lib/gc/gcUnreferencedStateTracker.mjs.map +1 -0
- package/lib/gc/index.d.mts +13 -0
- package/lib/gc/index.d.mts.map +1 -0
- package/lib/gc/index.mjs +12 -0
- package/lib/gc/index.mjs.map +1 -0
- package/lib/index.d.mts +25 -0
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +24 -0
- package/lib/index.mjs.map +1 -0
- package/lib/messageTypes.d.mts +142 -0
- package/lib/messageTypes.d.mts.map +1 -0
- package/lib/messageTypes.mjs +34 -0
- package/lib/messageTypes.mjs.map +1 -0
- package/lib/metadata.d.mts +24 -0
- package/lib/metadata.d.mts.map +1 -0
- package/lib/metadata.mjs +6 -0
- package/lib/metadata.mjs.map +1 -0
- package/lib/opLifecycle/batchManager.d.mts +48 -0
- package/lib/opLifecycle/batchManager.d.mts.map +1 -0
- package/lib/opLifecycle/batchManager.mjs +133 -0
- package/lib/opLifecycle/batchManager.mjs.map +1 -0
- package/lib/opLifecycle/definitions.d.mts +83 -0
- package/lib/opLifecycle/definitions.d.mts.map +1 -0
- package/lib/opLifecycle/definitions.mjs +6 -0
- package/lib/opLifecycle/definitions.mjs.map +1 -0
- package/lib/opLifecycle/index.d.mts +13 -0
- package/lib/opLifecycle/index.d.mts.map +1 -0
- package/lib/opLifecycle/index.mjs +12 -0
- package/lib/opLifecycle/index.mjs.map +1 -0
- package/lib/opLifecycle/opCompressor.d.mts +18 -0
- package/lib/opLifecycle/opCompressor.d.mts.map +1 -0
- package/lib/opLifecycle/opCompressor.mjs +80 -0
- package/lib/opLifecycle/opCompressor.mjs.map +1 -0
- package/lib/opLifecycle/opDecompressor.d.mts +25 -0
- package/lib/opLifecycle/opDecompressor.d.mts.map +1 -0
- package/lib/opLifecycle/opDecompressor.mjs +128 -0
- package/lib/opLifecycle/opDecompressor.mjs.map +1 -0
- package/lib/opLifecycle/opGroupingManager.d.mts +22 -0
- package/lib/opLifecycle/opGroupingManager.d.mts.map +1 -0
- package/lib/opLifecycle/opGroupingManager.mjs +91 -0
- package/lib/opLifecycle/opGroupingManager.mjs.map +1 -0
- package/lib/opLifecycle/opSplitter.d.mts +61 -0
- package/lib/opLifecycle/opSplitter.d.mts.map +1 -0
- package/lib/opLifecycle/opSplitter.mjs +197 -0
- package/lib/opLifecycle/opSplitter.mjs.map +1 -0
- package/lib/opLifecycle/outbox.d.mts +104 -0
- package/lib/opLifecycle/outbox.d.mts.map +1 -0
- package/lib/opLifecycle/outbox.mjs +318 -0
- package/lib/opLifecycle/outbox.mjs.map +1 -0
- package/lib/opLifecycle/remoteMessageProcessor.d.mts +47 -0
- package/lib/opLifecycle/remoteMessageProcessor.d.mts.map +1 -0
- package/lib/opLifecycle/remoteMessageProcessor.mjs +131 -0
- package/lib/opLifecycle/remoteMessageProcessor.mjs.map +1 -0
- package/lib/opProperties.d.mts +7 -0
- package/lib/opProperties.d.mts.map +1 -0
- package/lib/opProperties.mjs +13 -0
- package/lib/opProperties.mjs.map +1 -0
- package/lib/{packageVersion.d.ts → packageVersion.d.mts} +1 -1
- package/lib/{packageVersion.d.ts.map → packageVersion.d.mts.map} +1 -1
- package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
- package/lib/packageVersion.mjs.map +1 -0
- package/lib/{pendingStateManager.d.ts → pendingStateManager.d.mts} +32 -69
- package/lib/pendingStateManager.d.mts.map +1 -0
- package/lib/pendingStateManager.mjs +275 -0
- package/lib/pendingStateManager.mjs.map +1 -0
- package/lib/scheduleManager.d.mts +27 -0
- package/lib/scheduleManager.d.mts.map +1 -0
- package/lib/scheduleManager.mjs +254 -0
- package/lib/scheduleManager.mjs.map +1 -0
- package/lib/storageServiceWithAttachBlobs.d.mts +17 -0
- package/lib/storageServiceWithAttachBlobs.d.mts.map +1 -0
- package/lib/storageServiceWithAttachBlobs.mjs +28 -0
- package/lib/storageServiceWithAttachBlobs.mjs.map +1 -0
- package/lib/summary/index.d.mts +17 -0
- package/lib/summary/index.d.mts.map +1 -0
- package/lib/summary/index.mjs +16 -0
- package/lib/summary/index.mjs.map +1 -0
- package/{dist/orderedClientElection.d.ts → lib/summary/orderedClientElection.d.mts} +41 -22
- package/lib/summary/orderedClientElection.d.mts.map +1 -0
- package/lib/{orderedClientElection.js → summary/orderedClientElection.mjs} +95 -79
- package/lib/summary/orderedClientElection.mjs.map +1 -0
- package/{dist/runWhileConnectedCoordinator.d.ts → lib/summary/runWhileConnectedCoordinator.d.mts} +9 -3
- package/lib/summary/runWhileConnectedCoordinator.d.mts.map +1 -0
- package/lib/{runWhileConnectedCoordinator.js → summary/runWhileConnectedCoordinator.mjs} +12 -10
- package/lib/summary/runWhileConnectedCoordinator.mjs.map +1 -0
- package/lib/summary/runningSummarizer.d.mts +128 -0
- package/lib/summary/runningSummarizer.d.mts.map +1 -0
- package/lib/summary/runningSummarizer.mjs +675 -0
- package/lib/summary/runningSummarizer.mjs.map +1 -0
- package/lib/{summarizer.d.ts → summary/summarizer.d.mts} +20 -35
- package/lib/summary/summarizer.d.mts.map +1 -0
- package/lib/summary/summarizer.mjs +257 -0
- package/lib/summary/summarizer.mjs.map +1 -0
- package/{dist/summarizerClientElection.d.ts → lib/summary/summarizerClientElection.d.mts} +6 -6
- package/lib/summary/summarizerClientElection.d.mts.map +1 -0
- package/lib/{summarizerClientElection.js → summary/summarizerClientElection.mjs} +14 -45
- package/lib/summary/summarizerClientElection.mjs.map +1 -0
- package/{dist/summarizerHeuristics.d.ts → lib/summary/summarizerHeuristics.d.mts} +29 -7
- package/lib/summary/summarizerHeuristics.d.mts.map +1 -0
- package/lib/summary/summarizerHeuristics.mjs +151 -0
- package/lib/summary/summarizerHeuristics.mjs.map +1 -0
- package/lib/summary/summarizerNode/index.d.mts +8 -0
- package/lib/summary/summarizerNode/index.d.mts.map +1 -0
- package/lib/summary/summarizerNode/index.mjs +7 -0
- package/lib/summary/summarizerNode/index.mjs.map +1 -0
- package/lib/summary/summarizerNode/summarizerNode.d.mts +167 -0
- package/lib/summary/summarizerNode/summarizerNode.d.mts.map +1 -0
- package/lib/summary/summarizerNode/summarizerNode.mjs +521 -0
- package/lib/summary/summarizerNode/summarizerNode.mjs.map +1 -0
- package/lib/summary/summarizerNode/summarizerNodeUtils.d.mts +121 -0
- package/lib/summary/summarizerNode/summarizerNodeUtils.d.mts.map +1 -0
- package/lib/summary/summarizerNode/summarizerNodeUtils.mjs +123 -0
- package/lib/summary/summarizerNode/summarizerNodeUtils.mjs.map +1 -0
- package/lib/summary/summarizerNode/summarizerNodeWithGc.d.mts +153 -0
- package/lib/summary/summarizerNode/summarizerNodeWithGc.d.mts.map +1 -0
- package/lib/summary/summarizerNode/summarizerNodeWithGc.mjs +370 -0
- package/lib/summary/summarizerNode/summarizerNodeWithGc.mjs.map +1 -0
- package/{dist/summarizerTypes.d.ts → lib/summary/summarizerTypes.d.mts} +234 -84
- package/lib/summary/summarizerTypes.d.mts.map +1 -0
- package/lib/summary/summarizerTypes.mjs +6 -0
- package/lib/summary/summarizerTypes.mjs.map +1 -0
- package/lib/{summaryCollection.d.ts → summary/summaryCollection.d.mts} +23 -5
- package/lib/summary/summaryCollection.d.mts.map +1 -0
- package/lib/{summaryCollection.js → summary/summaryCollection.mjs} +76 -45
- package/lib/summary/summaryCollection.mjs.map +1 -0
- package/{dist/summaryFormat.d.ts → lib/summary/summaryFormat.d.mts} +25 -30
- package/lib/summary/summaryFormat.d.mts.map +1 -0
- package/lib/{summaryFormat.js → summary/summaryFormat.mjs} +30 -26
- package/lib/summary/summaryFormat.mjs.map +1 -0
- package/lib/summary/summaryGenerator.d.mts +127 -0
- package/lib/summary/summaryGenerator.d.mts.map +1 -0
- package/lib/{summaryGenerator.js → summary/summaryGenerator.mjs} +153 -67
- package/lib/summary/summaryGenerator.mjs.map +1 -0
- package/{dist/summaryManager.d.ts → lib/summary/summaryManager.d.mts} +15 -13
- package/lib/summary/summaryManager.d.mts.map +1 -0
- package/lib/{summaryManager.js → summary/summaryManager.mjs} +94 -51
- package/lib/summary/summaryManager.mjs.map +1 -0
- package/lib/{throttler.d.ts → throttler.d.mts} +2 -2
- package/lib/throttler.d.mts.map +1 -0
- package/lib/{throttler.js → throttler.mjs} +21 -21
- package/lib/throttler.mjs.map +1 -0
- package/package.json +173 -72
- package/prettier.config.cjs +8 -0
- package/src/batchTracker.ts +59 -54
- package/src/blobManager.ts +937 -294
- package/src/connectionTelemetry.ts +342 -252
- package/src/containerHandleContext.ts +27 -29
- package/src/containerRuntime.ts +3879 -3143
- package/src/dataStore.ts +170 -140
- package/src/dataStoreContext.ts +1166 -986
- package/src/dataStoreContexts.ts +176 -163
- package/src/dataStoreRegistry.ts +29 -21
- package/src/dataStores.ts +921 -678
- package/src/deltaManagerProxyBase.ts +111 -0
- package/src/deltaManagerSummarizerProxy.ts +49 -0
- package/src/deltaScheduler.ts +161 -156
- package/src/error.ts +21 -0
- package/src/gc/garbageCollection.md +106 -0
- package/src/gc/garbageCollection.ts +1153 -0
- package/src/gc/gcConfigs.ts +216 -0
- package/src/gc/gcDefinitions.ts +502 -0
- package/src/gc/gcHelpers.ts +284 -0
- package/src/gc/gcReferenceGraphAlgorithm.ts +52 -0
- package/src/gc/gcSummaryDefinitions.ts +54 -0
- package/src/gc/gcSummaryStateTracker.ts +299 -0
- package/src/gc/gcTelemetry.ts +423 -0
- package/src/gc/gcUnreferencedStateTracker.ts +153 -0
- package/src/gc/index.ts +59 -0
- package/src/index.ts +101 -74
- package/src/messageTypes.ts +238 -0
- package/src/metadata.ts +26 -0
- package/src/opLifecycle/README.md +321 -0
- package/src/opLifecycle/batchManager.ts +179 -0
- package/src/opLifecycle/definitions.ts +89 -0
- package/src/opLifecycle/index.ts +19 -0
- package/src/opLifecycle/opCompressor.ts +99 -0
- package/src/opLifecycle/opDecompressor.ts +190 -0
- package/src/opLifecycle/opGroupingManager.ts +133 -0
- package/src/opLifecycle/opSplitter.ts +279 -0
- package/src/opLifecycle/outbox.ts +471 -0
- package/src/opLifecycle/remoteMessageProcessor.ts +175 -0
- package/src/opProperties.ts +21 -0
- package/src/packageVersion.ts +1 -1
- package/src/pendingStateManager.ts +396 -465
- package/src/scheduleManager.ts +358 -0
- package/src/storageServiceWithAttachBlobs.ts +38 -0
- package/src/summary/index.ts +109 -0
- package/src/summary/orderedClientElection.ts +571 -0
- package/src/summary/runWhileConnectedCoordinator.ts +117 -0
- package/src/summary/runningSummarizer.ts +920 -0
- package/src/summary/summarizer.ts +352 -0
- package/src/summary/summarizerClientElection.ts +140 -0
- package/src/summary/summarizerHeuristics.ts +227 -0
- package/src/summary/summarizerNode/index.ts +12 -0
- package/src/summary/summarizerNode/summarizerNode.ts +725 -0
- package/src/summary/summarizerNode/summarizerNodeUtils.ts +206 -0
- package/src/summary/summarizerNode/summarizerNodeWithGc.ts +571 -0
- package/src/summary/summarizerTypes.ts +631 -0
- package/src/summary/summaryCollection.ts +474 -0
- package/src/summary/summaryFormat.ts +249 -0
- package/src/summary/summaryGenerator.ts +539 -0
- package/src/summary/summaryManager.ts +452 -0
- package/src/throttler.ts +131 -122
- package/tsc-multi.test.json +4 -0
- package/tsconfig.json +11 -13
- package/dist/batchTracker.js.map +0 -1
- package/dist/blobManager.js +0 -249
- package/dist/blobManager.js.map +0 -1
- package/dist/connectionTelemetry.js +0 -178
- package/dist/connectionTelemetry.js.map +0 -1
- package/dist/containerHandleContext.js.map +0 -1
- package/dist/containerRuntime.js +0 -2174
- package/dist/containerRuntime.js.map +0 -1
- package/dist/dataStore.js.map +0 -1
- package/dist/dataStoreContext.js.map +0 -1
- package/dist/dataStoreContexts.js.map +0 -1
- package/dist/dataStoreRegistry.js.map +0 -1
- package/dist/dataStores.js.map +0 -1
- package/dist/deltaScheduler.js.map +0 -1
- package/dist/garbageCollection.d.ts +0 -319
- package/dist/garbageCollection.d.ts.map +0 -1
- package/dist/garbageCollection.js +0 -993
- package/dist/garbageCollection.js.map +0 -1
- package/dist/index.js +0 -33
- package/dist/index.js.map +0 -1
- package/dist/opTelemetry.d.ts +0 -22
- package/dist/opTelemetry.d.ts.map +0 -1
- package/dist/opTelemetry.js +0 -60
- package/dist/opTelemetry.js.map +0 -1
- package/dist/orderedClientElection.d.ts.map +0 -1
- package/dist/orderedClientElection.js.map +0 -1
- package/dist/packageVersion.js.map +0 -1
- package/dist/pendingStateManager.js +0 -346
- package/dist/pendingStateManager.js.map +0 -1
- package/dist/runWhileConnectedCoordinator.d.ts.map +0 -1
- package/dist/runWhileConnectedCoordinator.js.map +0 -1
- package/dist/runningSummarizer.d.ts +0 -93
- package/dist/runningSummarizer.d.ts.map +0 -1
- package/dist/runningSummarizer.js +0 -384
- package/dist/runningSummarizer.js.map +0 -1
- package/dist/serializedSnapshotStorage.d.ts +0 -58
- package/dist/serializedSnapshotStorage.d.ts.map +0 -1
- package/dist/serializedSnapshotStorage.js +0 -108
- package/dist/serializedSnapshotStorage.js.map +0 -1
- package/dist/summarizer.d.ts.map +0 -1
- package/dist/summarizer.js +0 -348
- package/dist/summarizer.js.map +0 -1
- package/dist/summarizerClientElection.d.ts.map +0 -1
- package/dist/summarizerClientElection.js.map +0 -1
- package/dist/summarizerHandle.d.ts +0 -12
- package/dist/summarizerHandle.d.ts.map +0 -1
- package/dist/summarizerHandle.js +0 -22
- package/dist/summarizerHandle.js.map +0 -1
- package/dist/summarizerHeuristics.d.ts.map +0 -1
- package/dist/summarizerHeuristics.js +0 -84
- package/dist/summarizerHeuristics.js.map +0 -1
- package/dist/summarizerTypes.d.ts.map +0 -1
- package/dist/summarizerTypes.js.map +0 -1
- package/dist/summaryCollection.d.ts.map +0 -1
- package/dist/summaryCollection.js.map +0 -1
- package/dist/summaryFormat.d.ts.map +0 -1
- package/dist/summaryFormat.js.map +0 -1
- package/dist/summaryGenerator.d.ts.map +0 -1
- package/dist/summaryGenerator.js.map +0 -1
- package/dist/summaryManager.d.ts.map +0 -1
- package/dist/summaryManager.js.map +0 -1
- package/dist/throttler.js.map +0 -1
- package/garbageCollection.md +0 -41
- package/lib/batchTracker.d.ts.map +0 -1
- package/lib/batchTracker.js.map +0 -1
- package/lib/blobManager.d.ts +0 -95
- package/lib/blobManager.d.ts.map +0 -1
- package/lib/blobManager.js +0 -244
- package/lib/blobManager.js.map +0 -1
- package/lib/connectionTelemetry.d.ts.map +0 -1
- package/lib/connectionTelemetry.js +0 -174
- package/lib/connectionTelemetry.js.map +0 -1
- package/lib/containerHandleContext.d.ts.map +0 -1
- package/lib/containerHandleContext.js.map +0 -1
- package/lib/containerRuntime.d.ts +0 -615
- package/lib/containerRuntime.d.ts.map +0 -1
- package/lib/containerRuntime.js +0 -2166
- package/lib/containerRuntime.js.map +0 -1
- package/lib/dataStore.d.ts.map +0 -1
- package/lib/dataStore.js.map +0 -1
- package/lib/dataStoreContext.d.ts.map +0 -1
- package/lib/dataStoreContext.js.map +0 -1
- package/lib/dataStoreContexts.d.ts.map +0 -1
- package/lib/dataStoreContexts.js.map +0 -1
- package/lib/dataStoreRegistry.d.ts.map +0 -1
- package/lib/dataStoreRegistry.js.map +0 -1
- package/lib/dataStores.d.ts.map +0 -1
- package/lib/dataStores.js.map +0 -1
- package/lib/deltaScheduler.d.ts.map +0 -1
- package/lib/deltaScheduler.js.map +0 -1
- package/lib/garbageCollection.d.ts +0 -319
- package/lib/garbageCollection.d.ts.map +0 -1
- package/lib/garbageCollection.js +0 -989
- package/lib/garbageCollection.js.map +0 -1
- package/lib/index.d.ts +0 -14
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -13
- package/lib/index.js.map +0 -1
- package/lib/opTelemetry.d.ts +0 -22
- package/lib/opTelemetry.d.ts.map +0 -1
- package/lib/opTelemetry.js +0 -56
- package/lib/opTelemetry.js.map +0 -1
- package/lib/orderedClientElection.d.ts.map +0 -1
- package/lib/orderedClientElection.js.map +0 -1
- package/lib/packageVersion.js.map +0 -1
- package/lib/pendingStateManager.d.ts.map +0 -1
- package/lib/pendingStateManager.js +0 -339
- package/lib/pendingStateManager.js.map +0 -1
- package/lib/runWhileConnectedCoordinator.d.ts.map +0 -1
- package/lib/runWhileConnectedCoordinator.js.map +0 -1
- package/lib/runningSummarizer.d.ts +0 -93
- package/lib/runningSummarizer.d.ts.map +0 -1
- package/lib/runningSummarizer.js +0 -380
- package/lib/runningSummarizer.js.map +0 -1
- package/lib/serializedSnapshotStorage.d.ts +0 -58
- package/lib/serializedSnapshotStorage.d.ts.map +0 -1
- package/lib/serializedSnapshotStorage.js +0 -104
- package/lib/serializedSnapshotStorage.js.map +0 -1
- package/lib/summarizer.d.ts.map +0 -1
- package/lib/summarizer.js +0 -342
- package/lib/summarizer.js.map +0 -1
- package/lib/summarizerClientElection.d.ts.map +0 -1
- package/lib/summarizerClientElection.js.map +0 -1
- package/lib/summarizerHandle.d.ts +0 -12
- package/lib/summarizerHandle.d.ts.map +0 -1
- package/lib/summarizerHandle.js +0 -18
- package/lib/summarizerHandle.js.map +0 -1
- package/lib/summarizerHeuristics.d.ts.map +0 -1
- package/lib/summarizerHeuristics.js +0 -79
- package/lib/summarizerHeuristics.js.map +0 -1
- package/lib/summarizerTypes.d.ts.map +0 -1
- package/lib/summarizerTypes.js +0 -9
- package/lib/summarizerTypes.js.map +0 -1
- package/lib/summaryCollection.d.ts.map +0 -1
- package/lib/summaryCollection.js.map +0 -1
- package/lib/summaryFormat.d.ts.map +0 -1
- package/lib/summaryFormat.js.map +0 -1
- package/lib/summaryGenerator.d.ts +0 -85
- package/lib/summaryGenerator.d.ts.map +0 -1
- package/lib/summaryGenerator.js.map +0 -1
- package/lib/summaryManager.d.ts.map +0 -1
- package/lib/summaryManager.js.map +0 -1
- package/lib/throttler.d.ts.map +0 -1
- package/lib/throttler.js.map +0 -1
- package/src/garbageCollection.ts +0 -1434
- package/src/opTelemetry.ts +0 -71
- package/src/orderedClientElection.ts +0 -511
- package/src/runWhileConnectedCoordinator.ts +0 -106
- package/src/runningSummarizer.ts +0 -550
- package/src/serializedSnapshotStorage.ts +0 -146
- package/src/summarizer.ts +0 -438
- package/src/summarizerClientElection.ts +0 -161
- package/src/summarizerHandle.ts +0 -21
- package/src/summarizerHeuristics.ts +0 -108
- package/src/summarizerTypes.ts +0 -462
- package/src/summaryCollection.ts +0 -406
- package/src/summaryFormat.ts +0 -239
- package/src/summaryGenerator.ts +0 -427
- package/src/summaryManager.ts +0 -368
- package/tsconfig.esnext.json +0 -7
package/src/blobManager.ts
CHANGED
|
@@ -3,21 +3,45 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { v4 as uuid } from "uuid";
|
|
6
7
|
import { IFluidHandle, IFluidHandleContext } from "@fluidframework/core-interfaces";
|
|
7
8
|
import { IDocumentStorageService } from "@fluidframework/driver-definitions";
|
|
8
|
-
import { ISnapshotTree } from "@fluidframework/protocol-definitions";
|
|
9
|
-
import { generateHandleContextPath, SummaryTreeBuilder } from "@fluidframework/runtime-utils";
|
|
10
|
-
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
11
|
-
import { assert, Deferred } from "@fluidframework/common-utils";
|
|
12
|
-
import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
|
|
13
|
-
import { AttachState } from "@fluidframework/container-definitions";
|
|
14
|
-
import { PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
15
9
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
ICreateBlobResponse,
|
|
11
|
+
ISequencedDocumentMessage,
|
|
12
|
+
ISnapshotTree,
|
|
13
|
+
} from "@fluidframework/protocol-definitions";
|
|
14
|
+
import {
|
|
15
|
+
createResponseError,
|
|
16
|
+
generateHandleContextPath,
|
|
17
|
+
responseToException,
|
|
18
|
+
SummaryTreeBuilder,
|
|
19
|
+
} from "@fluidframework/runtime-utils";
|
|
20
|
+
import { assert, Deferred } from "@fluidframework/core-utils";
|
|
21
|
+
import { bufferToString, stringToBuffer, TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
22
|
+
import {
|
|
23
|
+
IContainerRuntime,
|
|
24
|
+
IContainerRuntimeEvents,
|
|
25
|
+
} from "@fluidframework/container-runtime-definitions";
|
|
26
|
+
import { AttachState, ICriticalContainerError } from "@fluidframework/container-definitions";
|
|
27
|
+
import {
|
|
28
|
+
createChildMonitoringContext,
|
|
29
|
+
GenericError,
|
|
30
|
+
LoggingError,
|
|
31
|
+
MonitoringContext,
|
|
32
|
+
PerformanceEvent,
|
|
33
|
+
wrapError,
|
|
34
|
+
} from "@fluidframework/telemetry-utils";
|
|
35
|
+
import {
|
|
36
|
+
IGarbageCollectionData,
|
|
37
|
+
ISummaryTreeWithStats,
|
|
38
|
+
ITelemetryContext,
|
|
19
39
|
} from "@fluidframework/runtime-definitions";
|
|
20
40
|
|
|
41
|
+
import { canRetryOnError, runWithRetry } from "@fluidframework/driver-utils";
|
|
42
|
+
import { disableAttachmentBlobSweepKey } from "./gc";
|
|
43
|
+
import { IBlobMetadata } from "./metadata";
|
|
44
|
+
|
|
21
45
|
/**
|
|
22
46
|
* This class represents blob (long string)
|
|
23
47
|
* This object is used only when creating (writing) new blob and serialization purposes.
|
|
@@ -26,299 +50,918 @@ import {
|
|
|
26
50
|
* and loads blob.
|
|
27
51
|
*/
|
|
28
52
|
export class BlobHandle implements IFluidHandle<ArrayBufferLike> {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
53
|
+
private attached: boolean = false;
|
|
54
|
+
|
|
55
|
+
public get IFluidHandle(): IFluidHandle {
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public get isAttached(): boolean {
|
|
60
|
+
return this.routeContext.isAttached && this.attached;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public readonly absolutePath: string;
|
|
64
|
+
|
|
65
|
+
constructor(
|
|
66
|
+
public readonly path: string,
|
|
67
|
+
public readonly routeContext: IFluidHandleContext,
|
|
68
|
+
public get: () => Promise<any>,
|
|
69
|
+
private readonly onAttachGraph?: () => void,
|
|
70
|
+
) {
|
|
71
|
+
this.absolutePath = generateHandleContextPath(path, this.routeContext);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public attachGraph() {
|
|
75
|
+
if (!this.attached) {
|
|
76
|
+
this.attached = true;
|
|
77
|
+
this.onAttachGraph?.();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public bind(handle: IFluidHandle) {
|
|
82
|
+
throw new Error("Cannot bind to blob handle");
|
|
83
|
+
}
|
|
84
|
+
}
|
|
32
85
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Information from a snapshot needed to load BlobManager
|
|
88
|
+
* @alpha
|
|
89
|
+
*/
|
|
90
|
+
export interface IBlobManagerLoadInfo {
|
|
91
|
+
ids?: string[];
|
|
92
|
+
redirectTable?: [string, string][];
|
|
93
|
+
}
|
|
36
94
|
|
|
37
|
-
|
|
95
|
+
// Restrict the IContainerRuntime interface to the subset required by BlobManager. This helps to make
|
|
96
|
+
// the contract explicit and reduces the amount of mocking required for tests.
|
|
97
|
+
export type IBlobManagerRuntime = Pick<
|
|
98
|
+
IContainerRuntime,
|
|
99
|
+
"attachState" | "connected" | "logger" | "clientDetails"
|
|
100
|
+
> &
|
|
101
|
+
TypedEventEmitter<IContainerRuntimeEvents>;
|
|
102
|
+
|
|
103
|
+
type ICreateBlobResponseWithTTL = ICreateBlobResponse & Partial<Record<"minTTLInSeconds", number>>;
|
|
104
|
+
|
|
105
|
+
interface PendingBlob {
|
|
106
|
+
blob: ArrayBufferLike;
|
|
107
|
+
uploading?: boolean;
|
|
108
|
+
opsent?: boolean;
|
|
109
|
+
storageId?: string;
|
|
110
|
+
handleP: Deferred<BlobHandle>;
|
|
111
|
+
uploadP?: Promise<ICreateBlobResponse | void>;
|
|
112
|
+
uploadTime?: number;
|
|
113
|
+
minTTLInSeconds?: number;
|
|
114
|
+
attached?: boolean;
|
|
115
|
+
acked?: boolean;
|
|
116
|
+
abortSignal?: AbortSignal;
|
|
117
|
+
pendingStashed?: boolean;
|
|
118
|
+
}
|
|
38
119
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
120
|
+
export interface IPendingBlobs {
|
|
121
|
+
[id: string]: {
|
|
122
|
+
blob: string;
|
|
123
|
+
storageId?: string;
|
|
124
|
+
uploadTime?: number;
|
|
125
|
+
minTTLInSeconds?: number;
|
|
126
|
+
attached?: boolean;
|
|
127
|
+
acked?: boolean;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
46
130
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
131
|
+
export interface IBlobManagerEvents {
|
|
132
|
+
(event: "noPendingBlobs", listener: () => void);
|
|
133
|
+
}
|
|
50
134
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
135
|
+
export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
|
|
136
|
+
public static readonly basePath = "_blobs";
|
|
137
|
+
private static readonly redirectTableBlobName = ".redirectTable";
|
|
138
|
+
private readonly mc: MonitoringContext;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Map of local IDs to storage IDs. Contains identity entries (id → id) for storage IDs. All requested IDs should
|
|
142
|
+
* be a key in this map. Blobs created while the container is detached are stored in IDetachedBlobStorage which
|
|
143
|
+
* gives local IDs; the storage IDs are filled in at attach time.
|
|
144
|
+
* Note: It contains mappings from all clients, i.e., from remote clients as well. local ID comes from the client
|
|
145
|
+
* that uploaded the blob but its mapping to storage ID is needed in all clients in order to retrieve the blob.
|
|
146
|
+
*/
|
|
147
|
+
private readonly redirectTable: Map<string, string | undefined>;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Blobs which we have not yet seen a BlobAttach op round-trip and not yet attached to a DDS.
|
|
151
|
+
*/
|
|
152
|
+
private readonly pendingBlobs: Map<string, PendingBlob> = new Map();
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Track ops in flight for online flow. This is used for optimizations where if we receive an ack for a storage ID,
|
|
156
|
+
* we can resolve all pending blobs with the same storage ID even though they may have different local IDs. That's
|
|
157
|
+
* because we know that the server will not delete the blob corresponding to that storage ID.
|
|
158
|
+
*/
|
|
159
|
+
private readonly opsInFlight: Map<string, string[]> = new Map();
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* This stores IDs of tombstoned blobs.
|
|
163
|
+
* Tombstone is a temporary feature that imitates a blob getting swept by garbage collection.
|
|
164
|
+
*/
|
|
165
|
+
private readonly tombstonedBlobs: Set<string> = new Set();
|
|
166
|
+
|
|
167
|
+
private readonly sendBlobAttachOp: (localId: string, storageId?: string) => void;
|
|
168
|
+
private stopAttaching: boolean = false;
|
|
169
|
+
|
|
170
|
+
constructor(
|
|
171
|
+
private readonly routeContext: IFluidHandleContext,
|
|
172
|
+
snapshot: IBlobManagerLoadInfo,
|
|
173
|
+
private readonly getStorage: () => IDocumentStorageService,
|
|
174
|
+
/**
|
|
175
|
+
* Submit a BlobAttach op. When a blob is uploaded, there is a short grace period before which the blob is
|
|
176
|
+
* deleted. The BlobAttach op notifies the server that blob is in use. The server will then not delete the
|
|
177
|
+
* the blob as long as it is listed as referenced in future summaries. The summarizing client will know to
|
|
178
|
+
* include the storage ID in the summary when it sees the op.
|
|
179
|
+
*
|
|
180
|
+
* The op will also include a local ID to inform all clients of the relation to the storage ID, without
|
|
181
|
+
* knowledge of which they cannot request the blob from storage. It's important that this op is sequenced
|
|
182
|
+
* before any ops that reference the local ID, otherwise, an invalid handle could be added to the document.
|
|
183
|
+
*/
|
|
184
|
+
sendBlobAttachOp: (localId: string, storageId?: string) => void,
|
|
185
|
+
// Called when a blob node is requested. blobPath is the path of the blob's node in GC's graph.
|
|
186
|
+
// blobPath's format - `/<BlobManager.basePath>/<blobId>`.
|
|
187
|
+
private readonly blobRequested: (blobPath: string) => void,
|
|
188
|
+
// Called to check if a blob has been deleted by GC.
|
|
189
|
+
// blobPath's format - `/<BlobManager.basePath>/<blobId>`.
|
|
190
|
+
private readonly isBlobDeleted: (blobPath: string) => boolean,
|
|
191
|
+
private readonly runtime: IBlobManagerRuntime,
|
|
192
|
+
stashedBlobs: IPendingBlobs = {},
|
|
193
|
+
private readonly closeContainer: (error?: ICriticalContainerError) => void,
|
|
194
|
+
) {
|
|
195
|
+
super();
|
|
196
|
+
this.mc = createChildMonitoringContext({
|
|
197
|
+
logger: this.runtime.logger,
|
|
198
|
+
namespace: "BlobManager",
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
this.redirectTable = this.load(snapshot);
|
|
202
|
+
|
|
203
|
+
// Begin uploading stashed blobs from previous container instance
|
|
204
|
+
Object.entries(stashedBlobs).forEach(([localId, entry]) => {
|
|
205
|
+
const blob = stringToBuffer(entry.blob, "base64");
|
|
206
|
+
const attached = entry.attached;
|
|
207
|
+
const acked = entry.acked;
|
|
208
|
+
const storageId = entry.storageId; // entry.storageId = response.id
|
|
209
|
+
if (entry.minTTLInSeconds && entry.uploadTime) {
|
|
210
|
+
const timeLapseSinceLocalUpload = (Date.now() - entry.uploadTime) / 1000;
|
|
211
|
+
// stashed entries with more than half-life in storage will not be reuploaded
|
|
212
|
+
if (entry.minTTLInSeconds - timeLapseSinceLocalUpload > entry.minTTLInSeconds / 2) {
|
|
213
|
+
this.pendingBlobs.set(localId, {
|
|
214
|
+
blob,
|
|
215
|
+
uploading: false,
|
|
216
|
+
opsent: true,
|
|
217
|
+
handleP: new Deferred(),
|
|
218
|
+
storageId,
|
|
219
|
+
uploadP: undefined,
|
|
220
|
+
uploadTime: entry.uploadTime,
|
|
221
|
+
minTTLInSeconds: entry.minTTLInSeconds,
|
|
222
|
+
attached,
|
|
223
|
+
acked,
|
|
224
|
+
});
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
this.pendingBlobs.set(localId, {
|
|
229
|
+
blob,
|
|
230
|
+
uploading: true,
|
|
231
|
+
handleP: new Deferred(),
|
|
232
|
+
uploadP: this.uploadBlob(localId, blob),
|
|
233
|
+
attached,
|
|
234
|
+
acked,
|
|
235
|
+
opsent: true,
|
|
236
|
+
pendingStashed: true,
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
this.sendBlobAttachOp = (localId: string, blobId?: string) => {
|
|
241
|
+
const pendingEntry = this.pendingBlobs.get(localId);
|
|
242
|
+
assert(
|
|
243
|
+
pendingEntry !== undefined,
|
|
244
|
+
0x725 /* Must have pending blob entry for upcoming op */,
|
|
245
|
+
);
|
|
246
|
+
if (pendingEntry?.uploadTime && pendingEntry?.minTTLInSeconds) {
|
|
247
|
+
const secondsSinceUpload = (Date.now() - pendingEntry.uploadTime) / 1000;
|
|
248
|
+
const expired = pendingEntry.minTTLInSeconds - secondsSinceUpload < 0;
|
|
249
|
+
this.mc.logger.sendTelemetryEvent({
|
|
250
|
+
eventName: "sendBlobAttach",
|
|
251
|
+
secondsSinceUpload,
|
|
252
|
+
minTTLInSeconds: pendingEntry.minTTLInSeconds,
|
|
253
|
+
expired,
|
|
254
|
+
});
|
|
255
|
+
if (expired) {
|
|
256
|
+
// we want to avoid submitting ops with broken handles
|
|
257
|
+
this.closeContainer(
|
|
258
|
+
new GenericError(
|
|
259
|
+
"Trying to submit a BlobAttach for expired blob",
|
|
260
|
+
undefined,
|
|
261
|
+
{
|
|
262
|
+
localId,
|
|
263
|
+
blobId,
|
|
264
|
+
secondsSinceUpload,
|
|
265
|
+
},
|
|
266
|
+
),
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
pendingEntry.opsent = true;
|
|
271
|
+
return sendBlobAttachOp(localId, blobId);
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
public get allBlobsAttached(): boolean {
|
|
276
|
+
for (const [, entry] of this.pendingBlobs) {
|
|
277
|
+
if (entry.attached === false) {
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
public get hasPendingBlobs(): boolean {
|
|
285
|
+
return (
|
|
286
|
+
(this.runtime.attachState !== AttachState.Attached && this.redirectTable.size > 0) ||
|
|
287
|
+
this.pendingBlobs.size > 0
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
private createAbortError(pending?: PendingBlob) {
|
|
292
|
+
return new LoggingError("uploadBlob aborted", {
|
|
293
|
+
acked: pending?.acked,
|
|
294
|
+
uploadTime: pending?.uploadTime,
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
public hasPendingStashedBlobs(): boolean {
|
|
299
|
+
return Array.from(this.pendingBlobs.values()).some((e) => e.pendingStashed === true);
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Upload blobs added while offline. This must be completed before connecting and resubmitting ops.
|
|
303
|
+
*/
|
|
304
|
+
public async processStashedChanges() {
|
|
305
|
+
const pendingUploads = Array.from(this.pendingBlobs.values())
|
|
306
|
+
.filter((e) => e.pendingStashed === true)
|
|
307
|
+
.map(async (e) => e.uploadP);
|
|
308
|
+
await PerformanceEvent.timedExecAsync(
|
|
309
|
+
this.mc.logger,
|
|
310
|
+
{
|
|
311
|
+
eventName: "BlobUploadProcessStashedChanges",
|
|
312
|
+
count: pendingUploads.length,
|
|
313
|
+
},
|
|
314
|
+
async () => Promise.all(pendingUploads),
|
|
315
|
+
{ start: true, end: true },
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Set of actual storage IDs (i.e., IDs that can be requested from storage). This will be empty if the container is
|
|
321
|
+
* detached or there are no (non-pending) attachment blobs in the document
|
|
322
|
+
*/
|
|
323
|
+
private get storageIds(): Set<string> {
|
|
324
|
+
const ids = new Set<string | undefined>(this.redirectTable.values());
|
|
325
|
+
|
|
326
|
+
// If we are detached, we will not have storage IDs, only undefined
|
|
327
|
+
const undefinedValueInTable = ids.delete(undefined);
|
|
328
|
+
|
|
329
|
+
// For a detached container, entries are inserted into the redirect table with an undefined storage ID.
|
|
330
|
+
// For an attached container, entries are inserted w/storage ID after the BlobAttach op round-trips.
|
|
331
|
+
assert(
|
|
332
|
+
!undefinedValueInTable ||
|
|
333
|
+
(this.runtime.attachState === AttachState.Detached && ids.size === 0),
|
|
334
|
+
0x382 /* 'redirectTable' must contain only undefined while detached / defined values while attached */,
|
|
335
|
+
);
|
|
336
|
+
|
|
337
|
+
return ids as Set<string>;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
public async getBlob(blobId: string): Promise<ArrayBufferLike> {
|
|
341
|
+
// Verify that the blob is not deleted, i.e., it has not been garbage collected. If it is, this will throw
|
|
342
|
+
// an error, failing the call.
|
|
343
|
+
this.verifyBlobNotDeleted(blobId);
|
|
344
|
+
// Let runtime know that the corresponding GC node was requested.
|
|
345
|
+
// Note that this will throw if the blob is inactive or tombstoned and throwing on incorrect usage
|
|
346
|
+
// is configured.
|
|
347
|
+
this.blobRequested(getGCNodePathFromBlobId(blobId));
|
|
348
|
+
|
|
349
|
+
const pending = this.pendingBlobs.get(blobId);
|
|
350
|
+
if (pending) {
|
|
351
|
+
return pending.blob;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
let storageId: string;
|
|
355
|
+
if (this.runtime.attachState === AttachState.Detached) {
|
|
356
|
+
assert(this.redirectTable.has(blobId), 0x383 /* requesting unknown blobs */);
|
|
357
|
+
|
|
358
|
+
// Blobs created while the container is detached are stored in IDetachedBlobStorage.
|
|
359
|
+
// The 'IDocumentStorageService.readBlob()' call below will retrieve these via localId.
|
|
360
|
+
storageId = blobId;
|
|
361
|
+
} else {
|
|
362
|
+
const attachedStorageId = this.redirectTable.get(blobId);
|
|
363
|
+
assert(!!attachedStorageId, 0x11f /* "requesting unknown blobs" */);
|
|
364
|
+
storageId = attachedStorageId;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
return PerformanceEvent.timedExecAsync(
|
|
368
|
+
this.mc.logger,
|
|
369
|
+
{ eventName: "AttachmentReadBlob", id: storageId },
|
|
370
|
+
async () => {
|
|
371
|
+
return this.getStorage().readBlob(storageId);
|
|
372
|
+
},
|
|
373
|
+
{ end: true, cancel: "error" },
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
private getBlobHandle(id: string): BlobHandle {
|
|
378
|
+
assert(
|
|
379
|
+
this.redirectTable.has(id) || this.pendingBlobs.has(id),
|
|
380
|
+
0x384 /* requesting handle for unknown blob */,
|
|
381
|
+
);
|
|
382
|
+
const pending = this.pendingBlobs.get(id);
|
|
383
|
+
const callback = pending
|
|
384
|
+
? () => {
|
|
385
|
+
pending.attached = true;
|
|
386
|
+
this.emit("blobAttached", pending);
|
|
387
|
+
this.deletePendingBlobMaybe(id);
|
|
388
|
+
}
|
|
389
|
+
: undefined;
|
|
390
|
+
return new BlobHandle(
|
|
391
|
+
`${BlobManager.basePath}/${id}`,
|
|
392
|
+
this.routeContext,
|
|
393
|
+
async () => this.getBlob(id),
|
|
394
|
+
callback,
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
private async createBlobDetached(
|
|
399
|
+
blob: ArrayBufferLike,
|
|
400
|
+
): Promise<IFluidHandle<ArrayBufferLike>> {
|
|
401
|
+
// Blobs created while the container is detached are stored in IDetachedBlobStorage.
|
|
402
|
+
// The 'IDocumentStorageService.createBlob()' call below will respond with a localId.
|
|
403
|
+
const response = await this.getStorage().createBlob(blob);
|
|
404
|
+
this.setRedirection(response.id, undefined);
|
|
405
|
+
return this.getBlobHandle(response.id);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
public async createBlob(
|
|
409
|
+
blob: ArrayBufferLike,
|
|
410
|
+
signal?: AbortSignal,
|
|
411
|
+
): Promise<IFluidHandle<ArrayBufferLike>> {
|
|
412
|
+
if (this.runtime.attachState === AttachState.Detached) {
|
|
413
|
+
return this.createBlobDetached(blob);
|
|
414
|
+
}
|
|
415
|
+
if (this.runtime.attachState === AttachState.Attaching) {
|
|
416
|
+
// blob upload is not supported in "Attaching" state
|
|
417
|
+
this.mc.logger.sendTelemetryEvent({ eventName: "CreateBlobWhileAttaching" });
|
|
418
|
+
await new Promise<void>((resolve) => this.runtime.once("attached", resolve));
|
|
419
|
+
}
|
|
420
|
+
assert(
|
|
421
|
+
this.runtime.attachState === AttachState.Attached,
|
|
422
|
+
0x385 /* For clarity and paranoid defense against adding future attachment states */,
|
|
423
|
+
);
|
|
424
|
+
|
|
425
|
+
if (signal?.aborted) {
|
|
426
|
+
throw this.createAbortError();
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// Create a local ID for the blob. After uploading it to storage and before returning it, a local ID to
|
|
430
|
+
// storage ID mapping is created.
|
|
431
|
+
const localId = uuid();
|
|
432
|
+
const pendingEntry: PendingBlob = {
|
|
433
|
+
blob,
|
|
434
|
+
uploading: true,
|
|
435
|
+
handleP: new Deferred(),
|
|
436
|
+
uploadP: this.uploadBlob(localId, blob),
|
|
437
|
+
attached: false,
|
|
438
|
+
acked: false,
|
|
439
|
+
abortSignal: signal,
|
|
440
|
+
opsent: false,
|
|
441
|
+
};
|
|
442
|
+
this.pendingBlobs.set(localId, pendingEntry);
|
|
443
|
+
|
|
444
|
+
const abortListener = () => {
|
|
445
|
+
if (!pendingEntry.acked) {
|
|
446
|
+
pendingEntry.handleP.reject(this.createAbortError(pendingEntry));
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
signal?.addEventListener("abort", abortListener, { once: true });
|
|
450
|
+
|
|
451
|
+
return pendingEntry.handleP.promise.finally(() => {
|
|
452
|
+
signal?.removeEventListener("abort", abortListener);
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
private async uploadBlob(
|
|
457
|
+
localId: string,
|
|
458
|
+
blob: ArrayBufferLike,
|
|
459
|
+
): Promise<ICreateBlobResponse | void> {
|
|
460
|
+
return runWithRetry(
|
|
461
|
+
async () => {
|
|
462
|
+
try {
|
|
463
|
+
return await this.getStorage().createBlob(blob);
|
|
464
|
+
} catch (error) {
|
|
465
|
+
const entry = this.pendingBlobs.get(localId);
|
|
466
|
+
assert(
|
|
467
|
+
!!entry,
|
|
468
|
+
0x387 /* Must have pending blob entry for blob which failed to upload */,
|
|
469
|
+
);
|
|
470
|
+
if (entry.opsent && !canRetryOnError(error)) {
|
|
471
|
+
throw wrapError(
|
|
472
|
+
error,
|
|
473
|
+
() => new LoggingError(`uploadBlob error`, { canRetry: true }),
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
throw error;
|
|
477
|
+
}
|
|
478
|
+
},
|
|
479
|
+
"createBlob",
|
|
480
|
+
this.mc.logger,
|
|
481
|
+
{
|
|
482
|
+
cancel: this.pendingBlobs.get(localId)?.abortSignal,
|
|
483
|
+
},
|
|
484
|
+
).then(
|
|
485
|
+
(response) => this.onUploadResolve(localId, response),
|
|
486
|
+
(error) => {
|
|
487
|
+
// it will only reject if we haven't sent an op
|
|
488
|
+
// and is a non-retriable error. It will only reject
|
|
489
|
+
// the promise but not throw any error outside.
|
|
490
|
+
this.pendingBlobs.get(localId)?.handleP.reject(error);
|
|
491
|
+
this.deletePendingBlob(localId);
|
|
492
|
+
},
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Set up a mapping in the redirect table from fromId to toId. Also, notify the runtime that a reference is added
|
|
498
|
+
* which is required for GC.
|
|
499
|
+
*/
|
|
500
|
+
private setRedirection(fromId: string, toId: string | undefined) {
|
|
501
|
+
this.redirectTable.set(fromId, toId);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
private deletePendingBlobMaybe(id: string) {
|
|
505
|
+
if (this.pendingBlobs.has(id)) {
|
|
506
|
+
const entry = this.pendingBlobs.get(id);
|
|
507
|
+
if (entry?.attached && entry?.acked) {
|
|
508
|
+
this.deletePendingBlob(id);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
private deletePendingBlob(id: string) {
|
|
514
|
+
if (this.pendingBlobs.delete(id) && !this.hasPendingBlobs) {
|
|
515
|
+
this.emit("noPendingBlobs");
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
private onUploadResolve(localId: string, response: ICreateBlobResponseWithTTL) {
|
|
520
|
+
const entry = this.pendingBlobs.get(localId);
|
|
521
|
+
assert(entry !== undefined, 0x6c8 /* pending blob entry not found for uploaded blob */);
|
|
522
|
+
if ((entry.abortSignal?.aborted === true && !entry.opsent) || this.stopAttaching) {
|
|
523
|
+
this.deletePendingBlob(localId);
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
assert(
|
|
527
|
+
entry.uploading === true,
|
|
528
|
+
0x386 /* Must have pending blob entry for uploaded blob */,
|
|
529
|
+
);
|
|
530
|
+
entry.storageId = response.id;
|
|
531
|
+
entry.uploadTime = Date.now();
|
|
532
|
+
entry.minTTLInSeconds = response.minTTLInSeconds;
|
|
533
|
+
// Send a blob attach op. This serves two purposes:
|
|
534
|
+
// 1. If its a new blob, i.e., it isn't de-duped, the server will keep the blob alive if it sees this op
|
|
535
|
+
// until its storage ID is added to the next summary.
|
|
536
|
+
// 2. It will create a local ID to storage ID mapping in all clients which is needed to retrieve the
|
|
537
|
+
// blob from the server via the storage ID.
|
|
538
|
+
if (!entry.opsent) {
|
|
539
|
+
this.sendBlobAttachOp(localId, response.id);
|
|
540
|
+
}
|
|
541
|
+
if (this.storageIds.has(response.id)) {
|
|
542
|
+
// The blob is de-duped. Set up a local ID to storage ID mapping and return the blob. Since this is
|
|
543
|
+
// an existing blob, we don't have to wait for the op to be ack'd since this step has already
|
|
544
|
+
// happened before and so, the server won't delete it.
|
|
545
|
+
this.setRedirection(localId, response.id);
|
|
546
|
+
entry.handleP.resolve(this.getBlobHandle(localId));
|
|
547
|
+
this.deletePendingBlobMaybe(localId);
|
|
548
|
+
} else {
|
|
549
|
+
// If there is already an op for this storage ID, append the local ID to the list. Once any op for
|
|
550
|
+
// this storage ID is ack'd, all pending blobs for it can be resolved since the op will keep the
|
|
551
|
+
// blob alive in storage.
|
|
552
|
+
this.opsInFlight.set(
|
|
553
|
+
response.id,
|
|
554
|
+
(this.opsInFlight.get(response.id) ?? []).concat(localId),
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
return response;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Resubmit a BlobAttach op. Used to add storage IDs to ops that were
|
|
562
|
+
* submitted to runtime while disconnected.
|
|
563
|
+
* @param metadata - op metadata containing storage and/or local IDs
|
|
564
|
+
*/
|
|
565
|
+
public reSubmit(metadata: Record<string, unknown> | undefined) {
|
|
566
|
+
assert(!!metadata, 0x38b /* Resubmitted ops must have metadata */);
|
|
567
|
+
const { localId, blobId }: { localId?: string; blobId?: string } = metadata;
|
|
568
|
+
assert(localId !== undefined, 0x50d /* local ID not available on reSubmit */);
|
|
569
|
+
const pendingEntry = this.pendingBlobs.get(localId);
|
|
570
|
+
|
|
571
|
+
if (!blobId) {
|
|
572
|
+
// We submitted this op while offline. The blob should have been uploaded by now.
|
|
573
|
+
assert(
|
|
574
|
+
pendingEntry?.opsent === true && !!pendingEntry?.storageId,
|
|
575
|
+
0x38d /* blob must be uploaded before resubmitting BlobAttach op */,
|
|
576
|
+
);
|
|
577
|
+
return this.sendBlobAttachOp(localId, pendingEntry?.storageId);
|
|
578
|
+
}
|
|
579
|
+
return this.sendBlobAttachOp(localId, blobId);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
public processBlobAttachOp(message: ISequencedDocumentMessage, local: boolean) {
|
|
583
|
+
const localId = (message.metadata as IBlobMetadata | undefined)?.localId;
|
|
584
|
+
const blobId = (message.metadata as IBlobMetadata | undefined)?.blobId;
|
|
585
|
+
|
|
586
|
+
if (localId) {
|
|
587
|
+
const pendingEntry = this.pendingBlobs.get(localId);
|
|
588
|
+
if (pendingEntry?.abortSignal?.aborted) {
|
|
589
|
+
this.deletePendingBlob(localId);
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
if (pendingEntry?.pendingStashed) {
|
|
593
|
+
pendingEntry.pendingStashed = false;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
assert(blobId !== undefined, 0x12a /* "Missing blob id on metadata" */);
|
|
597
|
+
|
|
598
|
+
// Set up a mapping from local ID to storage ID. This is crucial since without this the blob cannot be
|
|
599
|
+
// requested from the server.
|
|
600
|
+
// Note: The check for undefined is needed for back-compat when localId was not part of the BlobAttach op that
|
|
601
|
+
// was sent when online.
|
|
602
|
+
if (localId !== undefined) {
|
|
603
|
+
this.setRedirection(localId, blobId);
|
|
604
|
+
}
|
|
605
|
+
// set identity (id -> id) entry
|
|
606
|
+
this.setRedirection(blobId, blobId);
|
|
607
|
+
|
|
608
|
+
if (local) {
|
|
609
|
+
assert(localId !== undefined, 0x50e /* local ID not present in blob attach message */);
|
|
610
|
+
const waitingBlobs = this.opsInFlight.get(blobId);
|
|
611
|
+
if (waitingBlobs !== undefined) {
|
|
612
|
+
// For each op corresponding to this storage ID that we are waiting for, resolve the pending blob.
|
|
613
|
+
// This is safe because the server will keep the blob alive and the op containing the local ID to
|
|
614
|
+
// storage ID is already in flight and any op containing this local ID will be sequenced after that.
|
|
615
|
+
waitingBlobs.forEach((pendingLocalId) => {
|
|
616
|
+
const entry = this.pendingBlobs.get(pendingLocalId);
|
|
617
|
+
assert(
|
|
618
|
+
entry !== undefined,
|
|
619
|
+
0x38f /* local online BlobAttach op with no pending blob entry */,
|
|
620
|
+
);
|
|
621
|
+
this.setRedirection(pendingLocalId, blobId);
|
|
622
|
+
entry.acked = true;
|
|
623
|
+
entry.handleP.resolve(this.getBlobHandle(pendingLocalId));
|
|
624
|
+
this.deletePendingBlobMaybe(pendingLocalId);
|
|
625
|
+
});
|
|
626
|
+
this.opsInFlight.delete(blobId);
|
|
627
|
+
}
|
|
628
|
+
const localEntry = this.pendingBlobs.get(localId);
|
|
629
|
+
if (localEntry) {
|
|
630
|
+
localEntry.acked = true;
|
|
631
|
+
localEntry.handleP.resolve(this.getBlobHandle(localId));
|
|
632
|
+
this.deletePendingBlobMaybe(localId);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Reads blobs needed to load BlobManager from storage.
|
|
639
|
+
* @param blobsTree - Tree containing IDs of previously attached blobs. We
|
|
640
|
+
* look for the IDs in the blob entries of the tree since the both the r11s
|
|
641
|
+
* and SPO drivers replace the attachment types returned in snapshot() with blobs.
|
|
642
|
+
*/
|
|
643
|
+
public static async load(
|
|
644
|
+
blobsTree: ISnapshotTree | undefined,
|
|
645
|
+
tryFetchBlob: (id: string) => Promise<[string, string][]>,
|
|
646
|
+
): Promise<IBlobManagerLoadInfo> {
|
|
647
|
+
if (!blobsTree) {
|
|
648
|
+
return {};
|
|
649
|
+
}
|
|
650
|
+
let redirectTable;
|
|
651
|
+
const tableId = blobsTree.blobs[this.redirectTableBlobName];
|
|
652
|
+
if (tableId) {
|
|
653
|
+
redirectTable = await tryFetchBlob(tableId);
|
|
654
|
+
}
|
|
655
|
+
const ids = Object.entries(blobsTree.blobs)
|
|
656
|
+
.filter(([k, _]) => k !== this.redirectTableBlobName)
|
|
657
|
+
.map(([_, v]) => v);
|
|
658
|
+
return { ids, redirectTable };
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Load a set of previously attached blob IDs and redirect table from a previous snapshot.
|
|
663
|
+
*/
|
|
664
|
+
private load(snapshot: IBlobManagerLoadInfo): Map<string, string | undefined> {
|
|
665
|
+
this.mc.logger.sendTelemetryEvent({
|
|
666
|
+
eventName: "AttachmentBlobsLoaded",
|
|
667
|
+
count: snapshot.ids?.length ?? 0,
|
|
668
|
+
redirectTable: snapshot.redirectTable?.length,
|
|
669
|
+
});
|
|
670
|
+
const table = new Map<string, string | undefined>(snapshot.redirectTable);
|
|
671
|
+
if (snapshot.ids) {
|
|
672
|
+
const detached = this.runtime.attachState === AttachState.Detached;
|
|
673
|
+
// If we are detached, we don't have storage IDs yet, so set to undefined
|
|
674
|
+
// Otherwise, set identity (id -> id) entries
|
|
675
|
+
snapshot.ids.forEach((entry) => table.set(entry, detached ? undefined : entry));
|
|
676
|
+
}
|
|
677
|
+
return table;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
public summarize(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats {
|
|
681
|
+
// if storageIds is empty, it means we are detached and have only local IDs, or that there are no blobs attached
|
|
682
|
+
const blobIds =
|
|
683
|
+
this.storageIds.size > 0
|
|
684
|
+
? Array.from(this.storageIds)
|
|
685
|
+
: Array.from(this.redirectTable.keys());
|
|
686
|
+
const builder = new SummaryTreeBuilder();
|
|
687
|
+
blobIds.forEach((blobId) => {
|
|
688
|
+
builder.addAttachment(blobId);
|
|
689
|
+
});
|
|
690
|
+
|
|
691
|
+
// Any non-identity entries in the table need to be saved in the summary
|
|
692
|
+
if (this.redirectTable.size > blobIds.length) {
|
|
693
|
+
builder.addBlob(
|
|
694
|
+
BlobManager.redirectTableBlobName,
|
|
695
|
+
// filter out identity entries
|
|
696
|
+
JSON.stringify(
|
|
697
|
+
Array.from(this.redirectTable.entries()).filter(
|
|
698
|
+
([localId, storageId]) => localId !== storageId,
|
|
699
|
+
),
|
|
700
|
+
),
|
|
701
|
+
);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
return builder.getSummaryTree();
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* Generates data used for garbage collection. Each blob uploaded represents a node in the GC graph as it can be
|
|
709
|
+
* individually referenced by storing its handle in a referenced DDS. Returns the list of blob ids as GC nodes.
|
|
710
|
+
* @param fullGC - true to bypass optimizations and force full generation of GC data. BlobManager doesn't care
|
|
711
|
+
* about this for now because the data is a simple list of blob ids.
|
|
712
|
+
*/
|
|
713
|
+
public getGCData(fullGC: boolean = false): IGarbageCollectionData {
|
|
714
|
+
const gcData: IGarbageCollectionData = { gcNodes: {} };
|
|
715
|
+
for (const [localId, storageId] of this.redirectTable) {
|
|
716
|
+
assert(!!storageId, 0x390 /* Must be attached to get GC data */);
|
|
717
|
+
// Only return local ids as GC nodes because a blob can only be referenced via its local id. The storage
|
|
718
|
+
// id entries have the same key and value, ignore them.
|
|
719
|
+
// The outbound routes are empty because a blob node cannot reference other nodes. It can only be referenced
|
|
720
|
+
// by adding its handle to a referenced DDS.
|
|
721
|
+
if (localId !== storageId) {
|
|
722
|
+
gcData.gcNodes[getGCNodePathFromBlobId(localId)] = [];
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
return gcData;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
/**
|
|
729
|
+
* This is called to update blobs whose routes are unused. The unused blobs are deleted.
|
|
730
|
+
* @param unusedRoutes - The routes of the blob nodes that are unused. These routes will be based off of local ids.
|
|
731
|
+
*/
|
|
732
|
+
public updateUnusedRoutes(unusedRoutes: readonly string[]): void {
|
|
733
|
+
this.deleteBlobsFromRedirectTable(unusedRoutes);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* Delete attachment blobs that are sweep ready.
|
|
738
|
+
* @param sweepReadyBlobRoutes - The routes of blobs that are sweep ready and should be deleted. These routes will
|
|
739
|
+
* be based off of local ids.
|
|
740
|
+
* @returns The routes of blobs that were deleted.
|
|
741
|
+
*/
|
|
742
|
+
public deleteSweepReadyNodes(sweepReadyBlobRoutes: readonly string[]): readonly string[] {
|
|
743
|
+
// If sweep for attachment blobs is not enabled, return empty list indicating nothing is deleted.
|
|
744
|
+
if (this.mc.config.getBoolean(disableAttachmentBlobSweepKey) === true) {
|
|
745
|
+
return [];
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
this.deleteBlobsFromRedirectTable(sweepReadyBlobRoutes);
|
|
749
|
+
return Array.from(sweepReadyBlobRoutes);
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Delete blobs with the given routes from the redirect table.
|
|
754
|
+
* The routes are GC nodes paths of format -`/<BlobManager.basePath>/<blobId>`. The blob ids are all local ids.
|
|
755
|
+
* Deleting the blobs involves 2 steps:
|
|
756
|
+
* 1. The redirect table entry for the local ids are deleted.
|
|
757
|
+
* 2. If the storage ids corresponding to the deleted local ids are not in-use anymore, the redirect table entries
|
|
758
|
+
* for the storage ids are deleted as well.
|
|
759
|
+
*
|
|
760
|
+
* Note that this does not delete the blobs from storage service immediately. Deleting the blobs from redirect table
|
|
761
|
+
* will remove them the next summary. The service would them delete them some time in the future.
|
|
762
|
+
*/
|
|
763
|
+
private deleteBlobsFromRedirectTable(blobRoutes: readonly string[]) {
|
|
764
|
+
if (blobRoutes.length === 0) {
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
// This tracks the storage ids of local ids that are deleted. After the local ids have been deleted, if any of
|
|
769
|
+
// these storage ids are unused, they will be deleted as well.
|
|
770
|
+
const maybeUnusedStorageIds: Set<string> = new Set();
|
|
771
|
+
for (const route of blobRoutes) {
|
|
772
|
+
const blobId = getBlobIdFromGCNodePath(route);
|
|
773
|
+
if (!this.redirectTable.has(blobId)) {
|
|
774
|
+
this.mc.logger.sendErrorEvent({
|
|
775
|
+
eventName: "DeletedAttachmentBlobNotFound",
|
|
776
|
+
blobId,
|
|
777
|
+
});
|
|
778
|
+
continue;
|
|
779
|
+
}
|
|
780
|
+
const storageId = this.redirectTable.get(blobId);
|
|
781
|
+
assert(!!storageId, 0x5bb /* Must be attached to run GC */);
|
|
782
|
+
maybeUnusedStorageIds.add(storageId);
|
|
783
|
+
this.redirectTable.delete(blobId);
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
// Find out storage ids that are in-use and remove them from maybeUnusedStorageIds. A storage id is in-use if
|
|
787
|
+
// the redirect table has a local id -> storage id entry for it.
|
|
788
|
+
for (const [localId, storageId] of this.redirectTable.entries()) {
|
|
789
|
+
assert(!!storageId, 0x5bc /* Must be attached to run GC */);
|
|
790
|
+
// For every storage id, the redirect table has a id -> id entry. These do not make the storage id in-use.
|
|
791
|
+
if (maybeUnusedStorageIds.has(storageId) && localId !== storageId) {
|
|
792
|
+
maybeUnusedStorageIds.delete(storageId);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
// For unused storage ids, delete their id -> id entries from the redirect table.
|
|
797
|
+
// This way they'll be absent from the next summary, and the service is free to delete them from storage.
|
|
798
|
+
for (const storageId of maybeUnusedStorageIds) {
|
|
799
|
+
this.redirectTable.delete(storageId);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
/**
|
|
804
|
+
* This is called to update blobs whose routes are tombstones. Tombstoned blobs enable testing scenarios with
|
|
805
|
+
* accessing deleted content without actually deleting content from summaries.
|
|
806
|
+
* @param tombstonedRoutes - The routes of blob nodes that are tombstones.
|
|
807
|
+
*/
|
|
808
|
+
public updateTombstonedRoutes(tombstonedRoutes: readonly string[]) {
|
|
809
|
+
const tombstonedBlobsSet: Set<string> = new Set();
|
|
810
|
+
// The routes or blob node paths are in the same format as returned in getGCData -
|
|
811
|
+
// `/<BlobManager.basePath>/<blobId>`.
|
|
812
|
+
for (const route of tombstonedRoutes) {
|
|
813
|
+
const blobId = getBlobIdFromGCNodePath(route);
|
|
814
|
+
tombstonedBlobsSet.add(blobId);
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
// Remove blobs from the tombstone list that were tombstoned but aren't anymore as per the tombstoneRoutes.
|
|
818
|
+
for (const blobId of this.tombstonedBlobs) {
|
|
819
|
+
if (!tombstonedBlobsSet.has(blobId)) {
|
|
820
|
+
this.tombstonedBlobs.delete(blobId);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
// Mark blobs that are now tombstoned by adding them to the tombstone list.
|
|
825
|
+
for (const blobId of tombstonedBlobsSet) {
|
|
826
|
+
this.tombstonedBlobs.add(blobId);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* Verifies that the blob with given id is not deleted, i.e., it has not been garbage collected. If the blob is GC'd,
|
|
832
|
+
* log an error and throw if necessary.
|
|
833
|
+
*/
|
|
834
|
+
private verifyBlobNotDeleted(blobId: string) {
|
|
835
|
+
if (!this.isBlobDeleted(getGCNodePathFromBlobId(blobId))) {
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
const request = { url: blobId };
|
|
840
|
+
const error = responseToException(
|
|
841
|
+
createResponseError(404, `Blob was deleted`, request),
|
|
842
|
+
request,
|
|
843
|
+
);
|
|
844
|
+
// Only log deleted events. Tombstone events are logged by garbage collector.
|
|
845
|
+
this.mc.logger.sendErrorEvent(
|
|
846
|
+
{
|
|
847
|
+
eventName: "GC_Deleted_Blob_Requested",
|
|
848
|
+
pkg: BlobManager.basePath,
|
|
849
|
+
},
|
|
850
|
+
error,
|
|
851
|
+
);
|
|
852
|
+
throw error;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
public setRedirectTable(table: Map<string, string>) {
|
|
856
|
+
assert(
|
|
857
|
+
this.runtime.attachState === AttachState.Detached,
|
|
858
|
+
0x252 /* "redirect table can only be set in detached container" */,
|
|
859
|
+
);
|
|
860
|
+
assert(
|
|
861
|
+
this.redirectTable.size === table.size,
|
|
862
|
+
0x391 /* Redirect table size must match BlobManager's local ID count */,
|
|
863
|
+
);
|
|
864
|
+
for (const [localId, storageId] of table) {
|
|
865
|
+
assert(
|
|
866
|
+
this.redirectTable.has(localId),
|
|
867
|
+
0x254 /* "unrecognized id in redirect table" */,
|
|
868
|
+
);
|
|
869
|
+
this.setRedirection(localId, storageId);
|
|
870
|
+
// set identity (id -> id) entry
|
|
871
|
+
this.setRedirection(storageId, storageId);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
public async attachAndGetPendingBlobs(
|
|
876
|
+
stopBlobAttachingSignal?: AbortSignal,
|
|
877
|
+
): Promise<IPendingBlobs | undefined> {
|
|
878
|
+
return PerformanceEvent.timedExecAsync(
|
|
879
|
+
this.mc.logger,
|
|
880
|
+
{ eventName: "GetPendingBlobs" },
|
|
881
|
+
async () => {
|
|
882
|
+
if (this.pendingBlobs.size === 0) {
|
|
883
|
+
return;
|
|
884
|
+
}
|
|
885
|
+
const blobs = {};
|
|
886
|
+
const localBlobs = new Set<PendingBlob>();
|
|
887
|
+
while (localBlobs.size < this.pendingBlobs.size) {
|
|
888
|
+
const attachBlobsP: Promise<void>[] = [];
|
|
889
|
+
for (const [id, entry] of this.pendingBlobs) {
|
|
890
|
+
if (!localBlobs.has(entry)) {
|
|
891
|
+
localBlobs.add(entry);
|
|
892
|
+
entry.handleP.resolve(this.getBlobHandle(id));
|
|
893
|
+
attachBlobsP.push(
|
|
894
|
+
new Promise<void>((resolve, reject) => {
|
|
895
|
+
stopBlobAttachingSignal?.addEventListener(
|
|
896
|
+
"abort",
|
|
897
|
+
() => {
|
|
898
|
+
this.stopAttaching = true;
|
|
899
|
+
reject(new Error("Operation aborted"));
|
|
900
|
+
},
|
|
901
|
+
{ once: true },
|
|
902
|
+
);
|
|
903
|
+
const onBlobAttached = (attachedEntry) => {
|
|
904
|
+
if (attachedEntry === entry) {
|
|
905
|
+
this.off("blobAttached", onBlobAttached);
|
|
906
|
+
resolve();
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
if (!entry.attached) {
|
|
910
|
+
this.on("blobAttached", onBlobAttached);
|
|
911
|
+
} else {
|
|
912
|
+
resolve();
|
|
913
|
+
}
|
|
914
|
+
}),
|
|
915
|
+
);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
await Promise.allSettled(attachBlobsP).catch(() => {});
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
for (const [id, entry] of this.pendingBlobs) {
|
|
922
|
+
if (stopBlobAttachingSignal?.aborted && !entry.attached) {
|
|
923
|
+
this.mc.logger.sendTelemetryEvent({
|
|
924
|
+
eventName: "UnableToStashBlob",
|
|
925
|
+
id,
|
|
926
|
+
});
|
|
927
|
+
continue;
|
|
928
|
+
}
|
|
929
|
+
assert(entry.attached === true, 0x790 /* stashed blob should be attached */);
|
|
930
|
+
if (!entry.opsent) {
|
|
931
|
+
this.sendBlobAttachOp(id, entry.storageId);
|
|
932
|
+
}
|
|
933
|
+
blobs[id] = {
|
|
934
|
+
blob: bufferToString(entry.blob, "base64"),
|
|
935
|
+
storageId: entry.storageId,
|
|
936
|
+
attached: entry.attached,
|
|
937
|
+
acked: entry.acked,
|
|
938
|
+
minTTLInSeconds: entry.minTTLInSeconds,
|
|
939
|
+
uploadTime: entry.uploadTime,
|
|
940
|
+
};
|
|
941
|
+
}
|
|
942
|
+
return Object.keys(blobs).length > 0 ? blobs : undefined;
|
|
943
|
+
},
|
|
944
|
+
);
|
|
945
|
+
}
|
|
54
946
|
}
|
|
55
947
|
|
|
56
948
|
/**
|
|
57
|
-
*
|
|
949
|
+
* For a blobId, returns its path in GC's graph. The node path is of the format `/<BlobManager.basePath>/<blobId>`.
|
|
950
|
+
* This path must match the path of the blob handle returned by the createBlob API because blobs are marked
|
|
951
|
+
* referenced by storing these handles in a referenced DDS.
|
|
58
952
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
redirectTable?: [string, string][];
|
|
953
|
+
function getGCNodePathFromBlobId(blobId: string) {
|
|
954
|
+
return `/${BlobManager.basePath}/${blobId}`;
|
|
62
955
|
}
|
|
63
956
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// map of detached blob IDs to IDs used by storage. used to support blob handles given out while detached
|
|
75
|
-
private redirectTable: Map<string, string> | undefined;
|
|
76
|
-
|
|
77
|
-
constructor(
|
|
78
|
-
private readonly routeContext: IFluidHandleContext,
|
|
79
|
-
snapshot: IBlobManagerLoadInfo,
|
|
80
|
-
private readonly getStorage: () => IDocumentStorageService,
|
|
81
|
-
private readonly attachBlobCallback: (blobId: string) => void,
|
|
82
|
-
// To be called when a blob node is requested. blobPath is the path of the blob's node in GC's graph. It's
|
|
83
|
-
// of the format `/<BlobManager.basePath>/<blobId>`.
|
|
84
|
-
private readonly gcNodeUpdated: (blobPath: string) => void,
|
|
85
|
-
private readonly runtime: IContainerRuntime,
|
|
86
|
-
private readonly logger: ITelemetryLogger,
|
|
87
|
-
) {
|
|
88
|
-
this.runtime.once("dispose", () => {
|
|
89
|
-
for (const promise of this.pendingBlobIds.values()) {
|
|
90
|
-
promise.reject(new Error("runtime disposed while blobAttach op in flight"));
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
this.load(snapshot);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
private hasBlob(id: string): boolean {
|
|
97
|
-
return this.blobIds.has(id) || this.detachedBlobIds.has(id);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* For a blobId, returns its path in GC's graph. The node path is of the format `/<BlobManager.basePath>/<blobId>`
|
|
102
|
-
* This path must match the path of the blob handle returned by the createBlob API because blobs are marked
|
|
103
|
-
* referenced by storing these handles in a referenced DDS.
|
|
104
|
-
*/
|
|
105
|
-
private getBlobGCNodePath(blobId: string) {
|
|
106
|
-
return `/${BlobManager.basePath}/${blobId}`;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
public async getBlob(blobId: string): Promise<IFluidHandle<ArrayBufferLike>> {
|
|
110
|
-
const storageId = this.redirectTable?.get(blobId) ?? blobId;
|
|
111
|
-
assert(this.hasBlob(storageId), 0x11f /* "requesting unknown blobs" */);
|
|
112
|
-
|
|
113
|
-
// When this blob is retrieved, let the container runtime know that the corresponding GC node got updated.
|
|
114
|
-
this.gcNodeUpdated(this.getBlobGCNodePath(blobId));
|
|
115
|
-
|
|
116
|
-
return new BlobHandle(
|
|
117
|
-
`${BlobManager.basePath}/${storageId}`,
|
|
118
|
-
this.routeContext,
|
|
119
|
-
async () => PerformanceEvent.timedExecAsync(
|
|
120
|
-
this.logger,
|
|
121
|
-
{ eventName: "AttachmentReadBlob", id: storageId },
|
|
122
|
-
async () => {
|
|
123
|
-
return this.getStorage().readBlob(storageId);
|
|
124
|
-
},
|
|
125
|
-
{ end: true, cancel: "error" },
|
|
126
|
-
),
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
public async createBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>> {
|
|
131
|
-
if (this.runtime.attachState === AttachState.Attaching) {
|
|
132
|
-
// blob upload is not supported in "Attaching" state
|
|
133
|
-
this.logger.sendTelemetryEvent({ eventName: "CreateBlobWhileAttaching" });
|
|
134
|
-
await new Promise<void>((resolve) => this.runtime.once("attached", resolve));
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (!this.runtime.connected && this.runtime.attachState === AttachState.Attached) {
|
|
138
|
-
// see https://github.com/microsoft/FluidFramework/issues/8246
|
|
139
|
-
// Avoid getting storage if we are offline since it might be undefined. In the future we will return
|
|
140
|
-
// handles immediately while offline
|
|
141
|
-
await new Promise((resolve) => this.runtime.once("connected", resolve));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const response = await PerformanceEvent.timedExecAsync(
|
|
145
|
-
this.logger,
|
|
146
|
-
{ eventName: "createBlob" },
|
|
147
|
-
async () => this.getStorage().createBlob(blob),
|
|
148
|
-
{ end: true, cancel: "error" },
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
const handle = new BlobHandle(
|
|
152
|
-
`${BlobManager.basePath}/${response.id}`,
|
|
153
|
-
this.routeContext,
|
|
154
|
-
// get() should go through BlobManager.getBlob() so handles created while detached can be redirected
|
|
155
|
-
// to the correct storage id after they are uploaded
|
|
156
|
-
async () => this.getBlob(response.id).then(async (h) => h.get()),
|
|
157
|
-
);
|
|
158
|
-
|
|
159
|
-
if (this.runtime.attachState === AttachState.Detached) {
|
|
160
|
-
this.detachedBlobIds.add(response.id);
|
|
161
|
-
return handle;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// Note - server will de-dup blobs, so we might get existing blobId!
|
|
165
|
-
if (this.pendingBlobIds.has(response.id)) {
|
|
166
|
-
await this.pendingBlobIds.get(response.id)?.promise;
|
|
167
|
-
} else if (!this.blobIds.has(response.id)) {
|
|
168
|
-
this.pendingBlobIds.set(response.id, new Deferred<void>());
|
|
169
|
-
|
|
170
|
-
// send blob attach op and wait until we see it to return the handle
|
|
171
|
-
this.attachBlobCallback(response.id);
|
|
172
|
-
await this.pendingBlobIds.get(response.id)?.promise;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return handle;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
public processBlobAttachOp(blobId: string, local: boolean) {
|
|
179
|
-
if (local) {
|
|
180
|
-
const pendingBlobP = this.pendingBlobIds.get(blobId);
|
|
181
|
-
assert(pendingBlobP !== undefined, 0x1f8 /* "local BlobAttach op with no pending blob" */);
|
|
182
|
-
pendingBlobP.resolve();
|
|
183
|
-
this.pendingBlobIds.delete(blobId);
|
|
184
|
-
}
|
|
185
|
-
this.blobIds.add(blobId);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Reads blobs needed to load BlobManager from storage.
|
|
190
|
-
*/
|
|
191
|
-
public static async load(
|
|
192
|
-
blobsTree: ISnapshotTree | undefined,
|
|
193
|
-
tryFetchBlob: (id: string) => Promise<[string, string][]>,
|
|
194
|
-
): Promise<IBlobManagerLoadInfo> {
|
|
195
|
-
if (!blobsTree) {
|
|
196
|
-
return {};
|
|
197
|
-
}
|
|
198
|
-
let redirectTable;
|
|
199
|
-
const tableId = blobsTree.blobs[this.redirectTableBlobName];
|
|
200
|
-
if (tableId) {
|
|
201
|
-
redirectTable = await tryFetchBlob(tableId);
|
|
202
|
-
}
|
|
203
|
-
const ids = Object.entries(blobsTree.blobs)
|
|
204
|
-
.filter(([k, _]) => k !== this.redirectTableBlobName).map(([_, v]) => v);
|
|
205
|
-
return { ids, redirectTable };
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Load a set of previously attached blob IDs from a previous snapshot. Note
|
|
210
|
-
* that BlobManager tracking and reporting attached blobs is a temporary
|
|
211
|
-
* solution since storage expects attached blobs to be reported and any that
|
|
212
|
-
* are not reported as attached may be GCed. In the future attached blob
|
|
213
|
-
* IDs will be collected at summarization time, and runtime will not care
|
|
214
|
-
* about the existence or specific formatting of this tree in returned
|
|
215
|
-
* snapshots.
|
|
216
|
-
*
|
|
217
|
-
* @param blobsTree - Tree containing IDs of previously attached blobs. This
|
|
218
|
-
* corresponds to snapshot() below. We look for the IDs in the blob entries
|
|
219
|
-
* of the tree since the both the r11s and SPO drivers replace the
|
|
220
|
-
* attachment types returned in snapshot() with blobs.
|
|
221
|
-
*/
|
|
222
|
-
private load(snapshot: IBlobManagerLoadInfo): void {
|
|
223
|
-
if (snapshot.ids) {
|
|
224
|
-
const detached = this.runtime.attachState === AttachState.Detached;
|
|
225
|
-
snapshot.ids.map((entry) => detached ? this.detachedBlobIds.add(entry) : this.blobIds.add(entry));
|
|
226
|
-
}
|
|
227
|
-
if (snapshot.redirectTable) {
|
|
228
|
-
this.redirectTable = new Map(snapshot.redirectTable);
|
|
229
|
-
}
|
|
230
|
-
this.logger.sendTelemetryEvent({
|
|
231
|
-
eventName: "AttachmentBlobsLoaded",
|
|
232
|
-
count: snapshot.ids?.length ?? 0,
|
|
233
|
-
redirectTable: snapshot.redirectTable?.length,
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Generates data used for garbage collection. Each blob uploaded represents a node in the GC graph as it can be
|
|
239
|
-
* individually referenced by storing its handle in a referenced DDS. Returns the list of blob ids as GC nodes.
|
|
240
|
-
* @param fullGC - true to bypass optimizations and force full generation of GC data. BlobManager doesn't care
|
|
241
|
-
* about this for now because the data is a simple list of blob ids.
|
|
242
|
-
*/
|
|
243
|
-
public getGCData(fullGC: boolean = false): IGarbageCollectionData {
|
|
244
|
-
const gcData: IGarbageCollectionData = { gcNodes: {} };
|
|
245
|
-
|
|
246
|
-
this.blobIds.forEach((blobId: string) => {
|
|
247
|
-
gcData.gcNodes[this.getBlobGCNodePath(blobId)] = [];
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* For all blobs in the redirect table, the handle returned on creation is based off of the localId. So, these
|
|
252
|
-
* nodes can be referenced by storing the localId handle. When that happens, the corresponding storageId node
|
|
253
|
-
* must also be marked referenced. So, we add a route from the localId node to the storageId node.
|
|
254
|
-
* Note that because of de-duping, there can be multiple localIds that all redirect to the same storageId or
|
|
255
|
-
* a blob may be referenced via its storageId handle.
|
|
256
|
-
*/
|
|
257
|
-
if (this.redirectTable !== undefined) {
|
|
258
|
-
for (const [localId, storageId] of this.redirectTable) {
|
|
259
|
-
// Add node for the localId and add a route to the storageId node. The storageId node will have been
|
|
260
|
-
// added above when adding nodes for this.blobIds.
|
|
261
|
-
gcData.gcNodes[this.getBlobGCNodePath(localId)] = [this.getBlobGCNodePath(storageId)];
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
return gcData;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* When running GC in test mode, this is called to delete blobs that are unused.
|
|
270
|
-
* @param unusedRoutes - These are the blob node ids that are unused and should be deleted.
|
|
271
|
-
*/
|
|
272
|
-
public deleteUnusedRoutes(unusedRoutes: string[]): void {
|
|
273
|
-
// The routes or blob node paths are in the same format as returned in getGCData -
|
|
274
|
-
// `/<BlobManager.basePath>/<blobId>`.
|
|
275
|
-
for (const route of unusedRoutes) {
|
|
276
|
-
const pathParts = route.split("/");
|
|
277
|
-
assert(
|
|
278
|
-
pathParts.length === 3 && pathParts[1] === BlobManager.basePath,
|
|
279
|
-
0x2d5 /* "Invalid blob node id in unused routes." */,
|
|
280
|
-
);
|
|
281
|
-
const blobId = pathParts[2];
|
|
282
|
-
|
|
283
|
-
// The unused blobId could be a localId. If so, remove it from the redirect table and continue. The
|
|
284
|
-
// corresponding storageId may still be used either directly or via other localIds.
|
|
285
|
-
if (this.redirectTable?.has(blobId)) {
|
|
286
|
-
this.redirectTable.delete(blobId);
|
|
287
|
-
continue;
|
|
288
|
-
}
|
|
289
|
-
this.blobIds.delete(blobId);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
public summarize(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats {
|
|
294
|
-
// If we have a redirect table it means the container is about to transition to "Attaching" state, so we need
|
|
295
|
-
// to return an actual snapshot containing all the real storage IDs we know about.
|
|
296
|
-
const attachingOrAttached = !!this.redirectTable || this.runtime.attachState !== AttachState.Detached;
|
|
297
|
-
const blobIds = attachingOrAttached ? this.blobIds : this.detachedBlobIds;
|
|
298
|
-
const builder = new SummaryTreeBuilder();
|
|
299
|
-
blobIds.forEach((blobId) => {
|
|
300
|
-
builder.addAttachment(blobId);
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
if (this.redirectTable && this.redirectTable.size > 0) {
|
|
304
|
-
builder.addBlob(
|
|
305
|
-
BlobManager.redirectTableBlobName,
|
|
306
|
-
JSON.stringify(Array.from(this.redirectTable.entries())),
|
|
307
|
-
);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
return builder.getSummaryTree();
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
public setRedirectTable(table: Map<string, string>) {
|
|
314
|
-
assert(this.runtime.attachState === AttachState.Detached,
|
|
315
|
-
0x252 /* "redirect table can only be set in detached container" */);
|
|
316
|
-
assert(!this.redirectTable, 0x253 /* "redirect table already exists" */);
|
|
317
|
-
for (const [localId, storageId] of table) {
|
|
318
|
-
assert(this.detachedBlobIds.delete(localId), 0x254 /* "unrecognized id in redirect table" */);
|
|
319
|
-
this.blobIds.add(storageId);
|
|
320
|
-
}
|
|
321
|
-
assert(this.detachedBlobIds.size === 0, 0x255 /* "detached blob id absent in redirect table" */);
|
|
322
|
-
this.redirectTable = table;
|
|
323
|
-
}
|
|
957
|
+
/**
|
|
958
|
+
* For a given GC node path, return the blobId. The node path is of the format `/<BlobManager.basePath>/<blobId>`.
|
|
959
|
+
*/
|
|
960
|
+
function getBlobIdFromGCNodePath(nodePath: string) {
|
|
961
|
+
const pathParts = nodePath.split("/");
|
|
962
|
+
assert(
|
|
963
|
+
pathParts.length === 3 && pathParts[1] === BlobManager.basePath,
|
|
964
|
+
0x5bd /* Invalid blob node path */,
|
|
965
|
+
);
|
|
966
|
+
return pathParts[2];
|
|
324
967
|
}
|