private void Update() { if (zooKeeper == null) { zooKeeper = new ZooKeeper( zooKeeperConnection, TimeSpan.FromSeconds(10), this); } state = SolrCloudStateParser.Parse( Encoding.Default.GetString( zooKeeper.GetData("/clusterstate.json", true, null))); }
/// <summary> /// Updates zookeeper connection and actual cloud state /// </summary> /// <param name="cleanZookeeperConnection">clean zookeeper connection and create new one</param> private async Task UpdateAsync(bool cleanZookeeperConnection = false) { if (zooKeeper == null || cleanZookeeperConnection) { if (zooKeeper != null) { await zooKeeper.closeAsync().ConfigureAwait(false); } zooKeeper = new ZooKeeper(zooKeeperConnection, 10_000, this); } state = (await GetInternalCollectionsStateAsync().ConfigureAwait(false)).Merge(await GetExternalCollectionsStateAsync().ConfigureAwait(false)); }
/// <summary> /// Updates zookeeper connection and actual cloud state /// </summary> /// <param name="cleanZookeeperConnection">clean zookeeper connection and create new one</param> private async Task UpdateAsync(bool cleanZookeeperConnection = false) { if (zooKeeper == null || cleanZookeeperConnection) { if (zooKeeper != null) { await zooKeeper.closeAsync().ConfigureAwait(false); } zooKeeper = new ZooKeeper(zooKeeperConnection, zooKeeperTimeoutMs, this); } liveNodes = await GetLiveNodesAsync().ConfigureAwait(false); state = liveNodes.Any() ? (await GetInternalCollectionsStateAsync().ConfigureAwait(false)).Merge(await GetExternalCollectionsStateAsync().ConfigureAwait(false)) : new SolrCloudState(new Dictionary <string, SolrCloudCollection>()); }
/// <summary> /// Returns parsed external collections cloud state /// </summary> private async Task <SolrCloudState> GetExternalCollectionsStateAsync() { var resultState = new SolrCloudState(new Dictionary <string, SolrCloudCollection>()); ChildrenResult children; try { children = await zooKeeper.getChildrenAsync(CollectionsZkNode, true).ConfigureAwait(false); } catch (KeeperException ex) { return(resultState); } if (children == null || !children.Children.Any()) { return(resultState); } foreach (var child in children.Children) { DataResult data; try { data = await zooKeeper.getDataAsync(GetCollectionPath(child), true).ConfigureAwait(false); } catch (KeeperException ex) { data = null; } var collectionState = data != null ? SolrCloudStateParser.Parse(Encoding.Default.GetString(data.Data)) : new SolrCloudState(new Dictionary <string, SolrCloudCollection>()); resultState = resultState.Merge(collectionState); } return(resultState); }
private void Update(string collection) { //if (zooKeeper == null) // zooKeeper = new ZooKeeper( // zooKeeperConnection, // TimeSpan.FromSeconds(10), this); //var data = Encoding.Default.GetString( // zooKeeper.GetData(string.Format("/collections/{0}/state.json", collection), true, null)); var data = GetJson(); state = SolrCloudStateParser.Parse(data); // state=SolrCloudStateParser.Parse(GetState()); }
private void Update() { if (zooKeeper == null) zooKeeper = new ZooKeeper( zooKeeperConnection, TimeSpan.FromSeconds(10), this); state = SolrCloudStateParser.Parse( Encoding.Default.GetString( zooKeeper.GetData("/clusterstate.json", true, null))); }