Skip to content

Commit 290d58b

Browse files
authored
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
1 parent 6332c40 commit 290d58b

File tree

8 files changed

+8
-11
lines changed

8 files changed

+8
-11
lines changed

server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public ClusterHealthRequest(StreamInput in) throws IOException {
7373
}
7474
timeout = in.readTimeValue();
7575
if (in.readBoolean()) {
76-
waitForStatus = ClusterHealthStatus.fromValue(in.readByte());
76+
waitForStatus = ClusterHealthStatus.readFrom(in);
7777
}
7878
waitForNoRelocatingShards = in.readBoolean();
7979
waitForActiveShards = ActiveShardCount.readFrom(in);

server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public ClusterHealthResponse() {}
147147
public ClusterHealthResponse(StreamInput in) throws IOException {
148148
super(in);
149149
clusterName = in.readString();
150-
clusterHealthStatus = ClusterHealthStatus.fromValue(in.readByte());
150+
clusterHealthStatus = ClusterHealthStatus.readFrom(in);
151151
clusterStateHealth = new ClusterStateHealth(in);
152152
numberOfPendingTasks = in.readInt();
153153
timedOut = in.readBoolean();

server/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsNodeResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public ClusterStatsNodeResponse(StreamInput in) throws IOException {
4242
super(in);
4343
clusterStatus = null;
4444
if (in.readBoolean()) {
45-
clusterStatus = ClusterHealthStatus.fromValue(in.readByte());
45+
clusterStatus = ClusterHealthStatus.readFrom(in);
4646
}
4747
this.nodeInfo = new NodeInfo(in);
4848
this.nodeStats = new NodeStats(in);

server/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public IndicesShardStoresRequest(StreamInput in) throws IOException {
5555
int nStatus = in.readVInt();
5656
statuses = EnumSet.noneOf(ClusterHealthStatus.class);
5757
for (int i = 0; i < nStatus; i++) {
58-
statuses.add(ClusterHealthStatus.fromValue(in.readByte()));
58+
statuses.add(ClusterHealthStatus.readFrom(in));
5959
}
6060
indicesOptions = IndicesOptions.readIndicesOptions(in);
6161
}

server/src/main/java/org/elasticsearch/cluster/health/ClusterHealthStatus.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ public void writeTo(StreamOutput out) throws IOException {
5252
* @throws IllegalArgumentException if the value is unrecognized
5353
*/
5454
public static ClusterHealthStatus readFrom(StreamInput in) throws IOException {
55-
return fromValue(in.readByte());
56-
}
57-
58-
public static ClusterHealthStatus fromValue(byte value) throws IOException {
55+
byte value = in.readByte();
5956
switch (value) {
6057
case 0:
6158
return GREEN;

server/src/main/java/org/elasticsearch/cluster/health/ClusterIndexHealth.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public ClusterIndexHealth(final StreamInput in) throws IOException {
165165
relocatingShards = in.readVInt();
166166
initializingShards = in.readVInt();
167167
unassignedShards = in.readVInt();
168-
status = ClusterHealthStatus.fromValue(in.readByte());
168+
status = ClusterHealthStatus.readFrom(in);
169169

170170
int size = in.readVInt();
171171
shards = new HashMap<>(size);

server/src/main/java/org/elasticsearch/cluster/health/ClusterShardHealth.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public ClusterShardHealth(final int shardId, final IndexShardRoutingTable shardR
121121

122122
public ClusterShardHealth(final StreamInput in) throws IOException {
123123
shardId = in.readVInt();
124-
status = ClusterHealthStatus.fromValue(in.readByte());
124+
status = ClusterHealthStatus.readFrom(in);
125125
activeShards = in.readVInt();
126126
relocatingShards = in.readVInt();
127127
initializingShards = in.readVInt();

server/src/main/java/org/elasticsearch/cluster/health/ClusterStateHealth.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public ClusterStateHealth(final StreamInput in) throws IOException {
134134
unassignedShards = in.readVInt();
135135
numberOfNodes = in.readVInt();
136136
numberOfDataNodes = in.readVInt();
137-
status = ClusterHealthStatus.fromValue(in.readByte());
137+
status = ClusterHealthStatus.readFrom(in);
138138
int size = in.readVInt();
139139
indices = new HashMap<>(size);
140140
for (int i = 0; i < size; i++) {

0 commit comments

Comments
 (0)