@fluidframework/container-runtime 2.0.0-internal.3.0.1 → 2.0.0-internal.3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (327) hide show
  1. package/.eslintrc.js +19 -19
  2. package/.mocharc.js +2 -2
  3. package/api-extractor.json +2 -2
  4. package/dist/batchTracker.d.ts.map +1 -1
  5. package/dist/batchTracker.js +2 -1
  6. package/dist/batchTracker.js.map +1 -1
  7. package/dist/blobManager.d.ts +9 -2
  8. package/dist/blobManager.d.ts.map +1 -1
  9. package/dist/blobManager.js +80 -33
  10. package/dist/blobManager.js.map +1 -1
  11. package/dist/connectionTelemetry.d.ts.map +1 -1
  12. package/dist/connectionTelemetry.js +11 -9
  13. package/dist/connectionTelemetry.js.map +1 -1
  14. package/dist/containerHandleContext.d.ts.map +1 -1
  15. package/dist/containerHandleContext.js +3 -1
  16. package/dist/containerHandleContext.js.map +1 -1
  17. package/dist/containerRuntime.d.ts +10 -0
  18. package/dist/containerRuntime.d.ts.map +1 -1
  19. package/dist/containerRuntime.js +140 -72
  20. package/dist/containerRuntime.js.map +1 -1
  21. package/dist/dataStore.d.ts.map +1 -1
  22. package/dist/dataStore.js +11 -9
  23. package/dist/dataStore.js.map +1 -1
  24. package/dist/dataStoreContext.d.ts +18 -1
  25. package/dist/dataStoreContext.d.ts.map +1 -1
  26. package/dist/dataStoreContext.js +66 -15
  27. package/dist/dataStoreContext.js.map +1 -1
  28. package/dist/dataStoreContexts.d.ts.map +1 -1
  29. package/dist/dataStoreContexts.js +7 -3
  30. package/dist/dataStoreContexts.js.map +1 -1
  31. package/dist/dataStoreRegistry.d.ts.map +1 -1
  32. package/dist/dataStoreRegistry.js +3 -1
  33. package/dist/dataStoreRegistry.js.map +1 -1
  34. package/dist/dataStores.d.ts +26 -1
  35. package/dist/dataStores.d.ts.map +1 -1
  36. package/dist/dataStores.js +103 -18
  37. package/dist/dataStores.js.map +1 -1
  38. package/dist/deltaScheduler.d.ts.map +1 -1
  39. package/dist/deltaScheduler.js +8 -3
  40. package/dist/deltaScheduler.js.map +1 -1
  41. package/dist/garbageCollection.d.ts +34 -14
  42. package/dist/garbageCollection.d.ts.map +1 -1
  43. package/dist/garbageCollection.js +188 -93
  44. package/dist/garbageCollection.js.map +1 -1
  45. package/dist/garbageCollectionConstants.d.ts +3 -0
  46. package/dist/garbageCollectionConstants.d.ts.map +1 -1
  47. package/dist/garbageCollectionConstants.js +6 -1
  48. package/dist/garbageCollectionConstants.js.map +1 -1
  49. package/dist/garbageCollectionHelpers.d.ts +26 -0
  50. package/dist/garbageCollectionHelpers.d.ts.map +1 -0
  51. package/dist/garbageCollectionHelpers.js +45 -0
  52. package/dist/garbageCollectionHelpers.js.map +1 -0
  53. package/dist/gcSweepReadyUsageDetection.d.ts +5 -5
  54. package/dist/gcSweepReadyUsageDetection.d.ts.map +1 -1
  55. package/dist/gcSweepReadyUsageDetection.js +14 -10
  56. package/dist/gcSweepReadyUsageDetection.js.map +1 -1
  57. package/dist/index.d.ts +2 -2
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js.map +1 -1
  60. package/dist/opLifecycle/batchManager.d.ts +5 -5
  61. package/dist/opLifecycle/batchManager.d.ts.map +1 -1
  62. package/dist/opLifecycle/batchManager.js +19 -12
  63. package/dist/opLifecycle/batchManager.js.map +1 -1
  64. package/dist/opLifecycle/definitions.d.ts.map +1 -1
  65. package/dist/opLifecycle/definitions.js.map +1 -1
  66. package/dist/opLifecycle/index.d.ts.map +1 -1
  67. package/dist/opLifecycle/index.js.map +1 -1
  68. package/dist/opLifecycle/opCompressor.d.ts.map +1 -1
  69. package/dist/opLifecycle/opCompressor.js.map +1 -1
  70. package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
  71. package/dist/opLifecycle/opDecompressor.js +5 -2
  72. package/dist/opLifecycle/opDecompressor.js.map +1 -1
  73. package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
  74. package/dist/opLifecycle/opSplitter.js +4 -1
  75. package/dist/opLifecycle/opSplitter.js.map +1 -1
  76. package/dist/opLifecycle/outbox.d.ts.map +1 -1
  77. package/dist/opLifecycle/outbox.js +19 -17
  78. package/dist/opLifecycle/outbox.js.map +1 -1
  79. package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  80. package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
  81. package/dist/opProperties.d.ts.map +1 -1
  82. package/dist/opProperties.js +1 -3
  83. package/dist/opProperties.js.map +1 -1
  84. package/dist/orderedClientElection.d.ts.map +1 -1
  85. package/dist/orderedClientElection.js +10 -4
  86. package/dist/orderedClientElection.js.map +1 -1
  87. package/dist/packageVersion.d.ts +1 -1
  88. package/dist/packageVersion.js +1 -1
  89. package/dist/packageVersion.js.map +1 -1
  90. package/dist/pendingStateManager.d.ts +7 -0
  91. package/dist/pendingStateManager.d.ts.map +1 -1
  92. package/dist/pendingStateManager.js +7 -4
  93. package/dist/pendingStateManager.js.map +1 -1
  94. package/dist/runWhileConnectedCoordinator.d.ts.map +1 -1
  95. package/dist/runWhileConnectedCoordinator.js.map +1 -1
  96. package/dist/runningSummarizer.d.ts.map +1 -1
  97. package/dist/runningSummarizer.js +34 -21
  98. package/dist/runningSummarizer.js.map +1 -1
  99. package/dist/scheduleManager.d.ts.map +1 -1
  100. package/dist/scheduleManager.js +3 -2
  101. package/dist/scheduleManager.js.map +1 -1
  102. package/dist/serializedSnapshotStorage.d.ts +2 -2
  103. package/dist/serializedSnapshotStorage.d.ts.map +1 -1
  104. package/dist/serializedSnapshotStorage.js +5 -3
  105. package/dist/serializedSnapshotStorage.js.map +1 -1
  106. package/dist/summarizer.d.ts +2 -2
  107. package/dist/summarizer.d.ts.map +1 -1
  108. package/dist/summarizer.js +37 -17
  109. package/dist/summarizer.js.map +1 -1
  110. package/dist/summarizerClientElection.d.ts.map +1 -1
  111. package/dist/summarizerClientElection.js.map +1 -1
  112. package/dist/summarizerHandle.d.ts.map +1 -1
  113. package/dist/summarizerHandle.js.map +1 -1
  114. package/dist/summarizerHeuristics.d.ts.map +1 -1
  115. package/dist/summarizerHeuristics.js +6 -9
  116. package/dist/summarizerHeuristics.js.map +1 -1
  117. package/dist/summarizerTypes.d.ts +21 -21
  118. package/dist/summarizerTypes.d.ts.map +1 -1
  119. package/dist/summarizerTypes.js.map +1 -1
  120. package/dist/summaryCollection.d.ts.map +1 -1
  121. package/dist/summaryCollection.js +18 -8
  122. package/dist/summaryCollection.js.map +1 -1
  123. package/dist/summaryFormat.d.ts +22 -0
  124. package/dist/summaryFormat.d.ts.map +1 -1
  125. package/dist/summaryFormat.js +18 -10
  126. package/dist/summaryFormat.js.map +1 -1
  127. package/dist/summaryGenerator.d.ts.map +1 -1
  128. package/dist/summaryGenerator.js +34 -15
  129. package/dist/summaryGenerator.js.map +1 -1
  130. package/dist/summaryManager.d.ts.map +1 -1
  131. package/dist/summaryManager.js +21 -9
  132. package/dist/summaryManager.js.map +1 -1
  133. package/dist/throttler.d.ts +2 -2
  134. package/dist/throttler.d.ts.map +1 -1
  135. package/dist/throttler.js +4 -4
  136. package/dist/throttler.js.map +1 -1
  137. package/garbageCollection.md +15 -2
  138. package/lib/batchTracker.d.ts.map +1 -1
  139. package/lib/batchTracker.js +2 -1
  140. package/lib/batchTracker.js.map +1 -1
  141. package/lib/blobManager.d.ts +9 -2
  142. package/lib/blobManager.d.ts.map +1 -1
  143. package/lib/blobManager.js +82 -35
  144. package/lib/blobManager.js.map +1 -1
  145. package/lib/connectionTelemetry.d.ts.map +1 -1
  146. package/lib/connectionTelemetry.js +11 -9
  147. package/lib/connectionTelemetry.js.map +1 -1
  148. package/lib/containerHandleContext.d.ts.map +1 -1
  149. package/lib/containerHandleContext.js +3 -1
  150. package/lib/containerHandleContext.js.map +1 -1
  151. package/lib/containerRuntime.d.ts +10 -0
  152. package/lib/containerRuntime.d.ts.map +1 -1
  153. package/lib/containerRuntime.js +146 -78
  154. package/lib/containerRuntime.js.map +1 -1
  155. package/lib/dataStore.d.ts.map +1 -1
  156. package/lib/dataStore.js +11 -9
  157. package/lib/dataStore.js.map +1 -1
  158. package/lib/dataStoreContext.d.ts +18 -1
  159. package/lib/dataStoreContext.d.ts.map +1 -1
  160. package/lib/dataStoreContext.js +68 -17
  161. package/lib/dataStoreContext.js.map +1 -1
  162. package/lib/dataStoreContexts.d.ts.map +1 -1
  163. package/lib/dataStoreContexts.js +7 -3
  164. package/lib/dataStoreContexts.js.map +1 -1
  165. package/lib/dataStoreRegistry.d.ts.map +1 -1
  166. package/lib/dataStoreRegistry.js +3 -1
  167. package/lib/dataStoreRegistry.js.map +1 -1
  168. package/lib/dataStores.d.ts +26 -1
  169. package/lib/dataStores.d.ts.map +1 -1
  170. package/lib/dataStores.js +109 -24
  171. package/lib/dataStores.js.map +1 -1
  172. package/lib/deltaScheduler.d.ts.map +1 -1
  173. package/lib/deltaScheduler.js +9 -4
  174. package/lib/deltaScheduler.js.map +1 -1
  175. package/lib/garbageCollection.d.ts +34 -14
  176. package/lib/garbageCollection.d.ts.map +1 -1
  177. package/lib/garbageCollection.js +190 -95
  178. package/lib/garbageCollection.js.map +1 -1
  179. package/lib/garbageCollectionConstants.d.ts +3 -0
  180. package/lib/garbageCollectionConstants.d.ts.map +1 -1
  181. package/lib/garbageCollectionConstants.js +5 -0
  182. package/lib/garbageCollectionConstants.js.map +1 -1
  183. package/lib/garbageCollectionHelpers.d.ts +26 -0
  184. package/lib/garbageCollectionHelpers.d.ts.map +1 -0
  185. package/lib/garbageCollectionHelpers.js +40 -0
  186. package/lib/garbageCollectionHelpers.js.map +1 -0
  187. package/lib/gcSweepReadyUsageDetection.d.ts +5 -5
  188. package/lib/gcSweepReadyUsageDetection.d.ts.map +1 -1
  189. package/lib/gcSweepReadyUsageDetection.js +14 -10
  190. package/lib/gcSweepReadyUsageDetection.js.map +1 -1
  191. package/lib/index.d.ts +2 -2
  192. package/lib/index.d.ts.map +1 -1
  193. package/lib/index.js +1 -1
  194. package/lib/index.js.map +1 -1
  195. package/lib/opLifecycle/batchManager.d.ts +5 -5
  196. package/lib/opLifecycle/batchManager.d.ts.map +1 -1
  197. package/lib/opLifecycle/batchManager.js +19 -12
  198. package/lib/opLifecycle/batchManager.js.map +1 -1
  199. package/lib/opLifecycle/definitions.d.ts.map +1 -1
  200. package/lib/opLifecycle/definitions.js.map +1 -1
  201. package/lib/opLifecycle/index.d.ts.map +1 -1
  202. package/lib/opLifecycle/index.js.map +1 -1
  203. package/lib/opLifecycle/opCompressor.d.ts.map +1 -1
  204. package/lib/opLifecycle/opCompressor.js.map +1 -1
  205. package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
  206. package/lib/opLifecycle/opDecompressor.js +5 -2
  207. package/lib/opLifecycle/opDecompressor.js.map +1 -1
  208. package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
  209. package/lib/opLifecycle/opSplitter.js +5 -2
  210. package/lib/opLifecycle/opSplitter.js.map +1 -1
  211. package/lib/opLifecycle/outbox.d.ts.map +1 -1
  212. package/lib/opLifecycle/outbox.js +19 -17
  213. package/lib/opLifecycle/outbox.js.map +1 -1
  214. package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  215. package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
  216. package/lib/opProperties.d.ts.map +1 -1
  217. package/lib/opProperties.js +1 -3
  218. package/lib/opProperties.js.map +1 -1
  219. package/lib/orderedClientElection.d.ts.map +1 -1
  220. package/lib/orderedClientElection.js +10 -4
  221. package/lib/orderedClientElection.js.map +1 -1
  222. package/lib/packageVersion.d.ts +1 -1
  223. package/lib/packageVersion.js +1 -1
  224. package/lib/packageVersion.js.map +1 -1
  225. package/lib/pendingStateManager.d.ts +7 -0
  226. package/lib/pendingStateManager.d.ts.map +1 -1
  227. package/lib/pendingStateManager.js +7 -4
  228. package/lib/pendingStateManager.js.map +1 -1
  229. package/lib/runWhileConnectedCoordinator.d.ts.map +1 -1
  230. package/lib/runWhileConnectedCoordinator.js.map +1 -1
  231. package/lib/runningSummarizer.d.ts.map +1 -1
  232. package/lib/runningSummarizer.js +35 -22
  233. package/lib/runningSummarizer.js.map +1 -1
  234. package/lib/scheduleManager.d.ts.map +1 -1
  235. package/lib/scheduleManager.js +3 -2
  236. package/lib/scheduleManager.js.map +1 -1
  237. package/lib/serializedSnapshotStorage.d.ts +2 -2
  238. package/lib/serializedSnapshotStorage.d.ts.map +1 -1
  239. package/lib/serializedSnapshotStorage.js +5 -3
  240. package/lib/serializedSnapshotStorage.js.map +1 -1
  241. package/lib/summarizer.d.ts +2 -2
  242. package/lib/summarizer.d.ts.map +1 -1
  243. package/lib/summarizer.js +37 -17
  244. package/lib/summarizer.js.map +1 -1
  245. package/lib/summarizerClientElection.d.ts.map +1 -1
  246. package/lib/summarizerClientElection.js.map +1 -1
  247. package/lib/summarizerHandle.d.ts.map +1 -1
  248. package/lib/summarizerHandle.js.map +1 -1
  249. package/lib/summarizerHeuristics.d.ts.map +1 -1
  250. package/lib/summarizerHeuristics.js +6 -9
  251. package/lib/summarizerHeuristics.js.map +1 -1
  252. package/lib/summarizerTypes.d.ts +21 -21
  253. package/lib/summarizerTypes.d.ts.map +1 -1
  254. package/lib/summarizerTypes.js.map +1 -1
  255. package/lib/summaryCollection.d.ts.map +1 -1
  256. package/lib/summaryCollection.js +18 -8
  257. package/lib/summaryCollection.js.map +1 -1
  258. package/lib/summaryFormat.d.ts +22 -0
  259. package/lib/summaryFormat.d.ts.map +1 -1
  260. package/lib/summaryFormat.js +20 -12
  261. package/lib/summaryFormat.js.map +1 -1
  262. package/lib/summaryGenerator.d.ts.map +1 -1
  263. package/lib/summaryGenerator.js +34 -15
  264. package/lib/summaryGenerator.js.map +1 -1
  265. package/lib/summaryManager.d.ts.map +1 -1
  266. package/lib/summaryManager.js +21 -9
  267. package/lib/summaryManager.js.map +1 -1
  268. package/lib/throttler.d.ts +2 -2
  269. package/lib/throttler.d.ts.map +1 -1
  270. package/lib/throttler.js +4 -4
  271. package/lib/throttler.js.map +1 -1
  272. package/package.json +121 -149
  273. package/prettier.config.cjs +1 -1
  274. package/src/batchTracker.ts +54 -49
  275. package/src/blobManager.ts +793 -672
  276. package/src/connectionTelemetry.ts +280 -249
  277. package/src/containerHandleContext.ts +27 -29
  278. package/src/containerRuntime.ts +3168 -2940
  279. package/src/dataStore.ts +172 -159
  280. package/src/dataStoreContext.ts +1098 -996
  281. package/src/dataStoreContexts.ts +178 -161
  282. package/src/dataStoreRegistry.ts +25 -20
  283. package/src/dataStores.ts +884 -728
  284. package/src/deltaScheduler.ts +158 -150
  285. package/src/garbageCollection.ts +1883 -1692
  286. package/src/garbageCollectionConstants.ts +6 -0
  287. package/src/garbageCollectionHelpers.ts +61 -0
  288. package/src/gcSweepReadyUsageDetection.ts +89 -83
  289. package/src/index.ts +67 -66
  290. package/src/opLifecycle/README.md +152 -0
  291. package/src/opLifecycle/batchManager.ts +145 -141
  292. package/src/opLifecycle/definitions.ts +29 -29
  293. package/src/opLifecycle/index.ts +5 -5
  294. package/src/opLifecycle/opCompressor.ts +54 -53
  295. package/src/opLifecycle/opDecompressor.ts +100 -81
  296. package/src/opLifecycle/opSplitter.ts +214 -188
  297. package/src/opLifecycle/outbox.ts +204 -194
  298. package/src/opLifecycle/remoteMessageProcessor.ts +62 -62
  299. package/src/opProperties.ts +11 -9
  300. package/src/orderedClientElection.ts +489 -457
  301. package/src/packageVersion.ts +1 -1
  302. package/src/pendingStateManager.ts +384 -338
  303. package/src/runWhileConnectedCoordinator.ts +78 -71
  304. package/src/runningSummarizer.ts +619 -581
  305. package/src/scheduleManager.ts +299 -269
  306. package/src/serializedSnapshotStorage.ts +126 -112
  307. package/src/summarizer.ts +417 -381
  308. package/src/summarizerClientElection.ts +107 -100
  309. package/src/summarizerHandle.ts +11 -9
  310. package/src/summarizerHeuristics.ts +183 -186
  311. package/src/summarizerTypes.ts +344 -330
  312. package/src/summaryCollection.ts +378 -349
  313. package/src/summaryFormat.ts +170 -126
  314. package/src/summaryGenerator.ts +465 -406
  315. package/src/summaryManager.ts +377 -348
  316. package/src/throttler.ts +131 -122
  317. package/tsconfig.esnext.json +6 -6
  318. package/tsconfig.json +9 -13
  319. package/dist/garbageCollectionTombstoneUtils.d.ts +0 -14
  320. package/dist/garbageCollectionTombstoneUtils.d.ts.map +0 -1
  321. package/dist/garbageCollectionTombstoneUtils.js +0 -23
  322. package/dist/garbageCollectionTombstoneUtils.js.map +0 -1
  323. package/lib/garbageCollectionTombstoneUtils.d.ts +0 -14
  324. package/lib/garbageCollectionTombstoneUtils.d.ts.map +0 -1
  325. package/lib/garbageCollectionTombstoneUtils.js +0 -19
  326. package/lib/garbageCollectionTombstoneUtils.js.map +0 -1
  327. package/src/garbageCollectionTombstoneUtils.ts +0 -28
@@ -1 +1 @@
1
- {"version":3,"file":"runningSummarizer.js","sourceRoot":"","sources":["../src/runningSummarizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;AAGH,+DAAqF;AACrF,qEAA6D;AAC7D,+DAAgE;AAChE,+EAG8C;AAC9C,qEAA8D;AAI9D,iDAAwC;AACxC,iEAAkE;AAkBlE,yDAK4B;AAE5B,MAAM,uBAAuB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AAE7D;;;;;;GAMG;AACH,MAAa,iBAAiB;IA2E1B,YACI,UAA4B,EACX,cAAqC,EACrC,aAAoC,EACpC,qBAAuF,EACvF,aAAsC,EACtC,qBAAqD,EACrD,iBAAoC,EACpC,iBAA4C,EAC5C,sBAA8D,EAC9D,OAA2B;QAR3B,mBAAc,GAAd,cAAc,CAAuB;QACrC,kBAAa,GAAb,aAAa,CAAuB;QACpC,0BAAqB,GAArB,qBAAqB,CAAkE;QACvF,kBAAa,GAAb,aAAa,CAAyB;QACtC,0BAAqB,GAArB,qBAAqB,CAAgC;QACrD,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,sBAAiB,GAAjB,iBAAiB,CAA2B;QAC5C,2BAAsB,GAAtB,sBAAsB,CAAw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,aAAa,CAAC,oBAAoB,GAAG,IAAI,CAAC,eAAe,CAAC,mBAAmB;eAClF,IAAI,CAAC,eAAe,KAAK,SAAS,EACvC;YACE,uFAAuF;YACvF,OAAO,KAAK,CAAC;SAChB;QACD,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,eAAe,CAAC;QACjE,+FAA+F;QAC/F,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QACjC,IAAI,CAAC,gBAAgB,CACjB,EAAE,MAAM,EAAE,mBAAmB,MAAM,EAAE,EAAE,EACvC,OAAO,EACP,IAAI,CAAC,iBAAiB,EACtB,cAAc,CAAC,CAAC;QACpB,OAAO,IAAI,CAAC;IAChB,CAAC;IAEO,sBAAsB;QAC1B,IAAI,IAAI,CAAC,eAAe,KAAK,SAAS,EAAE;YACpC,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,IAAI,CAAC,uCAAuC,EAAE,SAAS,CAAC,CAAC;YAC7F,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;SACpC;IACL,CAAC;CACJ;AA7iBD,8CA6iBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, delay, Deferred, PromiseTimer } from \"@fluidframework/common-utils\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport { isRuntimeMessage } from \"@fluidframework/driver-utils\";\nimport {\n ISequencedDocumentMessage,\n MessageType,\n} from \"@fluidframework/protocol-definitions\";\nimport { ChildLogger } from \"@fluidframework/telemetry-utils\";\nimport {\n ISummaryConfiguration,\n} from \"./containerRuntime\";\nimport { opSize } from \"./opProperties\";\nimport { SummarizeHeuristicRunner } from \"./summarizerHeuristics\";\nimport {\n IEnqueueSummarizeOptions,\n ISummarizeOptions,\n ISummarizeHeuristicData,\n ISummarizeHeuristicRunner,\n IOnDemandSummarizeOptions,\n EnqueueSummarizeResult,\n SummarizerStopReason,\n ISubmitSummaryOptions,\n SubmitSummaryResult,\n ISummaryCancellationToken,\n ISummarizeResults,\n ISummarizeTelemetryProperties,\n ISummarizerRuntime,\n ISummarizeRunnerTelemetry,\n} from \"./summarizerTypes\";\nimport { IClientSummaryWatcher, SummaryCollection } from \"./summaryCollection\";\nimport {\n raceTimer,\n SummarizeReason,\n SummarizeResultBuilder,\n SummaryGenerator,\n} from \"./summaryGenerator\";\n\nconst maxSummarizeAckWaitTime = 10 * 60 * 1000; // 10 minutes\n\n/**\n * An instance of RunningSummarizer manages the heuristics for summarizing.\n * Until disposed, the instance of RunningSummarizer can assume that it is\n * in a state of running, meaning it is connected and initialized. It keeps\n * track of summaries that it is generating as they are broadcast and acked/nacked.\n * This object is created and controlled by Summarizer object.\n */\nexport class RunningSummarizer implements IDisposable {\n public static async start(\n logger: ITelemetryLogger,\n summaryWatcher: IClientSummaryWatcher,\n configuration: ISummaryConfiguration,\n submitSummaryCallback: (options: ISubmitSummaryOptions) => Promise<SubmitSummaryResult>,\n heuristicData: ISummarizeHeuristicData,\n raiseSummarizingError: (errorMessage: string) => void,\n summaryCollection: SummaryCollection,\n cancellationToken: ISummaryCancellationToken,\n stopSummarizerCallback: (reason: SummarizerStopReason) => void,\n runtime: ISummarizerRuntime,\n ): Promise<RunningSummarizer> {\n const summarizer = new RunningSummarizer(\n logger,\n summaryWatcher,\n configuration,\n submitSummaryCallback,\n heuristicData,\n raiseSummarizingError,\n summaryCollection,\n cancellationToken,\n stopSummarizerCallback,\n runtime);\n\n await summarizer.waitStart();\n\n // Update heuristic counts\n // By the time we get here, there are potentially ops missing from the heuristic summary counts\n // Examples of where this could happen:\n // 1. Op is processed during the time that we are initiating the RunningSummarizer instance but before we\n // listen for the op events (will get missed by the handlers in the current workflow)\n // 2. Op was sequenced after the last time we summarized (op sequence number > summarize ref sequence number)\n const diff = runtime.deltaManager.lastSequenceNumber - (\n heuristicData.lastSuccessfulSummary.refSequenceNumber\n + heuristicData.numNonRuntimeOps\n + heuristicData.numRuntimeOps);\n heuristicData.hasMissingOpData = diff > 0;\n\n if (heuristicData.hasMissingOpData) {\n // Split the diff 50-50 and increment the counts appropriately\n heuristicData.numNonRuntimeOps += Math.ceil(diff / 2);\n heuristicData.numRuntimeOps += Math.floor(diff / 2);\n }\n\n // Update last seq number (in case the handlers haven't processed anything yet)\n heuristicData.lastOpSequenceNumber = runtime.deltaManager.lastSequenceNumber;\n\n // Start heuristics\n summarizer.heuristicRunner?.start();\n summarizer.heuristicRunner?.run();\n\n return summarizer;\n }\n\n public get disposed() { return this._disposed; }\n private stopping = false;\n private _disposed = false;\n private summarizingLock: Promise<void> | undefined;\n private refreshSummaryAckLock: Promise<void> | undefined;\n private tryWhileSummarizing = false;\n private readonly pendingAckTimer: PromiseTimer;\n private heuristicRunner?: ISummarizeHeuristicRunner;\n private readonly generator: SummaryGenerator;\n private readonly logger: ITelemetryLogger;\n private enqueuedSummary: {\n reason: SummarizeReason;\n afterSequenceNumber: number;\n options: ISummarizeOptions;\n readonly resultsBuilder: SummarizeResultBuilder;\n } | undefined;\n private summarizeCount = 0;\n private totalSuccessfulAttempts = 0;\n private initialized = false;\n\n private constructor(\n baseLogger: ITelemetryLogger,\n private readonly summaryWatcher: IClientSummaryWatcher,\n private readonly configuration: ISummaryConfiguration,\n private readonly submitSummaryCallback: (options: ISubmitSummaryOptions) => Promise<SubmitSummaryResult>,\n private readonly heuristicData: ISummarizeHeuristicData,\n private readonly raiseSummarizingError: (errorMessage: string) => void,\n private readonly summaryCollection: SummaryCollection,\n private readonly cancellationToken: ISummaryCancellationToken,\n private readonly stopSummarizerCallback: (reason: SummarizerStopReason) => void,\n private readonly runtime: ISummarizerRuntime,\n ) {\n const telemetryProps: ISummarizeRunnerTelemetry = {\n summarizeCount: () => this.summarizeCount,\n summarizerSuccessfulAttempts: () => this.totalSuccessfulAttempts,\n };\n\n this.logger = ChildLogger.create(\n baseLogger, \"Running\",\n {\n all: telemetryProps,\n },\n );\n\n if (configuration.state !== \"disableHeuristics\") {\n assert(this.configuration.state === \"enabled\", 0x2ea /* \"Configuration state should be enabled\" */);\n this.heuristicRunner = new SummarizeHeuristicRunner(\n heuristicData,\n this.configuration,\n (reason) => this.trySummarize(reason),\n this.logger);\n }\n\n assert(\n this.configuration.state !== \"disabled\",\n 0x2eb /* \"Summary not supported with configuration disabled\" */,\n );\n\n // Cap the maximum amount of time client will wait for a summarize op ack to maxSummarizeAckWaitTime\n // configuration.maxAckWaitTime is composed from defaults, server values, and runtime overrides\n\n const maxAckWaitTime = Math.min(this.configuration.maxAckWaitTime, maxSummarizeAckWaitTime);\n\n this.pendingAckTimer = new PromiseTimer(\n maxAckWaitTime,\n () => {\n // pre-0.58 error message: summaryAckWaitTimeout\n this.raiseSummarizingError(\"Pending summary ack not received in time\");\n // Note: summarizeCount (from ChildLogger definition) may be 0,\n // since this code path is hit when RunningSummarizer first starts up,\n // before this instance has kicked off a new summarize run.\n this.logger.sendErrorEvent({\n eventName: \"SummaryAckWaitTimeout\",\n maxAckWaitTime,\n referenceSequenceNumber: this.heuristicData.lastAttempt.refSequenceNumber,\n summarySequenceNumber: this.heuristicData.lastAttempt.summarySequenceNumber,\n timePending: Date.now() - this.heuristicData.lastAttempt.summaryTime,\n });\n });\n // Set up pending ack timeout by op timestamp differences for previous summaries.\n summaryCollection.setPendingAckTimerTimeoutCallback(maxAckWaitTime, () => {\n if (this.pendingAckTimer.hasTimer) {\n this.logger.sendTelemetryEvent({\n eventName: \"MissingSummaryAckFoundByOps\",\n referenceSequenceNumber: this.heuristicData.lastAttempt.refSequenceNumber,\n summarySequenceNumber: this.heuristicData.lastAttempt.summarySequenceNumber,\n });\n this.pendingAckTimer.clear();\n }\n });\n\n this.generator = new SummaryGenerator(\n this.pendingAckTimer,\n this.heuristicData,\n this.submitSummaryCallback,\n this.raiseSummarizingError,\n () => { this.totalSuccessfulAttempts++; },\n this.summaryWatcher,\n this.logger,\n );\n\n // Listen for ops\n this.runtime.deltaManager.on(\"op\", (op) => { this.handleOp(op); });\n }\n\n public dispose(): void {\n this.runtime.deltaManager.off(\"op\", (op) => { this.handleOp(op); });\n this.summaryWatcher.dispose();\n this.heuristicRunner?.dispose();\n this.heuristicRunner = undefined;\n this.generator.dispose();\n this.pendingAckTimer.clear();\n this.disposeEnqueuedSummary();\n this._disposed = true;\n this.stopping = true;\n }\n\n /**\n * RunningSummarizer's logger includes the sequenced index of the current summary on each event.\n * If some other Summarizer code wants that event on their logs they can get it here,\n * but only if they're logging about that same summary.\n * @param summaryOpRefSeq - RefSeq number of the summary op, to ensure the log correlation will be correct\n */\n public tryGetCorrelatedLogger = (summaryOpRefSeq) =>\n this.heuristicData.lastAttempt.refSequenceNumber === summaryOpRefSeq\n ? this.logger\n : undefined;\n\n /** We only want a single heuristic runner micro-task (will provide better optimized grouping of ops) */\n private heuristicRunnerMicroTaskExists = false;\n\n public handleOp(op: ISequencedDocumentMessage) {\n this.heuristicData.lastOpSequenceNumber = op.sequenceNumber;\n\n if (isRuntimeMessage(op)) {\n this.heuristicData.numRuntimeOps++;\n } else {\n this.heuristicData.numNonRuntimeOps++;\n }\n\n this.heuristicData.totalOpsSize += opSize(op);\n\n // Check for enqueued on-demand summaries; Intentionally do nothing otherwise\n if (this.initialized\n && this.opCanTriggerSummary(op)\n && !this.tryRunEnqueuedSummary()\n && !this.heuristicRunnerMicroTaskExists) {\n this.heuristicRunnerMicroTaskExists = true;\n Promise.resolve().then(() => {\n this.heuristicRunner?.run();\n }).finally(() => {\n this.heuristicRunnerMicroTaskExists = false;\n });\n }\n }\n\n /**\n * Can the given op trigger a summary?\n * # Currently always prevents summaries for Summarize and SummaryAck/Nack ops\n * @param op - op to check\n * @returns true if this op can trigger a summary\n */\n private opCanTriggerSummary(op: ISequencedDocumentMessage): boolean {\n switch (op.type) {\n case MessageType.Summarize:\n case MessageType.SummaryAck:\n case MessageType.SummaryNack:\n return false;\n default:\n return isRuntimeMessage(op) || this.nonRuntimeOpCanTriggerSummary();\n }\n }\n\n private nonRuntimeOpCanTriggerSummary(): boolean {\n const opsSinceLastAck = this.heuristicData.lastOpSequenceNumber - this.heuristicData.lastSuccessfulSummary.refSequenceNumber;\n return this.configuration.state === \"enabled\"\n && (this.configuration.nonRuntimeHeuristicThreshold === undefined\n || this.configuration.nonRuntimeHeuristicThreshold <= opsSinceLastAck);\n }\n\n public async waitStop(allowLastSummary: boolean): Promise<void> {\n if (this.stopping) {\n return;\n }\n\n this.stopping = true;\n\n this.disposeEnqueuedSummary();\n\n // This will try to run lastSummary if needed.\n if (allowLastSummary && this.heuristicRunner?.shouldRunLastSummary()) {\n if (this.summarizingLock === undefined) {\n this.trySummarizeOnce(\n // summarizeProps\n { reason: \"lastSummary\" },\n // ISummarizeOptions, using defaults: { refreshLatestAck: false, fullTree: false }\n {});\n }\n }\n\n // Note that trySummarizeOnce() call above returns right away, without waiting.\n // So we need to wait for its completion, otherwise it would be destroyed right away.\n // That said, if summary lock was taken upfront, this wait might wait on multiple retries to\n // submit summary. We should reconsider this flow and make summarizer move to exit faster.\n // This resolves when the current pending summary gets an ack or fails.\n await this.summarizingLock;\n }\n\n private async waitStart() {\n // Wait no longer than ack timeout for all pending\n const waitStartResult = await raceTimer(\n this.summaryWatcher.waitFlushed(),\n this.pendingAckTimer.start(),\n );\n this.pendingAckTimer.clear();\n\n // Remove pending ack wait timeout by op timestamp comparison, because\n // it has race conditions with summaries submitted by this same client.\n this.summaryCollection.unsetPendingAckTimerTimeoutCallback();\n\n if (waitStartResult.result === \"done\" && waitStartResult.value !== undefined) {\n this.heuristicData.updateWithLastSummaryAckInfo({\n refSequenceNumber: waitStartResult.value.summaryOp.referenceSequenceNumber,\n // This will be the Summarizer starting point so only use timestamps from client's machine.\n summaryTime: Date.now(),\n summarySequenceNumber: waitStartResult.value.summaryOp.sequenceNumber,\n });\n }\n this.initialized = true;\n }\n\n /**\n * Blocks a new summarizer from running in case RefreshSummaryAck is being processed.\n * Assumes that caller checked upfront for lack of concurrent action (this.refreshSummaryAckLock)\n * before calling this API. I.e. caller is responsible for either erroring out or waiting on this promise.\n * Note: The refreshSummaryAckLock makes sure no summarizer gets enqueued or processed\n * until the refresh has completed. One can't rely uniquely on the summarizingLock as the\n * refreshLatestSummaryAck also happens during the time summarizingLock !== undefined.\n * Ex. Summarizer submits a summay + op and then waits for the Summary Ack to proceed\n * with the refreshLatestSummaryAck and complete the summary.\n * @param action - action to perform.\n * @returns - result of action.\n */\n public async lockedRefreshSummaryAckAction<T>(action: () => Promise<T>) {\n assert(this.refreshSummaryAckLock === undefined,\n 0x396 /* Refresh Summary Ack - Caller is responsible for checking lock */);\n\n const refreshSummaryAckLock = new Deferred<void>();\n this.refreshSummaryAckLock = refreshSummaryAckLock.promise;\n\n return action().finally(() => {\n refreshSummaryAckLock.resolve();\n this.refreshSummaryAckLock = undefined;\n });\n }\n\n /**\n * Runs single summary action that prevents any other concurrent actions.\n * Assumes that caller checked upfront for lack of concurrent action (this.summarizingLock)\n * before calling this API. I.e. caller is responsible for either erroring out or waiting on this promise.\n * @param action - action to perform.\n * @returns - result of action.\n */\n private async lockedSummaryAction<T>(action: () => Promise<T>) {\n assert(this.summarizingLock === undefined, 0x25b /* \"Caller is responsible for checking lock\" */);\n\n const summarizingLock = new Deferred<void>();\n this.summarizingLock = summarizingLock.promise;\n\n this.summarizeCount++;\n // Make sure the RefreshLatestSummaryAck is not being executed.\n await this.refreshSummaryAckLock;\n\n return action().finally(() => {\n summarizingLock.resolve();\n this.summarizingLock = undefined;\n\n const retry = this.tryWhileSummarizing;\n this.tryWhileSummarizing = false;\n\n // After summarizing, we should check to see if we need to summarize again.\n // Rerun the heuristics and check for enqueued summaries.\n if (!this.stopping && !this.tryRunEnqueuedSummary() && retry) {\n this.heuristicRunner?.run();\n }\n });\n }\n\n /**\n * Runs single summarize attempt\n * @param summarizeProps - props to log with each telemetry event associated with this attempt\n * @param options - summary options\n * @param cancellationToken - cancellation token to use to be able to cancel this summary, if needed\n * @param resultsBuilder - optional, result builder to use.\n * @returns ISummarizeResult - result of running a summary.\n */\n private trySummarizeOnce(\n summarizeProps: ISummarizeTelemetryProperties,\n options: ISummarizeOptions,\n cancellationToken = this.cancellationToken,\n resultsBuilder = new SummarizeResultBuilder()): ISummarizeResults {\n this.lockedSummaryAction(async () => {\n const summarizeResult = this.generator.summarize(\n summarizeProps,\n options,\n cancellationToken,\n resultsBuilder);\n // ensure we wait till the end of the process\n return summarizeResult.receivedSummaryAckOrNack;\n }).catch((error) => {\n // SummaryGenerator.summarize() does not throw exceptions - it converts them to failed result\n // on resultsBuilder\n // We do not care about exceptions on receivedSummaryAckOrNack - caller should check results\n // and take a appropriate action.\n });\n\n return resultsBuilder.build();\n }\n\n /** Heuristics summarize attempt. */\n private trySummarize(\n reason: SummarizeReason,\n cancellationToken = this.cancellationToken): void {\n if (this.summarizingLock !== undefined) {\n // lockedSummaryAction() will retry heuristic-based summary at the end of current attempt\n // if it's still needed\n this.tryWhileSummarizing = true;\n return;\n }\n\n this.lockedSummaryAction(async () => {\n const attempts: (ISummarizeOptions & { delaySeconds?: number; })[] = [\n { refreshLatestAck: false, fullTree: false },\n { refreshLatestAck: true, fullTree: false },\n { refreshLatestAck: true, fullTree: false, delaySeconds: 2 * 60 },\n { refreshLatestAck: true, fullTree: true, delaySeconds: 10 * 60 },\n ];\n let overrideDelaySeconds: number | undefined;\n let summaryAttempts = 0;\n let summaryAttemptsPerPhase = 0;\n\n let lastResult: { message: string; error: any; } | undefined;\n\n for (let summaryAttemptPhase = 0; summaryAttemptPhase < attempts.length;) {\n if (this.cancellationToken.cancelled) {\n return;\n }\n\n // We only want to attempt 1 summary when reason is \"lastSummary\"\n if (++summaryAttempts > 1 && reason === \"lastSummary\") {\n return;\n }\n\n summaryAttemptsPerPhase++;\n\n const { delaySeconds: regularDelaySeconds = 0, ...options } = attempts[summaryAttemptPhase];\n const delaySeconds = overrideDelaySeconds ?? regularDelaySeconds;\n\n const summarizeProps: ISummarizeTelemetryProperties = {\n reason,\n summaryAttempts,\n summaryAttemptsPerPhase,\n summaryAttemptPhase: summaryAttemptPhase + 1, // make everything 1-based\n ...options,\n };\n\n if (delaySeconds > 0) {\n this.logger.sendPerformanceEvent({\n eventName: \"SummarizeAttemptDelay\",\n duration: delaySeconds,\n summaryNackDelay: overrideDelaySeconds !== undefined,\n ...summarizeProps,\n });\n await delay(delaySeconds * 1000);\n }\n\n // Make sure the refresh Summary Ack is not being executed.\n await this.refreshSummaryAckLock;\n\n // Note: no need to account for cancellationToken.waitCancelled here, as\n // this is accounted SummaryGenerator.summarizeCore that controls receivedSummaryAckOrNack.\n const resultSummarize = this.generator.summarize(summarizeProps, options, cancellationToken);\n const result = await resultSummarize.receivedSummaryAckOrNack;\n\n if (result.success) {\n return;\n }\n // Check for retryDelay that can come from summaryNack or upload summary flow.\n // Retry the same step only once per retryAfter response.\n overrideDelaySeconds = result.retryAfterSeconds;\n if (overrideDelaySeconds === undefined || summaryAttemptsPerPhase > 1) {\n summaryAttemptPhase++;\n summaryAttemptsPerPhase = 0;\n }\n lastResult = result;\n }\n\n // If all attempts failed, log error (with last attempt info) and close the summarizer container\n this.logger.sendErrorEvent({\n eventName: \"FailToSummarize\",\n reason,\n message: lastResult?.message,\n }, lastResult?.error);\n\n this.stopSummarizerCallback(\"failToSummarize\");\n }).catch((error) => {\n this.logger.sendErrorEvent({ eventName: \"UnexpectedSummarizeError\" }, error);\n });\n }\n\n /** {@inheritdoc (ISummarizer:interface).summarizeOnDemand} */\n public summarizeOnDemand(\n resultsBuilder: SummarizeResultBuilder = new SummarizeResultBuilder(),\n {\n reason,\n ...options\n }: IOnDemandSummarizeOptions): ISummarizeResults {\n if (this.stopping) {\n resultsBuilder.fail(\"RunningSummarizer stopped or disposed\", undefined);\n return resultsBuilder.build();\n }\n // Check for concurrent summary attempts. If one is found,\n // return a promise that caller can await before trying again.\n if (this.summarizingLock !== undefined) {\n // The heuristics are blocking concurrent summarize attempts.\n throw new UsageError(\"Attempted to run an already-running summarizer on demand\");\n }\n\n const result = this.trySummarizeOnce(\n { reason: `onDemand/${reason}` },\n options,\n this.cancellationToken,\n resultsBuilder);\n return result;\n }\n\n /** {@inheritdoc (ISummarizer:interface).enqueueSummarize} */\n public enqueueSummarize({\n reason,\n afterSequenceNumber = 0,\n override = false,\n ...options\n }: IEnqueueSummarizeOptions): EnqueueSummarizeResult {\n const onDemandReason = `enqueue;${reason}` as const;\n let overridden = false;\n if (this.enqueuedSummary !== undefined) {\n if (!override) {\n return { alreadyEnqueued: true };\n }\n // Override existing enqueued summarize attempt.\n this.enqueuedSummary.resultsBuilder.fail(\n \"Aborted; overridden by another enqueue summarize attempt\",\n undefined,\n );\n this.enqueuedSummary = undefined;\n overridden = true;\n }\n this.enqueuedSummary = {\n reason: onDemandReason,\n afterSequenceNumber,\n options,\n resultsBuilder: new SummarizeResultBuilder(),\n };\n const results = this.enqueuedSummary.resultsBuilder.build();\n this.tryRunEnqueuedSummary();\n return overridden ? {\n ...results,\n alreadyEnqueued: true,\n overridden: true,\n } : results;\n }\n\n private tryRunEnqueuedSummary() {\n if (this.stopping) {\n this.disposeEnqueuedSummary();\n return false;\n }\n if (\n this.enqueuedSummary === undefined\n || this.heuristicData.lastOpSequenceNumber < this.enqueuedSummary.afterSequenceNumber\n || this.summarizingLock !== undefined\n ) {\n // If no enqueued summary is ready or a summary is already in progress, take no action.\n return false;\n }\n const { reason, resultsBuilder, options } = this.enqueuedSummary;\n // Set to undefined first, so that subsequent enqueue attempt while summarize will occur later.\n this.enqueuedSummary = undefined;\n this.trySummarizeOnce(\n { reason: `enqueuedSummary/${reason}` },\n options,\n this.cancellationToken,\n resultsBuilder);\n return true;\n }\n\n private disposeEnqueuedSummary() {\n if (this.enqueuedSummary !== undefined) {\n this.enqueuedSummary.resultsBuilder.fail(\"RunningSummarizer stopped or disposed\", undefined);\n this.enqueuedSummary = undefined;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"runningSummarizer.js","sourceRoot":"","sources":["../src/runningSummarizer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vC,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,IAAI,CACvC,uCAAuC,EACvC,SAAS,CACT,CAAC;YACF,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;SACjC;IACF,CAAC;CACD;AAxlBD,8CAwlBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, delay, Deferred, PromiseTimer } from \"@fluidframework/common-utils\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport { isRuntimeMessage } from \"@fluidframework/driver-utils\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport { ChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { ISummaryConfiguration } from \"./containerRuntime\";\nimport { opSize } from \"./opProperties\";\nimport { SummarizeHeuristicRunner } from \"./summarizerHeuristics\";\nimport {\n\tIEnqueueSummarizeOptions,\n\tISummarizeOptions,\n\tISummarizeHeuristicData,\n\tISummarizeHeuristicRunner,\n\tIOnDemandSummarizeOptions,\n\tEnqueueSummarizeResult,\n\tSummarizerStopReason,\n\tISubmitSummaryOptions,\n\tSubmitSummaryResult,\n\tISummaryCancellationToken,\n\tISummarizeResults,\n\tISummarizeTelemetryProperties,\n\tISummarizerRuntime,\n\tISummarizeRunnerTelemetry,\n} from \"./summarizerTypes\";\nimport { IClientSummaryWatcher, SummaryCollection } from \"./summaryCollection\";\nimport {\n\traceTimer,\n\tSummarizeReason,\n\tSummarizeResultBuilder,\n\tSummaryGenerator,\n} from \"./summaryGenerator\";\n\nconst maxSummarizeAckWaitTime = 10 * 60 * 1000; // 10 minutes\n\n/**\n * An instance of RunningSummarizer manages the heuristics for summarizing.\n * Until disposed, the instance of RunningSummarizer can assume that it is\n * in a state of running, meaning it is connected and initialized. It keeps\n * track of summaries that it is generating as they are broadcast and acked/nacked.\n * This object is created and controlled by Summarizer object.\n */\nexport class RunningSummarizer implements IDisposable {\n\tpublic static async start(\n\t\tlogger: ITelemetryLogger,\n\t\tsummaryWatcher: IClientSummaryWatcher,\n\t\tconfiguration: ISummaryConfiguration,\n\t\tsubmitSummaryCallback: (options: ISubmitSummaryOptions) => Promise<SubmitSummaryResult>,\n\t\theuristicData: ISummarizeHeuristicData,\n\t\traiseSummarizingError: (errorMessage: string) => void,\n\t\tsummaryCollection: SummaryCollection,\n\t\tcancellationToken: ISummaryCancellationToken,\n\t\tstopSummarizerCallback: (reason: SummarizerStopReason) => void,\n\t\truntime: ISummarizerRuntime,\n\t): Promise<RunningSummarizer> {\n\t\tconst summarizer = new RunningSummarizer(\n\t\t\tlogger,\n\t\t\tsummaryWatcher,\n\t\t\tconfiguration,\n\t\t\tsubmitSummaryCallback,\n\t\t\theuristicData,\n\t\t\traiseSummarizingError,\n\t\t\tsummaryCollection,\n\t\t\tcancellationToken,\n\t\t\tstopSummarizerCallback,\n\t\t\truntime,\n\t\t);\n\n\t\tawait summarizer.waitStart();\n\n\t\t// Update heuristic counts\n\t\t// By the time we get here, there are potentially ops missing from the heuristic summary counts\n\t\t// Examples of where this could happen:\n\t\t// 1. Op is processed during the time that we are initiating the RunningSummarizer instance but before we\n\t\t// listen for the op events (will get missed by the handlers in the current workflow)\n\t\t// 2. Op was sequenced after the last time we summarized (op sequence number > summarize ref sequence number)\n\t\tconst diff =\n\t\t\truntime.deltaManager.lastSequenceNumber -\n\t\t\t(heuristicData.lastSuccessfulSummary.refSequenceNumber +\n\t\t\t\theuristicData.numNonRuntimeOps +\n\t\t\t\theuristicData.numRuntimeOps);\n\t\theuristicData.hasMissingOpData = diff > 0;\n\n\t\tif (heuristicData.hasMissingOpData) {\n\t\t\t// Split the diff 50-50 and increment the counts appropriately\n\t\t\theuristicData.numNonRuntimeOps += Math.ceil(diff / 2);\n\t\t\theuristicData.numRuntimeOps += Math.floor(diff / 2);\n\t\t}\n\n\t\t// Update last seq number (in case the handlers haven't processed anything yet)\n\t\theuristicData.lastOpSequenceNumber = runtime.deltaManager.lastSequenceNumber;\n\n\t\t// Start heuristics\n\t\tsummarizer.heuristicRunner?.start();\n\t\tsummarizer.heuristicRunner?.run();\n\n\t\treturn summarizer;\n\t}\n\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\tprivate stopping = false;\n\tprivate _disposed = false;\n\tprivate summarizingLock: Promise<void> | undefined;\n\tprivate refreshSummaryAckLock: Promise<void> | undefined;\n\tprivate tryWhileSummarizing = false;\n\tprivate readonly pendingAckTimer: PromiseTimer;\n\tprivate heuristicRunner?: ISummarizeHeuristicRunner;\n\tprivate readonly generator: SummaryGenerator;\n\tprivate readonly logger: ITelemetryLogger;\n\tprivate enqueuedSummary:\n\t\t| {\n\t\t\t\treason: SummarizeReason;\n\t\t\t\tafterSequenceNumber: number;\n\t\t\t\toptions: ISummarizeOptions;\n\t\t\t\treadonly resultsBuilder: SummarizeResultBuilder;\n\t\t }\n\t\t| undefined;\n\tprivate summarizeCount = 0;\n\tprivate totalSuccessfulAttempts = 0;\n\tprivate initialized = false;\n\n\tprivate constructor(\n\t\tbaseLogger: ITelemetryLogger,\n\t\tprivate readonly summaryWatcher: IClientSummaryWatcher,\n\t\tprivate readonly configuration: ISummaryConfiguration,\n\t\tprivate readonly submitSummaryCallback: (\n\t\t\toptions: ISubmitSummaryOptions,\n\t\t) => Promise<SubmitSummaryResult>,\n\t\tprivate readonly heuristicData: ISummarizeHeuristicData,\n\t\tprivate readonly raiseSummarizingError: (errorMessage: string) => void,\n\t\tprivate readonly summaryCollection: SummaryCollection,\n\t\tprivate readonly cancellationToken: ISummaryCancellationToken,\n\t\tprivate readonly stopSummarizerCallback: (reason: SummarizerStopReason) => void,\n\t\tprivate readonly runtime: ISummarizerRuntime,\n\t) {\n\t\tconst telemetryProps: ISummarizeRunnerTelemetry = {\n\t\t\tsummarizeCount: () => this.summarizeCount,\n\t\t\tsummarizerSuccessfulAttempts: () => this.totalSuccessfulAttempts,\n\t\t};\n\n\t\tthis.logger = ChildLogger.create(baseLogger, \"Running\", {\n\t\t\tall: telemetryProps,\n\t\t});\n\n\t\tif (configuration.state !== \"disableHeuristics\") {\n\t\t\tassert(\n\t\t\t\tthis.configuration.state === \"enabled\",\n\t\t\t\t0x2ea /* \"Configuration state should be enabled\" */,\n\t\t\t);\n\t\t\tthis.heuristicRunner = new SummarizeHeuristicRunner(\n\t\t\t\theuristicData,\n\t\t\t\tthis.configuration,\n\t\t\t\t(reason) => this.trySummarize(reason),\n\t\t\t\tthis.logger,\n\t\t\t);\n\t\t}\n\n\t\tassert(\n\t\t\tthis.configuration.state !== \"disabled\",\n\t\t\t0x2eb /* \"Summary not supported with configuration disabled\" */,\n\t\t);\n\n\t\t// Cap the maximum amount of time client will wait for a summarize op ack to maxSummarizeAckWaitTime\n\t\t// configuration.maxAckWaitTime is composed from defaults, server values, and runtime overrides\n\n\t\tconst maxAckWaitTime = Math.min(this.configuration.maxAckWaitTime, maxSummarizeAckWaitTime);\n\n\t\tthis.pendingAckTimer = new PromiseTimer(maxAckWaitTime, () => {\n\t\t\t// pre-0.58 error message: summaryAckWaitTimeout\n\t\t\tthis.raiseSummarizingError(\"Pending summary ack not received in time\");\n\t\t\t// Note: summarizeCount (from ChildLogger definition) may be 0,\n\t\t\t// since this code path is hit when RunningSummarizer first starts up,\n\t\t\t// before this instance has kicked off a new summarize run.\n\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\teventName: \"SummaryAckWaitTimeout\",\n\t\t\t\tmaxAckWaitTime,\n\t\t\t\treferenceSequenceNumber: this.heuristicData.lastAttempt.refSequenceNumber,\n\t\t\t\tsummarySequenceNumber: this.heuristicData.lastAttempt.summarySequenceNumber,\n\t\t\t\ttimePending: Date.now() - this.heuristicData.lastAttempt.summaryTime,\n\t\t\t});\n\t\t});\n\t\t// Set up pending ack timeout by op timestamp differences for previous summaries.\n\t\tsummaryCollection.setPendingAckTimerTimeoutCallback(maxAckWaitTime, () => {\n\t\t\tif (this.pendingAckTimer.hasTimer) {\n\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"MissingSummaryAckFoundByOps\",\n\t\t\t\t\treferenceSequenceNumber: this.heuristicData.lastAttempt.refSequenceNumber,\n\t\t\t\t\tsummarySequenceNumber: this.heuristicData.lastAttempt.summarySequenceNumber,\n\t\t\t\t});\n\t\t\t\tthis.pendingAckTimer.clear();\n\t\t\t}\n\t\t});\n\n\t\tthis.generator = new SummaryGenerator(\n\t\t\tthis.pendingAckTimer,\n\t\t\tthis.heuristicData,\n\t\t\tthis.submitSummaryCallback,\n\t\t\tthis.raiseSummarizingError,\n\t\t\t() => {\n\t\t\t\tthis.totalSuccessfulAttempts++;\n\t\t\t},\n\t\t\tthis.summaryWatcher,\n\t\t\tthis.logger,\n\t\t);\n\n\t\t// Listen for ops\n\t\tthis.runtime.deltaManager.on(\"op\", (op) => {\n\t\t\tthis.handleOp(op);\n\t\t});\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.runtime.deltaManager.off(\"op\", (op) => {\n\t\t\tthis.handleOp(op);\n\t\t});\n\t\tthis.summaryWatcher.dispose();\n\t\tthis.heuristicRunner?.dispose();\n\t\tthis.heuristicRunner = undefined;\n\t\tthis.generator.dispose();\n\t\tthis.pendingAckTimer.clear();\n\t\tthis.disposeEnqueuedSummary();\n\t\tthis._disposed = true;\n\t\tthis.stopping = true;\n\t}\n\n\t/**\n\t * RunningSummarizer's logger includes the sequenced index of the current summary on each event.\n\t * If some other Summarizer code wants that event on their logs they can get it here,\n\t * but only if they're logging about that same summary.\n\t * @param summaryOpRefSeq - RefSeq number of the summary op, to ensure the log correlation will be correct\n\t */\n\tpublic tryGetCorrelatedLogger = (summaryOpRefSeq) =>\n\t\tthis.heuristicData.lastAttempt.refSequenceNumber === summaryOpRefSeq\n\t\t\t? this.logger\n\t\t\t: undefined;\n\n\t/** We only want a single heuristic runner micro-task (will provide better optimized grouping of ops) */\n\tprivate heuristicRunnerMicroTaskExists = false;\n\n\tpublic handleOp(op: ISequencedDocumentMessage) {\n\t\tthis.heuristicData.lastOpSequenceNumber = op.sequenceNumber;\n\n\t\tif (isRuntimeMessage(op)) {\n\t\t\tthis.heuristicData.numRuntimeOps++;\n\t\t} else {\n\t\t\tthis.heuristicData.numNonRuntimeOps++;\n\t\t}\n\n\t\tthis.heuristicData.totalOpsSize += opSize(op);\n\n\t\t// Check for enqueued on-demand summaries; Intentionally do nothing otherwise\n\t\tif (\n\t\t\tthis.initialized &&\n\t\t\tthis.opCanTriggerSummary(op) &&\n\t\t\t!this.tryRunEnqueuedSummary() &&\n\t\t\t!this.heuristicRunnerMicroTaskExists\n\t\t) {\n\t\t\tthis.heuristicRunnerMicroTaskExists = true;\n\t\t\tPromise.resolve()\n\t\t\t\t.then(() => {\n\t\t\t\t\tthis.heuristicRunner?.run();\n\t\t\t\t})\n\t\t\t\t.finally(() => {\n\t\t\t\t\tthis.heuristicRunnerMicroTaskExists = false;\n\t\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Can the given op trigger a summary?\n\t * # Currently always prevents summaries for Summarize and SummaryAck/Nack ops\n\t * @param op - op to check\n\t * @returns true if this op can trigger a summary\n\t */\n\tprivate opCanTriggerSummary(op: ISequencedDocumentMessage): boolean {\n\t\tswitch (op.type) {\n\t\t\tcase MessageType.Summarize:\n\t\t\tcase MessageType.SummaryAck:\n\t\t\tcase MessageType.SummaryNack:\n\t\t\t\treturn false;\n\t\t\tdefault:\n\t\t\t\treturn isRuntimeMessage(op) || this.nonRuntimeOpCanTriggerSummary();\n\t\t}\n\t}\n\n\tprivate nonRuntimeOpCanTriggerSummary(): boolean {\n\t\tconst opsSinceLastAck =\n\t\t\tthis.heuristicData.lastOpSequenceNumber -\n\t\t\tthis.heuristicData.lastSuccessfulSummary.refSequenceNumber;\n\t\treturn (\n\t\t\tthis.configuration.state === \"enabled\" &&\n\t\t\t(this.configuration.nonRuntimeHeuristicThreshold === undefined ||\n\t\t\t\tthis.configuration.nonRuntimeHeuristicThreshold <= opsSinceLastAck)\n\t\t);\n\t}\n\n\tpublic async waitStop(allowLastSummary: boolean): Promise<void> {\n\t\tif (this.stopping) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.stopping = true;\n\n\t\tthis.disposeEnqueuedSummary();\n\n\t\t// This will try to run lastSummary if needed.\n\t\tif (allowLastSummary && this.heuristicRunner?.shouldRunLastSummary()) {\n\t\t\tif (this.summarizingLock === undefined) {\n\t\t\t\tthis.trySummarizeOnce(\n\t\t\t\t\t// summarizeProps\n\t\t\t\t\t{ reason: \"lastSummary\" },\n\t\t\t\t\t// ISummarizeOptions, using defaults: { refreshLatestAck: false, fullTree: false }\n\t\t\t\t\t{},\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Note that trySummarizeOnce() call above returns right away, without waiting.\n\t\t// So we need to wait for its completion, otherwise it would be destroyed right away.\n\t\t// That said, if summary lock was taken upfront, this wait might wait on multiple retries to\n\t\t// submit summary. We should reconsider this flow and make summarizer move to exit faster.\n\t\t// This resolves when the current pending summary gets an ack or fails.\n\t\tawait this.summarizingLock;\n\t}\n\n\tprivate async waitStart() {\n\t\t// Wait no longer than ack timeout for all pending\n\t\tconst waitStartResult = await raceTimer(\n\t\t\tthis.summaryWatcher.waitFlushed(),\n\t\t\tthis.pendingAckTimer.start(),\n\t\t);\n\t\tthis.pendingAckTimer.clear();\n\n\t\t// Remove pending ack wait timeout by op timestamp comparison, because\n\t\t// it has race conditions with summaries submitted by this same client.\n\t\tthis.summaryCollection.unsetPendingAckTimerTimeoutCallback();\n\n\t\tif (waitStartResult.result === \"done\" && waitStartResult.value !== undefined) {\n\t\t\tthis.heuristicData.updateWithLastSummaryAckInfo({\n\t\t\t\trefSequenceNumber: waitStartResult.value.summaryOp.referenceSequenceNumber,\n\t\t\t\t// This will be the Summarizer starting point so only use timestamps from client's machine.\n\t\t\t\tsummaryTime: Date.now(),\n\t\t\t\tsummarySequenceNumber: waitStartResult.value.summaryOp.sequenceNumber,\n\t\t\t});\n\t\t}\n\t\tthis.initialized = true;\n\t}\n\n\t/**\n\t * Blocks a new summarizer from running in case RefreshSummaryAck is being processed.\n\t * Assumes that caller checked upfront for lack of concurrent action (this.refreshSummaryAckLock)\n\t * before calling this API. I.e. caller is responsible for either erroring out or waiting on this promise.\n\t * Note: The refreshSummaryAckLock makes sure no summarizer gets enqueued or processed\n\t * until the refresh has completed. One can't rely uniquely on the summarizingLock as the\n\t * refreshLatestSummaryAck also happens during the time summarizingLock !== undefined.\n\t * Ex. Summarizer submits a summay + op and then waits for the Summary Ack to proceed\n\t * with the refreshLatestSummaryAck and complete the summary.\n\t * @param action - action to perform.\n\t * @returns - result of action.\n\t */\n\tpublic async lockedRefreshSummaryAckAction<T>(action: () => Promise<T>) {\n\t\tassert(\n\t\t\tthis.refreshSummaryAckLock === undefined,\n\t\t\t0x396 /* Refresh Summary Ack - Caller is responsible for checking lock */,\n\t\t);\n\n\t\tconst refreshSummaryAckLock = new Deferred<void>();\n\t\tthis.refreshSummaryAckLock = refreshSummaryAckLock.promise;\n\n\t\treturn action().finally(() => {\n\t\t\trefreshSummaryAckLock.resolve();\n\t\t\tthis.refreshSummaryAckLock = undefined;\n\t\t});\n\t}\n\n\t/**\n\t * Runs single summary action that prevents any other concurrent actions.\n\t * Assumes that caller checked upfront for lack of concurrent action (this.summarizingLock)\n\t * before calling this API. I.e. caller is responsible for either erroring out or waiting on this promise.\n\t * @param action - action to perform.\n\t * @returns - result of action.\n\t */\n\tprivate async lockedSummaryAction<T>(action: () => Promise<T>) {\n\t\tassert(\n\t\t\tthis.summarizingLock === undefined,\n\t\t\t0x25b /* \"Caller is responsible for checking lock\" */,\n\t\t);\n\n\t\tconst summarizingLock = new Deferred<void>();\n\t\tthis.summarizingLock = summarizingLock.promise;\n\n\t\tthis.summarizeCount++;\n\t\t// Make sure the RefreshLatestSummaryAck is not being executed.\n\t\tawait this.refreshSummaryAckLock;\n\n\t\treturn action().finally(() => {\n\t\t\tsummarizingLock.resolve();\n\t\t\tthis.summarizingLock = undefined;\n\n\t\t\tconst retry = this.tryWhileSummarizing;\n\t\t\tthis.tryWhileSummarizing = false;\n\n\t\t\t// After summarizing, we should check to see if we need to summarize again.\n\t\t\t// Rerun the heuristics and check for enqueued summaries.\n\t\t\tif (!this.stopping && !this.tryRunEnqueuedSummary() && retry) {\n\t\t\t\tthis.heuristicRunner?.run();\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Runs single summarize attempt\n\t * @param summarizeProps - props to log with each telemetry event associated with this attempt\n\t * @param options - summary options\n\t * @param cancellationToken - cancellation token to use to be able to cancel this summary, if needed\n\t * @param resultsBuilder - optional, result builder to use.\n\t * @returns ISummarizeResult - result of running a summary.\n\t */\n\tprivate trySummarizeOnce(\n\t\tsummarizeProps: ISummarizeTelemetryProperties,\n\t\toptions: ISummarizeOptions,\n\t\tcancellationToken = this.cancellationToken,\n\t\tresultsBuilder = new SummarizeResultBuilder(),\n\t): ISummarizeResults {\n\t\tthis.lockedSummaryAction(async () => {\n\t\t\tconst summarizeResult = this.generator.summarize(\n\t\t\t\tsummarizeProps,\n\t\t\t\toptions,\n\t\t\t\tcancellationToken,\n\t\t\t\tresultsBuilder,\n\t\t\t);\n\t\t\t// ensure we wait till the end of the process\n\t\t\treturn summarizeResult.receivedSummaryAckOrNack;\n\t\t}).catch((error) => {\n\t\t\t// SummaryGenerator.summarize() does not throw exceptions - it converts them to failed result\n\t\t\t// on resultsBuilder\n\t\t\t// We do not care about exceptions on receivedSummaryAckOrNack - caller should check results\n\t\t\t// and take a appropriate action.\n\t\t});\n\n\t\treturn resultsBuilder.build();\n\t}\n\n\t/** Heuristics summarize attempt. */\n\tprivate trySummarize(\n\t\treason: SummarizeReason,\n\t\tcancellationToken = this.cancellationToken,\n\t): void {\n\t\tif (this.summarizingLock !== undefined) {\n\t\t\t// lockedSummaryAction() will retry heuristic-based summary at the end of current attempt\n\t\t\t// if it's still needed\n\t\t\tthis.tryWhileSummarizing = true;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.lockedSummaryAction(async () => {\n\t\t\tconst attempts: (ISummarizeOptions & { delaySeconds?: number })[] = [\n\t\t\t\t{ refreshLatestAck: false, fullTree: false },\n\t\t\t\t{ refreshLatestAck: true, fullTree: false },\n\t\t\t\t{ refreshLatestAck: true, fullTree: false, delaySeconds: 2 * 60 },\n\t\t\t\t{ refreshLatestAck: true, fullTree: true, delaySeconds: 10 * 60 },\n\t\t\t];\n\t\t\tlet overrideDelaySeconds: number | undefined;\n\t\t\tlet summaryAttempts = 0;\n\t\t\tlet summaryAttemptsPerPhase = 0;\n\n\t\t\tlet lastResult: { message: string; error: any } | undefined;\n\n\t\t\tfor (let summaryAttemptPhase = 0; summaryAttemptPhase < attempts.length; ) {\n\t\t\t\tif (this.cancellationToken.cancelled) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// We only want to attempt 1 summary when reason is \"lastSummary\"\n\t\t\t\tif (++summaryAttempts > 1 && reason === \"lastSummary\") {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsummaryAttemptsPerPhase++;\n\n\t\t\t\tconst { delaySeconds: regularDelaySeconds = 0, ...options } =\n\t\t\t\t\tattempts[summaryAttemptPhase];\n\t\t\t\tconst delaySeconds = overrideDelaySeconds ?? regularDelaySeconds;\n\n\t\t\t\tconst summarizeProps: ISummarizeTelemetryProperties = {\n\t\t\t\t\treason,\n\t\t\t\t\tsummaryAttempts,\n\t\t\t\t\tsummaryAttemptsPerPhase,\n\t\t\t\t\tsummaryAttemptPhase: summaryAttemptPhase + 1, // make everything 1-based\n\t\t\t\t\t...options,\n\t\t\t\t};\n\n\t\t\t\tif (delaySeconds > 0) {\n\t\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\t\teventName: \"SummarizeAttemptDelay\",\n\t\t\t\t\t\tduration: delaySeconds,\n\t\t\t\t\t\tsummaryNackDelay: overrideDelaySeconds !== undefined,\n\t\t\t\t\t\t...summarizeProps,\n\t\t\t\t\t});\n\t\t\t\t\tawait delay(delaySeconds * 1000);\n\t\t\t\t}\n\n\t\t\t\t// Make sure the refresh Summary Ack is not being executed.\n\t\t\t\tawait this.refreshSummaryAckLock;\n\n\t\t\t\t// Note: no need to account for cancellationToken.waitCancelled here, as\n\t\t\t\t// this is accounted SummaryGenerator.summarizeCore that controls receivedSummaryAckOrNack.\n\t\t\t\tconst resultSummarize = this.generator.summarize(\n\t\t\t\t\tsummarizeProps,\n\t\t\t\t\toptions,\n\t\t\t\t\tcancellationToken,\n\t\t\t\t);\n\t\t\t\tconst result = await resultSummarize.receivedSummaryAckOrNack;\n\n\t\t\t\tif (result.success) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Check for retryDelay that can come from summaryNack or upload summary flow.\n\t\t\t\t// Retry the same step only once per retryAfter response.\n\t\t\t\toverrideDelaySeconds = result.retryAfterSeconds;\n\t\t\t\tif (overrideDelaySeconds === undefined || summaryAttemptsPerPhase > 1) {\n\t\t\t\t\tsummaryAttemptPhase++;\n\t\t\t\t\tsummaryAttemptsPerPhase = 0;\n\t\t\t\t}\n\t\t\t\tlastResult = result;\n\t\t\t}\n\n\t\t\t// If all attempts failed, log error (with last attempt info) and close the summarizer container\n\t\t\tthis.logger.sendErrorEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: \"FailToSummarize\",\n\t\t\t\t\treason,\n\t\t\t\t\tmessage: lastResult?.message,\n\t\t\t\t},\n\t\t\t\tlastResult?.error,\n\t\t\t);\n\n\t\t\tthis.stopSummarizerCallback(\"failToSummarize\");\n\t\t}).catch((error) => {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"UnexpectedSummarizeError\" }, error);\n\t\t});\n\t}\n\n\t/** {@inheritdoc (ISummarizer:interface).summarizeOnDemand} */\n\tpublic summarizeOnDemand(\n\t\tresultsBuilder: SummarizeResultBuilder = new SummarizeResultBuilder(),\n\t\t{ reason, ...options }: IOnDemandSummarizeOptions,\n\t): ISummarizeResults {\n\t\tif (this.stopping) {\n\t\t\tresultsBuilder.fail(\"RunningSummarizer stopped or disposed\", undefined);\n\t\t\treturn resultsBuilder.build();\n\t\t}\n\t\t// Check for concurrent summary attempts. If one is found,\n\t\t// return a promise that caller can await before trying again.\n\t\tif (this.summarizingLock !== undefined) {\n\t\t\t// The heuristics are blocking concurrent summarize attempts.\n\t\t\tthrow new UsageError(\"Attempted to run an already-running summarizer on demand\");\n\t\t}\n\n\t\tconst result = this.trySummarizeOnce(\n\t\t\t{ reason: `onDemand/${reason}` },\n\t\t\toptions,\n\t\t\tthis.cancellationToken,\n\t\t\tresultsBuilder,\n\t\t);\n\t\treturn result;\n\t}\n\n\t/** {@inheritdoc (ISummarizer:interface).enqueueSummarize} */\n\tpublic enqueueSummarize({\n\t\treason,\n\t\tafterSequenceNumber = 0,\n\t\toverride = false,\n\t\t...options\n\t}: IEnqueueSummarizeOptions): EnqueueSummarizeResult {\n\t\tconst onDemandReason = `enqueue;${reason}` as const;\n\t\tlet overridden = false;\n\t\tif (this.enqueuedSummary !== undefined) {\n\t\t\tif (!override) {\n\t\t\t\treturn { alreadyEnqueued: true };\n\t\t\t}\n\t\t\t// Override existing enqueued summarize attempt.\n\t\t\tthis.enqueuedSummary.resultsBuilder.fail(\n\t\t\t\t\"Aborted; overridden by another enqueue summarize attempt\",\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\tthis.enqueuedSummary = undefined;\n\t\t\toverridden = true;\n\t\t}\n\t\tthis.enqueuedSummary = {\n\t\t\treason: onDemandReason,\n\t\t\tafterSequenceNumber,\n\t\t\toptions,\n\t\t\tresultsBuilder: new SummarizeResultBuilder(),\n\t\t};\n\t\tconst results = this.enqueuedSummary.resultsBuilder.build();\n\t\tthis.tryRunEnqueuedSummary();\n\t\treturn overridden\n\t\t\t? {\n\t\t\t\t\t...results,\n\t\t\t\t\talreadyEnqueued: true,\n\t\t\t\t\toverridden: true,\n\t\t\t }\n\t\t\t: results;\n\t}\n\n\tprivate tryRunEnqueuedSummary() {\n\t\tif (this.stopping) {\n\t\t\tthis.disposeEnqueuedSummary();\n\t\t\treturn false;\n\t\t}\n\t\tif (\n\t\t\tthis.enqueuedSummary === undefined ||\n\t\t\tthis.heuristicData.lastOpSequenceNumber < this.enqueuedSummary.afterSequenceNumber ||\n\t\t\tthis.summarizingLock !== undefined\n\t\t) {\n\t\t\t// If no enqueued summary is ready or a summary is already in progress, take no action.\n\t\t\treturn false;\n\t\t}\n\t\tconst { reason, resultsBuilder, options } = this.enqueuedSummary;\n\t\t// Set to undefined first, so that subsequent enqueue attempt while summarize will occur later.\n\t\tthis.enqueuedSummary = undefined;\n\t\tthis.trySummarizeOnce(\n\t\t\t{ reason: `enqueuedSummary/${reason}` },\n\t\t\toptions,\n\t\t\tthis.cancellationToken,\n\t\t\tresultsBuilder,\n\t\t);\n\t\treturn true;\n\t}\n\n\tprivate disposeEnqueuedSummary() {\n\t\tif (this.enqueuedSummary !== undefined) {\n\t\t\tthis.enqueuedSummary.resultsBuilder.fail(\n\t\t\t\t\"RunningSummarizer stopped or disposed\",\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\tthis.enqueuedSummary = undefined;\n\t\t}\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"scheduleManager.d.ts","sourceRoot":"","sources":["../src/scheduleManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACnG,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAgBtE;;;;;;;;GAQG;AACH,qBAAa,eAAe;IAMpB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,MAAM,GAAG,SAAS;IAC9C,OAA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AO,EAAE,yBAAyB;IAgBrD,iBAAiB,CAAC,KAAK,EAAE,GAAG,GAAG,SAAS,EAAE,OAAO,EAAE,yBAAyB;CAwBnF"}
@@ -142,7 +142,7 @@ class ScheduleManagerCore {
142
142
  }
143
143
  resumeQueue(startBatch, messageEndBatch) {
144
144
  const endBatch = messageEndBatch.sequenceNumber;
145
- const duration = this.localPaused ? (common_utils_1.performance.now() - this.timePaused) : undefined;
145
+ const duration = this.localPaused ? common_utils_1.performance.now() - this.timePaused : undefined;
146
146
  this.batchCount++;
147
147
  if (this.batchCount % 1000 === 1) {
148
148
  this.logger.sendTelemetryEvent({
@@ -196,7 +196,8 @@ class ScheduleManagerCore {
196
196
  // If we got here, the message is part of a batch. Either starting, in progress, or ending.
197
197
  // If this is not the start of the batch, error out if the message was sent by a client other than the one that
198
198
  // started the current batch (it should not be possible for ops from other clients to get interleaved with a batch).
199
- if (this.currentBatchClientId !== undefined && this.currentBatchClientId !== message.clientId) {
199
+ if (this.currentBatchClientId !== undefined &&
200
+ this.currentBatchClientId !== message.clientId) {
200
201
  throw new container_utils_1.DataCorruptionError("OpBatchIncomplete", Object.assign({ runtimeVersion: packageVersion_1.pkgVersion, batchClientId: this.currentBatchClientId, pauseSequenceNumber: this.pauseSequenceNumber, localBatch: this.currentBatchClientId === this.getClientId(), localMessage: message.clientId === this.getClientId() }, (0, container_utils_1.extractSafePropertiesFromMessage)(message)));
201
202
  }
202
203
  // The queue is
@@ -1 +1 @@
1
- {"version":3,"file":"scheduleManager.js","sourceRoot":"","sources":["../src/scheduleManager.ts"],"names":[],"mappings":";;;AAQA,qEAA8D;AAC9D,+DAAmE;AACnE,+DAAgE;AAChE,qEAIyC;AACzC,qDAAkD;AAClD,qDAA8C;AAM9C;;;;;;;;GAQG;AACH,MAAa,eAAe;IAKxB,YACqB,YAAwE,EACxE,OAAqB,EAC7B,WAAqC,EAC7B,MAAwB;QAHxB,iBAAY,GAAZ,YAAY,CAA4D;QACxE,YAAO,GAAP,OAAO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AC,QAAQ,CAAC;YAC7C,qBAAqB;YACrB,mDAAmD;YACnD,+FAA+F;YAC/F,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;gBACxC,IAAI,CAAC,UAAU,EAAE,CAAC;aACrB;SACJ;aAAM,IAAI,aAAa,KAAK,KAAK,EAAE;YAChC,IAAA,qBAAM,EAAC,IAAI,CAAC,mBAAmB,KAAK,SAAS,EAAE,KAAK,CAAC,0CAA0C,CAAC,CAAC;YACjG,wCAAwC;YACxC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;YACpD,IAAI,CAAC,mBAAmB,GAAG,SAAS,CAAC;YACrC,IAAI,CAAC,oBAAoB,GAAG,SAAS,CAAC;SACzC;aAAM;YACH,4CAA4C;YAC5C,IAAA,qBAAM,EAAC,IAAI,CAAC,oBAAoB,KAAK,SAAS,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;SAC9E;IACL,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { EventEmitter } from \"events\";\nimport { IDeltaManager } from \"@fluidframework/container-definitions\";\nimport { IDocumentMessage, ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { ChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { assert, performance } from \"@fluidframework/common-utils\";\nimport { isRuntimeMessage } from \"@fluidframework/driver-utils\";\nimport {\n DataCorruptionError,\n DataProcessingError,\n extractSafePropertiesFromMessage,\n} from \"@fluidframework/container-utils\";\nimport { DeltaScheduler } from \"./deltaScheduler\";\nimport { pkgVersion } from \"./packageVersion\";\n\ntype IRuntimeMessageMetadata = undefined | {\n batch?: boolean;\n};\n\n/**\n * This class has the following responsibilities:\n *\n * 1. It tracks batches as we process ops and raises \"batchBegin\" and \"batchEnd\" events.\n * As part of it, it validates batch correctness (i.e. no system ops in the middle of batch)\n *\n * 2. It creates instance of ScheduleManagerCore that ensures we never start processing ops from batch\n * unless all ops of the batch are in.\n */\nexport class ScheduleManager {\n private readonly deltaScheduler: DeltaScheduler;\n private batchClientId: string | undefined;\n private hitError = false;\n\n constructor(\n private readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n private readonly emitter: EventEmitter,\n readonly getClientId: () => string | undefined,\n private readonly logger: ITelemetryLogger,\n ) {\n this.deltaScheduler = new DeltaScheduler(\n this.deltaManager,\n ChildLogger.create(this.logger, \"DeltaScheduler\"),\n );\n void new ScheduleManagerCore(deltaManager, getClientId, logger);\n }\n\n public beforeOpProcessing(message: ISequencedDocumentMessage) {\n if (this.batchClientId !== message.clientId) {\n assert(this.batchClientId === undefined,\n 0x2a2 /* \"Batch is interrupted by other client op. Should be caught by trackPending()\" */);\n\n // This could be the beginning of a new batch or an individual message.\n this.emitter.emit(\"batchBegin\", message);\n this.deltaScheduler.batchBegin(message);\n\n const batch = (message?.metadata as IRuntimeMessageMetadata)?.batch;\n this.batchClientId = batch ? message.clientId : undefined;\n }\n }\n\n public afterOpProcessing(error: any | undefined, message: ISequencedDocumentMessage) {\n // If this is no longer true, we need to revisit what we do where we set this.hitError.\n assert(!this.hitError, 0x2a3 /* \"container should be closed on any error\" */);\n\n if (error) {\n // We assume here that loader will close container and stop processing all future ops.\n // This is implicit dependency. If this flow changes, this code might no longer be correct.\n this.hitError = true;\n this.batchClientId = undefined;\n this.emitter.emit(\"batchEnd\", error, message);\n this.deltaScheduler.batchEnd(message);\n return;\n }\n\n const batch = (message?.metadata as IRuntimeMessageMetadata)?.batch;\n // If no batchClientId has been set then we're in an individual batch. Else, if we get\n // batch end metadata, this is end of the current batch.\n if (this.batchClientId === undefined || batch === false) {\n this.batchClientId = undefined;\n this.emitter.emit(\"batchEnd\", undefined, message);\n this.deltaScheduler.batchEnd(message);\n return;\n }\n }\n}\n\n/**\n * This class controls pausing and resuming of inbound queue to ensure that we never\n * start processing ops in a batch IF we do not have all ops in the batch.\n */\nclass ScheduleManagerCore {\n private pauseSequenceNumber: number | undefined;\n private currentBatchClientId: string | undefined;\n private localPaused = false;\n private timePaused = 0;\n private batchCount = 0;\n\n constructor(\n private readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n private readonly getClientId: () => string | undefined,\n private readonly logger: ITelemetryLogger,\n ) {\n // Listen for delta manager sends and add batch metadata to messages\n this.deltaManager.on(\"prepareSend\", (messages: IDocumentMessage[]) => {\n if (messages.length === 0) {\n return;\n }\n\n // First message will have the batch flag set to true if doing a batched send\n const firstMessageMetadata = messages[0].metadata as IRuntimeMessageMetadata;\n if (!firstMessageMetadata?.batch) {\n return;\n }\n\n // If the batch contains only a single op, clear the batch flag.\n if (messages.length === 1) {\n delete firstMessageMetadata.batch;\n return;\n }\n\n // Set the batch flag to false on the last message to indicate the end of the send batch\n const lastMessage = messages[messages.length - 1];\n lastMessage.metadata = { ...lastMessage.metadata, batch: false };\n });\n\n // Listen for updates and peek at the inbound\n this.deltaManager.inbound.on(\n \"push\",\n (message: ISequencedDocumentMessage) => {\n this.trackPending(message);\n });\n\n // Start with baseline - empty inbound queue.\n assert(!this.localPaused, 0x293 /* \"initial state\" */);\n\n const allPending = this.deltaManager.inbound.toArray();\n for (const pending of allPending) {\n this.trackPending(pending);\n }\n\n // We are intentionally directly listening to the \"op\" to inspect system ops as well.\n // If we do not observe system ops, we are likely to hit 0x296 assert when system ops\n // precedes start of incomplete batch.\n this.deltaManager.on(\"op\", (message) => this.afterOpProcessing(message.sequenceNumber));\n }\n\n /**\n * The only public function in this class - called when we processed an op,\n * to make decision if op processing should be paused or not after that.\n */\n public afterOpProcessing(sequenceNumber: number) {\n assert(!this.localPaused, 0x294 /* \"can't have op processing paused if we are processing an op\" */);\n\n // If the inbound queue is ever empty, nothing to do!\n if (this.deltaManager.inbound.length === 0) {\n assert(this.pauseSequenceNumber === undefined,\n 0x295 /* \"there should be no pending batch if we have no ops\" */);\n return;\n }\n\n // The queue is\n // 1. paused only when the next message to be processed is the beginning of a batch. Done in two places:\n // - here (processing ops until reaching start of incomplete batch)\n // - in trackPending(), when queue was empty and start of batch showed up.\n // 2. resumed when batch end comes in (in trackPending())\n\n // do we have incomplete batch to worry about?\n if (this.pauseSequenceNumber !== undefined) {\n assert(sequenceNumber < this.pauseSequenceNumber,\n 0x296 /* \"we should never start processing incomplete batch!\" */);\n // If the next op is the start of incomplete batch, then we can't process it until it's fully in - pause!\n if (sequenceNumber + 1 === this.pauseSequenceNumber) {\n this.pauseQueue();\n }\n }\n }\n\n private pauseQueue() {\n assert(!this.localPaused, 0x297 /* \"always called from resumed state\" */);\n this.localPaused = true;\n this.timePaused = performance.now();\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.deltaManager.inbound.pause();\n }\n\n private resumeQueue(startBatch: number, messageEndBatch: ISequencedDocumentMessage) {\n const endBatch = messageEndBatch.sequenceNumber;\n const duration = this.localPaused ? (performance.now() - this.timePaused) : undefined;\n\n this.batchCount++;\n if (this.batchCount % 1000 === 1) {\n this.logger.sendTelemetryEvent({\n eventName: \"BatchStats\",\n sequenceNumber: endBatch,\n length: endBatch - startBatch + 1,\n msnDistance: endBatch - messageEndBatch.minimumSequenceNumber,\n duration,\n batchCount: this.batchCount,\n interrupted: this.localPaused,\n });\n }\n\n // Return early if no change in value\n if (!this.localPaused) {\n return;\n }\n\n this.localPaused = false;\n\n this.deltaManager.inbound.resume();\n }\n\n /**\n * Called for each incoming op (i.e. inbound \"push\" notification)\n */\n private trackPending(message: ISequencedDocumentMessage) {\n assert(this.deltaManager.inbound.length !== 0,\n 0x298 /* \"we have something in the queue that generates this event\" */);\n\n assert((this.currentBatchClientId === undefined) === (this.pauseSequenceNumber === undefined),\n 0x299 /* \"non-synchronized state\" */);\n\n const metadata = message.metadata as IRuntimeMessageMetadata;\n // batchMetadata will be true for the message that starts a batch, false for the one that ends it, and\n // undefined for all other messages.\n const batchMetadata = metadata?.batch;\n\n // Protocol messages are never part of a runtime batch of messages\n if (!isRuntimeMessage(message)) {\n // Protocol messages should never show up in the middle of the batch!\n if (this.currentBatchClientId !== undefined) {\n throw DataProcessingError.create(\n \"Received a system message during batch processing\", // Formerly known as assert 0x29a\n \"trackPending\",\n message,\n {\n runtimeVersion: pkgVersion,\n batchClientId: this.currentBatchClientId,\n pauseSequenceNumber: this.pauseSequenceNumber,\n localBatch: this.currentBatchClientId === this.getClientId(),\n messageType: message.type,\n });\n }\n\n assert(batchMetadata === undefined, 0x29b /* \"system op in a batch?\" */);\n assert(!this.localPaused, 0x29c /* \"we should be processing ops when there is no active batch\" */);\n return;\n }\n\n if (this.currentBatchClientId === undefined && batchMetadata === undefined) {\n assert(!this.localPaused, 0x29d /* \"we should be processing ops when there is no active batch\" */);\n return;\n }\n\n // If we got here, the message is part of a batch. Either starting, in progress, or ending.\n\n // If this is not the start of the batch, error out if the message was sent by a client other than the one that\n // started the current batch (it should not be possible for ops from other clients to get interleaved with a batch).\n if (this.currentBatchClientId !== undefined && this.currentBatchClientId !== message.clientId) {\n throw new DataCorruptionError(\n \"OpBatchIncomplete\",\n {\n runtimeVersion: pkgVersion,\n batchClientId: this.currentBatchClientId,\n pauseSequenceNumber: this.pauseSequenceNumber,\n localBatch: this.currentBatchClientId === this.getClientId(),\n localMessage: message.clientId === this.getClientId(),\n ...extractSafePropertiesFromMessage(message),\n });\n }\n\n // The queue is\n // 1. paused only when the next message to be processed is the beginning of a batch. Done in two places:\n // - in afterOpProcessing() - processing ops until reaching start of incomplete batch\n // - here, when queue was empty and start of batch showed up (batchMetadata === true below).\n // 2. resumed when batch end comes in (batchMetadata === false below)\n\n if (batchMetadata) {\n assert(this.currentBatchClientId === undefined, 0x29e /* \"there can't be active batch\" */);\n assert(!this.localPaused, 0x29f /* \"we should be processing ops when there is no active batch\" */);\n this.pauseSequenceNumber = message.sequenceNumber;\n this.currentBatchClientId = message.clientId;\n // Start of the batch\n // Only pause processing if queue has no other ops!\n // If there are any other ops in the queue, processing will be stopped when they are processed!\n if (this.deltaManager.inbound.length === 1) {\n this.pauseQueue();\n }\n } else if (batchMetadata === false) {\n assert(this.pauseSequenceNumber !== undefined, 0x2a0 /* \"batch presence was validated above\" */);\n // Batch is complete, we can process it!\n this.resumeQueue(this.pauseSequenceNumber, message);\n this.pauseSequenceNumber = undefined;\n this.currentBatchClientId = undefined;\n } else {\n // Continuation of current batch. Do nothing\n assert(this.currentBatchClientId !== undefined, 0x2a1 /* \"logic error\" */);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"scheduleManager.js","sourceRoot":"","sources":["../src/scheduleManager.ts"],"names":[],"mappings":";;;AAQA,qEAA8D;AAC9D,+DAAmE;AACnE,+DAAgE;AAChE,qEAIyC;AACzC,qDAAkD;AAClD,qDAA8C;AAQ9C;;;;;;;;GAQG;AACH,MAAa,eAAe;IAK3B,YACkB,YAAwE,EACxE,OAAqB,EAC7B,WAAqC,EAC7B,MAAwB;QAHxB,iBAAY,GAAZ,YAAY,CAA4D;QACxE,YAAO,GAAP,OAAO,CAAc;QAC7B,gBAAW,GAAX,WAAW,CAA0B;QAC7B,WAAM,GAAN,MAAM,CAAkB;QANlC,aAAQ,GAAG,KAAK,CAAC;QAQxB,IAAI,CAAC,cAAc,GAAG,IAAI,+BAAc,CACvC,IAAI,CAAC,YAAY,EACjB,6BAAW,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,CACjD,CAAC;QACF,KAAK,IAAI,mBAAmB,CAAC,YAAY,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IACjE,CAAC;IAEM,kBAAkB,CAAC,OAAkC;;QAC3D,IAAI,IAAI,CAAC,aAAa,KAAK,OAAO,CAAC,QAAQ,EAAE;YAC5C,IAAA,qBAAM,EACL,IAAI,CAAC,aAAa,KAAK,SAAS,EAChC,KAAK,CAAC,mFAAmF,CACzF,CAAC;YAEF,uEAAuE;YACvE,IAAI,CAAC,O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AAmB,CAAC,CAAC;SAC3E;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { EventEmitter } from \"events\";\nimport { IDeltaManager } from \"@fluidframework/container-definitions\";\nimport { IDocumentMessage, ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { ChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { assert, performance } from \"@fluidframework/common-utils\";\nimport { isRuntimeMessage } from \"@fluidframework/driver-utils\";\nimport {\n\tDataCorruptionError,\n\tDataProcessingError,\n\textractSafePropertiesFromMessage,\n} from \"@fluidframework/container-utils\";\nimport { DeltaScheduler } from \"./deltaScheduler\";\nimport { pkgVersion } from \"./packageVersion\";\n\ntype IRuntimeMessageMetadata =\n\t| undefined\n\t| {\n\t\t\tbatch?: boolean;\n\t };\n\n/**\n * This class has the following responsibilities:\n *\n * 1. It tracks batches as we process ops and raises \"batchBegin\" and \"batchEnd\" events.\n * As part of it, it validates batch correctness (i.e. no system ops in the middle of batch)\n *\n * 2. It creates instance of ScheduleManagerCore that ensures we never start processing ops from batch\n * unless all ops of the batch are in.\n */\nexport class ScheduleManager {\n\tprivate readonly deltaScheduler: DeltaScheduler;\n\tprivate batchClientId: string | undefined;\n\tprivate hitError = false;\n\n\tconstructor(\n\t\tprivate readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tprivate readonly emitter: EventEmitter,\n\t\treadonly getClientId: () => string | undefined,\n\t\tprivate readonly logger: ITelemetryLogger,\n\t) {\n\t\tthis.deltaScheduler = new DeltaScheduler(\n\t\t\tthis.deltaManager,\n\t\t\tChildLogger.create(this.logger, \"DeltaScheduler\"),\n\t\t);\n\t\tvoid new ScheduleManagerCore(deltaManager, getClientId, logger);\n\t}\n\n\tpublic beforeOpProcessing(message: ISequencedDocumentMessage) {\n\t\tif (this.batchClientId !== message.clientId) {\n\t\t\tassert(\n\t\t\t\tthis.batchClientId === undefined,\n\t\t\t\t0x2a2 /* \"Batch is interrupted by other client op. Should be caught by trackPending()\" */,\n\t\t\t);\n\n\t\t\t// This could be the beginning of a new batch or an individual message.\n\t\t\tthis.emitter.emit(\"batchBegin\", message);\n\t\t\tthis.deltaScheduler.batchBegin(message);\n\n\t\t\tconst batch = (message?.metadata as IRuntimeMessageMetadata)?.batch;\n\t\t\tthis.batchClientId = batch ? message.clientId : undefined;\n\t\t}\n\t}\n\n\tpublic afterOpProcessing(error: any | undefined, message: ISequencedDocumentMessage) {\n\t\t// If this is no longer true, we need to revisit what we do where we set this.hitError.\n\t\tassert(!this.hitError, 0x2a3 /* \"container should be closed on any error\" */);\n\n\t\tif (error) {\n\t\t\t// We assume here that loader will close container and stop processing all future ops.\n\t\t\t// This is implicit dependency. If this flow changes, this code might no longer be correct.\n\t\t\tthis.hitError = true;\n\t\t\tthis.batchClientId = undefined;\n\t\t\tthis.emitter.emit(\"batchEnd\", error, message);\n\t\t\tthis.deltaScheduler.batchEnd(message);\n\t\t\treturn;\n\t\t}\n\n\t\tconst batch = (message?.metadata as IRuntimeMessageMetadata)?.batch;\n\t\t// If no batchClientId has been set then we're in an individual batch. Else, if we get\n\t\t// batch end metadata, this is end of the current batch.\n\t\tif (this.batchClientId === undefined || batch === false) {\n\t\t\tthis.batchClientId = undefined;\n\t\t\tthis.emitter.emit(\"batchEnd\", undefined, message);\n\t\t\tthis.deltaScheduler.batchEnd(message);\n\t\t\treturn;\n\t\t}\n\t}\n}\n\n/**\n * This class controls pausing and resuming of inbound queue to ensure that we never\n * start processing ops in a batch IF we do not have all ops in the batch.\n */\nclass ScheduleManagerCore {\n\tprivate pauseSequenceNumber: number | undefined;\n\tprivate currentBatchClientId: string | undefined;\n\tprivate localPaused = false;\n\tprivate timePaused = 0;\n\tprivate batchCount = 0;\n\n\tconstructor(\n\t\tprivate readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tprivate readonly getClientId: () => string | undefined,\n\t\tprivate readonly logger: ITelemetryLogger,\n\t) {\n\t\t// Listen for delta manager sends and add batch metadata to messages\n\t\tthis.deltaManager.on(\"prepareSend\", (messages: IDocumentMessage[]) => {\n\t\t\tif (messages.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// First message will have the batch flag set to true if doing a batched send\n\t\t\tconst firstMessageMetadata = messages[0].metadata as IRuntimeMessageMetadata;\n\t\t\tif (!firstMessageMetadata?.batch) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the batch contains only a single op, clear the batch flag.\n\t\t\tif (messages.length === 1) {\n\t\t\t\tdelete firstMessageMetadata.batch;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Set the batch flag to false on the last message to indicate the end of the send batch\n\t\t\tconst lastMessage = messages[messages.length - 1];\n\t\t\tlastMessage.metadata = { ...lastMessage.metadata, batch: false };\n\t\t});\n\n\t\t// Listen for updates and peek at the inbound\n\t\tthis.deltaManager.inbound.on(\"push\", (message: ISequencedDocumentMessage) => {\n\t\t\tthis.trackPending(message);\n\t\t});\n\n\t\t// Start with baseline - empty inbound queue.\n\t\tassert(!this.localPaused, 0x293 /* \"initial state\" */);\n\n\t\tconst allPending = this.deltaManager.inbound.toArray();\n\t\tfor (const pending of allPending) {\n\t\t\tthis.trackPending(pending);\n\t\t}\n\n\t\t// We are intentionally directly listening to the \"op\" to inspect system ops as well.\n\t\t// If we do not observe system ops, we are likely to hit 0x296 assert when system ops\n\t\t// precedes start of incomplete batch.\n\t\tthis.deltaManager.on(\"op\", (message) => this.afterOpProcessing(message.sequenceNumber));\n\t}\n\n\t/**\n\t * The only public function in this class - called when we processed an op,\n\t * to make decision if op processing should be paused or not after that.\n\t */\n\tpublic afterOpProcessing(sequenceNumber: number) {\n\t\tassert(\n\t\t\t!this.localPaused,\n\t\t\t0x294 /* \"can't have op processing paused if we are processing an op\" */,\n\t\t);\n\n\t\t// If the inbound queue is ever empty, nothing to do!\n\t\tif (this.deltaManager.inbound.length === 0) {\n\t\t\tassert(\n\t\t\t\tthis.pauseSequenceNumber === undefined,\n\t\t\t\t0x295 /* \"there should be no pending batch if we have no ops\" */,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// The queue is\n\t\t// 1. paused only when the next message to be processed is the beginning of a batch. Done in two places:\n\t\t// - here (processing ops until reaching start of incomplete batch)\n\t\t// - in trackPending(), when queue was empty and start of batch showed up.\n\t\t// 2. resumed when batch end comes in (in trackPending())\n\n\t\t// do we have incomplete batch to worry about?\n\t\tif (this.pauseSequenceNumber !== undefined) {\n\t\t\tassert(\n\t\t\t\tsequenceNumber < this.pauseSequenceNumber,\n\t\t\t\t0x296 /* \"we should never start processing incomplete batch!\" */,\n\t\t\t);\n\t\t\t// If the next op is the start of incomplete batch, then we can't process it until it's fully in - pause!\n\t\t\tif (sequenceNumber + 1 === this.pauseSequenceNumber) {\n\t\t\t\tthis.pauseQueue();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate pauseQueue() {\n\t\tassert(!this.localPaused, 0x297 /* \"always called from resumed state\" */);\n\t\tthis.localPaused = true;\n\t\tthis.timePaused = performance.now();\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\tthis.deltaManager.inbound.pause();\n\t}\n\n\tprivate resumeQueue(startBatch: number, messageEndBatch: ISequencedDocumentMessage) {\n\t\tconst endBatch = messageEndBatch.sequenceNumber;\n\t\tconst duration = this.localPaused ? performance.now() - this.timePaused : undefined;\n\n\t\tthis.batchCount++;\n\t\tif (this.batchCount % 1000 === 1) {\n\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"BatchStats\",\n\t\t\t\tsequenceNumber: endBatch,\n\t\t\t\tlength: endBatch - startBatch + 1,\n\t\t\t\tmsnDistance: endBatch - messageEndBatch.minimumSequenceNumber,\n\t\t\t\tduration,\n\t\t\t\tbatchCount: this.batchCount,\n\t\t\t\tinterrupted: this.localPaused,\n\t\t\t});\n\t\t}\n\n\t\t// Return early if no change in value\n\t\tif (!this.localPaused) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.localPaused = false;\n\n\t\tthis.deltaManager.inbound.resume();\n\t}\n\n\t/**\n\t * Called for each incoming op (i.e. inbound \"push\" notification)\n\t */\n\tprivate trackPending(message: ISequencedDocumentMessage) {\n\t\tassert(\n\t\t\tthis.deltaManager.inbound.length !== 0,\n\t\t\t0x298 /* \"we have something in the queue that generates this event\" */,\n\t\t);\n\n\t\tassert(\n\t\t\t(this.currentBatchClientId === undefined) === (this.pauseSequenceNumber === undefined),\n\t\t\t0x299 /* \"non-synchronized state\" */,\n\t\t);\n\n\t\tconst metadata = message.metadata as IRuntimeMessageMetadata;\n\t\t// batchMetadata will be true for the message that starts a batch, false for the one that ends it, and\n\t\t// undefined for all other messages.\n\t\tconst batchMetadata = metadata?.batch;\n\n\t\t// Protocol messages are never part of a runtime batch of messages\n\t\tif (!isRuntimeMessage(message)) {\n\t\t\t// Protocol messages should never show up in the middle of the batch!\n\t\t\tif (this.currentBatchClientId !== undefined) {\n\t\t\t\tthrow DataProcessingError.create(\n\t\t\t\t\t\"Received a system message during batch processing\", // Formerly known as assert 0x29a\n\t\t\t\t\t\"trackPending\",\n\t\t\t\t\tmessage,\n\t\t\t\t\t{\n\t\t\t\t\t\truntimeVersion: pkgVersion,\n\t\t\t\t\t\tbatchClientId: this.currentBatchClientId,\n\t\t\t\t\t\tpauseSequenceNumber: this.pauseSequenceNumber,\n\t\t\t\t\t\tlocalBatch: this.currentBatchClientId === this.getClientId(),\n\t\t\t\t\t\tmessageType: message.type,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tassert(batchMetadata === undefined, 0x29b /* \"system op in a batch?\" */);\n\t\t\tassert(\n\t\t\t\t!this.localPaused,\n\t\t\t\t0x29c /* \"we should be processing ops when there is no active batch\" */,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.currentBatchClientId === undefined && batchMetadata === undefined) {\n\t\t\tassert(\n\t\t\t\t!this.localPaused,\n\t\t\t\t0x29d /* \"we should be processing ops when there is no active batch\" */,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// If we got here, the message is part of a batch. Either starting, in progress, or ending.\n\n\t\t// If this is not the start of the batch, error out if the message was sent by a client other than the one that\n\t\t// started the current batch (it should not be possible for ops from other clients to get interleaved with a batch).\n\t\tif (\n\t\t\tthis.currentBatchClientId !== undefined &&\n\t\t\tthis.currentBatchClientId !== message.clientId\n\t\t) {\n\t\t\tthrow new DataCorruptionError(\"OpBatchIncomplete\", {\n\t\t\t\truntimeVersion: pkgVersion,\n\t\t\t\tbatchClientId: this.currentBatchClientId,\n\t\t\t\tpauseSequenceNumber: this.pauseSequenceNumber,\n\t\t\t\tlocalBatch: this.currentBatchClientId === this.getClientId(),\n\t\t\t\tlocalMessage: message.clientId === this.getClientId(),\n\t\t\t\t...extractSafePropertiesFromMessage(message),\n\t\t\t});\n\t\t}\n\n\t\t// The queue is\n\t\t// 1. paused only when the next message to be processed is the beginning of a batch. Done in two places:\n\t\t// - in afterOpProcessing() - processing ops until reaching start of incomplete batch\n\t\t// - here, when queue was empty and start of batch showed up (batchMetadata === true below).\n\t\t// 2. resumed when batch end comes in (batchMetadata === false below)\n\n\t\tif (batchMetadata) {\n\t\t\tassert(\n\t\t\t\tthis.currentBatchClientId === undefined,\n\t\t\t\t0x29e /* \"there can't be active batch\" */,\n\t\t\t);\n\t\t\tassert(\n\t\t\t\t!this.localPaused,\n\t\t\t\t0x29f /* \"we should be processing ops when there is no active batch\" */,\n\t\t\t);\n\t\t\tthis.pauseSequenceNumber = message.sequenceNumber;\n\t\t\tthis.currentBatchClientId = message.clientId;\n\t\t\t// Start of the batch\n\t\t\t// Only pause processing if queue has no other ops!\n\t\t\t// If there are any other ops in the queue, processing will be stopped when they are processed!\n\t\t\tif (this.deltaManager.inbound.length === 1) {\n\t\t\t\tthis.pauseQueue();\n\t\t\t}\n\t\t} else if (batchMetadata === false) {\n\t\t\tassert(\n\t\t\t\tthis.pauseSequenceNumber !== undefined,\n\t\t\t\t0x2a0 /* \"batch presence was validated above\" */,\n\t\t\t);\n\t\t\t// Batch is complete, we can process it!\n\t\t\tthis.resumeQueue(this.pauseSequenceNumber, message);\n\t\t\tthis.pauseSequenceNumber = undefined;\n\t\t\tthis.currentBatchClientId = undefined;\n\t\t} else {\n\t\t\t// Continuation of current batch. Do nothing\n\t\t\tassert(this.currentBatchClientId !== undefined, 0x2a1 /* \"logic error\" */);\n\t\t}\n\t}\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { IDocumentStorageService, ISummaryContext } from "@fluidframework/driver-definitions";
5
+ import { FetchSource, IDocumentStorageService, ISummaryContext } from "@fluidframework/driver-definitions";
6
6
  import { ICreateBlobResponse, ISnapshotTree, ISummaryHandle, ISummaryTree, IVersion } from "@fluidframework/protocol-definitions";
7
7
  import { ISnapshotTreeWithBlobContents } from "@fluidframework/container-definitions";
8
8
  /**
@@ -37,7 +37,7 @@ export declare class SerializedSnapshotStorage implements IDocumentStorageServic
37
37
  /**
38
38
  * Retrieves all versions of the document starting at the specified versionId - or null if from the head
39
39
  */
40
- getVersions(versionId: string | null, count: number): Promise<IVersion[]>;
40
+ getVersions(versionId: string | null, count: number, scenarioName?: string, fetchSource?: FetchSource): Promise<IVersion[]>;
41
41
  /**
42
42
  * Creates a blob out of the given buffer
43
43
  */
@@ -1 +1 @@
1
- {"version":3,"file":"serializedSnapshotStorage.d.ts","sourceRoot":"","sources":["../src/serializedSnapshotStorage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC9F,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,EACX,MAAM,sCAA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AAE,MAAM,EACrB,WAAW,CAAC,EAAE,WAAW,GACvB,OAAO,CAAC,QAAQ,EAAE,CAAC;IAItB;;OAEG;IACU,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAI5E;;;;;OAKG;IACU,wBAAwB,CACpC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC;IAIlB;;;OAGG;IACU,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;CAG3E"}
@@ -57,7 +57,9 @@ class SerializedSnapshotStorage {
57
57
  this._storage = this.storageGetter();
58
58
  return this._storage;
59
59
  }
60
- get repositoryUrl() { return this.storage.repositoryUrl; }
60
+ get repositoryUrl() {
61
+ return this.storage.repositoryUrl;
62
+ }
61
63
  /**
62
64
  * Reads the object with the given ID, returns content in arrayBufferLike
63
65
  */
@@ -78,8 +80,8 @@ class SerializedSnapshotStorage {
78
80
  * Retrieves all versions of the document starting at the specified versionId - or null if from the head
79
81
  */
80
82
  // eslint-disable-next-line @rushstack/no-new-null
81
- async getVersions(versionId, count) {
82
- return this.storage.getVersions(versionId, count);
83
+ async getVersions(versionId, count, scenarioName, fetchSource) {
84
+ return this.storage.getVersions(versionId, count, scenarioName, fetchSource);
83
85
  }
84
86
  /**
85
87
  * Creates a blob out of the given buffer
@@ -1 +1 @@
1
- {"version":3,"file":"serializedSnapshotStorage.js","sourceRoot":"","sources":["../src/serializedSnapshotStorage.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsF;AAkBtF;;;GAGG;AACH,MAAa,yBAAyB;IAClC,YACqB,aAA4C,EAC5C,KAAmC;QADnC,kBAAa,GAAb,aAAa,CAA+B;QAC5C,UAAK,GAAL,KAAK,CAA8B;IACpD,CAAC;IAEE,MAAM,CAAC,KAAK,CAAC,aAAa,CAC7B,QAAuB,EACvB,OAAgC;QAEhC,MAAM,KAAK,GAAG,EA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,IAAqB;QACzC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,wBAAwB,CAAC,OAAqB,EAAE,OAAwB;QACjF,OAAO,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,eAAe,CAAC,MAAsB;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC;CACJ;AAtHD,8DAsHC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, bufferToString, stringToBuffer } from \"@fluidframework/common-utils\";\nimport { IDocumentStorageService, ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport {\n ICreateBlobResponse,\n ISnapshotTree,\n ISummaryHandle,\n ISummaryTree,\n IVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { ISnapshotTreeWithBlobContents } from \"@fluidframework/container-definitions\";\n\n/**\n * Serialized blobs from a snapshot. Used to load offline.\n */\nexport interface ISerializedBaseSnapshotBlobs {\n [id: string]: string;\n}\n\n/**\n * A storage wrapper that can serialize blobs from a snapshot tree and then use them to rehydrate.\n * Used in offline load/attached dehydration to save snapshot blobs that are still needed but may have been deleted.\n */\nexport class SerializedSnapshotStorage implements IDocumentStorageService {\n constructor(\n private readonly storageGetter: () => IDocumentStorageService,\n private readonly blobs: ISerializedBaseSnapshotBlobs,\n ) { }\n\n public static async serializeTree(\n snapshot: ISnapshotTree,\n storage: IDocumentStorageService,\n ): Promise<ISerializedBaseSnapshotBlobs> {\n const blobs = {};\n await this.serializeTreeCore(snapshot, blobs, storage);\n return blobs;\n }\n\n private static async serializeTreeCore(\n tree: ISnapshotTree,\n blobs: ISerializedBaseSnapshotBlobs,\n storage: IDocumentStorageService,\n ) {\n const treePs: Promise<any>[] = [];\n for (const subTree of Object.values(tree.trees)) {\n treePs.push(this.serializeTreeCore(subTree, blobs, storage));\n }\n for (const id of Object.values(tree.blobs)) {\n const blob = await storage.readBlob(id);\n // ArrayBufferLike will not survive JSON.stringify()\n blobs[id] = bufferToString(blob, \"utf8\");\n }\n return Promise.all(treePs);\n }\n\n public static serializeTreeWithBlobContents(\n snapshot: ISnapshotTreeWithBlobContents,\n ): ISerializedBaseSnapshotBlobs {\n const blobs = {};\n this.serializeTreeWithBlobContentsCore(snapshot, blobs);\n return blobs;\n }\n\n private static serializeTreeWithBlobContentsCore(\n tree: ISnapshotTreeWithBlobContents,\n blobs: ISerializedBaseSnapshotBlobs,\n ) {\n for (const subTree of Object.values(tree.trees)) {\n this.serializeTreeWithBlobContentsCore(subTree, blobs);\n }\n for (const id of Object.values(tree.blobs)) {\n const blob = tree.blobsContents[id];\n assert(!!blob, 0x2ec /* \"Blob must be present in blobsContents\" */);\n // ArrayBufferLike will not survive JSON.stringify()\n blobs[id] = bufferToString(blob, \"utf8\");\n }\n }\n\n private _storage?: IDocumentStorageService;\n private get storage(): IDocumentStorageService {\n // avoid calling it until we need it since it will be undefined if we're not connected\n // and we shouldn't need it in this case anyway\n if (this._storage) {\n return this._storage;\n }\n this._storage = this.storageGetter();\n return this._storage;\n }\n\n public get repositoryUrl(): string { return this.storage.repositoryUrl; }\n\n /**\n * Reads the object with the given ID, returns content in arrayBufferLike\n */\n public async readBlob(id: string): Promise<ArrayBufferLike> {\n if (this.blobs[id] !== undefined) {\n return stringToBuffer(this.blobs[id], \"utf8\");\n }\n return this.storage.readBlob(id);\n }\n\n /**\n * Returns the snapshot tree.\n */\n // eslint-disable-next-line @rushstack/no-new-null\n public async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n return this.storage.getSnapshotTree(version);\n }\n\n /**\n * Retrieves all versions of the document starting at the specified versionId - or null if from the head\n */\n // eslint-disable-next-line @rushstack/no-new-null\n public async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n return this.storage.getVersions(versionId, count);\n }\n\n /**\n * Creates a blob out of the given buffer\n */\n public async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n return this.storage.createBlob(file);\n }\n\n /**\n * Uploads a summary tree to storage using the given context for reference of previous summary handle.\n * The ISummaryHandles in the uploaded tree should have paths to indicate which summary object they are\n * referencing from the previously acked summary.\n * Returns the uploaded summary handle.\n */\n public async uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string> {\n return this.storage.uploadSummaryWithContext(summary, context);\n }\n\n /**\n * Retrieves the commit that matches the packfile handle. If the packfile has already been committed and the\n * server has deleted it this call may result in a broken promise.\n */\n public async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n return this.storage.downloadSummary(handle);\n }\n}\n"]}
1
+ {"version":3,"file":"serializedSnapshotStorage.js","sourceRoot":"","sources":["../src/serializedSnapshotStorage.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsF;AAsBtF;;;GAGG;AACH,MAAa,yBAAyB;IACrC,YACkB,aAA4C,EAC5C,KAAmC;QADnC,kBAAa,GAAb,aAAa,CAA+B;QAC5C,UAAK,GAAL,KAAK,CAA8B;IAClD,CAAC;IAEG,MAAM,CAAC,KAAK,CAAC,aAAa,CAChC,QAAuB,EACvB,OAAgC;QAEhC,MAAM,KAAK,GAAG,EAAE,CAAC;QACjB,MAAM,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QACvD,OAAO,KAAK,CAAC;IACd,CAAC;IAEO,MAAM,CAAC,KAAK,CAAC,iBAAiB,CACrC,IAAmB,EACnB,KAAmC,EACnC,OAAgC;QAEhC,MAAM,MAAM,GAAmB,EAAE,CAAC;QAClC,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YAChD,MAAM,CAAC,IAAI,CAAC,IAAI,CA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AC,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;CACD;AAhID,8DAgIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, bufferToString, stringToBuffer } from \"@fluidframework/common-utils\";\nimport {\n\tFetchSource,\n\tIDocumentStorageService,\n\tISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { ISnapshotTreeWithBlobContents } from \"@fluidframework/container-definitions\";\n\n/**\n * Serialized blobs from a snapshot. Used to load offline.\n */\nexport interface ISerializedBaseSnapshotBlobs {\n\t[id: string]: string;\n}\n\n/**\n * A storage wrapper that can serialize blobs from a snapshot tree and then use them to rehydrate.\n * Used in offline load/attached dehydration to save snapshot blobs that are still needed but may have been deleted.\n */\nexport class SerializedSnapshotStorage implements IDocumentStorageService {\n\tconstructor(\n\t\tprivate readonly storageGetter: () => IDocumentStorageService,\n\t\tprivate readonly blobs: ISerializedBaseSnapshotBlobs,\n\t) {}\n\n\tpublic static async serializeTree(\n\t\tsnapshot: ISnapshotTree,\n\t\tstorage: IDocumentStorageService,\n\t): Promise<ISerializedBaseSnapshotBlobs> {\n\t\tconst blobs = {};\n\t\tawait this.serializeTreeCore(snapshot, blobs, storage);\n\t\treturn blobs;\n\t}\n\n\tprivate static async serializeTreeCore(\n\t\ttree: ISnapshotTree,\n\t\tblobs: ISerializedBaseSnapshotBlobs,\n\t\tstorage: IDocumentStorageService,\n\t) {\n\t\tconst treePs: Promise<any>[] = [];\n\t\tfor (const subTree of Object.values(tree.trees)) {\n\t\t\ttreePs.push(this.serializeTreeCore(subTree, blobs, storage));\n\t\t}\n\t\tfor (const id of Object.values(tree.blobs)) {\n\t\t\tconst blob = await storage.readBlob(id);\n\t\t\t// ArrayBufferLike will not survive JSON.stringify()\n\t\t\tblobs[id] = bufferToString(blob, \"utf8\");\n\t\t}\n\t\treturn Promise.all(treePs);\n\t}\n\n\tpublic static serializeTreeWithBlobContents(\n\t\tsnapshot: ISnapshotTreeWithBlobContents,\n\t): ISerializedBaseSnapshotBlobs {\n\t\tconst blobs = {};\n\t\tthis.serializeTreeWithBlobContentsCore(snapshot, blobs);\n\t\treturn blobs;\n\t}\n\n\tprivate static serializeTreeWithBlobContentsCore(\n\t\ttree: ISnapshotTreeWithBlobContents,\n\t\tblobs: ISerializedBaseSnapshotBlobs,\n\t) {\n\t\tfor (const subTree of Object.values(tree.trees)) {\n\t\t\tthis.serializeTreeWithBlobContentsCore(subTree, blobs);\n\t\t}\n\t\tfor (const id of Object.values(tree.blobs)) {\n\t\t\tconst blob = tree.blobsContents[id];\n\t\t\tassert(!!blob, 0x2ec /* \"Blob must be present in blobsContents\" */);\n\t\t\t// ArrayBufferLike will not survive JSON.stringify()\n\t\t\tblobs[id] = bufferToString(blob, \"utf8\");\n\t\t}\n\t}\n\n\tprivate _storage?: IDocumentStorageService;\n\tprivate get storage(): IDocumentStorageService {\n\t\t// avoid calling it until we need it since it will be undefined if we're not connected\n\t\t// and we shouldn't need it in this case anyway\n\t\tif (this._storage) {\n\t\t\treturn this._storage;\n\t\t}\n\t\tthis._storage = this.storageGetter();\n\t\treturn this._storage;\n\t}\n\n\tpublic get repositoryUrl(): string {\n\t\treturn this.storage.repositoryUrl;\n\t}\n\n\t/**\n\t * Reads the object with the given ID, returns content in arrayBufferLike\n\t */\n\tpublic async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\tif (this.blobs[id] !== undefined) {\n\t\t\treturn stringToBuffer(this.blobs[id], \"utf8\");\n\t\t}\n\t\treturn this.storage.readBlob(id);\n\t}\n\n\t/**\n\t * Returns the snapshot tree.\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n\t\treturn this.storage.getSnapshotTree(version);\n\t}\n\n\t/**\n\t * Retrieves all versions of the document starting at the specified versionId - or null if from the head\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tpublic async getVersions(\n\t\tversionId: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<IVersion[]> {\n\t\treturn this.storage.getVersions(versionId, count, scenarioName, fetchSource);\n\t}\n\n\t/**\n\t * Creates a blob out of the given buffer\n\t */\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this.storage.createBlob(file);\n\t}\n\n\t/**\n\t * Uploads a summary tree to storage using the given context for reference of previous summary handle.\n\t * The ISummaryHandles in the uploaded tree should have paths to indicate which summary object they are\n\t * referencing from the previously acked summary.\n\t * Returns the uploaded summary handle.\n\t */\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\treturn this.storage.uploadSummaryWithContext(summary, context);\n\t}\n\n\t/**\n\t * Retrieves the commit that matches the packfile handle. If the packfile has already been committed and the\n\t * server has deleted it this call may result in a broken promise.\n\t */\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\treturn this.storage.downloadSummary(handle);\n\t}\n}\n"]}
@@ -33,7 +33,7 @@ export declare class Summarizer extends EventEmitter implements ISummarizer {
33
33
  private readonly configurationGetter;
34
34
  /** Represents an object that can generate summary.
35
35
  * In practical terms, it's same runtime (this.runtime) with clientType === "summarizer".
36
- */
36
+ */
37
37
  private readonly internalsProvider;
38
38
  readonly summaryCollection: SummaryCollection;
39
39
  private readonly runCoordinatorCreateFn;
@@ -53,7 +53,7 @@ export declare class Summarizer extends EventEmitter implements ISummarizer {
53
53
  runtime: ISummarizerRuntime, configurationGetter: () => ISummaryConfiguration,
54
54
  /** Represents an object that can generate summary.
55
55
  * In practical terms, it's same runtime (this.runtime) with clientType === "summarizer".
56
- */
56
+ */
57
57
  internalsProvider: ISummarizerInternalsProvider, handleContext: IFluidHandleContext, summaryCollection: SummaryCollection, runCoordinatorCreateFn: (runtime: IConnectableRuntime) => Promise<ICancellableSummarizerController>);
58
58
  /**
59
59
  * Creates a Summarizer and its underlying client.
@@ -1 +1 @@
1
- {"version":3,"file":"summarizer.d.ts","sourceRoot":"","sources":["../src/summarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,OAAO,EAAgB,MAAM,uCAAuC,CAAC;AAI9E,OAAO,EAEH,eAAe,EAEf,YAAY,EAEf,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEH,mBAAmB,EACnB,YAAY,EAEf,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAElF,OAAO,EAAiB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGvE,OAAO,EACH,WAAW,EACX,4BAA4B,EAC5B,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACvB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,GAAG,CAAC;AAIxC,qBAAa,kBAAmB,SAAQ,YAAa,YAAW,mBAAmB,EAAE,eAAe;IAM5F,QAAQ,CAAC,MAAM,EAAE,OAAO;IAL5B,QAAQ,CAAC,SAAS,sBAAoB;IACtC,QAAQ,CAAC,QAAQ,QAAQ;gBAGrB,YAAY,EAAE,MAAM,EACX,MAAM,GAAE,OAAe;IAKpC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,qBAAiB,EAAE,MAAM,EAAE,gBAAgB;CAI5E;AAED,eAAO,MAAM,wBAAwB,iBAClB,MAAM,UAAU,OAAO,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;;;;OAKG;WACW,2BAA2B,CAAC,UAAU,EAAE,oBAAoB,GAAG,OAAO;IAIpF;;;;;;;;OAQG;YACW,KAAK;IA+DnB;;;;;OAKG;IACI,OAAO;IAWd,SAAgB,iBAAiB,EAAE,WAAW,CAAC,mBAAmB,CAAC,CA0DjE;IAEF,SAAgB,gBAAgB,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAS/D;YAEY,iBAAiB;CAgE/B"}
@@ -46,7 +46,7 @@ class Summarizer extends events_1.EventEmitter {
46
46
  runtime, configurationGetter,
47
47
  /** Represents an object that can generate summary.
48
48
  * In practical terms, it's same runtime (this.runtime) with clientType === "summarizer".
49
- */
49
+ */
50
50
  internalsProvider, handleContext, summaryCollection, runCoordinatorCreateFn) {
51
51
  super();
52
52
  this.runtime = runtime;
@@ -80,22 +80,29 @@ class Summarizer extends events_1.EventEmitter {
80
80
  // The promises related to starting, summarizing,
81
81
  // and submitting are communicated to the caller through the results builder.
82
82
  const coordinatorCreateP = this.runCoordinatorCreateFn(this.runtime);
83
- coordinatorCreateP.then((runCoordinator) => {
83
+ coordinatorCreateP
84
+ .then((runCoordinator) => {
84
85
  // Successfully created the cancellation token. Start the summarizer.
85
86
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
86
87
  const startP = this.start(this.runtime.clientId, runCoordinator);
87
- startP.then(async (runningSummarizer) => {
88
+ startP
89
+ .then(async (runningSummarizer) => {
88
90
  // Successfully started the summarizer. Run it.
89
91
  runningSummarizer.summarizeOnDemand(builder, ...args);
90
92
  // Wait for a command to stop or loss of connectivity before tearing down the summarizer and client.
91
- const stopReason = await Promise.race([this.stopDeferred.promise, runCoordinator.waitCancelled]);
93
+ const stopReason = await Promise.race([
94
+ this.stopDeferred.promise,
95
+ runCoordinator.waitCancelled,
96
+ ]);
92
97
  await runningSummarizer.waitStop(false);
93
98
  runCoordinator.stop(stopReason);
94
99
  this.close();
95
- }).catch((reason) => {
100
+ })
101
+ .catch((reason) => {
96
102
  builder.fail("Failed to start summarizer", reason);
97
103
  });
98
- }).catch((reason) => {
104
+ })
105
+ .catch((reason) => {
99
106
  builder.fail("Failed to create cancellation token", reason);
100
107
  });
101
108
  return builder.build();
@@ -105,7 +112,9 @@ class Summarizer extends events_1.EventEmitter {
105
112
  }
106
113
  };
107
114
  this.enqueueSummarize = (...args) => {
108
- if (this._disposed || this.runningSummarizer === undefined || this.runningSummarizer.disposed) {
115
+ if (this._disposed ||
116
+ this.runningSummarizer === undefined ||
117
+ this.runningSummarizer.disposed) {
109
118
  throw new container_utils_1.UsageError("Summarizer is not running or already disposed.");
110
119
  }
111
120
  return this.runningSummarizer.enqueueSummarize(...args);
@@ -113,9 +122,15 @@ class Summarizer extends events_1.EventEmitter {
113
122
  this.logger = telemetry_utils_1.ChildLogger.create(this.runtime.logger, "Summarizer");
114
123
  this.innerHandle = new summarizerHandle_1.SummarizerHandle(this, url, handleContext);
115
124
  }
116
- get IFluidLoadable() { return this; }
117
- get ISummarizer() { return this; }
118
- get handle() { return this.innerHandle; }
125
+ get IFluidLoadable() {
126
+ return this;
127
+ }
128
+ get ISummarizer() {
129
+ return this;
130
+ }
131
+ get handle() {
132
+ return this.innerHandle;
133
+ }
119
134
  /**
120
135
  * Creates a Summarizer and its underlying client.
121
136
  * Note that different implementations of ILoader will handle the URL differently.
@@ -139,7 +154,9 @@ class Summarizer extends events_1.EventEmitter {
139
154
  url,
140
155
  };
141
156
  const resolvedContainer = await loader.resolve(request);
142
- const fluidObject = await (0, runtime_utils_1.requestFluidObject)(resolvedContainer, { url: "_summarizer" });
157
+ const fluidObject = await (0, runtime_utils_1.requestFluidObject)(resolvedContainer, {
158
+ url: "_summarizer",
159
+ });
143
160
  if (fluidObject.ISummarizer === undefined) {
144
161
  throw new container_utils_1.UsageError("Fluid object does not implement ISummarizer");
145
162
  }
@@ -253,13 +270,14 @@ class Summarizer extends events_1.EventEmitter {
253
270
  }
254
271
  const runningSummarizer = await runningSummarizer_1.RunningSummarizer.start(this.logger, this.summaryCollection.createWatcher(clientId), this.configurationGetter(), async (...args) => this.internalsProvider.submitSummary(...args), // submitSummaryCallback
255
272
  new summarizerHeuristics_1.SummarizeHeuristicData(this.runtime.deltaManager.lastSequenceNumber, {
273
+ /** summary attempt baseline for heuristics */
256
274
  refSequenceNumber: this.runtime.deltaManager.initialSequenceNumber,
257
275
  summaryTime: Date.now(),
258
276
  }), (errorMessage) => {
259
277
  if (!this._disposed) {
260
278
  this.logger.sendErrorEvent({ eventName: "summarizingError" }, (0, exports.createSummarizingWarning)(errorMessage, true));
261
279
  }
262
- }, this.summaryCollection, runCoordinator /* cancellationToken */, (reason) => runCoordinator.stop(reason), /* stopSummarizerCallback */ this.runtime);
280
+ }, this.summaryCollection, runCoordinator /* cancellationToken */, (reason) => runCoordinator.stop(reason) /* stopSummarizerCallback */, this.runtime);
263
281
  this.runningSummarizer = runningSummarizer;
264
282
  this.starting = false;
265
283
  // Handle summary acks
@@ -301,20 +319,22 @@ class Summarizer extends events_1.EventEmitter {
301
319
  // Make sure we block any summarizer from being executed/enqueued while
302
320
  // executing the refreshLatestSummaryAck.
303
321
  // https://dev.azure.com/fluidframework/internal/_workitems/edit/779
304
- await this.runningSummarizer.lockedRefreshSummaryAckAction(async () => this.internalsProvider.refreshLatestSummaryAck({
322
+ await this.runningSummarizer.lockedRefreshSummaryAckAction(async () => this.internalsProvider
323
+ .refreshLatestSummaryAck({
305
324
  proposalHandle: summaryOpHandle,
306
325
  ackHandle: summaryAckHandle,
307
326
  summaryRefSeq: refSequenceNumber,
308
- summaryLogger
309
- }).catch(async (error) => {
327
+ summaryLogger,
328
+ })
329
+ .catch(async (error) => {
310
330
  // If the error is 404, so maybe the fetched version no longer exists on server. We just
311
331
  // ignore this error in that case, as that means we will have another summaryAck for the
312
332
  // latest version with which we will refresh the state. However in case of single commit
313
333
  // summary, we might me missing a summary ack, so in that case we are still fine as the
314
334
  // code in `submitSummary` function in container runtime, will refresh the latest state
315
335
  // by calling `refreshLatestSummaryAckFromServer` and we will be fine.
316
- if ((0, telemetry_utils_1.isFluidError)(error)
317
- && error.errorType === driver_definitions_1.DriverErrorType.fileNotFoundOrAccessDeniedError) {
336
+ if ((0, telemetry_utils_1.isFluidError)(error) &&
337
+ error.errorType === driver_definitions_1.DriverErrorType.fileNotFoundOrAccessDeniedError) {
318
338
  summaryLogger.sendTelemetryEvent({
319
339
  eventName: "HandleSummaryAckErrorIgnored",
320
340
  referenceSequenceNumber: refSequenceNumber,