@fluidframework/runtime-utils 0.52.1 → 0.53.0-46105
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/dataStoreHelpers.d.ts +0 -1
- package/dist/dataStoreHelpers.d.ts.map +1 -1
- package/dist/dataStoreHelpers.js +18 -31
- package/dist/dataStoreHelpers.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/remoteObjectHandle.d.ts +0 -4
- package/dist/remoteObjectHandle.d.ts.map +1 -1
- package/dist/remoteObjectHandle.js +0 -6
- package/dist/remoteObjectHandle.js.map +1 -1
- package/dist/summarizerNode/summarizerNodeWithGc.d.ts +1 -13
- package/dist/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
- package/dist/summarizerNode/summarizerNodeWithGc.js +3 -73
- package/dist/summarizerNode/summarizerNodeWithGc.js.map +1 -1
- package/lib/dataStoreHelpers.d.ts +0 -1
- package/lib/dataStoreHelpers.d.ts.map +1 -1
- package/lib/dataStoreHelpers.js +17 -29
- package/lib/dataStoreHelpers.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/remoteObjectHandle.d.ts +0 -4
- package/lib/remoteObjectHandle.d.ts.map +1 -1
- package/lib/remoteObjectHandle.js +0 -6
- package/lib/remoteObjectHandle.js.map +1 -1
- package/lib/summarizerNode/summarizerNodeWithGc.d.ts +1 -13
- package/lib/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
- package/lib/summarizerNode/summarizerNodeWithGc.js +4 -74
- package/lib/summarizerNode/summarizerNodeWithGc.js.map +1 -1
- package/package.json +9 -8
- package/src/dataStoreHelpers.ts +24 -29
- package/src/packageVersion.ts +1 -1
- package/src/remoteObjectHandle.ts +0 -7
- package/src/summarizerNode/summarizerNodeWithGc.ts +3 -92
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { FluidObject, IFluidObject, IFluidRouter, IRequest, IResponse } from "@fluidframework/core-interfaces";
|
|
6
6
|
import { IFluidDataStoreFactory, IFluidDataStoreRegistry, IProvideFluidDataStoreRegistry } from "@fluidframework/runtime-definitions";
|
|
7
|
-
export declare function getStack(): string | undefined;
|
|
8
7
|
export declare function exceptionToResponse(err: any): IResponse;
|
|
9
8
|
export declare function responseToException(response: IResponse, request: IRequest): Error;
|
|
10
9
|
export declare function requestFluidObject<T = IFluidObject & FluidObject>(router: IFluidRouter, url: string | IRequest): Promise<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataStoreHelpers.d.ts","sourceRoot":"","sources":["../src/dataStoreHelpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,SAAS,EACZ,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,EACjC,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"dataStoreHelpers.d.ts","sourceRoot":"","sources":["../src/dataStoreHelpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,SAAS,EACZ,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,EACjC,MAAM,qCAAqC,CAAC;AAU7C,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,GAAG,GAAG,SAAS,CAsBvD;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,GAAG,KAAK,CAYjF;AAED,wBAAsB,kBAAkB,CAAC,CAAC,GAAG,YAAY,GAAG,WAAW,EACnE,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAU5D;AAED,eAAO,MAAM,iBAAiB,YAAa,QAAQ,cAAmD,CAAC;AAEvG,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,SAAS,CAc/F;AAED,oBAAY,OAAO,GAAG,sBAAsB,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAGvF,wBAAgB,sBAAsB,CAClC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAChC,sBAAsB,GAAG,uBAAuB,CAStD"}
|
package/dist/dataStoreHelpers.js
CHANGED
|
@@ -4,23 +4,10 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.createDataStoreFactory = exports.createResponseError = exports.create404Response = exports.requestFluidObject = exports.responseToException = exports.exceptionToResponse =
|
|
7
|
+
exports.createDataStoreFactory = exports.createResponseError = exports.create404Response = exports.requestFluidObject = exports.responseToException = exports.exceptionToResponse = void 0;
|
|
8
8
|
const common_utils_1 = require("@fluidframework/common-utils");
|
|
9
|
-
|
|
10
|
-
const err = new Error();
|
|
11
|
-
if (err.stack !== undefined) {
|
|
12
|
-
return err.stack;
|
|
13
|
-
}
|
|
14
|
-
try {
|
|
15
|
-
throw err;
|
|
16
|
-
}
|
|
17
|
-
catch (err2) {
|
|
18
|
-
return err2.stack;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.getStack = getStack;
|
|
9
|
+
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
22
10
|
function exceptionToResponse(err) {
|
|
23
|
-
var _a;
|
|
24
11
|
const status = 500;
|
|
25
12
|
// eslint-disable-next-line no-null/no-null
|
|
26
13
|
if (err !== null && typeof err === "object" && err.errorFromRequestFluidObject === true) {
|
|
@@ -29,32 +16,30 @@ function exceptionToResponse(err) {
|
|
|
29
16
|
mimeType: "text/plain",
|
|
30
17
|
status: responseErr.code,
|
|
31
18
|
value: responseErr.message,
|
|
32
|
-
stack
|
|
19
|
+
get stack() { return responseErr.stack; },
|
|
33
20
|
};
|
|
34
21
|
}
|
|
22
|
+
// Capture error objects, not stack itself, as stack retrieval is very expensive operation, so we delay it
|
|
23
|
+
const errWithStack = telemetry_utils_1.generateErrorWithStack();
|
|
35
24
|
return {
|
|
36
25
|
mimeType: "text/plain",
|
|
37
26
|
status,
|
|
38
27
|
value: `${err}`,
|
|
39
|
-
stack:
|
|
28
|
+
get stack() { var _a; return (_a = (err === null || err === void 0 ? void 0 : err.stack)) !== null && _a !== void 0 ? _a : errWithStack.stack; },
|
|
40
29
|
};
|
|
41
30
|
}
|
|
42
31
|
exports.exceptionToResponse = exceptionToResponse;
|
|
43
32
|
function responseToException(response, request) {
|
|
44
33
|
const message = response.value;
|
|
45
|
-
const
|
|
46
|
-
const responseErr =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
catch (err2) { }
|
|
56
|
-
}
|
|
57
|
-
return err;
|
|
34
|
+
const errWithStack = telemetry_utils_1.generateErrorWithStack();
|
|
35
|
+
const responseErr = {
|
|
36
|
+
errorFromRequestFluidObject: true,
|
|
37
|
+
message,
|
|
38
|
+
name: "Error",
|
|
39
|
+
code: response.status,
|
|
40
|
+
get stack() { var _a; return (_a = response.stack) !== null && _a !== void 0 ? _a : errWithStack.stack; },
|
|
41
|
+
};
|
|
42
|
+
return responseErr;
|
|
58
43
|
}
|
|
59
44
|
exports.responseToException = responseToException;
|
|
60
45
|
async function requestFluidObject(router, url) {
|
|
@@ -74,11 +59,13 @@ function createResponseError(status, value, request) {
|
|
|
74
59
|
common_utils_1.assert(status !== 200, 0x19b /* "Cannot not create response error on 200 status" */);
|
|
75
60
|
// Omit query string which could contain personal data (aka "PII")
|
|
76
61
|
const urlNoQuery = (_a = request.url) === null || _a === void 0 ? void 0 : _a.split("?")[0];
|
|
62
|
+
// Capture error objects, not stack itself, as stack retrieval is very expensive operation, so we delay it
|
|
63
|
+
const errWithStack = telemetry_utils_1.generateErrorWithStack();
|
|
77
64
|
return {
|
|
78
65
|
mimeType: "text/plain",
|
|
79
66
|
status,
|
|
80
67
|
value: urlNoQuery === undefined ? value : `${value}: ${urlNoQuery}`,
|
|
81
|
-
stack
|
|
68
|
+
get stack() { return errWithStack.stack; },
|
|
82
69
|
};
|
|
83
70
|
}
|
|
84
71
|
exports.createResponseError = createResponseError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataStoreHelpers.js","sourceRoot":"","sources":["../src/dataStoreHelpers.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;
|
|
1
|
+
{"version":3,"file":"dataStoreHelpers.js","sourceRoot":"","sources":["../src/dataStoreHelpers.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAatD,qEAAyE;AASzE,SAAgB,mBAAmB,CAAC,GAAQ;IACxC,MAAM,MAAM,GAAG,GAAG,CAAC;IACnB,2CAA2C;IAC3C,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,2BAA2B,KAAK,IAAI,EAAE;QACrF,MAAM,WAAW,GAAuB,GAAG,CAAC;QAC5C,OAAO;YACH,QAAQ,EAAE,YAAY;YACtB,MAAM,EAAE,WAAW,CAAC,IAAI;YACxB,KAAK,EAAE,WAAW,CAAC,OAAO;YAC1B,IAAI,KAAK,KAAK,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;SAC5C,CAAC;KACL;IAED,0GAA0G;IAC1G,MAAM,YAAY,GAAG,wCAAsB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oft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport {\n FluidObject,\n IFluidObject,\n IFluidRouter,\n IRequest,\n IResponse,\n} from \"@fluidframework/core-interfaces\";\nimport {\n IFluidDataStoreFactory,\n IFluidDataStoreRegistry,\n IProvideFluidDataStoreRegistry,\n} from \"@fluidframework/runtime-definitions\";\nimport { generateErrorWithStack } from \"@fluidframework/telemetry-utils\";\n\ninterface IResponseException extends Error {\n errorFromRequestFluidObject: true;\n message: string;\n code: number;\n stack?: string;\n}\n\nexport function exceptionToResponse(err: any): IResponse {\n const status = 500;\n // eslint-disable-next-line no-null/no-null\n if (err !== null && typeof err === \"object\" && err.errorFromRequestFluidObject === true) {\n const responseErr: IResponseException = err;\n return {\n mimeType: \"text/plain\",\n status: responseErr.code,\n value: responseErr.message,\n get stack() { return responseErr.stack; },\n };\n }\n\n // Capture error objects, not stack itself, as stack retrieval is very expensive operation, so we delay it\n const errWithStack = generateErrorWithStack();\n\n return {\n mimeType: \"text/plain\",\n status,\n value: `${err}`,\n get stack() { return ((err?.stack) as (string|undefined)) ?? errWithStack.stack; },\n };\n}\n\nexport function responseToException(response: IResponse, request: IRequest): Error {\n const message = response.value;\n const errWithStack = generateErrorWithStack();\n const responseErr: Error & IResponseException = {\n errorFromRequestFluidObject: true,\n message,\n name: \"Error\",\n code: response.status,\n get stack() { return response.stack ?? errWithStack.stack; },\n };\n\n return responseErr;\n}\n\nexport async function requestFluidObject<T = IFluidObject & FluidObject>(\n router: IFluidRouter, url: string | IRequest): Promise<T> {\n const request = typeof url === \"string\" ? { url } : url;\n const response = await router.request(request);\n\n if (response.status !== 200 || response.mimeType !== \"fluid/object\") {\n throw responseToException(response, request);\n }\n\n assert(response.value, 0x19a /* \"Invalid response value for Fluid object request\" */);\n return response.value as T;\n}\n\nexport const create404Response = (request: IRequest) => createResponseError(404, \"not found\", request);\n\nexport function createResponseError(status: number, value: string, request: IRequest): IResponse {\n assert(status !== 200, 0x19b /* \"Cannot not create response error on 200 status\" */);\n // Omit query string which could contain personal data (aka \"PII\")\n const urlNoQuery = request.url?.split(\"?\")[0];\n\n // Capture error objects, not stack itself, as stack retrieval is very expensive operation, so we delay it\n const errWithStack = generateErrorWithStack();\n\n return {\n mimeType: \"text/plain\",\n status,\n value: urlNoQuery === undefined ? value : `${value}: ${urlNoQuery}`,\n get stack() { return errWithStack.stack; },\n };\n}\n\nexport type Factory = IFluidDataStoreFactory & Partial<IProvideFluidDataStoreRegistry>;\n\n// eslint-disable-next-line prefer-arrow/prefer-arrow-functions\nexport function createDataStoreFactory(\n type: string,\n factory: Factory | Promise<Factory>,\n ): IFluidDataStoreFactory & IFluidDataStoreRegistry\n{\n return {\n type,\n get IFluidDataStoreFactory() { return this; },\n get IFluidDataStoreRegistry() { return this; },\n instantiateDataStore: async (context, existing) => (await factory).instantiateDataStore(context, existing),\n get: async (name: string) => (await factory).IFluidDataStoreRegistry?.get(name),\n };\n}\n"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/runtime-utils";
|
|
8
|
-
export declare const pkgVersion = "0.
|
|
8
|
+
export declare const pkgVersion = "0.53.0-46105";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,kCAAkC,CAAC;AACvD,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,kCAAkC,CAAC;AACvD,eAAO,MAAM,UAAU,iBAAiB,CAAC"}
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/runtime-utils";
|
|
11
|
-
exports.pkgVersion = "0.
|
|
11
|
+
exports.pkgVersion = "0.53.0-46105";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,+BAA+B,CAAC;AAC1C,QAAA,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,+BAA+B,CAAC;AAC1C,QAAA,UAAU,GAAG,cAAc,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/runtime-utils\";\nexport const pkgVersion = \"0.53.0-46105\";\n"]}
|
|
@@ -24,10 +24,6 @@ export declare class RemoteFluidObjectHandle implements IFluidHandle {
|
|
|
24
24
|
* @param routeContext - The root IFluidHandleContext that has a route to this handle.
|
|
25
25
|
*/
|
|
26
26
|
constructor(absolutePath: string, routeContext: IFluidHandleContext);
|
|
27
|
-
/**
|
|
28
|
-
* @deprecated - This returns the absolute path.
|
|
29
|
-
*/
|
|
30
|
-
get path(): string;
|
|
31
27
|
get(): Promise<any>;
|
|
32
28
|
attachGraph(): void;
|
|
33
29
|
bind(handle: IFluidHandle): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteObjectHandle.d.ts","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,YAAY,EACZ,mBAAmB,EACnB,QAAQ,EACR,SAAS,EAGZ,MAAM,iCAAiC,CAAC;AAGzC;;;;;;GAMG;AACH,qBAAa,uBAAwB,YAAW,YAAY;aAcpC,YAAY,EAAE,MAAM;aACpB,YAAY,EAAE,mBAAmB;IAdrD,IAAW,YAAY,SAAmB;IAC1C,IAAW,mBAAmB,SAAmB;IACjD,IAAW,YAAY,SAAmB;IAE1C,SAAgB,UAAU,QAAQ;IAClC,OAAO,CAAC,OAAO,CAAmC;IAElD;;;;OAIG;gBAEiB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,mBAAmB;
|
|
1
|
+
{"version":3,"file":"remoteObjectHandle.d.ts","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,YAAY,EACZ,mBAAmB,EACnB,QAAQ,EACR,SAAS,EAGZ,MAAM,iCAAiC,CAAC;AAGzC;;;;;;GAMG;AACH,qBAAa,uBAAwB,YAAW,YAAY;aAcpC,YAAY,EAAE,MAAM;aACpB,YAAY,EAAE,mBAAmB;IAdrD,IAAW,YAAY,SAAmB;IAC1C,IAAW,mBAAmB,SAAmB;IACjD,IAAW,YAAY,SAAmB;IAE1C,SAAgB,UAAU,QAAQ;IAClC,OAAO,CAAC,OAAO,CAAmC;IAElD;;;;OAIG;gBAEiB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,mBAAmB;IAKxC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IAezB,WAAW,IAAI,IAAI;IAInB,IAAI,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAI1B,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;CAY9D"}
|
|
@@ -29,12 +29,6 @@ class RemoteFluidObjectHandle {
|
|
|
29
29
|
get IFluidRouter() { return this; }
|
|
30
30
|
get IFluidHandleContext() { return this; }
|
|
31
31
|
get IFluidHandle() { return this; }
|
|
32
|
-
/**
|
|
33
|
-
* @deprecated - This returns the absolute path.
|
|
34
|
-
*/
|
|
35
|
-
get path() {
|
|
36
|
-
return this.absolutePath;
|
|
37
|
-
}
|
|
38
32
|
async get() {
|
|
39
33
|
if (this.objectP === undefined) {
|
|
40
34
|
const request = { url: this.absolutePath };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteObjectHandle.js","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAStD,yDAAiG;AAEjG;;;;;;GAMG;AACH,MAAa,uBAAuB;IAQhC;;;;OAIG;IACH,YACoB,YAAoB,EACpB,YAAiC;QADjC,iBAAY,GAAZ,YAAY,CAAQ;QACpB,iBAAY,GAAZ,YAAY,CAAqB;QAVrC,eAAU,GAAG,IAAI,CAAC;QAY9B,qBAAM,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAClG,CAAC;IAjBD,IAAW,YAAY,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;IAC1C,IAAW,mBAAmB,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;IACjD,IAAW,YAAY,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"remoteObjectHandle.js","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAStD,yDAAiG;AAEjG;;;;;;GAMG;AACH,MAAa,uBAAuB;IAQhC;;;;OAIG;IACH,YACoB,YAAoB,EACpB,YAAiC;QADjC,iBAAY,GAAZ,YAAY,CAAQ;QACpB,iBAAY,GAAZ,YAAY,CAAqB;QAVrC,eAAU,GAAG,IAAI,CAA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AAC,OAAO,KAAK,EAAE;YACZ,OAAO,sCAAmB,CAAC,KAAK,CAAC,CAAC;SACrC;IACL,CAAC;CACJ;AAvDD,0DAuDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport {\n IFluidHandle,\n IFluidHandleContext,\n IRequest,\n IResponse,\n FluidObject,\n IFluidRouter,\n} from \"@fluidframework/core-interfaces\";\nimport { create404Response, exceptionToResponse, responseToException } from \"./dataStoreHelpers\";\n\n/**\n * This handle is used to dynamically load a Fluid object on a remote client and is created on parsing a serialized\n * FluidObjectHandle.\n * This class is used to generate an IFluidHandle when de-serializing any all handles (including handles to DDSs, custom\n * objects) that are stored in SharedObjects. The Data Store or SharedObject corresponding to the IFluidHandle can be\n * retrieved by calling `get` on it.\n */\nexport class RemoteFluidObjectHandle implements IFluidHandle {\n public get IFluidRouter() { return this; }\n public get IFluidHandleContext() { return this; }\n public get IFluidHandle() { return this; }\n\n public readonly isAttached = true;\n private objectP: Promise<FluidObject> | undefined;\n\n /**\n * Creates a new RemoteFluidObjectHandle when parsing an IFluidHandle.\n * @param absolutePath - The absolute path to the handle from the container runtime.\n * @param routeContext - The root IFluidHandleContext that has a route to this handle.\n */\n constructor(\n public readonly absolutePath: string,\n public readonly routeContext: IFluidHandleContext,\n ) {\n assert(absolutePath.startsWith(\"/\"), 0x19d /* \"Handles should always have absolute paths\" */);\n }\n\n public async get(): Promise<any> {\n if (this.objectP === undefined) {\n const request = { url: this.absolutePath };\n this.objectP = this.routeContext.resolveHandle(request)\n .then<FluidObject>((response) => {\n if (response.mimeType === \"fluid/object\") {\n const fluidObject: FluidObject = response.value;\n return fluidObject;\n }\n throw responseToException(response, request);\n });\n }\n return this.objectP;\n }\n\n public attachGraph(): void {\n return;\n }\n\n public bind(handle: IFluidHandle): void {\n handle.attachGraph();\n }\n\n public async request(request: IRequest): Promise<IResponse> {\n try {\n const object: FluidObject<IFluidRouter> = await this.get();\n const router = object.IFluidRouter;\n\n return router !== undefined\n ? router.request(request)\n : create404Response(request);\n } catch (error) {\n return exceptionToResponse(error);\n }\n }\n}\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
6
|
-
import {
|
|
6
|
+
import { ISnapshotTree } from "@fluidframework/protocol-definitions";
|
|
7
7
|
import { CreateChildSummarizerNodeParam, IGarbageCollectionData, IGarbageCollectionSummaryDetails, ISummarizeInternalResult, ISummarizeResult, ISummarizerNodeConfigWithGC, ISummarizerNodeWithGC } from "@fluidframework/runtime-definitions";
|
|
8
8
|
import { ReadAndParseBlob } from "../utils";
|
|
9
9
|
import { SummarizerNode } from "./summarizerNode";
|
|
@@ -28,11 +28,7 @@ export declare class SummarizerNodeWithGC extends SummarizerNode implements IRoo
|
|
|
28
28
|
private gcData;
|
|
29
29
|
private usedRoutes;
|
|
30
30
|
private unreferencedTimestampMs;
|
|
31
|
-
private readonly maxUnreferencedDurationMs;
|
|
32
|
-
private readonly unreferencedTimer;
|
|
33
|
-
private inactive;
|
|
34
31
|
private readonly gcDisabled;
|
|
35
|
-
private useAfterFreeErrorLogged;
|
|
36
32
|
/**
|
|
37
33
|
* Do not call constructor directly.
|
|
38
34
|
* Use createRootSummarizerNodeWithGC to create root node, or createChild to create child nodes.
|
|
@@ -102,14 +98,6 @@ export declare class SummarizerNodeWithGC extends SummarizerNode implements IRoo
|
|
|
102
98
|
getChild(id: string): ISummarizerNodeWithGC | undefined;
|
|
103
99
|
isReferenced(): boolean;
|
|
104
100
|
updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number): void;
|
|
105
|
-
recordChange(op: ISequencedDocumentMessage): void;
|
|
106
|
-
/**
|
|
107
|
-
* Logs an error event if the node is inactive. This is used to identify cases where an inactive object is used.
|
|
108
|
-
* @param eventName - The name of the event to log.
|
|
109
|
-
* @param currentTimestampMs - The current time stamp. Used to report how long the object has been inactive.
|
|
110
|
-
* @returns true if we logged an error, false otherwise.
|
|
111
|
-
*/
|
|
112
|
-
private logErrorIfInactive;
|
|
113
101
|
/**
|
|
114
102
|
* Override the hasChanged method. If this node data or its used state changed, the node is considered changed.
|
|
115
103
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summarizerNodeWithGc.d.ts","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNodeWithGc.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGtE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"summarizerNodeWithGc.d.ts","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNodeWithGc.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGtE,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EACH,8BAA8B,EAE9B,sBAAsB,EACtB,gCAAgC,EAChC,wBAAwB,EACxB,gBAAgB,EAChB,2BAA2B,EAC3B,qBAAqB,EACxB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EACH,WAAW,EAEX,eAAe,EACf,2BAA2B,EAC3B,WAAW,EACd,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,yBAA0B,SAAQ,qBAAqB,EAAE,2BAA2B;CAAG;AAiBxG;;;;;;;;GAQG;AACH,qBAAa,oBAAqB,SAAQ,cAAe,YAAW,yBAAyB;IA6BrF,OAAO,CAAC,QAAQ,CAAC,WAAW;IAO5B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;IAlCjC,OAAO,CAAC,uBAAuB,CAAqB;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/E,yBAUF,CAAC"}
|
|
@@ -10,7 +10,6 @@ const garbage_collector_1 = require("@fluidframework/garbage-collector");
|
|
|
10
10
|
const runtime_definitions_1 = require("@fluidframework/runtime-definitions");
|
|
11
11
|
const summarizerNode_1 = require("./summarizerNode");
|
|
12
12
|
const summarizerNodeUtils_1 = require("./summarizerNodeUtils");
|
|
13
|
-
const defaultMaxUnreferencedDurationMs = 7 * 24 * 60 * 60 * 1000; // 7 days
|
|
14
13
|
// Extend SummaryNode to add used routes tracking to it.
|
|
15
14
|
class SummaryNodeWithGC extends summarizerNodeUtils_1.SummaryNode {
|
|
16
15
|
constructor(serializedUsedRoutes, summary) {
|
|
@@ -35,7 +34,6 @@ class SummarizerNodeWithGC extends summarizerNode_1.SummarizerNode {
|
|
|
35
34
|
constructor(logger, summarizeFn, config, changeSequenceNumber,
|
|
36
35
|
/** Undefined means created without summary */
|
|
37
36
|
latestSummary, initialSummary, wipSummaryLogger, getGCDataFn, getInitialGCSummaryDetailsFn) {
|
|
38
|
-
var _a;
|
|
39
37
|
super(logger, async (fullTree) => summarizeFn(fullTree, true /* trackState */), config, changeSequenceNumber, latestSummary, initialSummary, wipSummaryLogger);
|
|
40
38
|
this.summarizeFn = summarizeFn;
|
|
41
39
|
this.getGCDataFn = getGCDataFn;
|
|
@@ -43,20 +41,11 @@ class SummarizerNodeWithGC extends summarizerNode_1.SummarizerNode {
|
|
|
43
41
|
// that this node is not marked as collected when running GC has been disabled. Once, the option to disable GC is
|
|
44
42
|
// removed (from runGC flag in IContainerRuntimeOptions), this should be changed to be have no routes by default.
|
|
45
43
|
this.usedRoutes = [""];
|
|
46
|
-
// Tracks whether this node is inactive after being unreferenced for maxUnreferencedDurationMs.
|
|
47
|
-
this.inactive = false;
|
|
48
|
-
// Keeps track of whether we logged an use-after-free error. This is temporary since the error is too noisy.
|
|
49
|
-
// To be removed once this item is completed - https://github.com/microsoft/FluidFramework/issues/7895.
|
|
50
|
-
this.useAfterFreeErrorLogged = false;
|
|
51
44
|
this.gcDisabled = config.gcDisabled === true;
|
|
52
|
-
this.maxUnreferencedDurationMs = (_a = config.maxUnreferencedDurationMs) !== null && _a !== void 0 ? _a : defaultMaxUnreferencedDurationMs;
|
|
53
45
|
this.gcDetailsInInitialSummaryP = new common_utils_1.LazyPromise(async () => {
|
|
54
46
|
const gcSummaryDetails = await (getInitialGCSummaryDetailsFn === null || getInitialGCSummaryDetailsFn === void 0 ? void 0 : getInitialGCSummaryDetailsFn());
|
|
55
47
|
return gcSummaryDetails !== null && gcSummaryDetails !== void 0 ? gcSummaryDetails : { usedRoutes: [] };
|
|
56
48
|
});
|
|
57
|
-
this.unreferencedTimer = new common_utils_1.Timer(this.maxUnreferencedDurationMs, () => {
|
|
58
|
-
this.inactive = true;
|
|
59
|
-
});
|
|
60
49
|
}
|
|
61
50
|
// Returns the GC details that may be added to this node's summary.
|
|
62
51
|
getGCSummaryDetails() {
|
|
@@ -203,12 +192,12 @@ class SummarizerNodeWithGC extends summarizerNode_1.SummarizerNode {
|
|
|
203
192
|
* Attach information if it is created from an attach op.
|
|
204
193
|
*/
|
|
205
194
|
createParam, config = {}, getGCDataFn, getInitialGCSummaryDetailsFn) {
|
|
206
|
-
var _a
|
|
195
|
+
var _a;
|
|
207
196
|
common_utils_1.assert(!this.children.has(id), 0x1b6 /* "Create SummarizerNode child already exists" */);
|
|
208
197
|
const createDetails = this.getCreateDetailsForChild(id, createParam);
|
|
209
198
|
const child = new SummarizerNodeWithGC(this.defaultLogger, summarizeInternalFn, Object.assign(Object.assign({}, config), {
|
|
210
199
|
// Propagate our gcDisabled state to the child if its not explicity specified in child's config.
|
|
211
|
-
gcDisabled: (_a = config.gcDisabled) !== null && _a !== void 0 ? _a : this.gcDisabled
|
|
200
|
+
gcDisabled: (_a = config.gcDisabled) !== null && _a !== void 0 ? _a : this.gcDisabled }), createDetails.changeSequenceNumber, createDetails.latestSummary, createDetails.initialSummary, this.wipSummaryLogger, getGCDataFn, getInitialGCSummaryDetailsFn);
|
|
212
201
|
// There may be additional state that has to be updated in this child. For example, if a summary is being
|
|
213
202
|
// tracked, the child's summary tracking state needs to be updated too.
|
|
214
203
|
this.maybeUpdateChildState(child);
|
|
@@ -240,72 +229,13 @@ class SummarizerNodeWithGC extends summarizerNode_1.SummarizerNode {
|
|
|
240
229
|
this.wipSerializedUsedRoutes = JSON.stringify(this.usedRoutes);
|
|
241
230
|
}
|
|
242
231
|
if (this.isReferenced()) {
|
|
243
|
-
// If this node has been unreferenced for longer than maxUnreferencedDurationMs and is being referenced,
|
|
244
|
-
// log an error as this may mean the maxUnreferencedDurationMs is not long enough.
|
|
245
|
-
this.logErrorIfInactive("inactiveObjectRevived", gcTimestamp);
|
|
246
|
-
// Clear unreferenced / inactive state, if any.
|
|
247
|
-
this.inactive = false;
|
|
248
232
|
this.unreferencedTimestampMs = undefined;
|
|
249
|
-
this.unreferencedTimer.clear();
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
// This node is unreferenced. We need to check if this node is inative or if we need to start the unreferenced
|
|
253
|
-
// timer which would mark the node as inactive.
|
|
254
|
-
// If there is no timestamp when GC was run, we don't have enough information to determine whether this content
|
|
255
|
-
// should become inactive.
|
|
256
|
-
if (gcTimestamp === undefined) {
|
|
257
233
|
return;
|
|
258
234
|
}
|
|
259
|
-
// If
|
|
260
|
-
// and start the unreferenced timer.
|
|
261
|
-
// Note that it's possible this node has been unreferenced before but the unreferencedTimestampMs was not added.
|
|
262
|
-
// For example, older versions where this concept did not exist or if gcTimestamp wasn't available. In such
|
|
263
|
-
// cases, we track them as if the content just became unreferenced.
|
|
235
|
+
// If this node just became unreferenced, update its unreferencedTimestampMs.
|
|
264
236
|
if (this.unreferencedTimestampMs === undefined) {
|
|
265
237
|
this.unreferencedTimestampMs = gcTimestamp;
|
|
266
|
-
this.unreferencedTimer.start();
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
// If we are here, this node was unreferenced earlier.
|
|
270
|
-
// If it is already inactive or has an unreferenced timer running, there is no more work to be done.
|
|
271
|
-
if (this.inactive || this.unreferencedTimer.hasTimer) {
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
// If it has been unreferenced longer than maxUnreferencedDurationMs, mark it as inactive. Otherwise, start the
|
|
275
|
-
// unreferenced timer for the duration left for it to reach maxUnreferencedDurationMs.
|
|
276
|
-
const currentUnreferencedDurationMs = gcTimestamp - this.unreferencedTimestampMs;
|
|
277
|
-
if (currentUnreferencedDurationMs >= this.maxUnreferencedDurationMs) {
|
|
278
|
-
this.inactive = true;
|
|
279
|
-
}
|
|
280
|
-
else {
|
|
281
|
-
this.unreferencedTimer.start(this.maxUnreferencedDurationMs - currentUnreferencedDurationMs);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
recordChange(op) {
|
|
285
|
-
// If the node is changed after it is inactive, log an error as this may mean use-after-delete.
|
|
286
|
-
// Currently, we only log this error once per node per session as it's too noisy.
|
|
287
|
-
if (!this.useAfterFreeErrorLogged && this.logErrorIfInactive("inactiveObjectChanged")) {
|
|
288
|
-
this.useAfterFreeErrorLogged = true;
|
|
289
|
-
}
|
|
290
|
-
super.recordChange(op);
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Logs an error event if the node is inactive. This is used to identify cases where an inactive object is used.
|
|
294
|
-
* @param eventName - The name of the event to log.
|
|
295
|
-
* @param currentTimestampMs - The current time stamp. Used to report how long the object has been inactive.
|
|
296
|
-
* @returns true if we logged an error, false otherwise.
|
|
297
|
-
*/
|
|
298
|
-
logErrorIfInactive(eventName, currentTimestampMs) {
|
|
299
|
-
if (this.inactive) {
|
|
300
|
-
common_utils_1.assert(this.unreferencedTimestampMs !== undefined, 0x271 /* "Node should not become inactive without setting unreferencedTimestampMs first" */);
|
|
301
|
-
this.defaultLogger.sendErrorEvent({
|
|
302
|
-
eventName,
|
|
303
|
-
unreferencedDuratonMs: (currentTimestampMs !== null && currentTimestampMs !== void 0 ? currentTimestampMs : Date.now()) - this.unreferencedTimestampMs,
|
|
304
|
-
maxUnreferencedDurationMs: this.maxUnreferencedDurationMs,
|
|
305
|
-
});
|
|
306
|
-
return true;
|
|
307
238
|
}
|
|
308
|
-
return false;
|
|
309
239
|
}
|
|
310
240
|
/**
|
|
311
241
|
* Override the hasChanged method. If this node data or its used state changed, the node is considered changed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summarizerNodeWithGc.js","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNodeWithGc.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAA0E;AAC1E,yEAAgE;AAEhE,6EAS6C;AAE7C,qDAAkD;AAClD,+DAM+B;AAE/B,MAAM,gCAAgC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,SAAS;AAI3E,wDAAwD;AACxD,MAAM,iBAAkB,SAAQ,iCAAW;IACvC,YACoB,oBAA4B,EAC5C,OAKC;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QARC,yBAAoB,GAApB,oBAAoB,CAAQ;IAShD,CAAC;CACJ;AAED;;;;;;;;GAQG;AACH,MAAa,oBAAqB,SAAQ,+BAAc;IAoCpD;;;OAGG;IACH,YACI,MAAwB,EACP,WAA0F,EAC3G,MAAmC,EACnC,oBAA4B;IAC5B,8CAA8C;IAC9C,aAA2B,EAC3B,cAAgC,EAChC,gBAAmC,EAClB,WAAmE,EACpF,4BAA8E;;QAE9E,KAAK,CACD,MAAM,EACN,KAAK,EAAE,QAAiB,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,gBAAgB,CAAC,EACzE,MAAM,EACN,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,gBAAgB,CACnB,CAAC;QAlBe,gBAAW,GAAX,WAAW,CAA+E;QAO1F,gBAAW,GAAX,WAAW,CAAwD;QArCxF,mHAAmH;QACnH,iHAAiH;QACjH,iHAAiH;QACzG,eAAU,GAAa,CAAC,EAA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C,SAAS,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IACrF,CAAC;CACJ;AAjbD,oDAibC;AAED;;;;;;;;;;GAUG;AACI,MAAM,8BAA8B,GAAG,CAC1C,MAAwB,EACxB,mBAAkG,EAClG,oBAA4B,EAC5B,uBAA2C,EAC3C,SAAsC,EAAE,EACxC,WAAmE,EACnE,4BAA8E,EACrD,EAAE,CAAC,IAAI,oBAAoB,CACpD,MAAM,EACN,mBAAmB,EACnB,MAAM,EACN,oBAAoB,EACpB,uBAAuB,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iCAAW,CAAC,aAAa,CAAC,uBAAuB,CAAC,EACtG,SAAS,CAAC,oBAAoB,EAC9B,SAAS,CAAC,sBAAsB,EAChC,WAAW,EACX,4BAA4B,CAC/B,CAAC;AAlBW,QAAA,8BAA8B,kCAkBzC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, LazyPromise, Timer } from \"@fluidframework/common-utils\";\nimport { cloneGCData } from \"@fluidframework/garbage-collector\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n CreateChildSummarizerNodeParam,\n gcBlobKey,\n IGarbageCollectionData,\n IGarbageCollectionSummaryDetails,\n ISummarizeInternalResult,\n ISummarizeResult,\n ISummarizerNodeConfigWithGC,\n ISummarizerNodeWithGC,\n} from \"@fluidframework/runtime-definitions\";\nimport { ReadAndParseBlob } from \"../utils\";\nimport { SummarizerNode } from \"./summarizerNode\";\nimport {\n EscapedPath,\n ICreateChildDetails,\n IInitialSummary,\n ISummarizerNodeRootContract,\n SummaryNode,\n} from \"./summarizerNodeUtils\";\n\nconst defaultMaxUnreferencedDurationMs = 7 * 24 * 60 * 60 * 1000; // 7 days\n\nexport interface IRootSummarizerNodeWithGC extends ISummarizerNodeWithGC, ISummarizerNodeRootContract {}\n\n// Extend SummaryNode to add used routes tracking to it.\nclass SummaryNodeWithGC extends SummaryNode {\n constructor(\n public readonly serializedUsedRoutes: string,\n summary: {\n readonly referenceSequenceNumber: number,\n readonly basePath: EscapedPath | undefined,\n readonly localPath: EscapedPath,\n additionalPath?: EscapedPath,\n },\n ) {\n super(summary);\n }\n}\n\n/**\n * Extends the functionality of SummarizerNode to manage this node's garbage collection data:\n * - Adds a new API `getGCData` to return GC data of this node.\n * - Caches the result of `getGCData` to be used if nothing changes between summaries.\n * - Manages the used routes of this node. These are used to identify if this node is referenced in the document\n * and to determine if the node's used state changed since last summary.\n * - Adds trackState param to summarize. If trackState is false, it bypasses the SummarizerNode and calls\n * directly into summarizeInternal method.\n */\nexport class SummarizerNodeWithGC extends SummarizerNode implements IRootSummarizerNodeWithGC {\n // Tracks the work-in-progress used routes during summary.\n private wipSerializedUsedRoutes: string | undefined;\n\n // This is the last known used routes of this node as seen by the server as part of a summary.\n private referenceUsedRoutes: string[] | undefined;\n\n // The GC details of this node in the initial summary.\n private gcDetailsInInitialSummaryP: LazyPromise<IGarbageCollectionSummaryDetails> | undefined;\n\n private gcData: IGarbageCollectionData | undefined;\n\n // Set used routes to have self route by default. This makes the node referenced by default. This is done to ensure\n // that this node is not marked as collected when running GC has been disabled. Once, the option to disable GC is\n // removed (from runGC flag in IContainerRuntimeOptions), this should be changed to be have no routes by default.\n private usedRoutes: string[] = [\"\"];\n\n // If this node is marked as unreferenced, the time when it marked as such.\n private unreferencedTimestampMs: number | undefined;\n\n // The max duration for which this node can be unreferenced before it is eligible for deletion.\n private readonly maxUnreferencedDurationMs: number;\n\n // The timer that runs when the node is marked unreferenced.\n private readonly unreferencedTimer: Timer;\n\n // Tracks whether this node is inactive after being unreferenced for maxUnreferencedDurationMs.\n private inactive: boolean = false;\n\n // True if GC is disabled for this node. If so, do not track GC specific state for a summary.\n private readonly gcDisabled: boolean;\n\n // Keeps track of whether we logged an use-after-free error. This is temporary since the error is too noisy.\n // To be removed once this item is completed - https://github.com/microsoft/FluidFramework/issues/7895.\n private useAfterFreeErrorLogged: boolean = false;\n\n /**\n * Do not call constructor directly.\n * Use createRootSummarizerNodeWithGC to create root node, or createChild to create child nodes.\n */\n public constructor(\n logger: ITelemetryLogger,\n private readonly summarizeFn: (fullTree: boolean, trackState: boolean) => Promise<ISummarizeInternalResult>,\n config: ISummarizerNodeConfigWithGC,\n changeSequenceNumber: number,\n /** Undefined means created without summary */\n latestSummary?: SummaryNode,\n initialSummary?: IInitialSummary,\n wipSummaryLogger?: ITelemetryLogger,\n private readonly getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getInitialGCSummaryDetailsFn?: () => Promise<IGarbageCollectionSummaryDetails>,\n ) {\n super(\n logger,\n async (fullTree: boolean) => summarizeFn(fullTree, true /* trackState */),\n config,\n changeSequenceNumber,\n latestSummary,\n initialSummary,\n wipSummaryLogger,\n );\n\n this.gcDisabled = config.gcDisabled === true;\n this.maxUnreferencedDurationMs = config.maxUnreferencedDurationMs ?? defaultMaxUnreferencedDurationMs;\n\n this.gcDetailsInInitialSummaryP = new LazyPromise(async () => {\n const gcSummaryDetails = await getInitialGCSummaryDetailsFn?.();\n return gcSummaryDetails ?? { usedRoutes: [] };\n });\n\n this.unreferencedTimer = new Timer(this.maxUnreferencedDurationMs, () => {\n this.inactive = true;\n });\n }\n\n // Returns the GC details that may be added to this node's summary.\n public getGCSummaryDetails(): IGarbageCollectionSummaryDetails {\n return {\n gcData: this.gcData,\n usedRoutes: this.usedRoutes,\n unrefTimestamp: this.unreferencedTimestampMs,\n };\n }\n\n /**\n * Loads state from this node's initial GC summary details. This contains the following data from the last summary\n * seen by the server for this client:\n * - usedRoutes: This is used to figure out if the used state of this node changed since last summary.\n * - gcData: The garbage collection data of this node that is required for running GC.\n */\n private async loadInitialGCSummaryDetails() {\n if (this.gcDetailsInInitialSummaryP === undefined) {\n return;\n }\n\n const gcDetailsInInitialSummaryP = this.gcDetailsInInitialSummaryP;\n this.gcDetailsInInitialSummaryP = undefined;\n\n const gcDetailsInInitialSummary = await gcDetailsInInitialSummaryP;\n // If the GC details has GC data, initialize our GC data from it.\n if (gcDetailsInInitialSummary.gcData !== undefined) {\n this.gcData = cloneGCData(gcDetailsInInitialSummary.gcData);\n }\n this.referenceUsedRoutes = gcDetailsInInitialSummary.usedRoutes;\n this.unreferencedTimestampMs = gcDetailsInInitialSummary.unrefTimestamp;\n }\n\n public async summarize(fullTree: boolean, trackState: boolean = true): Promise<ISummarizeResult> {\n // If GC is not disabled and we are tracking a summary, GC should have run and updated the used routes for this\n // summary by calling updateUsedRoutes which sets wipSerializedUsedRoutes.\n if (!this.gcDisabled && this.isTrackingInProgress()) {\n assert(this.wipSerializedUsedRoutes !== undefined,\n 0x1b1 /* \"wip used routes should be set if tracking a summary\" */);\n }\n\n // If trackState is true, get summary from base summarizer node which tracks summary state.\n // If trackState is false, get summary from summarizeInternal.\n return trackState ? super.summarize(fullTree) : this.summarizeFn(fullTree, trackState);\n }\n\n /**\n * Returns the GC data of this node. If nothing has changed since last summary, it tries to reuse the data from\n * the previous summary. Else, it gets new GC data from the underlying Fluid object.\n * @param fullGC - true to bypass optimizations and force full generation of GC data.\n */\n public async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n assert(!this.gcDisabled, 0x1b2 /* \"Getting GC data should not be called when GC is disabled!\" */);\n assert(this.getGCDataFn !== undefined, 0x1b3 /* \"GC data cannot be retrieved without getGCDataFn\" */);\n\n // Load GC details from the initial summary, if not already loaded. If this is the first time this function is\n // called and the node's data has not changed since last summary, the GC data in initial details is returned.\n await this.loadInitialGCSummaryDetails();\n\n // If there is no new data since last summary and we have GC data from the previous run, return it. We may not\n // have data from previous GC run for clients with older summary format before GC was added. They won't have\n // GC details in their initial summary.\n if (!fullGC && !this.hasDataChanged() && this.gcData !== undefined) {\n return cloneGCData(this.gcData);\n }\n\n const gcData = await this.getGCDataFn(fullGC);\n this.gcData = cloneGCData(gcData);\n return gcData;\n }\n\n /**\n * Called during the start of a summary. Updates the work-in-progress used routes.\n */\n public startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLogger) {\n // If GC is disabled, skip setting wip used routes since we should not track GC state.\n if (!this.gcDisabled) {\n assert(\n this.wipSerializedUsedRoutes === undefined,\n 0x1b4 /* \"We should not already be tracking used routes when to track a new summary\" */);\n }\n super.startSummary(referenceSequenceNumber, summaryLogger);\n }\n\n /**\n * Called after summary has been uploaded to the server. Add the work-in-progress state to the pending\n * summary queue. We track this until we get an ack from the server for this summary.\n */\n protected completeSummaryCore(\n proposalHandle: string,\n parentPath: EscapedPath | undefined,\n parentSkipRecursion: boolean,\n ) {\n let wipSerializedUsedRoutes: string | undefined;\n // If GC is disabled, don't set wip used routes.\n if (!this.gcDisabled) {\n wipSerializedUsedRoutes = this.wipSerializedUsedRoutes;\n assert(wipSerializedUsedRoutes !== undefined, 0x1b5 /* \"We should have been tracking used routes\" */);\n }\n\n super.completeSummaryCore(proposalHandle, parentPath, parentSkipRecursion);\n\n // If GC is disabled, skip setting pending summary with GC state.\n if (!this.gcDisabled) {\n const summaryNode = this.pendingSummaries.get(proposalHandle);\n if (summaryNode !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const summaryNodeWithGC = new SummaryNodeWithGC(wipSerializedUsedRoutes!, summaryNode);\n this.pendingSummaries.set(proposalHandle, summaryNodeWithGC);\n }\n }\n }\n\n /**\n * Clears the work-in-progress state.\n */\n public clearSummary() {\n this.wipSerializedUsedRoutes = undefined;\n super.clearSummary();\n }\n\n /**\n * Called when we get an ack from the server for a summary we sent. Update the reference state of this node\n * from the state in the pending summary queue.\n */\n protected refreshLatestSummaryFromPending(\n proposalHandle: string,\n referenceSequenceNumber: number,\n ): void {\n // If GC is disabled, skip setting referenced used routes since we are not tracking GC state.\n if (!this.gcDisabled) {\n const summaryNode = this.pendingSummaries.get(proposalHandle) as SummaryNodeWithGC;\n if (summaryNode !== undefined) {\n this.referenceUsedRoutes = JSON.parse(summaryNode.serializedUsedRoutes);\n }\n }\n\n return super.refreshLatestSummaryFromPending(proposalHandle, referenceSequenceNumber);\n }\n\n /**\n * Called when we need to upload the reference state from the given summary. Read the GC blob and get the state\n * to upload from it.\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 // If GC is disabled, skip setting referenced used routes since we are not tracking GC state.\n if (!this.gcDisabled) {\n const gcDetailsBlob = snapshotTree.blobs[gcBlobKey];\n if (gcDetailsBlob !== undefined) {\n const gcDetails = await readAndParseBlob<IGarbageCollectionSummaryDetails>(gcDetailsBlob);\n\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.referenceUsedRoutes = gcDetails.usedRoutes;\n }\n }\n\n return super.refreshLatestSummaryFromSnapshot(\n referenceSequenceNumber,\n snapshotTree,\n basePath,\n localPath,\n correlatedSummaryLogger,\n readAndParseBlob,\n );\n }\n\n /**\n * Override the createChild method to return an instance of SummarizerNodeWithGC.\n */\n public createChild(\n /** Summarize function */\n summarizeInternalFn: (fullTree: boolean, trackState: boolean) => Promise<ISummarizeInternalResult>,\n /** Initial id or path part of this node */\n id: string,\n /**\n * Information needed to create the node.\n * If it is from a base summary, it will assert that a summary has been seen.\n * Attach information if it is created from an attach op.\n */\n createParam: CreateChildSummarizerNodeParam,\n config: ISummarizerNodeConfigWithGC = {},\n getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getInitialGCSummaryDetailsFn?: () => Promise<IGarbageCollectionSummaryDetails>,\n ): ISummarizerNodeWithGC {\n assert(!this.children.has(id), 0x1b6 /* \"Create SummarizerNode child already exists\" */);\n\n const createDetails: ICreateChildDetails = this.getCreateDetailsForChild(id, createParam);\n const child = new SummarizerNodeWithGC(\n this.defaultLogger,\n summarizeInternalFn,\n {\n ...config,\n // Propagate our gcDisabled state to the child if its not explicity specified in child's config.\n gcDisabled: config.gcDisabled ?? this.gcDisabled,\n maxUnreferencedDurationMs: config.maxUnreferencedDurationMs ?? this.maxUnreferencedDurationMs,\n },\n createDetails.changeSequenceNumber,\n createDetails.latestSummary,\n createDetails.initialSummary,\n this.wipSummaryLogger,\n getGCDataFn,\n getInitialGCSummaryDetailsFn,\n );\n\n // There may be additional state that has to be updated in this child. For example, if a summary is being\n // tracked, the child's summary tracking state needs to be updated too.\n this.maybeUpdateChildState(child);\n\n this.children.set(id, child);\n return child;\n }\n\n /**\n * Deletes the child node with the given id.\n */\n public deleteChild(id: string): void {\n this.children.delete(id);\n }\n\n /**\n * Override the getChild method to return an instance of SummarizerNodeWithGC.\n */\n public getChild(id: string): ISummarizerNodeWithGC | undefined {\n return this.children.get(id) as SummarizerNodeWithGC;\n }\n\n public isReferenced(): boolean {\n return this.usedRoutes.includes(\"\") || this.usedRoutes.includes(\"/\");\n }\n\n public updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number) {\n // Sort the given routes before updating. This will ensure that the routes compared in hasUsedStateChanged()\n // are in the same order.\n this.usedRoutes = usedRoutes.sort();\n\n // If GC is not disabled and we are tracking a summary, update the work-in-progress used routes so that it can\n // be tracked for this summary.\n if (!this.gcDisabled && this.isTrackingInProgress()) {\n this.wipSerializedUsedRoutes = JSON.stringify(this.usedRoutes);\n }\n\n if (this.isReferenced()) {\n // If this node has been unreferenced for longer than maxUnreferencedDurationMs and is being referenced,\n // log an error as this may mean the maxUnreferencedDurationMs is not long enough.\n this.logErrorIfInactive(\"inactiveObjectRevived\", gcTimestamp);\n\n // Clear unreferenced / inactive state, if any.\n this.inactive = false;\n this.unreferencedTimestampMs = undefined;\n this.unreferencedTimer.clear();\n return;\n }\n\n // This node is unreferenced. We need to check if this node is inative or if we need to start the unreferenced\n // timer which would mark the node as inactive.\n\n // If there is no timestamp when GC was run, we don't have enough information to determine whether this content\n // should become inactive.\n if (gcTimestamp === undefined) {\n return;\n }\n\n // If unreferencedTimestampMs is not present, this node just became unreferenced. Update unreferencedTimestampMs\n // and start the unreferenced timer.\n // Note that it's possible this node has been unreferenced before but the unreferencedTimestampMs was not added.\n // For example, older versions where this concept did not exist or if gcTimestamp wasn't available. In such\n // cases, we track them as if the content just became unreferenced.\n if (this.unreferencedTimestampMs === undefined) {\n this.unreferencedTimestampMs = gcTimestamp;\n this.unreferencedTimer.start();\n return;\n }\n\n // If we are here, this node was unreferenced earlier.\n\n // If it is already inactive or has an unreferenced timer running, there is no more work to be done.\n if (this.inactive || this.unreferencedTimer.hasTimer) {\n return;\n }\n\n // If it has been unreferenced longer than maxUnreferencedDurationMs, mark it as inactive. Otherwise, start the\n // unreferenced timer for the duration left for it to reach maxUnreferencedDurationMs.\n const currentUnreferencedDurationMs = gcTimestamp - this.unreferencedTimestampMs;\n if (currentUnreferencedDurationMs >= this.maxUnreferencedDurationMs) {\n this.inactive = true;\n } else {\n this.unreferencedTimer.start(this.maxUnreferencedDurationMs - currentUnreferencedDurationMs);\n }\n }\n\n public recordChange(op: ISequencedDocumentMessage): void {\n // If the node is changed after it is inactive, log an error as this may mean use-after-delete.\n // Currently, we only log this error once per node per session as it's too noisy.\n if (!this.useAfterFreeErrorLogged && this.logErrorIfInactive(\"inactiveObjectChanged\")) {\n this.useAfterFreeErrorLogged = true;\n }\n super.recordChange(op);\n }\n\n /**\n * Logs an error event if the node is inactive. This is used to identify cases where an inactive object is used.\n * @param eventName - The name of the event to log.\n * @param currentTimestampMs - The current time stamp. Used to report how long the object has been inactive.\n * @returns true if we logged an error, false otherwise.\n */\n private logErrorIfInactive(eventName: string, currentTimestampMs?: number): boolean {\n if (this.inactive) {\n assert(\n this.unreferencedTimestampMs !== undefined,\n 0x271 /* \"Node should not become inactive without setting unreferencedTimestampMs first\" */);\n this.defaultLogger.sendErrorEvent({\n eventName,\n unreferencedDuratonMs: (currentTimestampMs ?? Date.now()) - this.unreferencedTimestampMs,\n maxUnreferencedDurationMs: this.maxUnreferencedDurationMs,\n });\n return true;\n }\n return false;\n }\n\n /**\n * Override the hasChanged method. If this node data or its used state changed, the node is considered changed.\n */\n protected hasChanged(): boolean {\n return this.hasDataChanged() || this.hasUsedStateChanged();\n }\n\n /**\n * This tells whether the data in this node has changed or not.\n */\n private hasDataChanged(): boolean {\n return super.hasChanged();\n }\n\n /**\n * This tells whether the used state of this node has changed since last successful summary. If the used routes\n * of this node changed, its used state is considered changed. Basically, if this node or any of its child nodes\n * was previously used and became unused (or vice versa), its used state has changed.\n */\n private hasUsedStateChanged(): boolean {\n // If GC is disabled, we are not tracking used state, return false.\n if (this.gcDisabled) {\n return false;\n }\n\n return this.referenceUsedRoutes === undefined ||\n JSON.stringify(this.usedRoutes) !== JSON.stringify(this.referenceUsedRoutes);\n }\n}\n\n/**\n * Creates a root summarizer node with GC functionality built-in.\n * @param logger - Logger to use within SummarizerNode\n * @param summarizeInternalFn - Function to generate summary\n * @param changeSequenceNumber - Sequence number of latest change to new node/subtree\n * @param referenceSequenceNumber - Reference sequence number of last acked summary,\n * or undefined if not loaded from summary\n * @param config - Configure behavior of summarizer node\n * @param getGCDataFn - Function to get the GC data of this node\n * @param gcDetailsInInitialSummaryP - Function to get the initial GC details of this node\n */\nexport const createRootSummarizerNodeWithGC = (\n logger: ITelemetryLogger,\n summarizeInternalFn: (fullTree: boolean, trackState: boolean) => Promise<ISummarizeInternalResult>,\n changeSequenceNumber: number,\n referenceSequenceNumber: number | undefined,\n config: ISummarizerNodeConfigWithGC = {},\n getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getInitialGCSummaryDetailsFn?: () => Promise<IGarbageCollectionSummaryDetails>,\n): IRootSummarizerNodeWithGC => new SummarizerNodeWithGC(\n logger,\n summarizeInternalFn,\n config,\n changeSequenceNumber,\n referenceSequenceNumber === undefined ? undefined : SummaryNode.createForRoot(referenceSequenceNumber),\n undefined /* initialSummary */,\n undefined /* wipSummaryLogger */,\n getGCDataFn,\n getInitialGCSummaryDetailsFn,\n);\n"]}
|
|
1
|
+
{"version":3,"file":"summarizerNodeWithGc.js","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNodeWithGc.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAAmE;AACnE,yEAAgE;AAEhE,6EAS6C;AAE7C,qDAAkD;AAClD,+DAM+B;AAI/B,wDAAwD;AACxD,MAAM,iBAAkB,SAAQ,iCAAW;IACvC,YACoB,oBAA4B,EAC5C,OAKC;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QARC,yBAAoB,GAApB,oBAAoB,CAAQ;IAShD,CAAC;CACJ;AAED;;;;;;;;GAQG;AACH,MAAa,oBAAqB,SAAQ,+BAAc;IAuBpD;;;OAGG;IACH,YACI,MAAwB,EACP,WAA0F,EAC3G,MAAmC,EACnC,oBAA4B;IAC5B,8CAA8C;IAC9C,aAA2B,EAC3B,cAAgC,EAChC,gBAAmC,EAClB,WAAmE,EACpF,4BAA8E;QAE9E,KAAK,CACD,MAAM,EACN,KAAK,EAAE,QAAiB,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,gBAAgB,CAAC,EACzE,MAAM,EACN,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,gBAAgB,CACnB,CAAC;QAlBe,gBAAW,GAAX,WAAW,CAA+E;QAO1F,gBAAW,GAAX,WAAW,CAAwD;QAxBxF,mHAAmH;QACnH,iHAAiH;QACjH,iHAAiH;QACzG,eAAU,GAAa,CAAC,EAAE,CAAC,CAAC;QAkChC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,KAAK,IAAI,CAAC;QAE7C,IAAI,CAAC,0BAA0B,GAAG,IAAI,0BAAW,CAAC,KAAK,IAAI,EAAE;YACzD,MAAM,gBAAgB,GAAG,OAAM,4BAA4B,aAA5B,4BAA4B,uBAA5B,4BAA4B,GAAI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K,mBAAmB;QACvB,mEAAmE;QACnE,IAAI,IAAI,CAAC,UAAU,EAAE;YACjB,OAAO,KAAK,CAAC;SAChB;QAED,OAAO,IAAI,CAAC,mBAAmB,KAAK,SAAS;YACzC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IACrF,CAAC;CACJ;AA1VD,oDA0VC;AAED;;;;;;;;;;GAUG;AACI,MAAM,8BAA8B,GAAG,CAC1C,MAAwB,EACxB,mBAAkG,EAClG,oBAA4B,EAC5B,uBAA2C,EAC3C,SAAsC,EAAE,EACxC,WAAmE,EACnE,4BAA8E,EACrD,EAAE,CAAC,IAAI,oBAAoB,CACpD,MAAM,EACN,mBAAmB,EACnB,MAAM,EACN,oBAAoB,EACpB,uBAAuB,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iCAAW,CAAC,aAAa,CAAC,uBAAuB,CAAC,EACtG,SAAS,CAAC,oBAAoB,EAC9B,SAAS,CAAC,sBAAsB,EAChC,WAAW,EACX,4BAA4B,CAC/B,CAAC;AAlBW,QAAA,8BAA8B,kCAkBzC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, LazyPromise } from \"@fluidframework/common-utils\";\nimport { cloneGCData } from \"@fluidframework/garbage-collector\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n CreateChildSummarizerNodeParam,\n gcBlobKey,\n IGarbageCollectionData,\n IGarbageCollectionSummaryDetails,\n ISummarizeInternalResult,\n ISummarizeResult,\n ISummarizerNodeConfigWithGC,\n ISummarizerNodeWithGC,\n} from \"@fluidframework/runtime-definitions\";\nimport { ReadAndParseBlob } from \"../utils\";\nimport { SummarizerNode } from \"./summarizerNode\";\nimport {\n EscapedPath,\n ICreateChildDetails,\n IInitialSummary,\n ISummarizerNodeRootContract,\n SummaryNode,\n} from \"./summarizerNodeUtils\";\n\nexport interface IRootSummarizerNodeWithGC extends ISummarizerNodeWithGC, ISummarizerNodeRootContract {}\n\n// Extend SummaryNode to add used routes tracking to it.\nclass SummaryNodeWithGC extends SummaryNode {\n constructor(\n public readonly serializedUsedRoutes: string,\n summary: {\n readonly referenceSequenceNumber: number,\n readonly basePath: EscapedPath | undefined,\n readonly localPath: EscapedPath,\n additionalPath?: EscapedPath,\n },\n ) {\n super(summary);\n }\n}\n\n/**\n * Extends the functionality of SummarizerNode to manage this node's garbage collection data:\n * - Adds a new API `getGCData` to return GC data of this node.\n * - Caches the result of `getGCData` to be used if nothing changes between summaries.\n * - Manages the used routes of this node. These are used to identify if this node is referenced in the document\n * and to determine if the node's used state changed since last summary.\n * - Adds trackState param to summarize. If trackState is false, it bypasses the SummarizerNode and calls\n * directly into summarizeInternal method.\n */\nexport class SummarizerNodeWithGC extends SummarizerNode implements IRootSummarizerNodeWithGC {\n // Tracks the work-in-progress used routes during summary.\n private wipSerializedUsedRoutes: string | undefined;\n\n // This is the last known used routes of this node as seen by the server as part of a summary.\n private referenceUsedRoutes: string[] | undefined;\n\n // The GC details of this node in the initial summary.\n private gcDetailsInInitialSummaryP: LazyPromise<IGarbageCollectionSummaryDetails> | undefined;\n\n private gcData: IGarbageCollectionData | undefined;\n\n // Set used routes to have self route by default. This makes the node referenced by default. This is done to ensure\n // that this node is not marked as collected when running GC has been disabled. Once, the option to disable GC is\n // removed (from runGC flag in IContainerRuntimeOptions), this should be changed to be have no routes by default.\n private usedRoutes: string[] = [\"\"];\n\n // If this node is marked as unreferenced, the time when it marked as such.\n private unreferencedTimestampMs: number | undefined;\n\n // True if GC is disabled for this node. If so, do not track GC specific state for a summary.\n private readonly gcDisabled: boolean;\n\n /**\n * Do not call constructor directly.\n * Use createRootSummarizerNodeWithGC to create root node, or createChild to create child nodes.\n */\n public constructor(\n logger: ITelemetryLogger,\n private readonly summarizeFn: (fullTree: boolean, trackState: boolean) => Promise<ISummarizeInternalResult>,\n config: ISummarizerNodeConfigWithGC,\n changeSequenceNumber: number,\n /** Undefined means created without summary */\n latestSummary?: SummaryNode,\n initialSummary?: IInitialSummary,\n wipSummaryLogger?: ITelemetryLogger,\n private readonly getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getInitialGCSummaryDetailsFn?: () => Promise<IGarbageCollectionSummaryDetails>,\n ) {\n super(\n logger,\n async (fullTree: boolean) => summarizeFn(fullTree, true /* trackState */),\n config,\n changeSequenceNumber,\n latestSummary,\n initialSummary,\n wipSummaryLogger,\n );\n\n this.gcDisabled = config.gcDisabled === true;\n\n this.gcDetailsInInitialSummaryP = new LazyPromise(async () => {\n const gcSummaryDetails = await getInitialGCSummaryDetailsFn?.();\n return gcSummaryDetails ?? { usedRoutes: [] };\n });\n }\n\n // Returns the GC details that may be added to this node's summary.\n public getGCSummaryDetails(): IGarbageCollectionSummaryDetails {\n return {\n gcData: this.gcData,\n usedRoutes: this.usedRoutes,\n unrefTimestamp: this.unreferencedTimestampMs,\n };\n }\n\n /**\n * Loads state from this node's initial GC summary details. This contains the following data from the last summary\n * seen by the server for this client:\n * - usedRoutes: This is used to figure out if the used state of this node changed since last summary.\n * - gcData: The garbage collection data of this node that is required for running GC.\n */\n private async loadInitialGCSummaryDetails() {\n if (this.gcDetailsInInitialSummaryP === undefined) {\n return;\n }\n\n const gcDetailsInInitialSummaryP = this.gcDetailsInInitialSummaryP;\n this.gcDetailsInInitialSummaryP = undefined;\n\n const gcDetailsInInitialSummary = await gcDetailsInInitialSummaryP;\n // If the GC details has GC data, initialize our GC data from it.\n if (gcDetailsInInitialSummary.gcData !== undefined) {\n this.gcData = cloneGCData(gcDetailsInInitialSummary.gcData);\n }\n this.referenceUsedRoutes = gcDetailsInInitialSummary.usedRoutes;\n this.unreferencedTimestampMs = gcDetailsInInitialSummary.unrefTimestamp;\n }\n\n public async summarize(fullTree: boolean, trackState: boolean = true): Promise<ISummarizeResult> {\n // If GC is not disabled and we are tracking a summary, GC should have run and updated the used routes for this\n // summary by calling updateUsedRoutes which sets wipSerializedUsedRoutes.\n if (!this.gcDisabled && this.isTrackingInProgress()) {\n assert(this.wipSerializedUsedRoutes !== undefined,\n 0x1b1 /* \"wip used routes should be set if tracking a summary\" */);\n }\n\n // If trackState is true, get summary from base summarizer node which tracks summary state.\n // If trackState is false, get summary from summarizeInternal.\n return trackState ? super.summarize(fullTree) : this.summarizeFn(fullTree, trackState);\n }\n\n /**\n * Returns the GC data of this node. If nothing has changed since last summary, it tries to reuse the data from\n * the previous summary. Else, it gets new GC data from the underlying Fluid object.\n * @param fullGC - true to bypass optimizations and force full generation of GC data.\n */\n public async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n assert(!this.gcDisabled, 0x1b2 /* \"Getting GC data should not be called when GC is disabled!\" */);\n assert(this.getGCDataFn !== undefined, 0x1b3 /* \"GC data cannot be retrieved without getGCDataFn\" */);\n\n // Load GC details from the initial summary, if not already loaded. If this is the first time this function is\n // called and the node's data has not changed since last summary, the GC data in initial details is returned.\n await this.loadInitialGCSummaryDetails();\n\n // If there is no new data since last summary and we have GC data from the previous run, return it. We may not\n // have data from previous GC run for clients with older summary format before GC was added. They won't have\n // GC details in their initial summary.\n if (!fullGC && !this.hasDataChanged() && this.gcData !== undefined) {\n return cloneGCData(this.gcData);\n }\n\n const gcData = await this.getGCDataFn(fullGC);\n this.gcData = cloneGCData(gcData);\n return gcData;\n }\n\n /**\n * Called during the start of a summary. Updates the work-in-progress used routes.\n */\n public startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLogger) {\n // If GC is disabled, skip setting wip used routes since we should not track GC state.\n if (!this.gcDisabled) {\n assert(\n this.wipSerializedUsedRoutes === undefined,\n 0x1b4 /* \"We should not already be tracking used routes when to track a new summary\" */);\n }\n super.startSummary(referenceSequenceNumber, summaryLogger);\n }\n\n /**\n * Called after summary has been uploaded to the server. Add the work-in-progress state to the pending\n * summary queue. We track this until we get an ack from the server for this summary.\n */\n protected completeSummaryCore(\n proposalHandle: string,\n parentPath: EscapedPath | undefined,\n parentSkipRecursion: boolean,\n ) {\n let wipSerializedUsedRoutes: string | undefined;\n // If GC is disabled, don't set wip used routes.\n if (!this.gcDisabled) {\n wipSerializedUsedRoutes = this.wipSerializedUsedRoutes;\n assert(wipSerializedUsedRoutes !== undefined, 0x1b5 /* \"We should have been tracking used routes\" */);\n }\n\n super.completeSummaryCore(proposalHandle, parentPath, parentSkipRecursion);\n\n // If GC is disabled, skip setting pending summary with GC state.\n if (!this.gcDisabled) {\n const summaryNode = this.pendingSummaries.get(proposalHandle);\n if (summaryNode !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const summaryNodeWithGC = new SummaryNodeWithGC(wipSerializedUsedRoutes!, summaryNode);\n this.pendingSummaries.set(proposalHandle, summaryNodeWithGC);\n }\n }\n }\n\n /**\n * Clears the work-in-progress state.\n */\n public clearSummary() {\n this.wipSerializedUsedRoutes = undefined;\n super.clearSummary();\n }\n\n /**\n * Called when we get an ack from the server for a summary we sent. Update the reference state of this node\n * from the state in the pending summary queue.\n */\n protected refreshLatestSummaryFromPending(\n proposalHandle: string,\n referenceSequenceNumber: number,\n ): void {\n // If GC is disabled, skip setting referenced used routes since we are not tracking GC state.\n if (!this.gcDisabled) {\n const summaryNode = this.pendingSummaries.get(proposalHandle) as SummaryNodeWithGC;\n if (summaryNode !== undefined) {\n this.referenceUsedRoutes = JSON.parse(summaryNode.serializedUsedRoutes);\n }\n }\n\n return super.refreshLatestSummaryFromPending(proposalHandle, referenceSequenceNumber);\n }\n\n /**\n * Called when we need to upload the reference state from the given summary. Read the GC blob and get the state\n * to upload from it.\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 // If GC is disabled, skip setting referenced used routes since we are not tracking GC state.\n if (!this.gcDisabled) {\n const gcDetailsBlob = snapshotTree.blobs[gcBlobKey];\n if (gcDetailsBlob !== undefined) {\n const gcDetails = await readAndParseBlob<IGarbageCollectionSummaryDetails>(gcDetailsBlob);\n\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.referenceUsedRoutes = gcDetails.usedRoutes;\n }\n }\n\n return super.refreshLatestSummaryFromSnapshot(\n referenceSequenceNumber,\n snapshotTree,\n basePath,\n localPath,\n correlatedSummaryLogger,\n readAndParseBlob,\n );\n }\n\n /**\n * Override the createChild method to return an instance of SummarizerNodeWithGC.\n */\n public createChild(\n /** Summarize function */\n summarizeInternalFn: (fullTree: boolean, trackState: boolean) => Promise<ISummarizeInternalResult>,\n /** Initial id or path part of this node */\n id: string,\n /**\n * Information needed to create the node.\n * If it is from a base summary, it will assert that a summary has been seen.\n * Attach information if it is created from an attach op.\n */\n createParam: CreateChildSummarizerNodeParam,\n config: ISummarizerNodeConfigWithGC = {},\n getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getInitialGCSummaryDetailsFn?: () => Promise<IGarbageCollectionSummaryDetails>,\n ): ISummarizerNodeWithGC {\n assert(!this.children.has(id), 0x1b6 /* \"Create SummarizerNode child already exists\" */);\n\n const createDetails: ICreateChildDetails = this.getCreateDetailsForChild(id, createParam);\n const child = new SummarizerNodeWithGC(\n this.defaultLogger,\n summarizeInternalFn,\n {\n ...config,\n // Propagate our gcDisabled state to the child if its not explicity specified in child's config.\n gcDisabled: config.gcDisabled ?? this.gcDisabled,\n },\n createDetails.changeSequenceNumber,\n createDetails.latestSummary,\n createDetails.initialSummary,\n this.wipSummaryLogger,\n getGCDataFn,\n getInitialGCSummaryDetailsFn,\n );\n\n // There may be additional state that has to be updated in this child. For example, if a summary is being\n // tracked, the child's summary tracking state needs to be updated too.\n this.maybeUpdateChildState(child);\n\n this.children.set(id, child);\n return child;\n }\n\n /**\n * Deletes the child node with the given id.\n */\n public deleteChild(id: string): void {\n this.children.delete(id);\n }\n\n /**\n * Override the getChild method to return an instance of SummarizerNodeWithGC.\n */\n public getChild(id: string): ISummarizerNodeWithGC | undefined {\n return this.children.get(id) as SummarizerNodeWithGC;\n }\n\n public isReferenced(): boolean {\n return this.usedRoutes.includes(\"\") || this.usedRoutes.includes(\"/\");\n }\n\n public updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number) {\n // Sort the given routes before updating. This will ensure that the routes compared in hasUsedStateChanged()\n // are in the same order.\n this.usedRoutes = usedRoutes.sort();\n\n // If GC is not disabled and we are tracking a summary, update the work-in-progress used routes so that it can\n // be tracked for this summary.\n if (!this.gcDisabled && this.isTrackingInProgress()) {\n this.wipSerializedUsedRoutes = JSON.stringify(this.usedRoutes);\n }\n\n if (this.isReferenced()) {\n this.unreferencedTimestampMs = undefined;\n return;\n }\n\n // If this node just became unreferenced, update its unreferencedTimestampMs.\n if (this.unreferencedTimestampMs === undefined) {\n this.unreferencedTimestampMs = gcTimestamp;\n }\n }\n\n /**\n * Override the hasChanged method. If this node data or its used state changed, the node is considered changed.\n */\n protected hasChanged(): boolean {\n return this.hasDataChanged() || this.hasUsedStateChanged();\n }\n\n /**\n * This tells whether the data in this node has changed or not.\n */\n private hasDataChanged(): boolean {\n return super.hasChanged();\n }\n\n /**\n * This tells whether the used state of this node has changed since last successful summary. If the used routes\n * of this node changed, its used state is considered changed. Basically, if this node or any of its child nodes\n * was previously used and became unused (or vice versa), its used state has changed.\n */\n private hasUsedStateChanged(): boolean {\n // If GC is disabled, we are not tracking used state, return false.\n if (this.gcDisabled) {\n return false;\n }\n\n return this.referenceUsedRoutes === undefined ||\n JSON.stringify(this.usedRoutes) !== JSON.stringify(this.referenceUsedRoutes);\n }\n}\n\n/**\n * Creates a root summarizer node with GC functionality built-in.\n * @param logger - Logger to use within SummarizerNode\n * @param summarizeInternalFn - Function to generate summary\n * @param changeSequenceNumber - Sequence number of latest change to new node/subtree\n * @param referenceSequenceNumber - Reference sequence number of last acked summary,\n * or undefined if not loaded from summary\n * @param config - Configure behavior of summarizer node\n * @param getGCDataFn - Function to get the GC data of this node\n * @param gcDetailsInInitialSummaryP - Function to get the initial GC details of this node\n */\nexport const createRootSummarizerNodeWithGC = (\n logger: ITelemetryLogger,\n summarizeInternalFn: (fullTree: boolean, trackState: boolean) => Promise<ISummarizeInternalResult>,\n changeSequenceNumber: number,\n referenceSequenceNumber: number | undefined,\n config: ISummarizerNodeConfigWithGC = {},\n getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getInitialGCSummaryDetailsFn?: () => Promise<IGarbageCollectionSummaryDetails>,\n): IRootSummarizerNodeWithGC => new SummarizerNodeWithGC(\n logger,\n summarizeInternalFn,\n config,\n changeSequenceNumber,\n referenceSequenceNumber === undefined ? undefined : SummaryNode.createForRoot(referenceSequenceNumber),\n undefined /* initialSummary */,\n undefined /* wipSummaryLogger */,\n getGCDataFn,\n getInitialGCSummaryDetailsFn,\n);\n"]}
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { FluidObject, IFluidObject, IFluidRouter, IRequest, IResponse } from "@fluidframework/core-interfaces";
|
|
6
6
|
import { IFluidDataStoreFactory, IFluidDataStoreRegistry, IProvideFluidDataStoreRegistry } from "@fluidframework/runtime-definitions";
|
|
7
|
-
export declare function getStack(): string | undefined;
|
|
8
7
|
export declare function exceptionToResponse(err: any): IResponse;
|
|
9
8
|
export declare function responseToException(response: IResponse, request: IRequest): Error;
|
|
10
9
|
export declare function requestFluidObject<T = IFluidObject & FluidObject>(router: IFluidRouter, url: string | IRequest): Promise<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataStoreHelpers.d.ts","sourceRoot":"","sources":["../src/dataStoreHelpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,SAAS,EACZ,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,EACjC,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"dataStoreHelpers.d.ts","sourceRoot":"","sources":["../src/dataStoreHelpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,SAAS,EACZ,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,EACjC,MAAM,qCAAqC,CAAC;AAU7C,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,GAAG,GAAG,SAAS,CAsBvD;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,GAAG,KAAK,CAYjF;AAED,wBAAsB,kBAAkB,CAAC,CAAC,GAAG,YAAY,GAAG,WAAW,EACnE,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAU5D;AAED,eAAO,MAAM,iBAAiB,YAAa,QAAQ,cAAmD,CAAC;AAEvG,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,SAAS,CAc/F;AAED,oBAAY,OAAO,GAAG,sBAAsB,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAGvF,wBAAgB,sBAAsB,CAClC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAChC,sBAAsB,GAAG,uBAAuB,CAStD"}
|