public SolrCloudState GetClusterStatus(string collection, string shard = null) { var json = SendRaw(adminHandler, new SolrParams() .AddRequired("wt", "json") .AddRequired("action", "clustertsate") .AddOptional("shard", shard)); var status = SolrCloudStateParser.Parse(json); return(status); }
public void ShouldProduceMergedStateFromSeveralJson() { var internalCollectionsState = SolrCloudStateParser.Parse(InternalCollectionsState); var external1State = SolrCloudStateParser.Parse(FirstExternalCollectionState); var external2State = SolrCloudStateParser.Parse(SecondExternalCollectionState); var totalCollectionsCount = internalCollectionsState.Collections.Count + external1State.Collections.Count + external2State.Collections.Count; var zkState = internalCollectionsState.Merge(external1State).Merge(external2State); Assert.Equal(zkState.Collections.Count, totalCollectionsCount); }
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))); }
public void ShouldProduceNotEmptyStateFromNotEmptyJson() { var collections = SolrCloudStateParser.Parse(NotEmptyJson).Collections.Values; Assert.True(collections.Any()); var shards = collections.SelectMany(collection => collection.Shards.Values).ToList(); Assert.True(shards.Any()); Assert.True(shards.Any(shard => shard.IsActive)); var replicas = shards.SelectMany(shard => shard.Replicas.Values).ToList(); Assert.True(replicas.Any()); Assert.True(replicas.Any(replica => replica.IsActive)); Assert.True(replicas.Any(replica => replica.IsLeader)); }
/// <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); }
/// <summary> /// Returns parsed internal collections cloud state /// </summary> private async Task <SolrCloudState> GetInternalCollectionsStateAsync() { DataResult data; try { data = await zooKeeper.getDataAsync(ClusterState, true).ConfigureAwait(false); } catch (KeeperException ex) { return(new SolrCloudState(new Dictionary <string, SolrCloudCollection>())); } var collectionsState = data != null ? SolrCloudStateParser.Parse(Encoding.Default.GetString(data.Data)) : new SolrCloudState(new Dictionary <string, SolrCloudCollection>()); return(collectionsState); }
public void ShouldProduceEmptyStateFromEmptyJson() { var state = SolrCloudStateParser.Parse(EmptyJson); Assert.False(state.Collections.Any()); }