Skip to content

Commit

Permalink
Remove some unused code
Browse files Browse the repository at this point in the history
Signed-off-by: Gao Binlong <[email protected]>
  • Loading branch information
gaobinlong committed Mar 15, 2024
1 parent bc44f08 commit f8539ee
Showing 1 changed file with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
package org.opensearch.action.admin.indices.forcemerge;

import org.opensearch.Version;
import org.opensearch.action.support.IndicesOptions;
import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.tasks.TaskId;
import org.opensearch.test.OpenSearchTestCase;
import org.opensearch.test.VersionUtils;

Expand Down Expand Up @@ -100,20 +102,26 @@ public void testBwcSerialization() throws Exception {
out.setVersion(compatibleVersion);
sample.writeTo(out);

final ForceMergeRequest deserializedRequest;
try (StreamInput in = out.bytes().streamInput()) {
in.setVersion(Version.CURRENT);
deserializedRequest = new ForceMergeRequest(in);
}

assertEquals(sample.maxNumSegments(), deserializedRequest.maxNumSegments());
assertEquals(sample.onlyExpungeDeletes(), deserializedRequest.onlyExpungeDeletes());
assertEquals(sample.flush(), deserializedRequest.flush());
if (compatibleVersion.onOrAfter(Version.V_2_13_0)) {
assertEquals(sample.primaryOnly(), deserializedRequest.primaryOnly());
TaskId.readFromStream(in);
in.readStringArray();
IndicesOptions.readIndicesOptions(in);
int maxNumSegments = in.readInt();
boolean onlyExpungeDeletes = in.readBoolean();
boolean flush = in.readBoolean();
boolean primaryOnly = in.readBoolean();
String forceMergeUUID;
if (compatibleVersion.onOrAfter(Version.V_3_0_0)) {
assertEquals(sample.forceMergeUUID(), deserializedRequest.forceMergeUUID());
forceMergeUUID = in.readString();
} else {
forceMergeUUID = in.readOptionalString();
}
assertEquals(sample.maxNumSegments(), maxNumSegments);
assertEquals(sample.onlyExpungeDeletes(), onlyExpungeDeletes);
assertEquals(sample.flush(), flush);
assertEquals(sample.primaryOnly(), primaryOnly);
assertEquals(sample.forceMergeUUID(), forceMergeUUID);
}
}
}
Expand All @@ -129,9 +137,7 @@ public void testBwcSerialization() throws Exception {
out.writeInt(sample.maxNumSegments());
out.writeBoolean(sample.onlyExpungeDeletes());
out.writeBoolean(sample.flush());
if (compatibleVersion.onOrAfter(Version.V_2_13_0)) {
out.writeBoolean(sample.primaryOnly());
}
out.writeBoolean(sample.primaryOnly());
if (compatibleVersion.onOrAfter(Version.V_3_0_0)) {
out.writeString(sample.forceMergeUUID());
} else {
Expand All @@ -149,7 +155,6 @@ public void testBwcSerialization() throws Exception {
assertEquals(sample.flush(), deserializedRequest.flush());
assertEquals(sample.primaryOnly(), deserializedRequest.primaryOnly());
assertEquals(sample.forceMergeUUID(), deserializedRequest.forceMergeUUID());

}
}
}
Expand Down

0 comments on commit f8539ee

Please sign in to comment.