-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add DecommissionService and helper to execute awareness attribute decommissioning #4084
Changes from 115 commits
346f194
4ad7ad1
223aceb
65b2c0c
5cc0a08
2ce51e7
9c7c318
356061c
a9aaabf
2da5c3f
36cb1fd
315a510
3cd8116
84e4fc8
376da0d
333eb86
6040ef0
409ab6f
e99058a
4053e2c
6476581
a21b238
8d6e485
09d6417
01679f8
465c15e
9107861
26df730
a86d138
27564d9
1cc01ae
9558bfd
870190d
2ada94c
6537dc6
1fb0b0a
9f39b5c
f9e602b
4eb5a9c
7a9e843
3b985cf
f88cccb
fe717dd
67cf701
68a1c64
157fd54
c7c5efe
1d67fcc
0a35445
54c21d3
0621be7
cef61b8
e12a73d
f1866c7
49af3e4
a5a3b8d
d2fe876
12247c0
48101a1
fb508c1
d5f6ac0
ee407de
ccde356
cba7670
96ee70d
860d148
2451078
65414c1
add1786
b15b9ff
f9ba08d
251d81f
aa5d41b
c271693
b0a35da
0f9cdba
a738ab2
081f52a
fa8dafc
30c9415
6000243
68943b1
ee528e7
72a20f0
87ebc18
c25aab1
93afa98
6aacc5c
5842746
bf7e1a6
6711c95
a39a52e
d1392f1
881664b
e7701f7
40af043
0c123e2
b28c96a
8c62bb0
7e6f5eb
f77496a
bf7c2ec
377c6be
7b03b3e
9a2b11c
c144db6
ca17fed
c3b512b
e3b1eb9
7479b40
dc58265
890eef0
5ef1348
4921a79
b4de2c7
c2b6e38
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.cluster.decommission; | ||
|
||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
import org.opensearch.common.io.stream.Writeable; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
/** | ||
* {@link DecommissionAttribute} encapsulates information about decommissioned node attribute like attribute name, attribute value. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public final class DecommissionAttribute implements Writeable { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems to be a generic Attribute class, nothing specific to Decommissioning. Also in the code base today node level attributes are referenced using simple Map<String, String> would that suffice here as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added this attribute class for simplicity and clarity. This is helping the code become more readable. Also, in future if the user just wants to decommission a set of nodes with a particular attribute, we would be easily able to modify this class. Similarly, there could be multiple such cases There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still feel you don't need a new class for it, just need to store key/ value pair. |
||
private final String attributeName; | ||
private final String attributeValue; | ||
|
||
/** | ||
* Constructs new decommission attribute name value pair | ||
* | ||
* @param attributeName attribute name | ||
* @param attributeValue attribute value | ||
*/ | ||
public DecommissionAttribute(String attributeName, String attributeValue) { | ||
this.attributeName = attributeName; | ||
this.attributeValue = attributeValue; | ||
} | ||
|
||
/** | ||
* Returns attribute name | ||
* | ||
* @return attributeName | ||
*/ | ||
public String attributeName() { | ||
return this.attributeName; | ||
} | ||
|
||
/** | ||
* Returns attribute value | ||
* | ||
* @return attributeValue | ||
*/ | ||
public String attributeValue() { | ||
return this.attributeValue; | ||
} | ||
|
||
public DecommissionAttribute(StreamInput in) throws IOException { | ||
attributeName = in.readString(); | ||
attributeValue = in.readString(); | ||
} | ||
|
||
/** | ||
* Writes decommission attribute name value to stream output | ||
* | ||
* @param out stream output | ||
*/ | ||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeString(attributeName); | ||
out.writeString(attributeValue); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
DecommissionAttribute that = (DecommissionAttribute) o; | ||
|
||
if (!attributeName.equals(that.attributeName)) return false; | ||
return attributeValue.equals(that.attributeValue); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(attributeName, attributeValue); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "DecommissionAttribute{" + "attributeName='" + attributeName + '\'' + ", attributeValue='" + attributeValue + '\'' + '}'; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: DECOMMISSION_FAILED_EXCEPTION
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept it
DECOMMISSION_FAILED_EXCEPTION
but @shwetathareja suggested to change it toDECOMMISSIONING_FAILED_EXCEPTION