@fluidframework/container-runtime 2.0.0-dev.5.2.0.169897 → 2.0.0-dev.6.4.0.191258

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 (561) hide show
  1. package/CHANGELOG.md +147 -0
  2. package/README.md +4 -3
  3. package/dist/batchTracker.d.ts +3 -2
  4. package/dist/batchTracker.d.ts.map +1 -1
  5. package/dist/batchTracker.js +6 -5
  6. package/dist/batchTracker.js.map +1 -1
  7. package/dist/blobManager.d.ts +15 -18
  8. package/dist/blobManager.d.ts.map +1 -1
  9. package/dist/blobManager.js +212 -171
  10. package/dist/blobManager.js.map +1 -1
  11. package/dist/connectionTelemetry.d.ts.map +1 -1
  12. package/dist/connectionTelemetry.js +33 -17
  13. package/dist/connectionTelemetry.js.map +1 -1
  14. package/dist/containerRuntime.d.ts +172 -35
  15. package/dist/containerRuntime.d.ts.map +1 -1
  16. package/dist/containerRuntime.js +722 -425
  17. package/dist/containerRuntime.js.map +1 -1
  18. package/dist/dataStore.d.ts.map +1 -1
  19. package/dist/dataStore.js +15 -7
  20. package/dist/dataStore.js.map +1 -1
  21. package/dist/dataStoreContext.d.ts +4 -4
  22. package/dist/dataStoreContext.d.ts.map +1 -1
  23. package/dist/dataStoreContext.js +87 -90
  24. package/dist/dataStoreContext.js.map +1 -1
  25. package/dist/dataStoreContexts.d.ts +1 -1
  26. package/dist/dataStoreContexts.d.ts.map +1 -1
  27. package/dist/dataStoreContexts.js +10 -10
  28. package/dist/dataStoreContexts.js.map +1 -1
  29. package/dist/dataStoreRegistry.js +2 -2
  30. package/dist/dataStoreRegistry.js.map +1 -1
  31. package/dist/dataStores.d.ts +23 -7
  32. package/dist/dataStores.d.ts.map +1 -1
  33. package/dist/dataStores.js +125 -82
  34. package/dist/dataStores.js.map +1 -1
  35. package/dist/deltaManagerProxyBase.d.ts +35 -0
  36. package/dist/deltaManagerProxyBase.d.ts.map +1 -0
  37. package/dist/deltaManagerProxyBase.js +77 -0
  38. package/dist/deltaManagerProxyBase.js.map +1 -0
  39. package/dist/deltaManagerSummarizerProxy.d.ts +1 -1
  40. package/dist/deltaManagerSummarizerProxy.d.ts.map +1 -1
  41. package/dist/deltaManagerSummarizerProxy.js +4 -2
  42. package/dist/deltaManagerSummarizerProxy.js.map +1 -1
  43. package/dist/deltaScheduler.d.ts.map +1 -1
  44. package/dist/deltaScheduler.js +10 -10
  45. package/dist/deltaScheduler.js.map +1 -1
  46. package/dist/error.d.ts +14 -0
  47. package/dist/error.d.ts.map +1 -0
  48. package/dist/error.js +21 -0
  49. package/dist/error.js.map +1 -0
  50. package/dist/gc/garbageCollection.d.ts +10 -9
  51. package/dist/gc/garbageCollection.d.ts.map +1 -1
  52. package/dist/gc/garbageCollection.js +65 -56
  53. package/dist/gc/garbageCollection.js.map +1 -1
  54. package/dist/gc/gcConfigs.d.ts.map +1 -1
  55. package/dist/gc/gcConfigs.js +18 -14
  56. package/dist/gc/gcConfigs.js.map +1 -1
  57. package/dist/gc/gcDefinitions.d.ts +17 -5
  58. package/dist/gc/gcDefinitions.d.ts.map +1 -1
  59. package/dist/gc/gcDefinitions.js +14 -15
  60. package/dist/gc/gcDefinitions.js.map +1 -1
  61. package/dist/gc/gcHelpers.d.ts +0 -8
  62. package/dist/gc/gcHelpers.d.ts.map +1 -1
  63. package/dist/gc/gcHelpers.js +11 -24
  64. package/dist/gc/gcHelpers.js.map +1 -1
  65. package/dist/gc/gcSummaryStateTracker.d.ts +4 -7
  66. package/dist/gc/gcSummaryStateTracker.d.ts.map +1 -1
  67. package/dist/gc/gcSummaryStateTracker.js +19 -58
  68. package/dist/gc/gcSummaryStateTracker.js.map +1 -1
  69. package/dist/gc/gcTelemetry.d.ts +1 -1
  70. package/dist/gc/gcTelemetry.d.ts.map +1 -1
  71. package/dist/gc/gcTelemetry.js +45 -35
  72. package/dist/gc/gcTelemetry.js.map +1 -1
  73. package/dist/gc/gcUnreferencedStateTracker.js +4 -4
  74. package/dist/gc/gcUnreferencedStateTracker.js.map +1 -1
  75. package/dist/gc/index.d.ts +2 -2
  76. package/dist/gc/index.d.ts.map +1 -1
  77. package/dist/gc/index.js +3 -5
  78. package/dist/gc/index.js.map +1 -1
  79. package/dist/id-compressor/appendOnlySortedMap.d.ts +8 -30
  80. package/dist/id-compressor/appendOnlySortedMap.d.ts.map +1 -1
  81. package/dist/id-compressor/appendOnlySortedMap.js +26 -68
  82. package/dist/id-compressor/appendOnlySortedMap.js.map +1 -1
  83. package/dist/id-compressor/finalSpace.d.ts +29 -0
  84. package/dist/id-compressor/finalSpace.d.ts.map +1 -0
  85. package/dist/id-compressor/finalSpace.js +62 -0
  86. package/dist/id-compressor/finalSpace.js.map +1 -0
  87. package/dist/id-compressor/idCompressor.d.ts +25 -250
  88. package/dist/id-compressor/idCompressor.d.ts.map +1 -1
  89. package/dist/id-compressor/idCompressor.js +390 -1153
  90. package/dist/id-compressor/idCompressor.js.map +1 -1
  91. package/dist/id-compressor/identifiers.d.ts +32 -0
  92. package/dist/id-compressor/identifiers.d.ts.map +1 -0
  93. package/dist/id-compressor/identifiers.js +15 -0
  94. package/dist/id-compressor/identifiers.js.map +1 -0
  95. package/dist/id-compressor/index.d.ts +5 -6
  96. package/dist/id-compressor/index.d.ts.map +1 -1
  97. package/dist/id-compressor/index.js +20 -26
  98. package/dist/id-compressor/index.js.map +1 -1
  99. package/dist/id-compressor/persistanceUtilities.d.ts +22 -0
  100. package/dist/id-compressor/persistanceUtilities.d.ts.map +1 -0
  101. package/dist/id-compressor/persistanceUtilities.js +43 -0
  102. package/dist/id-compressor/persistanceUtilities.js.map +1 -0
  103. package/dist/id-compressor/sessionSpaceNormalizer.d.ts +46 -0
  104. package/dist/id-compressor/sessionSpaceNormalizer.d.ts.map +1 -0
  105. package/dist/id-compressor/sessionSpaceNormalizer.js +80 -0
  106. package/dist/id-compressor/sessionSpaceNormalizer.js.map +1 -0
  107. package/dist/id-compressor/sessions.d.ts +115 -0
  108. package/dist/id-compressor/sessions.d.ts.map +1 -0
  109. package/dist/id-compressor/sessions.js +305 -0
  110. package/dist/id-compressor/sessions.js.map +1 -0
  111. package/dist/id-compressor/utilities.d.ts +49 -0
  112. package/dist/id-compressor/utilities.d.ts.map +1 -0
  113. package/dist/id-compressor/utilities.js +166 -0
  114. package/dist/id-compressor/utilities.js.map +1 -0
  115. package/dist/index.d.ts +3 -3
  116. package/dist/index.d.ts.map +1 -1
  117. package/dist/index.js +6 -4
  118. package/dist/index.js.map +1 -1
  119. package/dist/metadata.d.ts +18 -0
  120. package/dist/metadata.d.ts.map +1 -0
  121. package/dist/metadata.js +7 -0
  122. package/dist/metadata.js.map +1 -0
  123. package/dist/opLifecycle/batchManager.d.ts +2 -1
  124. package/dist/opLifecycle/batchManager.d.ts.map +1 -1
  125. package/dist/opLifecycle/batchManager.js +15 -7
  126. package/dist/opLifecycle/batchManager.js.map +1 -1
  127. package/dist/opLifecycle/definitions.d.ts +11 -0
  128. package/dist/opLifecycle/definitions.d.ts.map +1 -1
  129. package/dist/opLifecycle/definitions.js.map +1 -1
  130. package/dist/opLifecycle/index.d.ts +1 -1
  131. package/dist/opLifecycle/index.d.ts.map +1 -1
  132. package/dist/opLifecycle/index.js +2 -1
  133. package/dist/opLifecycle/index.js.map +1 -1
  134. package/dist/opLifecycle/opCompressor.d.ts +2 -2
  135. package/dist/opLifecycle/opCompressor.d.ts.map +1 -1
  136. package/dist/opLifecycle/opCompressor.js +12 -7
  137. package/dist/opLifecycle/opCompressor.js.map +1 -1
  138. package/dist/opLifecycle/opDecompressor.d.ts +2 -2
  139. package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
  140. package/dist/opLifecycle/opDecompressor.js +30 -21
  141. package/dist/opLifecycle/opDecompressor.js.map +1 -1
  142. package/dist/opLifecycle/opGroupingManager.d.ts +1 -1
  143. package/dist/opLifecycle/opGroupingManager.d.ts.map +1 -1
  144. package/dist/opLifecycle/opGroupingManager.js +19 -13
  145. package/dist/opLifecycle/opGroupingManager.js.map +1 -1
  146. package/dist/opLifecycle/opSplitter.d.ts +2 -2
  147. package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
  148. package/dist/opLifecycle/opSplitter.js +24 -19
  149. package/dist/opLifecycle/opSplitter.js.map +1 -1
  150. package/dist/opLifecycle/outbox.d.ts +39 -6
  151. package/dist/opLifecycle/outbox.d.ts.map +1 -1
  152. package/dist/opLifecycle/outbox.js +138 -61
  153. package/dist/opLifecycle/outbox.js.map +1 -1
  154. package/dist/opLifecycle/remoteMessageProcessor.d.ts +6 -1
  155. package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  156. package/dist/opLifecycle/remoteMessageProcessor.js +22 -8
  157. package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
  158. package/dist/opProperties.js +1 -2
  159. package/dist/opProperties.js.map +1 -1
  160. package/dist/packageVersion.d.ts +1 -1
  161. package/dist/packageVersion.js +1 -1
  162. package/dist/packageVersion.js.map +1 -1
  163. package/dist/pendingStateManager.d.ts +25 -10
  164. package/dist/pendingStateManager.d.ts.map +1 -1
  165. package/dist/pendingStateManager.js +101 -64
  166. package/dist/pendingStateManager.js.map +1 -1
  167. package/dist/scheduleManager.d.ts.map +1 -1
  168. package/dist/scheduleManager.js +43 -33
  169. package/dist/scheduleManager.js.map +1 -1
  170. package/dist/summary/index.d.ts +4 -4
  171. package/dist/summary/index.d.ts.map +1 -1
  172. package/dist/summary/index.js +3 -1
  173. package/dist/summary/index.js.map +1 -1
  174. package/dist/summary/orderedClientElection.d.ts +3 -3
  175. package/dist/summary/orderedClientElection.d.ts.map +1 -1
  176. package/dist/summary/orderedClientElection.js +26 -27
  177. package/dist/summary/orderedClientElection.js.map +1 -1
  178. package/dist/summary/runWhileConnectedCoordinator.js +3 -3
  179. package/dist/summary/runWhileConnectedCoordinator.js.map +1 -1
  180. package/dist/summary/runningSummarizer.d.ts +31 -10
  181. package/dist/summary/runningSummarizer.d.ts.map +1 -1
  182. package/dist/summary/runningSummarizer.js +271 -139
  183. package/dist/summary/runningSummarizer.js.map +1 -1
  184. package/dist/summary/summarizer.d.ts +8 -7
  185. package/dist/summary/summarizer.d.ts.map +1 -1
  186. package/dist/summary/summarizer.js +79 -78
  187. package/dist/summary/summarizer.js.map +1 -1
  188. package/dist/summary/summarizerClientElection.d.ts +2 -2
  189. package/dist/summary/summarizerClientElection.d.ts.map +1 -1
  190. package/dist/summary/summarizerClientElection.js +7 -11
  191. package/dist/summary/summarizerClientElection.js.map +1 -1
  192. package/dist/summary/summarizerHeuristics.js +10 -14
  193. package/dist/summary/summarizerHeuristics.js.map +1 -1
  194. package/dist/summary/summarizerNode/index.d.ts +1 -1
  195. package/dist/summary/summarizerNode/index.d.ts.map +1 -1
  196. package/dist/summary/summarizerNode/index.js.map +1 -1
  197. package/dist/summary/summarizerNode/summarizerNode.d.ts +40 -23
  198. package/dist/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  199. package/dist/summary/summarizerNode/summarizerNode.js +144 -149
  200. package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
  201. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts +25 -29
  202. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  203. package/dist/summary/summarizerNode/summarizerNodeUtils.js +2 -4
  204. package/dist/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  205. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts +21 -16
  206. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  207. package/dist/summary/summarizerNode/summarizerNodeWithGc.js +74 -123
  208. package/dist/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  209. package/dist/summary/summarizerTypes.d.ts +44 -24
  210. package/dist/summary/summarizerTypes.d.ts.map +1 -1
  211. package/dist/summary/summarizerTypes.js.map +1 -1
  212. package/dist/summary/summaryCollection.d.ts +2 -2
  213. package/dist/summary/summaryCollection.d.ts.map +1 -1
  214. package/dist/summary/summaryCollection.js +16 -13
  215. package/dist/summary/summaryCollection.js.map +1 -1
  216. package/dist/summary/summaryFormat.d.ts +4 -0
  217. package/dist/summary/summaryFormat.d.ts.map +1 -1
  218. package/dist/summary/summaryFormat.js +8 -5
  219. package/dist/summary/summaryFormat.js.map +1 -1
  220. package/dist/summary/summaryGenerator.d.ts +21 -6
  221. package/dist/summary/summaryGenerator.d.ts.map +1 -1
  222. package/dist/summary/summaryGenerator.js +117 -54
  223. package/dist/summary/summaryGenerator.js.map +1 -1
  224. package/dist/summary/summaryManager.d.ts +8 -7
  225. package/dist/summary/summaryManager.d.ts.map +1 -1
  226. package/dist/summary/summaryManager.js +38 -28
  227. package/dist/summary/summaryManager.js.map +1 -1
  228. package/lib/batchTracker.d.ts +3 -2
  229. package/lib/batchTracker.d.ts.map +1 -1
  230. package/lib/batchTracker.js +5 -4
  231. package/lib/batchTracker.js.map +1 -1
  232. package/lib/blobManager.d.ts +15 -18
  233. package/lib/blobManager.d.ts.map +1 -1
  234. package/lib/blobManager.js +187 -146
  235. package/lib/blobManager.js.map +1 -1
  236. package/lib/connectionTelemetry.d.ts.map +1 -1
  237. package/lib/connectionTelemetry.js +23 -7
  238. package/lib/connectionTelemetry.js.map +1 -1
  239. package/lib/containerRuntime.d.ts +172 -35
  240. package/lib/containerRuntime.d.ts.map +1 -1
  241. package/lib/containerRuntime.js +678 -380
  242. package/lib/containerRuntime.js.map +1 -1
  243. package/lib/dataStore.d.ts.map +1 -1
  244. package/lib/dataStore.js +13 -5
  245. package/lib/dataStore.js.map +1 -1
  246. package/lib/dataStoreContext.d.ts +4 -4
  247. package/lib/dataStoreContext.d.ts.map +1 -1
  248. package/lib/dataStoreContext.js +49 -52
  249. package/lib/dataStoreContext.js.map +1 -1
  250. package/lib/dataStoreContexts.d.ts +1 -1
  251. package/lib/dataStoreContexts.d.ts.map +1 -1
  252. package/lib/dataStoreContexts.js +3 -3
  253. package/lib/dataStoreContexts.js.map +1 -1
  254. package/lib/dataStoreRegistry.js +1 -1
  255. package/lib/dataStoreRegistry.js.map +1 -1
  256. package/lib/dataStores.d.ts +23 -7
  257. package/lib/dataStores.d.ts.map +1 -1
  258. package/lib/dataStores.js +107 -64
  259. package/lib/dataStores.js.map +1 -1
  260. package/lib/deltaManagerProxyBase.d.ts +35 -0
  261. package/lib/deltaManagerProxyBase.d.ts.map +1 -0
  262. package/lib/deltaManagerProxyBase.js +73 -0
  263. package/lib/deltaManagerProxyBase.js.map +1 -0
  264. package/lib/deltaManagerSummarizerProxy.d.ts +1 -1
  265. package/lib/deltaManagerSummarizerProxy.d.ts.map +1 -1
  266. package/lib/deltaManagerSummarizerProxy.js +3 -1
  267. package/lib/deltaManagerSummarizerProxy.js.map +1 -1
  268. package/lib/deltaScheduler.d.ts.map +1 -1
  269. package/lib/deltaScheduler.js +7 -7
  270. package/lib/deltaScheduler.js.map +1 -1
  271. package/lib/error.d.ts +14 -0
  272. package/lib/error.d.ts.map +1 -0
  273. package/lib/error.js +17 -0
  274. package/lib/error.js.map +1 -0
  275. package/lib/gc/garbageCollection.d.ts +10 -9
  276. package/lib/gc/garbageCollection.d.ts.map +1 -1
  277. package/lib/gc/garbageCollection.js +61 -52
  278. package/lib/gc/garbageCollection.js.map +1 -1
  279. package/lib/gc/gcConfigs.d.ts.map +1 -1
  280. package/lib/gc/gcConfigs.js +16 -12
  281. package/lib/gc/gcConfigs.js.map +1 -1
  282. package/lib/gc/gcDefinitions.d.ts +17 -5
  283. package/lib/gc/gcDefinitions.d.ts.map +1 -1
  284. package/lib/gc/gcDefinitions.js +13 -14
  285. package/lib/gc/gcDefinitions.js.map +1 -1
  286. package/lib/gc/gcHelpers.d.ts +0 -8
  287. package/lib/gc/gcHelpers.d.ts.map +1 -1
  288. package/lib/gc/gcHelpers.js +5 -17
  289. package/lib/gc/gcHelpers.js.map +1 -1
  290. package/lib/gc/gcSummaryStateTracker.d.ts +4 -7
  291. package/lib/gc/gcSummaryStateTracker.d.ts.map +1 -1
  292. package/lib/gc/gcSummaryStateTracker.js +20 -59
  293. package/lib/gc/gcSummaryStateTracker.js.map +1 -1
  294. package/lib/gc/gcTelemetry.d.ts +1 -1
  295. package/lib/gc/gcTelemetry.d.ts.map +1 -1
  296. package/lib/gc/gcTelemetry.js +46 -36
  297. package/lib/gc/gcTelemetry.js.map +1 -1
  298. package/lib/gc/gcUnreferencedStateTracker.js +1 -1
  299. package/lib/gc/gcUnreferencedStateTracker.js.map +1 -1
  300. package/lib/gc/index.d.ts +2 -2
  301. package/lib/gc/index.d.ts.map +1 -1
  302. package/lib/gc/index.js +2 -2
  303. package/lib/gc/index.js.map +1 -1
  304. package/lib/id-compressor/appendOnlySortedMap.d.ts +8 -30
  305. package/lib/id-compressor/appendOnlySortedMap.d.ts.map +1 -1
  306. package/lib/id-compressor/appendOnlySortedMap.js +25 -66
  307. package/lib/id-compressor/appendOnlySortedMap.js.map +1 -1
  308. package/lib/id-compressor/finalSpace.d.ts +29 -0
  309. package/lib/id-compressor/finalSpace.d.ts.map +1 -0
  310. package/lib/id-compressor/finalSpace.js +58 -0
  311. package/lib/id-compressor/finalSpace.js.map +1 -0
  312. package/lib/id-compressor/idCompressor.d.ts +25 -250
  313. package/lib/id-compressor/idCompressor.d.ts.map +1 -1
  314. package/lib/id-compressor/idCompressor.js +385 -1142
  315. package/lib/id-compressor/idCompressor.js.map +1 -1
  316. package/lib/id-compressor/identifiers.d.ts +32 -0
  317. package/lib/id-compressor/identifiers.d.ts.map +1 -0
  318. package/lib/id-compressor/identifiers.js +11 -0
  319. package/lib/id-compressor/identifiers.js.map +1 -0
  320. package/lib/id-compressor/index.d.ts +5 -6
  321. package/lib/id-compressor/index.d.ts.map +1 -1
  322. package/lib/id-compressor/index.js +5 -6
  323. package/lib/id-compressor/index.js.map +1 -1
  324. package/lib/id-compressor/persistanceUtilities.d.ts +22 -0
  325. package/lib/id-compressor/persistanceUtilities.d.ts.map +1 -0
  326. package/lib/id-compressor/persistanceUtilities.js +34 -0
  327. package/lib/id-compressor/persistanceUtilities.js.map +1 -0
  328. package/lib/id-compressor/sessionSpaceNormalizer.d.ts +46 -0
  329. package/lib/id-compressor/sessionSpaceNormalizer.d.ts.map +1 -0
  330. package/lib/id-compressor/sessionSpaceNormalizer.js +76 -0
  331. package/lib/id-compressor/sessionSpaceNormalizer.js.map +1 -0
  332. package/lib/id-compressor/sessions.d.ts +115 -0
  333. package/lib/id-compressor/sessions.d.ts.map +1 -0
  334. package/lib/id-compressor/sessions.js +290 -0
  335. package/lib/id-compressor/sessions.js.map +1 -0
  336. package/lib/id-compressor/utilities.d.ts +49 -0
  337. package/lib/id-compressor/utilities.d.ts.map +1 -0
  338. package/lib/id-compressor/utilities.js +148 -0
  339. package/lib/id-compressor/utilities.js.map +1 -0
  340. package/lib/index.d.ts +3 -3
  341. package/lib/index.d.ts.map +1 -1
  342. package/lib/index.js +2 -2
  343. package/lib/index.js.map +1 -1
  344. package/lib/metadata.d.ts +18 -0
  345. package/lib/metadata.d.ts.map +1 -0
  346. package/lib/metadata.js +6 -0
  347. package/lib/metadata.js.map +1 -0
  348. package/lib/opLifecycle/batchManager.d.ts +2 -1
  349. package/lib/opLifecycle/batchManager.d.ts.map +1 -1
  350. package/lib/opLifecycle/batchManager.js +15 -7
  351. package/lib/opLifecycle/batchManager.js.map +1 -1
  352. package/lib/opLifecycle/definitions.d.ts +11 -0
  353. package/lib/opLifecycle/definitions.d.ts.map +1 -1
  354. package/lib/opLifecycle/definitions.js.map +1 -1
  355. package/lib/opLifecycle/index.d.ts +1 -1
  356. package/lib/opLifecycle/index.d.ts.map +1 -1
  357. package/lib/opLifecycle/index.js +1 -1
  358. package/lib/opLifecycle/index.js.map +1 -1
  359. package/lib/opLifecycle/opCompressor.d.ts +2 -2
  360. package/lib/opLifecycle/opCompressor.d.ts.map +1 -1
  361. package/lib/opLifecycle/opCompressor.js +10 -5
  362. package/lib/opLifecycle/opCompressor.js.map +1 -1
  363. package/lib/opLifecycle/opDecompressor.d.ts +2 -2
  364. package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
  365. package/lib/opLifecycle/opDecompressor.js +22 -13
  366. package/lib/opLifecycle/opDecompressor.js.map +1 -1
  367. package/lib/opLifecycle/opGroupingManager.d.ts +1 -1
  368. package/lib/opLifecycle/opGroupingManager.d.ts.map +1 -1
  369. package/lib/opLifecycle/opGroupingManager.js +17 -11
  370. package/lib/opLifecycle/opGroupingManager.js.map +1 -1
  371. package/lib/opLifecycle/opSplitter.d.ts +2 -2
  372. package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
  373. package/lib/opLifecycle/opSplitter.js +15 -10
  374. package/lib/opLifecycle/opSplitter.js.map +1 -1
  375. package/lib/opLifecycle/outbox.d.ts +39 -6
  376. package/lib/opLifecycle/outbox.d.ts.map +1 -1
  377. package/lib/opLifecycle/outbox.js +132 -56
  378. package/lib/opLifecycle/outbox.js.map +1 -1
  379. package/lib/opLifecycle/remoteMessageProcessor.d.ts +6 -1
  380. package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  381. package/lib/opLifecycle/remoteMessageProcessor.js +23 -9
  382. package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
  383. package/lib/opProperties.js +1 -2
  384. package/lib/opProperties.js.map +1 -1
  385. package/lib/packageVersion.d.ts +1 -1
  386. package/lib/packageVersion.js +1 -1
  387. package/lib/packageVersion.js.map +1 -1
  388. package/lib/pendingStateManager.d.ts +25 -10
  389. package/lib/pendingStateManager.d.ts.map +1 -1
  390. package/lib/pendingStateManager.js +90 -53
  391. package/lib/pendingStateManager.js.map +1 -1
  392. package/lib/scheduleManager.d.ts.map +1 -1
  393. package/lib/scheduleManager.js +25 -15
  394. package/lib/scheduleManager.js.map +1 -1
  395. package/lib/summary/index.d.ts +4 -4
  396. package/lib/summary/index.d.ts.map +1 -1
  397. package/lib/summary/index.js +2 -2
  398. package/lib/summary/index.js.map +1 -1
  399. package/lib/summary/orderedClientElection.d.ts +3 -3
  400. package/lib/summary/orderedClientElection.d.ts.map +1 -1
  401. package/lib/summary/orderedClientElection.js +21 -22
  402. package/lib/summary/orderedClientElection.js.map +1 -1
  403. package/lib/summary/runWhileConnectedCoordinator.js +1 -1
  404. package/lib/summary/runWhileConnectedCoordinator.js.map +1 -1
  405. package/lib/summary/runningSummarizer.d.ts +31 -10
  406. package/lib/summary/runningSummarizer.d.ts.map +1 -1
  407. package/lib/summary/runningSummarizer.js +265 -133
  408. package/lib/summary/runningSummarizer.js.map +1 -1
  409. package/lib/summary/summarizer.d.ts +8 -7
  410. package/lib/summary/summarizer.d.ts.map +1 -1
  411. package/lib/summary/summarizer.js +75 -74
  412. package/lib/summary/summarizer.js.map +1 -1
  413. package/lib/summary/summarizerClientElection.d.ts +2 -2
  414. package/lib/summary/summarizerClientElection.d.ts.map +1 -1
  415. package/lib/summary/summarizerClientElection.js +6 -10
  416. package/lib/summary/summarizerClientElection.js.map +1 -1
  417. package/lib/summary/summarizerHeuristics.js +9 -13
  418. package/lib/summary/summarizerHeuristics.js.map +1 -1
  419. package/lib/summary/summarizerNode/index.d.ts +1 -1
  420. package/lib/summary/summarizerNode/index.d.ts.map +1 -1
  421. package/lib/summary/summarizerNode/index.js.map +1 -1
  422. package/lib/summary/summarizerNode/summarizerNode.d.ts +40 -23
  423. package/lib/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  424. package/lib/summary/summarizerNode/summarizerNode.js +132 -137
  425. package/lib/summary/summarizerNode/summarizerNode.js.map +1 -1
  426. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts +25 -29
  427. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  428. package/lib/summary/summarizerNode/summarizerNodeUtils.js +2 -4
  429. package/lib/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  430. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts +21 -16
  431. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  432. package/lib/summary/summarizerNode/summarizerNodeWithGc.js +70 -119
  433. package/lib/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  434. package/lib/summary/summarizerTypes.d.ts +44 -24
  435. package/lib/summary/summarizerTypes.d.ts.map +1 -1
  436. package/lib/summary/summarizerTypes.js.map +1 -1
  437. package/lib/summary/summaryCollection.d.ts +2 -2
  438. package/lib/summary/summaryCollection.d.ts.map +1 -1
  439. package/lib/summary/summaryCollection.js +9 -6
  440. package/lib/summary/summaryCollection.js.map +1 -1
  441. package/lib/summary/summaryFormat.d.ts +4 -0
  442. package/lib/summary/summaryFormat.d.ts.map +1 -1
  443. package/lib/summary/summaryFormat.js +7 -4
  444. package/lib/summary/summaryFormat.js.map +1 -1
  445. package/lib/summary/summaryGenerator.d.ts +21 -6
  446. package/lib/summary/summaryGenerator.d.ts.map +1 -1
  447. package/lib/summary/summaryGenerator.js +109 -47
  448. package/lib/summary/summaryGenerator.js.map +1 -1
  449. package/lib/summary/summaryManager.d.ts +8 -7
  450. package/lib/summary/summaryManager.d.ts.map +1 -1
  451. package/lib/summary/summaryManager.js +35 -25
  452. package/lib/summary/summaryManager.js.map +1 -1
  453. package/package.json +30 -32
  454. package/src/batchTracker.ts +7 -5
  455. package/src/blobManager.ts +235 -172
  456. package/src/connectionTelemetry.ts +19 -5
  457. package/src/containerRuntime.ts +853 -431
  458. package/src/dataStore.ts +12 -4
  459. package/src/dataStoreContext.ts +49 -46
  460. package/src/dataStoreContexts.ts +4 -4
  461. package/src/dataStoreRegistry.ts +1 -1
  462. package/src/dataStores.ts +119 -80
  463. package/src/deltaManagerProxyBase.ts +111 -0
  464. package/src/deltaManagerSummarizerProxy.ts +4 -1
  465. package/src/deltaScheduler.ts +7 -11
  466. package/src/error.ts +18 -0
  467. package/src/gc/garbageCollection.md +53 -5
  468. package/src/gc/garbageCollection.ts +58 -51
  469. package/src/gc/gcConfigs.ts +4 -2
  470. package/src/gc/gcDefinitions.ts +17 -21
  471. package/src/gc/gcEarlyAdoption.md +145 -0
  472. package/src/gc/gcHelpers.ts +1 -12
  473. package/src/gc/gcSummaryStateTracker.ts +19 -65
  474. package/src/gc/gcTelemetry.ts +15 -13
  475. package/src/gc/gcUnreferencedStateTracker.ts +1 -1
  476. package/src/gc/index.ts +2 -4
  477. package/src/id-compressor/appendOnlySortedMap.ts +26 -87
  478. package/src/id-compressor/finalSpace.ts +67 -0
  479. package/src/id-compressor/idCompressor.ts +458 -1682
  480. package/src/id-compressor/identifiers.ts +42 -0
  481. package/src/id-compressor/index.ts +11 -20
  482. package/src/id-compressor/persistanceUtilities.ts +58 -0
  483. package/src/id-compressor/sessionSpaceNormalizer.ts +83 -0
  484. package/src/id-compressor/sessions.ts +405 -0
  485. package/src/id-compressor/utilities.ts +187 -0
  486. package/src/index.ts +9 -2
  487. package/src/metadata.ts +19 -0
  488. package/src/opLifecycle/README.md +20 -0
  489. package/src/opLifecycle/batchManager.ts +9 -1
  490. package/src/opLifecycle/definitions.ts +11 -0
  491. package/src/opLifecycle/index.ts +1 -1
  492. package/src/opLifecycle/opCompressor.ts +6 -5
  493. package/src/opLifecycle/opDecompressor.ts +47 -17
  494. package/src/opLifecycle/opGroupingManager.ts +18 -8
  495. package/src/opLifecycle/opSplitter.ts +10 -7
  496. package/src/opLifecycle/outbox.ts +177 -72
  497. package/src/opLifecycle/remoteMessageProcessor.ts +32 -9
  498. package/src/packageVersion.ts +1 -1
  499. package/src/pendingStateManager.ts +123 -78
  500. package/src/scheduleManager.ts +22 -11
  501. package/src/summary/index.ts +7 -4
  502. package/src/summary/orderedClientElection.ts +10 -6
  503. package/src/summary/runWhileConnectedCoordinator.ts +1 -1
  504. package/src/summary/runningSummarizer.ts +291 -163
  505. package/src/summary/summarizer.ts +27 -16
  506. package/src/summary/summarizerClientElection.ts +2 -2
  507. package/src/summary/summarizerHeuristics.ts +1 -1
  508. package/src/summary/summarizerNode/index.ts +2 -2
  509. package/src/summary/summarizerNode/summarizerNode.ts +142 -184
  510. package/src/summary/summarizerNode/summarizerNodeUtils.ts +27 -35
  511. package/src/summary/summarizerNode/summarizerNodeWithGc.ts +72 -148
  512. package/src/summary/summarizerTypes.ts +49 -24
  513. package/src/summary/summaryCollection.ts +9 -4
  514. package/src/summary/summaryFormat.ts +9 -2
  515. package/src/summary/summaryGenerator.ts +72 -49
  516. package/src/summary/summaryManager.ts +44 -16
  517. package/dist/id-compressor/idRange.d.ts +0 -11
  518. package/dist/id-compressor/idRange.d.ts.map +0 -1
  519. package/dist/id-compressor/idRange.js +0 -29
  520. package/dist/id-compressor/idRange.js.map +0 -1
  521. package/dist/id-compressor/numericUuid.d.ts +0 -59
  522. package/dist/id-compressor/numericUuid.d.ts.map +0 -1
  523. package/dist/id-compressor/numericUuid.js +0 -325
  524. package/dist/id-compressor/numericUuid.js.map +0 -1
  525. package/dist/id-compressor/sessionIdNormalizer.d.ts +0 -138
  526. package/dist/id-compressor/sessionIdNormalizer.d.ts.map +0 -1
  527. package/dist/id-compressor/sessionIdNormalizer.js +0 -488
  528. package/dist/id-compressor/sessionIdNormalizer.js.map +0 -1
  529. package/dist/id-compressor/utils.d.ts +0 -57
  530. package/dist/id-compressor/utils.d.ts.map +0 -1
  531. package/dist/id-compressor/utils.js +0 -90
  532. package/dist/id-compressor/utils.js.map +0 -1
  533. package/dist/id-compressor/uuidUtilities.d.ts +0 -30
  534. package/dist/id-compressor/uuidUtilities.d.ts.map +0 -1
  535. package/dist/id-compressor/uuidUtilities.js +0 -106
  536. package/dist/id-compressor/uuidUtilities.js.map +0 -1
  537. package/lib/id-compressor/idRange.d.ts +0 -11
  538. package/lib/id-compressor/idRange.d.ts.map +0 -1
  539. package/lib/id-compressor/idRange.js +0 -25
  540. package/lib/id-compressor/idRange.js.map +0 -1
  541. package/lib/id-compressor/numericUuid.d.ts +0 -59
  542. package/lib/id-compressor/numericUuid.d.ts.map +0 -1
  543. package/lib/id-compressor/numericUuid.js +0 -315
  544. package/lib/id-compressor/numericUuid.js.map +0 -1
  545. package/lib/id-compressor/sessionIdNormalizer.d.ts +0 -138
  546. package/lib/id-compressor/sessionIdNormalizer.d.ts.map +0 -1
  547. package/lib/id-compressor/sessionIdNormalizer.js +0 -484
  548. package/lib/id-compressor/sessionIdNormalizer.js.map +0 -1
  549. package/lib/id-compressor/utils.d.ts +0 -57
  550. package/lib/id-compressor/utils.d.ts.map +0 -1
  551. package/lib/id-compressor/utils.js +0 -79
  552. package/lib/id-compressor/utils.js.map +0 -1
  553. package/lib/id-compressor/uuidUtilities.d.ts +0 -30
  554. package/lib/id-compressor/uuidUtilities.d.ts.map +0 -1
  555. package/lib/id-compressor/uuidUtilities.js +0 -98
  556. package/lib/id-compressor/uuidUtilities.js.map +0 -1
  557. package/src/id-compressor/idRange.ts +0 -35
  558. package/src/id-compressor/numericUuid.ts +0 -383
  559. package/src/id-compressor/sessionIdNormalizer.ts +0 -609
  560. package/src/id-compressor/utils.ts +0 -114
  561. package/src/id-compressor/uuidUtilities.ts +0 -123
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OrderedClientElection = exports.OrderedClientCollection = void 0;
4
4
  const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
5
- const common_utils_1 = require("@fluidframework/common-utils");
6
- const container_utils_1 = require("@fluidframework/container-utils");
5
+ const core_utils_1 = require("@fluidframework/core-utils");
6
+ const client_utils_1 = require("@fluid-internal/client-utils");
7
7
  const summarizerClientElection_1 = require("./summarizerClientElection");
8
8
  /**
9
9
  * Tracks clients in the Quorum. It maintains their order using their join op
@@ -12,7 +12,7 @@ const summarizerClientElection_1 = require("./summarizerClientElection");
12
12
  * with pointers to both the first and last nodes.
13
13
  * The first (root) node is a placeholder to simplify logic and reduce null checking.
14
14
  */
15
- class OrderedClientCollection extends common_utils_1.TypedEventEmitter {
15
+ class OrderedClientCollection extends client_utils_1.TypedEventEmitter {
16
16
  constructor(logger, deltaManager, quorum) {
17
17
  super();
18
18
  /** Collection of ALL clients currently in the quorum, with client ids as keys. */
@@ -25,7 +25,7 @@ class OrderedClientCollection extends common_utils_1.TypedEventEmitter {
25
25
  };
26
26
  /** Pointer to end of linked list, for optimized client adds. */
27
27
  this._youngestClient = this.rootNode;
28
- this.logger = telemetry_utils_1.ChildLogger.create(logger, "OrderedClientCollection");
28
+ this.logger = (0, telemetry_utils_1.createChildLogger)({ logger, namespace: "OrderedClientCollection" });
29
29
  const members = quorum.getMembers();
30
30
  for (const [clientId, client] of members) {
31
31
  this.addClient(clientId, client);
@@ -58,10 +58,10 @@ class OrderedClientCollection extends common_utils_1.TypedEventEmitter {
58
58
  addClient(clientId, client) {
59
59
  // Normal case is adding the latest client, which will bypass loop.
60
60
  // Find where it belongs otherwise (maybe possible during initial load?).
61
- (0, common_utils_1.assert)(client.sequenceNumber > -1, 0x1f6 /* "Negative client sequence number not allowed" */);
61
+ (0, core_utils_1.assert)(client.sequenceNumber > -1, 0x1f6 /* "Negative client sequence number not allowed" */);
62
62
  let currClient = this._youngestClient;
63
63
  while (currClient.sequenceNumber > client.sequenceNumber) {
64
- (0, common_utils_1.assert)(currClient.olderClient !== undefined, 0x1f7 /* "Previous client should always be defined" */);
64
+ (0, core_utils_1.assert)(currClient.olderClient !== undefined, 0x1f7 /* "Previous client should always be defined" */);
65
65
  // Note: If adding a client older than the elected client, it will not be automatically elected.
66
66
  currClient = currClient.olderClient;
67
67
  }
@@ -69,7 +69,7 @@ class OrderedClientCollection extends common_utils_1.TypedEventEmitter {
69
69
  const newClient = {
70
70
  clientId,
71
71
  sequenceNumber: client.sequenceNumber,
72
- client: Object.assign({}, client.client),
72
+ client: { ...client.client },
73
73
  olderClient: currClient,
74
74
  youngerClient: currClient.youngerClient,
75
75
  };
@@ -122,7 +122,7 @@ exports.OrderedClientCollection = OrderedClientCollection;
122
122
  * This can be true as long as incrementElectedClient and resetElectedClient calls
123
123
  * are called under the same conditions for all clients.
124
124
  */
125
- class OrderedClientElection extends common_utils_1.TypedEventEmitter {
125
+ class OrderedClientElection extends client_utils_1.TypedEventEmitter {
126
126
  constructor(logger, orderedClientCollection,
127
127
  /** Serialized state from summary or current sequence number at time of load if new. */
128
128
  initialState, isEligibleFn) {
@@ -156,13 +156,13 @@ class OrderedClientElection extends common_utils_1.TypedEventEmitter {
156
156
  }
157
157
  else {
158
158
  // Override the initially elected client with the initial state.
159
- if ((initialClient === null || initialClient === void 0 ? void 0 : initialClient.clientId) !== initialState.electedClientId) {
159
+ if (initialClient?.clientId !== initialState.electedClientId) {
160
160
  // Cannot find initially elected client, so elect undefined.
161
161
  this.logger.sendErrorEvent({
162
162
  eventName: "InitialElectedClientNotFound",
163
163
  electionSequenceNumber: initialState.electionSequenceNumber,
164
164
  expectedClientId: initialState.electedClientId,
165
- electedClientId: initialClient === null || initialClient === void 0 ? void 0 : initialClient.clientId,
165
+ electedClientId: initialClient?.clientId,
166
166
  clientCount: orderedClientCollection.count,
167
167
  });
168
168
  }
@@ -173,7 +173,7 @@ class OrderedClientElection extends common_utils_1.TypedEventEmitter {
173
173
  eventName: "InitialElectedClientIneligible",
174
174
  electionSequenceNumber: initialState.electionSequenceNumber,
175
175
  expectedClientId: initialState.electedClientId,
176
- electedClientId: initialClient === null || initialClient === void 0 ? void 0 : initialClient.clientId,
176
+ electedClientId: initialClient?.clientId,
177
177
  });
178
178
  }
179
179
  this._electedParent = initialParent;
@@ -236,7 +236,7 @@ class OrderedClientElection extends common_utils_1.TypedEventEmitter {
236
236
  */
237
237
  tryElectingClient(client, sequenceNumber) {
238
238
  let change = false;
239
- const isSummarizerClient = (client === null || client === void 0 ? void 0 : client.client.details.type) === summarizerClientElection_1.summarizerClientType;
239
+ const isSummarizerClient = client?.client.details.type === summarizerClientElection_1.summarizerClientType;
240
240
  const prevClient = this._electedClient;
241
241
  if (this._electedClient !== client) {
242
242
  // Changing the elected client. Record the sequence number and note that we have to fire an event.
@@ -281,11 +281,10 @@ class OrderedClientElection extends common_utils_1.TypedEventEmitter {
281
281
  * @param sequenceNumber - sequence number when client was added
282
282
  */
283
283
  addClient(client, sequenceNumber) {
284
- var _a;
285
284
  if (this.isEligibleFn(client)) {
286
285
  this._eligibleCount++;
287
286
  const newClientIsSummarizer = client.client.details.type === summarizerClientElection_1.summarizerClientType;
288
- const electedClientIsSummarizer = ((_a = this._electedClient) === null || _a === void 0 ? void 0 : _a.client.details.type) === summarizerClientElection_1.summarizerClientType;
287
+ const electedClientIsSummarizer = this._electedClient?.client.details.type === summarizerClientElection_1.summarizerClientType;
289
288
  // Note that we allow a summarizer client to supersede an interactive client as elected client.
290
289
  if (this._electedClient === undefined ||
291
290
  (!electedClientIsSummarizer && newClientIsSummarizer)) {
@@ -304,7 +303,6 @@ class OrderedClientElection extends common_utils_1.TypedEventEmitter {
304
303
  * @param sequenceNumber - sequence number when client was removed
305
304
  */
306
305
  removeClient(client, sequenceNumber) {
307
- var _a, _b, _c, _d, _e;
308
306
  if (this.isEligibleFn(client)) {
309
307
  this._eligibleCount--;
310
308
  if (this._electedClient === client) {
@@ -313,14 +311,15 @@ class OrderedClientElection extends common_utils_1.TypedEventEmitter {
313
311
  // 1. The _electedClient is a summarizer that we've been allowing to finish its work.
314
312
  // Let the _electedParent become the _electedClient so that it can start its own summarizer.
315
313
  if (this._electedClient.client.details.type !== summarizerClientElection_1.summarizerClientType) {
316
- throw new container_utils_1.UsageError("Elected client should be a summarizer client 1");
314
+ throw new telemetry_utils_1.UsageError("Elected client should be a summarizer client 1");
317
315
  }
318
316
  this.tryElectingClient(this._electedParent, sequenceNumber);
319
317
  }
320
318
  else {
321
319
  // 2. The _electedClient is an interactive client that has left the quorum.
322
320
  // Automatically shift to next oldest client.
323
- const nextClient = (_b = this.findFirstEligibleParent((_a = this._electedParent) === null || _a === void 0 ? void 0 : _a.youngerClient)) !== null && _b !== void 0 ? _b : this.findFirstEligibleParent(this.orderedClientCollection.oldestClient);
321
+ const nextClient = this.findFirstEligibleParent(this._electedParent?.youngerClient) ??
322
+ this.findFirstEligibleParent(this.orderedClientCollection.oldestClient);
324
323
  this.tryElectingClient(nextClient, sequenceNumber);
325
324
  }
326
325
  }
@@ -328,10 +327,11 @@ class OrderedClientElection extends common_utils_1.TypedEventEmitter {
328
327
  // Removing the _electedParent (but not _electedClient).
329
328
  // Shift to the next oldest parent, but do not replace the _electedClient,
330
329
  // which is a summarizer that is still doing work.
331
- if (((_c = this._electedClient) === null || _c === void 0 ? void 0 : _c.client.details.type) !== summarizerClientElection_1.summarizerClientType) {
332
- throw new container_utils_1.UsageError("Elected client should be a summarizer client 2");
330
+ if (this._electedClient?.client.details.type !== summarizerClientElection_1.summarizerClientType) {
331
+ throw new telemetry_utils_1.UsageError("Elected client should be a summarizer client 2");
333
332
  }
334
- const nextParent = (_e = this.findFirstEligibleParent((_d = this._electedParent) === null || _d === void 0 ? void 0 : _d.youngerClient)) !== null && _e !== void 0 ? _e : this.findFirstEligibleParent(this.orderedClientCollection.oldestClient);
333
+ const nextParent = this.findFirstEligibleParent(this._electedParent?.youngerClient) ??
334
+ this.findFirstEligibleParent(this.orderedClientCollection.oldestClient);
335
335
  this.tryElectingParent(nextParent, sequenceNumber);
336
336
  }
337
337
  }
@@ -344,8 +344,8 @@ class OrderedClientElection extends common_utils_1.TypedEventEmitter {
344
344
  * or if the current summarizer is not responsive and we want to stop it and spawn a new one.
345
345
  */
346
346
  incrementElectedClient(sequenceNumber) {
347
- var _a, _b;
348
- const nextClient = (_b = this.findFirstEligibleParent((_a = this._electedParent) === null || _a === void 0 ? void 0 : _a.youngerClient)) !== null && _b !== void 0 ? _b : this.findFirstEligibleParent(this.orderedClientCollection.oldestClient);
347
+ const nextClient = this.findFirstEligibleParent(this._electedParent?.youngerClient) ??
348
+ this.findFirstEligibleParent(this.orderedClientCollection.oldestClient);
349
349
  if (this._electedClient === undefined || this._electedClient === this._electedParent) {
350
350
  this.tryElectingClient(nextClient, sequenceNumber);
351
351
  }
@@ -371,15 +371,14 @@ class OrderedClientElection extends common_utils_1.TypedEventEmitter {
371
371
  }
372
372
  }
373
373
  peekNextElectedClient() {
374
- var _a, _b;
375
- return ((_b = this.findFirstEligibleParent((_a = this._electedParent) === null || _a === void 0 ? void 0 : _a.youngerClient)) !== null && _b !== void 0 ? _b : this.findFirstEligibleParent(this.orderedClientCollection.oldestClient));
374
+ return (this.findFirstEligibleParent(this._electedParent?.youngerClient) ??
375
+ this.findFirstEligibleParent(this.orderedClientCollection.oldestClient));
376
376
  }
377
377
  serialize() {
378
- var _a, _b;
379
378
  return {
380
379
  electionSequenceNumber: this.electionSequenceNumber,
381
- electedClientId: (_a = this.electedClient) === null || _a === void 0 ? void 0 : _a.clientId,
382
- electedParentId: (_b = this.electedParent) === null || _b === void 0 ? void 0 : _b.clientId,
380
+ electedClientId: this.electedClient?.clientId,
381
+ electedParentId: this.electedParent?.clientId,
383
382
  };
384
383
  }
385
384
  }
@@ -1 +1 @@
1
- {"version":3,"file":"orderedClientElection.js","sourceRoot":"","sources":["../../src/summary/orderedClientElection.ts"],"names":[],"mappings":";;;AAMA,qEAAmF;AACnF,+DAAyE;AAEzE,qEAA6D;AAE7D,yEAAkE;AA6DlE;;;;;;GAMG;AACH,MAAa,uBACZ,SAAQ,gCAAiD;IAsBzD,YACC,MAA2B,EAC3B,YAAyE,EACzE,MAAiD;QAEjD,KAAK,EAAE,CAAC;QAxBT,kFAAkF;QACjE,cAAS,GAAG,IAAI,GAAG,EAAyB,CAAC;QAC9D,0EAA0E;QACzD,aAAQ,GAAkB;YAC1C,cAAc,EAAE,CAAC,CAAC;YAClB,WAAW,EAAE,SAAS;YACtB,aAAa,EAAE,SAAS;SACxB,CAAC;QACF,gEAAgE;QACxD,oBAAe,GAAa,IAAI,CAAC,QAAQ,CAAC;QAgBjD,IAAI,CAAC,MAAM,GAAG,6BAAW,CAAC,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;QACpE,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QACpC,KAAK,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,OAAO,EAAE;YACzC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;SACjC;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aAAa,CAAC,mCAChE,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,uBAAuB,CAAC,YAAY,CAAC,CACvE,CAAC;IACH,CAAC;IAEM,SAAS;;QACf,OAAO;YACN,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;YACnD,eAAe,EAAE,MAAA,IAAI,CAAC,aAAa,0CAAE,QAAQ;YAC7C,eAAe,EAAE,MAAA,IAAI,CAAC,aAAa,0CAAE,QAAQ;SAC7C,CAAC;IACH,CAAC;CACD;AA7RD,sDA6RC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/* eslint-disable @rushstack/no-new-null */\nimport { IEvent, IEventProvider } from \"@fluidframework/common-definitions\";\nimport { ITelemetryLoggerExt, ChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { IDeltaManager } from \"@fluidframework/container-definitions\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport { IClient, IQuorumClients, ISequencedClient } from \"@fluidframework/protocol-definitions\";\nimport { summarizerClientType } from \"./summarizerClientElection\";\n\n// helper types for recursive readonly.\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type ImmutablePrimitives = undefined | null | boolean | string | number | Function;\nexport type Immutable<T> = T extends ImmutablePrimitives\n\t? T\n\t: T extends (infer A)[]\n\t? readonly Immutable<A>[]\n\t: T extends Map<infer K, infer V>\n\t? ReadonlyMap<Immutable<K>, Immutable<V>>\n\t: T extends Set<infer V>\n\t? ReadonlySet<Immutable<V>>\n\t: { readonly [K in keyof T]: Immutable<T[K]> };\n\n/** Minimum information for a client tracked for election consideration. */\nexport interface ITrackedClient {\n\treadonly clientId: string;\n\treadonly sequenceNumber: number;\n\treadonly client: Immutable<IClient>;\n}\n\n/** Common contract for link nodes within an OrderedClientCollection. */\nexport interface ILinkNode {\n\treadonly sequenceNumber: number;\n\tyoungerClient: ILinkedClient | undefined;\n}\n\n/** Placeholder root node within an OrderedClientCollection; does not represent a client. */\nexport interface IRootLinkNode extends ILinkNode {\n\treadonly sequenceNumber: -1;\n\treadonly olderClient: undefined;\n}\n\n/** Additional information required to keep track of the client within the doubly-linked list. */\nexport interface ILinkedClient extends ILinkNode, ITrackedClient {\n\tolderClient: LinkNode;\n}\n\n/** Any link node within OrderedClientCollection including the placeholder root node. */\nexport type LinkNode = IRootLinkNode | ILinkedClient;\n\n/** Events raised by an OrderedClientCollection. */\nexport interface IOrderedClientCollectionEvents extends IEvent {\n\t/** Event fires when client is being added. */\n\t(\n\t\tevent: \"addClient\" | \"removeClient\",\n\t\tlistener: (client: ILinkedClient, sequenceNumber: number) => void,\n\t);\n}\n\n/** Contract for a sorted collection of all clients in the quorum. */\nexport interface IOrderedClientCollection extends IEventProvider<IOrderedClientCollectionEvents> {\n\t/** Count of clients in the collection. */\n\treadonly count: number;\n\t/** Pointer to the oldest client in the collection. */\n\treadonly oldestClient: ILinkedClient | undefined;\n\t/** Returns a sorted array of all the clients in the collection. */\n\tgetAllClients(): ILinkedClient[];\n}\n\n/**\n * Tracks clients in the Quorum. It maintains their order using their join op\n * sequence numbers.\n * Internally, the collection of clients is maintained in a doubly-linked list,\n * with pointers to both the first and last nodes.\n * The first (root) node is a placeholder to simplify logic and reduce null checking.\n */\nexport class OrderedClientCollection\n\textends TypedEventEmitter<IOrderedClientCollectionEvents>\n\timplements IOrderedClientCollection\n{\n\t/** Collection of ALL clients currently in the quorum, with client ids as keys. */\n\tprivate readonly clientMap = new Map<string, ILinkedClient>();\n\t/** Placeholder head node of linked list, for simplified null checking. */\n\tprivate readonly rootNode: IRootLinkNode = {\n\t\tsequenceNumber: -1,\n\t\tolderClient: undefined,\n\t\tyoungerClient: undefined,\n\t};\n\t/** Pointer to end of linked list, for optimized client adds. */\n\tprivate _youngestClient: LinkNode = this.rootNode;\n\tprivate readonly logger: ITelemetryLoggerExt;\n\n\tpublic get count() {\n\t\treturn this.clientMap.size;\n\t}\n\tpublic get oldestClient() {\n\t\treturn this.rootNode.youngerClient;\n\t}\n\n\tconstructor(\n\t\tlogger: ITelemetryLoggerExt,\n\t\tdeltaManager: Pick<IDeltaManager<unknown, unknown>, \"lastSequenceNumber\">,\n\t\tquorum: Pick<IQuorumClients, \"getMembers\" | \"on\">,\n\t) {\n\t\tsuper();\n\t\tthis.logger = ChildLogger.create(logger, \"OrderedClientCollection\");\n\t\tconst members = quorum.getMembers();\n\t\tfor (const [clientId, client] of members) {\n\t\t\tthis.addClient(clientId, client);\n\t\t}\n\n\t\tquorum.on(\"addMember\", (clientId, client) => {\n\t\t\tconst newClient = this.addClient(clientId, client);\n\t\t\tthis.emit(\"addClient\", newClient, deltaManager.lastSequenceNumber);\n\t\t});\n\t\tquorum.on(\"removeMember\", (clientId) => {\n\t\t\tconst sequenceNumber = deltaManager.lastSequenceNumber;\n\t\t\tconst removeClient = this.removeClient(clientId);\n\t\t\tif (removeClient === undefined) {\n\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"ClientNotFound\",\n\t\t\t\t\tclientId,\n\t\t\t\t\tsequenceNumber,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tthis.emit(\"removeClient\", removeClient, sequenceNumber);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate addClient(clientId: string, client: ISequencedClient): ITrackedClient {\n\t\t// Normal case is adding the latest client, which will bypass loop.\n\t\t// Find where it belongs otherwise (maybe possible during initial load?).\n\t\tassert(\n\t\t\tclient.sequenceNumber > -1,\n\t\t\t0x1f6 /* \"Negative client sequence number not allowed\" */,\n\t\t);\n\t\tlet currClient = this._youngestClient;\n\t\twhile (currClient.sequenceNumber > client.sequenceNumber) {\n\t\t\tassert(\n\t\t\t\tcurrClient.olderClient !== undefined,\n\t\t\t\t0x1f7 /* \"Previous client should always be defined\" */,\n\t\t\t);\n\t\t\t// Note: If adding a client older than the elected client, it will not be automatically elected.\n\t\t\tcurrClient = currClient.olderClient;\n\t\t}\n\n\t\t// Now currClient is the node right before where the new client node should be.\n\t\tconst newClient: ILinkedClient = {\n\t\t\tclientId,\n\t\t\tsequenceNumber: client.sequenceNumber,\n\t\t\tclient: { ...client.client }, // shallow clone\n\t\t\tolderClient: currClient,\n\t\t\tyoungerClient: currClient.youngerClient,\n\t\t};\n\n\t\t// Update prev node to point to this new node.\n\t\tnewClient.olderClient.youngerClient = newClient;\n\n\t\tif (newClient.youngerClient === undefined) {\n\t\t\t// Update linked list end pointer to youngest client.\n\t\t\tthis._youngestClient = newClient;\n\t\t} else {\n\t\t\t// Update next node to point back to this new node.\n\t\t\tnewClient.youngerClient.olderClient = newClient;\n\t\t}\n\n\t\tthis.clientMap.set(clientId, newClient);\n\t\treturn newClient;\n\t}\n\n\tprivate removeClient(clientId: string): ITrackedClient | undefined {\n\t\tconst removeClient = this.clientMap.get(clientId);\n\t\tif (removeClient === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Update prev node to point to next node.\n\t\tremoveClient.olderClient.youngerClient = removeClient.youngerClient;\n\n\t\tif (removeClient.youngerClient === undefined) {\n\t\t\t// Update linked list end pointer to youngest client.\n\t\t\tthis._youngestClient = removeClient.olderClient;\n\t\t} else {\n\t\t\t// Update next node to point back to previous node.\n\t\t\tremoveClient.youngerClient.olderClient = removeClient.olderClient;\n\t\t}\n\n\t\tthis.clientMap.delete(clientId);\n\t\treturn removeClient;\n\t}\n\n\t/** Returns an array of all clients being tracked in order from oldest to newest. */\n\tpublic getAllClients(): ILinkedClient[] {\n\t\tconst result: ILinkedClient[] = [];\n\t\tlet currClient: LinkNode = this.rootNode;\n\t\twhile (currClient.youngerClient !== undefined) {\n\t\t\tresult.push(currClient.youngerClient);\n\t\t\tcurrClient = currClient.youngerClient;\n\t\t}\n\t\treturn result;\n\t}\n}\n\n/** Events raised by an OrderedClientElection. */\nexport interface IOrderedClientElectionEvents extends IEvent {\n\t/** Event fires when the currently elected client changes. */\n\t(\n\t\tevent: \"election\",\n\t\tlistener: (\n\t\t\t/** Newly elected client. */\n\t\t\tclient: ITrackedClient | undefined,\n\t\t\t/** Sequence number where election took place. */\n\t\t\tsequenceNumber: number,\n\t\t\t/** Previously elected client. */\n\t\t\tprevClient: ITrackedClient | undefined,\n\t\t) => void,\n\t);\n}\n\n/** Serialized state of IOrderedClientElection. */\nexport interface ISerializedElection {\n\t/** Sequence number at the time of the latest election. */\n\treadonly electionSequenceNumber: number;\n\n\t/**\n\t * Most recently elected client id. This is either:\n\t *\n\t * 1. the interactive elected parent client, in which case electedClientId === electedParentId,\n\t * and the SummaryManager on the elected client will spawn a summarizer client, or\n\t *\n\t * 2. the non-interactive summarizer client itself.\n\t */\n\treadonly electedClientId: string | undefined;\n\n\t/** Most recently elected parent client id. This is always an interactive client. */\n\treadonly electedParentId: string | undefined;\n}\n\n/** Contract for maintaining a deterministic client election based on eligibility. */\nexport interface IOrderedClientElection extends IEventProvider<IOrderedClientElectionEvents> {\n\t/** Count of eligible clients in the collection. */\n\treadonly eligibleCount: number;\n\n\t/**\n\t * Currently elected client. This is either:\n\t *\n\t * 1. the interactive elected parent client, in which case electedClientId === electedParentId,\n\t * and the SummaryManager on the elected client will spawn a summarizer client, or\n\t *\n\t * 2. the non-interactive summarizer client itself.\n\t */\n\treadonly electedClient: ITrackedClient | undefined;\n\t/** Currently elected parent client. This is always an interactive client. */\n\treadonly electedParent: ITrackedClient | undefined;\n\t/** Sequence number of most recent election. */\n\treadonly electionSequenceNumber: number;\n\t/** Marks the currently elected client as invalid, and elects the next eligible client. */\n\tincrementElectedClient(sequenceNumber: number): void;\n\t/** Resets the currently elected client back to the oldest eligible client. */\n\tresetElectedClient(sequenceNumber: number): void;\n\t/** Peeks at what the next elected client would be if incrementElectedClient were called. */\n\tpeekNextElectedClient(): ITrackedClient | undefined;\n\t/** Returns a sorted array of all the eligible clients in the collection. */\n\tgetAllEligibleClients(): ITrackedClient[];\n\t/** Serialize election data */\n\tserialize(): ISerializedElection;\n}\n\n/**\n * Adapter for OrderedClientCollection, with the purpose of deterministically maintaining\n * a currently elected client, excluding ineligible clients, in a distributed fashion.\n * This can be true as long as incrementElectedClient and resetElectedClient calls\n * are called under the same conditions for all clients.\n */\nexport class OrderedClientElection\n\textends TypedEventEmitter<IOrderedClientElectionEvents>\n\timplements IOrderedClientElection\n{\n\tprivate _eligibleCount: number = 0;\n\tprivate _electedClient: ILinkedClient | undefined;\n\tprivate _electedParent: ILinkedClient | undefined;\n\tprivate _electionSequenceNumber: number;\n\n\tpublic get eligibleCount() {\n\t\treturn this._eligibleCount;\n\t}\n\tpublic get electionSequenceNumber() {\n\t\treturn this._electionSequenceNumber;\n\t}\n\n\t/**\n\t * OrderedClientCollection tracks electedClient and electedParent separately. This allows us to handle the case\n\t * where a new interactive parent client has been elected, but the summarizer is still doing work, so\n\t * a new summarizer should not yet be spawned. In this case, changing electedParent will cause SummaryManager\n\t * to stop the current summarizer, but a new summarizer will not be spawned until the old summarizer client has\n\t * left the quorum.\n\t *\n\t * Details:\n\t *\n\t * electedParent is the interactive client that has been elected to spawn a summarizer. It is typically the oldest\n\t * eligible interactive client in the quorum. Only the electedParent is permitted to spawn a summarizer.\n\t * Once elected, this client will remain the electedParent until it leaves the quorum or the summarizer that\n\t * it spawned stops producing summaries, at which point a new electedParent will be chosen.\n\t *\n\t * electedClient is the non-interactive summarizer client if one exists. If not, then electedClient is equal to\n\t * electedParent. If electedParent === electedClient, this is the signal for electedParent to spawn a new\n\t * electedClient. Once a summarizer client becomes electedClient, a new summarizer will not be spawned until\n\t * electedClient leaves the quorum.\n\t *\n\t * A typical sequence looks like this:\n\t *\n\t * i. Begin by electing A. electedParent === A, electedClient === A.\n\t *\n\t * ii. SummaryManager running on A spawns a summarizer client, A'. electedParent === A, electedClient === A'\n\t *\n\t * iii. A' stops producing summaries. A new parent client, B, is elected. electedParent === B, electedClient === A'\n\t *\n\t * iv. SummaryManager running on A detects the change to electedParent and tells the summarizer to stop, but A'\n\t * is in mid-summarization. No new summarizer is spawned, as electedParent !== electedClient.\n\t *\n\t * v. A' completes its summary, and the summarizer and backing client are torn down.\n\t *\n\t * vi. A' leaves the quorum, and B takes its place as electedClient. electedParent === B, electedClient === B\n\t *\n\t * vii. SummaryManager running on B spawns a summarizer client, B'. electedParent === B, electedClient === B'\n\t */\n\tpublic get electedClient() {\n\t\treturn this._electedClient;\n\t}\n\tpublic get electedParent() {\n\t\treturn this._electedParent;\n\t}\n\n\tconstructor(\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly orderedClientCollection: IOrderedClientCollection,\n\t\t/** Serialized state from summary or current sequence number at time of load if new. */\n\t\tinitialState: ISerializedElection | number,\n\t\tprivate readonly isEligibleFn: (c: ITrackedClient) => boolean,\n\t) {\n\t\tsuper();\n\t\tlet initialClient: ILinkedClient | undefined;\n\t\tlet initialParent: ILinkedClient | undefined;\n\t\tfor (const client of orderedClientCollection.getAllClients()) {\n\t\t\tthis.addClient(client, 0);\n\t\t\tif (typeof initialState !== \"number\") {\n\t\t\t\tif (client.clientId === initialState.electedClientId) {\n\t\t\t\t\tinitialClient = client;\n\t\t\t\t\tif (\n\t\t\t\t\t\tinitialState.electedParentId === undefined &&\n\t\t\t\t\t\tclient.client.details.type !== summarizerClientType\n\t\t\t\t\t) {\n\t\t\t\t\t\t// If there was no elected parent in the serialized data, use this one.\n\t\t\t\t\t\tinitialParent = client;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (client.clientId === initialState.electedParentId) {\n\t\t\t\t\tinitialParent = client;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\torderedClientCollection.on(\"addClient\", (client, seq) => this.addClient(client, seq));\n\t\torderedClientCollection.on(\"removeClient\", (client, seq) => this.removeClient(client, seq));\n\n\t\tif (typeof initialState === \"number\") {\n\t\t\tthis._electionSequenceNumber = initialState;\n\t\t} else {\n\t\t\t// Override the initially elected client with the initial state.\n\t\t\tif (initialClient?.clientId !== initialState.electedClientId) {\n\t\t\t\t// Cannot find initially elected client, so elect undefined.\n\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"InitialElectedClientNotFound\",\n\t\t\t\t\telectionSequenceNumber: initialState.electionSequenceNumber,\n\t\t\t\t\texpectedClientId: initialState.electedClientId,\n\t\t\t\t\telectedClientId: initialClient?.clientId,\n\t\t\t\t\tclientCount: orderedClientCollection.count,\n\t\t\t\t});\n\t\t\t} else if (initialClient !== undefined && !isEligibleFn(initialClient)) {\n\t\t\t\t// Initially elected client is ineligible, so elect next eligible client.\n\t\t\t\tinitialClient = initialParent = this.findFirstEligibleParent(initialParent);\n\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"InitialElectedClientIneligible\",\n\t\t\t\t\telectionSequenceNumber: initialState.electionSequenceNumber,\n\t\t\t\t\texpectedClientId: initialState.electedClientId,\n\t\t\t\t\telectedClientId: initialClient?.clientId,\n\t\t\t\t});\n\t\t\t}\n\t\t\tthis._electedParent = initialParent;\n\t\t\tthis._electedClient = initialClient;\n\t\t\tthis._electionSequenceNumber = initialState.electionSequenceNumber;\n\t\t}\n\t}\n\n\t/**\n\t * Tries changing the elected client, raising an event if it is different.\n\t * Note that this function does no eligibility or suitability checks. If we get here, then\n\t * we will set _electedClient, and we will set _electedParent if this is an interactive client.\n\t */\n\tprivate tryElectingClient(client: ILinkedClient | undefined, sequenceNumber: number): void {\n\t\tlet change = false;\n\t\tconst isSummarizerClient = client?.client.details.type === summarizerClientType;\n\t\tconst prevClient = this._electedClient;\n\t\tif (this._electedClient !== client) {\n\t\t\t// Changing the elected client. Record the sequence number and note that we have to fire an event.\n\t\t\tthis._electionSequenceNumber = sequenceNumber;\n\t\t\tthis._electedClient = client;\n\t\t\tchange = true;\n\t\t}\n\t\tif (this._electedParent !== client && !isSummarizerClient) {\n\t\t\t// Changing the elected parent as well.\n\t\t\tthis._electedParent = client;\n\t\t\tchange = true;\n\t\t}\n\t\tif (change) {\n\t\t\tthis.emit(\"election\", client, sequenceNumber, prevClient);\n\t\t}\n\t}\n\n\tprivate tryElectingParent(client: ILinkedClient | undefined, sequenceNumber: number): void {\n\t\tif (this._electedParent !== client) {\n\t\t\tthis._electedParent = client;\n\t\t\tthis.emit(\"election\", this._electedClient, sequenceNumber, this._electedClient);\n\t\t}\n\t}\n\n\t/**\n\t * Helper function to find the first eligible parent client starting with the passed in client,\n\t * or undefined if none are eligible.\n\t * @param client - client to start checking\n\t * @returns oldest eligible client starting with passed in client or undefined if none.\n\t */\n\tprivate findFirstEligibleParent(client: ILinkedClient | undefined): ILinkedClient | undefined {\n\t\tlet candidateClient = client;\n\t\twhile (\n\t\t\tcandidateClient !== undefined &&\n\t\t\t(!this.isEligibleFn(candidateClient) ||\n\t\t\t\tcandidateClient.client.details.type === summarizerClientType)\n\t\t) {\n\t\t\tcandidateClient = candidateClient.youngerClient;\n\t\t}\n\t\treturn candidateClient;\n\t}\n\n\t/**\n\t * Updates tracking for when a new client is added to the collection.\n\t * Will automatically elect that new client if none is elected currently.\n\t * @param client - client added to the collection\n\t * @param sequenceNumber - sequence number when client was added\n\t */\n\tprivate addClient(client: ILinkedClient, sequenceNumber: number): void {\n\t\tif (this.isEligibleFn(client)) {\n\t\t\tthis._eligibleCount++;\n\t\t\tconst newClientIsSummarizer = client.client.details.type === summarizerClientType;\n\t\t\tconst electedClientIsSummarizer =\n\t\t\t\tthis._electedClient?.client.details.type === summarizerClientType;\n\t\t\t// Note that we allow a summarizer client to supersede an interactive client as elected client.\n\t\t\tif (\n\t\t\t\tthis._electedClient === undefined ||\n\t\t\t\t(!electedClientIsSummarizer && newClientIsSummarizer)\n\t\t\t) {\n\t\t\t\tthis.tryElectingClient(client, sequenceNumber);\n\t\t\t} else if (this._electedParent === undefined && !newClientIsSummarizer) {\n\t\t\t\t// This is an odd case. If the _electedClient is set, the _electedParent should be as well.\n\t\t\t\tthis.tryElectingParent(client, sequenceNumber);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Updates tracking for when an existing client is removed from the collection.\n\t * Will automatically elect next oldest client if currently elected is removed.\n\t * @param client - client removed from the collection\n\t * @param sequenceNumber - sequence number when client was removed\n\t */\n\tprivate removeClient(client: ILinkedClient, sequenceNumber: number): void {\n\t\tif (this.isEligibleFn(client)) {\n\t\t\tthis._eligibleCount--;\n\t\t\tif (this._electedClient === client) {\n\t\t\t\t// Removing the _electedClient. There are 2 possible cases:\n\t\t\t\tif (this._electedParent !== client) {\n\t\t\t\t\t// 1. The _electedClient is a summarizer that we've been allowing to finish its work.\n\t\t\t\t\t// Let the _electedParent become the _electedClient so that it can start its own summarizer.\n\t\t\t\t\tif (this._electedClient.client.details.type !== summarizerClientType) {\n\t\t\t\t\t\tthrow new UsageError(\"Elected client should be a summarizer client 1\");\n\t\t\t\t\t}\n\t\t\t\t\tthis.tryElectingClient(this._electedParent, sequenceNumber);\n\t\t\t\t} else {\n\t\t\t\t\t// 2. The _electedClient is an interactive client that has left the quorum.\n\t\t\t\t\t// Automatically shift to next oldest client.\n\t\t\t\t\tconst nextClient =\n\t\t\t\t\t\tthis.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n\t\t\t\t\t\tthis.findFirstEligibleParent(this.orderedClientCollection.oldestClient);\n\t\t\t\t\tthis.tryElectingClient(nextClient, sequenceNumber);\n\t\t\t\t}\n\t\t\t} else if (this._electedParent === client) {\n\t\t\t\t// Removing the _electedParent (but not _electedClient).\n\t\t\t\t// Shift to the next oldest parent, but do not replace the _electedClient,\n\t\t\t\t// which is a summarizer that is still doing work.\n\t\t\t\tif (this._electedClient?.client.details.type !== summarizerClientType) {\n\t\t\t\t\tthrow new UsageError(\"Elected client should be a summarizer client 2\");\n\t\t\t\t}\n\t\t\t\tconst nextParent =\n\t\t\t\t\tthis.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n\t\t\t\t\tthis.findFirstEligibleParent(this.orderedClientCollection.oldestClient);\n\t\t\t\tthis.tryElectingParent(nextParent, sequenceNumber);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic getAllEligibleClients(): ITrackedClient[] {\n\t\treturn this.orderedClientCollection.getAllClients().filter(this.isEligibleFn);\n\t}\n\n\t/**\n\t * Advance election to the next-oldest client. This is called if the current parent is leaving the quorum,\n\t * or if the current summarizer is not responsive and we want to stop it and spawn a new one.\n\t */\n\tpublic incrementElectedClient(sequenceNumber: number): void {\n\t\tconst nextClient =\n\t\t\tthis.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n\t\t\tthis.findFirstEligibleParent(this.orderedClientCollection.oldestClient);\n\t\tif (this._electedClient === undefined || this._electedClient === this._electedParent) {\n\t\t\tthis.tryElectingClient(nextClient, sequenceNumber);\n\t\t} else {\n\t\t\t// The _electedClient is a summarizer and should not be replaced until it leaves the quorum.\n\t\t\t// Changing the _electedParent will stop the summarizer.\n\t\t\tthis.tryElectingParent(nextClient, sequenceNumber);\n\t\t}\n\t}\n\n\t/**\n\t * (Re-)start election with the oldest client in the quorum. This is called if we need to summarize\n\t * and no client has been elected.\n\t */\n\tpublic resetElectedClient(sequenceNumber: number): void {\n\t\tconst firstClient = this.findFirstEligibleParent(this.orderedClientCollection.oldestClient);\n\t\tif (this._electedClient === undefined || this._electedClient === this._electedParent) {\n\t\t\tthis.tryElectingClient(firstClient, sequenceNumber);\n\t\t} else {\n\t\t\t// The _electedClient is a summarizer and should not be replaced until it leaves the quorum.\n\t\t\t// Changing the _electedParent will stop the summarizer.\n\t\t\tthis.tryElectingParent(firstClient, sequenceNumber);\n\t\t}\n\t}\n\n\tpublic peekNextElectedClient(): ITrackedClient | undefined {\n\t\treturn (\n\t\t\tthis.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n\t\t\tthis.findFirstEligibleParent(this.orderedClientCollection.oldestClient)\n\t\t);\n\t}\n\n\tpublic serialize(): ISerializedElection {\n\t\treturn {\n\t\t\telectionSequenceNumber: this.electionSequenceNumber,\n\t\t\telectedClientId: this.electedClient?.clientId,\n\t\t\telectedParentId: this.electedParent?.clientId,\n\t\t};\n\t}\n}\n"]}
1
+ {"version":3,"file":"orderedClientElection.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4F;YAC5F,wDAAwD;YACxD,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;SACnD;IACF,CAAC;IAED;;;OAGG;IACI,kBAAkB,CAAC,cAAsB;QAC/C,MAAM,WAAW,GAAG,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAC;QAC5F,IAAI,IAAI,CAAC,cAAc,KAAK,SAAS,IAAI,IAAI,CAAC,cAAc,KAAK,IAAI,CAAC,cAAc,EAAE;YACrF,IAAI,CAAC,iBAAiB,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;SACpD;aAAM;YACN,4FAA4F;YAC5F,wDAAwD;YACxD,IAAI,CAAC,iBAAiB,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;SACpD;IACF,CAAC;IAEM,qBAAqB;QAC3B,OAAO,CACN,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,cAAc,EAAE,aAAa,CAAC;YAChE,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,uBAAuB,CAAC,YAAY,CAAC,CACvE,CAAC;IACH,CAAC;IAEM,SAAS;QACf,OAAO;YACN,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;YACnD,eAAe,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ;YAC7C,eAAe,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ;SAC7C,CAAC;IACH,CAAC;CACD;AA7RD,sDA6RC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/* eslint-disable @rushstack/no-new-null */\nimport { IEvent, IEventProvider, ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport {\n\tITelemetryLoggerExt,\n\tcreateChildLogger,\n\tUsageError,\n} from \"@fluidframework/telemetry-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { IDeltaManager } from \"@fluidframework/container-definitions\";\nimport { IClient, IQuorumClients, ISequencedClient } from \"@fluidframework/protocol-definitions\";\nimport { summarizerClientType } from \"./summarizerClientElection\";\n\n// helper types for recursive readonly.\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type ImmutablePrimitives = undefined | null | boolean | string | number | Function;\nexport type Immutable<T> = T extends ImmutablePrimitives\n\t? T\n\t: T extends (infer A)[]\n\t? readonly Immutable<A>[]\n\t: T extends Map<infer K, infer V>\n\t? ReadonlyMap<Immutable<K>, Immutable<V>>\n\t: T extends Set<infer V>\n\t? ReadonlySet<Immutable<V>>\n\t: { readonly [K in keyof T]: Immutable<T[K]> };\n\n/** Minimum information for a client tracked for election consideration. */\nexport interface ITrackedClient {\n\treadonly clientId: string;\n\treadonly sequenceNumber: number;\n\treadonly client: Immutable<IClient>;\n}\n\n/** Common contract for link nodes within an OrderedClientCollection. */\nexport interface ILinkNode {\n\treadonly sequenceNumber: number;\n\tyoungerClient: ILinkedClient | undefined;\n}\n\n/** Placeholder root node within an OrderedClientCollection; does not represent a client. */\nexport interface IRootLinkNode extends ILinkNode {\n\treadonly sequenceNumber: -1;\n\treadonly olderClient: undefined;\n}\n\n/** Additional information required to keep track of the client within the doubly-linked list. */\nexport interface ILinkedClient extends ILinkNode, ITrackedClient {\n\tolderClient: LinkNode;\n}\n\n/** Any link node within OrderedClientCollection including the placeholder root node. */\nexport type LinkNode = IRootLinkNode | ILinkedClient;\n\n/** Events raised by an OrderedClientCollection. */\nexport interface IOrderedClientCollectionEvents extends IEvent {\n\t/** Event fires when client is being added. */\n\t(\n\t\tevent: \"addClient\" | \"removeClient\",\n\t\tlistener: (client: ILinkedClient, sequenceNumber: number) => void,\n\t);\n}\n\n/** Contract for a sorted collection of all clients in the quorum. */\nexport interface IOrderedClientCollection extends IEventProvider<IOrderedClientCollectionEvents> {\n\t/** Count of clients in the collection. */\n\treadonly count: number;\n\t/** Pointer to the oldest client in the collection. */\n\treadonly oldestClient: ILinkedClient | undefined;\n\t/** Returns a sorted array of all the clients in the collection. */\n\tgetAllClients(): ILinkedClient[];\n}\n\n/**\n * Tracks clients in the Quorum. It maintains their order using their join op\n * sequence numbers.\n * Internally, the collection of clients is maintained in a doubly-linked list,\n * with pointers to both the first and last nodes.\n * The first (root) node is a placeholder to simplify logic and reduce null checking.\n */\nexport class OrderedClientCollection\n\textends TypedEventEmitter<IOrderedClientCollectionEvents>\n\timplements IOrderedClientCollection\n{\n\t/** Collection of ALL clients currently in the quorum, with client ids as keys. */\n\tprivate readonly clientMap = new Map<string, ILinkedClient>();\n\t/** Placeholder head node of linked list, for simplified null checking. */\n\tprivate readonly rootNode: IRootLinkNode = {\n\t\tsequenceNumber: -1,\n\t\tolderClient: undefined,\n\t\tyoungerClient: undefined,\n\t};\n\t/** Pointer to end of linked list, for optimized client adds. */\n\tprivate _youngestClient: LinkNode = this.rootNode;\n\tprivate readonly logger: ITelemetryLoggerExt;\n\n\tpublic get count() {\n\t\treturn this.clientMap.size;\n\t}\n\tpublic get oldestClient() {\n\t\treturn this.rootNode.youngerClient;\n\t}\n\n\tconstructor(\n\t\tlogger: ITelemetryBaseLogger,\n\t\tdeltaManager: Pick<IDeltaManager<unknown, unknown>, \"lastSequenceNumber\">,\n\t\tquorum: Pick<IQuorumClients, \"getMembers\" | \"on\">,\n\t) {\n\t\tsuper();\n\t\tthis.logger = createChildLogger({ logger, namespace: \"OrderedClientCollection\" });\n\t\tconst members = quorum.getMembers();\n\t\tfor (const [clientId, client] of members) {\n\t\t\tthis.addClient(clientId, client);\n\t\t}\n\n\t\tquorum.on(\"addMember\", (clientId, client) => {\n\t\t\tconst newClient = this.addClient(clientId, client);\n\t\t\tthis.emit(\"addClient\", newClient, deltaManager.lastSequenceNumber);\n\t\t});\n\t\tquorum.on(\"removeMember\", (clientId) => {\n\t\t\tconst sequenceNumber = deltaManager.lastSequenceNumber;\n\t\t\tconst removeClient = this.removeClient(clientId);\n\t\t\tif (removeClient === undefined) {\n\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"ClientNotFound\",\n\t\t\t\t\tclientId,\n\t\t\t\t\tsequenceNumber,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tthis.emit(\"removeClient\", removeClient, sequenceNumber);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate addClient(clientId: string, client: ISequencedClient): ITrackedClient {\n\t\t// Normal case is adding the latest client, which will bypass loop.\n\t\t// Find where it belongs otherwise (maybe possible during initial load?).\n\t\tassert(\n\t\t\tclient.sequenceNumber > -1,\n\t\t\t0x1f6 /* \"Negative client sequence number not allowed\" */,\n\t\t);\n\t\tlet currClient = this._youngestClient;\n\t\twhile (currClient.sequenceNumber > client.sequenceNumber) {\n\t\t\tassert(\n\t\t\t\tcurrClient.olderClient !== undefined,\n\t\t\t\t0x1f7 /* \"Previous client should always be defined\" */,\n\t\t\t);\n\t\t\t// Note: If adding a client older than the elected client, it will not be automatically elected.\n\t\t\tcurrClient = currClient.olderClient;\n\t\t}\n\n\t\t// Now currClient is the node right before where the new client node should be.\n\t\tconst newClient: ILinkedClient = {\n\t\t\tclientId,\n\t\t\tsequenceNumber: client.sequenceNumber,\n\t\t\tclient: { ...client.client }, // shallow clone\n\t\t\tolderClient: currClient,\n\t\t\tyoungerClient: currClient.youngerClient,\n\t\t};\n\n\t\t// Update prev node to point to this new node.\n\t\tnewClient.olderClient.youngerClient = newClient;\n\n\t\tif (newClient.youngerClient === undefined) {\n\t\t\t// Update linked list end pointer to youngest client.\n\t\t\tthis._youngestClient = newClient;\n\t\t} else {\n\t\t\t// Update next node to point back to this new node.\n\t\t\tnewClient.youngerClient.olderClient = newClient;\n\t\t}\n\n\t\tthis.clientMap.set(clientId, newClient);\n\t\treturn newClient;\n\t}\n\n\tprivate removeClient(clientId: string): ITrackedClient | undefined {\n\t\tconst removeClient = this.clientMap.get(clientId);\n\t\tif (removeClient === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Update prev node to point to next node.\n\t\tremoveClient.olderClient.youngerClient = removeClient.youngerClient;\n\n\t\tif (removeClient.youngerClient === undefined) {\n\t\t\t// Update linked list end pointer to youngest client.\n\t\t\tthis._youngestClient = removeClient.olderClient;\n\t\t} else {\n\t\t\t// Update next node to point back to previous node.\n\t\t\tremoveClient.youngerClient.olderClient = removeClient.olderClient;\n\t\t}\n\n\t\tthis.clientMap.delete(clientId);\n\t\treturn removeClient;\n\t}\n\n\t/** Returns an array of all clients being tracked in order from oldest to newest. */\n\tpublic getAllClients(): ILinkedClient[] {\n\t\tconst result: ILinkedClient[] = [];\n\t\tlet currClient: LinkNode = this.rootNode;\n\t\twhile (currClient.youngerClient !== undefined) {\n\t\t\tresult.push(currClient.youngerClient);\n\t\t\tcurrClient = currClient.youngerClient;\n\t\t}\n\t\treturn result;\n\t}\n}\n\n/** Events raised by an OrderedClientElection. */\nexport interface IOrderedClientElectionEvents extends IEvent {\n\t/** Event fires when the currently elected client changes. */\n\t(\n\t\tevent: \"election\",\n\t\tlistener: (\n\t\t\t/** Newly elected client. */\n\t\t\tclient: ITrackedClient | undefined,\n\t\t\t/** Sequence number where election took place. */\n\t\t\tsequenceNumber: number,\n\t\t\t/** Previously elected client. */\n\t\t\tprevClient: ITrackedClient | undefined,\n\t\t) => void,\n\t);\n}\n\n/** Serialized state of IOrderedClientElection. */\nexport interface ISerializedElection {\n\t/** Sequence number at the time of the latest election. */\n\treadonly electionSequenceNumber: number;\n\n\t/**\n\t * Most recently elected client id. This is either:\n\t *\n\t * 1. the interactive elected parent client, in which case electedClientId === electedParentId,\n\t * and the SummaryManager on the elected client will spawn a summarizer client, or\n\t *\n\t * 2. the non-interactive summarizer client itself.\n\t */\n\treadonly electedClientId: string | undefined;\n\n\t/** Most recently elected parent client id. This is always an interactive client. */\n\treadonly electedParentId: string | undefined;\n}\n\n/** Contract for maintaining a deterministic client election based on eligibility. */\nexport interface IOrderedClientElection extends IEventProvider<IOrderedClientElectionEvents> {\n\t/** Count of eligible clients in the collection. */\n\treadonly eligibleCount: number;\n\n\t/**\n\t * Currently elected client. This is either:\n\t *\n\t * 1. the interactive elected parent client, in which case electedClientId === electedParentId,\n\t * and the SummaryManager on the elected client will spawn a summarizer client, or\n\t *\n\t * 2. the non-interactive summarizer client itself.\n\t */\n\treadonly electedClient: ITrackedClient | undefined;\n\t/** Currently elected parent client. This is always an interactive client. */\n\treadonly electedParent: ITrackedClient | undefined;\n\t/** Sequence number of most recent election. */\n\treadonly electionSequenceNumber: number;\n\t/** Marks the currently elected client as invalid, and elects the next eligible client. */\n\tincrementElectedClient(sequenceNumber: number): void;\n\t/** Resets the currently elected client back to the oldest eligible client. */\n\tresetElectedClient(sequenceNumber: number): void;\n\t/** Peeks at what the next elected client would be if incrementElectedClient were called. */\n\tpeekNextElectedClient(): ITrackedClient | undefined;\n\t/** Returns a sorted array of all the eligible clients in the collection. */\n\tgetAllEligibleClients(): ITrackedClient[];\n\t/** Serialize election data */\n\tserialize(): ISerializedElection;\n}\n\n/**\n * Adapter for OrderedClientCollection, with the purpose of deterministically maintaining\n * a currently elected client, excluding ineligible clients, in a distributed fashion.\n * This can be true as long as incrementElectedClient and resetElectedClient calls\n * are called under the same conditions for all clients.\n */\nexport class OrderedClientElection\n\textends TypedEventEmitter<IOrderedClientElectionEvents>\n\timplements IOrderedClientElection\n{\n\tprivate _eligibleCount: number = 0;\n\tprivate _electedClient: ILinkedClient | undefined;\n\tprivate _electedParent: ILinkedClient | undefined;\n\tprivate _electionSequenceNumber: number;\n\n\tpublic get eligibleCount() {\n\t\treturn this._eligibleCount;\n\t}\n\tpublic get electionSequenceNumber() {\n\t\treturn this._electionSequenceNumber;\n\t}\n\n\t/**\n\t * OrderedClientCollection tracks electedClient and electedParent separately. This allows us to handle the case\n\t * where a new interactive parent client has been elected, but the summarizer is still doing work, so\n\t * a new summarizer should not yet be spawned. In this case, changing electedParent will cause SummaryManager\n\t * to stop the current summarizer, but a new summarizer will not be spawned until the old summarizer client has\n\t * left the quorum.\n\t *\n\t * Details:\n\t *\n\t * electedParent is the interactive client that has been elected to spawn a summarizer. It is typically the oldest\n\t * eligible interactive client in the quorum. Only the electedParent is permitted to spawn a summarizer.\n\t * Once elected, this client will remain the electedParent until it leaves the quorum or the summarizer that\n\t * it spawned stops producing summaries, at which point a new electedParent will be chosen.\n\t *\n\t * electedClient is the non-interactive summarizer client if one exists. If not, then electedClient is equal to\n\t * electedParent. If electedParent === electedClient, this is the signal for electedParent to spawn a new\n\t * electedClient. Once a summarizer client becomes electedClient, a new summarizer will not be spawned until\n\t * electedClient leaves the quorum.\n\t *\n\t * A typical sequence looks like this:\n\t *\n\t * i. Begin by electing A. electedParent === A, electedClient === A.\n\t *\n\t * ii. SummaryManager running on A spawns a summarizer client, A'. electedParent === A, electedClient === A'\n\t *\n\t * iii. A' stops producing summaries. A new parent client, B, is elected. electedParent === B, electedClient === A'\n\t *\n\t * iv. SummaryManager running on A detects the change to electedParent and tells the summarizer to stop, but A'\n\t * is in mid-summarization. No new summarizer is spawned, as electedParent !== electedClient.\n\t *\n\t * v. A' completes its summary, and the summarizer and backing client are torn down.\n\t *\n\t * vi. A' leaves the quorum, and B takes its place as electedClient. electedParent === B, electedClient === B\n\t *\n\t * vii. SummaryManager running on B spawns a summarizer client, B'. electedParent === B, electedClient === B'\n\t */\n\tpublic get electedClient() {\n\t\treturn this._electedClient;\n\t}\n\tpublic get electedParent() {\n\t\treturn this._electedParent;\n\t}\n\n\tconstructor(\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly orderedClientCollection: IOrderedClientCollection,\n\t\t/** Serialized state from summary or current sequence number at time of load if new. */\n\t\tinitialState: ISerializedElection | number,\n\t\tprivate readonly isEligibleFn: (c: ITrackedClient) => boolean,\n\t) {\n\t\tsuper();\n\t\tlet initialClient: ILinkedClient | undefined;\n\t\tlet initialParent: ILinkedClient | undefined;\n\t\tfor (const client of orderedClientCollection.getAllClients()) {\n\t\t\tthis.addClient(client, 0);\n\t\t\tif (typeof initialState !== \"number\") {\n\t\t\t\tif (client.clientId === initialState.electedClientId) {\n\t\t\t\t\tinitialClient = client;\n\t\t\t\t\tif (\n\t\t\t\t\t\tinitialState.electedParentId === undefined &&\n\t\t\t\t\t\tclient.client.details.type !== summarizerClientType\n\t\t\t\t\t) {\n\t\t\t\t\t\t// If there was no elected parent in the serialized data, use this one.\n\t\t\t\t\t\tinitialParent = client;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (client.clientId === initialState.electedParentId) {\n\t\t\t\t\tinitialParent = client;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\torderedClientCollection.on(\"addClient\", (client, seq) => this.addClient(client, seq));\n\t\torderedClientCollection.on(\"removeClient\", (client, seq) => this.removeClient(client, seq));\n\n\t\tif (typeof initialState === \"number\") {\n\t\t\tthis._electionSequenceNumber = initialState;\n\t\t} else {\n\t\t\t// Override the initially elected client with the initial state.\n\t\t\tif (initialClient?.clientId !== initialState.electedClientId) {\n\t\t\t\t// Cannot find initially elected client, so elect undefined.\n\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"InitialElectedClientNotFound\",\n\t\t\t\t\telectionSequenceNumber: initialState.electionSequenceNumber,\n\t\t\t\t\texpectedClientId: initialState.electedClientId,\n\t\t\t\t\telectedClientId: initialClient?.clientId,\n\t\t\t\t\tclientCount: orderedClientCollection.count,\n\t\t\t\t});\n\t\t\t} else if (initialClient !== undefined && !isEligibleFn(initialClient)) {\n\t\t\t\t// Initially elected client is ineligible, so elect next eligible client.\n\t\t\t\tinitialClient = initialParent = this.findFirstEligibleParent(initialParent);\n\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"InitialElectedClientIneligible\",\n\t\t\t\t\telectionSequenceNumber: initialState.electionSequenceNumber,\n\t\t\t\t\texpectedClientId: initialState.electedClientId,\n\t\t\t\t\telectedClientId: initialClient?.clientId,\n\t\t\t\t});\n\t\t\t}\n\t\t\tthis._electedParent = initialParent;\n\t\t\tthis._electedClient = initialClient;\n\t\t\tthis._electionSequenceNumber = initialState.electionSequenceNumber;\n\t\t}\n\t}\n\n\t/**\n\t * Tries changing the elected client, raising an event if it is different.\n\t * Note that this function does no eligibility or suitability checks. If we get here, then\n\t * we will set _electedClient, and we will set _electedParent if this is an interactive client.\n\t */\n\tprivate tryElectingClient(client: ILinkedClient | undefined, sequenceNumber: number): void {\n\t\tlet change = false;\n\t\tconst isSummarizerClient = client?.client.details.type === summarizerClientType;\n\t\tconst prevClient = this._electedClient;\n\t\tif (this._electedClient !== client) {\n\t\t\t// Changing the elected client. Record the sequence number and note that we have to fire an event.\n\t\t\tthis._electionSequenceNumber = sequenceNumber;\n\t\t\tthis._electedClient = client;\n\t\t\tchange = true;\n\t\t}\n\t\tif (this._electedParent !== client && !isSummarizerClient) {\n\t\t\t// Changing the elected parent as well.\n\t\t\tthis._electedParent = client;\n\t\t\tchange = true;\n\t\t}\n\t\tif (change) {\n\t\t\tthis.emit(\"election\", client, sequenceNumber, prevClient);\n\t\t}\n\t}\n\n\tprivate tryElectingParent(client: ILinkedClient | undefined, sequenceNumber: number): void {\n\t\tif (this._electedParent !== client) {\n\t\t\tthis._electedParent = client;\n\t\t\tthis.emit(\"election\", this._electedClient, sequenceNumber, this._electedClient);\n\t\t}\n\t}\n\n\t/**\n\t * Helper function to find the first eligible parent client starting with the passed in client,\n\t * or undefined if none are eligible.\n\t * @param client - client to start checking\n\t * @returns oldest eligible client starting with passed in client or undefined if none.\n\t */\n\tprivate findFirstEligibleParent(client: ILinkedClient | undefined): ILinkedClient | undefined {\n\t\tlet candidateClient = client;\n\t\twhile (\n\t\t\tcandidateClient !== undefined &&\n\t\t\t(!this.isEligibleFn(candidateClient) ||\n\t\t\t\tcandidateClient.client.details.type === summarizerClientType)\n\t\t) {\n\t\t\tcandidateClient = candidateClient.youngerClient;\n\t\t}\n\t\treturn candidateClient;\n\t}\n\n\t/**\n\t * Updates tracking for when a new client is added to the collection.\n\t * Will automatically elect that new client if none is elected currently.\n\t * @param client - client added to the collection\n\t * @param sequenceNumber - sequence number when client was added\n\t */\n\tprivate addClient(client: ILinkedClient, sequenceNumber: number): void {\n\t\tif (this.isEligibleFn(client)) {\n\t\t\tthis._eligibleCount++;\n\t\t\tconst newClientIsSummarizer = client.client.details.type === summarizerClientType;\n\t\t\tconst electedClientIsSummarizer =\n\t\t\t\tthis._electedClient?.client.details.type === summarizerClientType;\n\t\t\t// Note that we allow a summarizer client to supersede an interactive client as elected client.\n\t\t\tif (\n\t\t\t\tthis._electedClient === undefined ||\n\t\t\t\t(!electedClientIsSummarizer && newClientIsSummarizer)\n\t\t\t) {\n\t\t\t\tthis.tryElectingClient(client, sequenceNumber);\n\t\t\t} else if (this._electedParent === undefined && !newClientIsSummarizer) {\n\t\t\t\t// This is an odd case. If the _electedClient is set, the _electedParent should be as well.\n\t\t\t\tthis.tryElectingParent(client, sequenceNumber);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Updates tracking for when an existing client is removed from the collection.\n\t * Will automatically elect next oldest client if currently elected is removed.\n\t * @param client - client removed from the collection\n\t * @param sequenceNumber - sequence number when client was removed\n\t */\n\tprivate removeClient(client: ILinkedClient, sequenceNumber: number): void {\n\t\tif (this.isEligibleFn(client)) {\n\t\t\tthis._eligibleCount--;\n\t\t\tif (this._electedClient === client) {\n\t\t\t\t// Removing the _electedClient. There are 2 possible cases:\n\t\t\t\tif (this._electedParent !== client) {\n\t\t\t\t\t// 1. The _electedClient is a summarizer that we've been allowing to finish its work.\n\t\t\t\t\t// Let the _electedParent become the _electedClient so that it can start its own summarizer.\n\t\t\t\t\tif (this._electedClient.client.details.type !== summarizerClientType) {\n\t\t\t\t\t\tthrow new UsageError(\"Elected client should be a summarizer client 1\");\n\t\t\t\t\t}\n\t\t\t\t\tthis.tryElectingClient(this._electedParent, sequenceNumber);\n\t\t\t\t} else {\n\t\t\t\t\t// 2. The _electedClient is an interactive client that has left the quorum.\n\t\t\t\t\t// Automatically shift to next oldest client.\n\t\t\t\t\tconst nextClient =\n\t\t\t\t\t\tthis.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n\t\t\t\t\t\tthis.findFirstEligibleParent(this.orderedClientCollection.oldestClient);\n\t\t\t\t\tthis.tryElectingClient(nextClient, sequenceNumber);\n\t\t\t\t}\n\t\t\t} else if (this._electedParent === client) {\n\t\t\t\t// Removing the _electedParent (but not _electedClient).\n\t\t\t\t// Shift to the next oldest parent, but do not replace the _electedClient,\n\t\t\t\t// which is a summarizer that is still doing work.\n\t\t\t\tif (this._electedClient?.client.details.type !== summarizerClientType) {\n\t\t\t\t\tthrow new UsageError(\"Elected client should be a summarizer client 2\");\n\t\t\t\t}\n\t\t\t\tconst nextParent =\n\t\t\t\t\tthis.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n\t\t\t\t\tthis.findFirstEligibleParent(this.orderedClientCollection.oldestClient);\n\t\t\t\tthis.tryElectingParent(nextParent, sequenceNumber);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic getAllEligibleClients(): ITrackedClient[] {\n\t\treturn this.orderedClientCollection.getAllClients().filter(this.isEligibleFn);\n\t}\n\n\t/**\n\t * Advance election to the next-oldest client. This is called if the current parent is leaving the quorum,\n\t * or if the current summarizer is not responsive and we want to stop it and spawn a new one.\n\t */\n\tpublic incrementElectedClient(sequenceNumber: number): void {\n\t\tconst nextClient =\n\t\t\tthis.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n\t\t\tthis.findFirstEligibleParent(this.orderedClientCollection.oldestClient);\n\t\tif (this._electedClient === undefined || this._electedClient === this._electedParent) {\n\t\t\tthis.tryElectingClient(nextClient, sequenceNumber);\n\t\t} else {\n\t\t\t// The _electedClient is a summarizer and should not be replaced until it leaves the quorum.\n\t\t\t// Changing the _electedParent will stop the summarizer.\n\t\t\tthis.tryElectingParent(nextClient, sequenceNumber);\n\t\t}\n\t}\n\n\t/**\n\t * (Re-)start election with the oldest client in the quorum. This is called if we need to summarize\n\t * and no client has been elected.\n\t */\n\tpublic resetElectedClient(sequenceNumber: number): void {\n\t\tconst firstClient = this.findFirstEligibleParent(this.orderedClientCollection.oldestClient);\n\t\tif (this._electedClient === undefined || this._electedClient === this._electedParent) {\n\t\t\tthis.tryElectingClient(firstClient, sequenceNumber);\n\t\t} else {\n\t\t\t// The _electedClient is a summarizer and should not be replaced until it leaves the quorum.\n\t\t\t// Changing the _electedParent will stop the summarizer.\n\t\t\tthis.tryElectingParent(firstClient, sequenceNumber);\n\t\t}\n\t}\n\n\tpublic peekNextElectedClient(): ITrackedClient | undefined {\n\t\treturn (\n\t\t\tthis.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n\t\t\tthis.findFirstEligibleParent(this.orderedClientCollection.oldestClient)\n\t\t);\n\t}\n\n\tpublic serialize(): ISerializedElection {\n\t\treturn {\n\t\t\telectionSequenceNumber: this.electionSequenceNumber,\n\t\t\telectedClientId: this.electedClient?.clientId,\n\t\t\telectedParentId: this.electedParent?.clientId,\n\t\t};\n\t}\n}\n"]}
@@ -5,7 +5,7 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.RunWhileConnectedCoordinator = exports.neverCancelledSummaryToken = void 0;
8
- const common_utils_1 = require("@fluidframework/common-utils");
8
+ const core_utils_1 = require("@fluidframework/core-utils");
9
9
  /**
10
10
  * Can be useful in testing as well as in places where caller does not use cancellation.
11
11
  * This object implements ISummaryCancellationToken interface but cancellation is never leveraged.
@@ -24,11 +24,11 @@ class RunWhileConnectedCoordinator {
24
24
  this.runtime = runtime;
25
25
  this.active = active;
26
26
  this._cancelled = false;
27
- this.stopDeferred = new common_utils_1.Deferred();
27
+ this.stopDeferred = new core_utils_1.Deferred();
28
28
  }
29
29
  get cancelled() {
30
30
  if (!this._cancelled) {
31
- (0, common_utils_1.assert)(this.active(), 0x25d /* "We should never connect as 'read'" */);
31
+ (0, core_utils_1.assert)(this.active(), 0x25d /* "We should never connect as 'read'" */);
32
32
  // This check can't be enabled in current design due to lastSummary flow, where
33
33
  // summarizer for closed container stays around and can produce one more summary.
34
34
  // Currently we solve the problem of overlapping summarizer by doing wait in
@@ -1 +1 @@
1
- {"version":3,"file":"runWhileConnectedCoordinator.js","sourceRoot":"","sources":["../../src/summary/runWhileConnectedCoordinator.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAgE;AAYhE;;;GAGG;AACU,QAAA,0BAA0B,GAA8B;IACpE,SAAS,EAAE,KAAK;IAChB,aAAa,EAAE,IAAI,OAAO,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;CACpC,CAAC;AAEF;;;;GAIG;AACH,MAAa,4BAA4B;IAqCxC,YACkB,OAA4B,EAC5B,MAAqB;QADrB,YAAO,GAAP,OAAO,CAAqB;QAC5B,WAAM,GAAN,MAAM,CAAe;QAtC/B,eAAU,GAAG,KAAK,CAAC;QACV,iBAAY,GAAG,IAAI,uBAAQ,EAAwB,CAAC;IAsClE,CAAC;IApCJ,IAAW,SAAS;QACnB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACrB,IAAA,qBAAM,EAAC,IAAI,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,yCAAyC,CAAC,CAAC;YAEvE,+EAA+E;YAC/E,iFAAiF;YACjF,4EAA4E;YAC5E,oCAAoC;YACpC,6CAA6C;YAC7C,mGAAmG;YACnG,yBAAyB;YACzB,oFAAoF;YACpF,EAAE;YACF,wEAAwE;YACxE,uFAAuF;SACvF;QAED,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,aAAa;QACvB,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;IAClC,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAA4B,EAAE,MAAqB;QAC7E,MAAM,GAAG,GAAG,IAAI,4BAA4B,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC9D,MAAM,GAAG,CAAC,SAAS,EAAE,CAAC;QACtB,OAAO,GAAG,CAAC;IACZ,CAAC;IAOD;;;;;;;;;;;;OAYG;IACO,KAAK,CAAC,SAAS;QACxB,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;YAC1B,IAAI,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;YAC1C,OAAO;SACP;QAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;QAE9E,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE;YAC5B,MAAM,aAAa,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CACnD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CACvC,CAAC;YACF,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;SACxD;QACD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACpF,CAAC;IAED;;OAEG;IACI,IAAI,CAAC,MAA4B;QACvC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACrB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;SAClC;IACF,CAAC;CACD;AAjFD,oEAiFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Deferred } from \"@fluidframework/common-utils\";\nimport {\n\tSummarizerStopReason,\n\tIConnectableRuntime,\n\tISummaryCancellationToken,\n} from \"./summarizerTypes\";\n\n/* Similar to AbortController, but using promise instead of events */\nexport interface ICancellableSummarizerController extends ISummaryCancellationToken {\n\tstop(reason: SummarizerStopReason): void;\n}\n\n/**\n * Can be useful in testing as well as in places where caller does not use cancellation.\n * This object implements ISummaryCancellationToken interface but cancellation is never leveraged.\n */\nexport const neverCancelledSummaryToken: ISummaryCancellationToken = {\n\tcancelled: false,\n\twaitCancelled: new Promise(() => {}),\n};\n\n/**\n * Helper class to coordinate something that needs to run only while connected.\n * This provides promises that resolve as it starts or stops. Stopping happens\n * when disconnected or if stop() is called.\n */\nexport class RunWhileConnectedCoordinator implements ICancellableSummarizerController {\n\tprivate _cancelled = false;\n\tprivate readonly stopDeferred = new Deferred<SummarizerStopReason>();\n\n\tpublic get cancelled() {\n\t\tif (!this._cancelled) {\n\t\t\tassert(this.active(), 0x25d /* \"We should never connect as 'read'\" */);\n\n\t\t\t// This check can't be enabled in current design due to lastSummary flow, where\n\t\t\t// summarizer for closed container stays around and can produce one more summary.\n\t\t\t// Currently we solve the problem of overlapping summarizer by doing wait in\n\t\t\t// SummaryManager.createSummarizer()\n\t\t\t// Better solution would involve these steps:\n\t\t\t// 1. Summarizer selection logic should chose summarizing client (with clientType === \"summarizer\")\n\t\t\t// if such client exists.\n\t\t\t// 2. Summarizer should be updated about such changes (to update onBehalfOfClientId)\n\t\t\t//\n\t\t\t// assert(this.runtime.summarizerClientId === this.onBehalfOfClientId ||\n\t\t\t// this.runtime.summarizerClientId === this.runtime.clientId, \"onBehalfOfClientId\");\n\t\t}\n\n\t\treturn this._cancelled;\n\t}\n\n\t/**\n\t * Returns a promise that resolves once stopped either externally or by disconnect.\n\t */\n\tpublic get waitCancelled(): Promise<SummarizerStopReason> {\n\t\treturn this.stopDeferred.promise;\n\t}\n\n\tpublic static async create(runtime: IConnectableRuntime, active: () => boolean) {\n\t\tconst obj = new RunWhileConnectedCoordinator(runtime, active);\n\t\tawait obj.waitStart();\n\t\treturn obj;\n\t}\n\n\tprotected constructor(\n\t\tprivate readonly runtime: IConnectableRuntime,\n\t\tprivate readonly active: () => boolean,\n\t) {}\n\n\t/**\n\t * Starts and waits for a promise which resolves when connected.\n\t * The promise will also resolve if stopped either externally or by disconnect.\n\t *\n\t * We only listen on disconnected event for clientType === \"summarizer\" container!\n\t * And only do it here - no other place should check it! That way we have only one place\n\t * that controls policy and it's easy to change policy in the future if we want to!\n\t * We do not listen for \"main\" (aka interactive) container disconnect here, as it's\n\t * responsibility of SummaryManager to decide if that's material or not. There are cases\n\t * like \"lastSummary\", or main client experiencing nacks / disconnects due to hitting limit\n\t * of non-summarized ops, where can make determination to continue with summary even if main\n\t * client is disconnected.\n\t */\n\tprotected async waitStart() {\n\t\tif (this.runtime.disposed) {\n\t\t\tthis.stop(\"summarizerClientDisconnected\");\n\t\t\treturn;\n\t\t}\n\n\t\tthis.runtime.once(\"dispose\", () => this.stop(\"summarizerClientDisconnected\"));\n\n\t\tif (!this.runtime.connected) {\n\t\t\tconst waitConnected = new Promise<void>((resolve) =>\n\t\t\t\tthis.runtime.once(\"connected\", resolve),\n\t\t\t);\n\t\t\tawait Promise.race([waitConnected, this.waitCancelled]);\n\t\t}\n\t\tthis.runtime.once(\"disconnected\", () => this.stop(\"summarizerClientDisconnected\"));\n\t}\n\n\t/**\n\t * Stops running.\n\t */\n\tpublic stop(reason: SummarizerStopReason): void {\n\t\tif (!this._cancelled) {\n\t\t\tthis._cancelled = true;\n\t\t\tthis.stopDeferred.resolve(reason);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"runWhileConnectedCoordinator.js","sourceRoot":"","sources":["../../src/summary/runWhileConnectedCoordinator.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAA8D;AAY9D;;;GAGG;AACU,QAAA,0BAA0B,GAA8B;IACpE,SAAS,EAAE,KAAK;IAChB,aAAa,EAAE,IAAI,OAAO,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;CACpC,CAAC;AAEF;;;;GAIG;AACH,MAAa,4BAA4B;IAqCxC,YACkB,OAA4B,EAC5B,MAAqB;QADrB,YAAO,GAAP,OAAO,CAAqB;QAC5B,WAAM,GAAN,MAAM,CAAe;QAtC/B,eAAU,GAAG,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F,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;SACxD;QACD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACpF,CAAC;IAED;;OAEG;IACI,IAAI,CAAC,MAA4B;QACvC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACrB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;SAClC;IACF,CAAC;CACD;AAjFD,oEAiFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Deferred } from \"@fluidframework/core-utils\";\nimport {\n\tSummarizerStopReason,\n\tIConnectableRuntime,\n\tISummaryCancellationToken,\n} from \"./summarizerTypes\";\n\n/* Similar to AbortController, but using promise instead of events */\nexport interface ICancellableSummarizerController extends ISummaryCancellationToken {\n\tstop(reason: SummarizerStopReason): void;\n}\n\n/**\n * Can be useful in testing as well as in places where caller does not use cancellation.\n * This object implements ISummaryCancellationToken interface but cancellation is never leveraged.\n */\nexport const neverCancelledSummaryToken: ISummaryCancellationToken = {\n\tcancelled: false,\n\twaitCancelled: new Promise(() => {}),\n};\n\n/**\n * Helper class to coordinate something that needs to run only while connected.\n * This provides promises that resolve as it starts or stops. Stopping happens\n * when disconnected or if stop() is called.\n */\nexport class RunWhileConnectedCoordinator implements ICancellableSummarizerController {\n\tprivate _cancelled = false;\n\tprivate readonly stopDeferred = new Deferred<SummarizerStopReason>();\n\n\tpublic get cancelled() {\n\t\tif (!this._cancelled) {\n\t\t\tassert(this.active(), 0x25d /* \"We should never connect as 'read'\" */);\n\n\t\t\t// This check can't be enabled in current design due to lastSummary flow, where\n\t\t\t// summarizer for closed container stays around and can produce one more summary.\n\t\t\t// Currently we solve the problem of overlapping summarizer by doing wait in\n\t\t\t// SummaryManager.createSummarizer()\n\t\t\t// Better solution would involve these steps:\n\t\t\t// 1. Summarizer selection logic should chose summarizing client (with clientType === \"summarizer\")\n\t\t\t// if such client exists.\n\t\t\t// 2. Summarizer should be updated about such changes (to update onBehalfOfClientId)\n\t\t\t//\n\t\t\t// assert(this.runtime.summarizerClientId === this.onBehalfOfClientId ||\n\t\t\t// this.runtime.summarizerClientId === this.runtime.clientId, \"onBehalfOfClientId\");\n\t\t}\n\n\t\treturn this._cancelled;\n\t}\n\n\t/**\n\t * Returns a promise that resolves once stopped either externally or by disconnect.\n\t */\n\tpublic get waitCancelled(): Promise<SummarizerStopReason> {\n\t\treturn this.stopDeferred.promise;\n\t}\n\n\tpublic static async create(runtime: IConnectableRuntime, active: () => boolean) {\n\t\tconst obj = new RunWhileConnectedCoordinator(runtime, active);\n\t\tawait obj.waitStart();\n\t\treturn obj;\n\t}\n\n\tprotected constructor(\n\t\tprivate readonly runtime: IConnectableRuntime,\n\t\tprivate readonly active: () => boolean,\n\t) {}\n\n\t/**\n\t * Starts and waits for a promise which resolves when connected.\n\t * The promise will also resolve if stopped either externally or by disconnect.\n\t *\n\t * We only listen on disconnected event for clientType === \"summarizer\" container!\n\t * And only do it here - no other place should check it! That way we have only one place\n\t * that controls policy and it's easy to change policy in the future if we want to!\n\t * We do not listen for \"main\" (aka interactive) container disconnect here, as it's\n\t * responsibility of SummaryManager to decide if that's material or not. There are cases\n\t * like \"lastSummary\", or main client experiencing nacks / disconnects due to hitting limit\n\t * of non-summarized ops, where can make determination to continue with summary even if main\n\t * client is disconnected.\n\t */\n\tprotected async waitStart() {\n\t\tif (this.runtime.disposed) {\n\t\t\tthis.stop(\"summarizerClientDisconnected\");\n\t\t\treturn;\n\t\t}\n\n\t\tthis.runtime.once(\"dispose\", () => this.stop(\"summarizerClientDisconnected\"));\n\n\t\tif (!this.runtime.connected) {\n\t\t\tconst waitConnected = new Promise<void>((resolve) =>\n\t\t\t\tthis.runtime.once(\"connected\", resolve),\n\t\t\t);\n\t\t\tawait Promise.race([waitConnected, this.waitCancelled]);\n\t\t}\n\t\tthis.runtime.once(\"disconnected\", () => this.stop(\"summarizerClientDisconnected\"));\n\t}\n\n\t/**\n\t * Stops running.\n\t */\n\tpublic stop(reason: SummarizerStopReason): void {\n\t\tif (!this._cancelled) {\n\t\t\tthis._cancelled = true;\n\t\t\tthis.stopDeferred.resolve(reason);\n\t\t}\n\t}\n}\n"]}
@@ -2,13 +2,23 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { IDisposable } from "@fluidframework/common-definitions";
6
- import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
5
+ import { IDisposable, ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
6
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
7
7
  import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
8
8
  import { ISummaryConfiguration } from "../containerRuntime";
9
- import { IEnqueueSummarizeOptions, ISummarizeHeuristicData, IOnDemandSummarizeOptions, EnqueueSummarizeResult, SummarizerStopReason, ISubmitSummaryOptions, SubmitSummaryResult, ISummaryCancellationToken, ISummarizeResults, ISummarizerRuntime, IRefreshSummaryAckOptions } from "./summarizerTypes";
9
+ import { IEnqueueSummarizeOptions, ISummarizeHeuristicData, IOnDemandSummarizeOptions, EnqueueSummarizeResult, SummarizerStopReason, ISubmitSummaryOptions, SubmitSummaryResult, ISummaryCancellationToken, ISummarizeResults, ISummarizerRuntime, IRefreshSummaryAckOptions, ISummarizerEvents } from "./summarizerTypes";
10
10
  import { IClientSummaryWatcher, SummaryCollection } from "./summaryCollection";
11
11
  import { SummarizeResultBuilder } from "./summaryGenerator";
12
+ /**
13
+ * The maximum number of summarization attempts that will be done by default in case of failures
14
+ * that can be retried.
15
+ */
16
+ export declare const defaultMaxAttempts = 2;
17
+ /**
18
+ * The default value for maximum number of summarization attempts that will be done for summarization failures where
19
+ * submit fails and the failure can be retried.
20
+ */
21
+ export declare const defaultMaxAttemptsForSubmitFailures = 5;
12
22
  /**
13
23
  * An instance of RunningSummarizer manages the heuristics for summarizing.
14
24
  * Until disposed, the instance of RunningSummarizer can assume that it is
@@ -16,7 +26,7 @@ import { SummarizeResultBuilder } from "./summaryGenerator";
16
26
  * track of summaries that it is generating as they are broadcast and acked/nacked.
17
27
  * This object is created and controlled by Summarizer object.
18
28
  */
19
- export declare class RunningSummarizer implements IDisposable {
29
+ export declare class RunningSummarizer extends TypedEventEmitter<ISummarizerEvents> implements IDisposable {
20
30
  private readonly summaryWatcher;
21
31
  private readonly configuration;
22
32
  private readonly submitSummaryCallback;
@@ -26,7 +36,7 @@ export declare class RunningSummarizer implements IDisposable {
26
36
  private readonly cancellationToken;
27
37
  private readonly stopSummarizerCallback;
28
38
  private readonly runtime;
29
- static start(logger: ITelemetryLoggerExt, summaryWatcher: IClientSummaryWatcher, configuration: ISummaryConfiguration, submitSummaryCallback: (options: ISubmitSummaryOptions) => Promise<SubmitSummaryResult>, refreshLatestSummaryAckCallback: (options: IRefreshSummaryAckOptions) => Promise<void>, heuristicData: ISummarizeHeuristicData, summaryCollection: SummaryCollection, cancellationToken: ISummaryCancellationToken, stopSummarizerCallback: (reason: SummarizerStopReason) => void, runtime: ISummarizerRuntime): Promise<RunningSummarizer>;
39
+ static start(logger: ITelemetryBaseLogger, summaryWatcher: IClientSummaryWatcher, configuration: ISummaryConfiguration, submitSummaryCallback: (options: ISubmitSummaryOptions) => Promise<SubmitSummaryResult>, refreshLatestSummaryAckCallback: (options: IRefreshSummaryAckOptions) => Promise<void>, heuristicData: ISummarizeHeuristicData, summaryCollection: SummaryCollection, cancellationToken: ISummaryCancellationToken, stopSummarizerCallback: (reason: SummarizerStopReason) => void, runtime: ISummarizerRuntime): Promise<RunningSummarizer>;
30
40
  get disposed(): boolean;
31
41
  private stopping;
32
42
  private _disposed;
@@ -40,8 +50,9 @@ export declare class RunningSummarizer implements IDisposable {
40
50
  private summarizeCount;
41
51
  private totalSuccessfulAttempts;
42
52
  private initialized;
43
- private readonly deltaManagerListener;
44
53
  private readonly runtimeListener;
54
+ /** The maximum number of summary attempts to do when submit summary fails. */
55
+ private readonly maxAttemptsForSubmitFailures;
45
56
  private constructor();
46
57
  private handleSummaryAck;
47
58
  /**
@@ -60,7 +71,7 @@ export declare class RunningSummarizer implements IDisposable {
60
71
  * but only if they're logging about that same summary.
61
72
  * @param summaryOpRefSeq - RefSeq number of the summary op, to ensure the log correlation will be correct
62
73
  */
63
- tryGetCorrelatedLogger: (summaryOpRefSeq: any) => ITelemetryLoggerExt | undefined;
74
+ tryGetCorrelatedLogger: (summaryOpRefSeq: any) => import("@fluidframework/telemetry-utils").ITelemetryLoggerExt | undefined;
64
75
  /** We only want a single heuristic runner micro-task (will provide better optimized grouping of ops) */
65
76
  private heuristicRunnerMicroTaskExists;
66
77
  handleOp(op: ISequencedDocumentMessage, runtimeMessage: boolean): void;
@@ -83,7 +94,7 @@ export declare class RunningSummarizer implements IDisposable {
83
94
  * @param before - set of instructions to run before running the action.
84
95
  * @param action - action to perform.
85
96
  * @param after - set of instructions to run after running the action.
86
- * @returns - result of action.
97
+ * @returns The result of the action.
87
98
  */
88
99
  private lockedSummaryAction;
89
100
  /**
@@ -97,10 +108,20 @@ export declare class RunningSummarizer implements IDisposable {
97
108
  private trySummarizeOnce;
98
109
  /** Heuristics summarize attempt. */
99
110
  private trySummarize;
111
+ /**
112
+ * Tries to summarize 2 times with pre-defined summary options. If an attempt fails with "retryAfterSeconds"
113
+ * param, that attempt is tried once more.
114
+ */
115
+ private trySummarizeWithStaticAttempts;
116
+ /**
117
+ * Tries to summarize with retries where retry is based on the failure params.
118
+ * For example, summarization may be retried for failures with "retryAfterSeconds" param.
119
+ */
120
+ private trySummarizeWithRetries;
100
121
  /** {@inheritdoc (ISummarizer:interface).summarizeOnDemand} */
101
- summarizeOnDemand(resultsBuilder: SummarizeResultBuilder | undefined, { reason, ...options }: IOnDemandSummarizeOptions): ISummarizeResults;
122
+ summarizeOnDemand(options: IOnDemandSummarizeOptions, resultsBuilder?: SummarizeResultBuilder): ISummarizeResults;
102
123
  /** {@inheritdoc (ISummarizer:interface).enqueueSummarize} */
103
- enqueueSummarize({ reason, afterSequenceNumber, override, ...options }: IEnqueueSummarizeOptions): EnqueueSummarizeResult;
124
+ enqueueSummarize(options: IEnqueueSummarizeOptions): EnqueueSummarizeResult;
104
125
  private tryRunEnqueuedSummary;
105
126
  private disposeEnqueuedSummary;
106
127
  }
@@ -1 +1 @@
1
- {"version":3,"file":"runningSummarizer.d.ts","sourceRoot":"","sources":["../../src/summary/runningSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EACN,mBAAmB,EAKnB,MAAM,iCAAiC,CAAC;AAKzC,OAAO,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAG5D,OAAO,EACN,wBAAwB,EAExB,uBAAuB,EAEvB,yBAAyB,EACzB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB,EAEjB,kBAAkB,EAElB,yBAAyB,EACzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAiB,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAGN,sBAAsB,EAEtB,MAAM,oBAAoB,CAAC;AAM5B;;;;;;GAMG;AACH,qBAAa,iBAAkB,YAAW,WAAW;IAgGnD,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IAGtC,OAAO,CAAC,QAAQ,CAAC,+BAA+B;IAGhD,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