Remove unnecessary fromValue method for ClusterHealthStatus (#53893)

We use readFrom as a standard name for deserializing an object, but
ClusterHealthStatus also had a `fromValue` method which was used during
outer deserialization. This commit collapses the two methods together.

closes #53569
This commit is contained in:
Ryan Ernst 2020-03-20 13:26:22 -07:00 committed by GitHub
parent 6332c40a2c
commit 290d58b1b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 8 additions and 11 deletions

View File

@ -73,7 +73,7 @@ public class ClusterHealthRequest extends MasterNodeReadRequest<ClusterHealthReq
} }
timeout = in.readTimeValue(); timeout = in.readTimeValue();
if (in.readBoolean()) { if (in.readBoolean()) {
waitForStatus = ClusterHealthStatus.fromValue(in.readByte()); waitForStatus = ClusterHealthStatus.readFrom(in);
} }
waitForNoRelocatingShards = in.readBoolean(); waitForNoRelocatingShards = in.readBoolean();
waitForActiveShards = ActiveShardCount.readFrom(in); waitForActiveShards = ActiveShardCount.readFrom(in);

View File

@ -147,7 +147,7 @@ public class ClusterHealthResponse extends ActionResponse implements StatusToXCo
public ClusterHealthResponse(StreamInput in) throws IOException { public ClusterHealthResponse(StreamInput in) throws IOException {
super(in); super(in);
clusterName = in.readString(); clusterName = in.readString();
clusterHealthStatus = ClusterHealthStatus.fromValue(in.readByte()); clusterHealthStatus = ClusterHealthStatus.readFrom(in);
clusterStateHealth = new ClusterStateHealth(in); clusterStateHealth = new ClusterStateHealth(in);
numberOfPendingTasks = in.readInt(); numberOfPendingTasks = in.readInt();
timedOut = in.readBoolean(); timedOut = in.readBoolean();

View File

@ -42,7 +42,7 @@ public class ClusterStatsNodeResponse extends BaseNodeResponse {
super(in); super(in);
clusterStatus = null; clusterStatus = null;
if (in.readBoolean()) { if (in.readBoolean()) {
clusterStatus = ClusterHealthStatus.fromValue(in.readByte()); clusterStatus = ClusterHealthStatus.readFrom(in);
} }
this.nodeInfo = new NodeInfo(in); this.nodeInfo = new NodeInfo(in);
this.nodeStats = new NodeStats(in); this.nodeStats = new NodeStats(in);

View File

@ -55,7 +55,7 @@ public class IndicesShardStoresRequest extends MasterNodeReadRequest<IndicesShar
int nStatus = in.readVInt(); int nStatus = in.readVInt();
statuses = EnumSet.noneOf(ClusterHealthStatus.class); statuses = EnumSet.noneOf(ClusterHealthStatus.class);
for (int i = 0; i < nStatus; i++) { for (int i = 0; i < nStatus; i++) {
statuses.add(ClusterHealthStatus.fromValue(in.readByte())); statuses.add(ClusterHealthStatus.readFrom(in));
} }
indicesOptions = IndicesOptions.readIndicesOptions(in); indicesOptions = IndicesOptions.readIndicesOptions(in);
} }

View File

@ -52,10 +52,7 @@ public enum ClusterHealthStatus implements Writeable {
* @throws IllegalArgumentException if the value is unrecognized * @throws IllegalArgumentException if the value is unrecognized
*/ */
public static ClusterHealthStatus readFrom(StreamInput in) throws IOException { public static ClusterHealthStatus readFrom(StreamInput in) throws IOException {
return fromValue(in.readByte()); byte value = in.readByte();
}
public static ClusterHealthStatus fromValue(byte value) throws IOException {
switch (value) { switch (value) {
case 0: case 0:
return GREEN; return GREEN;

View File

@ -165,7 +165,7 @@ public final class ClusterIndexHealth implements Iterable<ClusterShardHealth>, W
relocatingShards = in.readVInt(); relocatingShards = in.readVInt();
initializingShards = in.readVInt(); initializingShards = in.readVInt();
unassignedShards = in.readVInt(); unassignedShards = in.readVInt();
status = ClusterHealthStatus.fromValue(in.readByte()); status = ClusterHealthStatus.readFrom(in);
int size = in.readVInt(); int size = in.readVInt();
shards = new HashMap<>(size); shards = new HashMap<>(size);

View File

@ -121,7 +121,7 @@ public final class ClusterShardHealth implements Writeable, ToXContentFragment {
public ClusterShardHealth(final StreamInput in) throws IOException { public ClusterShardHealth(final StreamInput in) throws IOException {
shardId = in.readVInt(); shardId = in.readVInt();
status = ClusterHealthStatus.fromValue(in.readByte()); status = ClusterHealthStatus.readFrom(in);
activeShards = in.readVInt(); activeShards = in.readVInt();
relocatingShards = in.readVInt(); relocatingShards = in.readVInt();
initializingShards = in.readVInt(); initializingShards = in.readVInt();

View File

@ -134,7 +134,7 @@ public final class ClusterStateHealth implements Iterable<ClusterIndexHealth>, W
unassignedShards = in.readVInt(); unassignedShards = in.readVInt();
numberOfNodes = in.readVInt(); numberOfNodes = in.readVInt();
numberOfDataNodes = in.readVInt(); numberOfDataNodes = in.readVInt();
status = ClusterHealthStatus.fromValue(in.readByte()); status = ClusterHealthStatus.readFrom(in);
int size = in.readVInt(); int size = in.readVInt();
indices = new HashMap<>(size); indices = new HashMap<>(size);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {