Skip to content
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

Remove redundant field from GetDecommissionStateResponse #4751

Merged
merged 12 commits into from
Oct 18, 2022
Prev Previous commit
Next Next commit
Fix spotless check
Signed-off-by: Rishab Nahata <rnnahata@amazon.com>
  • Loading branch information
imRishN committed Oct 17, 2022
commit 28e975099a6c8f4588931eb8b2596678693b4392
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
package org.opensearch.action.admin.cluster.decommission.awareness.get;

import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.admin.cluster.snapshots.status.SnapshotsStatusRequest;
import org.opensearch.action.support.clustermanager.ClusterManagerNodeReadRequest;
import org.opensearch.common.Strings;
import org.opensearch.common.io.stream.StreamInput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@

package org.opensearch.action.admin.cluster.decommission.awareness.get;

import org.opensearch.action.admin.cluster.decommission.awareness.put.DecommissionRequestBuilder;
import org.opensearch.action.support.clustermanager.ClusterManagerNodeReadOperationRequestBuilder;
import org.opensearch.client.OpenSearchClient;
import org.opensearch.cluster.decommission.DecommissionAttribute;

/**
* Get decommission request builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@

package org.opensearch.action.admin.cluster.decommission.awareness.get;

import org.apache.logging.log4j.util.Strings;
import org.opensearch.OpenSearchParseException;
import org.opensearch.action.ActionResponse;
import org.opensearch.cluster.decommission.DecommissionAttribute;
import org.opensearch.cluster.decommission.DecommissionStatus;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
Expand Down Expand Up @@ -91,9 +89,7 @@ public static GetDecommissionStateResponse fromXContent(XContentParser parser) t
if (token == XContentParser.Token.FIELD_NAME) {
attributeValue = parser.currentName();
if (parser.nextToken() != XContentParser.Token.VALUE_STRING) {
throw new OpenSearchParseException(
"failed to parse status of decommissioning, expected string but found unknown type"
);
throw new OpenSearchParseException("failed to parse status of decommissioning, expected string but found unknown type");
}
status = DecommissionStatus.fromString(parser.text().toLowerCase(Locale.ROOT));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.opensearch.cluster.decommission.DecommissionAttributeMetadata;
import org.opensearch.cluster.metadata.IndexNameExpressionResolver;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.Strings;
import org.opensearch.common.inject.Inject;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.threadpool.ThreadPool;
Expand Down Expand Up @@ -70,7 +69,8 @@ protected void clusterManagerOperation(
ActionListener<GetDecommissionStateResponse> listener
) throws Exception {
DecommissionAttributeMetadata decommissionAttributeMetadata = state.metadata().decommissionAttributeMetadata();
if (decommissionAttributeMetadata != null && request.attributeName().equals(decommissionAttributeMetadata.decommissionAttribute().attributeName())) {
if (decommissionAttributeMetadata != null
&& request.attributeName().equals(decommissionAttributeMetadata.decommissionAttribute().attributeName())) {
listener.onResponse(
new GetDecommissionStateResponse(
decommissionAttributeMetadata.decommissionAttribute().attributeValue(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ public class GetDecommissionStateRequestTests extends OpenSearchTestCase {
public void testSerialization() throws IOException {
String attributeName = "zone";
final GetDecommissionStateRequest originalRequest = new GetDecommissionStateRequest(attributeName);
final GetDecommissionStateRequest deserialized = copyWriteable(originalRequest, writableRegistry(), GetDecommissionStateRequest::new);
final GetDecommissionStateRequest deserialized = copyWriteable(
originalRequest,
writableRegistry(),
GetDecommissionStateRequest::new
);
assertEquals(deserialized.attributeName(), originalRequest.attributeName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

package org.opensearch.action.admin.cluster.decommission.awareness.get;

import org.opensearch.cluster.decommission.DecommissionAttribute;
import org.opensearch.cluster.decommission.DecommissionStatus;
import org.opensearch.common.xcontent.XContentParser;
import org.opensearch.test.AbstractXContentTestCase;
Expand Down