@fluidframework/container-runtime 2.11.0 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/api-report/container-runtime.legacy.alpha.api.md +17 -15
  3. package/container-runtime.test-files.tar +0 -0
  4. package/dist/blobManager/blobManagerSnapSum.js.map +1 -1
  5. package/dist/channelCollection.js.map +1 -1
  6. package/dist/containerRuntime.d.ts +38 -5
  7. package/dist/containerRuntime.d.ts.map +1 -1
  8. package/dist/containerRuntime.js +28 -7
  9. package/dist/containerRuntime.js.map +1 -1
  10. package/dist/gc/garbageCollection.d.ts.map +1 -1
  11. package/dist/gc/garbageCollection.js.map +1 -1
  12. package/dist/gc/gcConfigs.js +1 -1
  13. package/dist/gc/gcConfigs.js.map +1 -1
  14. package/dist/gc/gcHelpers.js.map +1 -1
  15. package/dist/gc/gcReferenceGraphAlgorithm.js.map +1 -1
  16. package/dist/index.d.ts +1 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/opLifecycle/opDecompressor.js +0 -1
  20. package/dist/opLifecycle/opDecompressor.js.map +1 -1
  21. package/dist/opLifecycle/opSplitter.js +0 -1
  22. package/dist/opLifecycle/opSplitter.js.map +1 -1
  23. package/dist/packageVersion.d.ts +1 -1
  24. package/dist/packageVersion.js +1 -1
  25. package/dist/packageVersion.js.map +1 -1
  26. package/dist/pendingStateManager.d.ts +4 -0
  27. package/dist/pendingStateManager.d.ts.map +1 -1
  28. package/dist/pendingStateManager.js +31 -1
  29. package/dist/pendingStateManager.js.map +1 -1
  30. package/dist/scheduleManager.js +0 -2
  31. package/dist/scheduleManager.js.map +1 -1
  32. package/dist/summary/runWhileConnectedCoordinator.d.ts +2 -1
  33. package/dist/summary/runWhileConnectedCoordinator.d.ts.map +1 -1
  34. package/dist/summary/runWhileConnectedCoordinator.js.map +1 -1
  35. package/dist/summary/runningSummarizer.d.ts +8 -1
  36. package/dist/summary/runningSummarizer.d.ts.map +1 -1
  37. package/dist/summary/runningSummarizer.js +70 -8
  38. package/dist/summary/runningSummarizer.js.map +1 -1
  39. package/dist/summary/summarizer.d.ts +5 -2
  40. package/dist/summary/summarizer.d.ts.map +1 -1
  41. package/dist/summary/summarizer.js +39 -6
  42. package/dist/summary/summarizer.js.map +1 -1
  43. package/dist/summary/summarizerTypes.d.ts +8 -4
  44. package/dist/summary/summarizerTypes.d.ts.map +1 -1
  45. package/dist/summary/summarizerTypes.js.map +1 -1
  46. package/dist/summary/summaryCollection.js +0 -2
  47. package/dist/summary/summaryCollection.js.map +1 -1
  48. package/dist/summary/summaryManager.d.ts +5 -2
  49. package/dist/summary/summaryManager.d.ts.map +1 -1
  50. package/dist/summary/summaryManager.js +23 -6
  51. package/dist/summary/summaryManager.js.map +1 -1
  52. package/lib/blobManager/blobManagerSnapSum.js.map +1 -1
  53. package/lib/channelCollection.js.map +1 -1
  54. package/lib/containerRuntime.d.ts +38 -5
  55. package/lib/containerRuntime.d.ts.map +1 -1
  56. package/lib/containerRuntime.js +28 -7
  57. package/lib/containerRuntime.js.map +1 -1
  58. package/lib/gc/garbageCollection.d.ts.map +1 -1
  59. package/lib/gc/garbageCollection.js.map +1 -1
  60. package/lib/gc/gcConfigs.js +1 -1
  61. package/lib/gc/gcConfigs.js.map +1 -1
  62. package/lib/gc/gcHelpers.js.map +1 -1
  63. package/lib/gc/gcReferenceGraphAlgorithm.js.map +1 -1
  64. package/lib/index.d.ts +1 -1
  65. package/lib/index.d.ts.map +1 -1
  66. package/lib/index.js.map +1 -1
  67. package/lib/opLifecycle/opDecompressor.js +0 -1
  68. package/lib/opLifecycle/opDecompressor.js.map +1 -1
  69. package/lib/opLifecycle/opSplitter.js +0 -1
  70. package/lib/opLifecycle/opSplitter.js.map +1 -1
  71. package/lib/packageVersion.d.ts +1 -1
  72. package/lib/packageVersion.js +1 -1
  73. package/lib/packageVersion.js.map +1 -1
  74. package/lib/pendingStateManager.d.ts +4 -0
  75. package/lib/pendingStateManager.d.ts.map +1 -1
  76. package/lib/pendingStateManager.js +29 -0
  77. package/lib/pendingStateManager.js.map +1 -1
  78. package/lib/scheduleManager.js +0 -2
  79. package/lib/scheduleManager.js.map +1 -1
  80. package/lib/summary/runWhileConnectedCoordinator.d.ts +2 -1
  81. package/lib/summary/runWhileConnectedCoordinator.d.ts.map +1 -1
  82. package/lib/summary/runWhileConnectedCoordinator.js.map +1 -1
  83. package/lib/summary/runningSummarizer.d.ts +8 -1
  84. package/lib/summary/runningSummarizer.d.ts.map +1 -1
  85. package/lib/summary/runningSummarizer.js +70 -8
  86. package/lib/summary/runningSummarizer.js.map +1 -1
  87. package/lib/summary/summarizer.d.ts +5 -2
  88. package/lib/summary/summarizer.d.ts.map +1 -1
  89. package/lib/summary/summarizer.js +39 -6
  90. package/lib/summary/summarizer.js.map +1 -1
  91. package/lib/summary/summarizerTypes.d.ts +8 -4
  92. package/lib/summary/summarizerTypes.d.ts.map +1 -1
  93. package/lib/summary/summarizerTypes.js.map +1 -1
  94. package/lib/summary/summaryCollection.js +0 -2
  95. package/lib/summary/summaryCollection.js.map +1 -1
  96. package/lib/summary/summaryManager.d.ts +5 -2
  97. package/lib/summary/summaryManager.d.ts.map +1 -1
  98. package/lib/summary/summaryManager.js +23 -6
  99. package/lib/summary/summaryManager.js.map +1 -1
  100. package/package.json +20 -20
  101. package/src/blobManager/blobManagerSnapSum.ts +1 -1
  102. package/src/channelCollection.ts +1 -1
  103. package/src/containerRuntime.ts +84 -24
  104. package/src/gc/garbageCollection.ts +2 -1
  105. package/src/gc/gcConfigs.ts +1 -1
  106. package/src/gc/gcHelpers.ts +2 -2
  107. package/src/gc/gcReferenceGraphAlgorithm.ts +1 -1
  108. package/src/index.ts +1 -0
  109. package/src/opLifecycle/opDecompressor.ts +1 -1
  110. package/src/opLifecycle/opSplitter.ts +1 -1
  111. package/src/packageVersion.ts +1 -1
  112. package/src/pendingStateManager.ts +38 -0
  113. package/src/scheduleManager.ts +2 -2
  114. package/src/summary/runWhileConnectedCoordinator.ts +2 -5
  115. package/src/summary/runningSummarizer.ts +82 -11
  116. package/src/summary/summarizer.ts +49 -10
  117. package/src/summary/summarizerTypes.ts +11 -4
  118. package/src/summary/summaryCollection.ts +2 -2
  119. package/src/summary/summaryManager.ts +30 -10
@@ -1 +1 @@
1
- {"version":3,"file":"summarizerTypes.d.ts","sourceRoot":"","sources":["../../src/summary/summarizerTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,aAAa,EACb,gBAAgB,EAChB,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACN,MAAM,EACN,cAAc,EACd,wBAAwB,EACxB,oBAAoB,EACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EACN,gBAAgB,EAChB,yBAAyB,EACzB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAC7E,OAAO,EACN,mBAAmB,EACnB,2BAA2B,EAC3B,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AAEzE,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACpC,mDAAmD;IACnD,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,GAAG,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;AAEjF;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACzC,wCAAwC;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AC/C,oEAAoE;AAClE,yBAAyB;AAC3B,iEAAiE;GAC/D,uBAAuB;AACzB,gHAAgH;GAC9G,qBAAqB;AACvB,gHAAgH;GAC9G,qBAAqB;AACvB;;;GAGG;GACD,0BAA0B;AAC5B,yEAAyE;GACvE,+BAA+B;AACjC,qEAAqE;GACnE,4BAA4B;AAC9B,mFAAmF;GACjF,kBAAkB;AACpB,2DAA2D;GACzD,kBAAkB;AACpB,4EAA4E;GAC1E,QAAQ;AACV,0DAA0D;GACxD,gBAAgB;AAClB,gFAAgF;GAC9E,sBAAsB;AACxB,uEAAuE;GACrE,iBAAiB;AACnB,wDAAwD;GACtD,uBAAuB;AACzB,yDAAyD;GACvD,uBAAuB;AACzB,oHAAoH;GAClH,gBAAgB;AAClB,mHAAmH;GACjH,OAAO,CAAC;AAEX,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC3C,wBAAwB,EACxB,2CAA2C,CAC3C,GACA,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,2CAA2C,CAAC,CAAC,CAAC;AAEtF,MAAM,WAAW,yBAA0B,SAAQ,2BAA2B;IAC7E,0CAA0C;IAC1C,cAAc,EAAE,MAAM,MAAM,CAAC;IAC7B,kDAAkD;IAClD,4BAA4B,EAAE,MAAM,MAAM,CAAC;CAC3C"}
1
+ {"version":3,"file":"summarizerTypes.d.ts","sourceRoot":"","sources":["../../src/summary/summarizerTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,aAAa,EACb,gBAAgB,EAChB,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EACX,iBAAiB,IAAI,oBAAoB,EACzC,oBAAoB,IAAI,uBAAuB,EAC/C,MAAM,wDAAwD,CAAC;AAChE,OAAO,EACN,MAAM,EACN,cAAc,EACd,wBAAwB,EACxB,oBAAoB,EACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EACN,gBAAgB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wB,EACxB,2CAA2C,CAC3C,GACA,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,2CAA2C,CAAC,CAAC,CAAC;AAEtF,MAAM,WAAW,yBAA0B,SAAQ,2BAA2B;IAC7E,0CAA0C;IAC1C,cAAc,EAAE,MAAM,MAAM,CAAC;IAC7B,kDAAkD;IAClD,4BAA4B,EAAE,MAAM,MAAM,CAAC;CAC3C"}
@@ -1 +1 @@
1
- {"version":3,"file":"summarizerTypes.js","sourceRoot":"","sources":["../../src/summary/summarizerTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIDeltaManager,\n\tContainerWarning,\n} from \"@fluidframework/container-definitions/internal\";\nimport {\n\tIEvent,\n\tIEventProvider,\n\tITelemetryBaseProperties,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentMessage,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { ISummaryStats } from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tITelemetryLoggerPropertyBag,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ISummaryConfigurationHeuristics } from \"../containerRuntime.js\";\n\nimport {\n\tISummaryAckMessage,\n\tISummaryNackMessage,\n\tISummaryOpMessage,\n} from \"./summaryCollection.js\";\nimport { SummarizeReason } from \"./summaryGenerator.js\";\n\n/**\n * Similar to AbortSignal, but using promise instead of events\n * @param T - cancellation reason type\n * @legacy\n * @alpha\n */\nexport interface ICancellationToken<T> {\n\t/** Tells if this cancellable token is cancelled */\n\treadonly cancelled: boolean;\n\t/**\n\t * Promise that gets fulfilled when this cancellable token is cancelled\n\t * @returns reason of cancellation\n\t */\n\treadonly waitCancelled: Promise<T>;\n}\n\n/**\n * Similar to AbortSignal, but using promise instead of events\n * @legacy\n * @alpha\n */\nexport type ISummaryCancellationToken = ICancellationToken<SummarizerStopReason>;\n\n/**\n * Data required to update internal tracking state after receiving a Summary Ack.\n * @legacy\n * @alpha\n */\nexport interface IRefreshSummaryAckOptions {\n\t/** Handle from the ack's summary op. */\n\treadonly proposalHandle: string | undefined;\n\t/** Handle from the summary ack just received */\n\treadonly ackHandle: string;\n\t/** Reference sequence number from the ack's summary op */\n\treadonly summaryRefSeq: number;\n\t/** Telemetry logger to which telemetry events will be forwarded. */\n\treadonly summaryLogger: ITelemetryLoggerExt;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface ISummarizerInternalsProvider {\n\t/** Encapsulates the work to walk the internals of the running container to generate a summary */\n\tsubmitSummary(options: ISubmitSummaryOptions): Promise<SubmitSummaryResult>;\n\n\t/** Callback whenever a new SummaryAck is received, to update internal tracking state */\n\trefreshLatestSummaryAck(options: IRefreshSummaryAckOptions): Promise<void>;\n}\n\n/**\n * @internal\n */\nexport interface ISummarizingWarning extends ContainerWarning {\n\treadonly errorType: \"summarizingError\";\n\treadonly logged: boolean;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IConnectableRuntime {\n\treadonly disposed: boolean;\n\treadonly connected: boolean;\n\treadonly clientId: string | undefined;\n\tonce(event: \"connected\" | \"disconnected\" | \"dispose\", listener: () => void): this;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface ISummarizerRuntime extends IConnectableRuntime {\n\treadonly baseLogger: ITelemetryBaseLogger;\n\t/** clientId of parent (non-summarizing) container that owns summarizer container */\n\treadonly summarizerClientId: string | undefined;\n\treadonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;\n\tdisposeFn(): void;\n\tcloseFn(): void;\n\ton(\n\t\tevent: \"op\",\n\t\tlistener: (op: ISequencedDocumentMessage, runtimeMessage?: boolean) => void,\n\t): this;\n\toff(\n\t\tevent: \"op\",\n\t\tlistener: (op: ISequencedDocumentMessage, runtimeMessage?: boolean) => void,\n\t): this;\n}\n\n/**\n * Options affecting summarize behavior.\n * @legacy\n * @alpha\n */\nexport interface ISummarizeOptions {\n\t/** True to generate the full tree with no handle reuse optimizations; defaults to false */\n\treadonly fullTree?: boolean;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface ISubmitSummaryOptions extends ISummarizeOptions {\n\t/** Logger to use for correlated summary events */\n\treadonly summaryLogger: ITelemetryLoggerExt;\n\t/** Tells when summary process should be cancelled */\n\treadonly cancellationToken: ISummaryCancellationToken;\n\t/** Summarization may be attempted multiple times. This tells whether this is the final summarization attempt. */\n\treadonly finalAttempt?: boolean;\n\t/** The sequence number of the latest summary used to validate if summary state is correct before summarizing */\n\treadonly latestSummaryRefSeqNum: number;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IOnDemandSummarizeOptions extends ISummarizeOptions {\n\t/** Reason for generating summary. */\n\treadonly reason: string;\n\t/** In case of a failure, will attempt to retry based on if the failure is retriable. */\n\treadonly retryOnFailure?: boolean;\n}\n\n/**\n * Options to use when enqueueing a summarize attempt.\n * @legacy\n * @alpha\n */\nexport interface IEnqueueSummarizeOptions extends IOnDemandSummarizeOptions {\n\t/** If specified, The summarize attempt will not occur until after this sequence number. */\n\treadonly afterSequenceNumber?: number;\n\n\t/**\n\t * True to override the existing enqueued summarize attempt if there is one.\n\t * This will guarantee that this attempt gets enqueued. If override is false,\n\t * than an existing enqueued summarize attempt will block a new one from being\n\t * enqueued. There can only be one enqueued at a time. Defaults to false.\n\t */\n\treadonly override?: boolean;\n}\n\n/**\n * In addition to the normal summary tree + stats, this contains additional stats\n * only relevant at the root of the tree.\n * @legacy\n * @alpha\n */\nexport interface IGeneratedSummaryStats extends ISummaryStats {\n\t/** The total number of data stores in the container. */\n\treadonly dataStoreCount: number;\n\t/** The number of data stores that were summarized in this summary. */\n\treadonly summarizedDataStoreCount: number;\n\t/** The number of data stores whose GC reference state was updated in this summary. */\n\treadonly gcStateUpdatedDataStoreCount?: number;\n\t/** The size of the gc blobs in this summary. */\n\treadonly gcTotalBlobsSize?: number;\n\t/** The number of gc blobs in this summary. */\n\treadonly gcBlobNodeCount?: number;\n\t/** The summary number for a container's summary. Incremented on summaries throughout its lifetime. */\n\treadonly summaryNumber: number;\n}\n\n/**\n * Type for summarization failures that are retriable.\n * @legacy\n * @alpha\n */\nexport interface IRetriableFailureError extends Error {\n\treadonly retryAfterSeconds?: number;\n}\n\n/**\n * Base results for all submitSummary attempts.\n * @legacy\n * @alpha\n */\nexport interface IBaseSummarizeResult {\n\treadonly stage: \"base\";\n\t/** Retriable error object related to failed summarize attempt. */\n\treadonly error: IRetriableFailureError | undefined;\n\t/** Reference sequence number as of the generate summary attempt. */\n\treadonly referenceSequenceNumber: number;\n\treadonly minimumSequenceNumber: number;\n}\n\n/**\n * Results of submitSummary after generating the summary tree.\n * @legacy\n * @alpha\n */\nexport interface IGenerateSummaryTreeResult extends Omit<IBaseSummarizeResult, \"stage\"> {\n\treadonly stage: \"generate\";\n\t/** Generated summary tree. */\n\treadonly summaryTree: ISummaryTree;\n\t/** Stats for generated summary tree. */\n\treadonly summaryStats: IGeneratedSummaryStats;\n\t/** Time it took to generate the summary tree and stats. */\n\treadonly generateDuration: number;\n}\n\n/**\n * Results of submitSummary after uploading the tree to storage.\n * @legacy\n * @alpha\n */\nexport interface IUploadSummaryResult extends Omit<IGenerateSummaryTreeResult, \"stage\"> {\n\treadonly stage: \"upload\";\n\t/** The handle returned by storage pointing to the uploaded summary tree. */\n\treadonly handle: string;\n\t/** Time it took to upload the summary tree to storage. */\n\treadonly uploadDuration: number;\n}\n\n/**\n * Results of submitSummary after submitting the summarize op.\n * @legacy\n * @alpha\n */\nexport interface ISubmitSummaryOpResult extends Omit<IUploadSummaryResult, \"stage\" | \"error\"> {\n\treadonly stage: \"submit\";\n\t/** The client sequence number of the summarize op submitted for the summary. */\n\treadonly clientSequenceNumber: number;\n\t/** Time it took to submit the summarize op to the broadcasting service. */\n\treadonly submitOpDuration: number;\n}\n\n/**\n * Strict type representing result of a submitSummary attempt.\n * The result consists of 4 possible stages, each with its own data.\n * The data is cumulative, so each stage will contain the data from the previous stages.\n * If the final \"submitted\" stage is not reached, the result may contain the error object.\n *\n * Stages:\n *\n * 1. \"base\" - stopped before the summary tree was even generated, and the result only contains the base data\n *\n * 2. \"generate\" - the summary tree was generated, and the result will contain that tree + stats\n *\n * 3. \"upload\" - the summary was uploaded to storage, and the result contains the server-provided handle\n *\n * 4. \"submit\" - the summarize op was submitted, and the result contains the op client sequence number.\n * @legacy\n * @alpha\n */\nexport type SubmitSummaryResult =\n\t| IBaseSummarizeResult\n\t| IGenerateSummaryTreeResult\n\t| IUploadSummaryResult\n\t| ISubmitSummaryOpResult;\n\n/**\n * The stages of Summarize, used to describe how far progress succeeded in case of a failure at a later stage.\n * @legacy\n * @alpha\n */\nexport type SummaryStage = SubmitSummaryResult[\"stage\"] | \"unknown\";\n\n/**\n * The data in summarizer result when submit summary stage fails.\n * @legacy\n * @alpha\n */\nexport interface SubmitSummaryFailureData {\n\tstage: SummaryStage;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IBroadcastSummaryResult {\n\treadonly summarizeOp: ISummaryOpMessage;\n\treadonly broadcastDuration: number;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IAckSummaryResult {\n\treadonly summaryAckOp: ISummaryAckMessage;\n\treadonly ackNackDuration: number;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface INackSummaryResult {\n\treadonly summaryNackOp: ISummaryNackMessage;\n\treadonly ackNackDuration: number;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport type SummarizeResultPart<TSuccess, TFailure = undefined> =\n\t| {\n\t\t\tsuccess: true;\n\t\t\tdata: TSuccess;\n\t }\n\t| {\n\t\t\tsuccess: false;\n\t\t\tdata: TFailure | undefined;\n\t\t\tmessage: string;\n\t\t\terror: IRetriableFailureError;\n\t };\n\n/**\n * @legacy\n * @alpha\n */\nexport interface ISummarizeResults {\n\t/** Resolves when we generate, upload, and submit the summary. */\n\treadonly summarySubmitted: Promise<\n\t\tSummarizeResultPart<SubmitSummaryResult, SubmitSummaryFailureData>\n\t>;\n\t/** Resolves when we observe our summarize op broadcast. */\n\treadonly summaryOpBroadcasted: Promise<SummarizeResultPart<IBroadcastSummaryResult>>;\n\t/** Resolves when we receive a summaryAck or summaryNack. */\n\treadonly receivedSummaryAckOrNack: Promise<\n\t\tSummarizeResultPart<IAckSummaryResult, INackSummaryResult>\n\t>;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport type EnqueueSummarizeResult =\n\t| (ISummarizeResults & {\n\t\t\t/**\n\t\t\t * Indicates that another summarize attempt is not already enqueued,\n\t\t\t * and this attempt has been enqueued.\n\t\t\t */\n\t\t\treadonly alreadyEnqueued?: undefined;\n\t })\n\t| (ISummarizeResults & {\n\t\t\t/** Indicates that another summarize attempt was already enqueued. */\n\t\t\treadonly alreadyEnqueued: true;\n\t\t\t/**\n\t\t\t * Indicates that the other enqueued summarize attempt was abandoned,\n\t\t\t * and this attempt has been enqueued enqueued.\n\t\t\t */\n\t\t\treadonly overridden: true;\n\t })\n\t| {\n\t\t\t/** Indicates that another summarize attempt was already enqueued. */\n\t\t\treadonly alreadyEnqueued: true;\n\t\t\t/**\n\t\t\t * Indicates that the other enqueued summarize attempt remains enqueued,\n\t\t\t * and this attempt has not been enqueued.\n\t\t\t */\n\t\t\treadonly overridden?: undefined;\n\t };\n\n/**\n * @legacy\n * @alpha\n */\nexport type SummarizerStopReason =\n\t/** Summarizer client failed to summarize in all attempts. */\n\t| \"failToSummarize\"\n\t/** Parent client reported that it is no longer connected. */\n\t| \"parentNotConnected\"\n\t/**\n\t * Parent client reported that it is no longer elected the summarizer.\n\t * This is the normal flow; a disconnect will always trigger the parent\n\t * client to no longer be elected as responsible for summaries. Then it\n\t * tries to stop its spawned summarizer client.\n\t */\n\t| \"notElectedParent\"\n\t/**\n\t * We are not already running the summarizer and we are not the current elected client id.\n\t */\n\t| \"notElectedClient\"\n\t/** Summarizer client was disconnected */\n\t| \"summarizerClientDisconnected\"\n\t/** running summarizer threw an exception */\n\t| \"summarizerException\"\n\t/**\n\t * The previous summary state on the summarizer is not the most recently acked summary. this also happens when the\n\t * first submitSummary attempt fails for any reason and there's a 2nd summary attempt without an ack\n\t */\n\t| \"latestSummaryStateStale\";\n\n/**\n * @legacy\n * @alpha\n */\nexport interface ISummarizeEventProps {\n\tresult: \"success\" | \"failure\" | \"canceled\";\n\tcurrentAttempt: number;\n\tmaxAttempts: number;\n\terror?: any;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface ISummarizerEvents extends IEvent {\n\t(event: \"summarize\", listener: (props: ISummarizeEventProps) => void);\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface ISummarizer extends IEventProvider<ISummarizerEvents> {\n\t/**\n\t * Allows {@link ISummarizer} to be used with our {@link @fluidframework/core-interfaces#FluidObject} pattern.\n\t */\n\treadonly ISummarizer?: ISummarizer;\n\n\t/*\n\t * Asks summarizer to move to exit.\n\t * Summarizer will finish current processes, which may take a while.\n\t * For example, summarizer may complete last summary before exiting.\n\t */\n\tstop(reason: SummarizerStopReason): void;\n\n\t/* Closes summarizer. Any pending processes (summary in flight) are abandoned. */\n\tclose(): void;\n\n\trun(onBehalfOf: string): Promise<SummarizerStopReason>;\n\n\t/**\n\t * Attempts to generate a summary on demand. If already running, takes no action.\n\t * @param options - options controlling the summarize attempt\n\t * @returns an alreadyRunning promise if a summarize attempt is already in progress,\n\t * which will resolve when the current attempt completes. At that point caller can\n\t * decide to try again or not. Otherwise, it will return an object containing promises\n\t * that resolve as the summarize attempt progresses. They will resolve with success\n\t * false if a failure is encountered.\n\t */\n\tsummarizeOnDemand(options: IOnDemandSummarizeOptions): ISummarizeResults;\n\t/**\n\t * Enqueue an attempt to summarize after the specified sequence number.\n\t * If afterSequenceNumber is provided, the summarize attempt is \"enqueued\"\n\t * to run once an eligible op comes in with sequenceNumber \\>= afterSequenceNumber.\n\t * @param options - options controlling the summarize attempt\n\t * @returns an object containing an alreadyEnqueued flag to indicate if another\n\t * summarize attempt has already been enqueued. It also may contain an overridden flag\n\t * when alreadyEnqueued is true, that indicates whether this attempt forced the\n\t * previous attempt to abort. If this attempt becomes enqueued, it returns an object\n\t * containing promises that resolve as the summarize attempt progresses. They will\n\t * resolve with success false if a failure is encountered.\n\t */\n\tenqueueSummarize(options: IEnqueueSummarizeOptions): EnqueueSummarizeResult;\n}\n\n/** Data about an attempt to summarize used for heuristics. */\nexport interface ISummarizeAttempt {\n\t/** Reference sequence number when summary was generated or attempted */\n\treadonly refSequenceNumber: number;\n\n\t/** Time of summary attempt after it was sent or attempted */\n\treadonly summaryTime: number;\n\n\t/** Sequence number of summary op */\n\tsummarySequenceNumber?: number;\n}\n\n/** Data relevant for summary heuristics. */\nexport interface ISummarizeHeuristicData {\n\t/** Latest received op sequence number */\n\tlastOpSequenceNumber: number;\n\n\t/** Most recent summary attempt from this client */\n\treadonly lastAttempt: ISummarizeAttempt;\n\n\t/** Most recent summary that received an ack */\n\treadonly lastSuccessfulSummary: Readonly<ISummarizeAttempt>;\n\n\t/** Number of runtime ops since last summary */\n\tnumRuntimeOps: number;\n\n\t/** Number of non-runtime ops since last summary */\n\tnumNonRuntimeOps: number;\n\n\t/** Cumulative size in bytes of all the ops since the last summary */\n\ttotalOpsSize: number;\n\n\t/** Wether or not this instance contains adjusted metrics due to missing op data */\n\thasMissingOpData: boolean;\n\n\t/**\n\t * Updates lastAttempt and lastSuccessfulAttempt based on the last summary.\n\t * @param lastSummary - last ack summary\n\t */\n\tupdateWithLastSummaryAckInfo(lastSummary: ISummarizeAttempt): void;\n\n\t/**\n\t * Records a summary attempt. If the attempt was successfully sent,\n\t * provide the reference sequence number, otherwise it will be set\n\t * to the last seen op sequence number.\n\t * @param referenceSequenceNumber - reference sequence number of sent summary\n\t */\n\trecordAttempt(referenceSequenceNumber?: number): void;\n\n\t/** Mark that the last sent summary attempt has received an ack */\n\tmarkLastAttemptAsSuccessful(): void;\n\n\topsSinceLastSummary: number;\n}\n\n/** Responsible for running heuristics determining when to summarize. */\nexport interface ISummarizeHeuristicRunner {\n\t/** Start specific heuristic trackers (ex: idle timer) */\n\tstart(): void;\n\n\t/** Runs the heuristics to determine if it should try to summarize */\n\trun(): void;\n\n\t/** Runs a different heuristic to check if it should summarize before closing */\n\tshouldRunLastSummary(): boolean;\n\n\t/** Disposes of resources */\n\tdispose(): void;\n}\n\ntype ISummarizeTelemetryRequiredProperties =\n\t/** Reason code for attempting to summarize */\n\t\"summarizeReason\";\n\ntype ISummarizeTelemetryOptionalProperties =\n\t/** Number of attempts within the last time window, used for calculating the throttle delay. */\n\t| \"summaryAttempts\"\n\t/** Summarization may be attempted multiple times. This tells whether this is the final summarization attempt */\n\t| \"finalAttempt\"\n\t| keyof ISummarizeOptions;\n\nexport type ISummarizeTelemetryProperties = Pick<\n\tITelemetryBaseProperties,\n\tISummarizeTelemetryRequiredProperties\n> &\n\tPartial<Pick<ITelemetryBaseProperties, ISummarizeTelemetryOptionalProperties>>;\n\n/** Strategy used to heuristically determine when we should run a summary */\nexport interface ISummaryHeuristicStrategy {\n\t/** Summarize reason for this summarize heuristic strategy (ex: \"maxTime\") */\n\tsummarizeReason: Readonly<SummarizeReason>;\n\n\t/**\n\t * Determines if this strategy's summarize criteria been met\n\t * @param configuration - summary configuration we are to check against\n\t * @param heuristicData - heuristic data used to confirm conditions are met\n\t */\n\tshouldRunSummary(\n\t\tconfiguration: ISummaryConfigurationHeuristics,\n\t\theuristicData: ISummarizeHeuristicData,\n\t): boolean;\n}\n\ntype SummaryGeneratorRequiredTelemetryProperties =\n\t/** True to generate the full tree with no handle reuse optimizations */\n\t| \"fullTree\"\n\t/** Time since we last attempted to generate a summary */\n\t| \"timeSinceLastAttempt\"\n\t/** Time since we last successfully generated a summary */\n\t| \"timeSinceLastSummary\";\n\ntype SummaryGeneratorOptionalTelemetryProperties =\n\t/** Reference sequence number as of the generate summary attempt. */\n\t| \"referenceSequenceNumber\"\n\t/** minimum sequence number (at the reference sequence number) */\n\t| \"minimumSequenceNumber\"\n\t/** Delta between the current reference sequence number and the reference sequence number of the last attempt */\n\t| \"opsSinceLastAttempt\"\n\t/** Delta between the current reference sequence number and the reference sequence number of the last summary */\n\t| \"opsSinceLastSummary\"\n\t/**\n\t * Delta in sum of op sizes between the current reference sequence number and the reference\n\t * sequence number of the last summary\n\t */\n\t| \"opsSizesSinceLastSummary\"\n\t/** Delta between the number of non-runtime ops since the last summary */\n\t| \"nonRuntimeOpsSinceLastSummary\"\n\t/** Delta between the number of runtime ops since the last summary */\n\t| \"runtimeOpsSinceLastSummary\"\n\t/** Wether or not this instance contains adjusted metrics due to missing op data */\n\t| \"hasMissingOpData\"\n\t/** Time it took to generate the summary tree and stats. */\n\t| \"generateDuration\"\n\t/** The handle returned by storage pointing to the uploaded summary tree. */\n\t| \"handle\"\n\t/** Time it took to upload the summary tree to storage. */\n\t| \"uploadDuration\"\n\t/** The client sequence number of the summarize op submitted for the summary. */\n\t| \"clientSequenceNumber\"\n\t/** Time it took for this summary to be acked after it was generated */\n\t| \"ackWaitDuration\"\n\t/** Reference sequence number of the ack/nack message */\n\t| \"ackNackSequenceNumber\"\n\t/** Actual sequence number of the summary op proposal. */\n\t| \"summarySequenceNumber\"\n\t/** Optional Retry-After time in seconds. If specified, the client should wait this many seconds before retrying. */\n\t| \"nackRetryAfter\"\n\t/** The stage at which the submit summary method failed at. This can help determine what type of failure we have */\n\t| \"stage\";\n\nexport type SummaryGeneratorTelemetry = Pick<\n\tITelemetryBaseProperties,\n\tSummaryGeneratorRequiredTelemetryProperties\n> &\n\tPartial<Pick<ITelemetryBaseProperties, SummaryGeneratorOptionalTelemetryProperties>>;\n\nexport interface ISummarizeRunnerTelemetry extends ITelemetryLoggerPropertyBag {\n\t/** Number of times the summarizer run. */\n\tsummarizeCount: () => number;\n\t/** Number of successful attempts to summarize. */\n\tsummarizerSuccessfulAttempts: () => number;\n}\n"]}
1
+ {"version":3,"file":"summarizerTypes.js","sourceRoot":"","sources":["../../src/summary/summarizerTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIDeltaManager,\n\tContainerWarning,\n} from \"@fluidframework/container-definitions/internal\";\nimport type {\n\tISummarizerEvents as NewISummarizerEvents,\n\tSummarizerStopReason as NewSummarizerStopReason,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport {\n\tIEvent,\n\tIEventProvider,\n\tITelemetryBaseProperties,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentMessage,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { ISummaryStats } from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tITelemetryLoggerPropertyBag,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ISummaryConfigurationHeuristics } from \"../containerRuntime.js\";\n\nimport {\n\tISummaryAckMessage,\n\tISummaryNackMessage,\n\tISummaryOpMessage,\n} from \"./summaryCollection.js\";\nimport { SummarizeReason } from \"./summaryGenerator.js\";\n\n/**\n * Similar to AbortSignal, but using promise instead of events\n * @param T - cancellation reason type\n * @legacy\n * @alpha\n */\nexport interface ICancellationToken<T> {\n\t/** Tells if this cancellable token is cancelled */\n\treadonly cancelled: boolean;\n\t/**\n\t * Promise that gets fulfilled when this cancellable token is cancelled\n\t * @returns reason of cancellation\n\t */\n\treadonly waitCancelled: Promise<T>;\n}\n\n/**\n * Similar to AbortSignal, but using promise instead of events\n * @legacy\n * @alpha\n */\nexport type ISummaryCancellationToken = ICancellationToken<NewSummarizerStopReason>;\n\n/**\n * Data required to update internal tracking state after receiving a Summary Ack.\n * @legacy\n * @alpha\n */\nexport interface IRefreshSummaryAckOptions {\n\t/** Handle from the ack's summary op. */\n\treadonly proposalHandle: string | undefined;\n\t/** Handle from the summary ack just received */\n\treadonly ackHandle: string;\n\t/** Reference sequence number from the ack's summary op */\n\treadonly summaryRefSeq: number;\n\t/** Telemetry logger to which telemetry events will be forwarded. */\n\treadonly summaryLogger: ITelemetryLoggerExt;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface ISummarizerInternalsProvider {\n\t/** Encapsulates the work to walk the internals of the running container to generate a summary */\n\tsubmitSummary(options: ISubmitSummaryOptions): Promise<SubmitSummaryResult>;\n\n\t/** Callback whenever a new SummaryAck is received, to update internal tracking state */\n\trefreshLatestSummaryAck(options: IRefreshSummaryAckOptions): Promise<void>;\n}\n\n/**\n * @internal\n */\nexport interface ISummarizingWarning extends ContainerWarning {\n\treadonly errorType: \"summarizingError\";\n\treadonly logged: boolean;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IConnectableRuntime {\n\treadonly disposed: boolean;\n\treadonly connected: boolean;\n\treadonly clientId: string | undefined;\n\tonce(event: \"connected\" | \"disconnected\" | \"dispose\", listener: () => void): this;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface ISummarizerRuntime extends IConnectableRuntime {\n\treadonly baseLogger: ITelemetryBaseLogger;\n\t/** clientId of parent (non-summarizing) container that owns summarizer container */\n\treadonly summarizerClientId: string | undefined;\n\treadonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;\n\tdisposeFn(): void;\n\tcloseFn(): void;\n\ton(\n\t\tevent: \"op\",\n\t\tlistener: (op: ISequencedDocumentMessage, runtimeMessage?: boolean) => void,\n\t): this;\n\toff(\n\t\tevent: \"op\",\n\t\tlistener: (op: ISequencedDocumentMessage, runtimeMessage?: boolean) => void,\n\t): this;\n}\n\n/**\n * Options affecting summarize behavior.\n * @legacy\n * @alpha\n */\nexport interface ISummarizeOptions {\n\t/** True to generate the full tree with no handle reuse optimizations; defaults to false */\n\treadonly fullTree?: boolean;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface ISubmitSummaryOptions extends ISummarizeOptions {\n\t/** Logger to use for correlated summary events */\n\treadonly summaryLogger: ITelemetryLoggerExt;\n\t/** Tells when summary process should be cancelled */\n\treadonly cancellationToken: ISummaryCancellationToken;\n\t/** Summarization may be attempted multiple times. This tells whether this is the final summarization attempt. */\n\treadonly finalAttempt?: boolean;\n\t/** The sequence number of the latest summary used to validate if summary state is correct before summarizing */\n\treadonly latestSummaryRefSeqNum: number;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IOnDemandSummarizeOptions extends ISummarizeOptions {\n\t/** Reason for generating summary. */\n\treadonly reason: string;\n\t/** In case of a failure, will attempt to retry based on if the failure is retriable. */\n\treadonly retryOnFailure?: boolean;\n}\n\n/**\n * Options to use when enqueueing a summarize attempt.\n * @legacy\n * @alpha\n */\nexport interface IEnqueueSummarizeOptions extends IOnDemandSummarizeOptions {\n\t/** If specified, The summarize attempt will not occur until after this sequence number. */\n\treadonly afterSequenceNumber?: number;\n\n\t/**\n\t * True to override the existing enqueued summarize attempt if there is one.\n\t * This will guarantee that this attempt gets enqueued. If override is false,\n\t * than an existing enqueued summarize attempt will block a new one from being\n\t * enqueued. There can only be one enqueued at a time. Defaults to false.\n\t */\n\treadonly override?: boolean;\n}\n\n/**\n * In addition to the normal summary tree + stats, this contains additional stats\n * only relevant at the root of the tree.\n * @legacy\n * @alpha\n */\nexport interface IGeneratedSummaryStats extends ISummaryStats {\n\t/** The total number of data stores in the container. */\n\treadonly dataStoreCount: number;\n\t/** The number of data stores that were summarized in this summary. */\n\treadonly summarizedDataStoreCount: number;\n\t/** The number of data stores whose GC reference state was updated in this summary. */\n\treadonly gcStateUpdatedDataStoreCount?: number;\n\t/** The size of the gc blobs in this summary. */\n\treadonly gcTotalBlobsSize?: number;\n\t/** The number of gc blobs in this summary. */\n\treadonly gcBlobNodeCount?: number;\n\t/** The summary number for a container's summary. Incremented on summaries throughout its lifetime. */\n\treadonly summaryNumber: number;\n}\n\n/**\n * Type for summarization failures that are retriable.\n * @legacy\n * @alpha\n */\nexport interface IRetriableFailureError extends Error {\n\treadonly retryAfterSeconds?: number;\n}\n\n/**\n * Base results for all submitSummary attempts.\n * @legacy\n * @alpha\n */\nexport interface IBaseSummarizeResult {\n\treadonly stage: \"base\";\n\t/** Retriable error object related to failed summarize attempt. */\n\treadonly error: IRetriableFailureError | undefined;\n\t/** Reference sequence number as of the generate summary attempt. */\n\treadonly referenceSequenceNumber: number;\n\treadonly minimumSequenceNumber: number;\n}\n\n/**\n * Results of submitSummary after generating the summary tree.\n * @legacy\n * @alpha\n */\nexport interface IGenerateSummaryTreeResult extends Omit<IBaseSummarizeResult, \"stage\"> {\n\treadonly stage: \"generate\";\n\t/** Generated summary tree. */\n\treadonly summaryTree: ISummaryTree;\n\t/** Stats for generated summary tree. */\n\treadonly summaryStats: IGeneratedSummaryStats;\n\t/** Time it took to generate the summary tree and stats. */\n\treadonly generateDuration: number;\n}\n\n/**\n * Results of submitSummary after uploading the tree to storage.\n * @legacy\n * @alpha\n */\nexport interface IUploadSummaryResult extends Omit<IGenerateSummaryTreeResult, \"stage\"> {\n\treadonly stage: \"upload\";\n\t/** The handle returned by storage pointing to the uploaded summary tree. */\n\treadonly handle: string;\n\t/** Time it took to upload the summary tree to storage. */\n\treadonly uploadDuration: number;\n}\n\n/**\n * Results of submitSummary after submitting the summarize op.\n * @legacy\n * @alpha\n */\nexport interface ISubmitSummaryOpResult extends Omit<IUploadSummaryResult, \"stage\" | \"error\"> {\n\treadonly stage: \"submit\";\n\t/** The client sequence number of the summarize op submitted for the summary. */\n\treadonly clientSequenceNumber: number;\n\t/** Time it took to submit the summarize op to the broadcasting service. */\n\treadonly submitOpDuration: number;\n}\n\n/**\n * Strict type representing result of a submitSummary attempt.\n * The result consists of 4 possible stages, each with its own data.\n * The data is cumulative, so each stage will contain the data from the previous stages.\n * If the final \"submitted\" stage is not reached, the result may contain the error object.\n *\n * Stages:\n *\n * 1. \"base\" - stopped before the summary tree was even generated, and the result only contains the base data\n *\n * 2. \"generate\" - the summary tree was generated, and the result will contain that tree + stats\n *\n * 3. \"upload\" - the summary was uploaded to storage, and the result contains the server-provided handle\n *\n * 4. \"submit\" - the summarize op was submitted, and the result contains the op client sequence number.\n * @legacy\n * @alpha\n */\nexport type SubmitSummaryResult =\n\t| IBaseSummarizeResult\n\t| IGenerateSummaryTreeResult\n\t| IUploadSummaryResult\n\t| ISubmitSummaryOpResult;\n\n/**\n * The stages of Summarize, used to describe how far progress succeeded in case of a failure at a later stage.\n * @legacy\n * @alpha\n */\nexport type SummaryStage = SubmitSummaryResult[\"stage\"] | \"unknown\";\n\n/**\n * The data in summarizer result when submit summary stage fails.\n * @legacy\n * @alpha\n */\nexport interface SubmitSummaryFailureData {\n\tstage: SummaryStage;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IBroadcastSummaryResult {\n\treadonly summarizeOp: ISummaryOpMessage;\n\treadonly broadcastDuration: number;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IAckSummaryResult {\n\treadonly summaryAckOp: ISummaryAckMessage;\n\treadonly ackNackDuration: number;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface INackSummaryResult {\n\treadonly summaryNackOp: ISummaryNackMessage;\n\treadonly ackNackDuration: number;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport type SummarizeResultPart<TSuccess, TFailure = undefined> =\n\t| {\n\t\t\tsuccess: true;\n\t\t\tdata: TSuccess;\n\t }\n\t| {\n\t\t\tsuccess: false;\n\t\t\tdata: TFailure | undefined;\n\t\t\tmessage: string;\n\t\t\terror: IRetriableFailureError;\n\t };\n\n/**\n * @legacy\n * @alpha\n */\nexport interface ISummarizeResults {\n\t/** Resolves when we generate, upload, and submit the summary. */\n\treadonly summarySubmitted: Promise<\n\t\tSummarizeResultPart<SubmitSummaryResult, SubmitSummaryFailureData>\n\t>;\n\t/** Resolves when we observe our summarize op broadcast. */\n\treadonly summaryOpBroadcasted: Promise<SummarizeResultPart<IBroadcastSummaryResult>>;\n\t/** Resolves when we receive a summaryAck or summaryNack. */\n\treadonly receivedSummaryAckOrNack: Promise<\n\t\tSummarizeResultPart<IAckSummaryResult, INackSummaryResult>\n\t>;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport type EnqueueSummarizeResult =\n\t| (ISummarizeResults & {\n\t\t\t/**\n\t\t\t * Indicates that another summarize attempt is not already enqueued,\n\t\t\t * and this attempt has been enqueued.\n\t\t\t */\n\t\t\treadonly alreadyEnqueued?: undefined;\n\t })\n\t| (ISummarizeResults & {\n\t\t\t/** Indicates that another summarize attempt was already enqueued. */\n\t\t\treadonly alreadyEnqueued: true;\n\t\t\t/**\n\t\t\t * Indicates that the other enqueued summarize attempt was abandoned,\n\t\t\t * and this attempt has been enqueued enqueued.\n\t\t\t */\n\t\t\treadonly overridden: true;\n\t })\n\t| {\n\t\t\t/** Indicates that another summarize attempt was already enqueued. */\n\t\t\treadonly alreadyEnqueued: true;\n\t\t\t/**\n\t\t\t * Indicates that the other enqueued summarize attempt remains enqueued,\n\t\t\t * and this attempt has not been enqueued.\n\t\t\t */\n\t\t\treadonly overridden?: undefined;\n\t };\n\n/**\n * @legacy\n * @alpha\n * @deprecated Use SummarizerStopReason from the \"\\@fluidframework/container-runtime-definitions\" package\n */\nexport type SummarizerStopReason =\n\t/** Summarizer client failed to summarize in all attempts. */\n\t| \"failToSummarize\"\n\t/** Parent client reported that it is no longer connected. */\n\t| \"parentNotConnected\"\n\t/**\n\t * Parent client reported that it is no longer elected the summarizer.\n\t * This is the normal flow; a disconnect will always trigger the parent\n\t * client to no longer be elected as responsible for summaries. Then it\n\t * tries to stop its spawned summarizer client.\n\t */\n\t| \"notElectedParent\"\n\t/**\n\t * We are not already running the summarizer and we are not the current elected client id.\n\t */\n\t| \"notElectedClient\"\n\t/** Summarizer client was disconnected */\n\t| \"summarizerClientDisconnected\"\n\t/** running summarizer threw an exception */\n\t| \"summarizerException\"\n\t/**\n\t * The previous summary state on the summarizer is not the most recently acked summary. this also happens when the\n\t * first submitSummary attempt fails for any reason and there's a 2nd summary attempt without an ack\n\t */\n\t| \"latestSummaryStateStale\";\n\n/**\n * @legacy\n * @alpha\n * @deprecated Use ISummarizeEventProps from the \"\\@fluidframework/container-runtime-definitions\" package\n */\nexport interface ISummarizeEventProps {\n\tresult: \"success\" | \"failure\" | \"canceled\";\n\tcurrentAttempt: number;\n\tmaxAttempts: number;\n\terror?: any;\n}\n\n/**\n * @legacy\n * @alpha\n * @deprecated Use ISummarizerEvents from the \"\\@fluidframework/container-runtime-definitions\" package\n */\nexport interface ISummarizerEvents extends IEvent {\n\t(event: \"summarize\", listener: (props: ISummarizeEventProps) => void);\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface ISummarizer extends IEventProvider<NewISummarizerEvents> {\n\t/**\n\t * Allows {@link ISummarizer} to be used with our {@link @fluidframework/core-interfaces#FluidObject} pattern.\n\t */\n\treadonly ISummarizer?: ISummarizer;\n\n\t/*\n\t * Asks summarizer to move to exit.\n\t * Summarizer will finish current processes, which may take a while.\n\t * For example, summarizer may complete last summary before exiting.\n\t */\n\tstop(reason: NewSummarizerStopReason): void;\n\n\t/* Closes summarizer. Any pending processes (summary in flight) are abandoned. */\n\tclose(): void;\n\n\trun(onBehalfOf: string): Promise<NewSummarizerStopReason>;\n\n\t/**\n\t * Attempts to generate a summary on demand. If already running, takes no action.\n\t * @param options - options controlling the summarize attempt\n\t * @returns an alreadyRunning promise if a summarize attempt is already in progress,\n\t * which will resolve when the current attempt completes. At that point caller can\n\t * decide to try again or not. Otherwise, it will return an object containing promises\n\t * that resolve as the summarize attempt progresses. They will resolve with success\n\t * false if a failure is encountered.\n\t */\n\tsummarizeOnDemand(options: IOnDemandSummarizeOptions): ISummarizeResults;\n\t/**\n\t * Enqueue an attempt to summarize after the specified sequence number.\n\t * If afterSequenceNumber is provided, the summarize attempt is \"enqueued\"\n\t * to run once an eligible op comes in with sequenceNumber \\>= afterSequenceNumber.\n\t * @param options - options controlling the summarize attempt\n\t * @returns an object containing an alreadyEnqueued flag to indicate if another\n\t * summarize attempt has already been enqueued. It also may contain an overridden flag\n\t * when alreadyEnqueued is true, that indicates whether this attempt forced the\n\t * previous attempt to abort. If this attempt becomes enqueued, it returns an object\n\t * containing promises that resolve as the summarize attempt progresses. They will\n\t * resolve with success false if a failure is encountered.\n\t */\n\tenqueueSummarize(options: IEnqueueSummarizeOptions): EnqueueSummarizeResult;\n}\n\n/** Data about an attempt to summarize used for heuristics. */\nexport interface ISummarizeAttempt {\n\t/** Reference sequence number when summary was generated or attempted */\n\treadonly refSequenceNumber: number;\n\n\t/** Time of summary attempt after it was sent or attempted */\n\treadonly summaryTime: number;\n\n\t/** Sequence number of summary op */\n\tsummarySequenceNumber?: number;\n}\n\n/** Data relevant for summary heuristics. */\nexport interface ISummarizeHeuristicData {\n\t/** Latest received op sequence number */\n\tlastOpSequenceNumber: number;\n\n\t/** Most recent summary attempt from this client */\n\treadonly lastAttempt: ISummarizeAttempt;\n\n\t/** Most recent summary that received an ack */\n\treadonly lastSuccessfulSummary: Readonly<ISummarizeAttempt>;\n\n\t/** Number of runtime ops since last summary */\n\tnumRuntimeOps: number;\n\n\t/** Number of non-runtime ops since last summary */\n\tnumNonRuntimeOps: number;\n\n\t/** Cumulative size in bytes of all the ops since the last summary */\n\ttotalOpsSize: number;\n\n\t/** Wether or not this instance contains adjusted metrics due to missing op data */\n\thasMissingOpData: boolean;\n\n\t/**\n\t * Updates lastAttempt and lastSuccessfulAttempt based on the last summary.\n\t * @param lastSummary - last ack summary\n\t */\n\tupdateWithLastSummaryAckInfo(lastSummary: ISummarizeAttempt): void;\n\n\t/**\n\t * Records a summary attempt. If the attempt was successfully sent,\n\t * provide the reference sequence number, otherwise it will be set\n\t * to the last seen op sequence number.\n\t * @param referenceSequenceNumber - reference sequence number of sent summary\n\t */\n\trecordAttempt(referenceSequenceNumber?: number): void;\n\n\t/** Mark that the last sent summary attempt has received an ack */\n\tmarkLastAttemptAsSuccessful(): void;\n\n\topsSinceLastSummary: number;\n}\n\n/** Responsible for running heuristics determining when to summarize. */\nexport interface ISummarizeHeuristicRunner {\n\t/** Start specific heuristic trackers (ex: idle timer) */\n\tstart(): void;\n\n\t/** Runs the heuristics to determine if it should try to summarize */\n\trun(): void;\n\n\t/** Runs a different heuristic to check if it should summarize before closing */\n\tshouldRunLastSummary(): boolean;\n\n\t/** Disposes of resources */\n\tdispose(): void;\n}\n\ntype ISummarizeTelemetryRequiredProperties =\n\t/** Reason code for attempting to summarize */\n\t\"summarizeReason\";\n\ntype ISummarizeTelemetryOptionalProperties =\n\t/** Number of attempts within the last time window, used for calculating the throttle delay. */\n\t| \"summaryAttempts\"\n\t/** Summarization may be attempted multiple times. This tells whether this is the final summarization attempt */\n\t| \"finalAttempt\"\n\t| keyof ISummarizeOptions;\n\nexport type ISummarizeTelemetryProperties = Pick<\n\tITelemetryBaseProperties,\n\tISummarizeTelemetryRequiredProperties\n> &\n\tPartial<Pick<ITelemetryBaseProperties, ISummarizeTelemetryOptionalProperties>>;\n\n/** Strategy used to heuristically determine when we should run a summary */\nexport interface ISummaryHeuristicStrategy {\n\t/** Summarize reason for this summarize heuristic strategy (ex: \"maxTime\") */\n\tsummarizeReason: Readonly<SummarizeReason>;\n\n\t/**\n\t * Determines if this strategy's summarize criteria been met\n\t * @param configuration - summary configuration we are to check against\n\t * @param heuristicData - heuristic data used to confirm conditions are met\n\t */\n\tshouldRunSummary(\n\t\tconfiguration: ISummaryConfigurationHeuristics,\n\t\theuristicData: ISummarizeHeuristicData,\n\t): boolean;\n}\n\ntype SummaryGeneratorRequiredTelemetryProperties =\n\t/** True to generate the full tree with no handle reuse optimizations */\n\t| \"fullTree\"\n\t/** Time since we last attempted to generate a summary */\n\t| \"timeSinceLastAttempt\"\n\t/** Time since we last successfully generated a summary */\n\t| \"timeSinceLastSummary\";\n\ntype SummaryGeneratorOptionalTelemetryProperties =\n\t/** Reference sequence number as of the generate summary attempt. */\n\t| \"referenceSequenceNumber\"\n\t/** minimum sequence number (at the reference sequence number) */\n\t| \"minimumSequenceNumber\"\n\t/** Delta between the current reference sequence number and the reference sequence number of the last attempt */\n\t| \"opsSinceLastAttempt\"\n\t/** Delta between the current reference sequence number and the reference sequence number of the last summary */\n\t| \"opsSinceLastSummary\"\n\t/**\n\t * Delta in sum of op sizes between the current reference sequence number and the reference\n\t * sequence number of the last summary\n\t */\n\t| \"opsSizesSinceLastSummary\"\n\t/** Delta between the number of non-runtime ops since the last summary */\n\t| \"nonRuntimeOpsSinceLastSummary\"\n\t/** Delta between the number of runtime ops since the last summary */\n\t| \"runtimeOpsSinceLastSummary\"\n\t/** Wether or not this instance contains adjusted metrics due to missing op data */\n\t| \"hasMissingOpData\"\n\t/** Time it took to generate the summary tree and stats. */\n\t| \"generateDuration\"\n\t/** The handle returned by storage pointing to the uploaded summary tree. */\n\t| \"handle\"\n\t/** Time it took to upload the summary tree to storage. */\n\t| \"uploadDuration\"\n\t/** The client sequence number of the summarize op submitted for the summary. */\n\t| \"clientSequenceNumber\"\n\t/** Time it took for this summary to be acked after it was generated */\n\t| \"ackWaitDuration\"\n\t/** Reference sequence number of the ack/nack message */\n\t| \"ackNackSequenceNumber\"\n\t/** Actual sequence number of the summary op proposal. */\n\t| \"summarySequenceNumber\"\n\t/** Optional Retry-After time in seconds. If specified, the client should wait this many seconds before retrying. */\n\t| \"nackRetryAfter\"\n\t/** The stage at which the submit summary method failed at. This can help determine what type of failure we have */\n\t| \"stage\";\n\nexport type SummaryGeneratorTelemetry = Pick<\n\tITelemetryBaseProperties,\n\tSummaryGeneratorRequiredTelemetryProperties\n> &\n\tPartial<Pick<ITelemetryBaseProperties, SummaryGeneratorOptionalTelemetryProperties>>;\n\nexport interface ISummarizeRunnerTelemetry extends ITelemetryLoggerPropertyBag {\n\t/** Number of times the summarizer run. */\n\tsummarizeCount: () => number;\n\t/** Number of successful attempts to summarize. */\n\tsummarizerSuccessfulAttempts: () => number;\n}\n"]}
@@ -18,7 +18,6 @@ class Summary {
18
18
  }
19
19
  static createFromOp(op) {
20
20
  // TODO: Verify whether this should be able to handle server-generated ops (with null clientId)
21
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
22
21
  const summary = new Summary(op.clientId, op.clientSequenceNumber);
23
22
  summary.broadcast(op);
24
23
  return summary;
@@ -249,7 +248,6 @@ export class SummaryCollection extends TypedEventEmitter {
249
248
  let summary;
250
249
  // Check if summary already being watched, broadcast if so
251
250
  // TODO: Verify whether this should be able to handle server-generated ops (with null clientId)
252
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
253
251
  const watcher = this.summaryWatchers.get(op.clientId);
254
252
  if (watcher) {
255
253
  summary = watcher.tryGetSummary(op.clientSequenceNumber);
@@ -1 +1 @@
1
- {"version":3,"file":"summaryCollection.js","sourceRoot":"","sources":["../../src/summary/summaryCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAKN,WAAW,GAEX,MAAM,6CAA6C,CAAC;AAwDrD,IAAK,YAKJ;AALD,WAAK,YAAY;IAChB,iDAAS,CAAA;IACT,yDAAa,CAAA;IACb,iDAAS,CAAA;IACT,oDAAW,CAAA;AACZ,CAAC,EALI,YAAY,KAAZ,YAAY,QAKhB;AAED,MAAM,OAAO;IACL,MAAM,CAAC,WAAW,CAAC,QAAgB,EAAE,oBAA4B;QACvE,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IACpD,CAAC;IACM,MAAM,CAAC,YAAY,CAAC,EAAqB;QAC/C,+FAA+F;QAC/F,4EAA4E;QAC5E,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,CAAC,QAAkB,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC;QAC5E,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,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,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACvC,CAAC;IACF,CAAC;IAEO,iBAAiB,CAAC,EAAuB;QAChD,MAAM,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC,qBAAqB,CAAC;QAC9D,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/C,IAAI,OAAO,EAAE,CAAC;YACb,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACpB,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAClC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QACxC,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport { IDisposable, IEvent } from \"@fluidframework/core-interfaces\";\nimport { assert, Deferred } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIDocumentMessage,\n\tISummaryAck,\n\tISummaryContent,\n\tISummaryNack,\n\tMessageType,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Interface for summary op messages with typed contents.\n * @legacy\n * @alpha\n */\nexport interface ISummaryOpMessage extends ISequencedDocumentMessage {\n\ttype: MessageType.Summarize;\n\tcontents: ISummaryContent;\n}\n\n/**\n * Interface for summary ack messages with typed contents.\n * @legacy\n * @alpha\n */\nexport interface ISummaryAckMessage extends ISequencedDocumentMessage {\n\ttype: MessageType.SummaryAck;\n\tcontents: ISummaryAck;\n}\n\n/**\n * Interface for summary nack messages with typed contents.\n * @legacy\n * @alpha\n */\nexport interface ISummaryNackMessage extends ISequencedDocumentMessage {\n\ttype: MessageType.SummaryNack;\n\tcontents: ISummaryNack;\n}\n\n/**\n * A single summary which can be tracked as it goes through its life cycle.\n * The life cycle is: Local to Broadcast to Acked/Nacked.\n * @legacy\n * @alpha\n */\nexport interface ISummary {\n\treadonly clientId: string;\n\treadonly clientSequenceNumber: number;\n\twaitBroadcast(): Promise<ISummaryOpMessage>;\n\twaitAckNack(): Promise<ISummaryAckMessage | ISummaryNackMessage>;\n}\n\n/**\n * A single summary which has already been acked by the server.\n * @legacy\n * @alpha\n */\nexport interface IAckedSummary {\n\treadonly summaryOp: ISummaryOpMessage;\n\treadonly summaryAck: ISummaryAckMessage;\n}\n\nenum SummaryState {\n\tLocal = 0,\n\tBroadcast = 1,\n\tAcked = 2,\n\tNacked = -1,\n}\n\nclass Summary implements ISummary {\n\tpublic static createLocal(clientId: string, clientSequenceNumber: number) {\n\t\treturn new Summary(clientId, clientSequenceNumber);\n\t}\n\tpublic static createFromOp(op: ISummaryOpMessage) {\n\t\t// TODO: Verify whether this should be able to handle server-generated ops (with null clientId)\n\t\t// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n\t\tconst summary = new Summary(op.clientId as string, op.clientSequenceNumber);\n\t\tsummary.broadcast(op);\n\t\treturn summary;\n\t}\n\n\tprivate state = SummaryState.Local;\n\n\tprivate _summaryOp?: ISummaryOpMessage;\n\tprivate _summaryAckNack?: ISummaryAckMessage | ISummaryNackMessage;\n\n\tprivate readonly defSummaryOp = new Deferred<void>();\n\tprivate readonly defSummaryAck = new Deferred<void>();\n\n\tpublic get summaryOp() {\n\t\treturn this._summaryOp;\n\t}\n\tpublic get summaryAckNack() {\n\t\treturn this._summaryAckNack;\n\t}\n\n\tprivate constructor(\n\t\tpublic readonly clientId: string,\n\t\tpublic readonly clientSequenceNumber: number,\n\t) {}\n\n\tpublic hasBeenAcked(): this is IAckedSummary {\n\t\treturn this.state === SummaryState.Acked;\n\t}\n\n\tpublic broadcast(op: ISummaryOpMessage) {\n\t\tassert(\n\t\t\tthis.state === SummaryState.Local,\n\t\t\t0x175 /* \"Can only broadcast if summarizer starts in local state\" */,\n\t\t);\n\t\tthis._summaryOp = op;\n\t\tthis.defSummaryOp.resolve();\n\t\tthis.state = SummaryState.Broadcast;\n\t\treturn true;\n\t}\n\n\tpublic ackNack(op: ISummaryAckMessage | ISummaryNackMessage) {\n\t\tassert(\n\t\t\tthis.state === SummaryState.Broadcast,\n\t\t\t0x176 /* \"Can only ack/nack if summarizer is in broadcasting state\" */,\n\t\t);\n\t\tthis._summaryAckNack = op;\n\t\tthis.defSummaryAck.resolve();\n\t\tthis.state = op.type === MessageType.SummaryAck ? SummaryState.Acked : SummaryState.Nacked;\n\t\treturn true;\n\t}\n\n\tpublic async waitBroadcast(): Promise<ISummaryOpMessage> {\n\t\tawait this.defSummaryOp.promise;\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this._summaryOp!;\n\t}\n\n\tpublic async waitAckNack(): Promise<ISummaryAckMessage | ISummaryNackMessage> {\n\t\tawait this.defSummaryAck.promise;\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this._summaryAckNack!;\n\t}\n}\n\n/**\n * Watches summaries created by a specific client.\n * @legacy\n * @alpha\n */\nexport interface IClientSummaryWatcher extends IDisposable {\n\twatchSummary(clientSequenceNumber: number): ISummary;\n\twaitFlushed(): Promise<IAckedSummary | undefined>;\n}\n\n/**\n * This class watches summaries created by a specific client.\n * It should be created and managed from a SummaryCollection.\n */\nclass ClientSummaryWatcher implements IClientSummaryWatcher {\n\t// key: clientSeqNum\n\tprivate readonly localSummaries = new Map<number, Summary>();\n\tprivate _disposed = false;\n\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\n\tpublic constructor(\n\t\tpublic readonly clientId: string,\n\t\tprivate readonly summaryCollection: SummaryCollection,\n\t) {}\n\n\t/**\n\t * Watches for a specific sent summary op.\n\t * @param clientSequenceNumber - client sequence number of sent summary op\n\t */\n\tpublic watchSummary(clientSequenceNumber: number): ISummary {\n\t\tlet summary = this.localSummaries.get(clientSequenceNumber);\n\t\tif (!summary) {\n\t\t\tsummary = Summary.createLocal(this.clientId, clientSequenceNumber);\n\t\t\tthis.localSummaries.set(summary.clientSequenceNumber, summary);\n\t\t}\n\t\treturn summary;\n\t}\n\n\t/**\n\t * Waits until all of the pending summaries in the underlying SummaryCollection\n\t * are acked/nacked.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\tpublic waitFlushed() {\n\t\treturn this.summaryCollection.waitFlushed();\n\t}\n\n\t/**\n\t * Gets a watched summary or returns undefined if not watched.\n\t * @param clientSequenceNumber - client sequence number of sent summary op\n\t */\n\tpublic tryGetSummary(clientSequenceNumber: number) {\n\t\treturn this.localSummaries.get(clientSequenceNumber);\n\t}\n\n\t/**\n\t * Starts watching a summary made by this client.\n\t * @param summary - summary to start watching\n\t */\n\tpublic setSummary(summary: Summary) {\n\t\tthis.localSummaries.set(summary.clientSequenceNumber, summary);\n\t}\n\n\tpublic dispose() {\n\t\tthis.summaryCollection.removeWatcher(this.clientId);\n\t\tthis._disposed = true;\n\t}\n}\n/**\n * @legacy\n * @alpha\n */\nexport type OpActionEventName =\n\t| MessageType.Summarize\n\t| MessageType.SummaryAck\n\t| MessageType.SummaryNack\n\t| \"default\";\n\n/**\n * @legacy\n * @alpha\n */\nexport type OpActionEventListener = (op: ISequencedDocumentMessage) => void;\n\n/**\n * @legacy\n * @alpha\n */\nexport interface ISummaryCollectionOpEvents extends IEvent {\n\t(event: OpActionEventName, listener: OpActionEventListener);\n}\n\n/**\n * Data structure that looks at the op stream to track summaries as they\n * are broadcast, acked and nacked.\n * It provides functionality for watching specific summaries.\n * @legacy\n * @alpha\n */\nexport class SummaryCollection extends TypedEventEmitter<ISummaryCollectionOpEvents> {\n\t// key: clientId\n\tprivate readonly summaryWatchers = new Map<string, ClientSummaryWatcher>();\n\t// key: summarySeqNum\n\tprivate readonly pendingSummaries = new Map<number, Summary>();\n\tprivate refreshWaitNextAck = new Deferred<void>();\n\n\tprivate lastSummaryTimestamp: number | undefined;\n\tprivate maxAckWaitTime: number | undefined;\n\tprivate pendingAckTimerTimeoutCallback: (() => void) | undefined;\n\tprivate lastAck: IAckedSummary | undefined;\n\n\tpublic get latestAck(): IAckedSummary | undefined {\n\t\treturn this.lastAck;\n\t}\n\n\tpublic emit(event: OpActionEventName, ...args: Parameters<OpActionEventListener>): boolean {\n\t\treturn super.emit(event, ...args);\n\t}\n\n\tpublic get opsSinceLastAck() {\n\t\treturn (\n\t\t\tthis.deltaManager.lastSequenceNumber -\n\t\t\t(this.lastAck?.summaryAck.sequenceNumber ?? this.deltaManager.initialSequenceNumber)\n\t\t);\n\t}\n\n\tpublic addOpListener(listener: () => void) {\n\t\tthis.deltaManager.on(\"op\", listener);\n\t}\n\n\tpublic removeOpListener(listener: () => void) {\n\t\tthis.deltaManager.off(\"op\", listener);\n\t}\n\n\tpublic constructor(\n\t\tprivate readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {\n\t\tsuper();\n\t\tthis.deltaManager.on(\"op\", (op) => this.handleOp(op));\n\t}\n\n\t/**\n\t * Creates and returns a summary watcher for a specific client.\n\t * This will allow for local sent summaries to be better tracked.\n\t * @param clientId - client id for watcher\n\t */\n\tpublic createWatcher(clientId: string): IClientSummaryWatcher {\n\t\tconst watcher = new ClientSummaryWatcher(clientId, this);\n\t\tthis.summaryWatchers.set(clientId, watcher);\n\t\treturn watcher;\n\t}\n\n\tpublic removeWatcher(clientId: string) {\n\t\tthis.summaryWatchers.delete(clientId);\n\t}\n\n\tpublic setPendingAckTimerTimeoutCallback(\n\t\tmaxAckWaitTime: number,\n\t\ttimeoutCallback: () => void,\n\t) {\n\t\tthis.maxAckWaitTime = maxAckWaitTime;\n\t\tthis.pendingAckTimerTimeoutCallback = timeoutCallback;\n\t}\n\n\tpublic unsetPendingAckTimerTimeoutCallback() {\n\t\tthis.maxAckWaitTime = undefined;\n\t\tthis.pendingAckTimerTimeoutCallback = undefined;\n\t}\n\n\t/**\n\t * Returns a promise that resolves once all pending summary ops\n\t * have been acked or nacked.\n\t */\n\tpublic async waitFlushed(): Promise<IAckedSummary | undefined> {\n\t\twhile (this.pendingSummaries.size > 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\t\tconst promises = Array.from(this.pendingSummaries, ([, summary]) =>\n\t\t\t\tsummary.waitAckNack(),\n\t\t\t);\n\t\t\tawait Promise.all(promises);\n\t\t}\n\t\treturn this.lastAck;\n\t}\n\n\t/**\n\t * Returns a promise that resolves once a summary is acked that has a reference\n\t * sequence number greater than or equal to the passed in sequence number.\n\t * @param referenceSequenceNumber - reference sequence number to wait for\n\t * @returns The latest acked summary\n\t */\n\tpublic async waitSummaryAck(referenceSequenceNumber: number): Promise<IAckedSummary> {\n\t\twhile (\n\t\t\t!this.lastAck ||\n\t\t\tthis.lastAck.summaryOp.referenceSequenceNumber < referenceSequenceNumber\n\t\t) {\n\t\t\tawait this.refreshWaitNextAck.promise;\n\t\t}\n\t\treturn this.lastAck;\n\t}\n\n\tprivate parseContent(op: ISequencedDocumentMessage) {\n\t\t// This should become unconditional once (Loader LTS) reaches 2.4 or later\n\t\t// There will be a long time of needing both cases, until LTS catches up to the change.\n\t\t// That said, we may instead move to listen for \"op\" events from ContainerRuntime,\n\t\t// and parsing may not be required at all if ContainerRuntime.process() continues to parse it for all types of ops.\n\t\tif (typeof op.contents === \"string\") {\n\t\t\top.contents = JSON.parse(op.contents);\n\t\t}\n\t}\n\n\t/**\n\t * Handler for ops; only handles ops relating to summaries.\n\t * @param op - op message to handle\n\t */\n\tprivate handleOp(opArg: ISequencedDocumentMessage) {\n\t\tconst op = { ...opArg };\n\n\t\tswitch (op.type) {\n\t\t\tcase MessageType.Summarize:\n\t\t\t\tthis.parseContent(op);\n\t\t\t\treturn this.handleSummaryOp(op as ISummaryOpMessage);\n\t\t\tcase MessageType.SummaryAck:\n\t\t\tcase MessageType.SummaryNack:\n\t\t\t\t// Old files (prior to PR #10077) may not contain this info\n\t\t\t\tif (op.data !== undefined) {\n\t\t\t\t\top.contents = JSON.parse(op.data);\n\t\t\t\t} else {\n\t\t\t\t\tthis.parseContent(op);\n\t\t\t\t}\n\t\t\t\treturn op.type === MessageType.SummaryAck\n\t\t\t\t\t? this.handleSummaryAck(op as ISummaryAckMessage)\n\t\t\t\t\t: this.handleSummaryNack(op as ISummaryNackMessage);\n\t\t\tdefault: {\n\t\t\t\t// If the difference between timestamp of current op and last summary op is greater than\n\t\t\t\t// the maxAckWaitTime, then we need to inform summarizer to not wait and summarize\n\t\t\t\t// immediately as we have already waited for maxAckWaitTime.\n\t\t\t\tconst lastOpTimestamp = op.timestamp;\n\t\t\t\tif (\n\t\t\t\t\tthis.lastSummaryTimestamp !== undefined &&\n\t\t\t\t\tthis.maxAckWaitTime !== undefined &&\n\t\t\t\t\tlastOpTimestamp - this.lastSummaryTimestamp >= this.maxAckWaitTime\n\t\t\t\t) {\n\t\t\t\t\tthis.pendingAckTimerTimeoutCallback?.();\n\t\t\t\t}\n\t\t\t\tthis.emit(\"default\", op);\n\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleSummaryOp(op: ISummaryOpMessage) {\n\t\tlet summary: Summary | undefined;\n\n\t\t// Check if summary already being watched, broadcast if so\n\t\t// TODO: Verify whether this should be able to handle server-generated ops (with null clientId)\n\t\t// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n\t\tconst watcher = this.summaryWatchers.get(op.clientId as string);\n\t\tif (watcher) {\n\t\t\tsummary = watcher.tryGetSummary(op.clientSequenceNumber);\n\t\t\tif (summary) {\n\t\t\t\tsummary.broadcast(op);\n\t\t\t}\n\t\t}\n\n\t\t// If not watched, create from op\n\t\tif (!summary) {\n\t\t\tsummary = Summary.createFromOp(op);\n\t\t\tif (watcher) {\n\t\t\t\twatcher.setSummary(summary);\n\t\t\t}\n\t\t}\n\t\tthis.pendingSummaries.set(op.sequenceNumber, summary);\n\t\tthis.lastSummaryTimestamp = op.timestamp;\n\t\tthis.emit(MessageType.Summarize, op);\n\t}\n\n\tprivate handleSummaryAck(op: ISummaryAckMessage) {\n\t\tconst seq = op.contents.summaryProposal.summarySequenceNumber;\n\t\tconst summary = this.pendingSummaries.get(seq);\n\t\t// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- optional chain is not logically equivalent\n\t\tif (!summary || summary.summaryOp === undefined) {\n\t\t\t// Summary ack without an op should be rare. We could fetch the\n\t\t\t// reference sequence number from the snapshot, but instead we\n\t\t\t// will not emit this ack. It should be the case that the summary\n\t\t\t// op that this ack is for is earlier than this file was loaded\n\t\t\t// from. i.e. initialSequenceNumber > summarySequenceNumber.\n\t\t\t// We really don't care about it for now, since it is older than\n\t\t\t// the one we loaded from.\n\t\t\tif (seq > this.deltaManager.initialSequenceNumber) {\n\t\t\t\t// Potential causes for it to be later than our initialSequenceNumber\n\t\t\t\t// are that the summaryOp was nacked then acked, double-acked, or\n\t\t\t\t// the summarySequenceNumber is incorrect.\n\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"SummaryAckWithoutOp\",\n\t\t\t\t\tsequenceNumber: op.sequenceNumber, // summary ack seq #\n\t\t\t\t\tsummarySequenceNumber: seq, // missing summary seq #\n\t\t\t\t\tinitialSequenceNumber: this.deltaManager.initialSequenceNumber,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tsummary.ackNack(op);\n\t\tthis.pendingSummaries.delete(seq);\n\n\t\t// Track latest ack\n\t\tif (\n\t\t\t!this.lastAck ||\n\t\t\tseq > this.lastAck.summaryAck.contents.summaryProposal.summarySequenceNumber\n\t\t) {\n\t\t\tthis.lastAck = {\n\t\t\t\tsummaryOp: summary.summaryOp,\n\t\t\t\tsummaryAck: op,\n\t\t\t};\n\t\t\tthis.refreshWaitNextAck.resolve();\n\t\t\tthis.refreshWaitNextAck = new Deferred<void>();\n\t\t\tthis.emit(MessageType.SummaryAck, op);\n\t\t}\n\t}\n\n\tprivate handleSummaryNack(op: ISummaryNackMessage) {\n\t\tconst seq = op.contents.summaryProposal.summarySequenceNumber;\n\t\tconst summary = this.pendingSummaries.get(seq);\n\t\tif (summary) {\n\t\t\tsummary.ackNack(op);\n\t\t\tthis.pendingSummaries.delete(seq);\n\t\t\tthis.emit(MessageType.SummaryNack, op);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"summaryCollection.js","sourceRoot":"","sources":["../../src/summary/summaryCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAKN,WAAW,GAEX,MAAM,6CAA6C,CAAC;AAwDrD,IAAK,YAKJ;AALD,WAAK,YAAY;IAChB,iDAAS,CAAA;IACT,yDAAa,CAAA;IACb,iDAAS,CAAA;IACT,oDAAW,CAAA;AACZ,CAAC,EALI,YAAY,KAAZ,YAAY,QAKhB;AAED,MAAM,OAAO;IACL,MAAM,CAAC,WAAW,CAAC,QAAgB,EAAE,oBAA4B;QACvE,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IACpD,CAAC;IACM,MAAM,CAAC,YAAY,CAAC,EAAqB;QAC/C,+FAA+F;QAE/F,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,CAAC,QAAkB,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC;QAC5E,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QACtB,OAAO,OAAO,CAAC;IAChB,CAAC;IAUD,IAAW,SAAS;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IACD,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC,eAAe,CAAC;IA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AO,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/C,IAAI,OAAO,EAAE,CAAC;YACb,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACpB,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAClC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QACxC,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport { IDisposable, IEvent } from \"@fluidframework/core-interfaces\";\nimport { assert, Deferred } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIDocumentMessage,\n\tISummaryAck,\n\tISummaryContent,\n\tISummaryNack,\n\tMessageType,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Interface for summary op messages with typed contents.\n * @legacy\n * @alpha\n */\nexport interface ISummaryOpMessage extends ISequencedDocumentMessage {\n\ttype: MessageType.Summarize;\n\tcontents: ISummaryContent;\n}\n\n/**\n * Interface for summary ack messages with typed contents.\n * @legacy\n * @alpha\n */\nexport interface ISummaryAckMessage extends ISequencedDocumentMessage {\n\ttype: MessageType.SummaryAck;\n\tcontents: ISummaryAck;\n}\n\n/**\n * Interface for summary nack messages with typed contents.\n * @legacy\n * @alpha\n */\nexport interface ISummaryNackMessage extends ISequencedDocumentMessage {\n\ttype: MessageType.SummaryNack;\n\tcontents: ISummaryNack;\n}\n\n/**\n * A single summary which can be tracked as it goes through its life cycle.\n * The life cycle is: Local to Broadcast to Acked/Nacked.\n * @legacy\n * @alpha\n */\nexport interface ISummary {\n\treadonly clientId: string;\n\treadonly clientSequenceNumber: number;\n\twaitBroadcast(): Promise<ISummaryOpMessage>;\n\twaitAckNack(): Promise<ISummaryAckMessage | ISummaryNackMessage>;\n}\n\n/**\n * A single summary which has already been acked by the server.\n * @legacy\n * @alpha\n */\nexport interface IAckedSummary {\n\treadonly summaryOp: ISummaryOpMessage;\n\treadonly summaryAck: ISummaryAckMessage;\n}\n\nenum SummaryState {\n\tLocal = 0,\n\tBroadcast = 1,\n\tAcked = 2,\n\tNacked = -1,\n}\n\nclass Summary implements ISummary {\n\tpublic static createLocal(clientId: string, clientSequenceNumber: number) {\n\t\treturn new Summary(clientId, clientSequenceNumber);\n\t}\n\tpublic static createFromOp(op: ISummaryOpMessage) {\n\t\t// TODO: Verify whether this should be able to handle server-generated ops (with null clientId)\n\n\t\tconst summary = new Summary(op.clientId as string, op.clientSequenceNumber);\n\t\tsummary.broadcast(op);\n\t\treturn summary;\n\t}\n\n\tprivate state = SummaryState.Local;\n\n\tprivate _summaryOp?: ISummaryOpMessage;\n\tprivate _summaryAckNack?: ISummaryAckMessage | ISummaryNackMessage;\n\n\tprivate readonly defSummaryOp = new Deferred<void>();\n\tprivate readonly defSummaryAck = new Deferred<void>();\n\n\tpublic get summaryOp() {\n\t\treturn this._summaryOp;\n\t}\n\tpublic get summaryAckNack() {\n\t\treturn this._summaryAckNack;\n\t}\n\n\tprivate constructor(\n\t\tpublic readonly clientId: string,\n\t\tpublic readonly clientSequenceNumber: number,\n\t) {}\n\n\tpublic hasBeenAcked(): this is IAckedSummary {\n\t\treturn this.state === SummaryState.Acked;\n\t}\n\n\tpublic broadcast(op: ISummaryOpMessage) {\n\t\tassert(\n\t\t\tthis.state === SummaryState.Local,\n\t\t\t0x175 /* \"Can only broadcast if summarizer starts in local state\" */,\n\t\t);\n\t\tthis._summaryOp = op;\n\t\tthis.defSummaryOp.resolve();\n\t\tthis.state = SummaryState.Broadcast;\n\t\treturn true;\n\t}\n\n\tpublic ackNack(op: ISummaryAckMessage | ISummaryNackMessage) {\n\t\tassert(\n\t\t\tthis.state === SummaryState.Broadcast,\n\t\t\t0x176 /* \"Can only ack/nack if summarizer is in broadcasting state\" */,\n\t\t);\n\t\tthis._summaryAckNack = op;\n\t\tthis.defSummaryAck.resolve();\n\t\tthis.state = op.type === MessageType.SummaryAck ? SummaryState.Acked : SummaryState.Nacked;\n\t\treturn true;\n\t}\n\n\tpublic async waitBroadcast(): Promise<ISummaryOpMessage> {\n\t\tawait this.defSummaryOp.promise;\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this._summaryOp!;\n\t}\n\n\tpublic async waitAckNack(): Promise<ISummaryAckMessage | ISummaryNackMessage> {\n\t\tawait this.defSummaryAck.promise;\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this._summaryAckNack!;\n\t}\n}\n\n/**\n * Watches summaries created by a specific client.\n * @legacy\n * @alpha\n */\nexport interface IClientSummaryWatcher extends IDisposable {\n\twatchSummary(clientSequenceNumber: number): ISummary;\n\twaitFlushed(): Promise<IAckedSummary | undefined>;\n}\n\n/**\n * This class watches summaries created by a specific client.\n * It should be created and managed from a SummaryCollection.\n */\nclass ClientSummaryWatcher implements IClientSummaryWatcher {\n\t// key: clientSeqNum\n\tprivate readonly localSummaries = new Map<number, Summary>();\n\tprivate _disposed = false;\n\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\n\tpublic constructor(\n\t\tpublic readonly clientId: string,\n\t\tprivate readonly summaryCollection: SummaryCollection,\n\t) {}\n\n\t/**\n\t * Watches for a specific sent summary op.\n\t * @param clientSequenceNumber - client sequence number of sent summary op\n\t */\n\tpublic watchSummary(clientSequenceNumber: number): ISummary {\n\t\tlet summary = this.localSummaries.get(clientSequenceNumber);\n\t\tif (!summary) {\n\t\t\tsummary = Summary.createLocal(this.clientId, clientSequenceNumber);\n\t\t\tthis.localSummaries.set(summary.clientSequenceNumber, summary);\n\t\t}\n\t\treturn summary;\n\t}\n\n\t/**\n\t * Waits until all of the pending summaries in the underlying SummaryCollection\n\t * are acked/nacked.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\tpublic waitFlushed() {\n\t\treturn this.summaryCollection.waitFlushed();\n\t}\n\n\t/**\n\t * Gets a watched summary or returns undefined if not watched.\n\t * @param clientSequenceNumber - client sequence number of sent summary op\n\t */\n\tpublic tryGetSummary(clientSequenceNumber: number) {\n\t\treturn this.localSummaries.get(clientSequenceNumber);\n\t}\n\n\t/**\n\t * Starts watching a summary made by this client.\n\t * @param summary - summary to start watching\n\t */\n\tpublic setSummary(summary: Summary) {\n\t\tthis.localSummaries.set(summary.clientSequenceNumber, summary);\n\t}\n\n\tpublic dispose() {\n\t\tthis.summaryCollection.removeWatcher(this.clientId);\n\t\tthis._disposed = true;\n\t}\n}\n/**\n * @legacy\n * @alpha\n */\nexport type OpActionEventName =\n\t| MessageType.Summarize\n\t| MessageType.SummaryAck\n\t| MessageType.SummaryNack\n\t| \"default\";\n\n/**\n * @legacy\n * @alpha\n */\nexport type OpActionEventListener = (op: ISequencedDocumentMessage) => void;\n\n/**\n * @legacy\n * @alpha\n */\nexport interface ISummaryCollectionOpEvents extends IEvent {\n\t(event: OpActionEventName, listener: OpActionEventListener);\n}\n\n/**\n * Data structure that looks at the op stream to track summaries as they\n * are broadcast, acked and nacked.\n * It provides functionality for watching specific summaries.\n * @legacy\n * @alpha\n */\nexport class SummaryCollection extends TypedEventEmitter<ISummaryCollectionOpEvents> {\n\t// key: clientId\n\tprivate readonly summaryWatchers = new Map<string, ClientSummaryWatcher>();\n\t// key: summarySeqNum\n\tprivate readonly pendingSummaries = new Map<number, Summary>();\n\tprivate refreshWaitNextAck = new Deferred<void>();\n\n\tprivate lastSummaryTimestamp: number | undefined;\n\tprivate maxAckWaitTime: number | undefined;\n\tprivate pendingAckTimerTimeoutCallback: (() => void) | undefined;\n\tprivate lastAck: IAckedSummary | undefined;\n\n\tpublic get latestAck(): IAckedSummary | undefined {\n\t\treturn this.lastAck;\n\t}\n\n\tpublic emit(event: OpActionEventName, ...args: Parameters<OpActionEventListener>): boolean {\n\t\treturn super.emit(event, ...args);\n\t}\n\n\tpublic get opsSinceLastAck() {\n\t\treturn (\n\t\t\tthis.deltaManager.lastSequenceNumber -\n\t\t\t(this.lastAck?.summaryAck.sequenceNumber ?? this.deltaManager.initialSequenceNumber)\n\t\t);\n\t}\n\n\tpublic addOpListener(listener: () => void) {\n\t\tthis.deltaManager.on(\"op\", listener);\n\t}\n\n\tpublic removeOpListener(listener: () => void) {\n\t\tthis.deltaManager.off(\"op\", listener);\n\t}\n\n\tpublic constructor(\n\t\tprivate readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {\n\t\tsuper();\n\t\tthis.deltaManager.on(\"op\", (op) => this.handleOp(op));\n\t}\n\n\t/**\n\t * Creates and returns a summary watcher for a specific client.\n\t * This will allow for local sent summaries to be better tracked.\n\t * @param clientId - client id for watcher\n\t */\n\tpublic createWatcher(clientId: string): IClientSummaryWatcher {\n\t\tconst watcher = new ClientSummaryWatcher(clientId, this);\n\t\tthis.summaryWatchers.set(clientId, watcher);\n\t\treturn watcher;\n\t}\n\n\tpublic removeWatcher(clientId: string) {\n\t\tthis.summaryWatchers.delete(clientId);\n\t}\n\n\tpublic setPendingAckTimerTimeoutCallback(\n\t\tmaxAckWaitTime: number,\n\t\ttimeoutCallback: () => void,\n\t) {\n\t\tthis.maxAckWaitTime = maxAckWaitTime;\n\t\tthis.pendingAckTimerTimeoutCallback = timeoutCallback;\n\t}\n\n\tpublic unsetPendingAckTimerTimeoutCallback() {\n\t\tthis.maxAckWaitTime = undefined;\n\t\tthis.pendingAckTimerTimeoutCallback = undefined;\n\t}\n\n\t/**\n\t * Returns a promise that resolves once all pending summary ops\n\t * have been acked or nacked.\n\t */\n\tpublic async waitFlushed(): Promise<IAckedSummary | undefined> {\n\t\twhile (this.pendingSummaries.size > 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\t\tconst promises = Array.from(this.pendingSummaries, ([, summary]) =>\n\t\t\t\tsummary.waitAckNack(),\n\t\t\t);\n\t\t\tawait Promise.all(promises);\n\t\t}\n\t\treturn this.lastAck;\n\t}\n\n\t/**\n\t * Returns a promise that resolves once a summary is acked that has a reference\n\t * sequence number greater than or equal to the passed in sequence number.\n\t * @param referenceSequenceNumber - reference sequence number to wait for\n\t * @returns The latest acked summary\n\t */\n\tpublic async waitSummaryAck(referenceSequenceNumber: number): Promise<IAckedSummary> {\n\t\twhile (\n\t\t\t!this.lastAck ||\n\t\t\tthis.lastAck.summaryOp.referenceSequenceNumber < referenceSequenceNumber\n\t\t) {\n\t\t\tawait this.refreshWaitNextAck.promise;\n\t\t}\n\t\treturn this.lastAck;\n\t}\n\n\tprivate parseContent(op: ISequencedDocumentMessage) {\n\t\t// This should become unconditional once (Loader LTS) reaches 2.4 or later\n\t\t// There will be a long time of needing both cases, until LTS catches up to the change.\n\t\t// That said, we may instead move to listen for \"op\" events from ContainerRuntime,\n\t\t// and parsing may not be required at all if ContainerRuntime.process() continues to parse it for all types of ops.\n\t\tif (typeof op.contents === \"string\") {\n\t\t\top.contents = JSON.parse(op.contents);\n\t\t}\n\t}\n\n\t/**\n\t * Handler for ops; only handles ops relating to summaries.\n\t * @param op - op message to handle\n\t */\n\tprivate handleOp(opArg: ISequencedDocumentMessage) {\n\t\tconst op = { ...opArg };\n\n\t\tswitch (op.type) {\n\t\t\tcase MessageType.Summarize:\n\t\t\t\tthis.parseContent(op);\n\t\t\t\treturn this.handleSummaryOp(op as ISummaryOpMessage);\n\t\t\tcase MessageType.SummaryAck:\n\t\t\tcase MessageType.SummaryNack:\n\t\t\t\t// Old files (prior to PR #10077) may not contain this info\n\t\t\t\tif (op.data !== undefined) {\n\t\t\t\t\top.contents = JSON.parse(op.data);\n\t\t\t\t} else {\n\t\t\t\t\tthis.parseContent(op);\n\t\t\t\t}\n\t\t\t\treturn op.type === MessageType.SummaryAck\n\t\t\t\t\t? this.handleSummaryAck(op as ISummaryAckMessage)\n\t\t\t\t\t: this.handleSummaryNack(op as ISummaryNackMessage);\n\t\t\tdefault: {\n\t\t\t\t// If the difference between timestamp of current op and last summary op is greater than\n\t\t\t\t// the maxAckWaitTime, then we need to inform summarizer to not wait and summarize\n\t\t\t\t// immediately as we have already waited for maxAckWaitTime.\n\t\t\t\tconst lastOpTimestamp = op.timestamp;\n\t\t\t\tif (\n\t\t\t\t\tthis.lastSummaryTimestamp !== undefined &&\n\t\t\t\t\tthis.maxAckWaitTime !== undefined &&\n\t\t\t\t\tlastOpTimestamp - this.lastSummaryTimestamp >= this.maxAckWaitTime\n\t\t\t\t) {\n\t\t\t\t\tthis.pendingAckTimerTimeoutCallback?.();\n\t\t\t\t}\n\t\t\t\tthis.emit(\"default\", op);\n\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleSummaryOp(op: ISummaryOpMessage) {\n\t\tlet summary: Summary | undefined;\n\n\t\t// Check if summary already being watched, broadcast if so\n\t\t// TODO: Verify whether this should be able to handle server-generated ops (with null clientId)\n\n\t\tconst watcher = this.summaryWatchers.get(op.clientId as string);\n\t\tif (watcher) {\n\t\t\tsummary = watcher.tryGetSummary(op.clientSequenceNumber);\n\t\t\tif (summary) {\n\t\t\t\tsummary.broadcast(op);\n\t\t\t}\n\t\t}\n\n\t\t// If not watched, create from op\n\t\tif (!summary) {\n\t\t\tsummary = Summary.createFromOp(op);\n\t\t\tif (watcher) {\n\t\t\t\twatcher.setSummary(summary);\n\t\t\t}\n\t\t}\n\t\tthis.pendingSummaries.set(op.sequenceNumber, summary);\n\t\tthis.lastSummaryTimestamp = op.timestamp;\n\t\tthis.emit(MessageType.Summarize, op);\n\t}\n\n\tprivate handleSummaryAck(op: ISummaryAckMessage) {\n\t\tconst seq = op.contents.summaryProposal.summarySequenceNumber;\n\t\tconst summary = this.pendingSummaries.get(seq);\n\t\t// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- optional chain is not logically equivalent\n\t\tif (!summary || summary.summaryOp === undefined) {\n\t\t\t// Summary ack without an op should be rare. We could fetch the\n\t\t\t// reference sequence number from the snapshot, but instead we\n\t\t\t// will not emit this ack. It should be the case that the summary\n\t\t\t// op that this ack is for is earlier than this file was loaded\n\t\t\t// from. i.e. initialSequenceNumber > summarySequenceNumber.\n\t\t\t// We really don't care about it for now, since it is older than\n\t\t\t// the one we loaded from.\n\t\t\tif (seq > this.deltaManager.initialSequenceNumber) {\n\t\t\t\t// Potential causes for it to be later than our initialSequenceNumber\n\t\t\t\t// are that the summaryOp was nacked then acked, double-acked, or\n\t\t\t\t// the summarySequenceNumber is incorrect.\n\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"SummaryAckWithoutOp\",\n\t\t\t\t\tsequenceNumber: op.sequenceNumber, // summary ack seq #\n\t\t\t\t\tsummarySequenceNumber: seq, // missing summary seq #\n\t\t\t\t\tinitialSequenceNumber: this.deltaManager.initialSequenceNumber,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tsummary.ackNack(op);\n\t\tthis.pendingSummaries.delete(seq);\n\n\t\t// Track latest ack\n\t\tif (\n\t\t\t!this.lastAck ||\n\t\t\tseq > this.lastAck.summaryAck.contents.summaryProposal.summarySequenceNumber\n\t\t) {\n\t\t\tthis.lastAck = {\n\t\t\t\tsummaryOp: summary.summaryOp,\n\t\t\t\tsummaryAck: op,\n\t\t\t};\n\t\t\tthis.refreshWaitNextAck.resolve();\n\t\t\tthis.refreshWaitNextAck = new Deferred<void>();\n\t\t\tthis.emit(MessageType.SummaryAck, op);\n\t\t}\n\t}\n\n\tprivate handleSummaryNack(op: ISummaryNackMessage) {\n\t\tconst seq = op.contents.summaryProposal.summarySequenceNumber;\n\t\tconst summary = this.pendingSummaries.get(seq);\n\t\tif (summary) {\n\t\t\tsummary.ackNack(op);\n\t\t\tthis.pendingSummaries.delete(seq);\n\t\t\tthis.emit(MessageType.SummaryNack, op);\n\t\t}\n\t}\n}\n"]}
@@ -3,10 +3,11 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { TypedEventEmitter } from "@fluid-internal/client-utils";
6
+ import type { ISummarizerEvents } from "@fluidframework/container-runtime-definitions/internal";
6
7
  import { IDisposable, IEvent, IEventProvider, ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
7
8
  import { IThrottler } from "../throttler.js";
8
9
  import { ISummarizerClientElection } from "./summarizerClientElection.js";
9
- import { EnqueueSummarizeResult, IEnqueueSummarizeOptions, IOnDemandSummarizeOptions, ISummarizeResults, ISummarizer, ISummarizerEvents } from "./summarizerTypes.js";
10
+ import { EnqueueSummarizeResult, IEnqueueSummarizeOptions, IOnDemandSummarizeOptions, ISummarizeResults, ISummarizer } from "./summarizerTypes.js";
10
11
  import { SummaryCollection } from "./summaryCollection.js";
11
12
  export declare enum SummaryManagerState {
12
13
  Off = 0,
@@ -72,7 +73,6 @@ export declare class SummaryManager extends TypedEventEmitter<ISummarizerEvents>
72
73
  start(): void;
73
74
  private readonly handleConnected;
74
75
  private readonly handleDisconnected;
75
- private readonly handleSummarizeEvent;
76
76
  private static readonly isStartingOrRunning;
77
77
  private getShouldSummarizeState;
78
78
  private readonly refreshSummarizer;
@@ -87,5 +87,8 @@ export declare class SummaryManager extends TypedEventEmitter<ISummarizerEvents>
87
87
  summarizeOnDemand(options: IOnDemandSummarizeOptions): ISummarizeResults;
88
88
  enqueueSummarize(options: IEnqueueSummarizeOptions): EnqueueSummarizeResult;
89
89
  dispose(): void;
90
+ private readonly forwardedEvents;
91
+ private setupForwardedEvents;
92
+ private cleanupForwardedEvents;
90
93
  }
91
94
  //# sourceMappingURL=summaryManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"summaryManager.d.ts","sourceRoot":"","sources":["../../src/summary/summaryManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,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W,6BAA6B;IAyDpC,iBAAiB,CAAC,OAAO,EAAE,yBAAyB,GAAG,iBAAiB;IAQxE,gBAAgB,CAAC,OAAO,EAAE,wBAAwB,GAAG,sBAAsB;IAQ3E,OAAO;IAQd,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA8B;IAE9D,OAAO,CAAC,oBAAoB;IAgB5B,OAAO,CAAC,sBAAsB;CAI9B"}
@@ -50,9 +50,6 @@ export class SummaryManager extends TypedEventEmitter {
50
50
  this.handleDisconnected = () => {
51
51
  this.refreshSummarizer();
52
52
  };
53
- this.handleSummarizeEvent = (eventProps) => {
54
- this.emit("summarize", eventProps);
55
- };
56
53
  this.refreshSummarizer = () => {
57
54
  // Transition states depending on shouldSummarize, which is a calculated property
58
55
  // that is only true if this client is connected and is the elected summarizer.
@@ -85,6 +82,7 @@ export class SummaryManager extends TypedEventEmitter {
85
82
  }
86
83
  }
87
84
  };
85
+ this.forwardedEvents = new Map();
88
86
  this.logger = createChildLogger({
89
87
  logger: parentLogger,
90
88
  namespace: "SummaryManager",
@@ -157,7 +155,7 @@ export class SummaryManager extends TypedEventEmitter {
157
155
  this.state = SummaryManagerState.Running;
158
156
  const summarizer = await this.createSummarizerFn();
159
157
  this.summarizer = summarizer;
160
- this.summarizer.on("summarize", this.handleSummarizeEvent);
158
+ this.setupForwardedEvents();
161
159
  // Re-validate that it need to be running. Due to asynchrony, it may be not the case anymore
162
160
  // If we can't run the LastSummary, simply return as to avoid paying the cost of launching
163
161
  // the summarizer at all.
@@ -213,7 +211,7 @@ export class SummaryManager extends TypedEventEmitter {
213
211
  .finally(() => {
214
212
  assert(this.state !== SummaryManagerState.Off, 0x264 /* "Expected: Not Off" */);
215
213
  this.state = SummaryManagerState.Off;
216
- this.summarizer?.off("summarize", this.handleSummarizeEvent);
214
+ this.cleanupForwardedEvents();
217
215
  this.summarizer?.close();
218
216
  this.summarizer = undefined;
219
217
  if (this.getShouldSummarizeState().shouldSummarize) {
@@ -306,9 +304,28 @@ export class SummaryManager extends TypedEventEmitter {
306
304
  this.clientElection.off("electedSummarizerChanged", this.refreshSummarizer);
307
305
  this.connectedState.off("connected", this.handleConnected);
308
306
  this.connectedState.off("disconnected", this.handleDisconnected);
309
- this.summarizer?.off("summarize", this.handleSummarizeEvent);
307
+ this.cleanupForwardedEvents();
310
308
  this._disposed = true;
311
309
  }
310
+ setupForwardedEvents() {
311
+ [
312
+ "summarize",
313
+ "summarizeAllAttemptsFailed",
314
+ "summarizerStop",
315
+ "summarizerStart",
316
+ "summarizerStartupFailed",
317
+ ].forEach((event) => {
318
+ const listener = (...args) => {
319
+ this.emit(event, ...args);
320
+ };
321
+ this.summarizer?.on(event, listener);
322
+ this.forwardedEvents.set(event, listener);
323
+ });
324
+ }
325
+ cleanupForwardedEvents() {
326
+ this.forwardedEvents.forEach((listener, event) => this.summarizer?.off(event, listener));
327
+ this.forwardedEvents.clear();
328
+ }
312
329
  }
313
330
  SummaryManager.isStartingOrRunning = (state) => state === SummaryManagerState.Starting || state === SummaryManagerState.Running;
314
331
  //# sourceMappingURL=summaryManager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"summaryManager.js","sourceRoot":"","sources":["../../src/summary/summaryManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAOjE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAC/E,OAAO,EAEN,gBAAgB,EAChB,iBAAiB,GACjB,MAAM,0CAA0C,CAAC;AAIlD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAc7C,MAAM,qBAAqB,GAAG,IAAI,CAAC;AACnC,MAAM,8BAA8B,GAAG,IAAI,CAAC;AAE5C,MAAM,CAAN,IAAY,mBAKX;AALD,WAAY,mBAAmB;IAC9B,2DAAO,CAAA;IACP,qEAAY,CAAA;IACZ,mEAAW,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,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAC7D,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACvB,CAAC;;AAzRuB,kCAAmB,GAAG,CAAC,KAA0B,EAAE,EAAE,CAC5E,KAAK,KAAK,mBAAmB,CAAC,QAAQ,IAAI,KAAK,KAAK,mBAAmB,CAAC,OAAO,AADrC,CACsC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport {\n\tIDisposable,\n\tIEvent,\n\tIEventProvider,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { DriverErrorTypes } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tcreateChildLogger,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { IThrottler } from \"../throttler.js\";\n\nimport { Summarizer } from \"./summarizer.js\";\nimport { ISummarizerClientElection } from \"./summarizerClientElection.js\";\nimport {\n\tEnqueueSummarizeResult,\n\tIEnqueueSummarizeOptions,\n\tIOnDemandSummarizeOptions,\n\tISummarizeEventProps,\n\tISummarizeResults,\n\tISummarizer,\n\tISummarizerEvents,\n\tSummarizerStopReason,\n} from \"./summarizerTypes.js\";\nimport { SummaryCollection } from \"./summaryCollection.js\";\n\nconst defaultInitialDelayMs = 5000;\nconst defaultOpsToBypassInitialDelay = 4000;\n\nexport enum SummaryManagerState {\n\tOff = 0,\n\tStarting = 1,\n\tRunning = 2,\n\tStopping = 3,\n}\n\n// Please note that all reasons in this list are not errors,\n// and thus they are not raised today to parent container as error.\n// If this needs to be changed in future, we should re-evaluate what and how we raise to summarizer\ntype StopReason = Extract<\n\tSummarizerStopReason,\n\t\"parentNotConnected\" | \"notElectedParent\" | \"notElectedClient\"\n>;\ntype ShouldSummarizeState =\n\t| { shouldSummarize: true }\n\t| { shouldSummarize: false; stopReason: StopReason };\n\nexport interface IConnectedEvents extends IEvent {\n\t(event: \"connected\", listener: (clientId: string) => void);\n\t(event: \"disconnected\", listener: () => void);\n}\n\n/**\n * IConnectedState describes an object that SummaryManager can watch to observe connection/disconnection.\n *\n * Under current implementation, its role will be fulfilled by the ContainerRuntime, but this could be replaced\n * with anything else that fulfills the contract if we want to shift the layer that the SummaryManager lives at.\n */\nexport interface IConnectedState extends IEventProvider<IConnectedEvents> {\n\treadonly connected: boolean;\n\n\t/**\n\t * Under current implementation this is undefined if we've never connected, otherwise it's the clientId from our\n\t * latest connection (even if we've since disconnected!). Although this happens to be the behavior we want in\n\t * SummaryManager, I suspect that globally we may eventually want to modify this behavior (e.g. make clientId\n\t * undefined while disconnected). To protect against this, let's assume this field can't be trusted while\n\t * disconnected and instead separately track \"latest clientId\" in SummaryManager.\n\t */\n\treadonly clientId: string | undefined;\n}\n\nexport interface ISummaryManagerConfig {\n\tinitialDelayMs: number;\n\topsToBypassInitialDelay: number;\n}\n\n/**\n * SummaryManager is created by parent container (i.e. interactive container with clientType !== \"summarizer\") only.\n * It observes changes in calculated summarizer and reacts to changes by either creating summarizer client or\n * stopping existing summarizer client.\n */\nexport class SummaryManager\n\textends TypedEventEmitter<ISummarizerEvents>\n\timplements IDisposable\n{\n\tprivate readonly logger: ITelemetryLoggerExt;\n\tprivate readonly opsToBypassInitialDelay: number;\n\tprivate readonly initialDelayMs: number;\n\tprivate latestClientId: string | undefined;\n\tprivate state = SummaryManagerState.Off;\n\tprivate summarizer?: ISummarizer;\n\tprivate _disposed = false;\n\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\n\tpublic get currentState() {\n\t\treturn this.state;\n\t}\n\n\tconstructor(\n\t\tprivate readonly clientElection: ISummarizerClientElection,\n\t\tprivate readonly connectedState: IConnectedState,\n\t\tprivate readonly summaryCollection: Pick<\n\t\t\tSummaryCollection,\n\t\t\t\"opsSinceLastAck\" | \"addOpListener\" | \"removeOpListener\"\n\t\t>,\n\t\tparentLogger: ITelemetryBaseLogger,\n\t\t/** Creates summarizer by asking interactive container to spawn summarizing container and\n\t\t * get back its Summarizer instance. */\n\t\tprivate readonly createSummarizerFn: () => Promise<ISummarizer>,\n\t\tprivate readonly startThrottler: IThrottler,\n\t\t{\n\t\t\tinitialDelayMs = defaultInitialDelayMs,\n\t\t\topsToBypassInitialDelay = defaultOpsToBypassInitialDelay,\n\t\t}: Readonly<Partial<ISummaryManagerConfig>> = {},\n\t) {\n\t\tsuper();\n\n\t\tthis.logger = createChildLogger({\n\t\t\tlogger: parentLogger,\n\t\t\tnamespace: \"SummaryManager\",\n\t\t\tproperties: {\n\t\t\t\tall: { clientId: () => this.latestClientId },\n\t\t\t},\n\t\t});\n\n\t\tthis.connectedState.on(\"connected\", this.handleConnected);\n\t\tthis.connectedState.on(\"disconnected\", this.handleDisconnected);\n\t\tthis.latestClientId = this.connectedState.clientId;\n\n\t\tthis.opsToBypassInitialDelay = opsToBypassInitialDelay;\n\t\tthis.initialDelayMs = initialDelayMs;\n\t}\n\n\t/**\n\t * Until start is called, the SummaryManager won't begin attempting to start summarization. This ensures there's\n\t * a window between construction and starting where the caller can attach listeners.\n\t */\n\tpublic start(): void {\n\t\tthis.clientElection.on(\"electedSummarizerChanged\", this.refreshSummarizer);\n\t\tthis.refreshSummarizer();\n\t}\n\n\tprivate readonly handleConnected = (clientId: string) => {\n\t\tthis.latestClientId = clientId;\n\t\t// If we have a summarizer, it should have been either cancelled on disconnected by now.\n\t\t// But because of lastSummary process, it can still hang around, so there is not much we can\n\t\t// check or assert.\n\t\tthis.refreshSummarizer();\n\t};\n\n\tprivate readonly handleDisconnected = () => {\n\t\tthis.refreshSummarizer();\n\t};\n\n\tprivate readonly handleSummarizeEvent = (eventProps: ISummarizeEventProps) => {\n\t\tthis.emit(\"summarize\", eventProps);\n\t};\n\n\tprivate static readonly isStartingOrRunning = (state: SummaryManagerState) =>\n\t\tstate === SummaryManagerState.Starting || state === SummaryManagerState.Running;\n\n\tprivate getShouldSummarizeState(): ShouldSummarizeState {\n\t\tif (this.disposed) {\n\t\t\treturn { shouldSummarize: false, stopReason: \"parentNotConnected\" };\n\t\t}\n\n\t\t// Note that if we're in the Running state, the electedClient may be a summarizer client, so we can't\n\t\t// enforce connectedState.clientId === clientElection.electedClientId. But once we're Running, we should\n\t\t// only transition to Stopping when the electedParentId changes. Stopping the summarizer without\n\t\t// changing the electedParent will just cause us to transition to Starting again.\n\n\t\t// New Parent has been elected and it is not the current client, or\n\t\tif (this.connectedState.clientId !== this.clientElection.electedParentId) {\n\t\t\treturn { shouldSummarize: false, stopReason: \"notElectedParent\" };\n\t\t}\n\n\t\t// We are not already running the summarizer and we are not the current elected client id.\n\t\tif (\n\t\t\tthis.state !== SummaryManagerState.Running &&\n\t\t\tthis.connectedState.clientId !== this.clientElection.electedClientId\n\t\t) {\n\t\t\treturn { shouldSummarize: false, stopReason: \"notElectedClient\" };\n\t\t}\n\n\t\tif (!this.connectedState.connected) {\n\t\t\treturn { shouldSummarize: false, stopReason: \"parentNotConnected\" };\n\t\t}\n\n\t\treturn { shouldSummarize: true };\n\t}\n\n\tprivate readonly refreshSummarizer = () => {\n\t\t// Transition states depending on shouldSummarize, which is a calculated property\n\t\t// that is only true if this client is connected and is the elected summarizer.\n\t\tconst shouldSummarizeState = this.getShouldSummarizeState();\n\t\tswitch (this.state) {\n\t\t\tcase SummaryManagerState.Off: {\n\t\t\t\tif (shouldSummarizeState.shouldSummarize) {\n\t\t\t\t\tthis.startSummarization();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase SummaryManagerState.Starting: {\n\t\t\t\t// Cannot take any action until summarizer is created\n\t\t\t\t// state transition will occur after creation\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase SummaryManagerState.Running: {\n\t\t\t\tif (shouldSummarizeState.shouldSummarize === false) {\n\t\t\t\t\tthis.stop(shouldSummarizeState.stopReason);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase SummaryManagerState.Stopping: {\n\t\t\t\t// Cannot take any action until running summarizer finishes\n\t\t\t\t// state transition will occur after it stops\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate startSummarization() {\n\t\tassert(this.state === SummaryManagerState.Off, 0x261 /* \"Expected: off\" */);\n\t\tthis.state = SummaryManagerState.Starting;\n\n\t\tassert(this.summarizer === undefined, 0x262 /* \"Old summarizer is still working!\" */);\n\n\t\tthis.delayBeforeCreatingSummarizer()\n\t\t\t.then(async (startWithInitialDelay: boolean) => {\n\t\t\t\tif (this.disposed) {\n\t\t\t\t\treturn \"early exit (disposed)\";\n\t\t\t\t}\n\n\t\t\t\t// Re-validate that it need to be running. Due to asynchrony, it may be not the case anymore\n\t\t\t\t// but only if creation was delayed. If it was not, then we want to ensure we always create\n\t\t\t\t// a summarizer to kick off lastSummary. Without that, we would not be able to summarize and get\n\t\t\t\t// document out of broken state if it has too many ops and ordering service keeps nacking main\n\t\t\t\t// container (and thus it goes into cycle of reconnects)\n\t\t\t\t// If we can't run the LastSummary, simply return as to avoid paying the cost of launching\n\t\t\t\t// the summarizer at all.\n\t\t\t\tconst shouldSummarizeStateEarlyStage = this.getShouldSummarizeState();\n\t\t\t\tif (\n\t\t\t\t\tstartWithInitialDelay &&\n\t\t\t\t\tshouldSummarizeStateEarlyStage.shouldSummarize === false\n\t\t\t\t) {\n\t\t\t\t\treturn `early exit ${shouldSummarizeStateEarlyStage.stopReason}`;\n\t\t\t\t}\n\n\t\t\t\t// We transition to Running before requesting the summarizer, because after requesting we can't predict\n\t\t\t\t// when the electedClient will be replaced with the new summarizer client.\n\t\t\t\t// The alternative would be to let connectedState.clientId !== clientElection.electedClientId when\n\t\t\t\t// state === Starting || state === Running.\n\t\t\t\tassert(this.state === SummaryManagerState.Starting, 0x263 /* \"Expected: starting\" */);\n\t\t\t\tthis.state = SummaryManagerState.Running;\n\n\t\t\t\tconst summarizer = await this.createSummarizerFn();\n\t\t\t\tthis.summarizer = summarizer;\n\t\t\t\tthis.summarizer.on(\"summarize\", this.handleSummarizeEvent);\n\n\t\t\t\t// Re-validate that it need to be running. Due to asynchrony, it may be not the case anymore\n\t\t\t\t// If we can't run the LastSummary, simply return as to avoid paying the cost of launching\n\t\t\t\t// the summarizer at all.\n\t\t\t\tconst shouldSummarizeState = this.getShouldSummarizeState();\n\t\t\t\tif (shouldSummarizeState.shouldSummarize === false) {\n\t\t\t\t\t// In order to allow the last summary to run, we not only need a stop reason that would\n\t\t\t\t\t// allow it but also, startWithInitialDelay to be false (start the summarization immediately),\n\t\t\t\t\t// which would happen when we have a high enough number of unsummarized ops.\n\t\t\t\t\tif (\n\t\t\t\t\t\tstartWithInitialDelay ||\n\t\t\t\t\t\t!Summarizer.stopReasonCanRunLastSummary(shouldSummarizeState.stopReason)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.state = SummaryManagerState.Starting;\n\t\t\t\t\t\tsummarizer.stop(shouldSummarizeState.stopReason);\n\t\t\t\t\t\treturn `early exit after starting summarizer ${shouldSummarizeState.stopReason}`;\n\t\t\t\t\t}\n\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"LastAttemptToSummarize\",\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst clientId = this.latestClientId!;\n\n\t\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\t\tthis.logger,\n\t\t\t\t\t{ eventName: \"RunningSummarizer\", attempt: this.startThrottler.numAttempts },\n\t\t\t\t\tasync () => summarizer.run(clientId),\n\t\t\t\t);\n\t\t\t})\n\t\t\t.then((reason: string) => {\n\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"EndingSummarizer\",\n\t\t\t\t\treason,\n\t\t\t\t});\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"EndingSummarizer\",\n\t\t\t\t\t\treason: \"exception\",\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\n\t\t\t\t// Most of exceptions happen due to container being closed while loading it, due to\n\t\t\t\t// summarizer container loosing connection while load.\n\t\t\t\t// Not worth reporting such errors as errors. That said, we might miss some real errors if\n\t\t\t\t// we ignore blindly, so try to narrow signature we are looking for - skip logging\n\t\t\t\t// error only if this client should no longer be a summarizer (which in practice\n\t\t\t\t// means it also lost connection), and error happened on load (we do not have summarizer).\n\t\t\t\t// We could annotate the error raised in Container.load where the container closed during load with no error\n\t\t\t\t// and check for that case here, but that does not seem to be necessary.\n\t\t\t\tif (this.getShouldSummarizeState().shouldSummarize || this.summarizer !== undefined) {\n\t\t\t\t\t// Report any failure as an error unless it was due to cancellation (like \"disconnected\" error)\n\t\t\t\t\t// If failure happened on container load, we may not yet realized that socket disconnected, so check\n\t\t\t\t\t// offlineError.\n\t\t\t\t\tconst category =\n\t\t\t\t\t\terror?.errorType === DriverErrorTypes.offlineError ? \"generic\" : \"error\";\n\t\t\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teventName: \"SummarizerException\",\n\t\t\t\t\t\t\tcategory,\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tassert(this.state !== SummaryManagerState.Off, 0x264 /* \"Expected: Not Off\" */);\n\t\t\t\tthis.state = SummaryManagerState.Off;\n\n\t\t\t\tthis.summarizer?.off(\"summarize\", this.handleSummarizeEvent);\n\t\t\t\tthis.summarizer?.close();\n\t\t\t\tthis.summarizer = undefined;\n\n\t\t\t\tif (this.getShouldSummarizeState().shouldSummarize) {\n\t\t\t\t\tthis.startSummarization();\n\t\t\t\t}\n\t\t\t});\n\t}\n\n\tprivate stop(reason: SummarizerStopReason) {\n\t\tif (!SummaryManager.isStartingOrRunning(this.state)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.state = SummaryManagerState.Stopping;\n\n\t\t// Stopping the running summarizer client should trigger a change\n\t\t// in states when the running summarizer closes\n\t\tthis.summarizer?.stop(reason);\n\t}\n\n\t/**\n\t * Implements initial delay before creating summarizer\n\t * @returns `true`, if creation is delayed due to heuristics (not many ops to summarize).\n\t * `false` if summarizer should start immediately due to too many unsummarized ops.\n\t */\n\tprivate async delayBeforeCreatingSummarizer(): Promise<boolean> {\n\t\t// throttle creation of new summarizer containers to prevent spamming the server with websocket connections\n\t\tlet delayMs = this.startThrottler.getDelay();\n\n\t\t// We have been elected the summarizer. Some day we may be able to summarize with a live document but for\n\t\t// now we play it safe and launch a second copy.\n\t\tthis.logger.sendTelemetryEvent({\n\t\t\teventName: \"CreatingSummarizer\",\n\t\t\tthrottlerDelay: delayMs,\n\t\t\tinitialDelay: this.initialDelayMs,\n\t\t\tstartThrottlerMaxDelayMs: this.startThrottler.maxDelayMs,\n\t\t\topsSinceLastAck: this.summaryCollection.opsSinceLastAck,\n\t\t\topsToBypassInitialDelay: this.opsToBypassInitialDelay,\n\t\t\telectedParentId: this.clientElection.electedParentId,\n\t\t\telectedClientId: this.clientElection.electedClientId,\n\t\t});\n\n\t\t// This delay helps ensure that last summarizer that might be left from previous client\n\t\t// has enough time to complete its last summary and thus new summarizer not conflict with previous one.\n\t\t// If, however, there are too many unsummarized ops, try to resolve it as quickly as possible, with\n\t\t// understanding that we may see nacks because of such quick action.\n\t\t// A better design would be for summarizer election logic to always select current summarizer as\n\t\t// summarizing client (i.e. clientType === \"summarizer\" can be elected) to ensure that nobody else can\n\t\t// summarizer while it finishes its work and moves to exit.\n\t\t// It also helps with pure boot scenario (single client) to offset expensive work a bit out from\n\t\t// critical boot sequence.\n\t\tlet startWithInitialDelay = false;\n\t\tif (this.summaryCollection.opsSinceLastAck < this.opsToBypassInitialDelay) {\n\t\t\tstartWithInitialDelay = true;\n\t\t\tdelayMs = Math.max(delayMs, this.initialDelayMs);\n\t\t}\n\n\t\tif (delayMs > 0) {\n\t\t\tlet timer;\n\t\t\tlet resolveOpPromiseFn;\n\t\t\t// Create a listener that will break the delay if we've exceeded the initial delay ops count.\n\t\t\tconst opsListenerFn = () => {\n\t\t\t\tif (this.summaryCollection.opsSinceLastAck >= this.opsToBypassInitialDelay) {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tresolveOpPromiseFn();\n\t\t\t\t}\n\t\t\t};\n\t\t\t// Create a Promise that will resolve when the delay expires.\n\t\t\tconst delayPromise = new Promise<void>((resolve) => {\n\t\t\t\ttimer = setTimeout(() => resolve(), delayMs);\n\t\t\t});\n\t\t\t// Create a Promise that will resolve if the ops count passes the threshold.\n\t\t\tconst opPromise = new Promise<void>((resolve) => {\n\t\t\t\tresolveOpPromiseFn = resolve;\n\t\t\t});\n\t\t\tthis.summaryCollection.addOpListener(opsListenerFn);\n\t\t\tawait Promise.race([delayPromise, opPromise]);\n\t\t\tthis.summaryCollection.removeOpListener(opsListenerFn);\n\t\t}\n\t\treturn startWithInitialDelay;\n\t}\n\n\tpublic summarizeOnDemand(options: IOnDemandSummarizeOptions): ISummarizeResults {\n\t\tif (this.summarizer === undefined) {\n\t\t\tthrow Error(\"No running summarizer client\");\n\t\t\t// TODO: could spawn a summarizer client temporarily.\n\t\t}\n\t\treturn this.summarizer.summarizeOnDemand(options);\n\t}\n\n\tpublic enqueueSummarize(options: IEnqueueSummarizeOptions): EnqueueSummarizeResult {\n\t\tif (this.summarizer === undefined) {\n\t\t\tthrow Error(\"No running summarizer client\");\n\t\t\t// TODO: could spawn a summarizer client temporarily.\n\t\t}\n\t\treturn this.summarizer.enqueueSummarize(options);\n\t}\n\n\tpublic dispose() {\n\t\tthis.clientElection.off(\"electedSummarizerChanged\", this.refreshSummarizer);\n\t\tthis.connectedState.off(\"connected\", this.handleConnected);\n\t\tthis.connectedState.off(\"disconnected\", this.handleDisconnected);\n\t\tthis.summarizer?.off(\"summarize\", this.handleSummarizeEvent);\n\t\tthis._disposed = true;\n\t}\n}\n"]}
1
+ {"version":3,"file":"summaryManager.js","sourceRoot":"","sources":["../../src/summary/summaryManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAWjE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAC/E,OAAO,EAEN,gBAAgB,EAChB,iBAAiB,GACjB,MAAM,0CAA0C,CAAC;AAIlD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAW7C,MAAM,qBAAqB,GAAG,IAAI,CAAC;AACnC,MAAM,8BAA8B,GAAG,IAAI,CAAC;AAE5C,MAAM,CAAN,IAAY,mBAKX;AALD,WAAY,mBAAmB;IAC9B,2DAAO,CAAA;IACP,qEAAY,CAAA;IACZ,mEAAW,CAAA;IACX,qEAAY,CAAA;AACb,CAAC,EALW,mBAAmB,KAAnB,mBAAmB,QAK9B;AA0CD;;;;GAIG;AACH,MAAM,OAAO,cACZ,SAAQ,iBAAoC;IAW5C,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IAED,IAAW,YAAY;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAED,YACkB,cAAyC,EACzC,cAA+B,EAC/B,iBAGhB,EACD,YAAkC;IAClC;2CACuC;IACtB,kBAA8C,EAC9C,cAA0B,EAC3C,EACC,cAAc,GAAG,qBAAqB,EACtC,uBAAuB,GAAG,8BAA8B,MACX,EAAE;QAEhD,KAAK,EAAE,CAAC;QAhBS,mBAAc,GAAd,cAAc,CAA2B;QACzC,mBAAc,GAAd,cAAc,CAAiB;QAC/B,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AQ,CAAC,CAAC,CAAC;QACzF,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;;AAhTuB,kCAAmB,GAAG,CAAC,KAA0B,EAAE,EAAE,CAC5E,KAAK,KAAK,mBAAmB,CAAC,QAAQ,IAAI,KAAK,KAAK,mBAAmB,CAAC,OAAO,AADrC,CACsC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type {\n\tISummarizerEvents,\n\tSummarizerStopReason,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport {\n\tIDisposable,\n\tIEvent,\n\tIEventProvider,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { DriverErrorTypes } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tcreateChildLogger,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { IThrottler } from \"../throttler.js\";\n\nimport { Summarizer } from \"./summarizer.js\";\nimport { ISummarizerClientElection } from \"./summarizerClientElection.js\";\nimport {\n\tEnqueueSummarizeResult,\n\tIEnqueueSummarizeOptions,\n\tIOnDemandSummarizeOptions,\n\tISummarizeResults,\n\tISummarizer,\n} from \"./summarizerTypes.js\";\nimport { SummaryCollection } from \"./summaryCollection.js\";\n\nconst defaultInitialDelayMs = 5000;\nconst defaultOpsToBypassInitialDelay = 4000;\n\nexport enum SummaryManagerState {\n\tOff = 0,\n\tStarting = 1,\n\tRunning = 2,\n\tStopping = 3,\n}\n\n// Please note that all reasons in this list are not errors,\n// and thus they are not raised today to parent container as error.\n// If this needs to be changed in future, we should re-evaluate what and how we raise to summarizer\ntype StopReason = Extract<\n\tSummarizerStopReason,\n\t\"parentNotConnected\" | \"notElectedParent\" | \"notElectedClient\"\n>;\ntype ShouldSummarizeState =\n\t| { shouldSummarize: true }\n\t| { shouldSummarize: false; stopReason: StopReason };\n\nexport interface IConnectedEvents extends IEvent {\n\t(event: \"connected\", listener: (clientId: string) => void);\n\t(event: \"disconnected\", listener: () => void);\n}\n\n/**\n * IConnectedState describes an object that SummaryManager can watch to observe connection/disconnection.\n *\n * Under current implementation, its role will be fulfilled by the ContainerRuntime, but this could be replaced\n * with anything else that fulfills the contract if we want to shift the layer that the SummaryManager lives at.\n */\nexport interface IConnectedState extends IEventProvider<IConnectedEvents> {\n\treadonly connected: boolean;\n\n\t/**\n\t * Under current implementation this is undefined if we've never connected, otherwise it's the clientId from our\n\t * latest connection (even if we've since disconnected!). Although this happens to be the behavior we want in\n\t * SummaryManager, I suspect that globally we may eventually want to modify this behavior (e.g. make clientId\n\t * undefined while disconnected). To protect against this, let's assume this field can't be trusted while\n\t * disconnected and instead separately track \"latest clientId\" in SummaryManager.\n\t */\n\treadonly clientId: string | undefined;\n}\n\nexport interface ISummaryManagerConfig {\n\tinitialDelayMs: number;\n\topsToBypassInitialDelay: number;\n}\n\n/**\n * SummaryManager is created by parent container (i.e. interactive container with clientType !== \"summarizer\") only.\n * It observes changes in calculated summarizer and reacts to changes by either creating summarizer client or\n * stopping existing summarizer client.\n */\nexport class SummaryManager\n\textends TypedEventEmitter<ISummarizerEvents>\n\timplements IDisposable\n{\n\tprivate readonly logger: ITelemetryLoggerExt;\n\tprivate readonly opsToBypassInitialDelay: number;\n\tprivate readonly initialDelayMs: number;\n\tprivate latestClientId: string | undefined;\n\tprivate state = SummaryManagerState.Off;\n\tprivate summarizer?: ISummarizer;\n\tprivate _disposed = false;\n\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\n\tpublic get currentState() {\n\t\treturn this.state;\n\t}\n\n\tconstructor(\n\t\tprivate readonly clientElection: ISummarizerClientElection,\n\t\tprivate readonly connectedState: IConnectedState,\n\t\tprivate readonly summaryCollection: Pick<\n\t\t\tSummaryCollection,\n\t\t\t\"opsSinceLastAck\" | \"addOpListener\" | \"removeOpListener\"\n\t\t>,\n\t\tparentLogger: ITelemetryBaseLogger,\n\t\t/** Creates summarizer by asking interactive container to spawn summarizing container and\n\t\t * get back its Summarizer instance. */\n\t\tprivate readonly createSummarizerFn: () => Promise<ISummarizer>,\n\t\tprivate readonly startThrottler: IThrottler,\n\t\t{\n\t\t\tinitialDelayMs = defaultInitialDelayMs,\n\t\t\topsToBypassInitialDelay = defaultOpsToBypassInitialDelay,\n\t\t}: Readonly<Partial<ISummaryManagerConfig>> = {},\n\t) {\n\t\tsuper();\n\n\t\tthis.logger = createChildLogger({\n\t\t\tlogger: parentLogger,\n\t\t\tnamespace: \"SummaryManager\",\n\t\t\tproperties: {\n\t\t\t\tall: { clientId: () => this.latestClientId },\n\t\t\t},\n\t\t});\n\n\t\tthis.connectedState.on(\"connected\", this.handleConnected);\n\t\tthis.connectedState.on(\"disconnected\", this.handleDisconnected);\n\t\tthis.latestClientId = this.connectedState.clientId;\n\n\t\tthis.opsToBypassInitialDelay = opsToBypassInitialDelay;\n\t\tthis.initialDelayMs = initialDelayMs;\n\t}\n\n\t/**\n\t * Until start is called, the SummaryManager won't begin attempting to start summarization. This ensures there's\n\t * a window between construction and starting where the caller can attach listeners.\n\t */\n\tpublic start(): void {\n\t\tthis.clientElection.on(\"electedSummarizerChanged\", this.refreshSummarizer);\n\t\tthis.refreshSummarizer();\n\t}\n\n\tprivate readonly handleConnected = (clientId: string) => {\n\t\tthis.latestClientId = clientId;\n\t\t// If we have a summarizer, it should have been either cancelled on disconnected by now.\n\t\t// But because of lastSummary process, it can still hang around, so there is not much we can\n\t\t// check or assert.\n\t\tthis.refreshSummarizer();\n\t};\n\n\tprivate readonly handleDisconnected = () => {\n\t\tthis.refreshSummarizer();\n\t};\n\n\tprivate static readonly isStartingOrRunning = (state: SummaryManagerState) =>\n\t\tstate === SummaryManagerState.Starting || state === SummaryManagerState.Running;\n\n\tprivate getShouldSummarizeState(): ShouldSummarizeState {\n\t\tif (this.disposed) {\n\t\t\treturn { shouldSummarize: false, stopReason: \"parentNotConnected\" };\n\t\t}\n\n\t\t// Note that if we're in the Running state, the electedClient may be a summarizer client, so we can't\n\t\t// enforce connectedState.clientId === clientElection.electedClientId. But once we're Running, we should\n\t\t// only transition to Stopping when the electedParentId changes. Stopping the summarizer without\n\t\t// changing the electedParent will just cause us to transition to Starting again.\n\n\t\t// New Parent has been elected and it is not the current client, or\n\t\tif (this.connectedState.clientId !== this.clientElection.electedParentId) {\n\t\t\treturn { shouldSummarize: false, stopReason: \"notElectedParent\" };\n\t\t}\n\n\t\t// We are not already running the summarizer and we are not the current elected client id.\n\t\tif (\n\t\t\tthis.state !== SummaryManagerState.Running &&\n\t\t\tthis.connectedState.clientId !== this.clientElection.electedClientId\n\t\t) {\n\t\t\treturn { shouldSummarize: false, stopReason: \"notElectedClient\" };\n\t\t}\n\n\t\tif (!this.connectedState.connected) {\n\t\t\treturn { shouldSummarize: false, stopReason: \"parentNotConnected\" };\n\t\t}\n\n\t\treturn { shouldSummarize: true };\n\t}\n\n\tprivate readonly refreshSummarizer = () => {\n\t\t// Transition states depending on shouldSummarize, which is a calculated property\n\t\t// that is only true if this client is connected and is the elected summarizer.\n\t\tconst shouldSummarizeState = this.getShouldSummarizeState();\n\t\tswitch (this.state) {\n\t\t\tcase SummaryManagerState.Off: {\n\t\t\t\tif (shouldSummarizeState.shouldSummarize) {\n\t\t\t\t\tthis.startSummarization();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase SummaryManagerState.Starting: {\n\t\t\t\t// Cannot take any action until summarizer is created\n\t\t\t\t// state transition will occur after creation\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase SummaryManagerState.Running: {\n\t\t\t\tif (shouldSummarizeState.shouldSummarize === false) {\n\t\t\t\t\tthis.stop(shouldSummarizeState.stopReason);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase SummaryManagerState.Stopping: {\n\t\t\t\t// Cannot take any action until running summarizer finishes\n\t\t\t\t// state transition will occur after it stops\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate startSummarization() {\n\t\tassert(this.state === SummaryManagerState.Off, 0x261 /* \"Expected: off\" */);\n\t\tthis.state = SummaryManagerState.Starting;\n\n\t\tassert(this.summarizer === undefined, 0x262 /* \"Old summarizer is still working!\" */);\n\n\t\tthis.delayBeforeCreatingSummarizer()\n\t\t\t.then(async (startWithInitialDelay: boolean) => {\n\t\t\t\tif (this.disposed) {\n\t\t\t\t\treturn \"early exit (disposed)\";\n\t\t\t\t}\n\n\t\t\t\t// Re-validate that it need to be running. Due to asynchrony, it may be not the case anymore\n\t\t\t\t// but only if creation was delayed. If it was not, then we want to ensure we always create\n\t\t\t\t// a summarizer to kick off lastSummary. Without that, we would not be able to summarize and get\n\t\t\t\t// document out of broken state if it has too many ops and ordering service keeps nacking main\n\t\t\t\t// container (and thus it goes into cycle of reconnects)\n\t\t\t\t// If we can't run the LastSummary, simply return as to avoid paying the cost of launching\n\t\t\t\t// the summarizer at all.\n\t\t\t\tconst shouldSummarizeStateEarlyStage = this.getShouldSummarizeState();\n\t\t\t\tif (\n\t\t\t\t\tstartWithInitialDelay &&\n\t\t\t\t\tshouldSummarizeStateEarlyStage.shouldSummarize === false\n\t\t\t\t) {\n\t\t\t\t\treturn `early exit ${shouldSummarizeStateEarlyStage.stopReason}`;\n\t\t\t\t}\n\n\t\t\t\t// We transition to Running before requesting the summarizer, because after requesting we can't predict\n\t\t\t\t// when the electedClient will be replaced with the new summarizer client.\n\t\t\t\t// The alternative would be to let connectedState.clientId !== clientElection.electedClientId when\n\t\t\t\t// state === Starting || state === Running.\n\t\t\t\tassert(this.state === SummaryManagerState.Starting, 0x263 /* \"Expected: starting\" */);\n\t\t\t\tthis.state = SummaryManagerState.Running;\n\n\t\t\t\tconst summarizer = await this.createSummarizerFn();\n\t\t\t\tthis.summarizer = summarizer;\n\t\t\t\tthis.setupForwardedEvents();\n\n\t\t\t\t// Re-validate that it need to be running. Due to asynchrony, it may be not the case anymore\n\t\t\t\t// If we can't run the LastSummary, simply return as to avoid paying the cost of launching\n\t\t\t\t// the summarizer at all.\n\t\t\t\tconst shouldSummarizeState = this.getShouldSummarizeState();\n\t\t\t\tif (shouldSummarizeState.shouldSummarize === false) {\n\t\t\t\t\t// In order to allow the last summary to run, we not only need a stop reason that would\n\t\t\t\t\t// allow it but also, startWithInitialDelay to be false (start the summarization immediately),\n\t\t\t\t\t// which would happen when we have a high enough number of unsummarized ops.\n\t\t\t\t\tif (\n\t\t\t\t\t\tstartWithInitialDelay ||\n\t\t\t\t\t\t!Summarizer.stopReasonCanRunLastSummary(shouldSummarizeState.stopReason)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.state = SummaryManagerState.Starting;\n\t\t\t\t\t\tsummarizer.stop(shouldSummarizeState.stopReason);\n\t\t\t\t\t\treturn `early exit after starting summarizer ${shouldSummarizeState.stopReason}`;\n\t\t\t\t\t}\n\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"LastAttemptToSummarize\",\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst clientId = this.latestClientId!;\n\n\t\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\t\tthis.logger,\n\t\t\t\t\t{ eventName: \"RunningSummarizer\", attempt: this.startThrottler.numAttempts },\n\t\t\t\t\tasync () => summarizer.run(clientId),\n\t\t\t\t);\n\t\t\t})\n\t\t\t.then((reason: string) => {\n\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"EndingSummarizer\",\n\t\t\t\t\treason,\n\t\t\t\t});\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"EndingSummarizer\",\n\t\t\t\t\t\treason: \"exception\",\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\n\t\t\t\t// Most of exceptions happen due to container being closed while loading it, due to\n\t\t\t\t// summarizer container loosing connection while load.\n\t\t\t\t// Not worth reporting such errors as errors. That said, we might miss some real errors if\n\t\t\t\t// we ignore blindly, so try to narrow signature we are looking for - skip logging\n\t\t\t\t// error only if this client should no longer be a summarizer (which in practice\n\t\t\t\t// means it also lost connection), and error happened on load (we do not have summarizer).\n\t\t\t\t// We could annotate the error raised in Container.load where the container closed during load with no error\n\t\t\t\t// and check for that case here, but that does not seem to be necessary.\n\t\t\t\tif (this.getShouldSummarizeState().shouldSummarize || this.summarizer !== undefined) {\n\t\t\t\t\t// Report any failure as an error unless it was due to cancellation (like \"disconnected\" error)\n\t\t\t\t\t// If failure happened on container load, we may not yet realized that socket disconnected, so check\n\t\t\t\t\t// offlineError.\n\t\t\t\t\tconst category =\n\t\t\t\t\t\terror?.errorType === DriverErrorTypes.offlineError ? \"generic\" : \"error\";\n\t\t\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teventName: \"SummarizerException\",\n\t\t\t\t\t\t\tcategory,\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tassert(this.state !== SummaryManagerState.Off, 0x264 /* \"Expected: Not Off\" */);\n\t\t\t\tthis.state = SummaryManagerState.Off;\n\n\t\t\t\tthis.cleanupForwardedEvents();\n\t\t\t\tthis.summarizer?.close();\n\t\t\t\tthis.summarizer = undefined;\n\n\t\t\t\tif (this.getShouldSummarizeState().shouldSummarize) {\n\t\t\t\t\tthis.startSummarization();\n\t\t\t\t}\n\t\t\t});\n\t}\n\n\tprivate stop(reason: SummarizerStopReason) {\n\t\tif (!SummaryManager.isStartingOrRunning(this.state)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.state = SummaryManagerState.Stopping;\n\n\t\t// Stopping the running summarizer client should trigger a change\n\t\t// in states when the running summarizer closes\n\t\tthis.summarizer?.stop(reason);\n\t}\n\n\t/**\n\t * Implements initial delay before creating summarizer\n\t * @returns `true`, if creation is delayed due to heuristics (not many ops to summarize).\n\t * `false` if summarizer should start immediately due to too many unsummarized ops.\n\t */\n\tprivate async delayBeforeCreatingSummarizer(): Promise<boolean> {\n\t\t// throttle creation of new summarizer containers to prevent spamming the server with websocket connections\n\t\tlet delayMs = this.startThrottler.getDelay();\n\n\t\t// We have been elected the summarizer. Some day we may be able to summarize with a live document but for\n\t\t// now we play it safe and launch a second copy.\n\t\tthis.logger.sendTelemetryEvent({\n\t\t\teventName: \"CreatingSummarizer\",\n\t\t\tthrottlerDelay: delayMs,\n\t\t\tinitialDelay: this.initialDelayMs,\n\t\t\tstartThrottlerMaxDelayMs: this.startThrottler.maxDelayMs,\n\t\t\topsSinceLastAck: this.summaryCollection.opsSinceLastAck,\n\t\t\topsToBypassInitialDelay: this.opsToBypassInitialDelay,\n\t\t\telectedParentId: this.clientElection.electedParentId,\n\t\t\telectedClientId: this.clientElection.electedClientId,\n\t\t});\n\n\t\t// This delay helps ensure that last summarizer that might be left from previous client\n\t\t// has enough time to complete its last summary and thus new summarizer not conflict with previous one.\n\t\t// If, however, there are too many unsummarized ops, try to resolve it as quickly as possible, with\n\t\t// understanding that we may see nacks because of such quick action.\n\t\t// A better design would be for summarizer election logic to always select current summarizer as\n\t\t// summarizing client (i.e. clientType === \"summarizer\" can be elected) to ensure that nobody else can\n\t\t// summarizer while it finishes its work and moves to exit.\n\t\t// It also helps with pure boot scenario (single client) to offset expensive work a bit out from\n\t\t// critical boot sequence.\n\t\tlet startWithInitialDelay = false;\n\t\tif (this.summaryCollection.opsSinceLastAck < this.opsToBypassInitialDelay) {\n\t\t\tstartWithInitialDelay = true;\n\t\t\tdelayMs = Math.max(delayMs, this.initialDelayMs);\n\t\t}\n\n\t\tif (delayMs > 0) {\n\t\t\tlet timer;\n\t\t\tlet resolveOpPromiseFn;\n\t\t\t// Create a listener that will break the delay if we've exceeded the initial delay ops count.\n\t\t\tconst opsListenerFn = () => {\n\t\t\t\tif (this.summaryCollection.opsSinceLastAck >= this.opsToBypassInitialDelay) {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tresolveOpPromiseFn();\n\t\t\t\t}\n\t\t\t};\n\t\t\t// Create a Promise that will resolve when the delay expires.\n\t\t\tconst delayPromise = new Promise<void>((resolve) => {\n\t\t\t\ttimer = setTimeout(() => resolve(), delayMs);\n\t\t\t});\n\t\t\t// Create a Promise that will resolve if the ops count passes the threshold.\n\t\t\tconst opPromise = new Promise<void>((resolve) => {\n\t\t\t\tresolveOpPromiseFn = resolve;\n\t\t\t});\n\t\t\tthis.summaryCollection.addOpListener(opsListenerFn);\n\t\t\tawait Promise.race([delayPromise, opPromise]);\n\t\t\tthis.summaryCollection.removeOpListener(opsListenerFn);\n\t\t}\n\t\treturn startWithInitialDelay;\n\t}\n\n\tpublic summarizeOnDemand(options: IOnDemandSummarizeOptions): ISummarizeResults {\n\t\tif (this.summarizer === undefined) {\n\t\t\tthrow Error(\"No running summarizer client\");\n\t\t\t// TODO: could spawn a summarizer client temporarily.\n\t\t}\n\t\treturn this.summarizer.summarizeOnDemand(options);\n\t}\n\n\tpublic enqueueSummarize(options: IEnqueueSummarizeOptions): EnqueueSummarizeResult {\n\t\tif (this.summarizer === undefined) {\n\t\t\tthrow Error(\"No running summarizer client\");\n\t\t\t// TODO: could spawn a summarizer client temporarily.\n\t\t}\n\t\treturn this.summarizer.enqueueSummarize(options);\n\t}\n\n\tpublic dispose() {\n\t\tthis.clientElection.off(\"electedSummarizerChanged\", this.refreshSummarizer);\n\t\tthis.connectedState.off(\"connected\", this.handleConnected);\n\t\tthis.connectedState.off(\"disconnected\", this.handleDisconnected);\n\t\tthis.cleanupForwardedEvents();\n\t\tthis._disposed = true;\n\t}\n\n\tprivate readonly forwardedEvents = new Map<any, () => void>();\n\n\tprivate setupForwardedEvents() {\n\t\t[\n\t\t\t\"summarize\",\n\t\t\t\"summarizeAllAttemptsFailed\",\n\t\t\t\"summarizerStop\",\n\t\t\t\"summarizerStart\",\n\t\t\t\"summarizerStartupFailed\",\n\t\t].forEach((event) => {\n\t\t\tconst listener = (...args: any[]) => {\n\t\t\t\tthis.emit(event, ...args);\n\t\t\t};\n\t\t\tthis.summarizer?.on(event as any, listener);\n\t\t\tthis.forwardedEvents.set(event, listener);\n\t\t});\n\t}\n\n\tprivate cleanupForwardedEvents() {\n\t\tthis.forwardedEvents.forEach((listener, event) => this.summarizer?.off(event, listener));\n\t\tthis.forwardedEvents.clear();\n\t}\n}\n"]}