Search in sources :

Example 6 with ClusterStateHealth

use of org.elasticsearch.cluster.health.ClusterStateHealth in project elasticsearch by elastic.

the class PrimaryShardAllocatorTests method assertClusterHealthStatus.

private void assertClusterHealthStatus(RoutingAllocation allocation, ClusterHealthStatus expectedStatus) {
    RoutingTable oldRoutingTable = allocation.routingTable();
    RoutingNodes newRoutingNodes = allocation.routingNodes();
    final RoutingTable newRoutingTable = new RoutingTable.Builder().updateNodes(oldRoutingTable.version(), newRoutingNodes).build();
    ClusterState clusterState = ClusterState.builder(new ClusterName("test-cluster")).routingTable(newRoutingTable).build();
    ClusterStateHealth clusterStateHealth = new ClusterStateHealth(clusterState);
    assertThat(clusterStateHealth.getStatus().ordinal(), lessThanOrEqualTo(expectedStatus.ordinal()));
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) ClusterStateHealth(org.elasticsearch.cluster.health.ClusterStateHealth) RoutingTable(org.elasticsearch.cluster.routing.RoutingTable) RoutingNodes(org.elasticsearch.cluster.routing.RoutingNodes) ClusterName(org.elasticsearch.cluster.ClusterName)

Example 7 with ClusterStateHealth

use of org.elasticsearch.cluster.health.ClusterStateHealth in project elasticsearch by elastic.

the class ClusterHealthResponsesTests method assertClusterHealth.

private void assertClusterHealth(ClusterHealthResponse clusterHealth) {
    ClusterStateHealth clusterStateHealth = clusterHealth.getClusterStateHealth();
    assertThat(clusterHealth.getActiveShards(), Matchers.equalTo(clusterStateHealth.getActiveShards()));
    assertThat(clusterHealth.getRelocatingShards(), Matchers.equalTo(clusterStateHealth.getRelocatingShards()));
    assertThat(clusterHealth.getActivePrimaryShards(), Matchers.equalTo(clusterStateHealth.getActivePrimaryShards()));
    assertThat(clusterHealth.getInitializingShards(), Matchers.equalTo(clusterStateHealth.getInitializingShards()));
    assertThat(clusterHealth.getUnassignedShards(), Matchers.equalTo(clusterStateHealth.getUnassignedShards()));
    assertThat(clusterHealth.getNumberOfNodes(), Matchers.equalTo(clusterStateHealth.getNumberOfNodes()));
    assertThat(clusterHealth.getNumberOfDataNodes(), Matchers.equalTo(clusterStateHealth.getNumberOfDataNodes()));
}
Also used : ClusterStateHealth(org.elasticsearch.cluster.health.ClusterStateHealth)

Aggregations

ClusterStateHealth (org.elasticsearch.cluster.health.ClusterStateHealth)7 ClusterState (org.elasticsearch.cluster.ClusterState)4 RoutingTable (org.elasticsearch.cluster.routing.RoutingTable)3 ClusterName (org.elasticsearch.cluster.ClusterName)2 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)2 MetaData (org.elasticsearch.cluster.metadata.MetaData)2 RoutingNodes (org.elasticsearch.cluster.routing.RoutingNodes)2 ArrayList (java.util.ArrayList)1 NodeInfo (org.elasticsearch.action.admin.cluster.node.info.NodeInfo)1 NodeStats (org.elasticsearch.action.admin.cluster.node.stats.NodeStats)1 CommonStats (org.elasticsearch.action.admin.indices.stats.CommonStats)1 ShardStats (org.elasticsearch.action.admin.indices.stats.ShardStats)1 RestoreInProgress (org.elasticsearch.cluster.RestoreInProgress)1 ClusterHealthStatus (org.elasticsearch.cluster.health.ClusterHealthStatus)1 DiscoveryNodes (org.elasticsearch.cluster.node.DiscoveryNodes)1 IndexShardRoutingTable (org.elasticsearch.cluster.routing.IndexShardRoutingTable)1 ImmutableOpenMap (org.elasticsearch.common.collect.ImmutableOpenMap)1 TimeValue (org.elasticsearch.common.unit.TimeValue)1 IndexService (org.elasticsearch.index.IndexService)1 IndexShard (org.elasticsearch.index.shard.IndexShard)1