@fluidframework/runtime-utils 2.0.0-internal.3.0.2 → 2.0.0-internal.3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +5 -7
- package/.mocharc.js +2 -2
- package/api-extractor.json +2 -2
- package/dist/dataStoreHandleContextUtils.d.ts.map +1 -1
- package/dist/dataStoreHandleContextUtils.js +3 -1
- package/dist/dataStoreHandleContextUtils.js.map +1 -1
- package/dist/dataStoreHelpers.d.ts.map +1 -1
- package/dist/dataStoreHelpers.js +23 -7
- package/dist/dataStoreHelpers.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/objectstoragepartition.d.ts.map +1 -1
- package/dist/objectstoragepartition.js.map +1 -1
- package/dist/objectstorageutils.d.ts.map +1 -1
- package/dist/objectstorageutils.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/requestParser.d.ts.map +1 -1
- package/dist/requestParser.js.map +1 -1
- package/dist/runtimeFactoryHelper.d.ts.map +1 -1
- package/dist/runtimeFactoryHelper.js +6 -2
- package/dist/runtimeFactoryHelper.js.map +1 -1
- package/dist/summarizerNode/summarizerNode.d.ts +25 -10
- package/dist/summarizerNode/summarizerNode.d.ts.map +1 -1
- package/dist/summarizerNode/summarizerNode.js +117 -52
- package/dist/summarizerNode/summarizerNode.js.map +1 -1
- package/dist/summarizerNode/summarizerNodeUtils.d.ts +12 -14
- package/dist/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
- package/dist/summarizerNode/summarizerNodeUtils.js.map +1 -1
- package/dist/summarizerNode/summarizerNodeWithGc.d.ts +8 -114
- package/dist/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
- package/dist/summarizerNode/summarizerNodeWithGc.js +45 -19
- package/dist/summarizerNode/summarizerNodeWithGc.js.map +1 -1
- package/dist/summaryUtils.d.ts +2 -2
- package/dist/summaryUtils.d.ts.map +1 -1
- package/dist/summaryUtils.js +5 -4
- package/dist/summaryUtils.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js.map +1 -1
- package/lib/dataStoreHandleContextUtils.d.ts.map +1 -1
- package/lib/dataStoreHandleContextUtils.js +3 -1
- package/lib/dataStoreHandleContextUtils.js.map +1 -1
- package/lib/dataStoreHelpers.d.ts.map +1 -1
- package/lib/dataStoreHelpers.js +23 -7
- package/lib/dataStoreHelpers.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/objectstoragepartition.d.ts.map +1 -1
- package/lib/objectstoragepartition.js.map +1 -1
- package/lib/objectstorageutils.d.ts.map +1 -1
- package/lib/objectstorageutils.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/requestParser.d.ts.map +1 -1
- package/lib/requestParser.js.map +1 -1
- package/lib/runtimeFactoryHelper.d.ts.map +1 -1
- package/lib/runtimeFactoryHelper.js +6 -2
- package/lib/runtimeFactoryHelper.js.map +1 -1
- package/lib/summarizerNode/summarizerNode.d.ts +25 -10
- package/lib/summarizerNode/summarizerNode.d.ts.map +1 -1
- package/lib/summarizerNode/summarizerNode.js +117 -52
- package/lib/summarizerNode/summarizerNode.js.map +1 -1
- package/lib/summarizerNode/summarizerNodeUtils.d.ts +12 -14
- package/lib/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
- package/lib/summarizerNode/summarizerNodeUtils.js.map +1 -1
- package/lib/summarizerNode/summarizerNodeWithGc.d.ts +8 -114
- package/lib/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
- package/lib/summarizerNode/summarizerNodeWithGc.js +46 -19
- package/lib/summarizerNode/summarizerNodeWithGc.js.map +1 -1
- package/lib/summaryUtils.d.ts +2 -2
- package/lib/summaryUtils.d.ts.map +1 -1
- package/lib/summaryUtils.js +5 -4
- package/lib/summaryUtils.js.map +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js.map +1 -1
- package/package.json +45 -48
- package/prettier.config.cjs +1 -1
- package/src/dataStoreHandleContextUtils.ts +23 -16
- package/src/dataStoreHelpers.ts +104 -86
- package/src/index.ts +3 -2
- package/src/objectstoragepartition.ts +13 -13
- package/src/objectstorageutils.ts +31 -28
- package/src/packageVersion.ts +1 -1
- package/src/requestParser.ts +80 -82
- package/src/runtimeFactoryHelper.ts +24 -17
- package/src/summarizerNode/summarizerNode.ts +702 -575
- package/src/summarizerNode/summarizerNodeUtils.ts +157 -159
- package/src/summarizerNode/summarizerNodeWithGc.ts +532 -473
- package/src/summaryUtils.ts +313 -305
- package/src/utils.ts +6 -6
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +8 -12
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { CreateSummarizerNodeSource, } from "@fluidframework/runtime-definitions";
|
|
6
6
|
import { SummaryType, } from "@fluidframework/protocol-definitions";
|
|
7
7
|
import { assert, unreachableCase } from "@fluidframework/common-utils";
|
|
8
|
+
import { ChildLogger, LoggingError, PerformanceEvent, TelemetryDataTag, } from "@fluidframework/telemetry-utils";
|
|
8
9
|
import { mergeStats, convertToSummaryTree, calculateStats } from "../summaryUtils";
|
|
9
10
|
import { EscapedPath, parseSummaryForSubtrees, parseSummaryTreeForSubtrees, SummaryNode, } from "./summarizerNodeUtils";
|
|
10
11
|
/**
|
|
@@ -25,20 +26,31 @@ export class SummarizerNode {
|
|
|
25
26
|
* Do not call constructor directly.
|
|
26
27
|
* Use createRootSummarizerNode to create root node, or createChild to create child nodes.
|
|
27
28
|
*/
|
|
28
|
-
constructor(
|
|
29
|
+
constructor(baseLogger, summarizeInternalFn, config, _changeSequenceNumber,
|
|
29
30
|
/** Undefined means created without summary */
|
|
30
|
-
_latestSummary, initialSummary, wipSummaryLogger
|
|
31
|
+
_latestSummary, initialSummary, wipSummaryLogger,
|
|
32
|
+
/** A unique id of this node to be logged when sending telemetry. */
|
|
33
|
+
telemetryNodeId) {
|
|
31
34
|
var _a;
|
|
32
|
-
this.defaultLogger = defaultLogger;
|
|
33
35
|
this.summarizeInternalFn = summarizeInternalFn;
|
|
34
36
|
this._changeSequenceNumber = _changeSequenceNumber;
|
|
35
37
|
this._latestSummary = _latestSummary;
|
|
36
38
|
this.initialSummary = initialSummary;
|
|
37
39
|
this.wipSummaryLogger = wipSummaryLogger;
|
|
40
|
+
this.telemetryNodeId = telemetryNodeId;
|
|
38
41
|
this.children = new Map();
|
|
39
42
|
this.pendingSummaries = new Map();
|
|
40
43
|
this.wipSkipRecursion = false;
|
|
41
44
|
this.canReuseHandle = (_a = config.canReuseHandle) !== null && _a !== void 0 ? _a : true;
|
|
45
|
+
// All logs posted by the summarizer node should include the telemetryNodeId.
|
|
46
|
+
this.logger = ChildLogger.create(baseLogger, undefined /* namespace */, {
|
|
47
|
+
all: {
|
|
48
|
+
id: {
|
|
49
|
+
tag: TelemetryDataTag.CodeArtifact,
|
|
50
|
+
value: this.telemetryNodeId,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
});
|
|
42
54
|
}
|
|
43
55
|
/**
|
|
44
56
|
* The reference sequence number of the most recent acked summary.
|
|
@@ -126,10 +138,21 @@ export class SummarizerNode {
|
|
|
126
138
|
return;
|
|
127
139
|
}
|
|
128
140
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
141
|
+
/**
|
|
142
|
+
* The absence of wip local path indicates that summarize was not called for this node. This can happen if:
|
|
143
|
+
* 1. A child node was created after summarize was already called on the parent. For example, a data store
|
|
144
|
+
* is realized (loaded) after summarize was called on it creating summarizer nodes for its DDSes. In this case,
|
|
145
|
+
* parentSkipRecursion will be true and the if block above would handle it.
|
|
146
|
+
* 2. A new node was created but summarize was never called on it. This can mean that the summary that is
|
|
147
|
+
* generated may not have the data from this node. We should not continue, log and throw an error. This
|
|
148
|
+
* will help us identify these cases and take appropriate action.
|
|
149
|
+
*/
|
|
150
|
+
if (localPathsToUse === undefined) {
|
|
151
|
+
this.throwUnexpectedError({
|
|
152
|
+
eventName: "NodeNotSummarized",
|
|
153
|
+
proposalHandle,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
133
156
|
const summary = new SummaryNode(Object.assign(Object.assign({}, localPathsToUse), { referenceSequenceNumber: this.wipReferenceSequenceNumber, basePath: parentPath }));
|
|
134
157
|
const fullPathForChildren = summary.fullPathForChildren;
|
|
135
158
|
for (const child of this.children.values()) {
|
|
@@ -168,49 +191,72 @@ export class SummarizerNode {
|
|
|
168
191
|
* case, the latest summary is updated based on the downloaded snapshot which is also returned.
|
|
169
192
|
*/
|
|
170
193
|
async refreshLatestSummary(proposalHandle, summaryRefSeq, fetchLatestSnapshot, readAndParseBlob, correlatedSummaryLogger) {
|
|
171
|
-
|
|
172
|
-
this.defaultLogger.sendTelemetryEvent({
|
|
173
|
-
eventName: "refreshLatestSummary_start",
|
|
194
|
+
const eventProps = {
|
|
174
195
|
proposalHandle,
|
|
175
|
-
referenceSequenceNumber: this.referenceSequenceNumber,
|
|
176
196
|
summaryRefSeq,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
197
|
+
referenceSequenceNumber: this.referenceSequenceNumber,
|
|
198
|
+
};
|
|
199
|
+
return PerformanceEvent.timedExecAsync(this.logger, Object.assign({ eventName: "refreshLatestSummary" }, eventProps), async (event) => {
|
|
200
|
+
var _a;
|
|
201
|
+
// Refresh latest summary should not happen while a summary is in progress. If it does, it can result
|
|
202
|
+
// in inconsistent state, so, we should not continue;
|
|
203
|
+
if (this.isSummaryInProgress()) {
|
|
204
|
+
throw new LoggingError("UnexpectedRefreshDuringSummarize", {
|
|
205
|
+
inProgressSummaryRefSeq: this.wipReferenceSequenceNumber,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
if (proposalHandle !== undefined) {
|
|
209
|
+
const maybeSummaryNode = this.pendingSummaries.get(proposalHandle);
|
|
210
|
+
if (maybeSummaryNode !== undefined) {
|
|
211
|
+
this.refreshLatestSummaryFromPending(proposalHandle, maybeSummaryNode.referenceSequenceNumber);
|
|
212
|
+
eventProps.wasSummaryTracked = true;
|
|
213
|
+
eventProps.latestSummaryUpdated = true;
|
|
214
|
+
event.end(eventProps);
|
|
215
|
+
return {
|
|
216
|
+
latestSummaryUpdated: true,
|
|
217
|
+
wasSummaryTracked: true,
|
|
218
|
+
summaryRefSeq,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
const props = {
|
|
222
|
+
summaryRefSeq,
|
|
223
|
+
pendingSize: (_a = this.pendingSummaries.size) !== null && _a !== void 0 ? _a : undefined,
|
|
224
|
+
};
|
|
225
|
+
this.logger.sendTelemetryEvent({
|
|
226
|
+
eventName: "PendingSummaryNotFound",
|
|
227
|
+
proposalHandle,
|
|
228
|
+
referenceSequenceNumber: this.referenceSequenceNumber,
|
|
229
|
+
details: JSON.stringify(props),
|
|
230
|
+
});
|
|
183
231
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
232
|
+
// If the summary for which refresh is called is older than the latest tracked summary, ignore it.
|
|
233
|
+
if (this.referenceSequenceNumber >= summaryRefSeq) {
|
|
234
|
+
eventProps.latestSummaryUpdated = false;
|
|
235
|
+
event.end(eventProps);
|
|
236
|
+
return { latestSummaryUpdated: false };
|
|
237
|
+
}
|
|
238
|
+
// Fetch the latest snapshot and refresh state from it. Note that we need to use the reference sequence number
|
|
239
|
+
// of the fetched snapshot and not the "summaryRefSeq" that was passed in.
|
|
240
|
+
const { snapshotTree, snapshotRefSeq: fetchedSnapshotRefSeq } = await fetchLatestSnapshot();
|
|
241
|
+
// Possible re-entrancy. We may have updated latest summary state while fetching the snapshot. If the fetched
|
|
242
|
+
// snapshot is older than the latest tracked summary, ignore it.
|
|
243
|
+
if (this.referenceSequenceNumber >= fetchedSnapshotRefSeq) {
|
|
244
|
+
eventProps.latestSummaryUpdated = false;
|
|
245
|
+
event.end(eventProps);
|
|
246
|
+
return { latestSummaryUpdated: false };
|
|
247
|
+
}
|
|
248
|
+
await this.refreshLatestSummaryFromSnapshot(fetchedSnapshotRefSeq, snapshotTree, undefined, EscapedPath.create(""), correlatedSummaryLogger, readAndParseBlob);
|
|
249
|
+
eventProps.latestSummaryUpdated = true;
|
|
250
|
+
eventProps.wasSummaryTracked = false;
|
|
251
|
+
eventProps.summaryRefSeq = fetchedSnapshotRefSeq;
|
|
252
|
+
event.end(eventProps);
|
|
253
|
+
return {
|
|
254
|
+
latestSummaryUpdated: true,
|
|
255
|
+
wasSummaryTracked: false,
|
|
256
|
+
snapshotTree,
|
|
257
|
+
summaryRefSeq: fetchedSnapshotRefSeq,
|
|
187
258
|
};
|
|
188
|
-
|
|
189
|
-
eventName: "PendingSummaryNotFound",
|
|
190
|
-
proposalHandle,
|
|
191
|
-
referenceSequenceNumber: this.referenceSequenceNumber,
|
|
192
|
-
details: JSON.stringify(props),
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
// If the summary for which refresh is called is older than the latest tracked summary, ignore it.
|
|
196
|
-
if (this.referenceSequenceNumber >= summaryRefSeq) {
|
|
197
|
-
return { latestSummaryUpdated: false };
|
|
198
|
-
}
|
|
199
|
-
// Fetch the latest snapshot and refresh state from it. Note that we need to use the reference sequence number
|
|
200
|
-
// of the fetched snapshot and not the "summaryRefSeq" that was passed in.
|
|
201
|
-
const { snapshotTree, snapshotRefSeq: fetchedSnapshotRefSeq } = await fetchLatestSnapshot();
|
|
202
|
-
// Possible re-entrancy. We may have updated latest summary state while fetching the snapshot. If the fetched
|
|
203
|
-
// snapshot is older than the latest tracked summary, ignore it.
|
|
204
|
-
if (this.referenceSequenceNumber >= fetchedSnapshotRefSeq) {
|
|
205
|
-
return { latestSummaryUpdated: false };
|
|
206
|
-
}
|
|
207
|
-
await this.refreshLatestSummaryFromSnapshot(fetchedSnapshotRefSeq, snapshotTree, undefined, EscapedPath.create(""), correlatedSummaryLogger, readAndParseBlob);
|
|
208
|
-
return {
|
|
209
|
-
latestSummaryUpdated: true,
|
|
210
|
-
wasSummaryTracked: false,
|
|
211
|
-
snapshotTree,
|
|
212
|
-
summaryRefSeq: fetchedSnapshotRefSeq,
|
|
213
|
-
};
|
|
259
|
+
}, { start: true, end: true, cancel: "error" });
|
|
214
260
|
}
|
|
215
261
|
/**
|
|
216
262
|
* Called when we get an ack from the server for a summary we've just sent. Updates the reference state of this node
|
|
@@ -263,7 +309,8 @@ export class SummarizerNode {
|
|
|
263
309
|
// Assuming subtrees missing from snapshot are newer than the snapshot,
|
|
264
310
|
// but might be nice to assert this using earliest seq for node.
|
|
265
311
|
return childrenTree.trees[id] !== undefined;
|
|
266
|
-
})
|
|
312
|
+
})
|
|
313
|
+
.map(async ([id, child]) => {
|
|
267
314
|
return child.refreshLatestSummaryFromSnapshot(referenceSequenceNumber, childrenTree.trees[id], pathForChildren, EscapedPath.create(id), correlatedSummaryLogger, readAndParseBlob);
|
|
268
315
|
}));
|
|
269
316
|
}
|
|
@@ -314,7 +361,7 @@ export class SummarizerNode {
|
|
|
314
361
|
createParam, config = {}) {
|
|
315
362
|
assert(!this.children.has(id), 0x1ab /* "Create SummarizerNode child already exists" */);
|
|
316
363
|
const createDetails = this.getCreateDetailsForChild(id, createParam);
|
|
317
|
-
const child = new SummarizerNode(this.
|
|
364
|
+
const child = new SummarizerNode(this.logger, summarizeInternalFn, config, createDetails.changeSequenceNumber, createDetails.latestSummary, createDetails.initialSummary, this.wipSummaryLogger, createDetails.telemetryNodeId);
|
|
318
365
|
// There may be additional state that has to be updated in this child. For example, if a summary is being
|
|
319
366
|
// tracked, the child's summary tracking state needs to be updated too. Same goes for pendingSummaries we might
|
|
320
367
|
// have outstanding on the parent in case we realize nodes in between Summary Op and Summary Ack.
|
|
@@ -332,15 +379,15 @@ export class SummarizerNode {
|
|
|
332
379
|
* @returns the details needed to create the child node.
|
|
333
380
|
*/
|
|
334
381
|
getCreateDetailsForChild(id, createParam) {
|
|
335
|
-
var _a;
|
|
382
|
+
var _a, _b;
|
|
336
383
|
let initialSummary;
|
|
337
384
|
let latestSummary;
|
|
338
385
|
let changeSequenceNumber;
|
|
339
386
|
const parentLatestSummary = this._latestSummary;
|
|
340
387
|
switch (createParam.type) {
|
|
341
388
|
case CreateSummarizerNodeSource.FromAttach: {
|
|
342
|
-
if (parentLatestSummary !== undefined
|
|
343
|
-
|
|
389
|
+
if (parentLatestSummary !== undefined &&
|
|
390
|
+
createParam.sequenceNumber <= parentLatestSummary.referenceSequenceNumber) {
|
|
344
391
|
// Prioritize latest summary if it was after this node was attached.
|
|
345
392
|
latestSummary = parentLatestSummary.createForChild(id);
|
|
346
393
|
}
|
|
@@ -397,10 +444,12 @@ export class SummarizerNode {
|
|
|
397
444
|
unreachableCase(createParam, `Unexpected CreateSummarizerNodeSource: ${type}`);
|
|
398
445
|
}
|
|
399
446
|
}
|
|
447
|
+
const childtelemetryNodeId = `${(_b = this.telemetryNodeId) !== null && _b !== void 0 ? _b : ""}/${id}`;
|
|
400
448
|
return {
|
|
401
449
|
initialSummary,
|
|
402
450
|
latestSummary,
|
|
403
451
|
changeSequenceNumber,
|
|
452
|
+
telemetryNodeId: childtelemetryNodeId,
|
|
404
453
|
};
|
|
405
454
|
}
|
|
406
455
|
/**
|
|
@@ -437,6 +486,17 @@ export class SummarizerNode {
|
|
|
437
486
|
isSummaryInProgress() {
|
|
438
487
|
return this.wipReferenceSequenceNumber !== undefined;
|
|
439
488
|
}
|
|
489
|
+
/**
|
|
490
|
+
* Creates and throws an error due to unexpected conditions.
|
|
491
|
+
*/
|
|
492
|
+
throwUnexpectedError(eventProps) {
|
|
493
|
+
const error = new LoggingError(eventProps.eventName, Object.assign(Object.assign({}, eventProps), { referenceSequenceNumber: this.wipReferenceSequenceNumber, id: {
|
|
494
|
+
tag: TelemetryDataTag.CodeArtifact,
|
|
495
|
+
value: this.telemetryNodeId,
|
|
496
|
+
} }));
|
|
497
|
+
this.logger.sendErrorEvent(eventProps, error);
|
|
498
|
+
throw error;
|
|
499
|
+
}
|
|
440
500
|
}
|
|
441
501
|
/**
|
|
442
502
|
* Creates a root summarizer node.
|
|
@@ -446,6 +506,11 @@ export class SummarizerNode {
|
|
|
446
506
|
* @param referenceSequenceNumber - Reference sequence number of last acked summary,
|
|
447
507
|
* or undefined if not loaded from summary
|
|
448
508
|
* @param config - Configure behavior of summarizer node
|
|
509
|
+
*
|
|
510
|
+
* @deprecated Internal implementation detail and will no longer be exported in an
|
|
511
|
+
* upcoming release.
|
|
449
512
|
*/
|
|
450
|
-
export const createRootSummarizerNode = (logger, summarizeInternalFn, changeSequenceNumber, referenceSequenceNumber, config = {}) => new SummarizerNode(logger, summarizeInternalFn, config, changeSequenceNumber, referenceSequenceNumber === undefined
|
|
513
|
+
export const createRootSummarizerNode = (logger, summarizeInternalFn, changeSequenceNumber, referenceSequenceNumber, config = {}) => new SummarizerNode(logger, summarizeInternalFn, config, changeSequenceNumber, referenceSequenceNumber === undefined
|
|
514
|
+
? undefined
|
|
515
|
+
: SummaryNode.createForRoot(referenceSequenceNumber), undefined /* initialSummary */, undefined /* wipSummaryLogger */, "" /* telemetryNodeId */);
|
|
451
516
|
//# sourceMappingURL=summarizerNode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summarizerNode.js","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAMH,0BAA0B,GAG7B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAEH,WAAW,GAGd,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEnF,OAAO,EACH,WAAW,EAKX,u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ACzG,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n ISummarizerNode,\n ISummarizerNodeConfig,\n ISummarizeResult,\n ISummaryTreeWithStats,\n CreateChildSummarizerNodeParam,\n CreateSummarizerNodeSource,\n SummarizeInternalFn,\n ITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n ISequencedDocumentMessage,\n SummaryType,\n ISnapshotTree,\n SummaryObject,\n} from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, unreachableCase } from \"@fluidframework/common-utils\";\nimport { mergeStats, convertToSummaryTree, calculateStats } from \"../summaryUtils\";\nimport { ReadAndParseBlob } from \"../utils\";\nimport {\n EscapedPath,\n ICreateChildDetails,\n IFetchSnapshotResult,\n IInitialSummary,\n ISummarizerNodeRootContract,\n parseSummaryForSubtrees,\n parseSummaryTreeForSubtrees,\n RefreshSummaryResult,\n SummaryNode,\n} from \"./summarizerNodeUtils\";\n\nexport interface IRootSummarizerNode extends ISummarizerNode, ISummarizerNodeRootContract {}\n\n/**\n * Encapsulates the summarizing work and state of an individual tree node in the\n * summary tree. It tracks changes and allows for optimizations when unchanged, or\n * can allow for fallback summaries to be generated when an error is encountered.\n * Usage is for the root node to call startSummary first to begin tracking a WIP\n * (work in progress) summary. Then all nodes will call summarize to summaries their\n * individual parts. Once completed and uploaded to storage, the root node will call\n * completeSummary or clearSummary to clear the WIP summary tracking state if something\n * went wrong. The SummarizerNodes will track all pending summaries that have been\n * recorded by the completeSummary call. When one of them is acked, the root node should\n * call refreshLatestSummary to inform the tree of SummarizerNodes of the new baseline\n * latest successful summary.\n */\nexport class SummarizerNode implements IRootSummarizerNode {\n /**\n * The reference sequence number of the most recent acked summary.\n * Returns 0 if there is not yet an acked summary.\n */\n public get referenceSequenceNumber() {\n return this._latestSummary?.referenceSequenceNumber ?? 0;\n }\n\n protected readonly children = new Map<string, SummarizerNode>();\n protected readonly pendingSummaries = new Map<string, SummaryNode>();\n private wipReferenceSequenceNumber: number | undefined;\n private wipLocalPaths: { localPath: EscapedPath; additionalPath?: EscapedPath; } | undefined;\n private wipSkipRecursion = false;\n\n public startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLogger) {\n assert(this.wipSummaryLogger === undefined,\n 0x19f /* \"wipSummaryLogger should not be set yet in startSummary\" */);\n assert(this.wipReferenceSequenceNumber === undefined, 0x1a0 /* \"Already tracking a summary\" */);\n\n this.wipSummaryLogger = summaryLogger;\n\n for (const child of this.children.values()) {\n child.startSummary(referenceSequenceNumber, this.wipSummaryLogger);\n }\n this.wipReferenceSequenceNumber = referenceSequenceNumber;\n }\n\n public async summarize(\n fullTree: boolean,\n trackState: boolean = true,\n telemetryContext?: ITelemetryContext,\n ): Promise<ISummarizeResult> {\n assert(this.isSummaryInProgress(), 0x1a1 /* \"summarize should not be called when not tracking the summary\" */);\n assert(this.wipSummaryLogger !== undefined,\n 0x1a2 /* \"wipSummaryLogger should have been set in startSummary or ctor\" */);\n\n // Try to reuse the tree if unchanged\n if (this.canReuseHandle && !fullTree && !this.hasChanged()) {\n const latestSummary = this._latestSummary;\n if (latestSummary !== undefined) {\n this.wipLocalPaths = {\n localPath: latestSummary.localPath,\n additionalPath: latestSummary.additionalPath,\n };\n this.wipSkipRecursion = true;\n const stats = mergeStats();\n stats.handleNodeCount++;\n return {\n summary: {\n type: SummaryType.Handle,\n handle: latestSummary.fullPath.path,\n handleType: SummaryType.Tree,\n },\n stats,\n };\n }\n }\n\n const result = await this.summarizeInternalFn(fullTree, true, telemetryContext);\n this.wipLocalPaths = { localPath: EscapedPath.create(result.id) };\n if (result.pathPartsForChildren !== undefined) {\n this.wipLocalPaths.additionalPath = EscapedPath.createAndConcat(result.pathPartsForChildren);\n }\n return { summary: result.summary, stats: result.stats };\n }\n\n /**\n * Complete the WIP summary for the given proposalHandle\n */\n public completeSummary(proposalHandle: string) {\n this.completeSummaryCore(proposalHandle, undefined, false);\n }\n\n /**\n * Recursive implementation for completeSummary, with additional internal-only parameters\n */\n protected completeSummaryCore(\n proposalHandle: string,\n parentPath: EscapedPath | undefined,\n parentSkipRecursion: boolean,\n ) {\n assert(this.wipSummaryLogger !== undefined,\n 0x1a3 /* \"wipSummaryLogger should have been set in startSummary or ctor\" */);\n assert(this.wipReferenceSequenceNumber !== undefined, 0x1a4 /* \"Not tracking a summary\" */);\n let localPathsToUse = this.wipLocalPaths;\n\n if (parentSkipRecursion) {\n const latestSummary = this._latestSummary;\n if (latestSummary !== undefined) {\n // This case the parent node created a failure summary or was reused.\n // This node and all children should only try to reference their path\n // by its last known good state in the actual summary tree.\n // If parent fails or is reused, the child summarize is not called so\n // it did not get a chance to change its paths.\n // In this case, essentially only propagate the new summary ref seq num.\n localPathsToUse = {\n localPath: latestSummary.localPath,\n additionalPath: latestSummary.additionalPath,\n };\n } else {\n // This case the child is added after the latest non-failure summary.\n // This node and all children should consider themselves as still not\n // having a successful summary yet.\n // We cannot \"reuse\" this node if unchanged since that summary, because\n // handles will be unable to point to that node. It never made it to the\n // tree itself, and only exists as an attach op in the _outstandingOps.\n this.clearSummary();\n return;\n }\n }\n\n // This should come from wipLocalPaths in normal cases, or from the latestSummary\n // if parentIsFailure or parentIsReused is true.\n // If there is no latestSummary, clearSummary and return before reaching this code.\n assert(!!localPathsToUse, 0x1a5 /* \"Tracked summary local paths not set\" */);\n\n const summary = new SummaryNode({\n ...localPathsToUse,\n referenceSequenceNumber: this.wipReferenceSequenceNumber,\n basePath: parentPath,\n });\n const fullPathForChildren = summary.fullPathForChildren;\n for (const child of this.children.values()) {\n child.completeSummaryCore(\n proposalHandle,\n fullPathForChildren,\n this.wipSkipRecursion || parentSkipRecursion,\n );\n }\n // Note that this overwrites existing pending summary with\n // the same proposalHandle. If proposalHandle is something like\n // a hash or unique identifier, this should be fine. If storage\n // can return the same proposalHandle for a different summary,\n // this should still be okay, because we should be proposing the\n // newer one later which would have to overwrite the previous one.\n this.pendingSummaries.set(proposalHandle, summary);\n this.clearSummary();\n }\n\n public clearSummary() {\n this.wipReferenceSequenceNumber = undefined;\n this.wipLocalPaths = undefined;\n this.wipSkipRecursion = false;\n this.wipSummaryLogger = undefined;\n for (const child of this.children.values()) {\n child.clearSummary();\n }\n }\n\n /**\n * Refreshes the latest summary tracked by this node. If we have a pending summary for the given proposal handle,\n * it becomes the latest summary. If the current summary is already ahead (e.g., loaded from a service summary),\n * we skip the update. Otherwise, we fetch the latest snapshot and update latest summary based off of that.\n *\n * @returns A RefreshSummaryResult type which returns information based on the following three scenarios:\n *\n * 1. The latest summary was not updated.\n *\n * 2. The latest summary was updated and the summary corresponding to the params was being tracked.\n *\n * 3. The latest summary was updated but the summary corresponding to the params was not tracked. In this\n * case, the latest summary is updated based on the downloaded snapshot which is also returned.\n */\n public async refreshLatestSummary(\n proposalHandle: string | undefined,\n summaryRefSeq: number,\n fetchLatestSnapshot: () => Promise<IFetchSnapshotResult>,\n readAndParseBlob: ReadAndParseBlob,\n correlatedSummaryLogger: ITelemetryLogger,\n ): Promise<RefreshSummaryResult> {\n this.defaultLogger.sendTelemetryEvent({\n eventName: \"refreshLatestSummary_start\",\n proposalHandle,\n referenceSequenceNumber: this.referenceSequenceNumber,\n summaryRefSeq,\n });\n\n if (proposalHandle !== undefined) {\n const maybeSummaryNode = this.pendingSummaries.get(proposalHandle);\n\n if (maybeSummaryNode !== undefined) {\n this.refreshLatestSummaryFromPending(\n proposalHandle,\n maybeSummaryNode.referenceSequenceNumber,\n );\n return { latestSummaryUpdated: true, wasSummaryTracked: true, summaryRefSeq };\n }\n\n const props = {\n summaryRefSeq,\n pendingSize: this.pendingSummaries.size ?? undefined,\n };\n this.defaultLogger.sendTelemetryEvent({\n eventName: \"PendingSummaryNotFound\",\n proposalHandle,\n referenceSequenceNumber: this.referenceSequenceNumber,\n details: JSON.stringify(props),\n });\n }\n\n // If the summary for which refresh is called is older than the latest tracked summary, ignore it.\n if (this.referenceSequenceNumber >= summaryRefSeq) {\n return { latestSummaryUpdated: false };\n }\n\n // Fetch the latest snapshot and refresh state from it. Note that we need to use the reference sequence number\n // of the fetched snapshot and not the \"summaryRefSeq\" that was passed in.\n const { snapshotTree, snapshotRefSeq: fetchedSnapshotRefSeq } = await fetchLatestSnapshot();\n\n // Possible re-entrancy. We may have updated latest summary state while fetching the snapshot. If the fetched\n // snapshot is older than the latest tracked summary, ignore it.\n if (this.referenceSequenceNumber >= fetchedSnapshotRefSeq) {\n return { latestSummaryUpdated: false };\n }\n\n await this.refreshLatestSummaryFromSnapshot(\n fetchedSnapshotRefSeq,\n snapshotTree,\n undefined,\n EscapedPath.create(\"\"),\n correlatedSummaryLogger,\n readAndParseBlob,\n );\n\n return {\n latestSummaryUpdated: true,\n wasSummaryTracked: false,\n snapshotTree,\n summaryRefSeq: fetchedSnapshotRefSeq,\n };\n }\n/**\n * Called when we get an ack from the server for a summary we've just sent. Updates the reference state of this node\n * from the state in the pending summary queue.\n * @param proposalHandle - Handle for the current proposal.\n * @param referenceSequenceNumber - reference sequence number of sent summary.\n */\n protected refreshLatestSummaryFromPending(\n proposalHandle: string,\n referenceSequenceNumber: number,\n ): void {\n const summaryNode = this.pendingSummaries.get(proposalHandle);\n if (summaryNode === undefined) {\n // This should only happen if parent skipped recursion AND no prior summary existed.\n assert(\n this._latestSummary === undefined,\n 0x1a6 /* \"Not found pending summary, but this node has previously completed a summary\" */,\n );\n return;\n } else {\n assert(\n referenceSequenceNumber === summaryNode.referenceSequenceNumber,\n 0x1a7 /* Pending summary reference sequence number should be consistent */,\n );\n\n // Clear earlier pending summaries\n this.pendingSummaries.delete(proposalHandle);\n }\n\n this.refreshLatestSummaryCore(referenceSequenceNumber);\n\n this._latestSummary = summaryNode;\n // Propagate update to all child nodes\n for (const child of this.children.values()) {\n child.refreshLatestSummaryFromPending(proposalHandle, referenceSequenceNumber);\n }\n }\n\n protected async refreshLatestSummaryFromSnapshot(\n referenceSequenceNumber: number,\n snapshotTree: ISnapshotTree,\n basePath: EscapedPath | undefined,\n localPath: EscapedPath,\n correlatedSummaryLogger: ITelemetryLogger,\n readAndParseBlob: ReadAndParseBlob,\n ): Promise<void> {\n // Possible re-entrancy. If we have already seen a summary later than this one, ignore it.\n if (this.referenceSequenceNumber >= referenceSequenceNumber) {\n return;\n }\n\n this.refreshLatestSummaryCore(referenceSequenceNumber);\n\n this._latestSummary = new SummaryNode({\n referenceSequenceNumber,\n basePath,\n localPath,\n });\n\n const pathParts: string[] = [];\n const { childrenTree, childrenPathPart } = parseSummaryForSubtrees(snapshotTree);\n if (childrenPathPart !== undefined) {\n pathParts.push(childrenPathPart);\n }\n\n if (pathParts.length > 0) {\n this._latestSummary.additionalPath = EscapedPath.createAndConcat(pathParts);\n }\n\n // Propagate update to all child nodes\n const pathForChildren = this._latestSummary.fullPathForChildren;\n await Promise.all(Array.from(this.children)\n .filter(([id]) => {\n // Assuming subtrees missing from snapshot are newer than the snapshot,\n // but might be nice to assert this using earliest seq for node.\n return childrenTree.trees[id] !== undefined;\n }).map(async ([id, child]) => {\n return child.refreshLatestSummaryFromSnapshot(\n referenceSequenceNumber,\n childrenTree.trees[id],\n pathForChildren,\n EscapedPath.create(id),\n correlatedSummaryLogger,\n readAndParseBlob,\n );\n }));\n }\n\n private refreshLatestSummaryCore(referenceSequenceNumber: number): void {\n for (const [key, value] of this.pendingSummaries) {\n if (value.referenceSequenceNumber < referenceSequenceNumber) {\n this.pendingSummaries.delete(key);\n }\n }\n }\n\n public updateBaseSummaryState(snapshot: ISnapshotTree) {\n // Check base summary to see if it has any additional path parts\n // separating child SummarizerNodes. Checks for .channels subtrees.\n const { childrenPathPart } = parseSummaryForSubtrees(snapshot);\n if (childrenPathPart !== undefined && this._latestSummary !== undefined) {\n this._latestSummary.additionalPath = EscapedPath.create(childrenPathPart);\n }\n }\n\n public recordChange(op: ISequencedDocumentMessage): void {\n this.invalidate(op.sequenceNumber);\n }\n\n public invalidate(sequenceNumber: number): void {\n if (sequenceNumber > this._changeSequenceNumber) {\n this._changeSequenceNumber = sequenceNumber;\n }\n }\n\n /**\n * True if a change has been recorded with sequence number exceeding\n * the latest successfully acked summary reference sequence number.\n * False implies that the previous summary can be reused.\n */\n protected hasChanged(): boolean {\n return this._changeSequenceNumber > this.referenceSequenceNumber;\n }\n\n public get latestSummary(): Readonly<SummaryNode> | undefined {\n return this._latestSummary;\n }\n\n protected readonly canReuseHandle: boolean;\n\n /**\n * Do not call constructor directly.\n * Use createRootSummarizerNode to create root node, or createChild to create child nodes.\n */\n public constructor(\n protected readonly defaultLogger: ITelemetryLogger,\n private readonly summarizeInternalFn: SummarizeInternalFn,\n config: ISummarizerNodeConfig,\n private _changeSequenceNumber: number,\n /** Undefined means created without summary */\n private _latestSummary?: SummaryNode,\n private readonly initialSummary?: IInitialSummary,\n protected wipSummaryLogger?: ITelemetryLogger,\n ) {\n this.canReuseHandle = config.canReuseHandle ?? true;\n }\n\n public createChild(\n /** Summarize function */\n summarizeInternalFn: SummarizeInternalFn,\n /** Initial id or path part of this node */\n id: string,\n /**\n * Information needed to create the node.\n * If it is from a base summary, it will assert that a summary has been seen.\n * Attach information if it is created from an attach op.\n */\n createParam: CreateChildSummarizerNodeParam,\n config: ISummarizerNodeConfig = {},\n ): ISummarizerNode {\n assert(!this.children.has(id), 0x1ab /* \"Create SummarizerNode child already exists\" */);\n\n const createDetails: ICreateChildDetails = this.getCreateDetailsForChild(id, createParam);\n const child = new SummarizerNode(\n this.defaultLogger,\n summarizeInternalFn,\n config,\n createDetails.changeSequenceNumber,\n createDetails.latestSummary,\n createDetails.initialSummary,\n this.wipSummaryLogger,\n );\n\n // There may be additional state that has to be updated in this child. For example, if a summary is being\n // tracked, the child's summary tracking state needs to be updated too. Same goes for pendingSummaries we might\n // have outstanding on the parent in case we realize nodes in between Summary Op and Summary Ack.\n this.maybeUpdateChildState(child);\n\n this.children.set(id, child);\n return child;\n }\n\n public getChild(id: string): ISummarizerNode | undefined {\n return this.children.get(id);\n }\n\n /**\n * Returns the details needed to create a child node.\n * @param id - Initial id or path part of the child node.\n * @param createParam - Information needed to create the node.\n * @returns the details needed to create the child node.\n */\n protected getCreateDetailsForChild(id: string, createParam: CreateChildSummarizerNodeParam): ICreateChildDetails {\n let initialSummary: IInitialSummary | undefined;\n let latestSummary: SummaryNode | undefined;\n let changeSequenceNumber: number;\n\n const parentLatestSummary = this._latestSummary;\n switch (createParam.type) {\n case CreateSummarizerNodeSource.FromAttach: {\n if (\n parentLatestSummary !== undefined\n && createParam.sequenceNumber <= parentLatestSummary.referenceSequenceNumber\n ) {\n // Prioritize latest summary if it was after this node was attached.\n latestSummary = parentLatestSummary.createForChild(id);\n } else {\n const summary = convertToSummaryTree(createParam.snapshot) as ISummaryTreeWithStats;\n initialSummary = {\n sequenceNumber: createParam.sequenceNumber,\n id,\n summary,\n };\n }\n changeSequenceNumber = createParam.sequenceNumber;\n break;\n }\n case CreateSummarizerNodeSource.FromSummary: {\n if (this.initialSummary === undefined) {\n assert(\n !!parentLatestSummary,\n 0x1ac /* \"Cannot create child from summary if parent does not have latest summary\" */);\n }\n // fallthrough to local\n }\n case CreateSummarizerNodeSource.Local: {\n const parentInitialSummary = this.initialSummary;\n if (parentInitialSummary !== undefined) {\n let childSummary: SummaryObject | undefined;\n if (parentInitialSummary.summary !== undefined) {\n const { childrenTree } = parseSummaryTreeForSubtrees(parentInitialSummary.summary.summary);\n assert(\n childrenTree.type === SummaryType.Tree,\n 0x1d6 /* \"Parent summary object is not a tree\" */,\n );\n childSummary = childrenTree.tree[id];\n }\n if (createParam.type === CreateSummarizerNodeSource.FromSummary) {\n // Locally created would not have differential subtree.\n assert(!!childSummary, 0x1ad /* \"Missing child summary tree\" */);\n }\n let childSummaryWithStats: ISummaryTreeWithStats | undefined;\n if (childSummary !== undefined) {\n assert(\n childSummary.type === SummaryType.Tree,\n 0x1ae /* \"Child summary object is not a tree\" */,\n );\n childSummaryWithStats = {\n summary: childSummary,\n stats: calculateStats(childSummary),\n };\n }\n initialSummary = {\n sequenceNumber: parentInitialSummary.sequenceNumber,\n id,\n summary: childSummaryWithStats,\n };\n }\n latestSummary = parentLatestSummary?.createForChild(id);\n changeSequenceNumber = parentLatestSummary?.referenceSequenceNumber ?? -1;\n break;\n }\n default: {\n const type = (createParam as unknown as CreateChildSummarizerNodeParam).type;\n unreachableCase(createParam, `Unexpected CreateSummarizerNodeSource: ${type}`);\n }\n }\n\n return {\n initialSummary,\n latestSummary,\n changeSequenceNumber,\n };\n }\n\n /**\n * Updates the state of the child if required. For example, if a summary is currently being tracked, the child's\n * summary tracking state needs to be updated too.\n * Also, in case a child node gets realized in between Summary Op and Summary Ack, let's initialize the child's\n * pending summary as well.\n * @param child - The child node whose state is to be updated.\n */\n protected maybeUpdateChildState(child: SummarizerNode) {\n // If a summary is in progress, this child was created after the summary started. So, we need to update the\n // child's summary state as well.\n if (this.isSummaryInProgress()) {\n child.wipReferenceSequenceNumber = this.wipReferenceSequenceNumber;\n }\n // In case we have pending summaries on the parent, let's initialize it on the child.\n if (child._latestSummary !== undefined) {\n for (const [key, value] of this.pendingSummaries.entries()) {\n const newLatestSummaryNode = new SummaryNode({\n referenceSequenceNumber: value.referenceSequenceNumber,\n basePath: child._latestSummary.basePath,\n localPath: child._latestSummary.localPath,\n });\n\n child.addPendingSummary(key, newLatestSummaryNode);\n }\n }\n }\n\n protected addPendingSummary(key: string, summary: SummaryNode) {\n this.pendingSummaries.set(key, summary);\n }\n /**\n * Tells whether summary tracking is in progress. True if \"startSummary\" API is called before summarize.\n */\n public isSummaryInProgress(): boolean {\n return this.wipReferenceSequenceNumber !== undefined;\n }\n}\n\n/**\n * Creates a root summarizer node.\n * @param logger - Logger to use within SummarizerNode\n * @param summarizeInternalFn - Function to generate summary\n * @param changeSequenceNumber - Sequence number of latest change to new node/subtree\n * @param referenceSequenceNumber - Reference sequence number of last acked summary,\n * or undefined if not loaded from summary\n * @param config - Configure behavior of summarizer node\n */\nexport const createRootSummarizerNode = (\n logger: ITelemetryLogger,\n summarizeInternalFn: SummarizeInternalFn,\n changeSequenceNumber: number,\n referenceSequenceNumber: number | undefined,\n config: ISummarizerNodeConfig = {},\n): IRootSummarizerNode => new SummarizerNode(\n logger,\n summarizeInternalFn,\n config,\n changeSequenceNumber,\n referenceSequenceNumber === undefined ? undefined : SummaryNode.createForRoot(referenceSequenceNumber),\n );\n"]}
|
|
1
|
+
{"version":3,"file":"summarizerNode.js","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAMN,0BAA0B,GAG1B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAEN,WAAW,GAGX,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EACN,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEnF,OAAO,EACN,WAAW,EAKX,uBAAuB,EACvB,2BAA2B,EAE3B,WAAW,GACX,MAAM,uBAAuB,CAAC;AAQ/B;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,cAAc;IAiB1B;;;OAGG;IACH,YACC,UAA4B,EACX,mBAAwC,EACzD,MAA6B,EACrB,qBAA6B;IACrC,8CAA8C;IACtC,cAA4B,EACnB,cAAgC,EACvC,gBAAmC;IAC7C,oEAAoE;IAC1D,eAAwB;;QARjB,wBAAmB,GAAnB,mBAAmB,CAAqB;QAEjD,0BAAqB,GAArB,qBAAqB,CAAQ;QAE7B,mBAAc,GAAd,cAAc,CAAc;QACnB,mBAAc,GAAd,cAAc,CAAkB;QACvC,qBAAgB,GAAhB,gBAAgB,CAAmB;QAEnC,oBAAe,GAAf,eAAe,CAAS;QAtBhB,aAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;QAC7C,qBAAgB,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ChC,EAAE,CAAC,qBAAqB,CACxB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tISummarizerNode,\n\tISummarizerNodeConfig,\n\tISummarizeResult,\n\tISummaryTreeWithStats,\n\tCreateChildSummarizerNodeParam,\n\tCreateSummarizerNodeSource,\n\tSummarizeInternalFn,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n\tISequencedDocumentMessage,\n\tSummaryType,\n\tISnapshotTree,\n\tSummaryObject,\n} from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryErrorEvent, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, unreachableCase } from \"@fluidframework/common-utils\";\nimport {\n\tChildLogger,\n\tLoggingError,\n\tPerformanceEvent,\n\tTelemetryDataTag,\n} from \"@fluidframework/telemetry-utils\";\nimport { mergeStats, convertToSummaryTree, calculateStats } from \"../summaryUtils\";\nimport { ReadAndParseBlob } from \"../utils\";\nimport {\n\tEscapedPath,\n\tICreateChildDetails,\n\tIFetchSnapshotResult,\n\tIInitialSummary,\n\tISummarizerNodeRootContract,\n\tparseSummaryForSubtrees,\n\tparseSummaryTreeForSubtrees,\n\tRefreshSummaryResult,\n\tSummaryNode,\n} from \"./summarizerNodeUtils\";\n\n/**\n * @deprecated Internal implementation detail and will no longer be exported in an\n * upcoming release.\n */\nexport interface IRootSummarizerNode extends ISummarizerNode, ISummarizerNodeRootContract {}\n\n/**\n * Encapsulates the summarizing work and state of an individual tree node in the\n * summary tree. It tracks changes and allows for optimizations when unchanged, or\n * can allow for fallback summaries to be generated when an error is encountered.\n * Usage is for the root node to call startSummary first to begin tracking a WIP\n * (work in progress) summary. Then all nodes will call summarize to summaries their\n * individual parts. Once completed and uploaded to storage, the root node will call\n * completeSummary or clearSummary to clear the WIP summary tracking state if something\n * went wrong. The SummarizerNodes will track all pending summaries that have been\n * recorded by the completeSummary call. When one of them is acked, the root node should\n * call refreshLatestSummary to inform the tree of SummarizerNodes of the new baseline\n * latest successful summary.\n */\nexport class SummarizerNode implements IRootSummarizerNode {\n\t/**\n\t * The reference sequence number of the most recent acked summary.\n\t * Returns 0 if there is not yet an acked summary.\n\t */\n\tpublic get referenceSequenceNumber() {\n\t\treturn this._latestSummary?.referenceSequenceNumber ?? 0;\n\t}\n\n\tprotected readonly children = new Map<string, SummarizerNode>();\n\tprotected readonly pendingSummaries = new Map<string, SummaryNode>();\n\tprotected wipReferenceSequenceNumber: number | undefined;\n\tprivate wipLocalPaths: { localPath: EscapedPath; additionalPath?: EscapedPath } | undefined;\n\tprivate wipSkipRecursion = false;\n\n\tprotected readonly logger: ITelemetryLogger;\n\n\t/**\n\t * Do not call constructor directly.\n\t * Use createRootSummarizerNode to create root node, or createChild to create child nodes.\n\t */\n\tpublic constructor(\n\t\tbaseLogger: ITelemetryLogger,\n\t\tprivate readonly summarizeInternalFn: SummarizeInternalFn,\n\t\tconfig: ISummarizerNodeConfig,\n\t\tprivate _changeSequenceNumber: number,\n\t\t/** Undefined means created without summary */\n\t\tprivate _latestSummary?: SummaryNode,\n\t\tprivate readonly initialSummary?: IInitialSummary,\n\t\tprotected wipSummaryLogger?: ITelemetryLogger,\n\t\t/** A unique id of this node to be logged when sending telemetry. */\n\t\tprotected telemetryNodeId?: string,\n\t) {\n\t\tthis.canReuseHandle = config.canReuseHandle ?? true;\n\t\t// All logs posted by the summarizer node should include the telemetryNodeId.\n\t\tthis.logger = ChildLogger.create(baseLogger, undefined /* namespace */, {\n\t\t\tall: {\n\t\t\t\tid: {\n\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t\tvalue: this.telemetryNodeId,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t}\n\n\tpublic startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLogger) {\n\t\tassert(\n\t\t\tthis.wipSummaryLogger === undefined,\n\t\t\t0x19f /* \"wipSummaryLogger should not be set yet in startSummary\" */,\n\t\t);\n\t\tassert(\n\t\t\tthis.wipReferenceSequenceNumber === undefined,\n\t\t\t0x1a0 /* \"Already tracking a summary\" */,\n\t\t);\n\n\t\tthis.wipSummaryLogger = summaryLogger;\n\n\t\tfor (const child of this.children.values()) {\n\t\t\tchild.startSummary(referenceSequenceNumber, this.wipSummaryLogger);\n\t\t}\n\t\tthis.wipReferenceSequenceNumber = referenceSequenceNumber;\n\t}\n\n\tpublic async summarize(\n\t\tfullTree: boolean,\n\t\ttrackState: boolean = true,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummarizeResult> {\n\t\tassert(\n\t\t\tthis.isSummaryInProgress(),\n\t\t\t0x1a1 /* \"summarize should not be called when not tracking the summary\" */,\n\t\t);\n\t\tassert(\n\t\t\tthis.wipSummaryLogger !== undefined,\n\t\t\t0x1a2 /* \"wipSummaryLogger should have been set in startSummary or ctor\" */,\n\t\t);\n\n\t\t// Try to reuse the tree if unchanged\n\t\tif (this.canReuseHandle && !fullTree && !this.hasChanged()) {\n\t\t\tconst latestSummary = this._latestSummary;\n\t\t\tif (latestSummary !== undefined) {\n\t\t\t\tthis.wipLocalPaths = {\n\t\t\t\t\tlocalPath: latestSummary.localPath,\n\t\t\t\t\tadditionalPath: latestSummary.additionalPath,\n\t\t\t\t};\n\t\t\t\tthis.wipSkipRecursion = true;\n\t\t\t\tconst stats = mergeStats();\n\t\t\t\tstats.handleNodeCount++;\n\t\t\t\treturn {\n\t\t\t\t\tsummary: {\n\t\t\t\t\t\ttype: SummaryType.Handle,\n\t\t\t\t\t\thandle: latestSummary.fullPath.path,\n\t\t\t\t\t\thandleType: SummaryType.Tree,\n\t\t\t\t\t},\n\t\t\t\t\tstats,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tconst result = await this.summarizeInternalFn(fullTree, true, telemetryContext);\n\t\tthis.wipLocalPaths = { localPath: EscapedPath.create(result.id) };\n\t\tif (result.pathPartsForChildren !== undefined) {\n\t\t\tthis.wipLocalPaths.additionalPath = EscapedPath.createAndConcat(\n\t\t\t\tresult.pathPartsForChildren,\n\t\t\t);\n\t\t}\n\t\treturn { summary: result.summary, stats: result.stats };\n\t}\n\n\t/**\n\t * Complete the WIP summary for the given proposalHandle\n\t */\n\tpublic completeSummary(proposalHandle: string) {\n\t\tthis.completeSummaryCore(proposalHandle, undefined, false);\n\t}\n\n\t/**\n\t * Recursive implementation for completeSummary, with additional internal-only parameters\n\t */\n\tprotected completeSummaryCore(\n\t\tproposalHandle: string,\n\t\tparentPath: EscapedPath | undefined,\n\t\tparentSkipRecursion: boolean,\n\t) {\n\t\tassert(\n\t\t\tthis.wipSummaryLogger !== undefined,\n\t\t\t0x1a3 /* \"wipSummaryLogger should have been set in startSummary or ctor\" */,\n\t\t);\n\t\tassert(this.wipReferenceSequenceNumber !== undefined, 0x1a4 /* \"Not tracking a summary\" */);\n\t\tlet localPathsToUse = this.wipLocalPaths;\n\n\t\tif (parentSkipRecursion) {\n\t\t\tconst latestSummary = this._latestSummary;\n\t\t\tif (latestSummary !== undefined) {\n\t\t\t\t// This case the parent node created a failure summary or was reused.\n\t\t\t\t// This node and all children should only try to reference their path\n\t\t\t\t// by its last known good state in the actual summary tree.\n\t\t\t\t// If parent fails or is reused, the child summarize is not called so\n\t\t\t\t// it did not get a chance to change its paths.\n\t\t\t\t// In this case, essentially only propagate the new summary ref seq num.\n\t\t\t\tlocalPathsToUse = {\n\t\t\t\t\tlocalPath: latestSummary.localPath,\n\t\t\t\t\tadditionalPath: latestSummary.additionalPath,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\t// This case the child is added after the latest non-failure summary.\n\t\t\t\t// This node and all children should consider themselves as still not\n\t\t\t\t// having a successful summary yet.\n\t\t\t\t// We cannot \"reuse\" this node if unchanged since that summary, because\n\t\t\t\t// handles will be unable to point to that node. It never made it to the\n\t\t\t\t// tree itself, and only exists as an attach op in the _outstandingOps.\n\t\t\t\tthis.clearSummary();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * The absence of wip local path indicates that summarize was not called for this node. This can happen if:\n\t\t * 1. A child node was created after summarize was already called on the parent. For example, a data store\n\t\t * is realized (loaded) after summarize was called on it creating summarizer nodes for its DDSes. In this case,\n\t\t * parentSkipRecursion will be true and the if block above would handle it.\n\t\t * 2. A new node was created but summarize was never called on it. This can mean that the summary that is\n\t\t * generated may not have the data from this node. We should not continue, log and throw an error. This\n\t\t * will help us identify these cases and take appropriate action.\n\t\t */\n\t\tif (localPathsToUse === undefined) {\n\t\t\tthis.throwUnexpectedError({\n\t\t\t\teventName: \"NodeNotSummarized\",\n\t\t\t\tproposalHandle,\n\t\t\t});\n\t\t}\n\n\t\tconst summary = new SummaryNode({\n\t\t\t...localPathsToUse,\n\t\t\treferenceSequenceNumber: this.wipReferenceSequenceNumber,\n\t\t\tbasePath: parentPath,\n\t\t});\n\t\tconst fullPathForChildren = summary.fullPathForChildren;\n\t\tfor (const child of this.children.values()) {\n\t\t\tchild.completeSummaryCore(\n\t\t\t\tproposalHandle,\n\t\t\t\tfullPathForChildren,\n\t\t\t\tthis.wipSkipRecursion || parentSkipRecursion,\n\t\t\t);\n\t\t}\n\t\t// Note that this overwrites existing pending summary with\n\t\t// the same proposalHandle. If proposalHandle is something like\n\t\t// a hash or unique identifier, this should be fine. If storage\n\t\t// can return the same proposalHandle for a different summary,\n\t\t// this should still be okay, because we should be proposing the\n\t\t// newer one later which would have to overwrite the previous one.\n\t\tthis.pendingSummaries.set(proposalHandle, summary);\n\t\tthis.clearSummary();\n\t}\n\n\tpublic clearSummary() {\n\t\tthis.wipReferenceSequenceNumber = undefined;\n\t\tthis.wipLocalPaths = undefined;\n\t\tthis.wipSkipRecursion = false;\n\t\tthis.wipSummaryLogger = undefined;\n\t\tfor (const child of this.children.values()) {\n\t\t\tchild.clearSummary();\n\t\t}\n\t}\n\n\t/**\n\t * Refreshes the latest summary tracked by this node. If we have a pending summary for the given proposal handle,\n\t * it becomes the latest summary. If the current summary is already ahead (e.g., loaded from a service summary),\n\t * we skip the update. Otherwise, we fetch the latest snapshot and update latest summary based off of that.\n\t *\n\t * @returns A RefreshSummaryResult type which returns information based on the following three scenarios:\n\t *\n\t * 1. The latest summary was not updated.\n\t *\n\t * 2. The latest summary was updated and the summary corresponding to the params was being tracked.\n\t *\n\t * 3. The latest summary was updated but the summary corresponding to the params was not tracked. In this\n\t * case, the latest summary is updated based on the downloaded snapshot which is also returned.\n\t */\n\tpublic async refreshLatestSummary(\n\t\tproposalHandle: string | undefined,\n\t\tsummaryRefSeq: number,\n\t\tfetchLatestSnapshot: () => Promise<IFetchSnapshotResult>,\n\t\treadAndParseBlob: ReadAndParseBlob,\n\t\tcorrelatedSummaryLogger: ITelemetryLogger,\n\t): Promise<RefreshSummaryResult> {\n\t\tconst eventProps: {\n\t\t\tproposalHandle: string | undefined;\n\t\t\tsummaryRefSeq: number;\n\t\t\treferenceSequenceNumber: number;\n\t\t\tlatestSummaryUpdated?: boolean;\n\t\t\twasSummaryTracked?: boolean;\n\t\t} = {\n\t\t\tproposalHandle,\n\t\t\tsummaryRefSeq,\n\t\t\treferenceSequenceNumber: this.referenceSequenceNumber,\n\t\t};\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"refreshLatestSummary\",\n\t\t\t\t...eventProps,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\t// Refresh latest summary should not happen while a summary is in progress. If it does, it can result\n\t\t\t\t// in inconsistent state, so, we should not continue;\n\t\t\t\tif (this.isSummaryInProgress()) {\n\t\t\t\t\tthrow new LoggingError(\"UnexpectedRefreshDuringSummarize\", {\n\t\t\t\t\t\tinProgressSummaryRefSeq: this.wipReferenceSequenceNumber,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (proposalHandle !== undefined) {\n\t\t\t\t\tconst maybeSummaryNode = this.pendingSummaries.get(proposalHandle);\n\n\t\t\t\t\tif (maybeSummaryNode !== undefined) {\n\t\t\t\t\t\tthis.refreshLatestSummaryFromPending(\n\t\t\t\t\t\t\tproposalHandle,\n\t\t\t\t\t\t\tmaybeSummaryNode.referenceSequenceNumber,\n\t\t\t\t\t\t);\n\t\t\t\t\t\teventProps.wasSummaryTracked = true;\n\t\t\t\t\t\teventProps.latestSummaryUpdated = true;\n\t\t\t\t\t\tevent.end(eventProps);\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tlatestSummaryUpdated: true,\n\t\t\t\t\t\t\twasSummaryTracked: true,\n\t\t\t\t\t\t\tsummaryRefSeq,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst props = {\n\t\t\t\t\t\tsummaryRefSeq,\n\t\t\t\t\t\tpendingSize: this.pendingSummaries.size ?? undefined,\n\t\t\t\t\t};\n\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"PendingSummaryNotFound\",\n\t\t\t\t\t\tproposalHandle,\n\t\t\t\t\t\treferenceSequenceNumber: this.referenceSequenceNumber,\n\t\t\t\t\t\tdetails: JSON.stringify(props),\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// If the summary for which refresh is called is older than the latest tracked summary, ignore it.\n\t\t\t\tif (this.referenceSequenceNumber >= summaryRefSeq) {\n\t\t\t\t\teventProps.latestSummaryUpdated = false;\n\t\t\t\t\tevent.end(eventProps);\n\t\t\t\t\treturn { latestSummaryUpdated: false };\n\t\t\t\t}\n\n\t\t\t\t// Fetch the latest snapshot and refresh state from it. Note that we need to use the reference sequence number\n\t\t\t\t// of the fetched snapshot and not the \"summaryRefSeq\" that was passed in.\n\t\t\t\tconst { snapshotTree, snapshotRefSeq: fetchedSnapshotRefSeq } =\n\t\t\t\t\tawait fetchLatestSnapshot();\n\n\t\t\t\t// Possible re-entrancy. We may have updated latest summary state while fetching the snapshot. If the fetched\n\t\t\t\t// snapshot is older than the latest tracked summary, ignore it.\n\t\t\t\tif (this.referenceSequenceNumber >= fetchedSnapshotRefSeq) {\n\t\t\t\t\teventProps.latestSummaryUpdated = false;\n\t\t\t\t\tevent.end(eventProps);\n\t\t\t\t\treturn { latestSummaryUpdated: false };\n\t\t\t\t}\n\n\t\t\t\tawait this.refreshLatestSummaryFromSnapshot(\n\t\t\t\t\tfetchedSnapshotRefSeq,\n\t\t\t\t\tsnapshotTree,\n\t\t\t\t\tundefined,\n\t\t\t\t\tEscapedPath.create(\"\"),\n\t\t\t\t\tcorrelatedSummaryLogger,\n\t\t\t\t\treadAndParseBlob,\n\t\t\t\t);\n\n\t\t\t\teventProps.latestSummaryUpdated = true;\n\t\t\t\teventProps.wasSummaryTracked = false;\n\t\t\t\teventProps.summaryRefSeq = fetchedSnapshotRefSeq;\n\t\t\t\tevent.end(eventProps);\n\t\t\t\treturn {\n\t\t\t\t\tlatestSummaryUpdated: true,\n\t\t\t\t\twasSummaryTracked: false,\n\t\t\t\t\tsnapshotTree,\n\t\t\t\t\tsummaryRefSeq: fetchedSnapshotRefSeq,\n\t\t\t\t};\n\t\t\t},\n\t\t\t{ start: true, end: true, cancel: \"error\" },\n\t\t);\n\t}\n\t/**\n\t * Called when we get an ack from the server for a summary we've just sent. Updates the reference state of this node\n\t * from the state in the pending summary queue.\n\t * @param proposalHandle - Handle for the current proposal.\n\t * @param referenceSequenceNumber - reference sequence number of sent summary.\n\t */\n\tprotected refreshLatestSummaryFromPending(\n\t\tproposalHandle: string,\n\t\treferenceSequenceNumber: number,\n\t): void {\n\t\tconst summaryNode = this.pendingSummaries.get(proposalHandle);\n\t\tif (summaryNode === undefined) {\n\t\t\t// This should only happen if parent skipped recursion AND no prior summary existed.\n\t\t\tassert(\n\t\t\t\tthis._latestSummary === undefined,\n\t\t\t\t0x1a6 /* \"Not found pending summary, but this node has previously completed a summary\" */,\n\t\t\t);\n\t\t\treturn;\n\t\t} else {\n\t\t\tassert(\n\t\t\t\treferenceSequenceNumber === summaryNode.referenceSequenceNumber,\n\t\t\t\t0x1a7 /* Pending summary reference sequence number should be consistent */,\n\t\t\t);\n\n\t\t\t// Clear earlier pending summaries\n\t\t\tthis.pendingSummaries.delete(proposalHandle);\n\t\t}\n\n\t\tthis.refreshLatestSummaryCore(referenceSequenceNumber);\n\n\t\tthis._latestSummary = summaryNode;\n\t\t// Propagate update to all child nodes\n\t\tfor (const child of this.children.values()) {\n\t\t\tchild.refreshLatestSummaryFromPending(proposalHandle, referenceSequenceNumber);\n\t\t}\n\t}\n\n\tprotected async refreshLatestSummaryFromSnapshot(\n\t\treferenceSequenceNumber: number,\n\t\tsnapshotTree: ISnapshotTree,\n\t\tbasePath: EscapedPath | undefined,\n\t\tlocalPath: EscapedPath,\n\t\tcorrelatedSummaryLogger: ITelemetryLogger,\n\t\treadAndParseBlob: ReadAndParseBlob,\n\t): Promise<void> {\n\t\t// Possible re-entrancy. If we have already seen a summary later than this one, ignore it.\n\t\tif (this.referenceSequenceNumber >= referenceSequenceNumber) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.refreshLatestSummaryCore(referenceSequenceNumber);\n\n\t\tthis._latestSummary = new SummaryNode({\n\t\t\treferenceSequenceNumber,\n\t\t\tbasePath,\n\t\t\tlocalPath,\n\t\t});\n\n\t\tconst pathParts: string[] = [];\n\t\tconst { childrenTree, childrenPathPart } = parseSummaryForSubtrees(snapshotTree);\n\t\tif (childrenPathPart !== undefined) {\n\t\t\tpathParts.push(childrenPathPart);\n\t\t}\n\n\t\tif (pathParts.length > 0) {\n\t\t\tthis._latestSummary.additionalPath = EscapedPath.createAndConcat(pathParts);\n\t\t}\n\n\t\t// Propagate update to all child nodes\n\t\tconst pathForChildren = this._latestSummary.fullPathForChildren;\n\t\tawait Promise.all(\n\t\t\tArray.from(this.children)\n\t\t\t\t.filter(([id]) => {\n\t\t\t\t\t// Assuming subtrees missing from snapshot are newer than the snapshot,\n\t\t\t\t\t// but might be nice to assert this using earliest seq for node.\n\t\t\t\t\treturn childrenTree.trees[id] !== undefined;\n\t\t\t\t})\n\t\t\t\t.map(async ([id, child]) => {\n\t\t\t\t\treturn child.refreshLatestSummaryFromSnapshot(\n\t\t\t\t\t\treferenceSequenceNumber,\n\t\t\t\t\t\tchildrenTree.trees[id],\n\t\t\t\t\t\tpathForChildren,\n\t\t\t\t\t\tEscapedPath.create(id),\n\t\t\t\t\t\tcorrelatedSummaryLogger,\n\t\t\t\t\t\treadAndParseBlob,\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t);\n\t}\n\n\tprivate refreshLatestSummaryCore(referenceSequenceNumber: number): void {\n\t\tfor (const [key, value] of this.pendingSummaries) {\n\t\t\tif (value.referenceSequenceNumber < referenceSequenceNumber) {\n\t\t\t\tthis.pendingSummaries.delete(key);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic updateBaseSummaryState(snapshot: ISnapshotTree) {\n\t\t// Check base summary to see if it has any additional path parts\n\t\t// separating child SummarizerNodes. Checks for .channels subtrees.\n\t\tconst { childrenPathPart } = parseSummaryForSubtrees(snapshot);\n\t\tif (childrenPathPart !== undefined && this._latestSummary !== undefined) {\n\t\t\tthis._latestSummary.additionalPath = EscapedPath.create(childrenPathPart);\n\t\t}\n\t}\n\n\tpublic recordChange(op: ISequencedDocumentMessage): void {\n\t\tthis.invalidate(op.sequenceNumber);\n\t}\n\n\tpublic invalidate(sequenceNumber: number): void {\n\t\tif (sequenceNumber > this._changeSequenceNumber) {\n\t\t\tthis._changeSequenceNumber = sequenceNumber;\n\t\t}\n\t}\n\n\t/**\n\t * True if a change has been recorded with sequence number exceeding\n\t * the latest successfully acked summary reference sequence number.\n\t * False implies that the previous summary can be reused.\n\t */\n\tprotected hasChanged(): boolean {\n\t\treturn this._changeSequenceNumber > this.referenceSequenceNumber;\n\t}\n\n\tpublic get latestSummary(): Readonly<SummaryNode> | undefined {\n\t\treturn this._latestSummary;\n\t}\n\n\tprotected readonly canReuseHandle: boolean;\n\n\tpublic createChild(\n\t\t/** Summarize function */\n\t\tsummarizeInternalFn: SummarizeInternalFn,\n\t\t/** Initial id or path part of this node */\n\t\tid: string,\n\t\t/**\n\t\t * Information needed to create the node.\n\t\t * If it is from a base summary, it will assert that a summary has been seen.\n\t\t * Attach information if it is created from an attach op.\n\t\t */\n\t\tcreateParam: CreateChildSummarizerNodeParam,\n\t\tconfig: ISummarizerNodeConfig = {},\n\t): ISummarizerNode {\n\t\tassert(!this.children.has(id), 0x1ab /* \"Create SummarizerNode child already exists\" */);\n\n\t\tconst createDetails: ICreateChildDetails = this.getCreateDetailsForChild(id, createParam);\n\t\tconst child = new SummarizerNode(\n\t\t\tthis.logger,\n\t\t\tsummarizeInternalFn,\n\t\t\tconfig,\n\t\t\tcreateDetails.changeSequenceNumber,\n\t\t\tcreateDetails.latestSummary,\n\t\t\tcreateDetails.initialSummary,\n\t\t\tthis.wipSummaryLogger,\n\t\t\tcreateDetails.telemetryNodeId,\n\t\t);\n\n\t\t// There may be additional state that has to be updated in this child. For example, if a summary is being\n\t\t// tracked, the child's summary tracking state needs to be updated too. Same goes for pendingSummaries we might\n\t\t// have outstanding on the parent in case we realize nodes in between Summary Op and Summary Ack.\n\t\tthis.maybeUpdateChildState(child);\n\n\t\tthis.children.set(id, child);\n\t\treturn child;\n\t}\n\n\tpublic getChild(id: string): ISummarizerNode | undefined {\n\t\treturn this.children.get(id);\n\t}\n\n\t/**\n\t * Returns the details needed to create a child node.\n\t * @param id - Initial id or path part of the child node.\n\t * @param createParam - Information needed to create the node.\n\t * @returns the details needed to create the child node.\n\t */\n\tprotected getCreateDetailsForChild(\n\t\tid: string,\n\t\tcreateParam: CreateChildSummarizerNodeParam,\n\t): ICreateChildDetails {\n\t\tlet initialSummary: IInitialSummary | undefined;\n\t\tlet latestSummary: SummaryNode | undefined;\n\t\tlet changeSequenceNumber: number;\n\n\t\tconst parentLatestSummary = this._latestSummary;\n\t\tswitch (createParam.type) {\n\t\t\tcase CreateSummarizerNodeSource.FromAttach: {\n\t\t\t\tif (\n\t\t\t\t\tparentLatestSummary !== undefined &&\n\t\t\t\t\tcreateParam.sequenceNumber <= parentLatestSummary.referenceSequenceNumber\n\t\t\t\t) {\n\t\t\t\t\t// Prioritize latest summary if it was after this node was attached.\n\t\t\t\t\tlatestSummary = parentLatestSummary.createForChild(id);\n\t\t\t\t} else {\n\t\t\t\t\tconst summary = convertToSummaryTree(\n\t\t\t\t\t\tcreateParam.snapshot,\n\t\t\t\t\t) as ISummaryTreeWithStats;\n\t\t\t\t\tinitialSummary = {\n\t\t\t\t\t\tsequenceNumber: createParam.sequenceNumber,\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tsummary,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tchangeSequenceNumber = createParam.sequenceNumber;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase CreateSummarizerNodeSource.FromSummary: {\n\t\t\t\tif (this.initialSummary === undefined) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!!parentLatestSummary,\n\t\t\t\t\t\t0x1ac /* \"Cannot create child from summary if parent does not have latest summary\" */,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// fallthrough to local\n\t\t\t}\n\t\t\tcase CreateSummarizerNodeSource.Local: {\n\t\t\t\tconst parentInitialSummary = this.initialSummary;\n\t\t\t\tif (parentInitialSummary !== undefined) {\n\t\t\t\t\tlet childSummary: SummaryObject | undefined;\n\t\t\t\t\tif (parentInitialSummary.summary !== undefined) {\n\t\t\t\t\t\tconst { childrenTree } = parseSummaryTreeForSubtrees(\n\t\t\t\t\t\t\tparentInitialSummary.summary.summary,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tchildrenTree.type === SummaryType.Tree,\n\t\t\t\t\t\t\t0x1d6 /* \"Parent summary object is not a tree\" */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tchildSummary = childrenTree.tree[id];\n\t\t\t\t\t}\n\t\t\t\t\tif (createParam.type === CreateSummarizerNodeSource.FromSummary) {\n\t\t\t\t\t\t// Locally created would not have differential subtree.\n\t\t\t\t\t\tassert(!!childSummary, 0x1ad /* \"Missing child summary tree\" */);\n\t\t\t\t\t}\n\t\t\t\t\tlet childSummaryWithStats: ISummaryTreeWithStats | undefined;\n\t\t\t\t\tif (childSummary !== undefined) {\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tchildSummary.type === SummaryType.Tree,\n\t\t\t\t\t\t\t0x1ae /* \"Child summary object is not a tree\" */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tchildSummaryWithStats = {\n\t\t\t\t\t\t\tsummary: childSummary,\n\t\t\t\t\t\t\tstats: calculateStats(childSummary),\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tinitialSummary = {\n\t\t\t\t\t\tsequenceNumber: parentInitialSummary.sequenceNumber,\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tsummary: childSummaryWithStats,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tlatestSummary = parentLatestSummary?.createForChild(id);\n\t\t\t\tchangeSequenceNumber = parentLatestSummary?.referenceSequenceNumber ?? -1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tconst type = (createParam as unknown as CreateChildSummarizerNodeParam).type;\n\t\t\t\tunreachableCase(createParam, `Unexpected CreateSummarizerNodeSource: ${type}`);\n\t\t\t}\n\t\t}\n\n\t\tconst childtelemetryNodeId = `${this.telemetryNodeId ?? \"\"}/${id}`;\n\n\t\treturn {\n\t\t\tinitialSummary,\n\t\t\tlatestSummary,\n\t\t\tchangeSequenceNumber,\n\t\t\ttelemetryNodeId: childtelemetryNodeId,\n\t\t};\n\t}\n\n\t/**\n\t * Updates the state of the child if required. For example, if a summary is currently being tracked, the child's\n\t * summary tracking state needs to be updated too.\n\t * Also, in case a child node gets realized in between Summary Op and Summary Ack, let's initialize the child's\n\t * pending summary as well.\n\t * @param child - The child node whose state is to be updated.\n\t */\n\tprotected maybeUpdateChildState(child: SummarizerNode) {\n\t\t// If a summary is in progress, this child was created after the summary started. So, we need to update the\n\t\t// child's summary state as well.\n\t\tif (this.isSummaryInProgress()) {\n\t\t\tchild.wipReferenceSequenceNumber = this.wipReferenceSequenceNumber;\n\t\t}\n\t\t// In case we have pending summaries on the parent, let's initialize it on the child.\n\t\tif (child._latestSummary !== undefined) {\n\t\t\tfor (const [key, value] of this.pendingSummaries.entries()) {\n\t\t\t\tconst newLatestSummaryNode = new SummaryNode({\n\t\t\t\t\treferenceSequenceNumber: value.referenceSequenceNumber,\n\t\t\t\t\tbasePath: child._latestSummary.basePath,\n\t\t\t\t\tlocalPath: child._latestSummary.localPath,\n\t\t\t\t});\n\n\t\t\t\tchild.addPendingSummary(key, newLatestSummaryNode);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected addPendingSummary(key: string, summary: SummaryNode) {\n\t\tthis.pendingSummaries.set(key, summary);\n\t}\n\n\t/**\n\t * Tells whether summary tracking is in progress. True if \"startSummary\" API is called before summarize.\n\t */\n\tpublic isSummaryInProgress(): boolean {\n\t\treturn this.wipReferenceSequenceNumber !== undefined;\n\t}\n\n\t/**\n\t * Creates and throws an error due to unexpected conditions.\n\t */\n\tprotected throwUnexpectedError(eventProps: ITelemetryErrorEvent): never {\n\t\tconst error = new LoggingError(eventProps.eventName, {\n\t\t\t...eventProps,\n\t\t\treferenceSequenceNumber: this.wipReferenceSequenceNumber,\n\t\t\tid: {\n\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\tvalue: this.telemetryNodeId,\n\t\t\t},\n\t\t});\n\t\tthis.logger.sendErrorEvent(eventProps, error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Creates a root summarizer node.\n * @param logger - Logger to use within SummarizerNode\n * @param summarizeInternalFn - Function to generate summary\n * @param changeSequenceNumber - Sequence number of latest change to new node/subtree\n * @param referenceSequenceNumber - Reference sequence number of last acked summary,\n * or undefined if not loaded from summary\n * @param config - Configure behavior of summarizer node\n *\n * @deprecated Internal implementation detail and will no longer be exported in an\n * upcoming release.\n */\nexport const createRootSummarizerNode = (\n\tlogger: ITelemetryLogger,\n\tsummarizeInternalFn: SummarizeInternalFn,\n\tchangeSequenceNumber: number,\n\treferenceSequenceNumber: number | undefined,\n\tconfig: ISummarizerNodeConfig = {},\n): IRootSummarizerNode =>\n\tnew SummarizerNode(\n\t\tlogger,\n\t\tsummarizeInternalFn,\n\t\tconfig,\n\t\tchangeSequenceNumber,\n\t\treferenceSequenceNumber === undefined\n\t\t\t? undefined\n\t\t\t: SummaryNode.createForRoot(referenceSequenceNumber),\n\t\tundefined /* initialSummary */,\n\t\tundefined /* wipSummaryLogger */,\n\t\t\"\" /* telemetryNodeId */,\n\t);\n"]}
|
|
@@ -15,6 +15,9 @@ import { ReadAndParseBlob } from "../utils";
|
|
|
15
15
|
*
|
|
16
16
|
* 3. The latest summary was updated but the summary corresponding to the params was not tracked. In this case, the
|
|
17
17
|
* latest snapshot is fetched and the latest summary state is updated based on it.
|
|
18
|
+
*
|
|
19
|
+
* @deprecated Internal implementation detail and will no longer be exported in an
|
|
20
|
+
* upcoming release.
|
|
18
21
|
*/
|
|
19
22
|
export declare type RefreshSummaryResult = {
|
|
20
23
|
latestSummaryUpdated: false;
|
|
@@ -30,11 +33,18 @@ export declare type RefreshSummaryResult = {
|
|
|
30
33
|
};
|
|
31
34
|
/**
|
|
32
35
|
* Result of snapshot fetch during refreshing latest summary state.
|
|
36
|
+
*
|
|
37
|
+
* @deprecated Internal implementation detail and will no longer be exported in an
|
|
38
|
+
* upcoming release.
|
|
33
39
|
*/
|
|
34
40
|
export interface IFetchSnapshotResult {
|
|
35
41
|
snapshotTree: ISnapshotTree;
|
|
36
42
|
snapshotRefSeq: number;
|
|
37
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Internal implementation detail and will no longer be exported in an
|
|
46
|
+
* upcoming release.
|
|
47
|
+
*/
|
|
38
48
|
export interface ISummarizerNodeRootContract {
|
|
39
49
|
startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLogger): void;
|
|
40
50
|
completeSummary(proposalHandle: string): void;
|
|
@@ -83,20 +93,6 @@ export declare class SummaryNode {
|
|
|
83
93
|
*/
|
|
84
94
|
createForChild(id: string): SummaryNode;
|
|
85
95
|
}
|
|
86
|
-
/**
|
|
87
|
-
* Parameter to help encode summary with conditional behavior.
|
|
88
|
-
* When fromSummary is true, it will contain the SummaryNode of
|
|
89
|
-
* its previous summary, which it can use to point to with a handle.
|
|
90
|
-
* When fromSummary is false, it will use an actual summary tree
|
|
91
|
-
* as its base summary in case the first summary is a differential summary.
|
|
92
|
-
*/
|
|
93
|
-
export declare type EncodeSummaryParam = {
|
|
94
|
-
fromSummary: true;
|
|
95
|
-
summaryNode: SummaryNode;
|
|
96
|
-
} | {
|
|
97
|
-
fromSummary: false;
|
|
98
|
-
initialSummary: ISummaryTreeWithStats;
|
|
99
|
-
};
|
|
100
96
|
/**
|
|
101
97
|
* Information about the initial summary tree found from an attach op.
|
|
102
98
|
*/
|
|
@@ -115,6 +111,8 @@ export interface ICreateChildDetails {
|
|
|
115
111
|
latestSummary: SummaryNode | undefined;
|
|
116
112
|
/** Sequence number of latest known change to the node */
|
|
117
113
|
changeSequenceNumber: number;
|
|
114
|
+
/** A unique id of this child to be logged when sending telemetry. */
|
|
115
|
+
telemetryNodeId: string;
|
|
118
116
|
}
|
|
119
117
|
export interface ISubtreeInfo<T extends ISnapshotTree | SummaryObject> {
|
|
120
118
|
/** Tree to use to find children subtrees */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summarizerNodeUtils.d.ts","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNodeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,
|
|
1
|
+
{"version":3,"file":"summarizerNodeUtils.d.ts","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNodeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,M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B,OAAO,IAAI,CAAC,cAAc,KAAK,SAAS;YACpC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC;YAC3C,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;IACxB,CAAC;IAED;;;OAGG;IACI,cAAc,CAAC,EAAU;QAC5B,OAAO,IAAI,WAAW,CAAC;YACnB,uBAAuB,EAAE,IAAI,CAAC,uBAAuB;YACrD,QAAQ,EAAE,IAAI,CAAC,mBAAmB;YAClC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;SACpC,CAAC,CAAC;IACP,CAAC;CACJ;AA6CD;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,WAA0B;IAC9D,2EAA2E;IAC3E,MAAM,eAAe,GAAG,WAAW,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAC5D,IAAI,eAAe,KAAK,SAAS,EAAE;QAC/B,OAAO;YACH,YAAY,EAAE,eAAe;YAC7B,gBAAgB,EAAE,gBAAgB;SACrC,CAAC;KACL;IACD,OAAO;QACH,YAAY,EAAE,WAAW;QACzB,gBAAgB,EAAE,SAAS;KAC9B,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,OAAqB;IAC7D,2EAA2E;IAC3E,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACvD,IAAI,eAAe,KAAK,SAAS,EAAE;QAC/B,OAAO;YACH,YAAY,EAAE,eAAe;YAC7B,gBAAgB,EAAE,gBAAgB;SACrC,CAAC;KACL;IACD,OAAO;QACH,YAAY,EAAE,OAAO;QACrB,gBAAgB,EAAE,SAAS;KAC9B,CAAC;AACN,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n ISnapshotTree,\n ISummaryTree,\n SummaryObject,\n} from \"@fluidframework/protocol-definitions\";\nimport { channelsTreeName, ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { ReadAndParseBlob } from \"../utils\";\n\n/**\n * Return type of refreshSummaryAck function. There can be three different scenarios based on the passed params:\n *\n * 1. The latest summary was not updated.\n *\n * 2. The latest summary was updated and the summary corresponding to the params was tracked by this client.\n *\n * 3. The latest summary was updated but the summary corresponding to the params was not tracked. In this case, the\n * latest snapshot is fetched and the latest summary state is updated based on it.\n */\nexport type RefreshSummaryResult = {\n latestSummaryUpdated: false;\n} | {\n latestSummaryUpdated: true;\n wasSummaryTracked: true;\n summaryRefSeq: number;\n} | {\n latestSummaryUpdated: true;\n wasSummaryTracked: false;\n snapshotTree: ISnapshotTree;\n summaryRefSeq: number;\n};\n\n/**\n * Result of snapshot fetch during refreshing latest summary state.\n */\nexport interface IFetchSnapshotResult {\n snapshotTree: ISnapshotTree;\n snapshotRefSeq: number;\n}\n\nexport interface ISummarizerNodeRootContract {\n startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLogger): void;\n completeSummary(proposalHandle: string): void;\n clearSummary(): void;\n refreshLatestSummary(\n proposalHandle: string | undefined,\n summaryRefSeq: number,\n fetchLatestSnapshot: () => Promise<IFetchSnapshotResult>,\n readAndParseBlob: ReadAndParseBlob,\n correlatedSummaryLogger: ITelemetryLogger,\n ): Promise<RefreshSummaryResult>;\n}\n\n/** Path for nodes in a tree with escaped special characters */\nexport class EscapedPath {\n private constructor(public readonly path: string) { }\n public static create(path: string): EscapedPath {\n return new EscapedPath(encodeURIComponent(path));\n }\n public static createAndConcat(pathParts: string[]): EscapedPath {\n let ret = EscapedPath.create(pathParts[0] ?? \"\");\n for (let i = 1; i < pathParts.length; i++) {\n ret = ret.concat(EscapedPath.create(pathParts[i]));\n }\n return ret;\n }\n public toString(): string {\n return this.path;\n }\n public concat(path: EscapedPath): EscapedPath {\n return new EscapedPath(`${this.path}/${path.path}`);\n }\n}\n\n/** Information about a summary relevant to a specific node in the tree */\nexport class SummaryNode {\n /** Creates an instance that is valid for the root with specific basePath and localPath */\n public static createForRoot(referenceSequenceNumber: number): SummaryNode {\n return new SummaryNode({\n referenceSequenceNumber,\n basePath: undefined,\n localPath: EscapedPath.create(\"\"), // root hard-coded to \"\"\n });\n }\n\n /** Summary reference sequence number, i.e. last sequence number seen when it was created */\n public get referenceSequenceNumber(): number {\n return this.summary.referenceSequenceNumber;\n }\n /** Full path to parent node, or undefined if this is the root */\n public get basePath(): EscapedPath | undefined {\n return this.summary.basePath;\n }\n /** Relative path to this node from its parent node */\n public get localPath(): EscapedPath {\n return this.summary.localPath;\n }\n /** Relative path from this node to its node innermost base summary */\n public get additionalPath(): EscapedPath | undefined {\n return this.summary.additionalPath;\n }\n public set additionalPath(additionalPath: EscapedPath | undefined) {\n this.summary.additionalPath = additionalPath;\n }\n constructor(private readonly summary: {\n readonly referenceSequenceNumber: number;\n readonly basePath: EscapedPath | undefined;\n readonly localPath: EscapedPath;\n additionalPath?: EscapedPath;\n }) { }\n\n /** Gets the full path to this node, to be used when sending a handle */\n public get fullPath(): EscapedPath {\n return this.basePath?.concat(this.localPath) ?? this.localPath;\n }\n\n /**\n * Gets the full path to this node's innermost base summary.\n * The children nodes can use this as their basePath to determine their path.\n */\n public get fullPathForChildren(): EscapedPath {\n return this.additionalPath !== undefined\n ? this.fullPath.concat(this.additionalPath)\n : this.fullPath;\n }\n\n /**\n * Creates a new node within the same summary for a child of this node.\n * @param id - id of the child node\n */\n public createForChild(id: string): SummaryNode {\n return new SummaryNode({\n referenceSequenceNumber: this.referenceSequenceNumber,\n basePath: this.fullPathForChildren,\n localPath: EscapedPath.create(id),\n });\n }\n}\n\n/**\n * Parameter to help encode summary with conditional behavior.\n * When fromSummary is true, it will contain the SummaryNode of\n * its previous summary, which it can use to point to with a handle.\n * When fromSummary is false, it will use an actual summary tree\n * as its base summary in case the first summary is a differential summary.\n */\nexport type EncodeSummaryParam = {\n fromSummary: true;\n summaryNode: SummaryNode;\n} | {\n fromSummary: false;\n initialSummary: ISummaryTreeWithStats;\n};\n\n/**\n * Information about the initial summary tree found from an attach op.\n */\nexport interface IInitialSummary {\n sequenceNumber: number;\n id: string;\n summary: ISummaryTreeWithStats | undefined;\n}\n\n/**\n * Represents the details needed to create a child summarizer node.\n */\nexport interface ICreateChildDetails {\n /** Summary from attach op if known */\n initialSummary: IInitialSummary | undefined;\n /** Latest summary from server node data */\n latestSummary: SummaryNode | undefined;\n /** Sequence number of latest known change to the node */\n changeSequenceNumber: number;\n}\n\nexport interface ISubtreeInfo<T extends ISnapshotTree | SummaryObject> {\n /** Tree to use to find children subtrees */\n childrenTree: T;\n /** Additional path part where children are isolated */\n childrenPathPart: string | undefined;\n}\n\n/**\n * Checks if the summary contains .channels subtree where the children subtrees\n * would be located if exists.\n * @param baseSummary - summary to check\n */\nexport function parseSummaryForSubtrees(baseSummary: ISnapshotTree): ISubtreeInfo<ISnapshotTree> {\n // New versions of snapshots have child nodes isolated in .channels subtree\n const channelsSubtree = baseSummary.trees[channelsTreeName];\n if (channelsSubtree !== undefined) {\n return {\n childrenTree: channelsSubtree,\n childrenPathPart: channelsTreeName,\n };\n }\n return {\n childrenTree: baseSummary,\n childrenPathPart: undefined,\n };\n}\n\n/**\n * Checks if the summary contains .channels subtree where the children subtrees\n * would be located if exists.\n * @param baseSummary - summary to check\n */\nexport function parseSummaryTreeForSubtrees(summary: ISummaryTree): ISubtreeInfo<SummaryObject> {\n // New versions of snapshots have child nodes isolated in .channels subtree\n const channelsSubtree = summary.tree[channelsTreeName];\n if (channelsSubtree !== undefined) {\n return {\n childrenTree: channelsSubtree,\n childrenPathPart: channelsTreeName,\n };\n }\n return {\n childrenTree: summary,\n childrenPathPart: undefined,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"summarizerNodeUtils.js","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNodeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,E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AY,EAAE,eAAe;YAC7B,gBAAgB,EAAE,gBAAgB;SAClC,CAAC;KACF;IACD,OAAO;QACN,YAAY,EAAE,WAAW;QACzB,gBAAgB,EAAE,SAAS;KAC3B,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,OAAqB;IAChE,2EAA2E;IAC3E,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACvD,IAAI,eAAe,KAAK,SAAS,EAAE;QAClC,OAAO;YACN,YAAY,EAAE,eAAe;YAC7B,gBAAgB,EAAE,gBAAgB;SAClC,CAAC;KACF;IACD,OAAO;QACN,YAAY,EAAE,OAAO;QACrB,gBAAgB,EAAE,SAAS;KAC3B,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { ISnapshotTree, ISummaryTree, SummaryObject } from \"@fluidframework/protocol-definitions\";\nimport { channelsTreeName, ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { ReadAndParseBlob } from \"../utils\";\n\n/**\n * Return type of refreshSummaryAck function. There can be three different scenarios based on the passed params:\n *\n * 1. The latest summary was not updated.\n *\n * 2. The latest summary was updated and the summary corresponding to the params was tracked by this client.\n *\n * 3. The latest summary was updated but the summary corresponding to the params was not tracked. In this case, the\n * latest snapshot is fetched and the latest summary state is updated based on it.\n *\n * @deprecated Internal implementation detail and will no longer be exported in an\n * upcoming release.\n */\nexport type RefreshSummaryResult =\n\t| {\n\t\t\tlatestSummaryUpdated: false;\n\t }\n\t| {\n\t\t\tlatestSummaryUpdated: true;\n\t\t\twasSummaryTracked: true;\n\t\t\tsummaryRefSeq: number;\n\t }\n\t| {\n\t\t\tlatestSummaryUpdated: true;\n\t\t\twasSummaryTracked: false;\n\t\t\tsnapshotTree: ISnapshotTree;\n\t\t\tsummaryRefSeq: number;\n\t };\n\n/**\n * Result of snapshot fetch during refreshing latest summary state.\n *\n * @deprecated Internal implementation detail and will no longer be exported in an\n * upcoming release.\n */\nexport interface IFetchSnapshotResult {\n\tsnapshotTree: ISnapshotTree;\n\tsnapshotRefSeq: number;\n}\n\n/**\n * @deprecated Internal implementation detail and will no longer be exported in an\n * upcoming release.\n */\nexport interface ISummarizerNodeRootContract {\n\tstartSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLogger): void;\n\tcompleteSummary(proposalHandle: string): void;\n\tclearSummary(): void;\n\trefreshLatestSummary(\n\t\tproposalHandle: string | undefined,\n\t\tsummaryRefSeq: number,\n\t\tfetchLatestSnapshot: () => Promise<IFetchSnapshotResult>,\n\t\treadAndParseBlob: ReadAndParseBlob,\n\t\tcorrelatedSummaryLogger: ITelemetryLogger,\n\t): Promise<RefreshSummaryResult>;\n}\n\n/** Path for nodes in a tree with escaped special characters */\nexport class EscapedPath {\n\tprivate constructor(public readonly path: string) {}\n\tpublic static create(path: string): EscapedPath {\n\t\treturn new EscapedPath(encodeURIComponent(path));\n\t}\n\tpublic static createAndConcat(pathParts: string[]): EscapedPath {\n\t\tlet ret = EscapedPath.create(pathParts[0] ?? \"\");\n\t\tfor (let i = 1; i < pathParts.length; i++) {\n\t\t\tret = ret.concat(EscapedPath.create(pathParts[i]));\n\t\t}\n\t\treturn ret;\n\t}\n\tpublic toString(): string {\n\t\treturn this.path;\n\t}\n\tpublic concat(path: EscapedPath): EscapedPath {\n\t\treturn new EscapedPath(`${this.path}/${path.path}`);\n\t}\n}\n\n/** Information about a summary relevant to a specific node in the tree */\nexport class SummaryNode {\n\t/** Creates an instance that is valid for the root with specific basePath and localPath */\n\tpublic static createForRoot(referenceSequenceNumber: number): SummaryNode {\n\t\treturn new SummaryNode({\n\t\t\treferenceSequenceNumber,\n\t\t\tbasePath: undefined,\n\t\t\tlocalPath: EscapedPath.create(\"\"), // root hard-coded to \"\"\n\t\t});\n\t}\n\n\t/** Summary reference sequence number, i.e. last sequence number seen when it was created */\n\tpublic get referenceSequenceNumber(): number {\n\t\treturn this.summary.referenceSequenceNumber;\n\t}\n\t/** Full path to parent node, or undefined if this is the root */\n\tpublic get basePath(): EscapedPath | undefined {\n\t\treturn this.summary.basePath;\n\t}\n\t/** Relative path to this node from its parent node */\n\tpublic get localPath(): EscapedPath {\n\t\treturn this.summary.localPath;\n\t}\n\t/** Relative path from this node to its node innermost base summary */\n\tpublic get additionalPath(): EscapedPath | undefined {\n\t\treturn this.summary.additionalPath;\n\t}\n\tpublic set additionalPath(additionalPath: EscapedPath | undefined) {\n\t\tthis.summary.additionalPath = additionalPath;\n\t}\n\tconstructor(\n\t\tprivate readonly summary: {\n\t\t\treadonly referenceSequenceNumber: number;\n\t\t\treadonly basePath: EscapedPath | undefined;\n\t\t\treadonly localPath: EscapedPath;\n\t\t\tadditionalPath?: EscapedPath;\n\t\t},\n\t) {}\n\n\t/** Gets the full path to this node, to be used when sending a handle */\n\tpublic get fullPath(): EscapedPath {\n\t\treturn this.basePath?.concat(this.localPath) ?? this.localPath;\n\t}\n\n\t/**\n\t * Gets the full path to this node's innermost base summary.\n\t * The children nodes can use this as their basePath to determine their path.\n\t */\n\tpublic get fullPathForChildren(): EscapedPath {\n\t\treturn this.additionalPath !== undefined\n\t\t\t? this.fullPath.concat(this.additionalPath)\n\t\t\t: this.fullPath;\n\t}\n\n\t/**\n\t * Creates a new node within the same summary for a child of this node.\n\t * @param id - id of the child node\n\t */\n\tpublic createForChild(id: string): SummaryNode {\n\t\treturn new SummaryNode({\n\t\t\treferenceSequenceNumber: this.referenceSequenceNumber,\n\t\t\tbasePath: this.fullPathForChildren,\n\t\t\tlocalPath: EscapedPath.create(id),\n\t\t});\n\t}\n}\n\n/**\n * Information about the initial summary tree found from an attach op.\n */\nexport interface IInitialSummary {\n\tsequenceNumber: number;\n\tid: string;\n\tsummary: ISummaryTreeWithStats | undefined;\n}\n\n/**\n * Represents the details needed to create a child summarizer node.\n */\nexport interface ICreateChildDetails {\n\t/** Summary from attach op if known */\n\tinitialSummary: IInitialSummary | undefined;\n\t/** Latest summary from server node data */\n\tlatestSummary: SummaryNode | undefined;\n\t/** Sequence number of latest known change to the node */\n\tchangeSequenceNumber: number;\n\t/** A unique id of this child to be logged when sending telemetry. */\n\ttelemetryNodeId: string;\n}\n\nexport interface ISubtreeInfo<T extends ISnapshotTree | SummaryObject> {\n\t/** Tree to use to find children subtrees */\n\tchildrenTree: T;\n\t/** Additional path part where children are isolated */\n\tchildrenPathPart: string | undefined;\n}\n\n/**\n * Checks if the summary contains .channels subtree where the children subtrees\n * would be located if exists.\n * @param baseSummary - summary to check\n */\nexport function parseSummaryForSubtrees(baseSummary: ISnapshotTree): ISubtreeInfo<ISnapshotTree> {\n\t// New versions of snapshots have child nodes isolated in .channels subtree\n\tconst channelsSubtree = baseSummary.trees[channelsTreeName];\n\tif (channelsSubtree !== undefined) {\n\t\treturn {\n\t\t\tchildrenTree: channelsSubtree,\n\t\t\tchildrenPathPart: channelsTreeName,\n\t\t};\n\t}\n\treturn {\n\t\tchildrenTree: baseSummary,\n\t\tchildrenPathPart: undefined,\n\t};\n}\n\n/**\n * Checks if the summary contains .channels subtree where the children subtrees\n * would be located if exists.\n * @param baseSummary - summary to check\n */\nexport function parseSummaryTreeForSubtrees(summary: ISummaryTree): ISubtreeInfo<SummaryObject> {\n\t// New versions of snapshots have child nodes isolated in .channels subtree\n\tconst channelsSubtree = summary.tree[channelsTreeName];\n\tif (channelsSubtree !== undefined) {\n\t\treturn {\n\t\t\tchildrenTree: channelsSubtree,\n\t\t\tchildrenPathPart: channelsTreeName,\n\t\t};\n\t}\n\treturn {\n\t\tchildrenTree: summary,\n\t\tchildrenPathPart: undefined,\n\t};\n}\n"]}
|