Fixed serialization error. POST_RECOVERY is now also serialized

This commit is contained in:
Martijn van Groningen 2013-10-10 16:15:33 +02:00
parent ec809200f0
commit 1792bd6b16
1 changed files with 11 additions and 11 deletions

View File

@ -32,6 +32,14 @@ public enum IndexShardState {
RELOCATED((byte) 4),
CLOSED((byte) 5);
private static final IndexShardState[] ORDS = new IndexShardState[IndexShardState.values().length];
static {
for (IndexShardState state : IndexShardState.values()) {
ORDS[state.id()] = state;
}
}
private final byte id;
IndexShardState(byte id) {
@ -43,17 +51,9 @@ public enum IndexShardState {
}
public static IndexShardState fromId(byte id) throws ElasticSearchIllegalArgumentException {
if (id == 0) {
return CREATED;
} else if (id == 1) {
return RECOVERING;
} else if (id == 2) {
return STARTED;
} else if (id == 3) {
return RELOCATED;
} else if (id == 4) {
return CLOSED;
}
if (id < ORDS[0].id && id > ORDS[ORDS.length - 1].id) {
throw new ElasticSearchIllegalArgumentException("No mapping for id [" + id + "]");
}
return ORDS[id];
}
}