/// <summary> /// Gets the descendants of the given node from a snapshot of the current state of this instance. /// </summary> /// <param name="path">Path to the node</param> /// <returns>A <see cref="Task"/> that resolves to the list of descendant node paths</returns> public async Task <IList <string> > GetDescendantsFromSnapshot(string path) { Trace.TraceInformation($"RingMasterInstance.GetDescendantsFromSnapshot instanceId={this.Id}, path={path}"); byte[] snapshot = this.GetSnapshot(); if (path == null) { throw new ArgumentNullException(nameof(path)); } var nodes = new List <string>(); using (var factory = new InMemoryFactory()) { factory.LoadState = () => { using (var stream = new MemoryStream(snapshot)) { factory.LoadFrom(stream); } }; factory.OnFatalError = (message, exception) => { Assert.Fail($"FatalError: message={message}, exception={exception}"); }; using (var backend = CreateBackend(factory)) { using (var ringMaster = new CoreRequestHandler(backend)) { await ringMaster.ForEachDescendant( path, RingMasterInstance.MaxGetChildrenEnumerationCount, descendantPath => nodes.Add(descendantPath)); } } } Trace.TraceInformation($"RingMasterInstance.GetDescendantsFromSnapshot-Completed instanceId={this.Id}, path={path}, descendantsCount={nodes.Count}"); return(nodes); }