@fluidframework/container-runtime 2.0.0-internal.3.0.2 → 2.0.0-internal.3.2.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/.eslintrc.js +19 -19
- package/.mocharc.js +2 -2
- package/api-extractor.json +2 -2
- package/dist/batchTracker.d.ts.map +1 -1
- package/dist/batchTracker.js +2 -1
- package/dist/batchTracker.js.map +1 -1
- package/dist/blobManager.d.ts +15 -2
- package/dist/blobManager.d.ts.map +1 -1
- package/dist/blobManager.js +109 -37
- package/dist/blobManager.js.map +1 -1
- package/dist/connectionTelemetry.d.ts.map +1 -1
- package/dist/connectionTelemetry.js +11 -9
- package/dist/connectionTelemetry.js.map +1 -1
- package/dist/containerHandleContext.d.ts.map +1 -1
- package/dist/containerHandleContext.js +3 -1
- package/dist/containerHandleContext.js.map +1 -1
- package/dist/containerRuntime.d.ts +23 -11
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +225 -132
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStore.d.ts.map +1 -1
- package/dist/dataStore.js +11 -9
- package/dist/dataStore.js.map +1 -1
- package/dist/dataStoreContext.d.ts +27 -13
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js +95 -56
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/dataStoreContexts.d.ts.map +1 -1
- package/dist/dataStoreContexts.js +7 -3
- package/dist/dataStoreContexts.js.map +1 -1
- package/dist/dataStoreRegistry.d.ts.map +1 -1
- package/dist/dataStoreRegistry.js +3 -1
- package/dist/dataStoreRegistry.js.map +1 -1
- package/dist/dataStores.d.ts +28 -4
- package/dist/dataStores.d.ts.map +1 -1
- package/dist/dataStores.js +122 -44
- package/dist/dataStores.js.map +1 -1
- package/dist/deltaScheduler.d.ts.map +1 -1
- package/dist/deltaScheduler.js +8 -3
- package/dist/deltaScheduler.js.map +1 -1
- package/dist/{garbageCollection.d.ts → gc/garbageCollection.d.ts} +27 -203
- package/dist/gc/garbageCollection.d.ts.map +1 -0
- package/dist/{garbageCollection.js → gc/garbageCollection.js} +210 -400
- package/dist/gc/garbageCollection.js.map +1 -0
- package/dist/gc/gcDefinitions.d.ts +189 -0
- package/dist/gc/gcDefinitions.d.ts.map +1 -0
- package/dist/{garbageCollectionConstants.js → gc/gcDefinitions.js} +27 -2
- package/dist/gc/gcDefinitions.js.map +1 -0
- package/dist/gc/gcHelpers.d.ts +30 -0
- package/dist/gc/gcHelpers.d.ts.map +1 -0
- package/dist/gc/gcHelpers.js +65 -0
- package/dist/gc/gcHelpers.js.map +1 -0
- package/dist/gc/gcSummaryStateTracker.d.ts +86 -0
- package/dist/gc/gcSummaryStateTracker.d.ts.map +1 -0
- package/dist/gc/gcSummaryStateTracker.js +246 -0
- package/dist/gc/gcSummaryStateTracker.js.map +1 -0
- package/{lib → dist/gc}/gcSweepReadyUsageDetection.d.ts +5 -5
- package/dist/gc/gcSweepReadyUsageDetection.d.ts.map +1 -0
- package/dist/{gcSweepReadyUsageDetection.js → gc/gcSweepReadyUsageDetection.js} +15 -11
- package/dist/gc/gcSweepReadyUsageDetection.js.map +1 -0
- package/dist/gc/gcUnreferencedStateTracker.d.ts +34 -0
- package/dist/gc/gcUnreferencedStateTracker.d.ts.map +1 -0
- package/dist/gc/gcUnreferencedStateTracker.js +94 -0
- package/dist/gc/gcUnreferencedStateTracker.js.map +1 -0
- package/dist/gc/index.d.ts +11 -0
- package/dist/gc/index.d.ts.map +1 -0
- package/dist/gc/index.js +40 -0
- package/dist/gc/index.js.map +1 -0
- package/dist/index.d.ts +2 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -9
- package/dist/index.js.map +1 -1
- package/dist/opLifecycle/batchManager.d.ts +2 -13
- package/dist/opLifecycle/batchManager.d.ts.map +1 -1
- package/dist/opLifecycle/batchManager.js +19 -41
- package/dist/opLifecycle/batchManager.js.map +1 -1
- package/dist/opLifecycle/definitions.d.ts +4 -0
- package/dist/opLifecycle/definitions.d.ts.map +1 -1
- package/dist/opLifecycle/definitions.js.map +1 -1
- package/dist/opLifecycle/index.d.ts.map +1 -1
- package/dist/opLifecycle/index.js.map +1 -1
- package/dist/opLifecycle/opCompressor.d.ts.map +1 -1
- package/dist/opLifecycle/opCompressor.js +1 -0
- package/dist/opLifecycle/opCompressor.js.map +1 -1
- package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
- package/dist/opLifecycle/opDecompressor.js +5 -2
- package/dist/opLifecycle/opDecompressor.js.map +1 -1
- package/dist/opLifecycle/opSplitter.d.ts +1 -1
- package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
- package/dist/opLifecycle/opSplitter.js +24 -13
- package/dist/opLifecycle/opSplitter.js.map +1 -1
- package/dist/opLifecycle/outbox.d.ts +19 -3
- package/dist/opLifecycle/outbox.d.ts.map +1 -1
- package/dist/opLifecycle/outbox.js +78 -45
- package/dist/opLifecycle/outbox.js.map +1 -1
- package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
- package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
- package/dist/opProperties.d.ts.map +1 -1
- package/dist/opProperties.js +1 -3
- package/dist/opProperties.js.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 +8 -2
- package/dist/pendingStateManager.d.ts.map +1 -1
- package/dist/pendingStateManager.js +21 -13
- package/dist/pendingStateManager.js.map +1 -1
- package/dist/scheduleManager.d.ts.map +1 -1
- package/dist/scheduleManager.js +3 -2
- package/dist/scheduleManager.js.map +1 -1
- package/dist/serializedSnapshotStorage.d.ts +2 -2
- package/dist/serializedSnapshotStorage.d.ts.map +1 -1
- package/dist/serializedSnapshotStorage.js +5 -3
- package/dist/serializedSnapshotStorage.js.map +1 -1
- package/dist/summary/index.d.ts +17 -0
- package/dist/summary/index.d.ts.map +1 -0
- package/dist/summary/index.js +47 -0
- package/dist/summary/index.js.map +1 -0
- package/dist/summary/orderedClientElection.d.ts.map +1 -0
- package/dist/{orderedClientElection.js → summary/orderedClientElection.js} +10 -4
- package/dist/summary/orderedClientElection.js.map +1 -0
- package/dist/summary/runWhileConnectedCoordinator.d.ts.map +1 -0
- package/dist/summary/runWhileConnectedCoordinator.js.map +1 -0
- package/{lib → dist/summary}/runningSummarizer.d.ts +19 -18
- package/dist/summary/runningSummarizer.d.ts.map +1 -0
- package/dist/{runningSummarizer.js → summary/runningSummarizer.js} +191 -76
- package/dist/summary/runningSummarizer.js.map +1 -0
- package/dist/{summarizer.d.ts → summary/summarizer.d.ts} +4 -6
- package/dist/summary/summarizer.d.ts.map +1 -0
- package/dist/{summarizer.js → summary/summarizer.js} +31 -71
- package/dist/summary/summarizer.js.map +1 -0
- package/dist/summary/summarizerClientElection.d.ts.map +1 -0
- package/dist/summary/summarizerClientElection.js.map +1 -0
- package/dist/summary/summarizerHandle.d.ts.map +1 -0
- package/dist/summary/summarizerHandle.js.map +1 -0
- package/{lib → dist/summary}/summarizerHeuristics.d.ts +1 -1
- package/dist/summary/summarizerHeuristics.d.ts.map +1 -0
- package/dist/{summarizerHeuristics.js → summary/summarizerHeuristics.js} +6 -9
- package/dist/summary/summarizerHeuristics.js.map +1 -0
- package/{lib → dist/summary}/summarizerTypes.d.ts +22 -22
- package/dist/summary/summarizerTypes.d.ts.map +1 -0
- package/dist/summary/summarizerTypes.js.map +1 -0
- package/dist/summary/summaryCollection.d.ts.map +1 -0
- package/dist/{summaryCollection.js → summary/summaryCollection.js} +18 -8
- package/dist/summary/summaryCollection.js.map +1 -0
- package/{lib → dist/summary}/summaryFormat.d.ts +1 -40
- package/dist/summary/summaryFormat.d.ts.map +1 -0
- package/dist/{summaryFormat.js → summary/summaryFormat.js} +19 -20
- package/dist/summary/summaryFormat.js.map +1 -0
- package/dist/summary/summaryGenerator.d.ts.map +1 -0
- package/dist/{summaryGenerator.js → summary/summaryGenerator.js} +33 -15
- package/dist/summary/summaryGenerator.js.map +1 -0
- package/dist/{summaryManager.d.ts → summary/summaryManager.d.ts} +1 -1
- package/dist/summary/summaryManager.d.ts.map +1 -0
- package/dist/{summaryManager.js → summary/summaryManager.js} +21 -9
- package/dist/summary/summaryManager.js.map +1 -0
- package/dist/throttler.d.ts +2 -2
- package/dist/throttler.d.ts.map +1 -1
- package/dist/throttler.js +4 -4
- package/dist/throttler.js.map +1 -1
- package/lib/batchTracker.d.ts.map +1 -1
- package/lib/batchTracker.js +2 -1
- package/lib/batchTracker.js.map +1 -1
- package/lib/blobManager.d.ts +15 -2
- package/lib/blobManager.d.ts.map +1 -1
- package/lib/blobManager.js +109 -37
- package/lib/blobManager.js.map +1 -1
- package/lib/connectionTelemetry.d.ts.map +1 -1
- package/lib/connectionTelemetry.js +11 -9
- package/lib/connectionTelemetry.js.map +1 -1
- package/lib/containerHandleContext.d.ts.map +1 -1
- package/lib/containerHandleContext.js +3 -1
- package/lib/containerHandleContext.js.map +1 -1
- package/lib/containerRuntime.d.ts +23 -11
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +201 -108
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStore.d.ts.map +1 -1
- package/lib/dataStore.js +11 -9
- package/lib/dataStore.js.map +1 -1
- package/lib/dataStoreContext.d.ts +27 -13
- package/lib/dataStoreContext.d.ts.map +1 -1
- package/lib/dataStoreContext.js +84 -45
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/dataStoreContexts.d.ts.map +1 -1
- package/lib/dataStoreContexts.js +7 -3
- package/lib/dataStoreContexts.js.map +1 -1
- package/lib/dataStoreRegistry.d.ts.map +1 -1
- package/lib/dataStoreRegistry.js +3 -1
- package/lib/dataStoreRegistry.js.map +1 -1
- package/lib/dataStores.d.ts +28 -4
- package/lib/dataStores.d.ts.map +1 -1
- package/lib/dataStores.js +120 -42
- package/lib/dataStores.js.map +1 -1
- package/lib/deltaScheduler.d.ts.map +1 -1
- package/lib/deltaScheduler.js +9 -4
- package/lib/deltaScheduler.js.map +1 -1
- package/lib/{garbageCollection.d.ts → gc/garbageCollection.d.ts} +27 -203
- package/lib/gc/garbageCollection.d.ts.map +1 -0
- package/lib/{garbageCollection.js → gc/garbageCollection.js} +190 -379
- package/lib/gc/garbageCollection.js.map +1 -0
- package/lib/gc/gcDefinitions.d.ts +189 -0
- package/lib/gc/gcDefinitions.d.ts.map +1 -0
- package/lib/{garbageCollectionConstants.js → gc/gcDefinitions.js} +26 -1
- package/lib/gc/gcDefinitions.js.map +1 -0
- package/lib/gc/gcHelpers.d.ts +30 -0
- package/lib/gc/gcHelpers.d.ts.map +1 -0
- package/lib/gc/gcHelpers.js +58 -0
- package/lib/gc/gcHelpers.js.map +1 -0
- package/lib/gc/gcSummaryStateTracker.d.ts +86 -0
- package/lib/gc/gcSummaryStateTracker.d.ts.map +1 -0
- package/lib/gc/gcSummaryStateTracker.js +242 -0
- package/lib/gc/gcSummaryStateTracker.js.map +1 -0
- package/{dist → lib/gc}/gcSweepReadyUsageDetection.d.ts +5 -5
- package/lib/gc/gcSweepReadyUsageDetection.d.ts.map +1 -0
- package/lib/{gcSweepReadyUsageDetection.js → gc/gcSweepReadyUsageDetection.js} +15 -11
- package/lib/gc/gcSweepReadyUsageDetection.js.map +1 -0
- package/lib/gc/gcUnreferencedStateTracker.d.ts +34 -0
- package/lib/gc/gcUnreferencedStateTracker.d.ts.map +1 -0
- package/lib/gc/gcUnreferencedStateTracker.js +90 -0
- package/lib/gc/gcUnreferencedStateTracker.js.map +1 -0
- package/lib/gc/index.d.ts +11 -0
- package/lib/gc/index.d.ts.map +1 -0
- package/lib/gc/index.js +11 -0
- package/lib/gc/index.js.map +1 -0
- package/lib/index.d.ts +2 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -4
- package/lib/index.js.map +1 -1
- package/lib/opLifecycle/batchManager.d.ts +2 -13
- package/lib/opLifecycle/batchManager.d.ts.map +1 -1
- package/lib/opLifecycle/batchManager.js +19 -41
- package/lib/opLifecycle/batchManager.js.map +1 -1
- package/lib/opLifecycle/definitions.d.ts +4 -0
- package/lib/opLifecycle/definitions.d.ts.map +1 -1
- package/lib/opLifecycle/definitions.js.map +1 -1
- package/lib/opLifecycle/index.d.ts.map +1 -1
- package/lib/opLifecycle/index.js.map +1 -1
- package/lib/opLifecycle/opCompressor.d.ts.map +1 -1
- package/lib/opLifecycle/opCompressor.js +1 -0
- package/lib/opLifecycle/opCompressor.js.map +1 -1
- package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
- package/lib/opLifecycle/opDecompressor.js +5 -2
- package/lib/opLifecycle/opDecompressor.js.map +1 -1
- package/lib/opLifecycle/opSplitter.d.ts +1 -1
- package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
- package/lib/opLifecycle/opSplitter.js +25 -14
- package/lib/opLifecycle/opSplitter.js.map +1 -1
- package/lib/opLifecycle/outbox.d.ts +19 -3
- package/lib/opLifecycle/outbox.d.ts.map +1 -1
- package/lib/opLifecycle/outbox.js +79 -46
- package/lib/opLifecycle/outbox.js.map +1 -1
- package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
- package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
- package/lib/opProperties.d.ts.map +1 -1
- package/lib/opProperties.js +1 -3
- package/lib/opProperties.js.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 +8 -2
- package/lib/pendingStateManager.d.ts.map +1 -1
- package/lib/pendingStateManager.js +21 -13
- package/lib/pendingStateManager.js.map +1 -1
- package/lib/scheduleManager.d.ts.map +1 -1
- package/lib/scheduleManager.js +3 -2
- package/lib/scheduleManager.js.map +1 -1
- package/lib/serializedSnapshotStorage.d.ts +2 -2
- package/lib/serializedSnapshotStorage.d.ts.map +1 -1
- package/lib/serializedSnapshotStorage.js +5 -3
- package/lib/serializedSnapshotStorage.js.map +1 -1
- package/lib/summary/index.d.ts +17 -0
- package/lib/summary/index.d.ts.map +1 -0
- package/lib/summary/index.js +16 -0
- package/lib/summary/index.js.map +1 -0
- package/lib/summary/orderedClientElection.d.ts.map +1 -0
- package/lib/{orderedClientElection.js → summary/orderedClientElection.js} +10 -4
- package/lib/summary/orderedClientElection.js.map +1 -0
- package/lib/summary/runWhileConnectedCoordinator.d.ts.map +1 -0
- package/lib/summary/runWhileConnectedCoordinator.js.map +1 -0
- package/{dist → lib/summary}/runningSummarizer.d.ts +19 -18
- package/lib/summary/runningSummarizer.d.ts.map +1 -0
- package/lib/{runningSummarizer.js → summary/runningSummarizer.js} +193 -78
- package/lib/summary/runningSummarizer.js.map +1 -0
- package/lib/{summarizer.d.ts → summary/summarizer.d.ts} +4 -6
- package/lib/summary/summarizer.d.ts.map +1 -0
- package/lib/{summarizer.js → summary/summarizer.js} +33 -73
- package/lib/summary/summarizer.js.map +1 -0
- package/lib/summary/summarizerClientElection.d.ts.map +1 -0
- package/lib/summary/summarizerClientElection.js.map +1 -0
- package/lib/summary/summarizerHandle.d.ts.map +1 -0
- package/lib/summary/summarizerHandle.js.map +1 -0
- package/{dist → lib/summary}/summarizerHeuristics.d.ts +1 -1
- package/lib/summary/summarizerHeuristics.d.ts.map +1 -0
- package/lib/{summarizerHeuristics.js → summary/summarizerHeuristics.js} +6 -9
- package/lib/summary/summarizerHeuristics.js.map +1 -0
- package/{dist → lib/summary}/summarizerTypes.d.ts +22 -22
- package/lib/summary/summarizerTypes.d.ts.map +1 -0
- package/lib/summary/summarizerTypes.js.map +1 -0
- package/lib/summary/summaryCollection.d.ts.map +1 -0
- package/lib/{summaryCollection.js → summary/summaryCollection.js} +18 -8
- package/lib/summary/summaryCollection.js.map +1 -0
- package/{dist → lib/summary}/summaryFormat.d.ts +1 -40
- package/lib/summary/summaryFormat.d.ts.map +1 -0
- package/lib/{summaryFormat.js → summary/summaryFormat.js} +20 -20
- package/lib/summary/summaryFormat.js.map +1 -0
- package/lib/summary/summaryGenerator.d.ts.map +1 -0
- package/lib/{summaryGenerator.js → summary/summaryGenerator.js} +33 -15
- package/lib/summary/summaryGenerator.js.map +1 -0
- package/lib/{summaryManager.d.ts → summary/summaryManager.d.ts} +1 -1
- package/lib/summary/summaryManager.d.ts.map +1 -0
- package/lib/{summaryManager.js → summary/summaryManager.js} +21 -9
- package/lib/summary/summaryManager.js.map +1 -0
- package/lib/throttler.d.ts +2 -2
- package/lib/throttler.d.ts.map +1 -1
- package/lib/throttler.js +4 -4
- package/lib/throttler.js.map +1 -1
- package/package.json +60 -51
- package/prettier.config.cjs +1 -1
- package/src/batchTracker.ts +54 -49
- package/src/blobManager.ts +825 -674
- package/src/connectionTelemetry.ts +280 -249
- package/src/containerHandleContext.ts +27 -29
- package/src/containerRuntime.ts +3249 -2978
- package/src/dataStore.ts +172 -159
- package/src/dataStoreContext.ts +1141 -1057
- package/src/dataStoreContexts.ts +178 -161
- package/src/dataStoreRegistry.ts +25 -20
- package/src/dataStores.ts +880 -731
- package/src/deltaScheduler.ts +158 -150
- package/{garbageCollection.md → src/gc/garbageCollection.md} +16 -3
- package/src/gc/garbageCollection.ts +1506 -0
- package/src/gc/gcDefinitions.ts +244 -0
- package/src/gc/gcHelpers.ts +86 -0
- package/src/gc/gcSummaryStateTracker.ts +339 -0
- package/src/gc/gcSweepReadyUsageDetection.ts +145 -0
- package/src/gc/gcUnreferencedStateTracker.ts +114 -0
- package/src/gc/index.ts +40 -0
- package/src/index.ts +67 -70
- package/src/opLifecycle/README.md +152 -0
- package/src/opLifecycle/batchManager.ts +101 -144
- package/src/opLifecycle/definitions.ts +33 -29
- package/src/opLifecycle/index.ts +5 -5
- package/src/opLifecycle/opCompressor.ts +55 -53
- package/src/opLifecycle/opDecompressor.ts +100 -81
- package/src/opLifecycle/opSplitter.ts +233 -188
- package/src/opLifecycle/outbox.ts +251 -195
- package/src/opLifecycle/remoteMessageProcessor.ts +62 -62
- package/src/opProperties.ts +11 -9
- package/src/packageVersion.ts +1 -1
- package/src/pendingStateManager.ts +396 -338
- package/src/scheduleManager.ts +299 -269
- package/src/serializedSnapshotStorage.ts +126 -112
- package/src/summary/index.ts +99 -0
- package/src/summary/orderedClientElection.ts +564 -0
- package/src/summary/runWhileConnectedCoordinator.ts +113 -0
- package/src/summary/runningSummarizer.ts +788 -0
- package/src/summary/summarizer.ts +386 -0
- package/src/summary/summarizerClientElection.ts +139 -0
- package/src/{summarizerHandle.ts → summary/summarizerHandle.ts} +11 -9
- package/src/summary/summarizerHeuristics.ts +219 -0
- package/src/summary/summarizerTypes.ts +521 -0
- package/src/summary/summaryCollection.ts +450 -0
- package/src/summary/summaryFormat.ts +226 -0
- package/src/summary/summaryGenerator.ts +505 -0
- package/src/summary/summaryManager.ts +423 -0
- package/src/throttler.ts +131 -122
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +9 -13
- package/dist/garbageCollection.d.ts.map +0 -1
- package/dist/garbageCollection.js.map +0 -1
- package/dist/garbageCollectionConstants.d.ts +0 -25
- package/dist/garbageCollectionConstants.d.ts.map +0 -1
- package/dist/garbageCollectionConstants.js.map +0 -1
- package/dist/garbageCollectionTombstoneUtils.d.ts +0 -14
- package/dist/garbageCollectionTombstoneUtils.d.ts.map +0 -1
- package/dist/garbageCollectionTombstoneUtils.js +0 -23
- package/dist/garbageCollectionTombstoneUtils.js.map +0 -1
- package/dist/gcSweepReadyUsageDetection.d.ts.map +0 -1
- package/dist/gcSweepReadyUsageDetection.js.map +0 -1
- package/dist/orderedClientElection.d.ts.map +0 -1
- package/dist/orderedClientElection.js.map +0 -1
- package/dist/runWhileConnectedCoordinator.d.ts.map +0 -1
- package/dist/runWhileConnectedCoordinator.js.map +0 -1
- package/dist/runningSummarizer.d.ts.map +0 -1
- package/dist/runningSummarizer.js.map +0 -1
- package/dist/summarizer.d.ts.map +0 -1
- 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.map +0 -1
- package/dist/summarizerHandle.js.map +0 -1
- package/dist/summarizerHeuristics.d.ts.map +0 -1
- 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/lib/garbageCollection.d.ts.map +0 -1
- package/lib/garbageCollection.js.map +0 -1
- package/lib/garbageCollectionConstants.d.ts +0 -25
- package/lib/garbageCollectionConstants.d.ts.map +0 -1
- package/lib/garbageCollectionConstants.js.map +0 -1
- package/lib/garbageCollectionTombstoneUtils.d.ts +0 -14
- package/lib/garbageCollectionTombstoneUtils.d.ts.map +0 -1
- package/lib/garbageCollectionTombstoneUtils.js +0 -19
- package/lib/garbageCollectionTombstoneUtils.js.map +0 -1
- package/lib/gcSweepReadyUsageDetection.d.ts.map +0 -1
- package/lib/gcSweepReadyUsageDetection.js.map +0 -1
- package/lib/orderedClientElection.d.ts.map +0 -1
- package/lib/orderedClientElection.js.map +0 -1
- package/lib/runWhileConnectedCoordinator.d.ts.map +0 -1
- package/lib/runWhileConnectedCoordinator.js.map +0 -1
- package/lib/runningSummarizer.d.ts.map +0 -1
- package/lib/runningSummarizer.js.map +0 -1
- package/lib/summarizer.d.ts.map +0 -1
- 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.map +0 -1
- package/lib/summarizerHandle.js.map +0 -1
- package/lib/summarizerHeuristics.d.ts.map +0 -1
- package/lib/summarizerHeuristics.js.map +0 -1
- package/lib/summarizerTypes.d.ts.map +0 -1
- 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.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/src/garbageCollection.ts +0 -1800
- package/src/garbageCollectionConstants.ts +0 -41
- package/src/garbageCollectionTombstoneUtils.ts +0 -28
- package/src/gcSweepReadyUsageDetection.ts +0 -139
- package/src/orderedClientElection.ts +0 -532
- package/src/runWhileConnectedCoordinator.ts +0 -106
- package/src/runningSummarizer.ts +0 -610
- package/src/summarizer.ts +0 -421
- package/src/summarizerClientElection.ts +0 -132
- package/src/summarizerHeuristics.ts +0 -222
- package/src/summarizerTypes.ts +0 -507
- package/src/summaryCollection.ts +0 -421
- package/src/summaryFormat.ts +0 -256
- package/src/summaryGenerator.ts +0 -450
- package/src/summaryManager.ts +0 -394
- /package/dist/{orderedClientElection.d.ts → summary/orderedClientElection.d.ts} +0 -0
- /package/dist/{runWhileConnectedCoordinator.d.ts → summary/runWhileConnectedCoordinator.d.ts} +0 -0
- /package/dist/{runWhileConnectedCoordinator.js → summary/runWhileConnectedCoordinator.js} +0 -0
- /package/dist/{summarizerClientElection.d.ts → summary/summarizerClientElection.d.ts} +0 -0
- /package/dist/{summarizerClientElection.js → summary/summarizerClientElection.js} +0 -0
- /package/dist/{summarizerHandle.d.ts → summary/summarizerHandle.d.ts} +0 -0
- /package/dist/{summarizerHandle.js → summary/summarizerHandle.js} +0 -0
- /package/dist/{summarizerTypes.js → summary/summarizerTypes.js} +0 -0
- /package/dist/{summaryCollection.d.ts → summary/summaryCollection.d.ts} +0 -0
- /package/dist/{summaryGenerator.d.ts → summary/summaryGenerator.d.ts} +0 -0
- /package/lib/{orderedClientElection.d.ts → summary/orderedClientElection.d.ts} +0 -0
- /package/lib/{runWhileConnectedCoordinator.d.ts → summary/runWhileConnectedCoordinator.d.ts} +0 -0
- /package/lib/{runWhileConnectedCoordinator.js → summary/runWhileConnectedCoordinator.js} +0 -0
- /package/lib/{summarizerClientElection.d.ts → summary/summarizerClientElection.d.ts} +0 -0
- /package/lib/{summarizerClientElection.js → summary/summarizerClientElection.js} +0 -0
- /package/lib/{summarizerHandle.d.ts → summary/summarizerHandle.d.ts} +0 -0
- /package/lib/{summarizerHandle.js → summary/summarizerHandle.js} +0 -0
- /package/lib/{summarizerTypes.js → summary/summarizerTypes.js} +0 -0
- /package/lib/{summaryCollection.d.ts → summary/summaryCollection.d.ts} +0 -0
- /package/lib/{summaryGenerator.d.ts → summary/summaryGenerator.d.ts} +0 -0
package/src/blobManager.ts
CHANGED
|
@@ -6,26 +6,44 @@
|
|
|
6
6
|
import { v4 as uuid } from "uuid";
|
|
7
7
|
import { IFluidHandle, IFluidHandleContext } from "@fluidframework/core-interfaces";
|
|
8
8
|
import { IDocumentStorageService } from "@fluidframework/driver-definitions";
|
|
9
|
-
import { ICreateBlobResponse, ISequencedDocumentMessage, ISnapshotTree } from "@fluidframework/protocol-definitions";
|
|
10
9
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
ICreateBlobResponse,
|
|
11
|
+
ISequencedDocumentMessage,
|
|
12
|
+
ISnapshotTree,
|
|
13
|
+
} from "@fluidframework/protocol-definitions";
|
|
14
|
+
import {
|
|
15
|
+
createResponseError,
|
|
16
|
+
generateHandleContextPath,
|
|
17
|
+
responseToException,
|
|
18
|
+
SummaryTreeBuilder,
|
|
15
19
|
} from "@fluidframework/runtime-utils";
|
|
16
|
-
import {
|
|
17
|
-
|
|
20
|
+
import {
|
|
21
|
+
assert,
|
|
22
|
+
bufferToString,
|
|
23
|
+
Deferred,
|
|
24
|
+
stringToBuffer,
|
|
25
|
+
TypedEventEmitter,
|
|
26
|
+
} from "@fluidframework/common-utils";
|
|
27
|
+
import {
|
|
28
|
+
IContainerRuntime,
|
|
29
|
+
IContainerRuntimeEvents,
|
|
30
|
+
} from "@fluidframework/container-runtime-definitions";
|
|
18
31
|
import { AttachState } from "@fluidframework/container-definitions";
|
|
19
|
-
import { ChildLogger, loggerToMonitoringContext, MonitoringContext, PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
20
32
|
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
33
|
+
ChildLogger,
|
|
34
|
+
loggerToMonitoringContext,
|
|
35
|
+
MonitoringContext,
|
|
36
|
+
PerformanceEvent,
|
|
37
|
+
} from "@fluidframework/telemetry-utils";
|
|
38
|
+
import {
|
|
39
|
+
IGarbageCollectionData,
|
|
40
|
+
ISummaryTreeWithStats,
|
|
41
|
+
ITelemetryContext,
|
|
24
42
|
} from "@fluidframework/runtime-definitions";
|
|
43
|
+
import { ContainerRuntime, TombstoneResponseHeaderKey } from "./containerRuntime";
|
|
44
|
+
import { sendGCUnexpectedUsageEvent, sweepAttachmentBlobsKey, throwOnTombstoneLoadKey } from "./gc";
|
|
25
45
|
import { Throttler, formExponentialFn, IThrottler } from "./throttler";
|
|
26
|
-
import { summarizerClientType } from "./
|
|
27
|
-
import { throwOnTombstoneLoadKey } from "./garbageCollectionConstants";
|
|
28
|
-
import { sendGCTombstoneEvent } from "./garbageCollectionTombstoneUtils";
|
|
46
|
+
import { summarizerClientType } from "./summary";
|
|
29
47
|
|
|
30
48
|
/**
|
|
31
49
|
* This class represents blob (long string)
|
|
@@ -35,699 +53,832 @@ import { sendGCTombstoneEvent } from "./garbageCollectionTombstoneUtils";
|
|
|
35
53
|
* and loads blob.
|
|
36
54
|
*/
|
|
37
55
|
export class BlobHandle implements IFluidHandle<ArrayBufferLike> {
|
|
38
|
-
|
|
56
|
+
private attached: boolean = false;
|
|
39
57
|
|
|
40
|
-
|
|
58
|
+
public get IFluidHandle(): IFluidHandle {
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
41
61
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
62
|
+
public get isAttached(): boolean {
|
|
63
|
+
return this.attached;
|
|
64
|
+
}
|
|
45
65
|
|
|
46
|
-
|
|
66
|
+
public readonly absolutePath: string;
|
|
47
67
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
68
|
+
constructor(
|
|
69
|
+
public readonly path: string,
|
|
70
|
+
public readonly routeContext: IFluidHandleContext,
|
|
71
|
+
public get: () => Promise<any>,
|
|
72
|
+
) {
|
|
73
|
+
this.absolutePath = generateHandleContextPath(path, this.routeContext);
|
|
74
|
+
}
|
|
55
75
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
76
|
+
public attachGraph() {
|
|
77
|
+
this.attached = true;
|
|
78
|
+
}
|
|
59
79
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
80
|
+
public bind(handle: IFluidHandle) {
|
|
81
|
+
throw new Error("Cannot bind to blob handle");
|
|
82
|
+
}
|
|
63
83
|
}
|
|
64
84
|
|
|
65
85
|
class CancellableThrottler {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
86
|
+
constructor(private readonly throttler: IThrottler) {}
|
|
87
|
+
private cancelP = new Deferred<void>();
|
|
88
|
+
|
|
89
|
+
public async getDelay(): Promise<void> {
|
|
90
|
+
return Promise.race([
|
|
91
|
+
this.cancelP.promise,
|
|
92
|
+
new Promise<void>((resolve) => setTimeout(resolve, this.throttler.getDelay())),
|
|
93
|
+
]);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public cancel() {
|
|
97
|
+
this.cancelP.resolve();
|
|
98
|
+
this.cancelP = new Deferred<void>();
|
|
99
|
+
}
|
|
80
100
|
}
|
|
81
101
|
|
|
82
102
|
/**
|
|
83
103
|
* Information from a snapshot needed to load BlobManager
|
|
84
104
|
*/
|
|
85
105
|
export interface IBlobManagerLoadInfo {
|
|
86
|
-
|
|
87
|
-
|
|
106
|
+
ids?: string[];
|
|
107
|
+
redirectTable?: [string, string][];
|
|
88
108
|
}
|
|
89
109
|
|
|
90
110
|
// Restrict the IContainerRuntime interface to the subset required by BlobManager. This helps to make
|
|
91
111
|
// the contract explicit and reduces the amount of mocking required for tests.
|
|
92
|
-
export type IBlobManagerRuntime =
|
|
93
|
-
|
|
112
|
+
export type IBlobManagerRuntime = Pick<
|
|
113
|
+
IContainerRuntime,
|
|
114
|
+
"attachState" | "connected" | "logger" | "clientDetails"
|
|
115
|
+
> &
|
|
116
|
+
Pick<ContainerRuntime, "gcTombstoneEnforcementAllowed"> &
|
|
117
|
+
TypedEventEmitter<IContainerRuntimeEvents>;
|
|
94
118
|
|
|
95
119
|
// Note that while offline we "submit" an op before uploading the blob, but we always
|
|
96
120
|
// expect blobs to be uploaded before we actually see the op round-trip
|
|
97
121
|
enum PendingBlobStatus {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
122
|
+
OnlinePendingUpload,
|
|
123
|
+
OnlinePendingOp,
|
|
124
|
+
OfflinePendingUpload,
|
|
125
|
+
OfflinePendingOp,
|
|
102
126
|
}
|
|
103
127
|
|
|
104
128
|
type ICreateBlobResponseWithTTL = ICreateBlobResponse & Partial<Record<"minTTLInSeconds", number>>;
|
|
105
129
|
|
|
106
130
|
interface PendingBlob {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
131
|
+
blob: ArrayBufferLike;
|
|
132
|
+
status: PendingBlobStatus;
|
|
133
|
+
storageId?: string;
|
|
134
|
+
handleP: Deferred<IFluidHandle<ArrayBufferLike>>;
|
|
135
|
+
uploadP: Promise<ICreateBlobResponse>;
|
|
136
|
+
localUploadTime?: number;
|
|
137
|
+
serverUploadTime?: number;
|
|
138
|
+
minTTLInSeconds?: number;
|
|
115
139
|
}
|
|
116
140
|
|
|
117
|
-
export interface IPendingBlobs {
|
|
141
|
+
export interface IPendingBlobs {
|
|
142
|
+
[id: string]: { blob: string };
|
|
143
|
+
}
|
|
118
144
|
|
|
119
145
|
export interface IBlobManagerEvents {
|
|
120
|
-
|
|
146
|
+
(event: "noPendingBlobs", listener: () => void);
|
|
121
147
|
}
|
|
122
148
|
|
|
123
149
|
export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
150
|
+
public static readonly basePath = "_blobs";
|
|
151
|
+
private static readonly redirectTableBlobName = ".redirectTable";
|
|
152
|
+
private readonly mc: MonitoringContext;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Map of local IDs to storage IDs. Contains identity entries (id → id) for storage IDs. All requested IDs should
|
|
156
|
+
* be a key in this map. Blobs created while the container is detached are stored in IDetachedBlobStorage which
|
|
157
|
+
* gives local IDs; the storage IDs are filled in at attach time.
|
|
158
|
+
* Note: It contains mappings from all clients, i.e., from remote clients as well. local ID comes from the client
|
|
159
|
+
* that uploaded the blob but its mapping to storage ID is needed in all clients in order to retrieve the blob.
|
|
160
|
+
*/
|
|
161
|
+
private readonly redirectTable: Map<string, string | undefined>;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Blobs which have not been uploaded or for which we have not yet seen a BlobAttach op round-trip.
|
|
165
|
+
* Until we see the op round-trip, there is a possibility we may need to re-upload the blob, so
|
|
166
|
+
* we must save it. This is true for both the online and offline flow.
|
|
167
|
+
*/
|
|
168
|
+
private readonly pendingBlobs: Map<string, PendingBlob> = new Map();
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Track ops in flight for online flow. This is used for optimizations where if we receive an ack for a storage ID,
|
|
172
|
+
* we can resolve all pending blobs with the same storage ID even though they may have different local IDs. That's
|
|
173
|
+
* because we know that the server will not delete the blob corresponding to that storage ID.
|
|
174
|
+
*/
|
|
175
|
+
private readonly opsInFlight: Map<string, string[]> = new Map();
|
|
176
|
+
|
|
177
|
+
private readonly retryThrottler = new CancellableThrottler(
|
|
178
|
+
new Throttler(
|
|
179
|
+
60 * 1000, // 60 sec delay window
|
|
180
|
+
30 * 1000, // 30 sec max delay
|
|
181
|
+
// throttling function increases exponentially (0ms, 40ms, 80ms, 160ms, etc)
|
|
182
|
+
formExponentialFn({ coefficient: 20, initialDelay: 0 }),
|
|
183
|
+
),
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
/** If true, throw an error when a tombstone attachment blob is retrieved. */
|
|
187
|
+
private readonly throwOnTombstoneLoad: boolean;
|
|
188
|
+
/**
|
|
189
|
+
* This stores IDs of tombstoned blobs.
|
|
190
|
+
* Tombstone is a temporary feature that imitates a blob getting swept by garbage collection.
|
|
191
|
+
*/
|
|
192
|
+
private readonly tombstonedBlobs: Set<string> = new Set();
|
|
193
|
+
|
|
194
|
+
constructor(
|
|
195
|
+
private readonly routeContext: IFluidHandleContext,
|
|
196
|
+
snapshot: IBlobManagerLoadInfo,
|
|
197
|
+
private readonly getStorage: () => IDocumentStorageService,
|
|
198
|
+
/**
|
|
199
|
+
* Submit a BlobAttach op. When a blob is uploaded, there is a short grace period before which the blob is
|
|
200
|
+
* deleted. The BlobAttach op notifies the server that blob is in use. The server will then not delete the
|
|
201
|
+
* the blob as long as it is listed as referenced in future summaries. The summarizing client will know to
|
|
202
|
+
* include the storage ID in the summary when it sees the op.
|
|
203
|
+
*
|
|
204
|
+
* The op will also include a local ID to inform all clients of the relation to the storage ID, without
|
|
205
|
+
* knowledge of which they cannot request the blob from storage. It's important that this op is sequenced
|
|
206
|
+
* before any ops that reference the local ID, otherwise, an invalid handle could be added to the document.
|
|
207
|
+
*/
|
|
208
|
+
private readonly sendBlobAttachOp: (localId: string, storageId?: string) => void,
|
|
209
|
+
// Called when a blob node is requested. blobPath is the path of the blob's node in GC's graph.
|
|
210
|
+
// blobPath's format - `/<BlobManager.basePath>/<blobId>`.
|
|
211
|
+
private readonly blobRequested: (blobPath: string) => void,
|
|
212
|
+
// Called when a reference is added to a blob. For instance, when creating a localId / storageId to storageId
|
|
213
|
+
// mapping in the redirect table.
|
|
214
|
+
// Node path formats - `/<BlobManager.basePath>/<blobId>`.
|
|
215
|
+
private readonly addedBlobReference: (fromNodePath: string, toNodePath: string) => void,
|
|
216
|
+
// Called to check if a blob has been deleted by GC.
|
|
217
|
+
// blobPath's format - `/<BlobManager.basePath>/<blobId>`.
|
|
218
|
+
private readonly isBlobDeleted: (blobPath: string) => boolean,
|
|
219
|
+
private readonly runtime: IBlobManagerRuntime,
|
|
220
|
+
stashedBlobs: IPendingBlobs = {},
|
|
221
|
+
private readonly getCurrentReferenceTimestampMs: () => number | undefined,
|
|
222
|
+
) {
|
|
223
|
+
super();
|
|
224
|
+
this.mc = loggerToMonitoringContext(ChildLogger.create(this.runtime.logger, "BlobManager"));
|
|
225
|
+
// Read the feature flag that tells whether to throw when a tombstone blob is requested.
|
|
226
|
+
this.throwOnTombstoneLoad =
|
|
227
|
+
this.mc.config.getBoolean(throwOnTombstoneLoadKey) === true &&
|
|
228
|
+
this.runtime.gcTombstoneEnforcementAllowed &&
|
|
229
|
+
this.runtime.clientDetails.type !== summarizerClientType;
|
|
230
|
+
|
|
231
|
+
this.runtime.on("disconnected", () => this.onDisconnected());
|
|
232
|
+
this.redirectTable = this.load(snapshot);
|
|
233
|
+
|
|
234
|
+
// Begin uploading stashed blobs from previous container instance
|
|
235
|
+
Object.entries(stashedBlobs).forEach(([localId, entry]) => {
|
|
236
|
+
const blob = stringToBuffer(entry.blob, "base64");
|
|
237
|
+
this.pendingBlobs.set(localId, {
|
|
238
|
+
blob,
|
|
239
|
+
status: PendingBlobStatus.OfflinePendingUpload,
|
|
240
|
+
handleP: new Deferred(),
|
|
241
|
+
uploadP: this.uploadBlob(localId, blob),
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
private get pendingOfflineUploads() {
|
|
247
|
+
return Array.from(this.pendingBlobs.values()).filter(
|
|
248
|
+
(e) => e.status === PendingBlobStatus.OfflinePendingUpload,
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
public get hasPendingOfflineUploads(): boolean {
|
|
253
|
+
return this.pendingOfflineUploads.length > 0;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
public get hasPendingBlobs(): boolean {
|
|
257
|
+
return (
|
|
258
|
+
(this.runtime.attachState !== AttachState.Attached && this.redirectTable.size > 0) ||
|
|
259
|
+
this.pendingBlobs.size > 0
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Upload blobs added while offline. This must be completed before connecting and resubmitting ops.
|
|
265
|
+
*/
|
|
266
|
+
public async onConnected() {
|
|
267
|
+
this.retryThrottler.cancel();
|
|
268
|
+
const pendingUploads = this.pendingOfflineUploads.map(async (e) => e.uploadP);
|
|
269
|
+
await PerformanceEvent.timedExecAsync(
|
|
270
|
+
this.mc.logger,
|
|
271
|
+
{
|
|
272
|
+
eventName: "BlobUploadOnConnected",
|
|
273
|
+
count: pendingUploads.length,
|
|
274
|
+
},
|
|
275
|
+
async () => Promise.all(pendingUploads),
|
|
276
|
+
{ start: true, end: true },
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Transition online blobs waiting for BlobAttach op round-trip since we will not see the op until we are connected
|
|
282
|
+
* again
|
|
283
|
+
*/
|
|
284
|
+
private onDisconnected() {
|
|
285
|
+
for (const [localId, entry] of this.pendingBlobs) {
|
|
286
|
+
if (entry.status === PendingBlobStatus.OnlinePendingOp) {
|
|
287
|
+
// This will submit another BlobAttach op for this blob. This is necessary because the one we sent
|
|
288
|
+
// already didn't have the local ID.
|
|
289
|
+
this.transitionToOffline(localId);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* For a blobId, returns its path in GC's graph. The node path is of the format `/<BlobManager.basePath>/<blobId>`
|
|
296
|
+
* This path must match the path of the blob handle returned by the createBlob API because blobs are marked
|
|
297
|
+
* referenced by storing these handles in a referenced DDS.
|
|
298
|
+
*/
|
|
299
|
+
private getBlobGCNodePath(blobId: string) {
|
|
300
|
+
return `/${BlobManager.basePath}/${blobId}`;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Set of actual storage IDs (i.e., IDs that can be requested from storage). This will be empty if the container is
|
|
305
|
+
* detached or there are no (non-pending) attachment blobs in the document
|
|
306
|
+
*/
|
|
307
|
+
private get storageIds(): Set<string> {
|
|
308
|
+
const ids = new Set<string | undefined>(this.redirectTable.values());
|
|
309
|
+
|
|
310
|
+
// If we are detached, we will not have storage IDs, only undefined
|
|
311
|
+
const undefinedValueInTable = ids.delete(undefined);
|
|
312
|
+
|
|
313
|
+
// For a detached container, entries are inserted into the redirect table with an undefined storage ID.
|
|
314
|
+
// For an attached container, entries are inserted w/storage ID after the BlobAttach op round-trips.
|
|
315
|
+
assert(
|
|
316
|
+
!undefinedValueInTable ||
|
|
317
|
+
(this.runtime.attachState === AttachState.Detached && ids.size === 0),
|
|
318
|
+
0x382 /* 'redirectTable' must contain only undefined while detached / defined values while attached */,
|
|
319
|
+
);
|
|
320
|
+
|
|
321
|
+
return ids as Set<string>;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
public async getBlob(blobId: string): Promise<ArrayBufferLike> {
|
|
325
|
+
// Verify that the blob is valid, i.e., it has not been garbage collected. If it is, this will throw an error,
|
|
326
|
+
// failing the call.
|
|
327
|
+
this.verifyBlobValidity(blobId);
|
|
328
|
+
|
|
329
|
+
const pending = this.pendingBlobs.get(blobId);
|
|
330
|
+
if (pending) {
|
|
331
|
+
return pending.blob;
|
|
332
|
+
}
|
|
333
|
+
let storageId: string;
|
|
334
|
+
if (this.runtime.attachState === AttachState.Detached) {
|
|
335
|
+
assert(this.redirectTable.has(blobId), 0x383 /* requesting unknown blobs */);
|
|
336
|
+
|
|
337
|
+
// Blobs created while the container is detached are stored in IDetachedBlobStorage.
|
|
338
|
+
// The 'IDocumentStorageService.readBlob()' call below will retrieve these via localId.
|
|
339
|
+
storageId = blobId;
|
|
340
|
+
} else {
|
|
341
|
+
const attachedStorageId = this.redirectTable.get(blobId);
|
|
342
|
+
assert(!!attachedStorageId, 0x11f /* "requesting unknown blobs" */);
|
|
343
|
+
storageId = attachedStorageId;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// Let runtime know that the corresponding GC node was requested.
|
|
347
|
+
this.blobRequested(this.getBlobGCNodePath(blobId));
|
|
348
|
+
|
|
349
|
+
return PerformanceEvent.timedExecAsync(
|
|
350
|
+
this.mc.logger,
|
|
351
|
+
{ eventName: "AttachmentReadBlob", id: storageId },
|
|
352
|
+
async () => {
|
|
353
|
+
return this.getStorage().readBlob(storageId);
|
|
354
|
+
},
|
|
355
|
+
{ end: true, cancel: "error" },
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
private getBlobHandle(id: string): IFluidHandle<ArrayBufferLike> {
|
|
360
|
+
assert(
|
|
361
|
+
this.redirectTable.has(id) || this.pendingBlobs.has(id),
|
|
362
|
+
0x384 /* requesting handle for unknown blob */,
|
|
363
|
+
);
|
|
364
|
+
return new BlobHandle(`${BlobManager.basePath}/${id}`, this.routeContext, async () =>
|
|
365
|
+
this.getBlob(id),
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
private async createBlobDetached(
|
|
370
|
+
blob: ArrayBufferLike,
|
|
371
|
+
): Promise<IFluidHandle<ArrayBufferLike>> {
|
|
372
|
+
// Blobs created while the container is detached are stored in IDetachedBlobStorage.
|
|
373
|
+
// The 'IDocumentStorageService.createBlob()' call below will respond with a localId.
|
|
374
|
+
const response = await this.getStorage().createBlob(blob);
|
|
375
|
+
this.setRedirection(response.id, undefined);
|
|
376
|
+
return this.getBlobHandle(response.id);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
public async createBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>> {
|
|
380
|
+
if (this.runtime.attachState === AttachState.Detached) {
|
|
381
|
+
return this.createBlobDetached(blob);
|
|
382
|
+
}
|
|
383
|
+
if (this.runtime.attachState === AttachState.Attaching) {
|
|
384
|
+
// blob upload is not supported in "Attaching" state
|
|
385
|
+
this.mc.logger.sendTelemetryEvent({ eventName: "CreateBlobWhileAttaching" });
|
|
386
|
+
await new Promise<void>((resolve) => this.runtime.once("attached", resolve));
|
|
387
|
+
}
|
|
388
|
+
assert(
|
|
389
|
+
this.runtime.attachState === AttachState.Attached,
|
|
390
|
+
0x385 /* For clarity and paranoid defense against adding future attachment states */,
|
|
391
|
+
);
|
|
392
|
+
|
|
393
|
+
// Create a local ID for the blob. After uploading it to storage and before returning it, a local ID to
|
|
394
|
+
// storage ID mapping is created.
|
|
395
|
+
const localId = uuid();
|
|
396
|
+
const pendingEntry: PendingBlob = {
|
|
397
|
+
blob,
|
|
398
|
+
status: PendingBlobStatus.OnlinePendingUpload,
|
|
399
|
+
handleP: new Deferred(),
|
|
400
|
+
uploadP: this.uploadBlob(localId, blob),
|
|
401
|
+
};
|
|
402
|
+
this.pendingBlobs.set(localId, pendingEntry);
|
|
403
|
+
|
|
404
|
+
return pendingEntry.handleP.promise;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
private async uploadBlob(localId: string, blob: ArrayBufferLike): Promise<ICreateBlobResponse> {
|
|
408
|
+
return PerformanceEvent.timedExecAsync(
|
|
409
|
+
this.mc.logger,
|
|
410
|
+
{ eventName: "createBlob" },
|
|
411
|
+
async () => this.getStorage().createBlob(blob),
|
|
412
|
+
{ end: true, cancel: this.runtime.connected ? "error" : "generic" },
|
|
413
|
+
).then(
|
|
414
|
+
(response) => this.onUploadResolve(localId, response),
|
|
415
|
+
async (err) => this.onUploadReject(localId, err),
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Set up a mapping in the redirect table from fromId to toId. Also, notify the runtime that a reference is added
|
|
421
|
+
* which is required for GC.
|
|
422
|
+
*/
|
|
423
|
+
private setRedirection(fromId: string, toId: string | undefined) {
|
|
424
|
+
this.redirectTable.set(fromId, toId);
|
|
425
|
+
// Notify runtime of a reference added if toId is not undefined. It can be undefined when a blob is uploaded in
|
|
426
|
+
// detached mode. In this case, the entry will be updated when the blob is updated.
|
|
427
|
+
if (toId !== undefined) {
|
|
428
|
+
this.addedBlobReference(this.getBlobGCNodePath(fromId), this.getBlobGCNodePath(toId));
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
private deleteAndEmitsIfEmpty(id: string) {
|
|
433
|
+
if (this.pendingBlobs.has(id)) {
|
|
434
|
+
this.pendingBlobs.delete(id);
|
|
435
|
+
if (!this.hasPendingBlobs) {
|
|
436
|
+
this.emit("noPendingBlobs");
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
private onUploadResolve(localId: string, response: ICreateBlobResponseWithTTL) {
|
|
442
|
+
const entry = this.pendingBlobs.get(localId);
|
|
443
|
+
assert(
|
|
444
|
+
entry?.status === PendingBlobStatus.OnlinePendingUpload ||
|
|
445
|
+
entry?.status === PendingBlobStatus.OfflinePendingUpload,
|
|
446
|
+
0x386 /* Must have pending blob entry for uploaded blob */,
|
|
447
|
+
);
|
|
448
|
+
entry.storageId = response.id;
|
|
449
|
+
entry.localUploadTime = Date.now();
|
|
450
|
+
entry.minTTLInSeconds = response.minTTLInSeconds;
|
|
451
|
+
entry.serverUploadTime = this.getCurrentReferenceTimestampMs();
|
|
452
|
+
if (this.runtime.connected) {
|
|
453
|
+
if (entry.status === PendingBlobStatus.OnlinePendingUpload) {
|
|
454
|
+
// Send a blob attach op. This serves two purposes:
|
|
455
|
+
// 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
|
|
456
|
+
// until its storage ID is added to the next summary.
|
|
457
|
+
// 2. It will create a local ID to storage ID mapping in all clients which is needed to retrieve the
|
|
458
|
+
// blob from the server via the storage ID.
|
|
459
|
+
this.logTimeInfo(entry, "sendBlobAttachResolveTTL");
|
|
460
|
+
this.sendBlobAttachOp(localId, response.id);
|
|
461
|
+
if (this.storageIds.has(response.id)) {
|
|
462
|
+
// The blob is de-duped. Set up a local ID to storage ID mapping and return the blob. Since this is
|
|
463
|
+
// an existing blob, we don't have to wait for the op to be ack'd since this step has already
|
|
464
|
+
// happened before and so, the server won't delete it.
|
|
465
|
+
this.setRedirection(localId, response.id);
|
|
466
|
+
entry.handleP.resolve(this.getBlobHandle(localId));
|
|
467
|
+
this.deleteAndEmitsIfEmpty(localId);
|
|
468
|
+
} else {
|
|
469
|
+
// If there is already an op for this storage ID, append the local ID to the list. Once any op for
|
|
470
|
+
// this storage ID is ack'd, all pending blobs for it can be resolved since the op will keep the
|
|
471
|
+
// blob alive in storage.
|
|
472
|
+
this.opsInFlight.set(
|
|
473
|
+
response.id,
|
|
474
|
+
(this.opsInFlight.get(response.id) ?? []).concat(localId),
|
|
475
|
+
);
|
|
476
|
+
entry.status = PendingBlobStatus.OnlinePendingOp;
|
|
477
|
+
}
|
|
478
|
+
} else if (entry.status === PendingBlobStatus.OfflinePendingUpload) {
|
|
479
|
+
// We already submitted a BlobAttach op for this blob when it was transitioned to offline flow
|
|
480
|
+
entry.status = PendingBlobStatus.OfflinePendingOp;
|
|
481
|
+
}
|
|
482
|
+
} else {
|
|
483
|
+
// connected to storage but not ordering service?
|
|
484
|
+
this.mc.logger.sendTelemetryEvent({ eventName: "BlobUploadSuccessWhileDisconnected" });
|
|
485
|
+
if (entry.status === PendingBlobStatus.OnlinePendingUpload) {
|
|
486
|
+
this.transitionToOffline(localId);
|
|
487
|
+
}
|
|
488
|
+
entry.status = PendingBlobStatus.OfflinePendingOp;
|
|
489
|
+
}
|
|
490
|
+
return response;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
private async onUploadReject(localId: string, error) {
|
|
494
|
+
const entry = this.pendingBlobs.get(localId);
|
|
495
|
+
assert(!!entry, 0x387 /* Must have pending blob entry for blob which failed to upload */);
|
|
496
|
+
if (!this.runtime.connected) {
|
|
497
|
+
if (entry.status === PendingBlobStatus.OnlinePendingUpload) {
|
|
498
|
+
this.transitionToOffline(localId);
|
|
499
|
+
}
|
|
500
|
+
// we are probably not connected to storage but start another upload request in case we are
|
|
501
|
+
entry.uploadP = this.retryThrottler
|
|
502
|
+
.getDelay()
|
|
503
|
+
.then(async () => this.uploadBlob(localId, entry.blob));
|
|
504
|
+
return entry.uploadP;
|
|
505
|
+
} else {
|
|
506
|
+
entry.handleP.reject(error);
|
|
507
|
+
throw error;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
private transitionToOffline(localId: string) {
|
|
512
|
+
assert(
|
|
513
|
+
!this.runtime.connected,
|
|
514
|
+
0x388 /* Must only transition to offline flow while runtime is disconnected */,
|
|
515
|
+
);
|
|
516
|
+
const entry = this.pendingBlobs.get(localId);
|
|
517
|
+
assert(!!entry, 0x389 /* No pending blob entry */);
|
|
518
|
+
assert(
|
|
519
|
+
[PendingBlobStatus.OnlinePendingUpload, PendingBlobStatus.OnlinePendingOp].includes(
|
|
520
|
+
entry.status,
|
|
521
|
+
),
|
|
522
|
+
0x38a /* Blob must be in online flow to transition to offline flow */,
|
|
523
|
+
);
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* If we haven't already submitted a BlobAttach op for this entry, send it before returning the blob handle.
|
|
527
|
+
* This will make sure that the BlobAttach op is sequenced prior to any ops referencing the handle. Otherwise,
|
|
528
|
+
* an invalid handle could be added to the document.
|
|
529
|
+
* storageId may be undefined but since we are not connected we will have a chance to add it when reSubmit()
|
|
530
|
+
* is called on reconnection.
|
|
531
|
+
*/
|
|
532
|
+
if (entry.status !== PendingBlobStatus.OnlinePendingOp) {
|
|
533
|
+
this.logTimeInfo(entry, "sendBlobAttachTransitionOfflineTTL");
|
|
534
|
+
this.sendBlobAttachOp(localId, entry.storageId);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
entry.status =
|
|
538
|
+
entry.status === PendingBlobStatus.OnlinePendingUpload
|
|
539
|
+
? PendingBlobStatus.OfflinePendingUpload
|
|
540
|
+
: PendingBlobStatus.OfflinePendingOp;
|
|
541
|
+
|
|
542
|
+
entry.handleP.resolve(this.getBlobHandle(localId));
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Resubmit a BlobAttach op. Used to add storage IDs to ops that were
|
|
547
|
+
* submitted to runtime while disconnected.
|
|
548
|
+
* @param metadata - op metadata containing storage and/or local IDs
|
|
549
|
+
*/
|
|
550
|
+
public reSubmit(metadata: Record<string, unknown> | undefined) {
|
|
551
|
+
assert(!!metadata, 0x38b /* Resubmitted ops must have metadata */);
|
|
552
|
+
const { localId, blobId }: { localId?: string; blobId?: string } = metadata;
|
|
553
|
+
assert(localId !== undefined, 0x50d /* local ID not available on reSubmit */);
|
|
554
|
+
const pendingEntry = this.pendingBlobs.get(localId);
|
|
555
|
+
if (pendingEntry) {
|
|
556
|
+
this.logTimeInfo(pendingEntry, "sendBlobAttachResubmitTTL");
|
|
557
|
+
}
|
|
558
|
+
if (!blobId) {
|
|
559
|
+
// We submitted this op while offline. The blob should have been uploaded by now.
|
|
560
|
+
assert(
|
|
561
|
+
pendingEntry?.status === PendingBlobStatus.OfflinePendingOp &&
|
|
562
|
+
!!pendingEntry?.storageId,
|
|
563
|
+
0x38d /* blob must be uploaded before resubmitting BlobAttach op */,
|
|
564
|
+
);
|
|
565
|
+
return this.sendBlobAttachOp(localId, pendingEntry.storageId);
|
|
566
|
+
}
|
|
567
|
+
return this.sendBlobAttachOp(localId, blobId);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
private logTimeInfo(pendingEntry: PendingBlob, eventName: string) {
|
|
571
|
+
let timeLapseSinceLocalUpload: number = 0;
|
|
572
|
+
let timeLapseSinceServerUpload: number = 0;
|
|
573
|
+
let expiredUsingLocalTime;
|
|
574
|
+
let expiredUsingServerTime;
|
|
575
|
+
if (pendingEntry.localUploadTime) {
|
|
576
|
+
timeLapseSinceLocalUpload = (Date.now() - pendingEntry.localUploadTime) / 1000;
|
|
577
|
+
expiredUsingLocalTime =
|
|
578
|
+
(pendingEntry.minTTLInSeconds ?? 0) - timeLapseSinceLocalUpload < 0 ? true : false;
|
|
579
|
+
}
|
|
580
|
+
if (pendingEntry.serverUploadTime) {
|
|
581
|
+
timeLapseSinceServerUpload = (Date.now() - pendingEntry.serverUploadTime) / 1000;
|
|
582
|
+
expiredUsingServerTime =
|
|
583
|
+
(pendingEntry.minTTLInSeconds ?? 0) - timeLapseSinceServerUpload < 0 ? true : false;
|
|
584
|
+
}
|
|
585
|
+
this.mc.logger.sendTelemetryEvent({
|
|
586
|
+
eventName,
|
|
587
|
+
entryStatus: pendingEntry.status,
|
|
588
|
+
timeLapseSinceLocalUpload,
|
|
589
|
+
timeLapseSinceServerUpload,
|
|
590
|
+
minTTLInSeconds: pendingEntry.minTTLInSeconds,
|
|
591
|
+
expiredUsingLocalTime,
|
|
592
|
+
expiredUsingServerTime,
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
public processBlobAttachOp(message: ISequencedDocumentMessage, local: boolean) {
|
|
597
|
+
const localId = message.metadata?.localId;
|
|
598
|
+
const blobId = message.metadata?.blobId;
|
|
599
|
+
assert(blobId !== undefined, 0x12a /* "Missing blob id on metadata" */);
|
|
600
|
+
|
|
601
|
+
// Set up a mapping from local ID to storage ID. This is crucial since without this the blob cannot be
|
|
602
|
+
// requested from the server.
|
|
603
|
+
// Note: The check for undefined is needed for back-compat when localId was not part of the BlobAttach op that
|
|
604
|
+
// was sent when online.
|
|
605
|
+
if (localId !== undefined) {
|
|
606
|
+
this.setRedirection(localId, blobId);
|
|
607
|
+
}
|
|
608
|
+
// set identity (id -> id) entry
|
|
609
|
+
this.setRedirection(blobId, blobId);
|
|
610
|
+
|
|
611
|
+
if (local) {
|
|
612
|
+
assert(localId !== undefined, 0x50e /* local ID not present in blob attach message */);
|
|
613
|
+
const waitingBlobs = this.opsInFlight.get(blobId);
|
|
614
|
+
if (waitingBlobs !== undefined) {
|
|
615
|
+
// For each op corresponding to this storage ID that we are waiting for, resolve the pending blob.
|
|
616
|
+
// This is safe because the server will keep the blob alive and the op containing the local ID to
|
|
617
|
+
// storage ID is already in flight and any op containing this local ID will be sequenced after that.
|
|
618
|
+
waitingBlobs.forEach((pendingLocalId) => {
|
|
619
|
+
const pendingBlobEntry = this.pendingBlobs.get(pendingLocalId);
|
|
620
|
+
assert(
|
|
621
|
+
pendingBlobEntry !== undefined,
|
|
622
|
+
0x38f /* local online BlobAttach op with no pending blob entry */,
|
|
623
|
+
);
|
|
624
|
+
|
|
625
|
+
// It's possible we transitioned to offline flow while waiting for this op.
|
|
626
|
+
if (pendingBlobEntry.status === PendingBlobStatus.OnlinePendingOp) {
|
|
627
|
+
this.setRedirection(pendingLocalId, blobId);
|
|
628
|
+
pendingBlobEntry.handleP.resolve(this.getBlobHandle(pendingLocalId));
|
|
629
|
+
this.deleteAndEmitsIfEmpty(pendingLocalId);
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
this.opsInFlight.delete(blobId);
|
|
633
|
+
}
|
|
634
|
+
// For blobs that were transitioned to offline flow while waiting for this op, the entry should be deleted.
|
|
635
|
+
this.deleteAndEmitsIfEmpty(localId);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Reads blobs needed to load BlobManager from storage.
|
|
641
|
+
* @param blobsTree - Tree containing IDs of previously attached blobs. We
|
|
642
|
+
* look for the IDs in the blob entries of the tree since the both the r11s
|
|
643
|
+
* and SPO drivers replace the attachment types returned in snapshot() with blobs.
|
|
644
|
+
*/
|
|
645
|
+
public static async load(
|
|
646
|
+
blobsTree: ISnapshotTree | undefined,
|
|
647
|
+
tryFetchBlob: (id: string) => Promise<[string, string][]>,
|
|
648
|
+
): Promise<IBlobManagerLoadInfo> {
|
|
649
|
+
if (!blobsTree) {
|
|
650
|
+
return {};
|
|
651
|
+
}
|
|
652
|
+
let redirectTable;
|
|
653
|
+
const tableId = blobsTree.blobs[this.redirectTableBlobName];
|
|
654
|
+
if (tableId) {
|
|
655
|
+
redirectTable = await tryFetchBlob(tableId);
|
|
656
|
+
}
|
|
657
|
+
const ids = Object.entries(blobsTree.blobs)
|
|
658
|
+
.filter(([k, _]) => k !== this.redirectTableBlobName)
|
|
659
|
+
.map(([_, v]) => v);
|
|
660
|
+
return { ids, redirectTable };
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* Load a set of previously attached blob IDs and redirect table from a previous snapshot.
|
|
665
|
+
*/
|
|
666
|
+
private load(snapshot: IBlobManagerLoadInfo): Map<string, string | undefined> {
|
|
667
|
+
this.mc.logger.sendTelemetryEvent({
|
|
668
|
+
eventName: "AttachmentBlobsLoaded",
|
|
669
|
+
count: snapshot.ids?.length ?? 0,
|
|
670
|
+
redirectTable: snapshot.redirectTable?.length,
|
|
671
|
+
});
|
|
672
|
+
const table = new Map<string, string | undefined>(snapshot.redirectTable);
|
|
673
|
+
if (snapshot.ids) {
|
|
674
|
+
const detached = this.runtime.attachState === AttachState.Detached;
|
|
675
|
+
// If we are detached, we don't have storage IDs yet, so set to undefined
|
|
676
|
+
// Otherwise, set identity (id -> id) entries
|
|
677
|
+
snapshot.ids.forEach((entry) => table.set(entry, detached ? undefined : entry));
|
|
678
|
+
}
|
|
679
|
+
return table;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Generates data used for garbage collection. Each blob uploaded represents a node in the GC graph as it can be
|
|
684
|
+
* individually referenced by storing its handle in a referenced DDS. Returns the list of blob ids as GC nodes.
|
|
685
|
+
* @param fullGC - true to bypass optimizations and force full generation of GC data. BlobManager doesn't care
|
|
686
|
+
* about this for now because the data is a simple list of blob ids.
|
|
687
|
+
*/
|
|
688
|
+
public getGCData(fullGC: boolean = false): IGarbageCollectionData {
|
|
689
|
+
const gcData: IGarbageCollectionData = { gcNodes: {} };
|
|
690
|
+
for (const [localId, storageId] of this.redirectTable) {
|
|
691
|
+
assert(!!storageId, 0x390 /* Must be attached to get GC data */);
|
|
692
|
+
gcData.gcNodes[this.getBlobGCNodePath(localId)] = [this.getBlobGCNodePath(storageId)];
|
|
693
|
+
}
|
|
694
|
+
return gcData;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* This is called to update blobs whose routes are unused. The unused blobs are deleted.
|
|
699
|
+
* @param unusedRoutes - The routes of the blob nodes that are unused.
|
|
700
|
+
*/
|
|
701
|
+
public updateUnusedRoutes(unusedRoutes: string[]): void {
|
|
702
|
+
// The routes or blob node paths are in the same format as returned in getGCData -
|
|
703
|
+
// `/<BlobManager.basePath>/<blobId>`.
|
|
704
|
+
for (const route of unusedRoutes) {
|
|
705
|
+
const pathParts = route.split("/");
|
|
706
|
+
assert(
|
|
707
|
+
pathParts.length === 3 && pathParts[1] === BlobManager.basePath,
|
|
708
|
+
0x2d5 /* "Invalid blob node id in unused routes." */,
|
|
709
|
+
);
|
|
710
|
+
const blobId = pathParts[2];
|
|
711
|
+
this.redirectTable.delete(blobId);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Delete attachment blobs that are sweep ready.
|
|
717
|
+
* @param sweepReadyBlobRoutes - The routes of blobs that are sweep ready and should be deleted.
|
|
718
|
+
* @returns - The routes of blobs that were deleted.
|
|
719
|
+
*/
|
|
720
|
+
public deleteSweepReadyNodes(sweepReadyBlobRoutes: string[]): string[] {
|
|
721
|
+
// If sweep for attachment blobs is not enabled, return empty list indicating nothing is deleted.
|
|
722
|
+
if (this.mc.config.getBoolean(sweepAttachmentBlobsKey) !== true) {
|
|
723
|
+
return [];
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
// The routes or blob node paths are in the same format as returned in getGCData -
|
|
727
|
+
// `/<BlobManager.basePath>/<blobId>`.
|
|
728
|
+
for (const route of sweepReadyBlobRoutes) {
|
|
729
|
+
const pathParts = route.split("/");
|
|
730
|
+
assert(
|
|
731
|
+
pathParts.length === 3 && pathParts[1] === BlobManager.basePath,
|
|
732
|
+
0x586 /* Invalid blob node id in deleted routes. */,
|
|
733
|
+
);
|
|
734
|
+
const blobId = pathParts[2];
|
|
735
|
+
if (!this.redirectTable.has(blobId)) {
|
|
736
|
+
this.mc.logger.sendErrorEvent({
|
|
737
|
+
eventName: "DeletedAttachmentBlobNotFound",
|
|
738
|
+
blobId,
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
this.redirectTable.delete(blobId);
|
|
742
|
+
}
|
|
743
|
+
return Array.from(sweepReadyBlobRoutes);
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* This is called to update blobs whose routes are tombstones. Tombstoned blobs enable testing scenarios with
|
|
748
|
+
* accessing deleted content without actually deleting content from summaries.
|
|
749
|
+
* @param tombstonedRoutes - The routes of blob nodes that are tombstones.
|
|
750
|
+
*/
|
|
751
|
+
public updateTombstonedRoutes(tombstonedRoutes: string[]) {
|
|
752
|
+
const tombstonedBlobsSet: Set<string> = new Set();
|
|
753
|
+
// The routes or blob node paths are in the same format as returned in getGCData -
|
|
754
|
+
// `/<BlobManager.basePath>/<blobId>`.
|
|
755
|
+
for (const route of tombstonedRoutes) {
|
|
756
|
+
const pathParts = route.split("/");
|
|
757
|
+
assert(
|
|
758
|
+
pathParts.length === 3 && pathParts[1] === BlobManager.basePath,
|
|
759
|
+
0x50f /* Invalid blob node id in tombstoned routes. */,
|
|
760
|
+
);
|
|
761
|
+
tombstonedBlobsSet.add(pathParts[2]);
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
// Remove blobs from the tombstone list that were tombstoned but aren't anymore as per the tombstoneRoutes.
|
|
765
|
+
for (const blobId of this.tombstonedBlobs) {
|
|
766
|
+
if (!tombstonedBlobsSet.has(blobId)) {
|
|
767
|
+
this.tombstonedBlobs.delete(blobId);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
// Mark blobs that are now tombstoned by adding them to the tombstone list.
|
|
772
|
+
for (const blobId of tombstonedBlobsSet) {
|
|
773
|
+
this.tombstonedBlobs.add(blobId);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* Verifies that the blob with given id is valid, i.e., it has not been garbage collected. If the blob is GC'd,
|
|
779
|
+
* log an error and throw if necessary.
|
|
780
|
+
*/
|
|
781
|
+
private verifyBlobValidity(blobId: string) {
|
|
782
|
+
/**
|
|
783
|
+
* A blob can be in one of the following states:
|
|
784
|
+
* 1. "deleted" - It has been deleted by garbage collection sweep phase.
|
|
785
|
+
* 2. "tombstoned" - It is ready for deletion but sweep phase isn't enabled and tombstone feature is enabled.
|
|
786
|
+
* 3. "valid" - It has not been deleted or tombstoned.
|
|
787
|
+
*/
|
|
788
|
+
let state: "valid" | "tombstoned" | "deleted" = "valid";
|
|
789
|
+
if (this.isBlobDeleted(this.getBlobGCNodePath(blobId))) {
|
|
790
|
+
state = "deleted";
|
|
791
|
+
} else if (this.tombstonedBlobs.has(blobId)) {
|
|
792
|
+
state = "tombstoned";
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
if (state === "valid") {
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
// If the blob is deleted or throw on tombstone load is enabled, throw an error which will fail any attempt
|
|
800
|
+
// to load the blob.
|
|
801
|
+
const shouldFail = state === "deleted" || this.throwOnTombstoneLoad;
|
|
802
|
+
const request = { url: blobId };
|
|
803
|
+
const error = responseToException(
|
|
804
|
+
createResponseError(
|
|
805
|
+
404,
|
|
806
|
+
"Blob was deleted",
|
|
807
|
+
request,
|
|
808
|
+
state === "tombstoned" ? { [TombstoneResponseHeaderKey]: true } : undefined,
|
|
809
|
+
),
|
|
810
|
+
request,
|
|
811
|
+
);
|
|
812
|
+
sendGCUnexpectedUsageEvent(
|
|
813
|
+
this.mc,
|
|
814
|
+
{
|
|
815
|
+
eventName:
|
|
816
|
+
state === "tombstoned"
|
|
817
|
+
? "GC_Tombstone_Blob_Requested"
|
|
818
|
+
: "GC_Deleted_Blob_Requested",
|
|
819
|
+
category: shouldFail ? "error" : "generic",
|
|
820
|
+
gcTombstoneEnforcementAllowed: this.runtime.gcTombstoneEnforcementAllowed,
|
|
821
|
+
},
|
|
822
|
+
[BlobManager.basePath],
|
|
823
|
+
error,
|
|
824
|
+
);
|
|
825
|
+
if (shouldFail) {
|
|
826
|
+
throw error;
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
public summarize(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats {
|
|
831
|
+
// if storageIds is empty, it means we are detached and have only local IDs, or that there are no blobs attached
|
|
832
|
+
const blobIds =
|
|
833
|
+
this.storageIds.size > 0
|
|
834
|
+
? Array.from(this.storageIds)
|
|
835
|
+
: Array.from(this.redirectTable.keys());
|
|
836
|
+
const builder = new SummaryTreeBuilder();
|
|
837
|
+
blobIds.forEach((blobId) => {
|
|
838
|
+
builder.addAttachment(blobId);
|
|
839
|
+
});
|
|
840
|
+
|
|
841
|
+
// Any non-identity entries in the table need to be saved in the summary
|
|
842
|
+
if (this.redirectTable.size > blobIds.length) {
|
|
843
|
+
builder.addBlob(
|
|
844
|
+
BlobManager.redirectTableBlobName,
|
|
845
|
+
// filter out identity entries
|
|
846
|
+
JSON.stringify(
|
|
847
|
+
Array.from(this.redirectTable.entries()).filter(
|
|
848
|
+
([localId, storageId]) => localId !== storageId,
|
|
849
|
+
),
|
|
850
|
+
),
|
|
851
|
+
);
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
return builder.getSummaryTree();
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
public setRedirectTable(table: Map<string, string>) {
|
|
858
|
+
assert(
|
|
859
|
+
this.runtime.attachState === AttachState.Detached,
|
|
860
|
+
0x252 /* "redirect table can only be set in detached container" */,
|
|
861
|
+
);
|
|
862
|
+
assert(
|
|
863
|
+
this.redirectTable.size === table.size,
|
|
864
|
+
0x391 /* Redirect table size must match BlobManager's local ID count */,
|
|
865
|
+
);
|
|
866
|
+
for (const [localId, storageId] of table) {
|
|
867
|
+
assert(
|
|
868
|
+
this.redirectTable.has(localId),
|
|
869
|
+
0x254 /* "unrecognized id in redirect table" */,
|
|
870
|
+
);
|
|
871
|
+
this.setRedirection(localId, storageId);
|
|
872
|
+
// set identity (id -> id) entry
|
|
873
|
+
this.setRedirection(storageId, storageId);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
public getPendingBlobs(): IPendingBlobs {
|
|
878
|
+
const blobs = {};
|
|
879
|
+
for (const [key, entry] of this.pendingBlobs) {
|
|
880
|
+
blobs[key] = { blob: bufferToString(entry.blob, "base64") };
|
|
881
|
+
}
|
|
882
|
+
return blobs;
|
|
883
|
+
}
|
|
733
884
|
}
|