@fluidframework/datastore 2.0.0-dev.3.1.0.125672 → 2.0.0-dev.4.2.0.153917
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/README.md +38 -0
- package/dist/channelContext.d.ts +2 -2
- package/dist/channelContext.d.ts.map +1 -1
- package/dist/channelContext.js +2 -2
- package/dist/channelContext.js.map +1 -1
- package/dist/dataStoreRuntime.d.ts +14 -9
- package/dist/dataStoreRuntime.d.ts.map +1 -1
- package/dist/dataStoreRuntime.js +47 -48
- package/dist/dataStoreRuntime.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/remoteChannelContext.d.ts +2 -2
- package/dist/remoteChannelContext.d.ts.map +1 -1
- package/dist/remoteChannelContext.js +41 -60
- package/dist/remoteChannelContext.js.map +1 -1
- package/lib/channelContext.d.ts +2 -2
- package/lib/channelContext.d.ts.map +1 -1
- package/lib/channelContext.js +2 -2
- package/lib/channelContext.js.map +1 -1
- package/lib/dataStoreRuntime.d.ts +14 -9
- package/lib/dataStoreRuntime.d.ts.map +1 -1
- package/lib/dataStoreRuntime.js +48 -49
- package/lib/dataStoreRuntime.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/remoteChannelContext.d.ts +2 -2
- package/lib/remoteChannelContext.d.ts.map +1 -1
- package/lib/remoteChannelContext.js +41 -60
- package/lib/remoteChannelContext.js.map +1 -1
- package/package.json +58 -59
- package/src/channelContext.ts +8 -1
- package/src/dataStoreRuntime.ts +77 -68
- package/src/packageVersion.ts +1 -1
- package/src/remoteChannelContext.ts +49 -60
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteChannelContext.js","sourceRoot":"","sources":["../src/remoteChannelContext.ts"],"names":[],"mappings":";AAAA;;;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IG;IACK,KAAK,CAAC,iBAAiB,CAAC,SAAkB,KAAK;QACtD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QACxC,OAAO,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAEM,gBAAgB,CAAC,UAAoB;QAC3C;;;;;WAKG;QACH,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5C,CAAC;;AA3RF,oDA4RC;AAhRwB,6CAAwB,GAAG,IAAI,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { DataCorruptionError } from \"@fluidframework/container-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n\tIChannel,\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n\tCreateChildSummarizerNodeFn,\n\tIFluidDataStoreContext,\n\tIGarbageCollectionData,\n\tIGarbageCollectionDetailsBase,\n\tISummarizeInternalResult,\n\tISummarizeResult,\n\tISummarizerNodeWithGC,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { ChildLogger, TelemetryDataTag, ThresholdCounter } from \"@fluidframework/telemetry-utils\";\nimport {\n\tattributesBlobKey,\n\tcreateServiceEndpoints,\n\tIChannelContext,\n\tsummarizeChannelAsync,\n} from \"./channelContext\";\nimport { ChannelDeltaConnection } from \"./channelDeltaConnection\";\nimport { ChannelStorageService } from \"./channelStorageService\";\nimport { ISharedObjectRegistry } from \"./dataStoreRuntime\";\n\nexport class RemoteChannelContext implements IChannelContext {\n\tprivate isLoaded = false;\n\tprivate pending: ISequencedDocumentMessage[] | undefined = [];\n\tprivate channelP: Promise<IChannel> | undefined;\n\tprivate channel: IChannel | undefined;\n\tprivate readonly services: {\n\t\treadonly deltaConnection: ChannelDeltaConnection;\n\t\treadonly objectStorage: ChannelStorageService;\n\t};\n\tprivate readonly summarizerNode: ISummarizerNodeWithGC;\n\tprivate readonly subLogger: ITelemetryLogger;\n\tprivate readonly thresholdOpsCounter: ThresholdCounter;\n\tprivate static readonly pendingOpsCountThreshold = 1000;\n\n\tconstructor(\n\t\tprivate readonly runtime: IFluidDataStoreRuntime,\n\t\tprivate readonly dataStoreContext: IFluidDataStoreContext,\n\t\tstorageService: IDocumentStorageService,\n\t\tsubmitFn: (content: any, localOpMetadata: unknown) => void,\n\t\tdirtyFn: (address: string) => void,\n\t\taddedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n\t\tprivate readonly id: string,\n\t\tbaseSnapshot: ISnapshotTree,\n\t\tprivate readonly registry: ISharedObjectRegistry,\n\t\textraBlobs: Map<string, ArrayBufferLike> | undefined,\n\t\tcreateSummarizerNode: CreateChildSummarizerNodeFn,\n\t\tgetBaseGCDetails: () => Promise<IGarbageCollectionDetailsBase>,\n\t\tprivate readonly attachMessageType?: string,\n\t) {\n\t\tassert(!this.id.includes(\"/\"), 0x310 /* Channel context ID cannot contain slashes */);\n\n\t\tthis.subLogger = ChildLogger.create(this.runtime.logger, \"RemoteChannelContext\");\n\n\t\tthis.services = createServiceEndpoints(\n\t\t\tthis.id,\n\t\t\tthis.dataStoreContext.connected,\n\t\t\tsubmitFn,\n\t\t\t() => dirtyFn(this.id),\n\t\t\taddedGCOutboundReferenceFn,\n\t\t\tstorageService,\n\t\t\tthis.subLogger,\n\t\t\tbaseSnapshot,\n\t\t\textraBlobs,\n\t\t);\n\n\t\tconst thisSummarizeInternal = async (\n\t\t\tfullTree: boolean,\n\t\t\ttrackState: boolean,\n\t\t\ttelemetryContext?: ITelemetryContext,\n\t\t) => this.summarizeInternal(fullTree, trackState, telemetryContext);\n\n\t\tthis.summarizerNode = createSummarizerNode(\n\t\t\tthisSummarizeInternal,\n\t\t\tasync (fullGC?: boolean) => this.getGCDataInternal(fullGC),\n\t\t\tasync () => getBaseGCDetails(),\n\t\t);\n\n\t\tthis.thresholdOpsCounter = new ThresholdCounter(\n\t\t\tRemoteChannelContext.pendingOpsCountThreshold,\n\t\t\tthis.subLogger,\n\t\t);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\tpublic getChannel(): Promise<IChannel> {\n\t\tif (this.channelP === undefined) {\n\t\t\tthis.channelP = this.loadChannel();\n\t\t}\n\n\t\treturn this.channelP;\n\t}\n\n\tpublic setConnectionState(connected: boolean, clientId?: string) {\n\t\t// Connection events are ignored if the data store is not yet loaded\n\t\tif (!this.isLoaded) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.services.deltaConnection.setConnectionState(connected);\n\t}\n\n\tpublic applyStashedOp(message: ISequencedDocumentMessage): unknown {\n\t\tassert(this.isLoaded, 0x194 /* \"Remote channel must be loaded when rebasing op\" */);\n\t\treturn this.services.deltaConnection.applyStashedOp(message);\n\t}\n\n\tpublic processOp(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tthis.summarizerNode.invalidate(message.sequenceNumber);\n\n\t\tif (this.isLoaded) {\n\t\t\tthis.services.deltaConnection.process(message, local, localOpMetadata);\n\t\t} else {\n\t\t\tassert(!local, 0x195 /* \"Remote channel must not be local when processing op\" */);\n\t\t\tassert(this.pending !== undefined, 0x23e /* \"pending is undefined\" */);\n\t\t\tthis.pending.push(message);\n\t\t\tthis.thresholdOpsCounter.sendIfMultiple(\"StorePendingOps\", this.pending.length);\n\t\t}\n\t}\n\n\tpublic reSubmit(content: any, localOpMetadata: unknown) {\n\t\tassert(this.isLoaded, 0x196 /* \"Remote channel must be loaded when resubmitting op\" */);\n\n\t\tthis.services.deltaConnection.reSubmit(content, localOpMetadata);\n\t}\n\n\tpublic rollback(content: any, localOpMetadata: unknown) {\n\t\tassert(this.isLoaded, 0x2f0 /* \"Remote channel must be loaded when rolling back op\" */);\n\n\t\tthis.services.deltaConnection.rollback(content, localOpMetadata);\n\t}\n\n\t/**\n\t * Returns a summary at the current sequence number.\n\t * @param fullTree - true to bypass optimizations and force a full summary tree\n\t * @param trackState - This tells whether we should track state from this summary.\n\t * @param telemetryContext - summary data passed through the layers for telemetry purposes\n\t */\n\tpublic async summarize(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = true,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummarizeResult> {\n\t\treturn this.summarizerNode.summarize(fullTree, trackState, telemetryContext);\n\t}\n\n\tprivate async summarizeInternal(\n\t\tfullTree: boolean,\n\t\ttrackState: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummarizeInternalResult> {\n\t\tconst channel = await this.getChannel();\n\t\tconst summarizeResult = await summarizeChannelAsync(\n\t\t\tchannel,\n\t\t\tfullTree,\n\t\t\ttrackState,\n\t\t\ttelemetryContext,\n\t\t);\n\t\treturn { ...summarizeResult, id: this.id };\n\t}\n\n\tprivate async loadChannel(): Promise<IChannel> {\n\t\tassert(\n\t\t\t!this.isLoaded,\n\t\t\t0x197 /* \"Remote channel must not already be loaded when loading\" */,\n\t\t);\n\n\t\tlet attributes: IChannelAttributes | undefined;\n\t\tif (await this.services.objectStorage.contains(attributesBlobKey)) {\n\t\t\tattributes = await readAndParse<IChannelAttributes | undefined>(\n\t\t\t\tthis.services.objectStorage,\n\t\t\t\tattributesBlobKey,\n\t\t\t);\n\t\t}\n\n\t\tlet factory: IChannelFactory | undefined;\n\t\t// this is a backward compatibility case where\n\t\t// the attach message doesn't include\n\t\t// the attributes. Since old attach messages\n\t\t// will not have attributes we need to keep\n\t\t// this as long as we support old attach messages\n\t\tif (attributes === undefined) {\n\t\t\tif (this.attachMessageType === undefined) {\n\t\t\t\t// TODO: dataStoreId may require a different tag from PackageData #7488\n\t\t\t\tthrow new DataCorruptionError(\"channelTypeNotAvailable\", {\n\t\t\t\t\tchannelId: {\n\t\t\t\t\t\tvalue: this.id,\n\t\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t\t},\n\t\t\t\t\tdataStoreId: {\n\t\t\t\t\t\tvalue: this.dataStoreContext.id,\n\t\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t\t},\n\t\t\t\t\tdataStorePackagePath: this.dataStoreContext.packagePath.join(\"/\"),\n\t\t\t\t});\n\t\t\t}\n\t\t\tfactory = this.registry.get(this.attachMessageType);\n\t\t\tif (factory === undefined) {\n\t\t\t\t// TODO: dataStoreId may require a different tag from PackageData #7488\n\t\t\t\tthrow new DataCorruptionError(\"channelFactoryNotRegisteredForAttachMessageType\", {\n\t\t\t\t\tchannelId: {\n\t\t\t\t\t\tvalue: this.id,\n\t\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t\t},\n\t\t\t\t\tdataStoreId: {\n\t\t\t\t\t\tvalue: this.dataStoreContext.id,\n\t\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t\t},\n\t\t\t\t\tdataStorePackagePath: this.dataStoreContext.packagePath.join(\"/\"),\n\t\t\t\t\tchannelFactoryType: this.attachMessageType,\n\t\t\t\t});\n\t\t\t}\n\t\t\tattributes = factory.attributes;\n\t\t} else {\n\t\t\tfactory = this.registry.get(attributes.type);\n\t\t\tif (factory === undefined) {\n\t\t\t\t// TODO: dataStoreId may require a different tag from PackageData #7488\n\t\t\t\tthrow new DataCorruptionError(\"channelFactoryNotRegisteredForGivenType\", {\n\t\t\t\t\tchannelId: {\n\t\t\t\t\t\tvalue: this.id,\n\t\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t\t},\n\t\t\t\t\tdataStoreId: {\n\t\t\t\t\t\tvalue: this.dataStoreContext.id,\n\t\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t\t},\n\t\t\t\t\tdataStorePackagePath: this.dataStoreContext.packagePath.join(\"/\"),\n\t\t\t\t\tchannelFactoryType: attributes.type,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// Compare snapshot version to collaborative object version\n\t\tif (\n\t\t\tattributes.snapshotFormatVersion !== undefined &&\n\t\t\tattributes.snapshotFormatVersion !== factory.attributes.snapshotFormatVersion\n\t\t) {\n\t\t\tthis.subLogger.sendTelemetryEvent({\n\t\t\t\teventName: \"ChannelAttributesVersionMismatch\",\n\t\t\t\tchannelType: { value: attributes.type, tag: TelemetryDataTag.CodeArtifact },\n\t\t\t\tchannelSnapshotVersion: {\n\t\t\t\t\tvalue: `${attributes.snapshotFormatVersion}@${attributes.packageVersion}`,\n\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t},\n\t\t\t\tchannelCodeVersion: {\n\t\t\t\t\tvalue: `${factory.attributes.snapshotFormatVersion}@${factory.attributes.packageVersion}`,\n\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\tconst channel = await factory.load(this.runtime, this.id, this.services, attributes);\n\n\t\t// Send all pending messages to the channel\n\t\tassert(this.pending !== undefined, 0x23f /* \"pending undefined\" */);\n\t\tfor (const message of this.pending) {\n\t\t\tthis.services.deltaConnection.process(message, false, undefined /* localOpMetadata */);\n\t\t}\n\t\tthis.thresholdOpsCounter.send(\"ProcessPendingOps\", this.pending.length);\n\n\t\t// Commit changes.\n\t\tthis.channel = channel;\n\t\tthis.pending = undefined;\n\t\tthis.isLoaded = true;\n\n\t\t// Because have some await between we created the service and here, the connection state might have changed\n\t\t// and we don't propagate the connection state when we are not loaded. So we have to set it again here.\n\t\tthis.services.deltaConnection.setConnectionState(this.dataStoreContext.connected);\n\t\treturn this.channel;\n\t}\n\n\t/**\n\t * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context.\n\t * Each node has a set of outbound routes to other GC nodes in the document.\n\t * If there is no new data in this context since the last summary, previous GC data is used.\n\t * If there is new data, the GC data is generated again (by calling getGCDataInternal).\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data.\n\t */\n\tpublic async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n\t\treturn this.summarizerNode.getGCData(fullGC);\n\t}\n\n\t/**\n\t * Generates the data used for garbage collection. This is called when there is new data since last summary. It\n\t * loads the context and calls into the channel to get its GC data.\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data.\n\t */\n\tprivate async getGCDataInternal(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n\t\tconst channel = await this.getChannel();\n\t\treturn channel.getGCData(fullGC);\n\t}\n\n\tpublic updateUsedRoutes(usedRoutes: string[]) {\n\t\t/**\n\t\t * Currently, DDSes are always considered referenced and are not garbage collected. Update the summarizer node's\n\t\t * used routes to contain a route to this channel context.\n\t\t * Once we have GC at DDS level, this will be updated to use the passed usedRoutes. See -\n\t\t * https://github.com/microsoft/FluidFramework/issues/4611\n\t\t */\n\t\tthis.summarizerNode.updateUsedRoutes([\"\"]);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"remoteChannelContext.js","sourceRoot":"","sources":["../src/remoteChannelContext.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAAsD;AACtD,qEAAsE;AAQtE,+DAA4D;AAY5D,qEAAkG;AAClG,qDAK0B;AAK1B,MAAa,oBAAoB;IAchC,YACkB,OAA+B,EAC/B,gBAAwC,EACzD,cAAuC,EACvC,QAA0D,EAC1D,OAAkC,EAClC,0BAA2F,EAC1E,EAAU,EAC3B,YAA2B,EACV,QAA+B,EAChD,UAAoD,EACpD,oBAAiD,EAChC,iBAA0B;QAX1B,YAAO,GAAP,OAAO,CAAwB;QAC/B,qBAAgB,GAAhB,gBAA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GAAG,SAAS,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAErB,2GAA2G;QAC3G,wGAAwG;QACxG,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,kBAAkB,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAClF,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,SAAS,CAAC,SAAkB,KAAK;QAC7C,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACK,KAAK,CAAC,iBAAiB,CAAC,SAAkB,KAAK;QACtD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QACxC,OAAO,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAEM,gBAAgB,CAAC,UAAoB;QAC3C;;;;;WAKG;QACH,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5C,CAAC;;AAjRF,oDAkRC;AAtQwB,6CAAwB,GAAG,IAAI,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { DataCorruptionError } from \"@fluidframework/container-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n\tIChannel,\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n\tCreateChildSummarizerNodeFn,\n\tIFluidDataStoreContext,\n\tIGarbageCollectionData,\n\tIExperimentalIncrementalSummaryContext,\n\tISummarizeInternalResult,\n\tISummarizeResult,\n\tISummarizerNodeWithGC,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { ChildLogger, TelemetryDataTag, ThresholdCounter } from \"@fluidframework/telemetry-utils\";\nimport {\n\tattributesBlobKey,\n\tcreateServiceEndpoints,\n\tIChannelContext,\n\tsummarizeChannelAsync,\n} from \"./channelContext\";\nimport { ChannelDeltaConnection } from \"./channelDeltaConnection\";\nimport { ChannelStorageService } from \"./channelStorageService\";\nimport { ISharedObjectRegistry } from \"./dataStoreRuntime\";\n\nexport class RemoteChannelContext implements IChannelContext {\n\tprivate isLoaded = false;\n\tprivate pending: ISequencedDocumentMessage[] | undefined = [];\n\tprivate channelP: Promise<IChannel> | undefined;\n\tprivate channel: IChannel | undefined;\n\tprivate readonly services: {\n\t\treadonly deltaConnection: ChannelDeltaConnection;\n\t\treadonly objectStorage: ChannelStorageService;\n\t};\n\tprivate readonly summarizerNode: ISummarizerNodeWithGC;\n\tprivate readonly subLogger: ITelemetryLogger;\n\tprivate readonly thresholdOpsCounter: ThresholdCounter;\n\tprivate static readonly pendingOpsCountThreshold = 1000;\n\n\tconstructor(\n\t\tprivate readonly runtime: IFluidDataStoreRuntime,\n\t\tprivate readonly dataStoreContext: IFluidDataStoreContext,\n\t\tstorageService: IDocumentStorageService,\n\t\tsubmitFn: (content: any, localOpMetadata: unknown) => void,\n\t\tdirtyFn: (address: string) => void,\n\t\taddedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n\t\tprivate readonly id: string,\n\t\tbaseSnapshot: ISnapshotTree,\n\t\tprivate readonly registry: ISharedObjectRegistry,\n\t\textraBlobs: Map<string, ArrayBufferLike> | undefined,\n\t\tcreateSummarizerNode: CreateChildSummarizerNodeFn,\n\t\tprivate readonly attachMessageType?: string,\n\t) {\n\t\tassert(!this.id.includes(\"/\"), 0x310 /* Channel context ID cannot contain slashes */);\n\n\t\tthis.subLogger = ChildLogger.create(this.runtime.logger, \"RemoteChannelContext\");\n\n\t\tthis.services = createServiceEndpoints(\n\t\t\tthis.id,\n\t\t\tthis.dataStoreContext.connected,\n\t\t\tsubmitFn,\n\t\t\t() => dirtyFn(this.id),\n\t\t\taddedGCOutboundReferenceFn,\n\t\t\tstorageService,\n\t\t\tthis.subLogger,\n\t\t\tbaseSnapshot,\n\t\t\textraBlobs,\n\t\t);\n\n\t\tconst thisSummarizeInternal = async (\n\t\t\tfullTree: boolean,\n\t\t\ttrackState: boolean,\n\t\t\ttelemetryContext?: ITelemetryContext,\n\t\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t\t) =>\n\t\t\tthis.summarizeInternal(\n\t\t\t\tfullTree,\n\t\t\t\ttrackState,\n\t\t\t\ttelemetryContext,\n\t\t\t\tincrementalSummaryContext,\n\t\t\t);\n\n\t\tthis.summarizerNode = createSummarizerNode(\n\t\t\tthisSummarizeInternal,\n\t\t\tasync (fullGC?: boolean) => this.getGCDataInternal(fullGC),\n\t\t);\n\n\t\tthis.thresholdOpsCounter = new ThresholdCounter(\n\t\t\tRemoteChannelContext.pendingOpsCountThreshold,\n\t\t\tthis.subLogger,\n\t\t);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\tpublic getChannel(): Promise<IChannel> {\n\t\tif (this.channelP === undefined) {\n\t\t\tthis.channelP = this.loadChannel();\n\t\t}\n\n\t\treturn this.channelP;\n\t}\n\n\tpublic setConnectionState(connected: boolean, clientId?: string) {\n\t\t// Connection events are ignored if the data store is not yet loaded\n\t\tif (!this.isLoaded) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.services.deltaConnection.setConnectionState(connected);\n\t}\n\n\tpublic applyStashedOp(message: ISequencedDocumentMessage): unknown {\n\t\tassert(this.isLoaded, 0x194 /* \"Remote channel must be loaded when rebasing op\" */);\n\t\treturn this.services.deltaConnection.applyStashedOp(message);\n\t}\n\n\tpublic processOp(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tthis.summarizerNode.invalidate(message.sequenceNumber);\n\n\t\tif (this.isLoaded) {\n\t\t\tthis.services.deltaConnection.process(message, local, localOpMetadata);\n\t\t} else {\n\t\t\tassert(!local, 0x195 /* \"Remote channel must not be local when processing op\" */);\n\t\t\tassert(this.pending !== undefined, 0x23e /* \"pending is undefined\" */);\n\t\t\tthis.pending.push(message);\n\t\t\tthis.thresholdOpsCounter.sendIfMultiple(\"StorePendingOps\", this.pending.length);\n\t\t}\n\t}\n\n\tpublic reSubmit(content: any, localOpMetadata: unknown) {\n\t\tassert(this.isLoaded, 0x196 /* \"Remote channel must be loaded when resubmitting op\" */);\n\n\t\tthis.services.deltaConnection.reSubmit(content, localOpMetadata);\n\t}\n\n\tpublic rollback(content: any, localOpMetadata: unknown) {\n\t\tassert(this.isLoaded, 0x2f0 /* \"Remote channel must be loaded when rolling back op\" */);\n\n\t\tthis.services.deltaConnection.rollback(content, localOpMetadata);\n\t}\n\n\t/**\n\t * Returns a summary at the current sequence number.\n\t * @param fullTree - true to bypass optimizations and force a full summary tree\n\t * @param trackState - This tells whether we should track state from this summary.\n\t * @param telemetryContext - summary data passed through the layers for telemetry purposes\n\t */\n\tpublic async summarize(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = true,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummarizeResult> {\n\t\treturn this.summarizerNode.summarize(fullTree, trackState, telemetryContext);\n\t}\n\n\tprivate async summarizeInternal(\n\t\tfullTree: boolean,\n\t\ttrackState: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): Promise<ISummarizeInternalResult> {\n\t\tconst channel = await this.getChannel();\n\t\tconst summarizeResult = await summarizeChannelAsync(\n\t\t\tchannel,\n\t\t\tfullTree,\n\t\t\ttrackState,\n\t\t\ttelemetryContext,\n\t\t\tincrementalSummaryContext,\n\t\t);\n\t\treturn { ...summarizeResult, id: this.id };\n\t}\n\n\tprivate async loadChannel(): Promise<IChannel> {\n\t\tassert(\n\t\t\t!this.isLoaded,\n\t\t\t0x197 /* \"Remote channel must not already be loaded when loading\" */,\n\t\t);\n\n\t\tlet attributes: IChannelAttributes | undefined;\n\t\tif (await this.services.objectStorage.contains(attributesBlobKey)) {\n\t\t\tattributes = await readAndParse<IChannelAttributes | undefined>(\n\t\t\t\tthis.services.objectStorage,\n\t\t\t\tattributesBlobKey,\n\t\t\t);\n\t\t}\n\n\t\t// This is a backward compatibility case where the attach message doesn't include attributes. They must\n\t\t// include attach message type.\n\t\t// Since old attach messages will not have attributes, we need to keep this as long as we support old attach\n\t\t// messages.\n\t\tconst channelFactoryType = attributes ? attributes.type : this.attachMessageType;\n\t\tif (channelFactoryType === undefined) {\n\t\t\tthrow new DataCorruptionError(\"channelTypeNotAvailable\", {\n\t\t\t\tchannelId: {\n\t\t\t\t\tvalue: this.id,\n\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t},\n\t\t\t\tdataStoreId: {\n\t\t\t\t\tvalue: this.dataStoreContext.id,\n\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t},\n\t\t\t\tdataStorePackagePath: this.dataStoreContext.packagePath.join(\"/\"),\n\t\t\t\tchannelFactoryType: this.attachMessageType,\n\t\t\t});\n\t\t}\n\t\tconst factory = this.registry.get(channelFactoryType);\n\t\tif (factory === undefined) {\n\t\t\t// TODO: dataStoreId may require a different tag from PackageData #7488\n\t\t\tthrow new DataCorruptionError(\"channelFactoryNotRegisteredForGivenType\", {\n\t\t\t\tchannelId: {\n\t\t\t\t\tvalue: this.id,\n\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t},\n\t\t\t\tdataStoreId: {\n\t\t\t\t\tvalue: this.dataStoreContext.id,\n\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t},\n\t\t\t\tdataStorePackagePath: this.dataStoreContext.packagePath.join(\"/\"),\n\t\t\t\tchannelFactoryType,\n\t\t\t});\n\t\t}\n\n\t\t// This is a backward compatibility case where the attach message doesn't include attributes. Get the attributes\n\t\t// from the factory.\n\t\tattributes = attributes ?? factory.attributes;\n\n\t\t// Compare snapshot version to collaborative object version\n\t\tif (\n\t\t\tattributes.snapshotFormatVersion !== undefined &&\n\t\t\tattributes.snapshotFormatVersion !== factory.attributes.snapshotFormatVersion\n\t\t) {\n\t\t\tthis.subLogger.sendTelemetryEvent({\n\t\t\t\teventName: \"ChannelAttributesVersionMismatch\",\n\t\t\t\tchannelType: { value: attributes.type, tag: TelemetryDataTag.CodeArtifact },\n\t\t\t\tchannelSnapshotVersion: {\n\t\t\t\t\tvalue: `${attributes.snapshotFormatVersion}@${attributes.packageVersion}`,\n\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t},\n\t\t\t\tchannelCodeVersion: {\n\t\t\t\t\tvalue: `${factory.attributes.snapshotFormatVersion}@${factory.attributes.packageVersion}`,\n\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\tconst channel = await factory.load(this.runtime, this.id, this.services, attributes);\n\n\t\t// Send all pending messages to the channel\n\t\tassert(this.pending !== undefined, 0x23f /* \"pending undefined\" */);\n\t\tfor (const message of this.pending) {\n\t\t\tthis.services.deltaConnection.process(message, false, undefined /* localOpMetadata */);\n\t\t}\n\t\tthis.thresholdOpsCounter.send(\"ProcessPendingOps\", this.pending.length);\n\n\t\t// Commit changes.\n\t\tthis.channel = channel;\n\t\tthis.pending = undefined;\n\t\tthis.isLoaded = true;\n\n\t\t// Because have some await between we created the service and here, the connection state might have changed\n\t\t// and we don't propagate the connection state when we are not loaded. So we have to set it again here.\n\t\tthis.services.deltaConnection.setConnectionState(this.dataStoreContext.connected);\n\t\treturn this.channel;\n\t}\n\n\t/**\n\t * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context.\n\t * Each node has a set of outbound routes to other GC nodes in the document.\n\t * If there is no new data in this context since the last summary, previous GC data is used.\n\t * If there is new data, the GC data is generated again (by calling getGCDataInternal).\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data.\n\t */\n\tpublic async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n\t\treturn this.summarizerNode.getGCData(fullGC);\n\t}\n\n\t/**\n\t * Generates the data used for garbage collection. This is called when there is new data since last summary. It\n\t * loads the context and calls into the channel to get its GC data.\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data.\n\t */\n\tprivate async getGCDataInternal(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n\t\tconst channel = await this.getChannel();\n\t\treturn channel.getGCData(fullGC);\n\t}\n\n\tpublic updateUsedRoutes(usedRoutes: string[]) {\n\t\t/**\n\t\t * Currently, DDSes are always considered referenced and are not garbage collected. Update the summarizer node's\n\t\t * used routes to contain a route to this channel context.\n\t\t * Once we have GC at DDS level, this will be updated to use the passed usedRoutes. See -\n\t\t * https://github.com/microsoft/FluidFramework/issues/4611\n\t\t */\n\t\tthis.summarizerNode.updateUsedRoutes([\"\"]);\n\t}\n}\n"]}
|
package/lib/channelContext.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
|
7
7
|
import { IChannel } from "@fluidframework/datastore-definitions";
|
|
8
8
|
import { IDocumentStorageService } from "@fluidframework/driver-definitions";
|
|
9
9
|
import { ISequencedDocumentMessage, ISnapshotTree } from "@fluidframework/protocol-definitions";
|
|
10
|
-
import { IGarbageCollectionData, ISummarizeResult, ISummaryTreeWithStats, ITelemetryContext } from "@fluidframework/runtime-definitions";
|
|
10
|
+
import { IGarbageCollectionData, IExperimentalIncrementalSummaryContext, ISummarizeResult, ISummaryTreeWithStats, ITelemetryContext } from "@fluidframework/runtime-definitions";
|
|
11
11
|
import { ChannelDeltaConnection } from "./channelDeltaConnection";
|
|
12
12
|
import { ChannelStorageService } from "./channelStorageService";
|
|
13
13
|
export declare const attributesBlobKey = ".attributes";
|
|
@@ -38,5 +38,5 @@ export declare function createServiceEndpoints(id: string, connected: boolean, s
|
|
|
38
38
|
objectStorage: ChannelStorageService;
|
|
39
39
|
};
|
|
40
40
|
export declare function summarizeChannel(channel: IChannel, fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
|
|
41
|
-
export declare function summarizeChannelAsync(channel: IChannel, fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): Promise<ISummaryTreeWithStats>;
|
|
41
|
+
export declare function summarizeChannelAsync(channel: IChannel, fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext, incrementalSummaryContext?: IExperimentalIncrementalSummaryContext): Promise<ISummaryTreeWithStats>;
|
|
42
42
|
//# sourceMappingURL=channelContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channelContext.d.ts","sourceRoot":"","sources":["../src/channelContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAChG,OAAO,EACN,sBAAsB,EACtB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,eAAO,MAAM,iBAAiB,gBAAgB,CAAC;AAE/C,MAAM,WAAW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,CAAC,CAWhC"}
|
package/lib/channelContext.js
CHANGED
|
@@ -20,8 +20,8 @@ export function summarizeChannel(channel, fullTree = false, trackState = false,
|
|
|
20
20
|
addBlobToSummary(summarizeResult, attributesBlobKey, JSON.stringify(channel.attributes));
|
|
21
21
|
return summarizeResult;
|
|
22
22
|
}
|
|
23
|
-
export async function summarizeChannelAsync(channel, fullTree = false, trackState = false, telemetryContext) {
|
|
24
|
-
const summarizeResult = await channel.summarize(fullTree, trackState, telemetryContext);
|
|
23
|
+
export async function summarizeChannelAsync(channel, fullTree = false, trackState = false, telemetryContext, incrementalSummaryContext) {
|
|
24
|
+
const summarizeResult = await channel.summarize(fullTree, trackState, telemetryContext, incrementalSummaryContext);
|
|
25
25
|
// Add the channel attributes to the returned result.
|
|
26
26
|
addBlobToSummary(summarizeResult, attributesBlobKey, JSON.stringify(channel.attributes));
|
|
27
27
|
return summarizeResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channelContext.js","sourceRoot":"","sources":["../src/channelContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"channelContext.js","sourceRoot":"","sources":["../src/channelContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAqC/C,MAAM,UAAU,sBAAsB,CACrC,EAAU,EACV,SAAkB,EAClB,QAA0D,EAC1D,OAAmB,EACnB,0BAA2F,EAC3F,cAAuC,EACvC,MAAwB,EACxB,IAAoB,EACpB,UAAyC;IAEzC,MAAM,eAAe,GAAG,IAAI,sBAAsB,CACjD,EAAE,EACF,SAAS,EACT,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,EAChE,OAAO,EACP,0BAA0B,CAC1B,CAAC;IACF,MAAM,aAAa,GAAG,IAAI,qBAAqB,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;IAE1F,OAAO;QACN,eAAe;QACf,aAAa;KACb,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC/B,OAAiB,EACjB,WAAoB,KAAK,EACzB,aAAsB,KAAK,EAC3B,gBAAoC;IAEpC,MAAM,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC;IAEzF,qDAAqD;IACrD,gBAAgB,CAAC,eAAe,EAAE,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;IACzF,OAAO,eAAe,CAAC;AACxB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAC1C,OAAiB,EACjB,WAAoB,KAAK,EACzB,aAAsB,KAAK,EAC3B,gBAAoC,EACpC,yBAAkE;IAElE,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,SAAS,CAC9C,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,yBAAyB,CACzB,CAAC;IAEF,qDAAqD;IACrD,gBAAgB,CAAC,eAAe,EAAE,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;IACzF,OAAO,eAAe,CAAC;AACxB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { IChannel } from \"@fluidframework/datastore-definitions\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIGarbageCollectionData,\n\tIExperimentalIncrementalSummaryContext,\n\tISummarizeResult,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { addBlobToSummary } from \"@fluidframework/runtime-utils\";\nimport { ChannelDeltaConnection } from \"./channelDeltaConnection\";\nimport { ChannelStorageService } from \"./channelStorageService\";\n\nexport const attributesBlobKey = \".attributes\";\n\nexport interface IChannelContext {\n\tgetChannel(): Promise<IChannel>;\n\n\tsetConnectionState(connected: boolean, clientId?: string);\n\n\tprocessOp(message: ISequencedDocumentMessage, local: boolean, localOpMetadata?: unknown): void;\n\n\tsummarize(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummarizeResult>;\n\n\treSubmit(content: any, localOpMetadata: unknown): void;\n\n\tapplyStashedOp(content: any): unknown;\n\n\trollback(message: any, localOpMetadata: unknown): void;\n\n\t/**\n\t * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context\n\t * including any of its children. Each node has a set of outbound routes to other GC nodes in the document.\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data.\n\t */\n\tgetGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;\n\n\t/**\n\t * After GC has run, called to notify this context of routes that are used in it. These are used for the following:\n\t * 1. To identify if this context is being referenced in the document or not.\n\t * 2. To identify if this context or any of its children's used routes changed since last summary.\n\t * 3. They are added to the summary generated by this context.\n\t */\n\tupdateUsedRoutes(usedRoutes: string[]): void;\n}\n\nexport function createServiceEndpoints(\n\tid: string,\n\tconnected: boolean,\n\tsubmitFn: (content: any, localOpMetadata: unknown) => void,\n\tdirtyFn: () => void,\n\taddedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n\tstorageService: IDocumentStorageService,\n\tlogger: ITelemetryLogger,\n\ttree?: ISnapshotTree,\n\textraBlobs?: Map<string, ArrayBufferLike>,\n) {\n\tconst deltaConnection = new ChannelDeltaConnection(\n\t\tid,\n\t\tconnected,\n\t\t(message, localOpMetadata) => submitFn(message, localOpMetadata),\n\t\tdirtyFn,\n\t\taddedGCOutboundReferenceFn,\n\t);\n\tconst objectStorage = new ChannelStorageService(tree, storageService, logger, extraBlobs);\n\n\treturn {\n\t\tdeltaConnection,\n\t\tobjectStorage,\n\t};\n}\n\nexport function summarizeChannel(\n\tchannel: IChannel,\n\tfullTree: boolean = false,\n\ttrackState: boolean = false,\n\ttelemetryContext?: ITelemetryContext,\n): ISummaryTreeWithStats {\n\tconst summarizeResult = channel.getAttachSummary(fullTree, trackState, telemetryContext);\n\n\t// Add the channel attributes to the returned result.\n\taddBlobToSummary(summarizeResult, attributesBlobKey, JSON.stringify(channel.attributes));\n\treturn summarizeResult;\n}\n\nexport async function summarizeChannelAsync(\n\tchannel: IChannel,\n\tfullTree: boolean = false,\n\ttrackState: boolean = false,\n\ttelemetryContext?: ITelemetryContext,\n\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n): Promise<ISummaryTreeWithStats> {\n\tconst summarizeResult = await channel.summarize(\n\t\tfullTree,\n\t\ttrackState,\n\t\ttelemetryContext,\n\t\tincrementalSummaryContext,\n\t);\n\n\t// Add the channel attributes to the returned result.\n\taddBlobToSummary(summarizeResult, attributesBlobKey, JSON.stringify(channel.attributes));\n\treturn summarizeResult;\n}\n"]}
|
|
@@ -52,7 +52,6 @@ export declare class FluidDataStoreRuntime extends TypedEventEmitter<IFluidDataS
|
|
|
52
52
|
private readonly contexts;
|
|
53
53
|
private readonly contextsDeferred;
|
|
54
54
|
private readonly pendingAttach;
|
|
55
|
-
private bindState;
|
|
56
55
|
private readonly deferredAttached;
|
|
57
56
|
private readonly localChannelContextQueue;
|
|
58
57
|
private readonly notBoundedChannelContextSet;
|
|
@@ -64,8 +63,14 @@ export declare class FluidDataStoreRuntime extends TypedEventEmitter<IFluidDataS
|
|
|
64
63
|
readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;
|
|
65
64
|
private readonly quorum;
|
|
66
65
|
private readonly audience;
|
|
67
|
-
readonly
|
|
68
|
-
|
|
66
|
+
private readonly mc;
|
|
67
|
+
get logger(): ITelemetryLogger;
|
|
68
|
+
/**
|
|
69
|
+
* If the summarizer makes local changes, a telemetry event is logged. This has the potential to be very noisy.
|
|
70
|
+
* So, adding a count of how many telemetry events are logged per data store context. This can be
|
|
71
|
+
* controlled via feature flags.
|
|
72
|
+
*/
|
|
73
|
+
private localChangesTelemetryCount;
|
|
69
74
|
/**
|
|
70
75
|
* Invokes the given callback and expects that no ops are submitted
|
|
71
76
|
* until execution finishes. If an op is submitted, an error will be raised.
|
|
@@ -172,12 +177,6 @@ export declare class FluidDataStoreRuntime extends TypedEventEmitter<IFluidDataS
|
|
|
172
177
|
* @param outboundHandle - The handle of the outbound node that is referenced.
|
|
173
178
|
*/
|
|
174
179
|
private addedGCOutboundReference;
|
|
175
|
-
/**
|
|
176
|
-
* Returns the base GC details for the channel with the given id. This is used to initialize its GC state.
|
|
177
|
-
* @param channelId - The id of the channel context that is asked for the initial GC details.
|
|
178
|
-
* @returns the requested channel's base GC details.
|
|
179
|
-
*/
|
|
180
|
-
private getChannelBaseGCDetails;
|
|
181
180
|
/**
|
|
182
181
|
* Returns a summary at the current sequence number.
|
|
183
182
|
* @param fullTree - true to bypass optimizations and force a full summary tree
|
|
@@ -217,6 +216,12 @@ export declare class FluidDataStoreRuntime extends TypedEventEmitter<IFluidDataS
|
|
|
217
216
|
private processChannelOp;
|
|
218
217
|
private attachListener;
|
|
219
218
|
private verifyNotClosed;
|
|
219
|
+
/**
|
|
220
|
+
* Summarizer client should not have local changes. These changes can become part of the summary and can break
|
|
221
|
+
* eventual consistency. For example, the next summary (say at ref seq# 100) may contain these changes whereas
|
|
222
|
+
* other clients that are up-to-date till seq# 100 may not have them yet.
|
|
223
|
+
*/
|
|
224
|
+
private identifyLocalChangeInSummarizer;
|
|
220
225
|
}
|
|
221
226
|
/**
|
|
222
227
|
* Mixin class that adds request handler to FluidDataStoreRuntime
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataStoreRuntime.d.ts","sourceRoot":"","sources":["../src/dataStoreRuntime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EACN,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,QAAQ,EACR,SAAS,EACT,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACN,SAAS,EACT,aAAa,EACb,WAAW,EACX,cAAc,EACd,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAIN,iBAAiB,EAEjB,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"dataStoreRuntime.d.ts","sourceRoot":"","sources":["../src/dataStoreRuntime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EACN,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,QAAQ,EACR,SAAS,EACT,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACN,SAAS,EACT,aAAa,EACb,WAAW,EACX,cAAc,EACd,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAIN,iBAAiB,EAEjB,MAAM,8BAA8B,CAAC;AAWtC,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,yBAAyB,EAIzB,cAAc,EACd,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAIN,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,MAAM,qCAAqC,CAAC;AAe7C,OAAO,EACN,QAAQ,EACR,sBAAsB,EACtB,4BAA4B,EAC5B,eAAe,EACf,MAAM,uCAAuC,CAAC;AAW/C,oBAAY,oBAAoB;IAE/B,MAAM,WAAW;IACjB,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;;;;;OAMG;IACI,QAAQ,CAAC,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO;IAwBlF;;;;OAIG;IACI,QAAQ,CAAC,CAAC,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO;IAoBtE,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ3D,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,gBAAgB;IAqBxB,OAAO,CAAC,cAAc;IA0CtB,OAAO,CAAC,eAAe;IAMvB;;;;OAIG;IACH,OAAO,CAAC,+BAA+B;CA8BvC;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,6BACL,QAAQ,WAAW,qBAAqB,KAAK,QAAQ,SAAS,CAAC,SACnF,4BAA4B,iCAUD,CAAC;AAEnC;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,sBAErB,qBAAqB,KAC1B,QAAQ;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAAC,SACvD,4BAA4B,iCAkCD,CAAC"}
|
package/lib/dataStoreRuntime.js
CHANGED
|
@@ -5,12 +5,11 @@
|
|
|
5
5
|
import { AttachState, } from "@fluidframework/container-definitions";
|
|
6
6
|
import { DataProcessingError, UsageError } from "@fluidframework/container-utils";
|
|
7
7
|
import { assert, Deferred, LazyPromise, TypedEventEmitter, unreachableCase, } from "@fluidframework/common-utils";
|
|
8
|
-
import { ChildLogger, LoggingError, raiseConnectedEvent } from "@fluidframework/telemetry-utils";
|
|
8
|
+
import { ChildLogger, generateStack, LoggingError, loggerToMonitoringContext, raiseConnectedEvent, TelemetryDataTag, } from "@fluidframework/telemetry-utils";
|
|
9
9
|
import { buildSnapshotTree } from "@fluidframework/driver-utils";
|
|
10
10
|
import { SummaryType, } from "@fluidframework/protocol-definitions";
|
|
11
|
-
import {
|
|
12
|
-
import { convertSnapshotTreeToSummaryTree, convertSummaryTreeToITree, generateHandleContextPath, RequestParser, SummaryTreeBuilder, create404Response, createResponseError, exceptionToResponse, requestFluidObject, } from "@fluidframework/runtime-utils";
|
|
13
|
-
import { GCDataBuilder, removeRouteFromAllNodes, unpackChildNodesGCDetails, unpackChildNodesUsedRoutes, } from "@fluidframework/garbage-collector";
|
|
11
|
+
import { CreateSummarizerNodeSource, VisibilityState, } from "@fluidframework/runtime-definitions";
|
|
12
|
+
import { convertSnapshotTreeToSummaryTree, convertSummaryTreeToITree, generateHandleContextPath, RequestParser, SummaryTreeBuilder, create404Response, createResponseError, exceptionToResponse, GCDataBuilder, requestFluidObject, packagePathToTelemetryProperty, unpackChildNodesUsedRoutes, } from "@fluidframework/runtime-utils";
|
|
14
13
|
import { v4 as uuid } from "uuid";
|
|
15
14
|
import { summarizeChannel } from "./channelContext";
|
|
16
15
|
import { LocalChannelContext, LocalChannelContextBase, RehydratedLocalChannelContext, } from "./localChannelContext";
|
|
@@ -38,6 +37,7 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
38
37
|
* and the primary way of interacting with some Fluid objects, and should be used if possible.
|
|
39
38
|
*/
|
|
40
39
|
constructor(dataStoreContext, sharedObjectRegistry, existing, initializeEntryPoint) {
|
|
40
|
+
var _a;
|
|
41
41
|
super();
|
|
42
42
|
this.dataStoreContext = dataStoreContext;
|
|
43
43
|
this.sharedObjectRegistry = sharedObjectRegistry;
|
|
@@ -52,19 +52,15 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
52
52
|
// store becomes visible.
|
|
53
53
|
this.pendingHandlesToMakeVisible = new Set();
|
|
54
54
|
assert(!dataStoreContext.id.includes("/"), 0x30e /* Id cannot contain slashes. DataStoreContext should have validated this. */);
|
|
55
|
-
this.
|
|
55
|
+
this.mc = loggerToMonitoringContext(ChildLogger.create(dataStoreContext.logger, "FluidDataStoreRuntime", {
|
|
56
56
|
all: { dataStoreId: uuid() },
|
|
57
|
-
});
|
|
57
|
+
}));
|
|
58
58
|
this.id = dataStoreContext.id;
|
|
59
59
|
this.options = dataStoreContext.options;
|
|
60
60
|
this.deltaManager = dataStoreContext.deltaManager;
|
|
61
61
|
this.quorum = dataStoreContext.getQuorum();
|
|
62
62
|
this.audience = dataStoreContext.getAudience();
|
|
63
63
|
const tree = dataStoreContext.baseSnapshot;
|
|
64
|
-
this.channelsBaseGCDetails = new LazyPromise(async () => {
|
|
65
|
-
const baseGCDetails = await this.dataStoreContext.getBaseGCDetails();
|
|
66
|
-
return unpackChildNodesGCDetails(baseGCDetails);
|
|
67
|
-
});
|
|
68
64
|
// Must always receive the data store type inside of the attributes
|
|
69
65
|
if ((tree === null || tree === void 0 ? void 0 : tree.trees) !== undefined) {
|
|
70
66
|
Object.keys(tree.trees).forEach((path) => {
|
|
@@ -92,7 +88,7 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
92
88
|
else {
|
|
93
89
|
channelContext = new RemoteChannelContext(this, dataStoreContext, dataStoreContext.storage, (content, localOpMetadata) => this.submitChannelOp(path, content, localOpMetadata), (address) => this.setChannelDirty(address), (srcHandle, outboundHandle) => this.addedGCOutboundReference(srcHandle, outboundHandle), path, tree.trees[path], this.sharedObjectRegistry, undefined /* extraBlobs */, this.dataStoreContext.getCreateChildSummarizerNodeFn(path, {
|
|
94
90
|
type: CreateSummarizerNodeSource.FromSummary,
|
|
95
|
-
})
|
|
91
|
+
}));
|
|
96
92
|
}
|
|
97
93
|
const deferred = new Deferred();
|
|
98
94
|
deferred.resolve(channelContext);
|
|
@@ -105,8 +101,6 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
105
101
|
this.entryPoint = new FluidObjectHandle(promise, "", this.objectsRoutingContext);
|
|
106
102
|
}
|
|
107
103
|
this.attachListener();
|
|
108
|
-
// If exists on storage or loaded from a snapshot, it should already be bound.
|
|
109
|
-
this.bindState = existing ? BindState.Bound : BindState.NotBound;
|
|
110
104
|
this._attachState = dataStoreContext.attachState;
|
|
111
105
|
/**
|
|
112
106
|
* If existing flag is false, this is a new data store and is not visible. The existing flag can be true in two
|
|
@@ -131,6 +125,9 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
131
125
|
if (existing) {
|
|
132
126
|
this.deferredAttached.resolve();
|
|
133
127
|
}
|
|
128
|
+
// By default, a data store can log maximum 10 local changes telemetry in summarizer.
|
|
129
|
+
this.localChangesTelemetryCount =
|
|
130
|
+
(_a = this.mc.config.getNumber("Fluid.Telemetry.LocalChangesTelemetryCount")) !== null && _a !== void 0 ? _a : 10;
|
|
134
131
|
}
|
|
135
132
|
/**
|
|
136
133
|
* @deprecated - Instantiate the class using its constructor instead.
|
|
@@ -182,6 +179,9 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
182
179
|
get disposed() {
|
|
183
180
|
return this._disposed;
|
|
184
181
|
}
|
|
182
|
+
get logger() {
|
|
183
|
+
return this.mc.logger;
|
|
184
|
+
}
|
|
185
185
|
/**
|
|
186
186
|
* Invokes the given callback and expects that no ops are submitted
|
|
187
187
|
* until execution finishes. If an op is submitted, an error will be raised.
|
|
@@ -223,7 +223,7 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
223
223
|
return { mimeType: "fluid/object", status: 200, value: channel };
|
|
224
224
|
}
|
|
225
225
|
catch (error) {
|
|
226
|
-
this.logger.sendErrorEvent({ eventName: "GetChannelFailedInRequest" }, error);
|
|
226
|
+
this.mc.logger.sendErrorEvent({ eventName: "GetChannelFailedInRequest" }, error);
|
|
227
227
|
return createResponseError(500, `Failed to get Channel: ${error}`, request);
|
|
228
228
|
}
|
|
229
229
|
}
|
|
@@ -265,6 +265,8 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
265
265
|
deferred.resolve(context);
|
|
266
266
|
this.contextsDeferred.set(id, deferred);
|
|
267
267
|
}
|
|
268
|
+
// Channels (DDS) should not be created in summarizer client.
|
|
269
|
+
this.identifyLocalChangeInSummarizer("DDSCreatedInSummarizer", id, type);
|
|
268
270
|
assert(!!context.channel, 0x17a /* "Channel should be loaded when created!!" */);
|
|
269
271
|
return context.channel;
|
|
270
272
|
}
|
|
@@ -314,7 +316,7 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
314
316
|
handle.attachGraph();
|
|
315
317
|
});
|
|
316
318
|
this.pendingHandlesToMakeVisible.clear();
|
|
317
|
-
this.
|
|
319
|
+
this.dataStoreContext.makeLocallyVisible();
|
|
318
320
|
}
|
|
319
321
|
/**
|
|
320
322
|
* This function is called when a handle to this data store is added to a visible DDS.
|
|
@@ -330,12 +332,7 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
330
332
|
* 2. Attaching the graph if the data store becomes attached.
|
|
331
333
|
*/
|
|
332
334
|
bindToContext() {
|
|
333
|
-
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
this.bindState = BindState.Binding;
|
|
337
|
-
this.dataStoreContext.bindToContext();
|
|
338
|
-
this.bindState = BindState.Bound;
|
|
335
|
+
this.makeVisibleAndAttachGraph();
|
|
339
336
|
}
|
|
340
337
|
bind(handle) {
|
|
341
338
|
// If visible, attach the incoming handle's graph. Else, this will be done when we become visible.
|
|
@@ -377,16 +374,14 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
377
374
|
this.pendingAttach.delete(id);
|
|
378
375
|
}
|
|
379
376
|
else {
|
|
380
|
-
assert(!this.contexts.has(id), 0x17d /*
|
|
381
|
-
is in pendingAttach set: ${this.pendingAttach.has(id)},
|
|
382
|
-
is local channel contexts: ${this.contexts.get(id) instanceof LocalChannelContextBase}` */);
|
|
377
|
+
assert(!this.contexts.has(id), 0x17d /* "Unexpected attach channel OP" */);
|
|
383
378
|
const flatBlobs = new Map();
|
|
384
379
|
const snapshotTree = buildSnapshotTree(attachMessage.snapshot.entries, flatBlobs);
|
|
385
380
|
const remoteChannelContext = new RemoteChannelContext(this, this.dataStoreContext, this.dataStoreContext.storage, (content, localContentMetadata) => this.submitChannelOp(id, content, localContentMetadata), (address) => this.setChannelDirty(address), (srcHandle, outboundHandle) => this.addedGCOutboundReference(srcHandle, outboundHandle), id, snapshotTree, this.sharedObjectRegistry, flatBlobs, this.dataStoreContext.getCreateChildSummarizerNodeFn(id, {
|
|
386
381
|
type: CreateSummarizerNodeSource.FromAttach,
|
|
387
382
|
sequenceNumber: message.sequenceNumber,
|
|
388
383
|
snapshot: attachMessage.snapshot,
|
|
389
|
-
}),
|
|
384
|
+
}), attachMessage.type);
|
|
390
385
|
this.contexts.set(id, remoteChannelContext);
|
|
391
386
|
if (this.contextsDeferred.has(id)) {
|
|
392
387
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -512,30 +507,6 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
512
507
|
var _a, _b;
|
|
513
508
|
(_b = (_a = this.dataStoreContext).addedGCOutboundReference) === null || _b === void 0 ? void 0 : _b.call(_a, srcHandle, outboundHandle);
|
|
514
509
|
}
|
|
515
|
-
/**
|
|
516
|
-
* Returns the base GC details for the channel with the given id. This is used to initialize its GC state.
|
|
517
|
-
* @param channelId - The id of the channel context that is asked for the initial GC details.
|
|
518
|
-
* @returns the requested channel's base GC details.
|
|
519
|
-
*/
|
|
520
|
-
async getChannelBaseGCDetails(channelId) {
|
|
521
|
-
var _a;
|
|
522
|
-
let channelBaseGCDetails = (await this.channelsBaseGCDetails).get(channelId);
|
|
523
|
-
if (channelBaseGCDetails === undefined) {
|
|
524
|
-
channelBaseGCDetails = {};
|
|
525
|
-
}
|
|
526
|
-
else if (((_a = channelBaseGCDetails.gcData) === null || _a === void 0 ? void 0 : _a.gcNodes) !== undefined) {
|
|
527
|
-
// Note: if the child channel has an explicit handle route to its parent, it will be removed here and
|
|
528
|
-
// expected to be added back by the parent when getGCData is called.
|
|
529
|
-
removeRouteFromAllNodes(channelBaseGCDetails.gcData.gcNodes, this.absolutePath);
|
|
530
|
-
}
|
|
531
|
-
// Currently, channel context's are always considered used. So, it there are no used routes for it, we still
|
|
532
|
-
// need to mark it as used. Add self-route (empty string) to the channel context's used routes.
|
|
533
|
-
if (channelBaseGCDetails.usedRoutes === undefined ||
|
|
534
|
-
channelBaseGCDetails.usedRoutes.length === 0) {
|
|
535
|
-
channelBaseGCDetails.usedRoutes = [""];
|
|
536
|
-
}
|
|
537
|
-
return channelBaseGCDetails;
|
|
538
|
-
}
|
|
539
510
|
/**
|
|
540
511
|
* Returns a summary at the current sequence number.
|
|
541
512
|
* @param fullTree - true to bypass optimizations and force a full summary tree
|
|
@@ -751,6 +722,34 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
751
722
|
throw new LoggingError("Runtime is closed");
|
|
752
723
|
}
|
|
753
724
|
}
|
|
725
|
+
/**
|
|
726
|
+
* Summarizer client should not have local changes. These changes can become part of the summary and can break
|
|
727
|
+
* eventual consistency. For example, the next summary (say at ref seq# 100) may contain these changes whereas
|
|
728
|
+
* other clients that are up-to-date till seq# 100 may not have them yet.
|
|
729
|
+
*/
|
|
730
|
+
identifyLocalChangeInSummarizer(eventName, channelId, channelType) {
|
|
731
|
+
if (this.clientDetails.type !== "summarizer" || this.localChangesTelemetryCount <= 0) {
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
// Log a telemetry if there are local changes in the summarizer. This will give us data on how often
|
|
735
|
+
// this is happening and which data stores do this. The eventual goal is to disallow local changes
|
|
736
|
+
// in the summarizer and the data will help us plan this.
|
|
737
|
+
this.mc.logger.sendTelemetryEvent({
|
|
738
|
+
eventName,
|
|
739
|
+
channelType,
|
|
740
|
+
channelId: {
|
|
741
|
+
value: channelId,
|
|
742
|
+
tag: TelemetryDataTag.CodeArtifact,
|
|
743
|
+
},
|
|
744
|
+
fluidDataStoreId: {
|
|
745
|
+
value: this.id,
|
|
746
|
+
tag: TelemetryDataTag.CodeArtifact,
|
|
747
|
+
},
|
|
748
|
+
fluidDataStorePackagePath: packagePathToTelemetryProperty(this.dataStoreContext.packagePath),
|
|
749
|
+
stack: generateStack(),
|
|
750
|
+
});
|
|
751
|
+
this.localChangesTelemetryCount--;
|
|
752
|
+
}
|
|
754
753
|
}
|
|
755
754
|
/**
|
|
756
755
|
* Mixin class that adds request handler to FluidDataStoreRuntime
|