Skip to content

Commit 3f6ad3e

Browse files
authored
Move shutdown component status out into separate classes (elastic#72653)
Originally these were stored in the cluster state using a single class, however, they will need to be different objects without common parts, and they will be calculated on the fly rather than persisted into cluster state. This removes the NodeShutdownComponentStatus class, as its no longer needed. Relates to elastic#70338
1 parent c1c5e67 commit 3f6ad3e

File tree

10 files changed

+376
-319
lines changed

10 files changed

+376
-319
lines changed

server/src/main/java/org/elasticsearch/cluster/metadata/NodeShutdownComponentStatus.java

Lines changed: 0 additions & 124 deletions
This file was deleted.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
package org.elasticsearch.cluster.metadata;
10+
11+
import org.elasticsearch.common.Strings;
12+
import org.elasticsearch.common.io.stream.StreamInput;
13+
import org.elasticsearch.common.io.stream.StreamOutput;
14+
import org.elasticsearch.common.io.stream.Writeable;
15+
import org.elasticsearch.common.xcontent.ToXContentObject;
16+
import org.elasticsearch.common.xcontent.XContentBuilder;
17+
18+
import java.io.IOException;
19+
20+
public class ShutdownPersistentTasksStatus implements Writeable, ToXContentObject {
21+
22+
private final SingleNodeShutdownMetadata.Status status;
23+
24+
public ShutdownPersistentTasksStatus() {
25+
this.status = SingleNodeShutdownMetadata.Status.IN_PROGRESS;
26+
}
27+
28+
public ShutdownPersistentTasksStatus(StreamInput in) throws IOException {
29+
this.status = SingleNodeShutdownMetadata.Status.IN_PROGRESS;
30+
}
31+
32+
@Override
33+
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
34+
builder.startObject();
35+
builder.field("status", status);
36+
builder.endObject();
37+
return builder;
38+
}
39+
40+
@Override
41+
public void writeTo(StreamOutput out) throws IOException {
42+
43+
}
44+
45+
@Override
46+
public int hashCode() {
47+
return status.hashCode();
48+
}
49+
50+
@Override
51+
public boolean equals(Object obj) {
52+
if (obj == null) {
53+
return false;
54+
}
55+
if (getClass() != obj.getClass()) {
56+
return false;
57+
}
58+
ShutdownPersistentTasksStatus other = (ShutdownPersistentTasksStatus) obj;
59+
return status.equals(other.status);
60+
}
61+
62+
@Override
63+
public String toString() {
64+
return Strings.toString(this);
65+
}
66+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
package org.elasticsearch.cluster.metadata;
10+
11+
import org.elasticsearch.common.Strings;
12+
import org.elasticsearch.common.io.stream.StreamInput;
13+
import org.elasticsearch.common.io.stream.StreamOutput;
14+
import org.elasticsearch.common.io.stream.Writeable;
15+
import org.elasticsearch.common.xcontent.ToXContentObject;
16+
import org.elasticsearch.common.xcontent.XContentBuilder;
17+
18+
import java.io.IOException;
19+
20+
public class ShutdownPluginsStatus implements Writeable, ToXContentObject {
21+
22+
private final SingleNodeShutdownMetadata.Status status;
23+
24+
public ShutdownPluginsStatus() {
25+
this.status = SingleNodeShutdownMetadata.Status.IN_PROGRESS;
26+
}
27+
28+
public ShutdownPluginsStatus(StreamInput in) throws IOException {
29+
this.status = SingleNodeShutdownMetadata.Status.IN_PROGRESS;
30+
}
31+
32+
@Override
33+
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
34+
builder.startObject();
35+
builder.field("status", status);
36+
builder.endObject();
37+
return builder;
38+
}
39+
40+
@Override
41+
public void writeTo(StreamOutput out) throws IOException {
42+
43+
}
44+
45+
@Override
46+
public int hashCode() {
47+
return status.hashCode();
48+
}
49+
50+
@Override
51+
public boolean equals(Object obj) {
52+
if (obj == null) {
53+
return false;
54+
}
55+
if (getClass() != obj.getClass()) {
56+
return false;
57+
}
58+
ShutdownPluginsStatus other = (ShutdownPluginsStatus) obj;
59+
return status.equals(other.status);
60+
}
61+
62+
@Override
63+
public String toString() {
64+
return Strings.toString(this);
65+
}
66+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
package org.elasticsearch.cluster.metadata;
10+
11+
import org.elasticsearch.common.Strings;
12+
import org.elasticsearch.common.io.stream.StreamInput;
13+
import org.elasticsearch.common.io.stream.StreamOutput;
14+
import org.elasticsearch.common.io.stream.Writeable;
15+
import org.elasticsearch.common.xcontent.ToXContentObject;
16+
import org.elasticsearch.common.xcontent.XContentBuilder;
17+
18+
import java.io.IOException;
19+
20+
public class ShutdownShardMigrationStatus implements Writeable, ToXContentObject {
21+
22+
private final SingleNodeShutdownMetadata.Status status;
23+
24+
public ShutdownShardMigrationStatus() {
25+
this.status = SingleNodeShutdownMetadata.Status.IN_PROGRESS;
26+
}
27+
28+
public ShutdownShardMigrationStatus(StreamInput in) throws IOException {
29+
this.status = SingleNodeShutdownMetadata.Status.IN_PROGRESS;
30+
}
31+
32+
@Override
33+
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
34+
builder.startObject();
35+
builder.field("status", status);
36+
builder.endObject();
37+
return builder;
38+
}
39+
40+
@Override
41+
public void writeTo(StreamOutput out) throws IOException {
42+
43+
}
44+
45+
@Override
46+
public int hashCode() {
47+
return status.hashCode();
48+
}
49+
50+
@Override
51+
public boolean equals(Object obj) {
52+
if (obj == null) {
53+
return false;
54+
}
55+
if (getClass() != obj.getClass()) {
56+
return false;
57+
}
58+
ShutdownShardMigrationStatus other = (ShutdownShardMigrationStatus) obj;
59+
return status.equals(other.status);
60+
}
61+
62+
@Override
63+
public String toString() {
64+
return Strings.toString(this);
65+
}
66+
}

0 commit comments

Comments
 (0)