|
|
@@ -24,6 +24,7 @@ import org.elasticsearch.common.Nullable;
|
|
|
import org.elasticsearch.common.io.stream.StreamInput;
|
|
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
|
import org.elasticsearch.common.io.stream.Streamable;
|
|
|
+import org.elasticsearch.common.io.stream.Writeable;
|
|
|
import org.elasticsearch.common.xcontent.ToXContentFragment;
|
|
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
|
import org.elasticsearch.rest.RestStatus;
|
|
|
@@ -34,7 +35,7 @@ import java.util.EnumSet;
|
|
|
import java.util.Locale;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
-public class ClusterBlock implements Streamable, ToXContentFragment {
|
|
|
+public class ClusterBlock implements Streamable, Writeable, ToXContentFragment {
|
|
|
|
|
|
private int id;
|
|
|
private @Nullable String uuid;
|
|
|
@@ -45,7 +46,24 @@ public class ClusterBlock implements Streamable, ToXContentFragment {
|
|
|
private boolean allowReleaseResources;
|
|
|
private RestStatus status;
|
|
|
|
|
|
- private ClusterBlock() {
|
|
|
+ public ClusterBlock(StreamInput in) throws IOException {
|
|
|
+ id = in.readVInt();
|
|
|
+ if (in.getVersion().onOrAfter(Version.V_6_7_0)) {
|
|
|
+ uuid = in.readOptionalString();
|
|
|
+ } else {
|
|
|
+ uuid = null;
|
|
|
+ }
|
|
|
+ description = in.readString();
|
|
|
+ final int len = in.readVInt();
|
|
|
+ ArrayList<ClusterBlockLevel> levels = new ArrayList<>(len);
|
|
|
+ for (int i = 0; i < len; i++) {
|
|
|
+ levels.add(in.readEnum(ClusterBlockLevel.class));
|
|
|
+ }
|
|
|
+ this.levels = EnumSet.copyOf(levels);
|
|
|
+ retryable = in.readBoolean();
|
|
|
+ disableStatePersistence = in.readBoolean();
|
|
|
+ status = RestStatus.readFrom(in);
|
|
|
+ allowReleaseResources = in.readBoolean();
|
|
|
}
|
|
|
|
|
|
public ClusterBlock(int id, String description, boolean retryable, boolean disableStatePersistence,
|
|
|
@@ -129,31 +147,9 @@ public class ClusterBlock implements Streamable, ToXContentFragment {
|
|
|
return builder;
|
|
|
}
|
|
|
|
|
|
- public static ClusterBlock readClusterBlock(StreamInput in) throws IOException {
|
|
|
- ClusterBlock block = new ClusterBlock();
|
|
|
- block.readFrom(in);
|
|
|
- return block;
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public void readFrom(StreamInput in) throws IOException {
|
|
|
- id = in.readVInt();
|
|
|
- if (in.getVersion().onOrAfter(Version.V_6_7_0)) {
|
|
|
- uuid = in.readOptionalString();
|
|
|
- } else {
|
|
|
- uuid = null;
|
|
|
- }
|
|
|
- description = in.readString();
|
|
|
- final int len = in.readVInt();
|
|
|
- ArrayList<ClusterBlockLevel> levels = new ArrayList<>(len);
|
|
|
- for (int i = 0; i < len; i++) {
|
|
|
- levels.add(in.readEnum(ClusterBlockLevel.class));
|
|
|
- }
|
|
|
- this.levels = EnumSet.copyOf(levels);
|
|
|
- retryable = in.readBoolean();
|
|
|
- disableStatePersistence = in.readBoolean();
|
|
|
- status = RestStatus.readFrom(in);
|
|
|
- allowReleaseResources = in.readBoolean();
|
|
|
+ throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
|
|
|
}
|
|
|
|
|
|
@Override
|