@fluidframework/runtime-utils 2.0.0-internal.3.0.0 → 2.0.0-internal.3.0.2

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.
Files changed (54) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/packageVersion.d.ts +1 -1
  5. package/dist/packageVersion.js +1 -1
  6. package/dist/packageVersion.js.map +1 -1
  7. package/dist/summarizerNode/index.d.ts +1 -1
  8. package/dist/summarizerNode/index.d.ts.map +1 -1
  9. package/dist/summarizerNode/index.js.map +1 -1
  10. package/dist/summarizerNode/summarizerNode.d.ts +5 -6
  11. package/dist/summarizerNode/summarizerNode.d.ts.map +1 -1
  12. package/dist/summarizerNode/summarizerNode.js +31 -14
  13. package/dist/summarizerNode/summarizerNode.js.map +1 -1
  14. package/dist/summarizerNode/summarizerNodeUtils.d.ts +14 -5
  15. package/dist/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  16. package/dist/summarizerNode/summarizerNodeUtils.js.map +1 -1
  17. package/dist/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  18. package/dist/summarizerNode/summarizerNodeWithGc.js +7 -5
  19. package/dist/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  20. package/dist/summaryUtils.d.ts +4 -0
  21. package/dist/summaryUtils.d.ts.map +1 -1
  22. package/dist/summaryUtils.js +9 -0
  23. package/dist/summaryUtils.js.map +1 -1
  24. package/lib/index.d.ts +1 -1
  25. package/lib/index.d.ts.map +1 -1
  26. package/lib/index.js.map +1 -1
  27. package/lib/packageVersion.d.ts +1 -1
  28. package/lib/packageVersion.js +1 -1
  29. package/lib/packageVersion.js.map +1 -1
  30. package/lib/summarizerNode/index.d.ts +1 -1
  31. package/lib/summarizerNode/index.d.ts.map +1 -1
  32. package/lib/summarizerNode/index.js.map +1 -1
  33. package/lib/summarizerNode/summarizerNode.d.ts +5 -6
  34. package/lib/summarizerNode/summarizerNode.d.ts.map +1 -1
  35. package/lib/summarizerNode/summarizerNode.js +31 -14
  36. package/lib/summarizerNode/summarizerNode.js.map +1 -1
  37. package/lib/summarizerNode/summarizerNodeUtils.d.ts +14 -5
  38. package/lib/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  39. package/lib/summarizerNode/summarizerNodeUtils.js.map +1 -1
  40. package/lib/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  41. package/lib/summarizerNode/summarizerNodeWithGc.js +7 -5
  42. package/lib/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  43. package/lib/summaryUtils.d.ts +4 -0
  44. package/lib/summaryUtils.d.ts.map +1 -1
  45. package/lib/summaryUtils.js +9 -0
  46. package/lib/summaryUtils.js.map +1 -1
  47. package/package.json +22 -14
  48. package/src/index.ts +1 -0
  49. package/src/packageVersion.ts +1 -1
  50. package/src/summarizerNode/index.ts +5 -1
  51. package/src/summarizerNode/summarizerNode.ts +40 -15
  52. package/src/summarizerNode/summarizerNodeUtils.ts +15 -5
  53. package/src/summarizerNode/summarizerNodeWithGc.ts +7 -5
  54. package/src/summaryUtils.ts +14 -0
@@ -1 +1 @@
1
- {"version":3,"file":"summarizerNodeWithGc.js","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNodeWithGc.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAAmE;AACnE,yEAAwI;AAExI,6EAW6C;AAE7C,qDAAkD;AAClD,+DAO+B;AAI/B,wDAAwD;AACxD,MAAM,iBAAkB,SAAQ,iCAAW;IACvC,YACoB,oBAA4B,EAC5C,OAKC;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QARC,yBAAoB,GAApB,oBAAoB,CAAQ;IAShD,CAAC;CACJ;AAED;;;;;;;;;;;;GAYG;AACH,MAAa,oBAAqB,SAAQ,+BAAc;IAuBpD;;;OAGG;IACH,YACI,MAAwB,EACP,WAIqB,EACtC,MAAmC,EACnC,oBAA4B;IAC5B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uBAAuB,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iCAAW,CAAC,aAAa,CAAC,uBAAuB,CAAC,EACtG,SAAS,CAAC,oBAAoB,EAC9B,SAAS,CAAC,sBAAsB,EAChC,WAAW,EACX,kBAAkB,CACrB,CAAC;AAlBW,QAAA,8BAA8B,kCAkBzC","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, LazyPromise } from \"@fluidframework/common-utils\";\nimport { cloneGCData, getGCDataFromSnapshot, runGarbageCollection, unpackChildNodesGCDetails } from \"@fluidframework/garbage-collector\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n CreateChildSummarizerNodeParam,\n gcTreeKey,\n IGarbageCollectionData,\n IGarbageCollectionDetailsBase,\n ISummarizeInternalResult,\n ISummarizeResult,\n ISummarizerNodeConfigWithGC,\n ISummarizerNodeWithGC,\n SummarizeInternalFn,\n ITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { ReadAndParseBlob } from \"../utils\";\nimport { SummarizerNode } from \"./summarizerNode\";\nimport {\n EscapedPath,\n ICreateChildDetails,\n IInitialSummary,\n ISummarizerNodeRootContract,\n parseSummaryForSubtrees,\n SummaryNode,\n} from \"./summarizerNodeUtils\";\n\nexport interface IRootSummarizerNodeWithGC extends ISummarizerNodeWithGC, ISummarizerNodeRootContract {}\n\n// Extend SummaryNode to add used routes tracking to it.\nclass SummaryNodeWithGC extends SummaryNode {\n constructor(\n public readonly serializedUsedRoutes: string,\n summary: {\n readonly referenceSequenceNumber: number;\n readonly basePath: EscapedPath | undefined;\n readonly localPath: EscapedPath;\n additionalPath?: EscapedPath;\n },\n ) {\n super(summary);\n }\n}\n\n/**\n * Extends the functionality of SummarizerNode to manage this node's garbage collection data:\n *\n * - Adds a new API `getGCData` to return GC data of this node.\n *\n * - Caches the result of `getGCData` to be used if nothing changes between summaries.\n *\n * - Manages the used routes of this node. These are used to identify if this node is referenced in the document\n * and to determine if the node's used state changed since last summary.\n *\n * - Adds trackState param to summarize. If trackState is false, it bypasses the SummarizerNode and calls\n * directly into summarizeInternal method.\n */\nexport class SummarizerNodeWithGC extends SummarizerNode implements IRootSummarizerNodeWithGC {\n // Tracks the work-in-progress used routes during summary.\n private wipSerializedUsedRoutes: string | undefined;\n\n // This is the last known used routes of this node as seen by the server as part of a summary.\n private referenceUsedRoutes: string[] | undefined;\n\n // The base GC details of this node used to initialize the GC state.\n private readonly baseGCDetailsP: LazyPromise<IGarbageCollectionDetailsBase>;\n\n // Keeps track of whether we have loaded the base details to ensure that we on;y do it once.\n private baseGCDetailsLoaded: boolean = false;\n\n private gcData: IGarbageCollectionData | undefined;\n\n // Set used routes to have self route by default. This makes the node referenced by default. This is done to ensure\n // that this node is not marked as collected when running GC has been disabled. Once, the option to disable GC is\n // removed (from runGC flag in IContainerRuntimeOptions), this should be changed to be have no routes by default.\n private usedRoutes: string[] = [\"\"];\n\n // True if GC is disabled for this node. If so, do not track GC specific state for a summary.\n private readonly gcDisabled: boolean;\n\n /**\n * Do not call constructor directly.\n * Use createRootSummarizerNodeWithGC to create root node, or createChild to create child nodes.\n */\n public constructor(\n logger: ITelemetryLogger,\n private readonly summarizeFn: (\n fullTree: boolean,\n trackState: boolean,\n telemetryContext?: ITelemetryContext,\n ) => Promise<ISummarizeInternalResult>,\n config: ISummarizerNodeConfigWithGC,\n changeSequenceNumber: number,\n /** Undefined means created without summary */\n latestSummary?: SummaryNode,\n initialSummary?: IInitialSummary,\n wipSummaryLogger?: ITelemetryLogger,\n private readonly getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getBaseGCDetailsFn?: () => Promise<IGarbageCollectionDetailsBase>,\n ) {\n super(\n logger,\n async (fullTree: boolean, _trackState: boolean, telemetryContext?: ITelemetryContext) =>\n summarizeFn(fullTree, true /* trackState */, telemetryContext),\n config,\n changeSequenceNumber,\n latestSummary,\n initialSummary,\n wipSummaryLogger,\n );\n\n this.gcDisabled = config.gcDisabled === true;\n\n this.baseGCDetailsP = new LazyPromise(async () => {\n return (await getBaseGCDetailsFn?.()) ?? { usedRoutes: [] };\n });\n }\n\n /**\n * Loads state from this node's initial GC summary details. This contains the following data from the last summary\n * seen by the server for this client:\n * - usedRoutes: This is used to figure out if the used state of this node changed since last summary.\n * - gcData: The garbage collection data of this node that is required for running GC.\n */\n private async loadBaseGCDetails() {\n if (this.baseGCDetailsLoaded) {\n return;\n }\n const baseGCDetails = await this.baseGCDetailsP;\n\n // Possible race - If there were parallel calls to loadBaseGCDetails, we want to make sure that we update\n // the state from the base details only once.\n if (this.baseGCDetailsLoaded) {\n return;\n }\n this.baseGCDetailsLoaded = true;\n\n // Update GC data, used routes and reference used routes. The used routes are sorted because they are compared\n // across GC runs to check if they changed. Sorting ensures that the elements are in the same order.\n // If the GC details has GC data, initialize our GC data from it.\n if (baseGCDetails.gcData !== undefined) {\n this.gcData = cloneGCData(baseGCDetails.gcData);\n }\n if (baseGCDetails.usedRoutes !== undefined) {\n this.usedRoutes = Array.from(baseGCDetails.usedRoutes).sort();\n this.referenceUsedRoutes = Array.from(baseGCDetails.usedRoutes).sort()\n }\n }\n\n public async summarize(\n fullTree: boolean,\n trackState: boolean = true,\n telemetryContext?: ITelemetryContext,\n ): Promise<ISummarizeResult> {\n // If GC is not disabled and we are tracking a summary, GC should have run and updated the used routes for this\n // summary by calling updateUsedRoutes which sets wipSerializedUsedRoutes.\n if (!this.gcDisabled && this.isTrackingInProgress()) {\n assert(this.wipSerializedUsedRoutes !== undefined,\n 0x1b1 /* \"wip used routes should be set if tracking a summary\" */);\n }\n\n // If trackState is true, get summary from base summarizer node which tracks summary state.\n // If trackState is false, get summary from summarizeInternal.\n return trackState\n ? super.summarize(fullTree, true /* trackState */, telemetryContext)\n : this.summarizeFn(fullTree, trackState, telemetryContext);\n }\n\n /**\n * Returns the GC data of this node. If nothing has changed since last summary, it tries to reuse the data from\n * the previous summary. Else, it gets new GC data from the underlying Fluid object.\n * @param fullGC - true to bypass optimizations and force full generation of GC data.\n */\n public async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n assert(!this.gcDisabled, 0x1b2 /* \"Getting GC data should not be called when GC is disabled!\" */);\n assert(this.getGCDataFn !== undefined, 0x1b3 /* \"GC data cannot be retrieved without getGCDataFn\" */);\n\n // Load GC details from the initial summary, if not already loaded. If this is the first time this function is\n // called and the node's data has not changed since last summary, the GC data in initial details is returned.\n await this.loadBaseGCDetails();\n\n // If there is no new data since last summary and we have GC data from the previous run, return it. The previous\n // GC data may not be available if loaded from a snapshot with either GC disabled or before GC was added.\n // Note - canReuseHandle is checked to be consistent with summarize - generate GC data for nodes for which\n // summary must be generated.\n if (this.canReuseHandle && !fullGC && !this.hasDataChanged() && this.gcData !== undefined) {\n return cloneGCData(this.gcData);\n }\n\n const gcData = await this.getGCDataFn(fullGC);\n this.gcData = cloneGCData(gcData);\n return gcData;\n }\n\n /**\n * Called during the start of a summary. Updates the work-in-progress used routes.\n */\n public startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLogger) {\n // If GC is disabled, skip setting wip used routes since we should not track GC state.\n if (!this.gcDisabled) {\n assert(\n this.wipSerializedUsedRoutes === undefined,\n 0x1b4 /* \"We should not already be tracking used routes when to track a new summary\" */);\n }\n super.startSummary(referenceSequenceNumber, summaryLogger);\n }\n\n /**\n * Called after summary has been uploaded to the server. Add the work-in-progress state to the pending\n * summary queue. We track this until we get an ack from the server for this summary.\n */\n protected completeSummaryCore(\n proposalHandle: string,\n parentPath: EscapedPath | undefined,\n parentSkipRecursion: boolean,\n ) {\n let wipSerializedUsedRoutes: string | undefined;\n // If GC is disabled, don't set wip used routes.\n if (!this.gcDisabled) {\n wipSerializedUsedRoutes = this.wipSerializedUsedRoutes;\n assert(wipSerializedUsedRoutes !== undefined, 0x1b5 /* \"We should have been tracking used routes\" */);\n }\n\n super.completeSummaryCore(proposalHandle, parentPath, parentSkipRecursion);\n\n // If GC is disabled, skip setting pending summary with GC state.\n if (!this.gcDisabled) {\n const summaryNode = this.pendingSummaries.get(proposalHandle);\n if (summaryNode !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const summaryNodeWithGC = new SummaryNodeWithGC(wipSerializedUsedRoutes!, summaryNode);\n this.pendingSummaries.set(proposalHandle, summaryNodeWithGC);\n }\n }\n }\n\n /**\n * Clears the work-in-progress state.\n */\n public clearSummary() {\n this.wipSerializedUsedRoutes = undefined;\n super.clearSummary();\n }\n\n /**\n * Called when we get an ack from the server for a summary we sent. Update the reference state of this node\n * from the state in the pending summary queue.\n */\n protected refreshLatestSummaryFromPending(\n proposalHandle: string,\n referenceSequenceNumber: number,\n ): void {\n // If GC is disabled, skip setting referenced used routes since we are not tracking GC state.\n if (!this.gcDisabled) {\n const summaryNode = this.pendingSummaries.get(proposalHandle) as SummaryNodeWithGC;\n if (summaryNode?.serializedUsedRoutes !== undefined) {\n this.referenceUsedRoutes = JSON.parse(summaryNode.serializedUsedRoutes);\n }\n }\n\n return super.refreshLatestSummaryFromPending(proposalHandle, referenceSequenceNumber);\n }\n\n /**\n * Called when we need to upload the reference state from the given summary.\n */\n protected async refreshLatestSummaryFromSnapshot(\n referenceSequenceNumber: number,\n snapshotTree: ISnapshotTree,\n basePath: EscapedPath | undefined,\n localPath: EscapedPath,\n correlatedSummaryLogger: ITelemetryLogger,\n readAndParseBlob: ReadAndParseBlob,\n ): Promise<void> {\n await this.refreshGCStateFromSnapshot(referenceSequenceNumber, snapshotTree, readAndParseBlob);\n return super.refreshLatestSummaryFromSnapshot(\n referenceSequenceNumber,\n snapshotTree,\n basePath,\n localPath,\n correlatedSummaryLogger,\n readAndParseBlob,\n );\n }\n\n /**\n * Updates GC state from the given snapshot if GC is enabled and the snapshot is newer than the one this node\n * is tracking.\n */\n private async refreshGCStateFromSnapshot(\n referenceSequenceNumber: number,\n snapshotTree: ISnapshotTree,\n readAndParseBlob: ReadAndParseBlob,\n ): Promise<void> {\n // If GC is disabled or we have seen a newer summary, skip updating GC state.\n if (this.gcDisabled || this.referenceSequenceNumber >= referenceSequenceNumber) {\n return;\n }\n\n // Load the base GC details before proceeding because if that happens later it can overwrite the GC details\n // written by the following code.\n await this.loadBaseGCDetails();\n\n // Possible re-entrancy. We may already have processed this while loading base GC details.\n if (this.referenceSequenceNumber >= referenceSequenceNumber) {\n return;\n }\n\n /**\n * GC data is written at root of the snapshot tree under \"gc\" sub-tree. This data needs to be propagated to\n * all the nodes in the container.\n * The root summarizer node reads the GC data from the \"gc\" sub-tree, runs GC on it to get used routes in\n * the container and updates its GC data and referenced used routes. It then gets the GC data and used\n * routes of all its children and adds it to their snapshot tree.\n * All the other nodes gets the GC data and used routes from their snapshot tree and updates their state.\n * They get the GC data and used routes of their children and add it to their snapshot tree and so on.\n *\n * Note that if the snapshot does not have GC tree, GC data will be set to undefined and used routes will be\n * set to self-route (meaning referenced) for all nodes. This is important because the GC data needs to be\n * regenerated in the next summary.\n */\n let gcDetails: IGarbageCollectionDetailsBase | undefined;\n const gcSnapshotTree = snapshotTree.trees[gcTreeKey];\n if (gcSnapshotTree !== undefined) {\n // If there is a GC tree in the snapshot, this is the root summarizer node. Read GC data from the tree\n // process it as explained above.\n const gcSnapshotData = await getGCDataFromSnapshot(gcSnapshotTree, readAndParseBlob);\n\n const gcNodes: { [id: string]: string[]; } = {};\n for (const [nodeId, nodeData] of Object.entries(gcSnapshotData.gcState.gcNodes)) {\n gcNodes[nodeId] = Array.from(nodeData.outboundRoutes);\n }\n // Run GC on the nodes in the snapshot to get the used routes for each node in the container.\n const usedRoutes = runGarbageCollection(gcNodes, [\"/\"]).referencedNodeIds;\n gcDetails = { gcData: { gcNodes }, usedRoutes };\n } else {\n // If there is a GC blob in the snapshot, it's a non-root summarizer nodes - The root summarizer node\n // writes GC blob in the snapshot of child nodes. Get GC data and used routes from the blob.\n const gcDetailsBlob = snapshotTree.blobs[gcTreeKey];\n if (gcDetailsBlob !== undefined) {\n gcDetails = JSON.parse(gcDetailsBlob) as IGarbageCollectionDetailsBase;\n }\n }\n\n // Update this node to the same GC state it was when the ack corresponding to this summary was processed.\n this.gcData = gcDetails?.gcData !== undefined ? cloneGCData(gcDetails.gcData) : undefined;\n this.referenceUsedRoutes = gcDetails?.usedRoutes !== undefined ? Array.from(gcDetails.usedRoutes) : undefined;\n // If there are no used routes in the GC details, set it to have self route which will make the node\n // referenced. This scenario can only happen if the snapshot is from a client where GC was not run or\n // disabled. In both the cases, the node should be referenced.\n this.usedRoutes = gcDetails?.usedRoutes !== undefined ? Array.from(gcDetails.usedRoutes) : [\"\"];\n\n if (gcDetails === undefined) {\n return;\n }\n\n // Generate the GC data and used routes of children GC nodes and add it to their snapshot tree.\n const gcDetailsMap = unpackChildNodesGCDetails(gcDetails);\n const { childrenTree } = parseSummaryForSubtrees(snapshotTree);\n gcDetailsMap.forEach((childGCDetails: IGarbageCollectionDetailsBase, childId: string) => {\n childrenTree.trees[childId].blobs[gcTreeKey] = JSON.stringify(childGCDetails);\n });\n }\n\n /**\n * Override the createChild method to return an instance of SummarizerNodeWithGC.\n */\n public createChild(\n /** Summarize function */\n summarizeInternalFn: SummarizeInternalFn,\n /** Initial id or path part of this node */\n id: string,\n /**\n * Information needed to create the node.\n * If it is from a base summary, it will assert that a summary has been seen.\n * Attach information if it is created from an attach op.\n */\n createParam: CreateChildSummarizerNodeParam,\n config: ISummarizerNodeConfigWithGC = {},\n getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getBaseGCDetailsFn?: () => Promise<IGarbageCollectionDetailsBase>,\n ): ISummarizerNodeWithGC {\n assert(!this.children.has(id), 0x1b6 /* \"Create SummarizerNode child already exists\" */);\n\n /**\n * Update the child node's base GC details from this node's current GC details instead of updating from the base\n * GC details of this node. This will handle scenarios where the GC details was updated during refresh from\n * snapshot and the child node wasn't created then. If a child is created after that, its GC details should be\n * the one from the downloaded snapshot and not the base GC details.\n */\n const getChildBaseGCDetailsP = new LazyPromise<IGarbageCollectionDetailsBase>(async () => {\n // Ensure that the base GC details is loaded because a child can be created before GC runs which is when\n // base GC details is usually loaded.\n await this.loadBaseGCDetails();\n const childBaseGCDetails = unpackChildNodesGCDetails({ gcData: this.gcData, usedRoutes: this.usedRoutes });\n return childBaseGCDetails.get(id) ?? {};\n });\n\n const createDetails: ICreateChildDetails = this.getCreateDetailsForChild(id, createParam);\n const child = new SummarizerNodeWithGC(\n this.defaultLogger,\n summarizeInternalFn,\n {\n ...config,\n // Propagate our gcDisabled state to the child if its not explicity specified in child's config.\n gcDisabled: config.gcDisabled ?? this.gcDisabled,\n },\n createDetails.changeSequenceNumber,\n createDetails.latestSummary,\n createDetails.initialSummary,\n this.wipSummaryLogger,\n getGCDataFn,\n async () => getChildBaseGCDetailsP,\n );\n\n // There may be additional state that has to be updated in this child. For example, if a summary is being\n // tracked, the child's summary tracking state needs to be updated too.\n this.maybeUpdateChildState(child);\n\n this.children.set(id, child);\n return child;\n }\n\n /**\n * Deletes the child node with the given id.\n */\n public deleteChild(id: string): void {\n this.children.delete(id);\n }\n\n /**\n * Override the getChild method to return an instance of SummarizerNodeWithGC.\n */\n public getChild(id: string): ISummarizerNodeWithGC | undefined {\n return this.children.get(id) as SummarizerNodeWithGC;\n }\n\n public isReferenced(): boolean {\n return this.usedRoutes.includes(\"\") || this.usedRoutes.includes(\"/\");\n }\n\n public updateUsedRoutes(usedRoutes: string[]) {\n // Sort the given routes before updating. This will ensure that the routes compared in hasUsedStateChanged()\n // are in the same order.\n this.usedRoutes = usedRoutes.sort();\n\n // If GC is not disabled and we are tracking a summary, update the work-in-progress used routes so that it can\n // be tracked for this summary.\n if (!this.gcDisabled && this.isTrackingInProgress()) {\n this.wipSerializedUsedRoutes = JSON.stringify(this.usedRoutes);\n }\n }\n\n /**\n * Override the hasChanged method. If this node data or its used state changed, the node is considered changed.\n */\n protected hasChanged(): boolean {\n return this.hasDataChanged() || this.hasUsedStateChanged();\n }\n\n /**\n * This tells whether the data in this node has changed or not.\n */\n private hasDataChanged(): boolean {\n return super.hasChanged();\n }\n\n /**\n * This tells whether the used state of this node has changed since last successful summary. If the used routes\n * of this node changed, its used state is considered changed. Basically, if this node or any of its child nodes\n * was previously used and became unused (or vice versa), its used state has changed.\n */\n private hasUsedStateChanged(): boolean {\n // If GC is disabled, we are not tracking used state, return false.\n if (this.gcDisabled) {\n return false;\n }\n\n return this.referenceUsedRoutes === undefined ||\n JSON.stringify(this.usedRoutes) !== JSON.stringify(this.referenceUsedRoutes);\n }\n}\n\n/**\n * Creates a root summarizer node with GC functionality built-in.\n * @param logger - Logger to use within SummarizerNode\n * @param summarizeInternalFn - Function to generate summary\n * @param changeSequenceNumber - Sequence number of latest change to new node/subtree\n * @param referenceSequenceNumber - Reference sequence number of last acked summary,\n * or undefined if not loaded from summary\n * @param config - Configure behavior of summarizer node\n * @param getGCDataFn - Function to get the GC data of this node\n * @param baseGCDetailsP - Function to get the initial GC details of this node\n */\nexport const createRootSummarizerNodeWithGC = (\n logger: ITelemetryLogger,\n summarizeInternalFn: SummarizeInternalFn,\n changeSequenceNumber: number,\n referenceSequenceNumber: number | undefined,\n config: ISummarizerNodeConfigWithGC = {},\n getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getBaseGCDetailsFn?: () => Promise<IGarbageCollectionDetailsBase>,\n): IRootSummarizerNodeWithGC => new SummarizerNodeWithGC(\n logger,\n summarizeInternalFn,\n config,\n changeSequenceNumber,\n referenceSequenceNumber === undefined ? undefined : SummaryNode.createForRoot(referenceSequenceNumber),\n undefined /* initialSummary */,\n undefined /* wipSummaryLogger */,\n getGCDataFn,\n getBaseGCDetailsFn,\n);\n"]}
1
+ {"version":3,"file":"summarizerNodeWithGc.js","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNodeWithGc.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAAmE;AACnE,yEAAwI;AAExI,6EAW6C;AA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AmB,KAAK,SAAS;YACzC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IACrF,CAAC;CACJ;AA1aD,oDA0aC;AAED;;;;;;;;;;GAUG;AACI,MAAM,8BAA8B,GAAG,CAC1C,MAAwB,EACxB,mBAAwC,EACxC,oBAA4B,EAC5B,uBAA2C,EAC3C,SAAsC,EAAE,EACxC,WAAmE,EACnE,kBAAiE,EACxC,EAAE,CAAC,IAAI,oBAAoB,CACpD,MAAM,EACN,mBAAmB,EACnB,MAAM,EACN,oBAAoB,EACpB,uBAAuB,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iCAAW,CAAC,aAAa,CAAC,uBAAuB,CAAC,EACtG,SAAS,CAAC,oBAAoB,EAC9B,SAAS,CAAC,sBAAsB,EAChC,WAAW,EACX,kBAAkB,CACrB,CAAC;AAlBW,QAAA,8BAA8B,kCAkBzC","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, LazyPromise } from \"@fluidframework/common-utils\";\nimport { cloneGCData, getGCDataFromSnapshot, runGarbageCollection, unpackChildNodesGCDetails } from \"@fluidframework/garbage-collector\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n CreateChildSummarizerNodeParam,\n gcTreeKey,\n IGarbageCollectionData,\n IGarbageCollectionDetailsBase,\n ISummarizeInternalResult,\n ISummarizeResult,\n ISummarizerNodeConfigWithGC,\n ISummarizerNodeWithGC,\n SummarizeInternalFn,\n ITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { ReadAndParseBlob } from \"../utils\";\nimport { SummarizerNode } from \"./summarizerNode\";\nimport {\n EscapedPath,\n ICreateChildDetails,\n IInitialSummary,\n ISummarizerNodeRootContract,\n parseSummaryForSubtrees,\n SummaryNode,\n} from \"./summarizerNodeUtils\";\n\nexport interface IRootSummarizerNodeWithGC extends ISummarizerNodeWithGC, ISummarizerNodeRootContract {}\n\n// Extend SummaryNode to add used routes tracking to it.\nclass SummaryNodeWithGC extends SummaryNode {\n constructor(\n public readonly serializedUsedRoutes: string,\n summary: {\n readonly referenceSequenceNumber: number;\n readonly basePath: EscapedPath | undefined;\n readonly localPath: EscapedPath;\n additionalPath?: EscapedPath;\n },\n ) {\n super(summary);\n }\n}\n\n/**\n * Extends the functionality of SummarizerNode to manage this node's garbage collection data:\n *\n * - Adds a new API `getGCData` to return GC data of this node.\n *\n * - Caches the result of `getGCData` to be used if nothing changes between summaries.\n *\n * - Manages the used routes of this node. These are used to identify if this node is referenced in the document\n * and to determine if the node's used state changed since last summary.\n *\n * - Adds trackState param to summarize. If trackState is false, it bypasses the SummarizerNode and calls\n * directly into summarizeInternal method.\n */\nexport class SummarizerNodeWithGC extends SummarizerNode implements IRootSummarizerNodeWithGC {\n // Tracks the work-in-progress used routes during summary.\n private wipSerializedUsedRoutes: string | undefined;\n\n // This is the last known used routes of this node as seen by the server as part of a summary.\n private referenceUsedRoutes: string[] | undefined;\n\n // The base GC details of this node used to initialize the GC state.\n private readonly baseGCDetailsP: LazyPromise<IGarbageCollectionDetailsBase>;\n\n // Keeps track of whether we have loaded the base details to ensure that we on;y do it once.\n private baseGCDetailsLoaded: boolean = false;\n\n private gcData: IGarbageCollectionData | undefined;\n\n // Set used routes to have self route by default. This makes the node referenced by default. This is done to ensure\n // that this node is not marked as collected when running GC has been disabled. Once, the option to disable GC is\n // removed (from runGC flag in IContainerRuntimeOptions), this should be changed to be have no routes by default.\n private usedRoutes: string[] = [\"\"];\n\n // True if GC is disabled for this node. If so, do not track GC specific state for a summary.\n private readonly gcDisabled: boolean;\n\n /**\n * Do not call constructor directly.\n * Use createRootSummarizerNodeWithGC to create root node, or createChild to create child nodes.\n */\n public constructor(\n logger: ITelemetryLogger,\n private readonly summarizeFn: (\n fullTree: boolean,\n trackState: boolean,\n telemetryContext?: ITelemetryContext,\n ) => Promise<ISummarizeInternalResult>,\n config: ISummarizerNodeConfigWithGC,\n changeSequenceNumber: number,\n /** Undefined means created without summary */\n latestSummary?: SummaryNode,\n initialSummary?: IInitialSummary,\n wipSummaryLogger?: ITelemetryLogger,\n private readonly getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getBaseGCDetailsFn?: () => Promise<IGarbageCollectionDetailsBase>,\n ) {\n super(\n logger,\n async (fullTree: boolean, _trackState: boolean, telemetryContext?: ITelemetryContext) =>\n summarizeFn(fullTree, true /* trackState */, telemetryContext),\n config,\n changeSequenceNumber,\n latestSummary,\n initialSummary,\n wipSummaryLogger,\n );\n\n this.gcDisabled = config.gcDisabled === true;\n\n this.baseGCDetailsP = new LazyPromise(async () => {\n return (await getBaseGCDetailsFn?.()) ?? { usedRoutes: [] };\n });\n }\n\n /**\n * Loads state from this node's initial GC summary details. This contains the following data from the last summary\n * seen by the server for this client:\n * - usedRoutes: This is used to figure out if the used state of this node changed since last summary.\n * - gcData: The garbage collection data of this node that is required for running GC.\n */\n private async loadBaseGCDetails() {\n if (this.baseGCDetailsLoaded) {\n return;\n }\n const baseGCDetails = await this.baseGCDetailsP;\n\n // Possible race - If there were parallel calls to loadBaseGCDetails, we want to make sure that we update\n // the state from the base details only once.\n if (this.baseGCDetailsLoaded) {\n return;\n }\n this.baseGCDetailsLoaded = true;\n\n // Update GC data, used routes and reference used routes. The used routes are sorted because they are compared\n // across GC runs to check if they changed. Sorting ensures that the elements are in the same order.\n // If the GC details has GC data, initialize our GC data from it.\n if (baseGCDetails.gcData !== undefined) {\n this.gcData = cloneGCData(baseGCDetails.gcData);\n }\n if (baseGCDetails.usedRoutes !== undefined) {\n this.usedRoutes = Array.from(baseGCDetails.usedRoutes).sort();\n this.referenceUsedRoutes = Array.from(baseGCDetails.usedRoutes).sort()\n }\n }\n\n public async summarize(\n fullTree: boolean,\n trackState: boolean = true,\n telemetryContext?: ITelemetryContext,\n ): Promise<ISummarizeResult> {\n // If GC is not disabled and a summary is in progress, GC should have run and updated the used routes for this\n // summary by calling updateUsedRoutes which sets wipSerializedUsedRoutes.\n if (!this.gcDisabled && this.isSummaryInProgress()) {\n assert(this.wipSerializedUsedRoutes !== undefined,\n 0x1b1 /* \"wip used routes should be set if tracking a summary\" */);\n }\n\n // If trackState is true, get summary from base summarizer node which tracks summary state.\n // If trackState is false, get summary from summarizeInternal.\n return trackState\n ? super.summarize(fullTree, true /* trackState */, telemetryContext)\n : this.summarizeFn(fullTree, trackState, telemetryContext);\n }\n\n /**\n * Returns the GC data of this node. If nothing has changed since last summary, it tries to reuse the data from\n * the previous summary. Else, it gets new GC data from the underlying Fluid object.\n * @param fullGC - true to bypass optimizations and force full generation of GC data.\n */\n public async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n assert(!this.gcDisabled, 0x1b2 /* \"Getting GC data should not be called when GC is disabled!\" */);\n assert(this.getGCDataFn !== undefined, 0x1b3 /* \"GC data cannot be retrieved without getGCDataFn\" */);\n\n // Load GC details from the initial summary, if not already loaded. If this is the first time this function is\n // called and the node's data has not changed since last summary, the GC data in initial details is returned.\n await this.loadBaseGCDetails();\n\n // If there is no new data since last summary and we have GC data from the previous run, return it. The previous\n // GC data may not be available if loaded from a snapshot with either GC disabled or before GC was added.\n // Note - canReuseHandle is checked to be consistent with summarize - generate GC data for nodes for which\n // summary must be generated.\n if (this.canReuseHandle && !fullGC && !this.hasDataChanged() && this.gcData !== undefined) {\n return cloneGCData(this.gcData);\n }\n\n const gcData = await this.getGCDataFn(fullGC);\n this.gcData = cloneGCData(gcData);\n return gcData;\n }\n\n /**\n * Called during the start of a summary. Updates the work-in-progress used routes.\n */\n public startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLogger) {\n // If GC is disabled, skip setting wip used routes since we should not track GC state.\n if (!this.gcDisabled) {\n assert(\n this.wipSerializedUsedRoutes === undefined,\n 0x1b4 /* \"We should not already be tracking used routes when to track a new summary\" */);\n }\n super.startSummary(referenceSequenceNumber, summaryLogger);\n }\n\n /**\n * Called after summary has been uploaded to the server. Add the work-in-progress state to the pending\n * summary queue. We track this until we get an ack from the server for this summary.\n */\n protected completeSummaryCore(\n proposalHandle: string,\n parentPath: EscapedPath | undefined,\n parentSkipRecursion: boolean,\n ) {\n let wipSerializedUsedRoutes: string | undefined;\n // If GC is disabled, don't set wip used routes.\n if (!this.gcDisabled) {\n wipSerializedUsedRoutes = this.wipSerializedUsedRoutes;\n assert(wipSerializedUsedRoutes !== undefined, 0x1b5 /* \"We should have been tracking used routes\" */);\n }\n\n super.completeSummaryCore(proposalHandle, parentPath, parentSkipRecursion);\n\n // If GC is disabled, skip setting pending summary with GC state.\n if (!this.gcDisabled) {\n const summaryNode = this.pendingSummaries.get(proposalHandle);\n if (summaryNode !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const summaryNodeWithGC = new SummaryNodeWithGC(wipSerializedUsedRoutes!, summaryNode);\n this.pendingSummaries.set(proposalHandle, summaryNodeWithGC);\n }\n }\n }\n\n /**\n * Clears the work-in-progress state.\n */\n public clearSummary() {\n this.wipSerializedUsedRoutes = undefined;\n super.clearSummary();\n }\n\n /**\n * Called when we get an ack from the server for a summary we sent. Update the reference state of this node\n * from the state in the pending summary queue.\n */\n protected refreshLatestSummaryFromPending(\n proposalHandle: string,\n referenceSequenceNumber: number,\n ): void {\n // If GC is disabled, skip setting referenced used routes since we are not tracking GC state.\n if (!this.gcDisabled) {\n const summaryNode = this.pendingSummaries.get(proposalHandle) as SummaryNodeWithGC;\n if (summaryNode?.serializedUsedRoutes !== undefined) {\n this.referenceUsedRoutes = JSON.parse(summaryNode.serializedUsedRoutes);\n }\n }\n\n return super.refreshLatestSummaryFromPending(proposalHandle, referenceSequenceNumber);\n }\n\n /**\n * Called when we need to upload the reference state from the given summary.\n */\n protected async refreshLatestSummaryFromSnapshot(\n referenceSequenceNumber: number,\n snapshotTree: ISnapshotTree,\n basePath: EscapedPath | undefined,\n localPath: EscapedPath,\n correlatedSummaryLogger: ITelemetryLogger,\n readAndParseBlob: ReadAndParseBlob,\n ): Promise<void> {\n await this.refreshGCStateFromSnapshot(referenceSequenceNumber, snapshotTree, readAndParseBlob);\n return super.refreshLatestSummaryFromSnapshot(\n referenceSequenceNumber,\n snapshotTree,\n basePath,\n localPath,\n correlatedSummaryLogger,\n readAndParseBlob,\n );\n }\n\n /**\n * Updates GC state from the given snapshot if GC is enabled and the snapshot is newer than the one this node\n * is tracking.\n */\n private async refreshGCStateFromSnapshot(\n referenceSequenceNumber: number,\n snapshotTree: ISnapshotTree,\n readAndParseBlob: ReadAndParseBlob,\n ): Promise<void> {\n // If GC is disabled or we have seen a newer summary, skip updating GC state.\n if (this.gcDisabled || this.referenceSequenceNumber >= referenceSequenceNumber) {\n return;\n }\n\n // Load the base GC details before proceeding because if that happens later it can overwrite the GC details\n // written by the following code.\n await this.loadBaseGCDetails();\n\n // Possible re-entrancy. We may already have processed this while loading base GC details.\n if (this.referenceSequenceNumber >= referenceSequenceNumber) {\n return;\n }\n\n /**\n * GC data is written at root of the snapshot tree under \"gc\" sub-tree. This data needs to be propagated to\n * all the nodes in the container.\n * The root summarizer node reads the GC data from the \"gc\" sub-tree, runs GC on it to get used routes in\n * the container and updates its GC data and referenced used routes. It then gets the GC data and used\n * routes of all its children and adds it to their snapshot tree.\n * All the other nodes gets the GC data and used routes from their snapshot tree and updates their state.\n * They get the GC data and used routes of their children and add it to their snapshot tree and so on.\n *\n * Note that if the snapshot does not have GC tree, GC data will be set to undefined and used routes will be\n * set to self-route (meaning referenced) for all nodes. This is important because the GC data needs to be\n * regenerated in the next summary.\n */\n let gcDetails: IGarbageCollectionDetailsBase | undefined;\n const gcSnapshotTree = snapshotTree.trees[gcTreeKey];\n if (gcSnapshotTree !== undefined) {\n // If there is a GC tree in the snapshot, this is the root summarizer node. Read GC data from the tree\n // process it as explained above.\n const gcSnapshotData = await getGCDataFromSnapshot(gcSnapshotTree, readAndParseBlob);\n\n const gcNodes: { [id: string]: string[]; } = {};\n for (const [nodeId, nodeData] of Object.entries(gcSnapshotData.gcState.gcNodes)) {\n gcNodes[nodeId] = Array.from(nodeData.outboundRoutes);\n }\n // Run GC on the nodes in the snapshot to get the used routes for each node in the container.\n const usedRoutes = runGarbageCollection(gcNodes, [\"/\"]).referencedNodeIds;\n gcDetails = { gcData: { gcNodes }, usedRoutes };\n } else {\n // If there is a GC blob in the snapshot, it's a non-root summarizer nodes - The root summarizer node\n // writes GC blob in the snapshot of child nodes. Get GC data and used routes from the blob.\n const gcDetailsBlob = snapshotTree.blobs[gcTreeKey];\n if (gcDetailsBlob !== undefined) {\n gcDetails = JSON.parse(gcDetailsBlob) as IGarbageCollectionDetailsBase;\n }\n }\n\n // Update this node to the same GC state it was when the ack corresponding to this summary was processed.\n this.gcData = gcDetails?.gcData !== undefined ? cloneGCData(gcDetails.gcData) : undefined;\n this.referenceUsedRoutes = gcDetails?.usedRoutes !== undefined ? Array.from(gcDetails.usedRoutes) : undefined;\n // If there are no used routes in the GC details, set it to have self route which will make the node\n // referenced. This scenario can only happen if the snapshot is from a client where GC was not run or\n // disabled. In both the cases, the node should be referenced.\n this.usedRoutes = gcDetails?.usedRoutes !== undefined ? Array.from(gcDetails.usedRoutes) : [\"\"];\n\n if (gcDetails === undefined) {\n return;\n }\n\n // Generate the GC data and used routes of children GC nodes and add it to their snapshot tree.\n const gcDetailsMap = unpackChildNodesGCDetails(gcDetails);\n const { childrenTree } = parseSummaryForSubtrees(snapshotTree);\n gcDetailsMap.forEach((childGCDetails: IGarbageCollectionDetailsBase, childId: string) => {\n if (childrenTree.trees[childId] !== undefined) {\n childrenTree.trees[childId].blobs[gcTreeKey] = JSON.stringify(childGCDetails);\n }\n });\n }\n\n /**\n * Override the createChild method to return an instance of SummarizerNodeWithGC.\n */\n public createChild(\n /** Summarize function */\n summarizeInternalFn: SummarizeInternalFn,\n /** Initial id or path part of this node */\n id: string,\n /**\n * Information needed to create the node.\n * If it is from a base summary, it will assert that a summary has been seen.\n * Attach information if it is created from an attach op.\n */\n createParam: CreateChildSummarizerNodeParam,\n config: ISummarizerNodeConfigWithGC = {},\n getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getBaseGCDetailsFn?: () => Promise<IGarbageCollectionDetailsBase>,\n ): ISummarizerNodeWithGC {\n assert(!this.children.has(id), 0x1b6 /* \"Create SummarizerNode child already exists\" */);\n\n /**\n * Update the child node's base GC details from this node's current GC details instead of updating from the base\n * GC details of this node. This will handle scenarios where the GC details was updated during refresh from\n * snapshot and the child node wasn't created then. If a child is created after that, its GC details should be\n * the one from the downloaded snapshot and not the base GC details.\n */\n const getChildBaseGCDetailsP = new LazyPromise<IGarbageCollectionDetailsBase>(async () => {\n // Ensure that the base GC details is loaded because a child can be created before GC runs which is when\n // base GC details is usually loaded.\n await this.loadBaseGCDetails();\n const childBaseGCDetails = unpackChildNodesGCDetails({ gcData: this.gcData, usedRoutes: this.usedRoutes });\n return childBaseGCDetails.get(id) ?? {};\n });\n\n const createDetails: ICreateChildDetails = this.getCreateDetailsForChild(id, createParam);\n const child = new SummarizerNodeWithGC(\n this.defaultLogger,\n summarizeInternalFn,\n {\n ...config,\n // Propagate our gcDisabled state to the child if its not explicity specified in child's config.\n gcDisabled: config.gcDisabled ?? this.gcDisabled,\n },\n createDetails.changeSequenceNumber,\n createDetails.latestSummary,\n createDetails.initialSummary,\n this.wipSummaryLogger,\n getGCDataFn,\n async () => getChildBaseGCDetailsP,\n );\n\n // There may be additional state that has to be updated in this child. For example, if a summary is being\n // tracked, the child's summary tracking state needs to be updated too.\n this.maybeUpdateChildState(child);\n\n this.children.set(id, child);\n return child;\n }\n\n /**\n * Deletes the child node with the given id.\n */\n public deleteChild(id: string): void {\n this.children.delete(id);\n }\n\n /**\n * Override the getChild method to return an instance of SummarizerNodeWithGC.\n */\n public getChild(id: string): ISummarizerNodeWithGC | undefined {\n return this.children.get(id) as SummarizerNodeWithGC;\n }\n\n public isReferenced(): boolean {\n return this.usedRoutes.includes(\"\") || this.usedRoutes.includes(\"/\");\n }\n\n public updateUsedRoutes(usedRoutes: string[]) {\n // Sort the given routes before updating. This will ensure that the routes compared in hasUsedStateChanged()\n // are in the same order.\n this.usedRoutes = usedRoutes.sort();\n\n // If GC is not disabled and a summary is in progress, update the work-in-progress used routes so that it can\n // be tracked for this summary.\n if (!this.gcDisabled && this.isSummaryInProgress()) {\n this.wipSerializedUsedRoutes = JSON.stringify(this.usedRoutes);\n }\n }\n\n /**\n * Override the hasChanged method. If this node data or its used state changed, the node is considered changed.\n */\n protected hasChanged(): boolean {\n return this.hasDataChanged() || this.hasUsedStateChanged();\n }\n\n /**\n * This tells whether the data in this node has changed or not.\n */\n private hasDataChanged(): boolean {\n return super.hasChanged();\n }\n\n /**\n * This tells whether the used state of this node has changed since last successful summary. If the used routes\n * of this node changed, its used state is considered changed. Basically, if this node or any of its child nodes\n * was previously used and became unused (or vice versa), its used state has changed.\n */\n private hasUsedStateChanged(): boolean {\n // If GC is disabled, we are not tracking used state, return false.\n if (this.gcDisabled) {\n return false;\n }\n\n return this.referenceUsedRoutes === undefined ||\n JSON.stringify(this.usedRoutes) !== JSON.stringify(this.referenceUsedRoutes);\n }\n}\n\n/**\n * Creates a root summarizer node with GC functionality built-in.\n * @param logger - Logger to use within SummarizerNode\n * @param summarizeInternalFn - Function to generate summary\n * @param changeSequenceNumber - Sequence number of latest change to new node/subtree\n * @param referenceSequenceNumber - Reference sequence number of last acked summary,\n * or undefined if not loaded from summary\n * @param config - Configure behavior of summarizer node\n * @param getGCDataFn - Function to get the GC data of this node\n * @param baseGCDetailsP - Function to get the initial GC details of this node\n */\nexport const createRootSummarizerNodeWithGC = (\n logger: ITelemetryLogger,\n summarizeInternalFn: SummarizeInternalFn,\n changeSequenceNumber: number,\n referenceSequenceNumber: number | undefined,\n config: ISummarizerNodeConfigWithGC = {},\n getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getBaseGCDetailsFn?: () => Promise<IGarbageCollectionDetailsBase>,\n): IRootSummarizerNodeWithGC => new SummarizerNodeWithGC(\n logger,\n summarizeInternalFn,\n config,\n changeSequenceNumber,\n referenceSequenceNumber === undefined ? undefined : SummaryNode.createForRoot(referenceSequenceNumber),\n undefined /* initialSummary */,\n undefined /* wipSummaryLogger */,\n getGCDataFn,\n getBaseGCDetailsFn,\n);\n"]}
@@ -59,6 +59,10 @@ export declare class TelemetryContext implements ITelemetryContext {
59
59
  * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.set}
60
60
  */
61
61
  set(prefix: string, property: string, value: TelemetryEventPropertyType): void;
62
+ /**
63
+ * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.setAll}
64
+ */
65
+ setAll(prefix: string, property: string, values: Record<string, TelemetryEventPropertyType>): void;
62
66
  /**
63
67
  * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.get}
64
68
  */
@@ -1 +1 @@
1
- {"version":3,"file":"summaryUtils.d.ts","sourceRoot":"","sources":["../src/summaryUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAShF,OAAO,EACH,KAAK,EACL,WAAW,EACX,YAAY,EACZ,aAAa,EACb,YAAY,EAGZ,aAAa,EAChB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACH,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACpB,MAAM,qCAAqC,CAAC;AAE7C;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,KAAK,EAAE,aAAa,EAAE,GAAG,aAAa,CAgBnE;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAelD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,GAAG,MAAM,CAEpE;AAwBD,wBAAgB,cAAc,CAAC,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wBAAgB,yBAAyB,CAAC,WAAW,EAAE,YAAY,GAAG,KAAK,CAuC1E;AAED,qBAAa,gBAAiB,YAAW,iBAAiB;IACtD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiD;IAE3E;;OAEG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,0BAA0B,GAAG,IAAI;IAI9E;;OAEG;IACH,MAAM,CACF,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,GACnD,IAAI;IAOP;;OAEG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,0BAA0B;IAIjE;;OAEG;IACH,SAAS,IAAI,MAAM;CAOtB"}
@@ -291,6 +291,15 @@ class TelemetryContext {
291
291
  set(prefix, property, value) {
292
292
  this.telemetry.set(`${prefix}${property}`, value);
293
293
  }
294
+ /**
295
+ * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.setAll}
296
+ */
297
+ setAll(prefix, property, values) {
298
+ // Set the values individually so that they are logged as a flat list along with other properties.
299
+ for (const key of Object.keys(values)) {
300
+ this.set(prefix, `${property}_${key}`, values[key]);
301
+ }
302
+ }
294
303
  /**
295
304
  * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.get}
296
305
  */
@@ -1 +1 @@
1
- {"version":3,"file":"summaryUtils.js","sourceRoot":"","sources":["../src/summaryUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAMsC;AACtC,iEAAkG;AAClG,+EAS8C;AAQ9C;;;;GAIG;AACH,SAAgB,UAAU,CAAC,GAAG,KAAsB;IAChD,MAAM,OAAO,GAAG;QACZ,aAAa,EAAE,CAAC;QAChB,aAAa,EAAE,CAAC;QAChB,eAAe,EAAE,CAAC;QAClB,aAAa,EAAE,CAAC;QAChB,oBAAoB,EAAE,CAA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AAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,QAAQ,EAAE,EAAE,KAAK,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,MAAc,EAAE,QAAgB;QAChC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,QAAQ,EAAE,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACH,SAAS;QACL,MAAM,UAAU,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YAClC,UAAU,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QAC5B,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACtC,CAAC;CACJ;AA3BD,4CA2BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TelemetryEventPropertyType } from \"@fluidframework/common-definitions\";\nimport {\n bufferToString,\n fromBase64ToUtf8,\n IsoBuffer,\n Uint8ArrayToString,\n unreachableCase,\n} from \"@fluidframework/common-utils\";\nimport { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from \"@fluidframework/protocol-base\";\nimport {\n ITree,\n SummaryType,\n ISummaryTree,\n SummaryObject,\n ISummaryBlob,\n TreeEntry,\n ITreeEntry,\n ISnapshotTree,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n ISummaryStats,\n ISummarizeResult,\n ISummaryTreeWithStats,\n ITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\n\n/**\n * Combines summary stats by adding their totals together.\n * Returns empty stats if called without args.\n * @param stats - stats to merge\n */\nexport function mergeStats(...stats: ISummaryStats[]): ISummaryStats {\n const results = {\n treeNodeCount: 0,\n blobNodeCount: 0,\n handleNodeCount: 0,\n totalBlobSize: 0,\n unreferencedBlobSize: 0,\n };\n for (const stat of stats) {\n results.treeNodeCount += stat.treeNodeCount;\n results.blobNodeCount += stat.blobNodeCount;\n results.handleNodeCount += stat.handleNodeCount;\n results.totalBlobSize += stat.totalBlobSize;\n results.unreferencedBlobSize += stat.unreferencedBlobSize;\n }\n return results;\n}\n\nexport function utf8ByteLength(str: string): number {\n // returns the byte length of an utf8 string\n let s = str.length;\n for (let i = str.length - 1; i >= 0; i--) {\n const code = str.charCodeAt(i);\n if (code > 0x7f && code <= 0x7ff) {\n s++;\n } else if (code > 0x7ff && code <= 0xffff) {\n s += 2;\n }\n if (code >= 0xDC00 && code <= 0xDFFF) {\n i--; // trail surrogate\n }\n }\n return s;\n}\n\nexport function getBlobSize(content: ISummaryBlob[\"content\"]): number {\n return typeof content === \"string\" ? utf8ByteLength(content) : content.byteLength;\n}\n\nfunction calculateStatsCore(summaryObject: SummaryObject, stats: ISummaryStats): void {\n switch (summaryObject.type) {\n case SummaryType.Tree: {\n stats.treeNodeCount++;\n for (const value of Object.values(summaryObject.tree)) {\n calculateStatsCore(value, stats);\n }\n return;\n }\n case SummaryType.Handle: {\n stats.handleNodeCount++;\n return;\n }\n case SummaryType.Blob: {\n stats.blobNodeCount++;\n stats.totalBlobSize += getBlobSize(summaryObject.content);\n return;\n }\n default: return;\n }\n}\n\nexport function calculateStats(summary: SummaryObject): ISummaryStats {\n const stats = mergeStats();\n calculateStatsCore(summary, stats);\n return stats;\n}\n\nexport function addBlobToSummary(summary: ISummaryTreeWithStats, key: string, content: string | Uint8Array): void {\n const blob: ISummaryBlob = {\n type: SummaryType.Blob,\n content,\n };\n summary.summary.tree[key] = blob;\n summary.stats.blobNodeCount++;\n summary.stats.totalBlobSize += getBlobSize(content);\n}\n\nexport function addTreeToSummary(summary: ISummaryTreeWithStats, key: string, summarizeResult: ISummarizeResult): void {\n summary.summary.tree[key] = summarizeResult.summary;\n summary.stats = mergeStats(summary.stats, summarizeResult.stats);\n}\n\nexport function addSummarizeResultToSummary(\n summary: ISummaryTreeWithStats,\n key: string,\n summarizeResult: ISummarizeResult,\n): void {\n summary.summary.tree[key] = summarizeResult.summary;\n summary.stats = mergeStats(summary.stats, summarizeResult.stats);\n}\n\nexport class SummaryTreeBuilder implements ISummaryTreeWithStats {\n private attachmentCounter: number = 0;\n\n public get summary(): ISummaryTree {\n return {\n type: SummaryType.Tree,\n tree: { ...this.summaryTree },\n };\n }\n\n public get stats(): Readonly<ISummaryStats> {\n return { ...this.summaryStats };\n }\n\n constructor() {\n this.summaryStats = mergeStats();\n this.summaryStats.treeNodeCount++;\n }\n\n private readonly summaryTree: { [path: string]: SummaryObject; } = {};\n private summaryStats: ISummaryStats;\n\n public addBlob(key: string, content: string | Uint8Array): void {\n // Prevent cloning by directly referencing underlying private properties\n addBlobToSummary({\n summary: {\n type: SummaryType.Tree,\n tree: this.summaryTree,\n },\n stats: this.summaryStats,\n }, key, content);\n }\n\n public addHandle(\n key: string,\n handleType: SummaryType.Tree | SummaryType.Blob | SummaryType.Attachment,\n handle: string): void {\n this.summaryTree[key] = {\n type: SummaryType.Handle,\n handleType,\n handle,\n };\n this.summaryStats.handleNodeCount++;\n }\n\n public addWithStats(key: string, summarizeResult: ISummarizeResult): void {\n this.summaryTree[key] = summarizeResult.summary;\n this.summaryStats = mergeStats(this.summaryStats, summarizeResult.stats);\n }\n\n public addAttachment(id: string) {\n this.summaryTree[this.attachmentCounter++] = { id, type: SummaryType.Attachment };\n }\n\n public getSummaryTree(): ISummaryTreeWithStats {\n return { summary: this.summary, stats: this.stats };\n }\n}\n\n/**\n * Converts snapshot ITree to ISummaryTree format and tracks stats.\n * @param snapshot - snapshot in ITree format\n * @param fullTree - true to never use handles, even if id is specified\n */\nexport function convertToSummaryTreeWithStats(\n snapshot: ITree,\n fullTree: boolean = false,\n): ISummaryTreeWithStats {\n const builder = new SummaryTreeBuilder();\n for (const entry of snapshot.entries) {\n switch (entry.type) {\n case TreeEntry.Blob: {\n const blob = entry.value;\n const content = blob.encoding === \"base64\"\n ? IsoBuffer.from(blob.contents, \"base64\")\n : blob.contents;\n builder.addBlob(entry.path, content);\n break;\n }\n\n case TreeEntry.Tree: {\n const subtree = convertToSummaryTree(\n entry.value,\n fullTree);\n builder.addWithStats(entry.path, subtree);\n\n break;\n }\n\n case TreeEntry.Attachment: {\n const id = entry.value.id;\n builder.addAttachment(id);\n\n break;\n }\n\n default:\n throw new Error(\"Unexpected TreeEntry type\");\n }\n }\n\n const summaryTree = builder.getSummaryTree();\n summaryTree.summary.unreferenced = snapshot.unreferenced;\n return summaryTree;\n}\n\n/**\n * Converts snapshot ITree to ISummaryTree format and tracks stats.\n * @param snapshot - snapshot in ITree format\n * @param fullTree - true to never use handles, even if id is specified\n */\nexport function convertToSummaryTree(\n snapshot: ITree,\n fullTree: boolean = false,\n): ISummarizeResult {\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (snapshot.id && !fullTree) {\n const stats = mergeStats();\n stats.handleNodeCount++;\n return {\n summary: {\n handle: snapshot.id,\n handleType: SummaryType.Tree,\n type: SummaryType.Handle,\n },\n stats,\n };\n } else {\n return convertToSummaryTreeWithStats(snapshot, fullTree);\n }\n}\n\n/**\n * Converts ISnapshotTree to ISummaryTree format and tracks stats. This snapshot tree was\n * was taken by serialize api in detached container.\n * @param snapshot - snapshot in ISnapshotTree format\n */\nexport function convertSnapshotTreeToSummaryTree(\n snapshot: ISnapshotTree,\n): ISummaryTreeWithStats {\n const builder = new SummaryTreeBuilder();\n for (const [path, id] of Object.entries(snapshot.blobs)) {\n let decoded: string | undefined;\n if ((snapshot as any).blobsContents !== undefined) {\n const content: ArrayBufferLike = (snapshot as any).blobsContents[id];\n if (content !== undefined) {\n decoded = bufferToString(content, \"utf-8\");\n }\n // 0.44 back-compat We still put contents in same blob for back-compat so need to add blob\n // only for blobPath -> blobId mapping and not for blobId -> blob value contents.\n } else if (snapshot.blobs[id] !== undefined) {\n decoded = fromBase64ToUtf8(snapshot.blobs[id]);\n }\n if (decoded !== undefined) {\n builder.addBlob(path, decoded);\n }\n }\n\n for (const [key, tree] of Object.entries(snapshot.trees)) {\n const subtree = convertSnapshotTreeToSummaryTree(tree);\n builder.addWithStats(key, subtree);\n }\n\n const summaryTree = builder.getSummaryTree();\n summaryTree.summary.unreferenced = snapshot.unreferenced;\n return summaryTree;\n}\n\n/**\n * Converts ISummaryTree to ITree format. This is needed for back-compat while we get rid of snapshot.\n * @param summaryTree - summary tree in ISummaryTree format\n */\nexport function convertSummaryTreeToITree(summaryTree: ISummaryTree): ITree {\n const entries: ITreeEntry[] = [];\n for (const [key, value] of Object.entries(summaryTree.tree)) {\n switch (value.type) {\n case SummaryType.Blob: {\n let parsedContent: string;\n let encoding: \"utf-8\" | \"base64\" = \"utf-8\";\n if (typeof value.content === \"string\") {\n parsedContent = value.content;\n } else {\n parsedContent = Uint8ArrayToString(value.content, \"base64\");\n encoding = \"base64\";\n }\n entries.push(new BlobTreeEntry(key, parsedContent, encoding));\n break;\n }\n\n case SummaryType.Tree: {\n entries.push(new TreeTreeEntry(key, convertSummaryTreeToITree(value)));\n break;\n }\n\n case SummaryType.Attachment: {\n entries.push(new AttachmentTreeEntry(key, value.id));\n break;\n }\n\n case SummaryType.Handle: {\n throw new Error(\"Should not have Handle type in summary tree\");\n }\n\n default:\n unreachableCase(value, \"Unexpected summary tree type\");\n }\n }\n return {\n entries,\n unreferenced: summaryTree.unreferenced,\n };\n}\n\nexport class TelemetryContext implements ITelemetryContext {\n private readonly telemetry = new Map<string, TelemetryEventPropertyType>();\n\n /**\n * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.set}\n */\n set(prefix: string, property: string, value: TelemetryEventPropertyType): void {\n this.telemetry.set(`${prefix}${property}`, value);\n }\n\n /**\n * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.get}\n */\n get(prefix: string, property: string): TelemetryEventPropertyType {\n return this.telemetry.get(`${prefix}${property}`);\n }\n\n /**\n * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.serialize}\n */\n serialize(): string {\n const jsonObject = {};\n this.telemetry.forEach((value, key) => {\n jsonObject[key] = value;\n });\n return JSON.stringify(jsonObject);\n }\n}\n"]}
1
+ {"version":3,"file":"summaryUtils.js","sourceRoot":"","sources":["../src/summaryUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAMsC;AACtC,iEAAkG;AAClG,+EAS8C;AAQ9C;;;;GAIG;AACH,SAAgB,UAAU,CAAC,GAAG,KAAsB;IAChD,MAAM,OAAO,GAAG;QACZ,aAAa,EAAE,CAAC;QAChB,aAAa,EAAE,CAAC;QAChB,eAAe,EAAE,CAAC;QAClB,aAAa,EAAE,CAAC;QAChB,oBAAoB,EAAE,CAAC;KAC1B,CAAC;IACF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACtB,OAAO,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC;QAC5C,OAAO,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC;QAC5C,OAAO,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC;QAChD,OAAO,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC;QAC5C,OAAO,CAAC,oBAAoB,IAAI,IAAI,CAAC,oBAAoB,CAAC;KAC7D;IACD,OAAO,OAAO,CAAC;AACnB,CAAC;AAhBD,gCAgBC;AAED,SAAgB,cAAc,CAAC,GAAW;IACxC,4CAA4C;IAC5C,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QACxC,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC/B,IAAI,IAAI,GAAG,IAAI,IAAI,IAAI,IAAI,KAAK,EAAE;YAC9B,CAAC,EAAE,CAAC;SACP;aAAM,IAAI,IAAI,GAAG,KAAK,IAAI,IAAI,IAAI,MAA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;CACJ;AAzCD,4CAyCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TelemetryEventPropertyType } from \"@fluidframework/common-definitions\";\nimport {\n bufferToString,\n fromBase64ToUtf8,\n IsoBuffer,\n Uint8ArrayToString,\n unreachableCase,\n} from \"@fluidframework/common-utils\";\nimport { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from \"@fluidframework/protocol-base\";\nimport {\n ITree,\n SummaryType,\n ISummaryTree,\n SummaryObject,\n ISummaryBlob,\n TreeEntry,\n ITreeEntry,\n ISnapshotTree,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n ISummaryStats,\n ISummarizeResult,\n ISummaryTreeWithStats,\n ITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\n\n/**\n * Combines summary stats by adding their totals together.\n * Returns empty stats if called without args.\n * @param stats - stats to merge\n */\nexport function mergeStats(...stats: ISummaryStats[]): ISummaryStats {\n const results = {\n treeNodeCount: 0,\n blobNodeCount: 0,\n handleNodeCount: 0,\n totalBlobSize: 0,\n unreferencedBlobSize: 0,\n };\n for (const stat of stats) {\n results.treeNodeCount += stat.treeNodeCount;\n results.blobNodeCount += stat.blobNodeCount;\n results.handleNodeCount += stat.handleNodeCount;\n results.totalBlobSize += stat.totalBlobSize;\n results.unreferencedBlobSize += stat.unreferencedBlobSize;\n }\n return results;\n}\n\nexport function utf8ByteLength(str: string): number {\n // returns the byte length of an utf8 string\n let s = str.length;\n for (let i = str.length - 1; i >= 0; i--) {\n const code = str.charCodeAt(i);\n if (code > 0x7f && code <= 0x7ff) {\n s++;\n } else if (code > 0x7ff && code <= 0xffff) {\n s += 2;\n }\n if (code >= 0xDC00 && code <= 0xDFFF) {\n i--; // trail surrogate\n }\n }\n return s;\n}\n\nexport function getBlobSize(content: ISummaryBlob[\"content\"]): number {\n return typeof content === \"string\" ? utf8ByteLength(content) : content.byteLength;\n}\n\nfunction calculateStatsCore(summaryObject: SummaryObject, stats: ISummaryStats): void {\n switch (summaryObject.type) {\n case SummaryType.Tree: {\n stats.treeNodeCount++;\n for (const value of Object.values(summaryObject.tree)) {\n calculateStatsCore(value, stats);\n }\n return;\n }\n case SummaryType.Handle: {\n stats.handleNodeCount++;\n return;\n }\n case SummaryType.Blob: {\n stats.blobNodeCount++;\n stats.totalBlobSize += getBlobSize(summaryObject.content);\n return;\n }\n default: return;\n }\n}\n\nexport function calculateStats(summary: SummaryObject): ISummaryStats {\n const stats = mergeStats();\n calculateStatsCore(summary, stats);\n return stats;\n}\n\nexport function addBlobToSummary(summary: ISummaryTreeWithStats, key: string, content: string | Uint8Array): void {\n const blob: ISummaryBlob = {\n type: SummaryType.Blob,\n content,\n };\n summary.summary.tree[key] = blob;\n summary.stats.blobNodeCount++;\n summary.stats.totalBlobSize += getBlobSize(content);\n}\n\nexport function addTreeToSummary(summary: ISummaryTreeWithStats, key: string, summarizeResult: ISummarizeResult): void {\n summary.summary.tree[key] = summarizeResult.summary;\n summary.stats = mergeStats(summary.stats, summarizeResult.stats);\n}\n\nexport function addSummarizeResultToSummary(\n summary: ISummaryTreeWithStats,\n key: string,\n summarizeResult: ISummarizeResult,\n): void {\n summary.summary.tree[key] = summarizeResult.summary;\n summary.stats = mergeStats(summary.stats, summarizeResult.stats);\n}\n\nexport class SummaryTreeBuilder implements ISummaryTreeWithStats {\n private attachmentCounter: number = 0;\n\n public get summary(): ISummaryTree {\n return {\n type: SummaryType.Tree,\n tree: { ...this.summaryTree },\n };\n }\n\n public get stats(): Readonly<ISummaryStats> {\n return { ...this.summaryStats };\n }\n\n constructor() {\n this.summaryStats = mergeStats();\n this.summaryStats.treeNodeCount++;\n }\n\n private readonly summaryTree: { [path: string]: SummaryObject; } = {};\n private summaryStats: ISummaryStats;\n\n public addBlob(key: string, content: string | Uint8Array): void {\n // Prevent cloning by directly referencing underlying private properties\n addBlobToSummary({\n summary: {\n type: SummaryType.Tree,\n tree: this.summaryTree,\n },\n stats: this.summaryStats,\n }, key, content);\n }\n\n public addHandle(\n key: string,\n handleType: SummaryType.Tree | SummaryType.Blob | SummaryType.Attachment,\n handle: string): void {\n this.summaryTree[key] = {\n type: SummaryType.Handle,\n handleType,\n handle,\n };\n this.summaryStats.handleNodeCount++;\n }\n\n public addWithStats(key: string, summarizeResult: ISummarizeResult): void {\n this.summaryTree[key] = summarizeResult.summary;\n this.summaryStats = mergeStats(this.summaryStats, summarizeResult.stats);\n }\n\n public addAttachment(id: string) {\n this.summaryTree[this.attachmentCounter++] = { id, type: SummaryType.Attachment };\n }\n\n public getSummaryTree(): ISummaryTreeWithStats {\n return { summary: this.summary, stats: this.stats };\n }\n}\n\n/**\n * Converts snapshot ITree to ISummaryTree format and tracks stats.\n * @param snapshot - snapshot in ITree format\n * @param fullTree - true to never use handles, even if id is specified\n */\nexport function convertToSummaryTreeWithStats(\n snapshot: ITree,\n fullTree: boolean = false,\n): ISummaryTreeWithStats {\n const builder = new SummaryTreeBuilder();\n for (const entry of snapshot.entries) {\n switch (entry.type) {\n case TreeEntry.Blob: {\n const blob = entry.value;\n const content = blob.encoding === \"base64\"\n ? IsoBuffer.from(blob.contents, \"base64\")\n : blob.contents;\n builder.addBlob(entry.path, content);\n break;\n }\n\n case TreeEntry.Tree: {\n const subtree = convertToSummaryTree(\n entry.value,\n fullTree);\n builder.addWithStats(entry.path, subtree);\n\n break;\n }\n\n case TreeEntry.Attachment: {\n const id = entry.value.id;\n builder.addAttachment(id);\n\n break;\n }\n\n default:\n throw new Error(\"Unexpected TreeEntry type\");\n }\n }\n\n const summaryTree = builder.getSummaryTree();\n summaryTree.summary.unreferenced = snapshot.unreferenced;\n return summaryTree;\n}\n\n/**\n * Converts snapshot ITree to ISummaryTree format and tracks stats.\n * @param snapshot - snapshot in ITree format\n * @param fullTree - true to never use handles, even if id is specified\n */\nexport function convertToSummaryTree(\n snapshot: ITree,\n fullTree: boolean = false,\n): ISummarizeResult {\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (snapshot.id && !fullTree) {\n const stats = mergeStats();\n stats.handleNodeCount++;\n return {\n summary: {\n handle: snapshot.id,\n handleType: SummaryType.Tree,\n type: SummaryType.Handle,\n },\n stats,\n };\n } else {\n return convertToSummaryTreeWithStats(snapshot, fullTree);\n }\n}\n\n/**\n * Converts ISnapshotTree to ISummaryTree format and tracks stats. This snapshot tree was\n * was taken by serialize api in detached container.\n * @param snapshot - snapshot in ISnapshotTree format\n */\nexport function convertSnapshotTreeToSummaryTree(\n snapshot: ISnapshotTree,\n): ISummaryTreeWithStats {\n const builder = new SummaryTreeBuilder();\n for (const [path, id] of Object.entries(snapshot.blobs)) {\n let decoded: string | undefined;\n if ((snapshot as any).blobsContents !== undefined) {\n const content: ArrayBufferLike = (snapshot as any).blobsContents[id];\n if (content !== undefined) {\n decoded = bufferToString(content, \"utf-8\");\n }\n // 0.44 back-compat We still put contents in same blob for back-compat so need to add blob\n // only for blobPath -> blobId mapping and not for blobId -> blob value contents.\n } else if (snapshot.blobs[id] !== undefined) {\n decoded = fromBase64ToUtf8(snapshot.blobs[id]);\n }\n if (decoded !== undefined) {\n builder.addBlob(path, decoded);\n }\n }\n\n for (const [key, tree] of Object.entries(snapshot.trees)) {\n const subtree = convertSnapshotTreeToSummaryTree(tree);\n builder.addWithStats(key, subtree);\n }\n\n const summaryTree = builder.getSummaryTree();\n summaryTree.summary.unreferenced = snapshot.unreferenced;\n return summaryTree;\n}\n\n/**\n * Converts ISummaryTree to ITree format. This is needed for back-compat while we get rid of snapshot.\n * @param summaryTree - summary tree in ISummaryTree format\n */\nexport function convertSummaryTreeToITree(summaryTree: ISummaryTree): ITree {\n const entries: ITreeEntry[] = [];\n for (const [key, value] of Object.entries(summaryTree.tree)) {\n switch (value.type) {\n case SummaryType.Blob: {\n let parsedContent: string;\n let encoding: \"utf-8\" | \"base64\" = \"utf-8\";\n if (typeof value.content === \"string\") {\n parsedContent = value.content;\n } else {\n parsedContent = Uint8ArrayToString(value.content, \"base64\");\n encoding = \"base64\";\n }\n entries.push(new BlobTreeEntry(key, parsedContent, encoding));\n break;\n }\n\n case SummaryType.Tree: {\n entries.push(new TreeTreeEntry(key, convertSummaryTreeToITree(value)));\n break;\n }\n\n case SummaryType.Attachment: {\n entries.push(new AttachmentTreeEntry(key, value.id));\n break;\n }\n\n case SummaryType.Handle: {\n throw new Error(\"Should not have Handle type in summary tree\");\n }\n\n default:\n unreachableCase(value, \"Unexpected summary tree type\");\n }\n }\n return {\n entries,\n unreferenced: summaryTree.unreferenced,\n };\n}\n\nexport class TelemetryContext implements ITelemetryContext {\n private readonly telemetry = new Map<string, TelemetryEventPropertyType>();\n\n /**\n * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.set}\n */\n set(prefix: string, property: string, value: TelemetryEventPropertyType): void {\n this.telemetry.set(`${prefix}${property}`, value);\n }\n\n /**\n * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.setAll}\n */\n setAll(\n prefix: string,\n property: string,\n values: Record<string, TelemetryEventPropertyType>,\n ): void {\n // Set the values individually so that they are logged as a flat list along with other properties.\n for (const key of Object.keys(values)) {\n this.set(prefix, `${property}_${key}`, values[key]);\n }\n }\n\n /**\n * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.get}\n */\n get(prefix: string, property: string): TelemetryEventPropertyType {\n return this.telemetry.get(`${prefix}${property}`);\n }\n\n /**\n * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.serialize}\n */\n serialize(): string {\n const jsonObject = {};\n this.telemetry.forEach((value, key) => {\n jsonObject[key] = value;\n });\n return JSON.stringify(jsonObject);\n }\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -8,7 +8,7 @@ export { ObjectStoragePartition } from "./objectstoragepartition";
8
8
  export { getNormalizedObjectStoragePathParts, listBlobsAtTreePath } from "./objectstorageutils";
9
9
  export { RequestParser } from "./requestParser";
10
10
  export { RuntimeFactoryHelper } from "./runtimeFactoryHelper";
11
- export { createRootSummarizerNode, createRootSummarizerNodeWithGC, IRootSummarizerNode, IRootSummarizerNodeWithGC, ISummarizerNodeRootContract, RefreshSummaryResult, } from "./summarizerNode";
11
+ export { createRootSummarizerNode, createRootSummarizerNodeWithGC, IFetchSnapshotResult, IRootSummarizerNode, IRootSummarizerNodeWithGC, ISummarizerNodeRootContract, RefreshSummaryResult, } from "./summarizerNode";
12
12
  export { addBlobToSummary, addSummarizeResultToSummary, addTreeToSummary, calculateStats, convertSnapshotTreeToSummaryTree, convertSummaryTreeToITree, convertToSummaryTree, convertToSummaryTreeWithStats, getBlobSize, mergeStats, SummaryTreeBuilder, TelemetryContext, utf8ByteLength, } from "./summaryUtils";
13
13
  export { ReadAndParseBlob, seqFromTree } from "./utils";
14
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EACN,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,OAAO,EACJ,8BAA8B,EACjC,kBAAkB,EAClB,mBAAmB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,mCAAmC,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EACN,wBAAwB,EACxB,8BAA8B,EAC9B,mBAAmB,EACnB,yBAAyB,EACzB,2BAA2B,EAC3B,oBAAoB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,gBAAgB,EAChB,2BAA2B,EAC3B,gBAAgB,EAChB,cAAc,EACd,gCAAgC,EAChC,yBAAyB,EACzB,oBAAoB,EACpB,6BAA6B,EAC7B,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EACN,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,OAAO,EACJ,8BAA8B,EACjC,kBAAkB,EAClB,mBAAmB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,mCAAmC,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EACN,wBAAwB,EACxB,8BAA8B,EAC3B,oBAAoB,EACvB,mBAAmB,EACnB,yBAAyB,EACzB,2BAA2B,EAC3B,oBAAoB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,gBAAgB,EAChB,2BAA2B,EAC3B,gBAAgB,EAChB,cAAc,EACd,gCAAgC,EAChC,yBAAyB,EACzB,oBAAoB,EACpB,6BAA6B,EAC7B,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EACN,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EAEhB,8BAA8B,EACjC,kBAAkB,EAClB,mBAAmB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,mCAAmC,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EACN,wBAAwB,EACxB,8BAA8B,GAK9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,gBAAgB,EAChB,2BAA2B,EAC3B,gBAAgB,EAChB,cAAc,EACd,gCAAgC,EAChC,yBAAyB,EACzB,oBAAoB,EACpB,6BAA6B,EAC7B,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAoB,WAAW,EAAE,MAAM,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { generateHandleContextPath } from \"./dataStoreHandleContextUtils\";\nexport {\n\tcreate404Response,\n\tcreateDataStoreFactory,\n\tcreateResponseError,\n\texceptionToResponse,\n\tFactory,\n packagePathToTelemetryProperty,\n\trequestFluidObject,\n\tresponseToException,\n} from \"./dataStoreHelpers\";\nexport { ObjectStoragePartition } from \"./objectstoragepartition\";\nexport { getNormalizedObjectStoragePathParts, listBlobsAtTreePath } from \"./objectstorageutils\";\nexport { RequestParser } from \"./requestParser\";\nexport { RuntimeFactoryHelper } from \"./runtimeFactoryHelper\";\nexport {\n\tcreateRootSummarizerNode,\n\tcreateRootSummarizerNodeWithGC,\n\tIRootSummarizerNode,\n\tIRootSummarizerNodeWithGC,\n\tISummarizerNodeRootContract,\n\tRefreshSummaryResult,\n} from \"./summarizerNode\";\nexport {\n\taddBlobToSummary,\n\taddSummarizeResultToSummary,\n\taddTreeToSummary,\n\tcalculateStats,\n\tconvertSnapshotTreeToSummaryTree,\n\tconvertSummaryTreeToITree,\n\tconvertToSummaryTree,\n\tconvertToSummaryTreeWithStats,\n\tgetBlobSize,\n\tmergeStats,\n\tSummaryTreeBuilder,\n\tTelemetryContext,\n\tutf8ByteLength,\n} from \"./summaryUtils\";\nexport { ReadAndParseBlob, seqFromTree } from \"./utils\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EACN,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EAEhB,8BAA8B,EACjC,kBAAkB,EAClB,mBAAmB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,mCAAmC,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EACN,wBAAwB,EACxB,8BAA8B,GAM9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,gBAAgB,EAChB,2BAA2B,EAC3B,gBAAgB,EAChB,cAAc,EACd,gCAAgC,EAChC,yBAAyB,EACzB,oBAAoB,EACpB,6BAA6B,EAC7B,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAoB,WAAW,EAAE,MAAM,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { generateHandleContextPath } from \"./dataStoreHandleContextUtils\";\nexport {\n\tcreate404Response,\n\tcreateDataStoreFactory,\n\tcreateResponseError,\n\texceptionToResponse,\n\tFactory,\n packagePathToTelemetryProperty,\n\trequestFluidObject,\n\tresponseToException,\n} from \"./dataStoreHelpers\";\nexport { ObjectStoragePartition } from \"./objectstoragepartition\";\nexport { getNormalizedObjectStoragePathParts, listBlobsAtTreePath } from \"./objectstorageutils\";\nexport { RequestParser } from \"./requestParser\";\nexport { RuntimeFactoryHelper } from \"./runtimeFactoryHelper\";\nexport {\n\tcreateRootSummarizerNode,\n\tcreateRootSummarizerNodeWithGC,\n IFetchSnapshotResult,\n\tIRootSummarizerNode,\n\tIRootSummarizerNodeWithGC,\n\tISummarizerNodeRootContract,\n\tRefreshSummaryResult,\n} from \"./summarizerNode\";\nexport {\n\taddBlobToSummary,\n\taddSummarizeResultToSummary,\n\taddTreeToSummary,\n\tcalculateStats,\n\tconvertSnapshotTreeToSummaryTree,\n\tconvertSummaryTreeToITree,\n\tconvertToSummaryTree,\n\tconvertToSummaryTreeWithStats,\n\tgetBlobSize,\n\tmergeStats,\n\tSummaryTreeBuilder,\n\tTelemetryContext,\n\tutf8ByteLength,\n} from \"./summaryUtils\";\nexport { ReadAndParseBlob, seqFromTree } from \"./utils\";\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/runtime-utils";
8
- export declare const pkgVersion = "2.0.0-internal.3.0.0";
8
+ export declare const pkgVersion = "2.0.0-internal.3.0.2";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/runtime-utils";
8
- export const pkgVersion = "2.0.0-internal.3.0.0";
8
+ export const pkgVersion = "2.0.0-internal.3.0.2";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,+BAA+B,CAAC;AACvD,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/runtime-utils\";\nexport const pkgVersion = \"2.0.0-internal.3.0.0\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,+BAA+B,CAAC;AACvD,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/runtime-utils\";\nexport const pkgVersion = \"2.0.0-internal.3.0.2\";\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { ISummarizerNodeRootContract, RefreshSummaryResult } from "./summarizerNodeUtils";
5
+ export { IFetchSnapshotResult, ISummarizerNodeRootContract, RefreshSummaryResult, } from "./summarizerNodeUtils";
6
6
  export { IRootSummarizerNode, createRootSummarizerNode } from "./summarizerNode";
7
7
  export { IRootSummarizerNodeWithGC, createRootSummarizerNodeWithGC } from "./summarizerNodeWithGc";
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/summarizerNode/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,yBAAyB,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/summarizerNode/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,oBAAoB,EACpB,2BAA2B,EAC3B,oBAAoB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,yBAAyB,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/summarizerNode/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAuB,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAA6B,8BAA8B,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ISummarizerNodeRootContract, RefreshSummaryResult } from \"./summarizerNodeUtils\";\nexport { IRootSummarizerNode, createRootSummarizerNode } from \"./summarizerNode\";\nexport { IRootSummarizerNodeWithGC, createRootSummarizerNodeWithGC } from \"./summarizerNodeWithGc\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/summarizerNode/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAuB,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAA6B,8BAA8B,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tIFetchSnapshotResult,\n\tISummarizerNodeRootContract,\n\tRefreshSummaryResult,\n} from \"./summarizerNodeUtils\";\nexport { IRootSummarizerNode, createRootSummarizerNode } from \"./summarizerNode\";\nexport { IRootSummarizerNodeWithGC, createRootSummarizerNodeWithGC } from \"./summarizerNodeWithGc\";\n"]}
@@ -6,7 +6,7 @@ import { ISummarizerNode, ISummarizerNodeConfig, ISummarizeResult, CreateChildSu
6
6
  import { ISequencedDocumentMessage, ISnapshotTree } from "@fluidframework/protocol-definitions";
7
7
  import { ITelemetryLogger } from "@fluidframework/common-definitions";
8
8
  import { ReadAndParseBlob } from "../utils";
9
- import { EscapedPath, ICreateChildDetails, IInitialSummary, ISummarizerNodeRootContract, RefreshSummaryResult, SummaryNode } from "./summarizerNodeUtils";
9
+ import { EscapedPath, ICreateChildDetails, IFetchSnapshotResult, IInitialSummary, ISummarizerNodeRootContract, RefreshSummaryResult, SummaryNode } from "./summarizerNodeUtils";
10
10
  export interface IRootSummarizerNode extends ISummarizerNode, ISummarizerNodeRootContract {
11
11
  }
12
12
  /**
@@ -54,19 +54,18 @@ export declare class SummarizerNode implements IRootSummarizerNode {
54
54
  /**
55
55
  * Refreshes the latest summary tracked by this node. If we have a pending summary for the given proposal handle,
56
56
  * it becomes the latest summary. If the current summary is already ahead (e.g., loaded from a service summary),
57
- * we skip the update. Otherwise, we get the snapshot by calling `getSnapshot` and update latest
58
- * summary based off of that.
57
+ * we skip the update. Otherwise, we fetch the latest snapshot and update latest summary based off of that.
59
58
  *
60
59
  * @returns A RefreshSummaryResult type which returns information based on the following three scenarios:
61
60
  *
62
- * 1. The latest summary was not udpated.
61
+ * 1. The latest summary was not updated.
63
62
  *
64
63
  * 2. The latest summary was updated and the summary corresponding to the params was being tracked.
65
64
  *
66
65
  * 3. The latest summary was updated but the summary corresponding to the params was not tracked. In this
67
66
  * case, the latest summary is updated based on the downloaded snapshot which is also returned.
68
67
  */
69
- refreshLatestSummary(proposalHandle: string | undefined, summaryRefSeq: number, getSnapshot: () => Promise<ISnapshotTree>, readAndParseBlob: ReadAndParseBlob, correlatedSummaryLogger: ITelemetryLogger): Promise<RefreshSummaryResult>;
68
+ refreshLatestSummary(proposalHandle: string | undefined, summaryRefSeq: number, fetchLatestSnapshot: () => Promise<IFetchSnapshotResult>, readAndParseBlob: ReadAndParseBlob, correlatedSummaryLogger: ITelemetryLogger): Promise<RefreshSummaryResult>;
70
69
  /**
71
70
  * Called when we get an ack from the server for a summary we've just sent. Updates the reference state of this node
72
71
  * from the state in the pending summary queue.
@@ -125,7 +124,7 @@ export declare class SummarizerNode implements IRootSummarizerNode {
125
124
  /**
126
125
  * Tells whether summary tracking is in progress. True if "startSummary" API is called before summarize.
127
126
  */
128
- protected isTrackingInProgress(): boolean;
127
+ isSummaryInProgress(): boolean;
129
128
  }
130
129
  /**
131
130
  * Creates a root summarizer node.
@@ -1 +1 @@
1
- {"version":3,"file":"summarizerNode.d.ts","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAEhB,8BAA8B,EAE9B,mBAAmB,EACnB,iBAAiB,EACpB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACH,yBAAyB,EAEzB,aAAa,EAEhB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EACH,WAAW,EACX,mBAAmB,EACnB,eAAe,EACf,2BAA2B,EAG3B,oBAAoB,EACpB,WAAW,EACd,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,mBAAoB,SAAQ,eAAe,EAAE,2BA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SequenceNumber = referenceSequenceNumber;
59
59
  }
60
60
  async summarize(fullTree, trackState = true, telemetryContext) {
61
- assert(this.isTrackingInProgress(), 0x1a1 /* "summarize should not be called when not tracking the summary" */);
61
+ assert(this.isSummaryInProgress(), 0x1a1 /* "summarize should not be called when not tracking the summary" */);
62
62
  assert(this.wipSummaryLogger !== undefined, 0x1a2 /* "wipSummaryLogger should have been set in startSummary or ctor" */);
63
63
  // Try to reuse the tree if unchanged
64
64
  if (this.canReuseHandle && !fullTree && !this.hasChanged()) {
@@ -156,25 +156,30 @@ export class SummarizerNode {
156
156
  /**
157
157
  * Refreshes the latest summary tracked by this node. If we have a pending summary for the given proposal handle,
158
158
  * it becomes the latest summary. If the current summary is already ahead (e.g., loaded from a service summary),
159
- * we skip the update. Otherwise, we get the snapshot by calling `getSnapshot` and update latest
160
- * summary based off of that.
159
+ * we skip the update. Otherwise, we fetch the latest snapshot and update latest summary based off of that.
161
160
  *
162
161
  * @returns A RefreshSummaryResult type which returns information based on the following three scenarios:
163
162
  *
164
- * 1. The latest summary was not udpated.
163
+ * 1. The latest summary was not updated.
165
164
  *
166
165
  * 2. The latest summary was updated and the summary corresponding to the params was being tracked.
167
166
  *
168
167
  * 3. The latest summary was updated but the summary corresponding to the params was not tracked. In this
169
168
  * case, the latest summary is updated based on the downloaded snapshot which is also returned.
170
169
  */
171
- async refreshLatestSummary(proposalHandle, summaryRefSeq, getSnapshot, readAndParseBlob, correlatedSummaryLogger) {
170
+ async refreshLatestSummary(proposalHandle, summaryRefSeq, fetchLatestSnapshot, readAndParseBlob, correlatedSummaryLogger) {
172
171
  var _a;
172
+ this.defaultLogger.sendTelemetryEvent({
173
+ eventName: "refreshLatestSummary_start",
174
+ proposalHandle,
175
+ referenceSequenceNumber: this.referenceSequenceNumber,
176
+ summaryRefSeq,
177
+ });
173
178
  if (proposalHandle !== undefined) {
174
179
  const maybeSummaryNode = this.pendingSummaries.get(proposalHandle);
175
180
  if (maybeSummaryNode !== undefined) {
176
181
  this.refreshLatestSummaryFromPending(proposalHandle, maybeSummaryNode.referenceSequenceNumber);
177
- return { latestSummaryUpdated: true, wasSummaryTracked: true };
182
+ return { latestSummaryUpdated: true, wasSummaryTracked: true, summaryRefSeq };
178
183
  }
179
184
  const props = {
180
185
  summaryRefSeq,
@@ -187,13 +192,25 @@ export class SummarizerNode {
187
192
  details: JSON.stringify(props),
188
193
  });
189
194
  }
190
- // If we have seen a summary same or later as the current one, ignore it.
195
+ // If the summary for which refresh is called is older than the latest tracked summary, ignore it.
191
196
  if (this.referenceSequenceNumber >= summaryRefSeq) {
192
197
  return { latestSummaryUpdated: false };
193
198
  }
194
- const snapshotTree = await getSnapshot();
195
- await this.refreshLatestSummaryFromSnapshot(summaryRefSeq, snapshotTree, undefined, EscapedPath.create(""), correlatedSummaryLogger, readAndParseBlob);
196
- return { latestSummaryUpdated: true, wasSummaryTracked: false, snapshot: snapshotTree };
199
+ // Fetch the latest snapshot and refresh state from it. Note that we need to use the reference sequence number
200
+ // of the fetched snapshot and not the "summaryRefSeq" that was passed in.
201
+ const { snapshotTree, snapshotRefSeq: fetchedSnapshotRefSeq } = await fetchLatestSnapshot();
202
+ // Possible re-entrancy. We may have updated latest summary state while fetching the snapshot. If the fetched
203
+ // snapshot is older than the latest tracked summary, ignore it.
204
+ if (this.referenceSequenceNumber >= fetchedSnapshotRefSeq) {
205
+ return { latestSummaryUpdated: false };
206
+ }
207
+ await this.refreshLatestSummaryFromSnapshot(fetchedSnapshotRefSeq, snapshotTree, undefined, EscapedPath.create(""), correlatedSummaryLogger, readAndParseBlob);
208
+ return {
209
+ latestSummaryUpdated: true,
210
+ wasSummaryTracked: false,
211
+ snapshotTree,
212
+ summaryRefSeq: fetchedSnapshotRefSeq,
213
+ };
197
214
  }
198
215
  /**
199
216
  * Called when we get an ack from the server for a summary we've just sent. Updates the reference state of this node
@@ -394,9 +411,9 @@ export class SummarizerNode {
394
411
  * @param child - The child node whose state is to be updated.
395
412
  */
396
413
  maybeUpdateChildState(child) {
397
- // If we are tracking a summary, this child was created after the tracking started. So, we need to update the
398
- // child's tracking state as well.
399
- if (this.isTrackingInProgress()) {
414
+ // If a summary is in progress, this child was created after the summary started. So, we need to update the
415
+ // child's summary state as well.
416
+ if (this.isSummaryInProgress()) {
400
417
  child.wipReferenceSequenceNumber = this.wipReferenceSequenceNumber;
401
418
  }
402
419
  // In case we have pending summaries on the parent, let's initialize it on the child.
@@ -417,7 +434,7 @@ export class SummarizerNode {
417
434
  /**
418
435
  * Tells whether summary tracking is in progress. True if "startSummary" API is called before summarize.
419
436
  */
420
- isTrackingInProgress() {
437
+ isSummaryInProgress() {
421
438
  return this.wipReferenceSequenceNumber !== undefined;
422
439
  }
423
440
  }