Reset Priority values

For historical reasons, the value associated with Priority.IMMEDIATE is
-1. Yet, with a full-cluster restart required on major version upgrades,
we can reset these values so they are conceptually simpler. This commit
resets the values associated with Priority instances.
This commit is contained in:
Jason Tedor 2016-07-15 09:34:04 -04:00
parent 220a510d65
commit 917fea7c5d
2 changed files with 18 additions and 18 deletions

View File

@ -26,12 +26,12 @@ import java.io.IOException;
public enum Priority {
IMMEDIATE((byte) -1),
URGENT((byte) 0),
HIGH((byte) 1),
NORMAL((byte) 2),
LOW((byte) 3),
LANGUID((byte) 4);
IMMEDIATE((byte) 0),
URGENT((byte) 1),
HIGH((byte) 2),
NORMAL((byte) 3),
LOW((byte) 4),
LANGUID((byte) 5);
public static Priority readFrom(StreamInput input) throws IOException {
return fromByte(input.readByte());
@ -43,12 +43,12 @@ public enum Priority {
public static Priority fromByte(byte b) {
switch (b) {
case -1: return IMMEDIATE;
case 0: return URGENT;
case 1: return HIGH;
case 2: return NORMAL;
case 3: return LOW;
case 4: return LANGUID;
case 0: return IMMEDIATE;
case 1: return URGENT;
case 2: return HIGH;
case 3: return NORMAL;
case 4: return LOW;
case 5: return LANGUID;
default:
throw new IllegalArgumentException("can't find priority for [" + b + "]");
}

View File

@ -56,12 +56,12 @@ public class PriorityTests extends ESTestCase {
Priority priority = Priority.readFrom(out.bytes().streamInput());
assertSame(p, priority);
}
assertSame(Priority.IMMEDIATE, Priority.fromByte((byte) -1));
assertSame(Priority.HIGH, Priority.fromByte((byte) 1));
assertSame(Priority.LANGUID, Priority.fromByte((byte) 4));
assertSame(Priority.LOW, Priority.fromByte((byte) 3));
assertSame(Priority.NORMAL, Priority.fromByte((byte) 2));
assertSame(Priority.URGENT,Priority.fromByte((byte) 0));
assertSame(Priority.IMMEDIATE, Priority.fromByte((byte) 0));
assertSame(Priority.HIGH, Priority.fromByte((byte) 2));
assertSame(Priority.LANGUID, Priority.fromByte((byte) 5));
assertSame(Priority.LOW, Priority.fromByte((byte) 4));
assertSame(Priority.NORMAL, Priority.fromByte((byte) 3));
assertSame(Priority.URGENT,Priority.fromByte((byte) 1));
assertEquals(6, Priority.values().length);
}