Cluster Health API: Add `initializing_shards` and `unassigned_shards` to the response, closes #330.
This commit is contained in:
parent
113ea1bb1b
commit
38e6649a7e
|
@ -48,6 +48,10 @@ public class ClusterHealthResponse implements ActionResponse, Iterable<ClusterIn
|
|||
|
||||
int activePrimaryShards = 0;
|
||||
|
||||
int initializingShards = 0;
|
||||
|
||||
int unassignedShards = 0;
|
||||
|
||||
boolean timedOut = false;
|
||||
|
||||
ClusterHealthStatus status = ClusterHealthStatus.RED;
|
||||
|
@ -129,6 +133,22 @@ public class ClusterHealthResponse implements ActionResponse, Iterable<ClusterIn
|
|||
return activePrimaryShards();
|
||||
}
|
||||
|
||||
public int initializingShards() {
|
||||
return initializingShards;
|
||||
}
|
||||
|
||||
public int getInitializingShards() {
|
||||
return initializingShards();
|
||||
}
|
||||
|
||||
public int unassignedShards() {
|
||||
return unassignedShards;
|
||||
}
|
||||
|
||||
public int getUnassignedShards() {
|
||||
return unassignedShards();
|
||||
}
|
||||
|
||||
public int numberOfNodes() {
|
||||
return this.numberOfNodes;
|
||||
}
|
||||
|
@ -173,6 +193,8 @@ public class ClusterHealthResponse implements ActionResponse, Iterable<ClusterIn
|
|||
activePrimaryShards = in.readVInt();
|
||||
activeShards = in.readVInt();
|
||||
relocatingShards = in.readVInt();
|
||||
initializingShards = in.readVInt();
|
||||
unassignedShards = in.readVInt();
|
||||
numberOfNodes = in.readVInt();
|
||||
status = ClusterHealthStatus.fromValue(in.readByte());
|
||||
int size = in.readVInt();
|
||||
|
@ -196,6 +218,8 @@ public class ClusterHealthResponse implements ActionResponse, Iterable<ClusterIn
|
|||
out.writeVInt(activePrimaryShards);
|
||||
out.writeVInt(activeShards);
|
||||
out.writeVInt(relocatingShards);
|
||||
out.writeVInt(initializingShards);
|
||||
out.writeVInt(unassignedShards);
|
||||
out.writeVInt(numberOfNodes);
|
||||
out.writeByte(status.value());
|
||||
out.writeVInt(indices.size());
|
||||
|
|
|
@ -47,6 +47,10 @@ public class ClusterIndexHealth implements Iterable<ClusterShardHealth>, Streama
|
|||
|
||||
int relocatingShards = 0;
|
||||
|
||||
int initializingShards = 0;
|
||||
|
||||
int unassignedShards = 0;
|
||||
|
||||
int activePrimaryShards = 0;
|
||||
|
||||
ClusterHealthStatus status = ClusterHealthStatus.RED;
|
||||
|
@ -121,6 +125,22 @@ public class ClusterIndexHealth implements Iterable<ClusterShardHealth>, Streama
|
|||
return activePrimaryShards();
|
||||
}
|
||||
|
||||
public int initializingShards() {
|
||||
return initializingShards;
|
||||
}
|
||||
|
||||
public int getInitializingShards() {
|
||||
return initializingShards();
|
||||
}
|
||||
|
||||
public int unassignedShards() {
|
||||
return unassignedShards;
|
||||
}
|
||||
|
||||
public int getUnassignedShards() {
|
||||
return unassignedShards();
|
||||
}
|
||||
|
||||
public ClusterHealthStatus status() {
|
||||
return status;
|
||||
}
|
||||
|
@ -154,6 +174,8 @@ public class ClusterIndexHealth implements Iterable<ClusterShardHealth>, Streama
|
|||
activePrimaryShards = in.readVInt();
|
||||
activeShards = in.readVInt();
|
||||
relocatingShards = in.readVInt();
|
||||
initializingShards = in.readVInt();
|
||||
unassignedShards = in.readVInt();
|
||||
status = ClusterHealthStatus.fromValue(in.readByte());
|
||||
|
||||
int size = in.readVInt();
|
||||
|
@ -178,6 +200,8 @@ public class ClusterIndexHealth implements Iterable<ClusterShardHealth>, Streama
|
|||
out.writeVInt(activePrimaryShards);
|
||||
out.writeVInt(activeShards);
|
||||
out.writeVInt(relocatingShards);
|
||||
out.writeVInt(initializingShards);
|
||||
out.writeVInt(unassignedShards);
|
||||
out.writeByte(status.value());
|
||||
|
||||
out.writeVInt(shards.size());
|
||||
|
|
|
@ -38,6 +38,10 @@ public class ClusterShardHealth implements Streamable {
|
|||
|
||||
int relocatingShards = 0;
|
||||
|
||||
int initializingShards = 0;
|
||||
|
||||
int unassignedShards = 0;
|
||||
|
||||
boolean primaryActive = false;
|
||||
|
||||
private ClusterShardHealth() {
|
||||
|
@ -88,6 +92,22 @@ public class ClusterShardHealth implements Streamable {
|
|||
return primaryActive();
|
||||
}
|
||||
|
||||
public int initializingShards() {
|
||||
return initializingShards;
|
||||
}
|
||||
|
||||
public int getInitializingShards() {
|
||||
return initializingShards();
|
||||
}
|
||||
|
||||
public int unassignedShards() {
|
||||
return unassignedShards;
|
||||
}
|
||||
|
||||
public int getUnassignedShards() {
|
||||
return unassignedShards();
|
||||
}
|
||||
|
||||
static ClusterShardHealth readClusterShardHealth(StreamInput in) throws IOException {
|
||||
ClusterShardHealth ret = new ClusterShardHealth();
|
||||
ret.readFrom(in);
|
||||
|
@ -99,6 +119,8 @@ public class ClusterShardHealth implements Streamable {
|
|||
status = ClusterHealthStatus.fromValue(in.readByte());
|
||||
activeShards = in.readVInt();
|
||||
relocatingShards = in.readVInt();
|
||||
initializingShards = in.readVInt();
|
||||
unassignedShards = in.readVInt();
|
||||
primaryActive = in.readBoolean();
|
||||
}
|
||||
|
||||
|
@ -107,6 +129,8 @@ public class ClusterShardHealth implements Streamable {
|
|||
out.writeByte(status.value());
|
||||
out.writeVInt(activeShards);
|
||||
out.writeVInt(relocatingShards);
|
||||
out.writeVInt(initializingShards);
|
||||
out.writeVInt(unassignedShards);
|
||||
out.writeBoolean(primaryActive);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,6 +187,10 @@ public class TransportClusterHealthAction extends TransportMasterNodeOperationAc
|
|||
if (shardRouting.primary()) {
|
||||
shardHealth.primaryActive = true;
|
||||
}
|
||||
} else if (shardRouting.initializing()) {
|
||||
shardHealth.initializingShards++;
|
||||
} else if (shardRouting.unassigned()) {
|
||||
shardHealth.unassignedShards++;
|
||||
}
|
||||
}
|
||||
if (shardHealth.primaryActive) {
|
||||
|
@ -207,6 +211,8 @@ public class TransportClusterHealthAction extends TransportMasterNodeOperationAc
|
|||
}
|
||||
indexHealth.activeShards += shardHealth.activeShards;
|
||||
indexHealth.relocatingShards += shardHealth.relocatingShards;
|
||||
indexHealth.initializingShards += shardHealth.initializingShards;
|
||||
indexHealth.unassignedShards += shardHealth.unassignedShards;
|
||||
}
|
||||
// update the index status
|
||||
indexHealth.status = ClusterHealthStatus.GREEN;
|
||||
|
@ -231,6 +237,8 @@ public class TransportClusterHealthAction extends TransportMasterNodeOperationAc
|
|||
response.activePrimaryShards += indexHealth.activePrimaryShards;
|
||||
response.activeShards += indexHealth.activeShards;
|
||||
response.relocatingShards += indexHealth.relocatingShards;
|
||||
response.initializingShards += indexHealth.initializingShards;
|
||||
response.unassignedShards += indexHealth.unassignedShards;
|
||||
}
|
||||
|
||||
response.status = ClusterHealthStatus.GREEN;
|
||||
|
|
|
@ -90,6 +90,8 @@ public class RestClusterHealthAction extends BaseRestHandler {
|
|||
builder.field("active_primary_shards", response.activePrimaryShards());
|
||||
builder.field("active_shards", response.activeShards());
|
||||
builder.field("relocating_shards", response.relocatingShards());
|
||||
builder.field("initializing_shards", response.initializingShards());
|
||||
builder.field("unassigned_shards", response.unassignedShards());
|
||||
|
||||
if (!response.validationFailures().isEmpty()) {
|
||||
builder.startArray("validation_failures");
|
||||
|
@ -127,6 +129,8 @@ public class RestClusterHealthAction extends BaseRestHandler {
|
|||
builder.field("active_primary_shards", indexHealth.activePrimaryShards());
|
||||
builder.field("active_shards", indexHealth.activeShards());
|
||||
builder.field("relocating_shards", indexHealth.relocatingShards());
|
||||
builder.field("initializing_shards", indexHealth.initializingShards());
|
||||
builder.field("unassigned_shards", indexHealth.unassignedShards());
|
||||
|
||||
if (!indexHealth.validationFailures().isEmpty()) {
|
||||
builder.startArray("validation_failures");
|
||||
|
@ -146,6 +150,8 @@ public class RestClusterHealthAction extends BaseRestHandler {
|
|||
builder.field("primary_active", shardHealth.primaryActive());
|
||||
builder.field("active_shards", shardHealth.activeShards());
|
||||
builder.field("relocating_shards", shardHealth.relocatingShards());
|
||||
builder.field("initializing_shards", shardHealth.initializingShards());
|
||||
builder.field("unassigned_shards", shardHealth.unassignedShards());
|
||||
|
||||
builder.endObject();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue