@fluidframework/container-runtime 2.0.0-internal.2.4.0 → 2.0.0-internal.3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/containerRuntime.d.ts +45 -42
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +87 -38
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStoreContext.d.ts +1 -0
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js +7 -2
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/opLifecycle/outbox.d.ts.map +1 -1
- package/dist/opLifecycle/outbox.js +0 -1
- package/dist/opLifecycle/outbox.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/pendingStateManager.d.ts +4 -13
- package/dist/pendingStateManager.d.ts.map +1 -1
- package/dist/pendingStateManager.js +130 -160
- package/dist/pendingStateManager.js.map +1 -1
- package/dist/summarizerClientElection.d.ts +1 -2
- package/dist/summarizerClientElection.d.ts.map +1 -1
- package/dist/summarizerClientElection.js +3 -30
- package/dist/summarizerClientElection.js.map +1 -1
- package/dist/summarizerTypes.d.ts +0 -4
- package/dist/summarizerTypes.d.ts.map +1 -1
- package/dist/summarizerTypes.js.map +1 -1
- package/lib/containerRuntime.d.ts +45 -42
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +87 -38
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStoreContext.d.ts +1 -0
- package/lib/dataStoreContext.d.ts.map +1 -1
- package/lib/dataStoreContext.js +7 -2
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/opLifecycle/outbox.d.ts.map +1 -1
- package/lib/opLifecycle/outbox.js +0 -1
- package/lib/opLifecycle/outbox.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/pendingStateManager.d.ts +4 -13
- package/lib/pendingStateManager.d.ts.map +1 -1
- package/lib/pendingStateManager.js +130 -160
- package/lib/pendingStateManager.js.map +1 -1
- package/lib/summarizerClientElection.d.ts +1 -2
- package/lib/summarizerClientElection.d.ts.map +1 -1
- package/lib/summarizerClientElection.js +3 -30
- package/lib/summarizerClientElection.js.map +1 -1
- package/lib/summarizerTypes.d.ts +0 -4
- package/lib/summarizerTypes.d.ts.map +1 -1
- package/lib/summarizerTypes.js.map +1 -1
- package/package.json +34 -16
- package/src/containerRuntime.ts +116 -84
- package/src/dataStoreContext.ts +12 -6
- package/src/opLifecycle/outbox.ts +0 -2
- package/src/packageVersion.ts +1 -1
- package/src/pendingStateManager.ts +146 -187
- package/src/summarizerClientElection.ts +1 -30
- package/src/summarizerTypes.ts +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summarizerClientElection.js","sourceRoot":"","sources":["../src/summarizerClientElection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAkB,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAInF,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAWjD;;;;GAIG;AACH,MAAM,OAAO,wBACT,SAAQ,iBAAkD;IAuB1D,YACqB,MAAwB,EACxB,iBAA6D,EAC9D,cAAsC,EACrC,sBAA8B,EAC9B,eAAwB;QAEzC,KAAK,EAAE,CAAC;QANS,WAAM,GAAN,MAAM,CAAkB;QACxB,sBAAiB,GAAjB,iBAAiB,CAA4C;QAC9D,mBAAc,GAAd,cAAc,CAAwB;QACrC,2BAAsB,GAAtB,sBAAsB,CAAQ;QAC9B,oBAAe,GAAf,eAAe,CAAS;QAnB7C;;;;WAIG;QACK,oBAAe,GAAG,CAAC,CAAC;QAiBxB,6FAA6F;QAC7F,2CAA2C;QAC3C,IAAI,CAAC,iBAAiB,C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CAAC;QAC1C,CAAC,CAAC,CAAC;IACP,CAAC;IA9FD,IAAW,eAAe;;QACtB,OAAO,MAAA,IAAI,CAAC,cAAc,CAAC,aAAa,0CAAE,QAAQ,CAAC;IACvD,CAAC;IACD,IAAW,eAAe;;QACtB,OAAO,MAAA,IAAI,CAAC,cAAc,CAAC,aAAa,0CAAE,QAAQ,CAAC;IACvD,CAAC;IA2FM,SAAS;;QACZ,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,sBAAsB,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC;QACrG,OAAO;YACH,eAAe;YACf,eAAe;YACf,sBAAsB,EAAE,MAAA,IAAI,CAAC,0BAA0B,mCAAI,sBAAsB;SACpF,CAAC;IACN,CAAC;IAEM,MAAM,CAAC,gBAAgB,CAAC,MAAsB;QACjD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;QACtC,IAAI,OAAO,KAAK,SAAS,EAAE;YACvB,+BAA+B;YAC/B,OAAO,IAAI,CAAC;SACf;QACD,OAAO,wBAAwB,CAAC,2BAA2B,CAAC,OAAO,CAAC,CAAC;IACzE,CAAC;;AAEsB,oDAA2B,GAAG,CAAC,OAAuB,EAAW,EAAE,CACtF,OAAO,CAAC,YAAY,CAAC,WAAW,IAAI,OAAO,CAAC,IAAI,KAAK,oBAAoB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IEvent, IEventProvider, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { IClientDetails, MessageType } from \"@fluidframework/protocol-definitions\";\nimport { IOrderedClientElection, ISerializedElection, ITrackedClient } from \"./orderedClientElection\";\nimport { ISummaryCollectionOpEvents } from \"./summaryCollection\";\n\nexport const summarizerClientType = \"summarizer\";\n\nexport interface ISummarizerClientElectionEvents extends IEvent {\n (event: \"electedSummarizerChanged\", handler: () => void): void;\n}\n\nexport interface ISummarizerClientElection extends IEventProvider<ISummarizerClientElectionEvents> {\n readonly electedClientId: string | undefined;\n readonly electedParentId: string | undefined;\n}\n\n/**\n * This class encapsulates logic around tracking the elected summarizer client.\n * It will handle updating the elected client when a summary ack hasn't been seen\n * for some configured number of ops.\n */\nexport class SummarizerClientElection\n extends TypedEventEmitter<ISummarizerClientElectionEvents>\n implements ISummarizerClientElection {\n /**\n * Used to calculate number of ops since last summary ack for the current elected client.\n * This will be undefined if there is no elected summarizer, or no summary ack has been\n * observed since this client was elected.\n * When a summary ack comes in, this will be set to the sequence number of the summary ack.\n */\n private lastSummaryAckSeqForClient: number | undefined;\n /**\n * Used to prevent excess logging by recording the sequence number that we last reported at,\n * and making sure we don't report another event to telemetry. If things work as intended,\n * this is not needed, otherwise it could report an event on every op in worst case scenario.\n */\n private lastReportedSeq = 0;\n\n public get electedClientId() {\n return this.clientElection.electedClient?.clientId;\n }\n public get electedParentId() {\n return this.clientElection.electedParent?.clientId;\n }\n\n constructor(\n private readonly logger: ITelemetryLogger,\n private readonly summaryCollection: IEventProvider<ISummaryCollectionOpEvents>,\n public readonly clientElection: IOrderedClientElection,\n private readonly maxOpsSinceLastSummary: number,\n private readonly electionEnabled: boolean,\n ) {\n super();\n // On every inbound op, if enough ops pass without seeing a summary ack (per elected client),\n // elect a new client and log to telemetry.\n this.summaryCollection.on(\"default\", ({ sequenceNumber }) => {\n const electedClientId = this.electedClientId;\n if (electedClientId === undefined) {\n // Reset election if no elected client, but eligible clients are connected.\n // This should be uncommon, but is possible if the initial state of the\n // ordered client election contains an undefined client id or one not found\n // in the quorum (the latter would already log an error).\n if (this.clientElection.eligibleCount > 0) {\n this.clientElection.resetElectedClient(sequenceNumber);\n }\n return;\n }\n let electionSequenceNumber = this.clientElection.electionSequenceNumber;\n const opsWithoutSummary = sequenceNumber - (this.lastSummaryAckSeqForClient ?? electionSequenceNumber);\n if (opsWithoutSummary > this.maxOpsSinceLastSummary) {\n // Log and elect a new summarizer client.\n const opsSinceLastReport = sequenceNumber - this.lastReportedSeq;\n if (opsSinceLastReport > this.maxOpsSinceLastSummary) {\n this.logger.sendTelemetryEvent({\n eventName: \"ElectedClientNotSummarizing\",\n electedClientId,\n lastSummaryAckSeqForClient: this.lastSummaryAckSeqForClient,\n electionSequenceNumber,\n nextElectedClientId: this.clientElection.peekNextElectedClient()?.clientId,\n electionEnabled: this.electionEnabled,\n });\n this.lastReportedSeq = sequenceNumber;\n }\n\n if (this.electionEnabled) {\n const previousParentId = this.electedParentId;\n this.clientElection.incrementElectedClient(sequenceNumber);\n\n // Verify that state incremented as expected. This should be reliable,\n // since all of OrderedClientElection is synchronous.\n electionSequenceNumber = this.clientElection.electionSequenceNumber;\n if (sequenceNumber > (this.lastSummaryAckSeqForClient ?? electionSequenceNumber)) {\n if (opsSinceLastReport > this.maxOpsSinceLastSummary) {\n this.logger.sendErrorEvent({\n eventName: \"UnexpectedElectionSequenceNumber\",\n // Expected to be undefined\n lastSummaryAckSeqForClient: this.lastSummaryAckSeqForClient,\n // Expected to be same as op sequenceNumber\n electionSequenceNumber,\n sequenceNumber,\n previousClientId: electedClientId,\n previousParentId,\n electedParentId: this.electedParentId,\n electedClientId: this.electedClientId,\n opsSinceLastReport,\n maxOpsSinceLastSummary,\n });\n }\n }\n }\n }\n });\n\n // When a summary ack comes in, reset our op seq counter.\n this.summaryCollection.on(MessageType.SummaryAck, (op) => {\n this.lastSummaryAckSeqForClient = op.sequenceNumber;\n });\n\n // Use oldest client election for unanimously and deterministically deciding\n // which client should summarize.\n this.clientElection.on(\"election\", (client, sequenceNumber) => {\n this.lastSummaryAckSeqForClient = undefined;\n if (client === undefined && this.clientElection.eligibleCount > 0) {\n // If no client is valid for election, reset to the oldest again.\n // Also make extra sure not to get stuck in an infinite loop here:\n // If there are no eligible clients, just wait until a client joins\n // and will be auto-elected.\n this.clientElection.resetElectedClient(sequenceNumber);\n }\n // Election can trigger a change in SummaryManager state.\n this.emit(\"electedSummarizerChanged\");\n });\n }\n\n public serialize(): ISerializedElection {\n const { electedClientId, electedParentId, electionSequenceNumber } = this.clientElection.serialize();\n return {\n electedClientId,\n electedParentId,\n electionSequenceNumber: this.lastSummaryAckSeqForClient ?? electionSequenceNumber,\n };\n }\n\n public static isClientEligible(client: ITrackedClient): boolean {\n const details = client.client.details;\n if (details === undefined) {\n // Very old clients back-compat\n return true;\n }\n return SummarizerClientElection.clientDetailsPermitElection(details);\n }\n\n public static readonly clientDetailsPermitElection = (details: IClientDetails): boolean =>\n details.capabilities.interactive || details.type === summarizerClientType;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"summarizerClientElection.js","sourceRoot":"","sources":["../src/summarizerClientElection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAkB,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAInF,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAWjD;;;;GAIG;AACH,MAAM,OAAO,wBACT,SAAQ,iBAAkD;IAuB1D,YACqB,MAAwB,EACxB,iBAA6D,EAC9D,cAAsC,EACrC,sBAA8B;QAE/C,KAAK,EAAE,CAAC;QALS,WAAM,GAAN,MAAM,CAAkB;QACxB,sBAAiB,GAAjB,iBAAiB,CAA4C;QAC9D,mBAAc,GAAd,cAAc,CAAwB;QACrC,2BAAsB,GAAtB,sBAAsB,CAAQ;QAlBnD;;;;WAIG;QACK,oBAAe,GAAG,CAAC,CAAC;QAgBxB,6FAA6F;QAC7F,2CAA2C;QAC3C,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,EAAE,cAAc,EAAE,EAAE,EAAE;;YACxD,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;YAC7C,IAAI,eAAe,KAAK,SAAS,EAAE;gBAC/B,2EAA2E;gBAC3E,uEAAuE;gBACvE,2EAA2E;gBAC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I,CAAC,cAAc,CAAC,aAAa,GAAG,CAAC,EAAE;gBAC/D,iEAAiE;gBACjE,kEAAkE;gBAClE,mEAAmE;gBACnE,4BAA4B;gBAC5B,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;aAC1D;YACD,yDAAyD;YACzD,IAAI,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;IACP,CAAC;IAjED,IAAW,eAAe;;QACtB,OAAO,MAAA,IAAI,CAAC,cAAc,CAAC,aAAa,0CAAE,QAAQ,CAAC;IACvD,CAAC;IACD,IAAW,eAAe;;QACtB,OAAO,MAAA,IAAI,CAAC,cAAc,CAAC,aAAa,0CAAE,QAAQ,CAAC;IACvD,CAAC;IA8DM,SAAS;;QACZ,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,sBAAsB,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC;QACrG,OAAO;YACH,eAAe;YACf,eAAe;YACf,sBAAsB,EAAE,MAAA,IAAI,CAAC,0BAA0B,mCAAI,sBAAsB;SACpF,CAAC;IACN,CAAC;IAEM,MAAM,CAAC,gBAAgB,CAAC,MAAsB;QACjD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;QACtC,IAAI,OAAO,KAAK,SAAS,EAAE;YACvB,+BAA+B;YAC/B,OAAO,IAAI,CAAC;SACf;QACD,OAAO,wBAAwB,CAAC,2BAA2B,CAAC,OAAO,CAAC,CAAC;IACzE,CAAC;;AAEsB,oDAA2B,GAAG,CAAC,OAAuB,EAAW,EAAE,CACtF,OAAO,CAAC,YAAY,CAAC,WAAW,IAAI,OAAO,CAAC,IAAI,KAAK,oBAAoB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IEvent, IEventProvider, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { IClientDetails, MessageType } from \"@fluidframework/protocol-definitions\";\nimport { IOrderedClientElection, ISerializedElection, ITrackedClient } from \"./orderedClientElection\";\nimport { ISummaryCollectionOpEvents } from \"./summaryCollection\";\n\nexport const summarizerClientType = \"summarizer\";\n\nexport interface ISummarizerClientElectionEvents extends IEvent {\n (event: \"electedSummarizerChanged\", handler: () => void): void;\n}\n\nexport interface ISummarizerClientElection extends IEventProvider<ISummarizerClientElectionEvents> {\n readonly electedClientId: string | undefined;\n readonly electedParentId: string | undefined;\n}\n\n/**\n * This class encapsulates logic around tracking the elected summarizer client.\n * It will handle updating the elected client when a summary ack hasn't been seen\n * for some configured number of ops.\n */\nexport class SummarizerClientElection\n extends TypedEventEmitter<ISummarizerClientElectionEvents>\n implements ISummarizerClientElection {\n /**\n * Used to calculate number of ops since last summary ack for the current elected client.\n * This will be undefined if there is no elected summarizer, or no summary ack has been\n * observed since this client was elected.\n * When a summary ack comes in, this will be set to the sequence number of the summary ack.\n */\n private lastSummaryAckSeqForClient: number | undefined;\n /**\n * Used to prevent excess logging by recording the sequence number that we last reported at,\n * and making sure we don't report another event to telemetry. If things work as intended,\n * this is not needed, otherwise it could report an event on every op in worst case scenario.\n */\n private lastReportedSeq = 0;\n\n public get electedClientId() {\n return this.clientElection.electedClient?.clientId;\n }\n public get electedParentId() {\n return this.clientElection.electedParent?.clientId;\n }\n\n constructor(\n private readonly logger: ITelemetryLogger,\n private readonly summaryCollection: IEventProvider<ISummaryCollectionOpEvents>,\n public readonly clientElection: IOrderedClientElection,\n private readonly maxOpsSinceLastSummary: number,\n ) {\n super();\n // On every inbound op, if enough ops pass without seeing a summary ack (per elected client),\n // elect a new client and log to telemetry.\n this.summaryCollection.on(\"default\", ({ sequenceNumber }) => {\n const electedClientId = this.electedClientId;\n if (electedClientId === undefined) {\n // Reset election if no elected client, but eligible clients are connected.\n // This should be uncommon, but is possible if the initial state of the\n // ordered client election contains an undefined client id or one not found\n // in the quorum (the latter would already log an error).\n if (this.clientElection.eligibleCount > 0) {\n this.clientElection.resetElectedClient(sequenceNumber);\n }\n return;\n }\n const electionSequenceNumber = this.clientElection.electionSequenceNumber;\n const opsWithoutSummary = sequenceNumber - (this.lastSummaryAckSeqForClient ?? electionSequenceNumber);\n if (opsWithoutSummary > this.maxOpsSinceLastSummary) {\n // Log and elect a new summarizer client.\n const opsSinceLastReport = sequenceNumber - this.lastReportedSeq;\n if (opsSinceLastReport > this.maxOpsSinceLastSummary) {\n this.logger.sendTelemetryEvent({\n eventName: \"ElectedClientNotSummarizing\",\n electedClientId,\n lastSummaryAckSeqForClient: this.lastSummaryAckSeqForClient,\n electionSequenceNumber,\n nextElectedClientId: this.clientElection.peekNextElectedClient()?.clientId,\n });\n this.lastReportedSeq = sequenceNumber;\n }\n }\n });\n\n // When a summary ack comes in, reset our op seq counter.\n this.summaryCollection.on(MessageType.SummaryAck, (op) => {\n this.lastSummaryAckSeqForClient = op.sequenceNumber;\n });\n\n // Use oldest client election for unanimously and deterministically deciding\n // which client should summarize.\n this.clientElection.on(\"election\", (client, sequenceNumber) => {\n this.lastSummaryAckSeqForClient = undefined;\n if (client === undefined && this.clientElection.eligibleCount > 0) {\n // If no client is valid for election, reset to the oldest again.\n // Also make extra sure not to get stuck in an infinite loop here:\n // If there are no eligible clients, just wait until a client joins\n // and will be auto-elected.\n this.clientElection.resetElectedClient(sequenceNumber);\n }\n // Election can trigger a change in SummaryManager state.\n this.emit(\"electedSummarizerChanged\");\n });\n }\n\n public serialize(): ISerializedElection {\n const { electedClientId, electedParentId, electionSequenceNumber } = this.clientElection.serialize();\n return {\n electedClientId,\n electedParentId,\n electionSequenceNumber: this.lastSummaryAckSeqForClient ?? electionSequenceNumber,\n };\n }\n\n public static isClientEligible(client: ITrackedClient): boolean {\n const details = client.client.details;\n if (details === undefined) {\n // Very old clients back-compat\n return true;\n }\n return SummarizerClientElection.clientDetailsPermitElection(details);\n }\n\n public static readonly clientDetailsPermitElection = (details: IClientDetails): boolean =>\n details.capabilities.interactive || details.type === summarizerClientType;\n}\n"]}
|
package/lib/summarizerTypes.d.ts
CHANGED
|
@@ -73,10 +73,6 @@ export interface ISummarizerRuntime extends IConnectableRuntime {
|
|
|
73
73
|
readonly summarizerClientId: string | undefined;
|
|
74
74
|
disposeFn?(): void;
|
|
75
75
|
closeFn(): void;
|
|
76
|
-
/** @deprecated 1.0, please remove all implementations and usage */
|
|
77
|
-
on(event: "batchEnd", listener: (error: any, op: ISequencedDocumentMessage) => void): this;
|
|
78
|
-
/** @deprecated 1.0, please remove all implementations and usage */
|
|
79
|
-
removeListener(event: "batchEnd", listener: (error: any, op: ISequencedDocumentMessage) => void): this;
|
|
80
76
|
}
|
|
81
77
|
/** Options affecting summarize behavior. */
|
|
82
78
|
export interface ISummarizeOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summarizerTypes.d.ts","sourceRoot":"","sources":["../src/summarizerTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,MAAM,EACN,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EACH,cAAc,EACjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,EACH,yBAAyB,EACzB,YAAY,EACZ,gBAAgB,EACnB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACjG,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,+BAA+B,EAAE,MAAM,GAAG,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,W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names":[],"mappings":"AAAA;;;GAGG;AAuBH;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAA6B,aAAa,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IEvent,\n IEventProvider,\n ITelemetryLogger,\n ITelemetryProperties,\n} from \"@fluidframework/common-definitions\";\nimport { ITelemetryLoggerPropertyBag } from \"@fluidframework/telemetry-utils\";\nimport {\n IFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\nimport { ContainerWarning, IDeltaManager } from \"@fluidframework/container-definitions\";\nimport {\n ISequencedDocumentMessage,\n ISummaryTree,\n IDocumentMessage,\n} from \"@fluidframework/protocol-definitions\";\nimport { ISummaryStats } from \"@fluidframework/runtime-definitions\";\nimport { ISummaryAckMessage, ISummaryNackMessage, ISummaryOpMessage } from \"./summaryCollection\";\nimport { SummarizeReason } from \"./summaryGenerator\";\nimport { ISummaryConfigurationHeuristics } from \".\";\n\n/**\n * @deprecated This will be removed in a later release.\n */\nexport const ISummarizer: keyof IProvideSummarizer = \"ISummarizer\";\n\n/**\n * @deprecated This will be removed in a later release.\n */\nexport interface IProvideSummarizer {\n /**\n * @deprecated This will be removed in a later release.\n */\n readonly ISummarizer: ISummarizer;\n}\n\n/**\n * Similar to AbortSignal, but using promise instead of events\n * @param T - cancellation reason type\n */\nexport interface ICancellationToken<T> {\n /** Tells if this cancellable token is cancelled */\n readonly cancelled: boolean;\n /**\n * Promise that gets fulfilled when this cancellable token is cancelled\n * @returns reason of cancellation\n */\n readonly waitCancelled: Promise<T>;\n}\n\n/* Similar to AbortSignal, but using promise instead of events */\nexport type ISummaryCancellationToken = ICancellationToken<SummarizerStopReason>;\n\nexport interface ISummarizerInternalsProvider {\n /** Encapsulates the work to walk the internals of the running container to generate a summary */\n submitSummary(options: ISubmitSummaryOptions): Promise<SubmitSummaryResult>;\n\n /** Callback whenever a new SummaryAck is received, to update internal tracking state */\n refreshLatestSummaryAck(options: IRefreshSummaryAckOptions): Promise<void>;\n}\n\n/**\n * @deprecated Options that control the behavior of a running summarizer.\n * */\nexport interface ISummarizerOptions {\n /**\n * Set to true to disable the default heuristics from running; false by default.\n * This affects only the heuristics around when a summarizer should\n * submit summaries. So when it is disabled, summarizer clients should\n * not be expected to summarize unless an on-demand summary is requested.\n */\n disableHeuristics: boolean;\n}\n\nexport interface ISummarizingWarning extends ContainerWarning {\n readonly errorType: \"summarizingError\";\n readonly logged: boolean;\n}\n\nexport interface IConnectableRuntime {\n readonly disposed: boolean;\n readonly connected: boolean;\n readonly clientId: string | undefined;\n readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;\n once(event: \"connected\" | \"disconnected\" | \"dispose\", listener: () => void): this;\n}\n\nexport interface ISummarizerRuntime extends IConnectableRuntime {\n readonly logger: ITelemetryLogger;\n /** clientId of parent (non-summarizing) container that owns summarizer container */\n readonly summarizerClientId: string | undefined;\n disposeFn?(): void;\n closeFn(): void;\n /** @deprecated 1.0, please remove all implementations and usage */\n on(event: \"batchEnd\", listener: (error: any, op: ISequencedDocumentMessage) => void): this;\n /** @deprecated 1.0, please remove all implementations and usage */\n removeListener(event: \"batchEnd\", listener: (error: any, op: ISequencedDocumentMessage) => void): this;\n}\n\n/** Options affecting summarize behavior. */\nexport interface ISummarizeOptions {\n /** True to generate the full tree with no handle reuse optimizations; defaults to false */\n readonly fullTree?: boolean;\n /** True to ask the server what the latest summary is first; defaults to false */\n readonly refreshLatestAck?: boolean;\n}\n\n/**\n * Data required to update internal tracking state after receiving a Summary Ack.\n */\n export interface IRefreshSummaryAckOptions {\n /** Handle from the ack's summary op. */\n readonly proposalHandle: string | undefined;\n /** Handle from the summary ack just received */\n readonly ackHandle: string;\n /** Reference sequence number from the ack's summary op */\n readonly summaryRefSeq: number;\n /** Telemetry logger to which telemetry events will be forwarded. */\n readonly summaryLogger: ITelemetryLogger;\n}\n\nexport interface ISubmitSummaryOptions extends ISummarizeOptions {\n /** Logger to use for correlated summary events */\n readonly summaryLogger: ITelemetryLogger;\n /** Tells when summary process should be cancelled */\n readonly cancellationToken: ISummaryCancellationToken;\n}\n\nexport interface IOnDemandSummarizeOptions extends ISummarizeOptions {\n /** Reason for generating summary. */\n readonly reason: string;\n}\n\n/** Options to use when enqueueing a summarize attempt. */\nexport interface IEnqueueSummarizeOptions extends IOnDemandSummarizeOptions {\n /** If specified, The summarize attempt will not occur until after this sequence number. */\n readonly afterSequenceNumber?: number;\n\n /**\n * True to override the existing enqueued summarize attempt if there is one.\n * This will guarantee that this attempt gets enqueued. If override is false,\n * than an existing enqueued summarize attempt will block a new one from being\n * enqueued. There can only be one enqueued at a time. Defaults to false.\n */\n readonly 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 */\nexport interface IGeneratedSummaryStats extends ISummaryStats {\n /** The total number of data stores in the container. */\n readonly dataStoreCount: number;\n /** The number of data stores that were summarized in this summary. */\n readonly summarizedDataStoreCount: number;\n /** The number of data stores whose GC reference state was updated in this summary. */\n readonly gcStateUpdatedDataStoreCount?: number;\n /** The size of the gc blobs in this summary. */\n readonly gcTotalBlobsSize?: number;\n /** The number of gc blobs in this summary. */\n readonly gcBlobNodeCount?: number;\n /** The summary number for a container's summary. Incremented on summaries throughout its lifetime. */\n readonly summaryNumber: number;\n}\n\n/** Base results for all submitSummary attempts. */\nexport interface IBaseSummarizeResult {\n readonly stage: \"base\";\n /** Error object related to failed summarize attempt. */\n readonly error: any;\n /** Reference sequence number as of the generate summary attempt. */\n readonly referenceSequenceNumber: number;\n readonly minimumSequenceNumber: number;\n}\n\n/** Results of submitSummary after generating the summary tree. */\nexport interface IGenerateSummaryTreeResult extends Omit<IBaseSummarizeResult, \"stage\"> {\n readonly stage: \"generate\";\n /** Generated summary tree. */\n readonly summaryTree: ISummaryTree;\n /** Stats for generated summary tree. */\n readonly summaryStats: IGeneratedSummaryStats;\n /** Time it took to generate the summary tree and stats. */\n readonly generateDuration: number;\n /** True if the full tree regeneration with no handle reuse optimizations was forced. */\n readonly forcedFullTree: boolean;\n}\n\n/** Results of submitSummary after uploading the tree to storage. */\nexport interface IUploadSummaryResult extends Omit<IGenerateSummaryTreeResult, \"stage\"> {\n readonly stage: \"upload\";\n /** The handle returned by storage pointing to the uploaded summary tree. */\n readonly handle: string;\n /** Time it took to upload the summary tree to storage. */\n readonly uploadDuration: number;\n}\n\n/** Results of submitSummary after submitting the summarize op. */\nexport interface ISubmitSummaryOpResult extends Omit<IUploadSummaryResult, \"stage\" | \"error\"> {\n readonly stage: \"submit\";\n /** The client sequence number of the summarize op submitted for the summary. */\n readonly clientSequenceNumber: number;\n /** Time it took to submit the summarize op to the broadcasting service. */\n readonly 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 */\nexport type SubmitSummaryResult =\n | IBaseSummarizeResult\n | IGenerateSummaryTreeResult\n | IUploadSummaryResult\n | ISubmitSummaryOpResult;\n\nexport interface IBroadcastSummaryResult {\n readonly summarizeOp: ISummaryOpMessage;\n readonly broadcastDuration: number;\n}\n\nexport interface IAckSummaryResult {\n readonly summaryAckOp: ISummaryAckMessage;\n readonly ackNackDuration: number;\n}\n\nexport interface INackSummaryResult {\n readonly summaryNackOp: ISummaryNackMessage;\n readonly ackNackDuration: number;\n}\n\nexport type SummarizeResultPart<TSuccess, TFailure = undefined> = {\n success: true;\n data: TSuccess;\n} | {\n success: false;\n data: TFailure | undefined;\n message: string;\n error: any;\n retryAfterSeconds?: number;\n};\n\nexport interface ISummarizeResults {\n /** Resolves when we generate, upload, and submit the summary. */\n readonly summarySubmitted: Promise<SummarizeResultPart<SubmitSummaryResult>>;\n /** Resolves when we observe our summarize op broadcast. */\n readonly summaryOpBroadcasted: Promise<SummarizeResultPart<IBroadcastSummaryResult>>;\n /** Resolves when we receive a summaryAck or summaryNack. */\n readonly receivedSummaryAckOrNack: Promise<SummarizeResultPart<IAckSummaryResult, INackSummaryResult>>;\n}\n\nexport type EnqueueSummarizeResult = (ISummarizeResults & {\n /**\n * Indicates that another summarize attempt is not already enqueued,\n * and this attempt has been enqueued.\n */\n readonly alreadyEnqueued?: undefined;\n}) | (ISummarizeResults & {\n /** Indicates that another summarize attempt was already enqueued. */\n readonly alreadyEnqueued: true;\n /**\n * Indicates that the other enqueued summarize attempt was abandoned,\n * and this attempt has been enqueued enqueued.\n */\n readonly overridden: true;\n}) | {\n /** Indicates that another summarize attempt was already enqueued. */\n readonly alreadyEnqueued: true;\n /**\n * Indicates that the other enqueued summarize attempt remains enqueued,\n * and this attempt has not been enqueued.\n */\n readonly overridden?: undefined;\n};\n\nexport type SummarizerStopReason =\n /** Summarizer client failed to summarize in all 3 consecutive attempts. */\n | \"failToSummarize\"\n /** Parent client reported that it is no longer connected. */\n | \"parentNotConnected\"\n /**\n * Parent client reported that it is no longer elected the summarizer.\n * This is the normal flow; a disconnect will always trigger the parent\n * client to no longer be elected as responsible for summaries. Then it\n * tries to stop its spawned summarizer client.\n */\n | \"notElectedParent\"\n /**\n * We are not already running the summarizer and we are not the current elected client id.\n */\n | \"notElectedClient\"\n /** Summarizer client was disconnected */\n | \"summarizerClientDisconnected\"\n /* running summarizer threw an exception */\n | \"summarizerException\";\n\nexport interface ISummarizerEvents extends IEvent {\n /**\n * An event indicating that the Summarizer is having problems summarizing\n */\n (event: \"summarizingError\", listener: (error: ISummarizingWarning) => void);\n}\n\nexport interface ISummarizer extends\n IEventProvider<ISummarizerEvents>, IFluidLoadable, Partial<IProvideSummarizer> {\n /*\n * Asks summarizer to move to exit.\n * Summarizer will finish current processes, which may take a while.\n * For example, summarizer may complete last summary before exiting.\n */\n stop(reason: SummarizerStopReason): void;\n\n /* Closes summarizer. Any pending processes (summary in flight) are abandoned. */\n close(): void;\n\n run(onBehalfOf: string, disableHeuristics?: boolean): Promise<SummarizerStopReason>;\n\n /**\n * Attempts to generate a summary on demand. If already running, takes no action.\n * @param options - options controlling the summarize attempt\n * @returns an alreadyRunning promise if a summarize attempt is already in progress,\n * which will resolve when the current attempt completes. At that point caller can\n * decide to try again or not. Otherwise, it will return an object containing promises\n * that resolve as the summarize attempt progresses. They will resolve with success\n * false if a failure is encountered.\n */\n summarizeOnDemand(options: IOnDemandSummarizeOptions): ISummarizeResults;\n /**\n * Enqueue an attempt to summarize after the specified sequence number.\n * If afterSequenceNumber is provided, the summarize attempt is \"enqueued\"\n * to run once an eligible op comes in with sequenceNumber \\>= afterSequenceNumber.\n * @param options - options controlling the summarize attempt\n * @returns an object containing an alreadyEnqueued flag to indicate if another\n * summarize attempt has already been enqueued. It also may contain an overridden flag\n * when alreadyEnqueued is true, that indicates whether this attempt forced the\n * previous attempt to abort. If this attempt becomes enqueued, it returns an object\n * containing promises that resolve as the summarize attempt progresses. They will\n * resolve with success false if a failure is encountered.\n */\n enqueueSummarize(options: IEnqueueSummarizeOptions): EnqueueSummarizeResult;\n}\n\n/** Data about an attempt to summarize used for heuristics. */\nexport interface ISummarizeAttempt {\n /** Reference sequence number when summary was generated or attempted */\n readonly refSequenceNumber: number;\n\n /** Time of summary attempt after it was sent or attempted */\n readonly summaryTime: number;\n\n /** Sequence number of summary op */\n summarySequenceNumber?: number;\n}\n\n/** Data relevant for summary heuristics. */\nexport interface ISummarizeHeuristicData {\n /** Latest received op sequence number */\n lastOpSequenceNumber: number;\n\n /** Most recent summary attempt from this client */\n readonly lastAttempt: ISummarizeAttempt;\n\n /** Most recent summary that received an ack */\n readonly lastSuccessfulSummary: Readonly<ISummarizeAttempt>;\n\n /** Number of runtime ops since last summary */\n numRuntimeOps: number;\n\n /** Number of non-runtime ops since last summary */\n numNonRuntimeOps: number;\n\n /** Cumulative size in bytes of all the ops since the last summary */\n totalOpsSize: number;\n\n /** Wether or not this instance contains adjusted metrics due to missing op data */\n hasMissingOpData: boolean;\n\n /**\n * Updates lastAttempt and lastSuccessfulAttempt based on the last summary.\n * @param lastSummary - last ack summary\n */\n updateWithLastSummaryAckInfo(lastSummary: ISummarizeAttempt): void;\n\n /**\n * Records a summary attempt. If the attempt was successfully sent,\n * provide the reference sequence number, otherwise it will be set\n * to the last seen op sequence number.\n * @param referenceSequenceNumber - reference sequence number of sent summary\n */\n recordAttempt(referenceSequenceNumber?: number): void;\n\n /** Mark that the last sent summary attempt has received an ack */\n markLastAttemptAsSuccessful(): void;\n}\n\n/** Responsible for running heuristics determining when to summarize. */\nexport interface ISummarizeHeuristicRunner {\n /** Start specific heuristic trackers (ex: idle timer) */\n start(): void;\n\n /** Runs the heuristics to determine if it should try to summarize */\n run(): void;\n\n /** Runs a different heuristic to check if it should summarize before closing */\n shouldRunLastSummary(): boolean;\n\n /** Disposes of resources */\n dispose(): void;\n}\n\ntype ISummarizeTelemetryRequiredProperties =\n /** Reason code for attempting to summarize */\n \"reason\";\n\ntype ISummarizeTelemetryOptionalProperties =\n /** Number of attempts within the last time window, used for calculating the throttle delay. */\n \"summaryAttempts\" |\n /** Number of attempts within the current phase (currently capped at 2 ) */\n \"summaryAttemptsPerPhase\" |\n /** One-based count of phases we've attempted (used to index into an array of ISummarizeOptions */\n \"summaryAttemptPhase\" |\n keyof ISummarizeOptions;\n\nexport type ISummarizeTelemetryProperties =\n Pick<ITelemetryProperties, ISummarizeTelemetryRequiredProperties> &\n Partial<Pick<ITelemetryProperties, ISummarizeTelemetryOptionalProperties>>;\n\n/** Strategy used to heuristically determine when we should run a summary */\nexport interface ISummaryHeuristicStrategy {\n /** Summarize reason for this summarize heuristic strategy (ex: \"maxTime\") */\n summarizeReason: Readonly<SummarizeReason>;\n\n /**\n * Determines if this strategy's summarize criteria been met\n * @param configuration - summary configuration we are to check against\n * @param heuristicData - heuristic data used to confirm conditions are met\n */\n shouldRunSummary(configuration: ISummaryConfigurationHeuristics, heuristicData: ISummarizeHeuristicData): boolean;\n}\n\ntype SummaryGeneratorRequiredTelemetryProperties =\n /** True to generate the full tree with no handle reuse optimizations */\n \"fullTree\" |\n /** Time since we last attempted to generate a summary */\n \"timeSinceLastAttempt\" |\n /** Time since we last successfully generated a summary */\n \"timeSinceLastSummary\";\n\ntype SummaryGeneratorOptionalTelemetryProperties =\n /** Reference sequence number as of the generate summary attempt. */\n \"referenceSequenceNumber\" |\n /** minimum sequence number (at the reference sequence number) */\n \"minimumSequenceNumber\" |\n /** Delta between the current reference sequence number and the reference sequence number of the last attempt */\n \"opsSinceLastAttempt\" |\n /** Delta between the current reference sequence number and the reference sequence number of the last summary */\n \"opsSinceLastSummary\" |\n /**\n * Delta in sum of op sizes between the current reference sequence number and the reference\n * sequence number of the last summary\n */\n \"opsSizesSinceLastSummary\" |\n /** Delta between the number of non-runtime ops since the last summary */\n \"nonRuntimeOpsSinceLastSummary\" |\n /** Wether or not this instance contains adjusted metrics due to missing op data */\n \"hasMissingOpData\" |\n /** Time it took to generate the summary tree and stats. */\n \"generateDuration\" |\n /** The handle returned by storage pointing to the uploaded summary tree. */\n \"handle\" |\n /** Time it took to upload the summary tree to storage. */\n \"uploadDuration\" |\n /** The client sequence number of the summarize op submitted for the summary. */\n \"clientSequenceNumber\" |\n /** Time it took for this summary to be acked after it was generated */\n \"ackWaitDuration\" |\n /** Reference sequence number of the ack/nack message */\n \"ackNackSequenceNumber\" |\n /** Actual sequence number of the summary op proposal. */\n \"summarySequenceNumber\" |\n /** Optional Retry-After time in seconds. If specified, the client should wait this many seconds before retrying. */\n \"nackRetryAfter\";\n\nexport type SummaryGeneratorTelemetry =\n Pick<ITelemetryProperties, SummaryGeneratorRequiredTelemetryProperties> &\n Partial<Pick<ITelemetryProperties, SummaryGeneratorOptionalTelemetryProperties>>;\n\nexport interface ISummarizeRunnerTelemetry extends ITelemetryLoggerPropertyBag {\n /** Number of times the summarizer run. */\n summarizeCount: () => number;\n /** Number of successful attempts to summarize. */\n summarizerSuccessfulAttempts: () => number;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"summarizerTypes.js","sourceRoot":"","sources":["../src/summarizerTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAuBH;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAA6B,aAAa,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IEvent,\n IEventProvider,\n ITelemetryLogger,\n ITelemetryProperties,\n} from \"@fluidframework/common-definitions\";\nimport { ITelemetryLoggerPropertyBag } from \"@fluidframework/telemetry-utils\";\nimport {\n IFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\nimport { ContainerWarning, IDeltaManager } from \"@fluidframework/container-definitions\";\nimport {\n ISequencedDocumentMessage,\n ISummaryTree,\n IDocumentMessage,\n} from \"@fluidframework/protocol-definitions\";\nimport { ISummaryStats } from \"@fluidframework/runtime-definitions\";\nimport { ISummaryAckMessage, ISummaryNackMessage, ISummaryOpMessage } from \"./summaryCollection\";\nimport { SummarizeReason } from \"./summaryGenerator\";\nimport { ISummaryConfigurationHeuristics } from \".\";\n\n/**\n * @deprecated This will be removed in a later release.\n */\nexport const ISummarizer: keyof IProvideSummarizer = \"ISummarizer\";\n\n/**\n * @deprecated This will be removed in a later release.\n */\nexport interface IProvideSummarizer {\n /**\n * @deprecated This will be removed in a later release.\n */\n readonly ISummarizer: ISummarizer;\n}\n\n/**\n * Similar to AbortSignal, but using promise instead of events\n * @param T - cancellation reason type\n */\nexport interface ICancellationToken<T> {\n /** Tells if this cancellable token is cancelled */\n readonly cancelled: boolean;\n /**\n * Promise that gets fulfilled when this cancellable token is cancelled\n * @returns reason of cancellation\n */\n readonly waitCancelled: Promise<T>;\n}\n\n/* Similar to AbortSignal, but using promise instead of events */\nexport type ISummaryCancellationToken = ICancellationToken<SummarizerStopReason>;\n\nexport interface ISummarizerInternalsProvider {\n /** Encapsulates the work to walk the internals of the running container to generate a summary */\n submitSummary(options: ISubmitSummaryOptions): Promise<SubmitSummaryResult>;\n\n /** Callback whenever a new SummaryAck is received, to update internal tracking state */\n refreshLatestSummaryAck(options: IRefreshSummaryAckOptions): Promise<void>;\n}\n\n/**\n * @deprecated Options that control the behavior of a running summarizer.\n * */\nexport interface ISummarizerOptions {\n /**\n * Set to true to disable the default heuristics from running; false by default.\n * This affects only the heuristics around when a summarizer should\n * submit summaries. So when it is disabled, summarizer clients should\n * not be expected to summarize unless an on-demand summary is requested.\n */\n disableHeuristics: boolean;\n}\n\nexport interface ISummarizingWarning extends ContainerWarning {\n readonly errorType: \"summarizingError\";\n readonly logged: boolean;\n}\n\nexport interface IConnectableRuntime {\n readonly disposed: boolean;\n readonly connected: boolean;\n readonly clientId: string | undefined;\n readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;\n once(event: \"connected\" | \"disconnected\" | \"dispose\", listener: () => void): this;\n}\n\nexport interface ISummarizerRuntime extends IConnectableRuntime {\n readonly logger: ITelemetryLogger;\n /** clientId of parent (non-summarizing) container that owns summarizer container */\n readonly summarizerClientId: string | undefined;\n disposeFn?(): void;\n closeFn(): void;\n}\n\n/** Options affecting summarize behavior. */\nexport interface ISummarizeOptions {\n /** True to generate the full tree with no handle reuse optimizations; defaults to false */\n readonly fullTree?: boolean;\n /** True to ask the server what the latest summary is first; defaults to false */\n readonly refreshLatestAck?: boolean;\n}\n\n/**\n * Data required to update internal tracking state after receiving a Summary Ack.\n */\n export interface IRefreshSummaryAckOptions {\n /** Handle from the ack's summary op. */\n readonly proposalHandle: string | undefined;\n /** Handle from the summary ack just received */\n readonly ackHandle: string;\n /** Reference sequence number from the ack's summary op */\n readonly summaryRefSeq: number;\n /** Telemetry logger to which telemetry events will be forwarded. */\n readonly summaryLogger: ITelemetryLogger;\n}\n\nexport interface ISubmitSummaryOptions extends ISummarizeOptions {\n /** Logger to use for correlated summary events */\n readonly summaryLogger: ITelemetryLogger;\n /** Tells when summary process should be cancelled */\n readonly cancellationToken: ISummaryCancellationToken;\n}\n\nexport interface IOnDemandSummarizeOptions extends ISummarizeOptions {\n /** Reason for generating summary. */\n readonly reason: string;\n}\n\n/** Options to use when enqueueing a summarize attempt. */\nexport interface IEnqueueSummarizeOptions extends IOnDemandSummarizeOptions {\n /** If specified, The summarize attempt will not occur until after this sequence number. */\n readonly afterSequenceNumber?: number;\n\n /**\n * True to override the existing enqueued summarize attempt if there is one.\n * This will guarantee that this attempt gets enqueued. If override is false,\n * than an existing enqueued summarize attempt will block a new one from being\n * enqueued. There can only be one enqueued at a time. Defaults to false.\n */\n readonly 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 */\nexport interface IGeneratedSummaryStats extends ISummaryStats {\n /** The total number of data stores in the container. */\n readonly dataStoreCount: number;\n /** The number of data stores that were summarized in this summary. */\n readonly summarizedDataStoreCount: number;\n /** The number of data stores whose GC reference state was updated in this summary. */\n readonly gcStateUpdatedDataStoreCount?: number;\n /** The size of the gc blobs in this summary. */\n readonly gcTotalBlobsSize?: number;\n /** The number of gc blobs in this summary. */\n readonly gcBlobNodeCount?: number;\n /** The summary number for a container's summary. Incremented on summaries throughout its lifetime. */\n readonly summaryNumber: number;\n}\n\n/** Base results for all submitSummary attempts. */\nexport interface IBaseSummarizeResult {\n readonly stage: \"base\";\n /** Error object related to failed summarize attempt. */\n readonly error: any;\n /** Reference sequence number as of the generate summary attempt. */\n readonly referenceSequenceNumber: number;\n readonly minimumSequenceNumber: number;\n}\n\n/** Results of submitSummary after generating the summary tree. */\nexport interface IGenerateSummaryTreeResult extends Omit<IBaseSummarizeResult, \"stage\"> {\n readonly stage: \"generate\";\n /** Generated summary tree. */\n readonly summaryTree: ISummaryTree;\n /** Stats for generated summary tree. */\n readonly summaryStats: IGeneratedSummaryStats;\n /** Time it took to generate the summary tree and stats. */\n readonly generateDuration: number;\n /** True if the full tree regeneration with no handle reuse optimizations was forced. */\n readonly forcedFullTree: boolean;\n}\n\n/** Results of submitSummary after uploading the tree to storage. */\nexport interface IUploadSummaryResult extends Omit<IGenerateSummaryTreeResult, \"stage\"> {\n readonly stage: \"upload\";\n /** The handle returned by storage pointing to the uploaded summary tree. */\n readonly handle: string;\n /** Time it took to upload the summary tree to storage. */\n readonly uploadDuration: number;\n}\n\n/** Results of submitSummary after submitting the summarize op. */\nexport interface ISubmitSummaryOpResult extends Omit<IUploadSummaryResult, \"stage\" | \"error\"> {\n readonly stage: \"submit\";\n /** The client sequence number of the summarize op submitted for the summary. */\n readonly clientSequenceNumber: number;\n /** Time it took to submit the summarize op to the broadcasting service. */\n readonly 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 */\nexport type SubmitSummaryResult =\n | IBaseSummarizeResult\n | IGenerateSummaryTreeResult\n | IUploadSummaryResult\n | ISubmitSummaryOpResult;\n\nexport interface IBroadcastSummaryResult {\n readonly summarizeOp: ISummaryOpMessage;\n readonly broadcastDuration: number;\n}\n\nexport interface IAckSummaryResult {\n readonly summaryAckOp: ISummaryAckMessage;\n readonly ackNackDuration: number;\n}\n\nexport interface INackSummaryResult {\n readonly summaryNackOp: ISummaryNackMessage;\n readonly ackNackDuration: number;\n}\n\nexport type SummarizeResultPart<TSuccess, TFailure = undefined> = {\n success: true;\n data: TSuccess;\n} | {\n success: false;\n data: TFailure | undefined;\n message: string;\n error: any;\n retryAfterSeconds?: number;\n};\n\nexport interface ISummarizeResults {\n /** Resolves when we generate, upload, and submit the summary. */\n readonly summarySubmitted: Promise<SummarizeResultPart<SubmitSummaryResult>>;\n /** Resolves when we observe our summarize op broadcast. */\n readonly summaryOpBroadcasted: Promise<SummarizeResultPart<IBroadcastSummaryResult>>;\n /** Resolves when we receive a summaryAck or summaryNack. */\n readonly receivedSummaryAckOrNack: Promise<SummarizeResultPart<IAckSummaryResult, INackSummaryResult>>;\n}\n\nexport type EnqueueSummarizeResult = (ISummarizeResults & {\n /**\n * Indicates that another summarize attempt is not already enqueued,\n * and this attempt has been enqueued.\n */\n readonly alreadyEnqueued?: undefined;\n}) | (ISummarizeResults & {\n /** Indicates that another summarize attempt was already enqueued. */\n readonly alreadyEnqueued: true;\n /**\n * Indicates that the other enqueued summarize attempt was abandoned,\n * and this attempt has been enqueued enqueued.\n */\n readonly overridden: true;\n}) | {\n /** Indicates that another summarize attempt was already enqueued. */\n readonly alreadyEnqueued: true;\n /**\n * Indicates that the other enqueued summarize attempt remains enqueued,\n * and this attempt has not been enqueued.\n */\n readonly overridden?: undefined;\n};\n\nexport type SummarizerStopReason =\n /** Summarizer client failed to summarize in all 3 consecutive attempts. */\n | \"failToSummarize\"\n /** Parent client reported that it is no longer connected. */\n | \"parentNotConnected\"\n /**\n * Parent client reported that it is no longer elected the summarizer.\n * This is the normal flow; a disconnect will always trigger the parent\n * client to no longer be elected as responsible for summaries. Then it\n * tries to stop its spawned summarizer client.\n */\n | \"notElectedParent\"\n /**\n * We are not already running the summarizer and we are not the current elected client id.\n */\n | \"notElectedClient\"\n /** Summarizer client was disconnected */\n | \"summarizerClientDisconnected\"\n /* running summarizer threw an exception */\n | \"summarizerException\";\n\nexport interface ISummarizerEvents extends IEvent {\n /**\n * An event indicating that the Summarizer is having problems summarizing\n */\n (event: \"summarizingError\", listener: (error: ISummarizingWarning) => void);\n}\n\nexport interface ISummarizer extends\n IEventProvider<ISummarizerEvents>, IFluidLoadable, Partial<IProvideSummarizer> {\n /*\n * Asks summarizer to move to exit.\n * Summarizer will finish current processes, which may take a while.\n * For example, summarizer may complete last summary before exiting.\n */\n stop(reason: SummarizerStopReason): void;\n\n /* Closes summarizer. Any pending processes (summary in flight) are abandoned. */\n close(): void;\n\n run(onBehalfOf: string, disableHeuristics?: boolean): Promise<SummarizerStopReason>;\n\n /**\n * Attempts to generate a summary on demand. If already running, takes no action.\n * @param options - options controlling the summarize attempt\n * @returns an alreadyRunning promise if a summarize attempt is already in progress,\n * which will resolve when the current attempt completes. At that point caller can\n * decide to try again or not. Otherwise, it will return an object containing promises\n * that resolve as the summarize attempt progresses. They will resolve with success\n * false if a failure is encountered.\n */\n summarizeOnDemand(options: IOnDemandSummarizeOptions): ISummarizeResults;\n /**\n * Enqueue an attempt to summarize after the specified sequence number.\n * If afterSequenceNumber is provided, the summarize attempt is \"enqueued\"\n * to run once an eligible op comes in with sequenceNumber \\>= afterSequenceNumber.\n * @param options - options controlling the summarize attempt\n * @returns an object containing an alreadyEnqueued flag to indicate if another\n * summarize attempt has already been enqueued. It also may contain an overridden flag\n * when alreadyEnqueued is true, that indicates whether this attempt forced the\n * previous attempt to abort. If this attempt becomes enqueued, it returns an object\n * containing promises that resolve as the summarize attempt progresses. They will\n * resolve with success false if a failure is encountered.\n */\n enqueueSummarize(options: IEnqueueSummarizeOptions): EnqueueSummarizeResult;\n}\n\n/** Data about an attempt to summarize used for heuristics. */\nexport interface ISummarizeAttempt {\n /** Reference sequence number when summary was generated or attempted */\n readonly refSequenceNumber: number;\n\n /** Time of summary attempt after it was sent or attempted */\n readonly summaryTime: number;\n\n /** Sequence number of summary op */\n summarySequenceNumber?: number;\n}\n\n/** Data relevant for summary heuristics. */\nexport interface ISummarizeHeuristicData {\n /** Latest received op sequence number */\n lastOpSequenceNumber: number;\n\n /** Most recent summary attempt from this client */\n readonly lastAttempt: ISummarizeAttempt;\n\n /** Most recent summary that received an ack */\n readonly lastSuccessfulSummary: Readonly<ISummarizeAttempt>;\n\n /** Number of runtime ops since last summary */\n numRuntimeOps: number;\n\n /** Number of non-runtime ops since last summary */\n numNonRuntimeOps: number;\n\n /** Cumulative size in bytes of all the ops since the last summary */\n totalOpsSize: number;\n\n /** Wether or not this instance contains adjusted metrics due to missing op data */\n hasMissingOpData: boolean;\n\n /**\n * Updates lastAttempt and lastSuccessfulAttempt based on the last summary.\n * @param lastSummary - last ack summary\n */\n updateWithLastSummaryAckInfo(lastSummary: ISummarizeAttempt): void;\n\n /**\n * Records a summary attempt. If the attempt was successfully sent,\n * provide the reference sequence number, otherwise it will be set\n * to the last seen op sequence number.\n * @param referenceSequenceNumber - reference sequence number of sent summary\n */\n recordAttempt(referenceSequenceNumber?: number): void;\n\n /** Mark that the last sent summary attempt has received an ack */\n markLastAttemptAsSuccessful(): void;\n}\n\n/** Responsible for running heuristics determining when to summarize. */\nexport interface ISummarizeHeuristicRunner {\n /** Start specific heuristic trackers (ex: idle timer) */\n start(): void;\n\n /** Runs the heuristics to determine if it should try to summarize */\n run(): void;\n\n /** Runs a different heuristic to check if it should summarize before closing */\n shouldRunLastSummary(): boolean;\n\n /** Disposes of resources */\n dispose(): void;\n}\n\ntype ISummarizeTelemetryRequiredProperties =\n /** Reason code for attempting to summarize */\n \"reason\";\n\ntype ISummarizeTelemetryOptionalProperties =\n /** Number of attempts within the last time window, used for calculating the throttle delay. */\n \"summaryAttempts\" |\n /** Number of attempts within the current phase (currently capped at 2 ) */\n \"summaryAttemptsPerPhase\" |\n /** One-based count of phases we've attempted (used to index into an array of ISummarizeOptions */\n \"summaryAttemptPhase\" |\n keyof ISummarizeOptions;\n\nexport type ISummarizeTelemetryProperties =\n Pick<ITelemetryProperties, ISummarizeTelemetryRequiredProperties> &\n Partial<Pick<ITelemetryProperties, ISummarizeTelemetryOptionalProperties>>;\n\n/** Strategy used to heuristically determine when we should run a summary */\nexport interface ISummaryHeuristicStrategy {\n /** Summarize reason for this summarize heuristic strategy (ex: \"maxTime\") */\n summarizeReason: Readonly<SummarizeReason>;\n\n /**\n * Determines if this strategy's summarize criteria been met\n * @param configuration - summary configuration we are to check against\n * @param heuristicData - heuristic data used to confirm conditions are met\n */\n shouldRunSummary(configuration: ISummaryConfigurationHeuristics, heuristicData: ISummarizeHeuristicData): boolean;\n}\n\ntype SummaryGeneratorRequiredTelemetryProperties =\n /** True to generate the full tree with no handle reuse optimizations */\n \"fullTree\" |\n /** Time since we last attempted to generate a summary */\n \"timeSinceLastAttempt\" |\n /** Time since we last successfully generated a summary */\n \"timeSinceLastSummary\";\n\ntype SummaryGeneratorOptionalTelemetryProperties =\n /** Reference sequence number as of the generate summary attempt. */\n \"referenceSequenceNumber\" |\n /** minimum sequence number (at the reference sequence number) */\n \"minimumSequenceNumber\" |\n /** Delta between the current reference sequence number and the reference sequence number of the last attempt */\n \"opsSinceLastAttempt\" |\n /** Delta between the current reference sequence number and the reference sequence number of the last summary */\n \"opsSinceLastSummary\" |\n /**\n * Delta in sum of op sizes between the current reference sequence number and the reference\n * sequence number of the last summary\n */\n \"opsSizesSinceLastSummary\" |\n /** Delta between the number of non-runtime ops since the last summary */\n \"nonRuntimeOpsSinceLastSummary\" |\n /** Wether or not this instance contains adjusted metrics due to missing op data */\n \"hasMissingOpData\" |\n /** Time it took to generate the summary tree and stats. */\n \"generateDuration\" |\n /** The handle returned by storage pointing to the uploaded summary tree. */\n \"handle\" |\n /** Time it took to upload the summary tree to storage. */\n \"uploadDuration\" |\n /** The client sequence number of the summarize op submitted for the summary. */\n \"clientSequenceNumber\" |\n /** Time it took for this summary to be acked after it was generated */\n \"ackWaitDuration\" |\n /** Reference sequence number of the ack/nack message */\n \"ackNackSequenceNumber\" |\n /** Actual sequence number of the summary op proposal. */\n \"summarySequenceNumber\" |\n /** Optional Retry-After time in seconds. If specified, the client should wait this many seconds before retrying. */\n \"nackRetryAfter\";\n\nexport type SummaryGeneratorTelemetry =\n Pick<ITelemetryProperties, SummaryGeneratorRequiredTelemetryProperties> &\n Partial<Pick<ITelemetryProperties, SummaryGeneratorOptionalTelemetryProperties>>;\n\nexport interface ISummarizeRunnerTelemetry extends ITelemetryLoggerPropertyBag {\n /** Number of times the summarizer run. */\n summarizeCount: () => number;\n /** Number of successful attempts to summarize. */\n summarizerSuccessfulAttempts: () => number;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/container-runtime",
|
|
3
|
-
"version": "2.0.0-internal.
|
|
3
|
+
"version": "2.0.0-internal.3.0.1",
|
|
4
4
|
"description": "Fluid container runtime",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -65,19 +65,19 @@
|
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
67
67
|
"@fluidframework/common-utils": "^1.0.0",
|
|
68
|
-
"@fluidframework/container-definitions": ">=2.0.0-internal.
|
|
69
|
-
"@fluidframework/container-runtime-definitions": ">=2.0.0-internal.
|
|
70
|
-
"@fluidframework/container-utils": ">=2.0.0-internal.
|
|
71
|
-
"@fluidframework/core-interfaces": ">=2.0.0-internal.
|
|
72
|
-
"@fluidframework/datastore": ">=2.0.0-internal.
|
|
73
|
-
"@fluidframework/driver-definitions": ">=2.0.0-internal.
|
|
74
|
-
"@fluidframework/driver-utils": ">=2.0.0-internal.
|
|
75
|
-
"@fluidframework/garbage-collector": ">=2.0.0-internal.
|
|
68
|
+
"@fluidframework/container-definitions": ">=2.0.0-internal.3.0.1 <2.0.0-internal.4.0.0",
|
|
69
|
+
"@fluidframework/container-runtime-definitions": ">=2.0.0-internal.3.0.1 <2.0.0-internal.4.0.0",
|
|
70
|
+
"@fluidframework/container-utils": ">=2.0.0-internal.3.0.1 <2.0.0-internal.4.0.0",
|
|
71
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.3.0.1 <2.0.0-internal.4.0.0",
|
|
72
|
+
"@fluidframework/datastore": ">=2.0.0-internal.3.0.1 <2.0.0-internal.4.0.0",
|
|
73
|
+
"@fluidframework/driver-definitions": ">=2.0.0-internal.3.0.1 <2.0.0-internal.4.0.0",
|
|
74
|
+
"@fluidframework/driver-utils": ">=2.0.0-internal.3.0.1 <2.0.0-internal.4.0.0",
|
|
75
|
+
"@fluidframework/garbage-collector": ">=2.0.0-internal.3.0.1 <2.0.0-internal.4.0.0",
|
|
76
76
|
"@fluidframework/protocol-base": "^0.1038.2000",
|
|
77
77
|
"@fluidframework/protocol-definitions": "^1.1.0",
|
|
78
|
-
"@fluidframework/runtime-definitions": ">=2.0.0-internal.
|
|
79
|
-
"@fluidframework/runtime-utils": ">=2.0.0-internal.
|
|
80
|
-
"@fluidframework/telemetry-utils": ">=2.0.0-internal.
|
|
78
|
+
"@fluidframework/runtime-definitions": ">=2.0.0-internal.3.0.1 <2.0.0-internal.4.0.0",
|
|
79
|
+
"@fluidframework/runtime-utils": ">=2.0.0-internal.3.0.1 <2.0.0-internal.4.0.0",
|
|
80
|
+
"@fluidframework/telemetry-utils": ">=2.0.0-internal.3.0.1 <2.0.0-internal.4.0.0",
|
|
81
81
|
"double-ended-queue": "^2.1.0-0",
|
|
82
82
|
"events": "^3.1.0",
|
|
83
83
|
"lz4js": "^0.2.0",
|
|
@@ -89,8 +89,8 @@
|
|
|
89
89
|
"@fluidframework/build-tools": "^0.8.0",
|
|
90
90
|
"@fluidframework/container-runtime-previous": "npm:@fluidframework/container-runtime@2.0.0-internal.2.2.0",
|
|
91
91
|
"@fluidframework/eslint-config-fluid": "^2.0.0",
|
|
92
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.
|
|
93
|
-
"@fluidframework/test-runtime-utils": ">=2.0.0-internal.
|
|
92
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.3.0.1 <2.0.0-internal.4.0.0",
|
|
93
|
+
"@fluidframework/test-runtime-utils": ">=2.0.0-internal.3.0.1 <2.0.0-internal.4.0.0",
|
|
94
94
|
"@microsoft/api-extractor": "^7.22.2",
|
|
95
95
|
"@rushstack/eslint-config": "^2.5.1",
|
|
96
96
|
"@types/double-ended-queue": "^2.1.0",
|
|
@@ -109,8 +109,8 @@
|
|
|
109
109
|
"typescript": "~4.5.5"
|
|
110
110
|
},
|
|
111
111
|
"typeValidation": {
|
|
112
|
-
"version": "2.0.0-internal.
|
|
113
|
-
"baselineRange": ">=2.0.0-internal.2.
|
|
112
|
+
"version": "2.0.0-internal.3.0.0",
|
|
113
|
+
"baselineRange": ">=2.0.0-internal.2.0.0 <2.0.0-internal.3.0.0",
|
|
114
114
|
"baselineVersion": "2.0.0-internal.2.2.0",
|
|
115
115
|
"broken": {
|
|
116
116
|
"RemovedVariableDeclaration_gcBlobPrefix": {
|
|
@@ -125,8 +125,26 @@
|
|
|
125
125
|
"forwardCompat": false,
|
|
126
126
|
"backCompat": false
|
|
127
127
|
},
|
|
128
|
+
"VariableDeclaration_DefaultSummaryConfiguration": {
|
|
129
|
+
"backCompat": false
|
|
130
|
+
},
|
|
131
|
+
"InterfaceDeclaration_ISummaryBaseConfiguration": {
|
|
132
|
+
"backCompat": false
|
|
133
|
+
},
|
|
134
|
+
"TypeAliasDeclaration_ISummaryConfiguration": {
|
|
135
|
+
"backCompat": false
|
|
136
|
+
},
|
|
137
|
+
"InterfaceDeclaration_ISummaryConfigurationDisableHeuristics": {
|
|
138
|
+
"backCompat": false
|
|
139
|
+
},
|
|
140
|
+
"InterfaceDeclaration_ISummaryConfigurationHeuristics": {
|
|
141
|
+
"backCompat": false
|
|
142
|
+
},
|
|
128
143
|
"ClassDeclaration_ContainerRuntime": {
|
|
129
144
|
"forwardCompat": false
|
|
145
|
+
},
|
|
146
|
+
"InterfaceDeclaration_ISummarizerRuntime": {
|
|
147
|
+
"backCompat": false
|
|
130
148
|
}
|
|
131
149
|
}
|
|
132
150
|
}
|
package/src/containerRuntime.ts
CHANGED
|
@@ -143,7 +143,6 @@ import {
|
|
|
143
143
|
ISubmitSummaryOptions,
|
|
144
144
|
ISummarizer,
|
|
145
145
|
ISummarizerInternalsProvider,
|
|
146
|
-
ISummarizerOptions,
|
|
147
146
|
ISummarizerRuntime,
|
|
148
147
|
IRefreshSummaryAckOptions,
|
|
149
148
|
} from "./summarizerTypes";
|
|
@@ -205,13 +204,6 @@ export interface ISummaryBaseConfiguration {
|
|
|
205
204
|
*/
|
|
206
205
|
initialSummarizerDelayMs: number;
|
|
207
206
|
|
|
208
|
-
/**
|
|
209
|
-
* @deprecated
|
|
210
|
-
* Flag that will enable changing elected summarizer client after maxOpsSinceLastSummary.
|
|
211
|
-
* This defaults to false (disabled) and must be explicitly set to true to enable.
|
|
212
|
-
*/
|
|
213
|
-
summarizerClientElection: boolean;
|
|
214
|
-
|
|
215
207
|
/**
|
|
216
208
|
* Defines the maximum allowed time to wait for a pending summary ack.
|
|
217
209
|
* The maximum amount of time client will wait for a summarize is the minimum of
|
|
@@ -317,8 +309,6 @@ export const DefaultSummaryConfiguration: ISummaryConfiguration = {
|
|
|
317
309
|
|
|
318
310
|
initialSummarizerDelayMs: 5 * 1000, // 5 secs.
|
|
319
311
|
|
|
320
|
-
summarizerClientElection: false,
|
|
321
|
-
|
|
322
312
|
nonRuntimeOpWeight: 0.1,
|
|
323
313
|
|
|
324
314
|
runtimeOpWeight: 1.0,
|
|
@@ -386,40 +376,6 @@ export interface ISummaryRuntimeOptions {
|
|
|
386
376
|
* {@link ISummaryBaseConfiguration.initialSummarizerDelayMs} instead.
|
|
387
377
|
*/
|
|
388
378
|
initialSummarizerDelayMs?: number;
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* Flag that disables summaries if it is set to true.
|
|
392
|
-
*
|
|
393
|
-
* @deprecated Use {@link ISummaryRuntimeOptions.summaryConfigOverrides}'s
|
|
394
|
-
* {@link ISummaryConfigurationDisableSummarizer.state} instead.
|
|
395
|
-
*/
|
|
396
|
-
disableSummaries?: boolean;
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* @defaultValue 7000 operations (ops)
|
|
400
|
-
*
|
|
401
|
-
* @deprecated Use {@link ISummaryRuntimeOptions.summaryConfigOverrides}'s
|
|
402
|
-
* {@link ISummaryBaseConfiguration.maxOpsSinceLastSummary} instead.
|
|
403
|
-
*/
|
|
404
|
-
maxOpsSinceLastSummary?: number;
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* Flag that will enable changing elected summarizer client after maxOpsSinceLastSummary.
|
|
408
|
-
*
|
|
409
|
-
* @defaultValue `false` (disabled) and must be explicitly set to true to enable.
|
|
410
|
-
*
|
|
411
|
-
* @deprecated Use {@link ISummaryRuntimeOptions.summaryConfigOverrides}'s
|
|
412
|
-
* {@link ISummaryBaseConfiguration.summarizerClientElection} instead.
|
|
413
|
-
*/
|
|
414
|
-
summarizerClientElection?: boolean;
|
|
415
|
-
|
|
416
|
-
/**
|
|
417
|
-
* Options that control the running summarizer behavior.
|
|
418
|
-
*
|
|
419
|
-
* @deprecated Use {@link ISummaryRuntimeOptions.summaryConfigOverrides}'s
|
|
420
|
-
* `{@link ISummaryConfiguration.state} = "DisableHeuristics"` instead.
|
|
421
|
-
* */
|
|
422
|
-
summarizerOptions?: Readonly<Partial<ISummarizerOptions>>;
|
|
423
379
|
}
|
|
424
380
|
|
|
425
381
|
/**
|
|
@@ -491,9 +447,10 @@ export interface IContainerRuntimeOptions {
|
|
|
491
447
|
*/
|
|
492
448
|
readonly chunkSizeInBytes?: number;
|
|
493
449
|
/**
|
|
494
|
-
* If enabled, the runtime will block all attempts to send an op
|
|
495
|
-
*
|
|
496
|
-
*
|
|
450
|
+
* If enabled, the runtime will block all attempts to send an op inside the
|
|
451
|
+
* {@link ContainerRuntime#ensureNoDataModelChanges} callback. The callback is used by
|
|
452
|
+
* {@link @fluidframework/shared-object-base#SharedObjectCore} for event handlers so enabling this
|
|
453
|
+
* will disallow modifying DDSes while handling DDS events.
|
|
497
454
|
*
|
|
498
455
|
* By default, the feature is disabled. If enabled from options, the `Fluid.ContainerRuntime.DisableOpReentryCheck`
|
|
499
456
|
* can be used to disable it at runtime.
|
|
@@ -663,6 +620,7 @@ export class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>
|
|
|
663
620
|
public get IFluidRouter() { return this; }
|
|
664
621
|
|
|
665
622
|
/**
|
|
623
|
+
* @deprecated - use loadRuntime instead.
|
|
666
624
|
* Load the stores from a snapshot and returns the runtime.
|
|
667
625
|
* @param context - Context of the container.
|
|
668
626
|
* @param registryEntries - Mapping to the stores.
|
|
@@ -681,6 +639,54 @@ export class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>
|
|
|
681
639
|
existing?: boolean,
|
|
682
640
|
containerRuntimeCtor: typeof ContainerRuntime = ContainerRuntime
|
|
683
641
|
): Promise<ContainerRuntime> {
|
|
642
|
+
let existingFlag = true;
|
|
643
|
+
if (!existing) {
|
|
644
|
+
existingFlag = false;
|
|
645
|
+
}
|
|
646
|
+
return this.loadRuntime({
|
|
647
|
+
context,
|
|
648
|
+
registryEntries,
|
|
649
|
+
existing: existingFlag,
|
|
650
|
+
requestHandler,
|
|
651
|
+
runtimeOptions,
|
|
652
|
+
containerScope,
|
|
653
|
+
containerRuntimeCtor,
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* Load the stores from a snapshot and returns the runtime.
|
|
659
|
+
* @param params - An object housing the runtime properties:
|
|
660
|
+
* - context - Context of the container.
|
|
661
|
+
* - registryEntries - Mapping to the stores.
|
|
662
|
+
* - existing - When loading from an existing snapshot
|
|
663
|
+
* - requestHandler - Request handlers for the container runtime
|
|
664
|
+
* - runtimeOptions - Additional options to be passed to the runtime
|
|
665
|
+
* - containerScope - runtime services provided with context
|
|
666
|
+
* - containerRuntimeCtor - Constructor to use to create the ContainerRuntime instance.
|
|
667
|
+
* This allows mixin classes to leverage this method to define their own async initializer.
|
|
668
|
+
*/
|
|
669
|
+
public static async loadRuntime(
|
|
670
|
+
params: {
|
|
671
|
+
context: IContainerContext;
|
|
672
|
+
registryEntries: NamedFluidDataStoreRegistryEntries;
|
|
673
|
+
existing: boolean;
|
|
674
|
+
requestHandler?: (request: IRequest, runtime: IContainerRuntime) => Promise<IResponse>;
|
|
675
|
+
runtimeOptions?: IContainerRuntimeOptions;
|
|
676
|
+
containerScope?: FluidObject;
|
|
677
|
+
containerRuntimeCtor?: typeof ContainerRuntime;
|
|
678
|
+
},
|
|
679
|
+
): Promise<ContainerRuntime> {
|
|
680
|
+
const {
|
|
681
|
+
context,
|
|
682
|
+
registryEntries,
|
|
683
|
+
existing,
|
|
684
|
+
requestHandler,
|
|
685
|
+
runtimeOptions = {},
|
|
686
|
+
containerScope = {},
|
|
687
|
+
containerRuntimeCtor = ContainerRuntime
|
|
688
|
+
} = params;
|
|
689
|
+
|
|
684
690
|
// If taggedLogger exists, use it. Otherwise, wrap the vanilla logger:
|
|
685
691
|
// back-compat: Remove the TaggedLoggerAdapter fallback once all the host are using loader > 0.45
|
|
686
692
|
const backCompatContext: IContainerContext | OldContainerContextWithLogger = context;
|
|
@@ -905,6 +911,33 @@ export class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>
|
|
|
905
911
|
*/
|
|
906
912
|
private delayConnectClientId?: string;
|
|
907
913
|
|
|
914
|
+
private ensureNoDataModelChangesCalls = 0;
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Tracks the number of detected reentrant ops to report,
|
|
918
|
+
* in order to self-throttle the telemetry events.
|
|
919
|
+
*
|
|
920
|
+
* This should be removed as part of ADO:2322
|
|
921
|
+
*/
|
|
922
|
+
private opReentryCallsToReport = 5;
|
|
923
|
+
|
|
924
|
+
/**
|
|
925
|
+
* Invokes the given callback and expects that no ops are submitted
|
|
926
|
+
* until execution finishes. If an op is submitted, an error will be raised.
|
|
927
|
+
*
|
|
928
|
+
* Can be disabled by feature gate `Fluid.ContainerRuntime.DisableOpReentryCheck`
|
|
929
|
+
*
|
|
930
|
+
* @param callback - the callback to be invoked
|
|
931
|
+
*/
|
|
932
|
+
public ensureNoDataModelChanges<T>(callback: () => T): T {
|
|
933
|
+
this.ensureNoDataModelChangesCalls++;
|
|
934
|
+
try {
|
|
935
|
+
return callback();
|
|
936
|
+
} finally {
|
|
937
|
+
this.ensureNoDataModelChangesCalls--;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
|
|
908
941
|
public get connected(): boolean {
|
|
909
942
|
return this._connected;
|
|
910
943
|
}
|
|
@@ -955,45 +988,16 @@ export class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>
|
|
|
955
988
|
|
|
956
989
|
private readonly summariesDisabled: boolean;
|
|
957
990
|
private isSummariesDisabled(): boolean {
|
|
958
|
-
// back-compat: disableSummaries was moved from ISummaryRuntimeOptions
|
|
959
|
-
// to ISummaryConfiguration in 0.60.
|
|
960
|
-
if (this.runtimeOptions.summaryOptions.disableSummaries === true) {
|
|
961
|
-
return true;
|
|
962
|
-
}
|
|
963
991
|
return this.summaryConfiguration.state === "disabled";
|
|
964
992
|
}
|
|
965
993
|
|
|
966
994
|
private readonly heuristicsDisabled: boolean;
|
|
967
995
|
private isHeuristicsDisabled(): boolean {
|
|
968
|
-
// back-compat: disableHeuristics was moved from ISummarizerOptions
|
|
969
|
-
// to ISummaryConfiguration in 0.60.
|
|
970
|
-
if (this.runtimeOptions.summaryOptions.summarizerOptions?.disableHeuristics === true) {
|
|
971
|
-
return true;
|
|
972
|
-
}
|
|
973
996
|
return this.summaryConfiguration.state === "disableHeuristics";
|
|
974
997
|
}
|
|
975
998
|
|
|
976
|
-
private readonly summarizerClientElectionEnabled: boolean;
|
|
977
|
-
private isSummarizerClientElectionEnabled(): boolean {
|
|
978
|
-
if (this.mc.config.getBoolean("Fluid.ContainerRuntime.summarizerClientElection")) {
|
|
979
|
-
return this.mc.config.getBoolean("Fluid.ContainerRuntime.summarizerClientElection") ?? true;
|
|
980
|
-
}
|
|
981
|
-
// back-compat: summarizerClientElection was moved from ISummaryRuntimeOptions
|
|
982
|
-
// to ISummaryConfiguration in 0.60.
|
|
983
|
-
if (this.runtimeOptions.summaryOptions.summarizerClientElection === true) {
|
|
984
|
-
return true;
|
|
985
|
-
}
|
|
986
|
-
return this.summaryConfiguration.state !== "disabled"
|
|
987
|
-
? this.summaryConfiguration.summarizerClientElection === true
|
|
988
|
-
: false;
|
|
989
|
-
}
|
|
990
999
|
private readonly maxOpsSinceLastSummary: number;
|
|
991
1000
|
private getMaxOpsSinceLastSummary(): number {
|
|
992
|
-
// back-compat: maxOpsSinceLastSummary was moved from ISummaryRuntimeOptions
|
|
993
|
-
// to ISummaryConfiguration in 0.60.
|
|
994
|
-
if (this.runtimeOptions.summaryOptions.maxOpsSinceLastSummary !== undefined) {
|
|
995
|
-
return this.runtimeOptions.summaryOptions.maxOpsSinceLastSummary;
|
|
996
|
-
}
|
|
997
1001
|
return this.summaryConfiguration.state !== "disabled"
|
|
998
1002
|
? this.summaryConfiguration.maxOpsSinceLastSummary
|
|
999
1003
|
: 0;
|
|
@@ -1091,7 +1095,6 @@ export class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>
|
|
|
1091
1095
|
|
|
1092
1096
|
this.summariesDisabled = this.isSummariesDisabled();
|
|
1093
1097
|
this.heuristicsDisabled = this.isHeuristicsDisabled();
|
|
1094
|
-
this.summarizerClientElectionEnabled = this.isSummarizerClientElectionEnabled();
|
|
1095
1098
|
this.maxOpsSinceLastSummary = this.getMaxOpsSinceLastSummary();
|
|
1096
1099
|
this.initialSummarizerDelayMs = this.getInitialSummarizerDelayMs();
|
|
1097
1100
|
|
|
@@ -1214,7 +1217,6 @@ export class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>
|
|
|
1214
1217
|
clientId: () => this.clientId,
|
|
1215
1218
|
close: this.closeFn,
|
|
1216
1219
|
connected: () => this.connected,
|
|
1217
|
-
flush: this.flush.bind(this),
|
|
1218
1220
|
reSubmit: this.reSubmit.bind(this),
|
|
1219
1221
|
rollback: this.rollback.bind(this),
|
|
1220
1222
|
orderSequentially: this.orderSequentially.bind(this),
|
|
@@ -1273,7 +1275,6 @@ export class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>
|
|
|
1273
1275
|
this.summaryCollection,
|
|
1274
1276
|
orderedClientElectionForSummarizer,
|
|
1275
1277
|
this.maxOpsSinceLastSummary,
|
|
1276
|
-
this.summarizerClientElectionEnabled,
|
|
1277
1278
|
);
|
|
1278
1279
|
|
|
1279
1280
|
if (this.context.clientDetails.type === summarizerClientType) {
|
|
@@ -1946,7 +1947,8 @@ export class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>
|
|
|
1946
1947
|
this._orderSequentiallyCalls--;
|
|
1947
1948
|
}
|
|
1948
1949
|
|
|
1949
|
-
|
|
1950
|
+
// We don't flush on TurnBased since we expect all messages in the same JS turn to be part of the same batch
|
|
1951
|
+
if (this.flushMode !== FlushMode.TurnBased && this._orderSequentiallyCalls === 0) {
|
|
1950
1952
|
this.flush();
|
|
1951
1953
|
}
|
|
1952
1954
|
return result;
|
|
@@ -2631,6 +2633,7 @@ export class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>
|
|
|
2631
2633
|
metadata: Record<string, unknown> | undefined = undefined,
|
|
2632
2634
|
): void {
|
|
2633
2635
|
this.verifyNotClosed();
|
|
2636
|
+
this.verifyCanSubmitOps();
|
|
2634
2637
|
|
|
2635
2638
|
// There should be no ops in detached container state!
|
|
2636
2639
|
assert(this.attachState !== AttachState.Detached, 0x132 /* "sending ops in detached container" */);
|
|
@@ -2724,6 +2727,36 @@ export class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>
|
|
|
2724
2727
|
}
|
|
2725
2728
|
}
|
|
2726
2729
|
|
|
2730
|
+
private verifyCanSubmitOps() {
|
|
2731
|
+
if (this.ensureNoDataModelChangesCalls > 0) {
|
|
2732
|
+
const errorMessage = "Op was submitted from within a `ensureNoDataModelChanges` callback";
|
|
2733
|
+
if (this.opReentryCallsToReport > 0) {
|
|
2734
|
+
this.mc.logger.sendTelemetryEvent(
|
|
2735
|
+
{ eventName: "OpReentry" },
|
|
2736
|
+
// We need to capture the call stack in order to inspect the source of this usage pattern
|
|
2737
|
+
new UsageError(errorMessage),
|
|
2738
|
+
);
|
|
2739
|
+
this.opReentryCallsToReport--;
|
|
2740
|
+
}
|
|
2741
|
+
|
|
2742
|
+
// Creating ops while processing ops can lead
|
|
2743
|
+
// to undefined behavior and events observed in the wrong order.
|
|
2744
|
+
// For example, we have two callbacks registered for a DDS, A and B.
|
|
2745
|
+
// Then if on change #1 callback A creates change #2, the invocation flow will be:
|
|
2746
|
+
//
|
|
2747
|
+
// A because of #1
|
|
2748
|
+
// A because of #2
|
|
2749
|
+
// B because of #2
|
|
2750
|
+
// B because of #1
|
|
2751
|
+
//
|
|
2752
|
+
// The runtime must enforce op coherence by not allowing ops to be submitted
|
|
2753
|
+
// while ops are being processed.
|
|
2754
|
+
if (this.enableOpReentryCheck) {
|
|
2755
|
+
throw new UsageError(errorMessage);
|
|
2756
|
+
}
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
|
|
2727
2760
|
/**
|
|
2728
2761
|
* Finds the right store and asks it to resubmit the message. This typically happens when we
|
|
2729
2762
|
* reconnect and there are pending messages.
|
|
@@ -2959,15 +2992,14 @@ export class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>
|
|
|
2959
2992
|
throw new UsageError("can't get state when offline load disabled");
|
|
2960
2993
|
}
|
|
2961
2994
|
|
|
2995
|
+
if (this._orderSequentiallyCalls !== 0) {
|
|
2996
|
+
throw new UsageError("can't get state during orderSequentially");
|
|
2997
|
+
}
|
|
2962
2998
|
// Flush pending batch.
|
|
2963
2999
|
// getPendingLocalState() is only exposed through Container.closeAndGetPendingLocalState(), so it's safe
|
|
2964
3000
|
// to close current batch.
|
|
2965
3001
|
this.flush();
|
|
2966
3002
|
|
|
2967
|
-
if (this._orderSequentiallyCalls !== 0) {
|
|
2968
|
-
throw new UsageError("can't get state during orderSequentially");
|
|
2969
|
-
}
|
|
2970
|
-
|
|
2971
3003
|
const previousPendingState = this.context.pendingLocalState as IPendingRuntimeState | undefined;
|
|
2972
3004
|
if (previousPendingState) {
|
|
2973
3005
|
return {
|