Fix ClusterBlock serialization and Close Index API logic after backport to 6.x (#37360)

This commit changes the versions in the serialization logic of ClusterBlock 
after the backport to 6.x of the Close Index API refactoring (#37359).
This commit is contained in:
Tanguy Leroux 2019-01-14 13:13:15 +01:00 committed by GitHub
parent 87f9148580
commit 6ca076bf74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -138,7 +138,7 @@ public class ClusterBlock implements Streamable, ToXContentFragment {
@Override
public void readFrom(StreamInput in) throws IOException {
id = in.readVInt();
if (in.getVersion().onOrAfter(Version.V_7_0_0)) {
if (in.getVersion().onOrAfter(Version.V_6_7_0)) {
uuid = in.readOptionalString();
} else {
uuid = null;
@ -159,7 +159,7 @@ public class ClusterBlock implements Streamable, ToXContentFragment {
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(id);
if (out.getVersion().onOrAfter(Version.V_7_0_0)) {
if (out.getVersion().onOrAfter(Version.V_6_7_0)) {
out.writeOptionalString(uuid);
}
out.writeString(description);

View File

@ -225,7 +225,7 @@ public class MetaDataIndexStateService {
// If the cluster is in a mixed version that does not support the shard close action,
// we use the previous way to close indices and directly close them without sanity checks
final boolean useDirectClose = currentState.nodes().getMinNodeVersion().before(Version.V_7_0_0);
final boolean useDirectClose = currentState.nodes().getMinNodeVersion().before(Version.V_6_7_0);
final ClusterBlocks.Builder blocks = ClusterBlocks.builder().blocks(currentState.blocks());
final RoutingTable.Builder routingTable = RoutingTable.builder(currentState.routingTable());

View File

@ -65,7 +65,7 @@ public class ClusterBlockTests extends ESTestCase {
public void testBwcSerialization() throws Exception {
for (int runs = 0; runs < randomIntBetween(5, 20); runs++) {
// Generate a random cluster block in version < 7.0.0
final Version version = randomVersionBetween(random(), Version.V_6_0_0, getPreviousVersion(Version.V_7_0_0));
final Version version = randomVersionBetween(random(), Version.V_6_0_0, getPreviousVersion(Version.V_6_7_0));
final ClusterBlock expected = randomClusterBlock(version);
assertNull(expected.uuid());
@ -84,7 +84,7 @@ public class ClusterBlockTests extends ESTestCase {
// Serialize to node in version < 7.0.0
final BytesStreamOutput out = new BytesStreamOutput();
out.setVersion(randomVersionBetween(random(), Version.V_6_0_0, getPreviousVersion(Version.V_7_0_0)));
out.setVersion(randomVersionBetween(random(), Version.V_6_0_0, getPreviousVersion(Version.V_6_7_0)));
expected.writeTo(out);
// Deserialize and check the cluster block
@ -171,7 +171,7 @@ public class ClusterBlockTests extends ESTestCase {
}
private ClusterBlock randomClusterBlock(final Version version) {
final String uuid = (version.onOrAfter(Version.V_7_0_0) && randomBoolean()) ? UUIDs.randomBase64UUID() : null;
final String uuid = (version.onOrAfter(Version.V_6_7_0) && randomBoolean()) ? UUIDs.randomBase64UUID() : null;
final List<ClusterBlockLevel> levels = Arrays.asList(ClusterBlockLevel.values());
return new ClusterBlock(randomInt(), uuid, "cluster block #" + randomInt(), randomBoolean(), randomBoolean(), randomBoolean(),
randomFrom(RestStatus.values()), copyOf(randomSubsetOf(randomIntBetween(1, levels.size()), levels)));