private async Task LoadNode(org.apache.zookeeper.ZooKeeper zk, Node node) { var result = await zk.getChildrenAsync(node.Path); if (result != null) { node.NodeState = NodeState.Build(result.Stat); foreach (var child in result.Children) { var childNode = new Node { Text = child }; if (node.Path != "/") { childNode.Path = node.Path + "/" + child; } else { childNode.Path = node.Path + child; } await LoadNode(zk, childNode); if (node.Nodes == null) { node.Nodes = new List <Node>(); } node.Nodes.Add(childNode); } } }
public async Task <ResponseMessage <GetResponse> > Get([FromBody] RequestMessage <GetRequest> reqMsg) { var zk = await zkManager.Get(reqMsg.Header.ConnectString); DataResult result = await zk.getDataAsync(reqMsg.Body.Path); return(new ResponseMessage <GetResponse> { Body = new GetResponse { Data = result.Data == null ? "" : UTF8Encoding.UTF8.GetString(result.Data), NodeState = NodeState.Build(result.Stat) } }); }
public async Task <ResponseMessage <ExecResponse> > Set([FromBody] RequestMessage <SetRequest> reqMsg) { var zk = await zkManager.Get(reqMsg.Header.ConnectString); var data = Encoding.UTF8.GetBytes(reqMsg.Body.Data); var state = await zk.setDataAsync(reqMsg.Body.Path, data); return(new ResponseMessage <ExecResponse> { Body = new ExecResponse { NodeState = NodeState.Build(state) } }); }