Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions core/src/main/java/org/elasticsearch/cluster/ClusterState.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,7 @@ public static void registerPrototype(String type, Custom proto) {
registerPrototype(RestoreInProgress.TYPE, RestoreInProgress.PROTO);
}

@Nullable
public static <T extends Custom> T lookupPrototype(String type) {
//noinspection unchecked
return (T) customPrototypes.get(type);
}

public static <T extends Custom> T lookupPrototypeSafe(String type) {
@SuppressWarnings("unchecked")
T proto = (T) customPrototypes.get(type);
if (proto == null) {
Expand Down Expand Up @@ -308,7 +302,7 @@ public enum Metric {

private final String value;

private Metric(String value) {
Metric(String value) {
this.value = value;
}

Expand Down Expand Up @@ -630,10 +624,6 @@ public Builder stateUUID(String uuid) {
return this;
}

public Custom getCustom(String type) {
return customs.get(type);
}

public Builder putCustom(String type, Custom custom) {
customs.put(type, custom);
return this;
Expand Down Expand Up @@ -707,7 +697,7 @@ public ClusterState readFrom(StreamInput in, DiscoveryNode localNode) throws IOE
int customSize = in.readVInt();
for (int i = 0; i < customSize; i++) {
String type = in.readString();
Custom customIndexMetaData = lookupPrototypeSafe(type).readFrom(in);
Custom customIndexMetaData = lookupPrototype(type).readFrom(in);
builder.putCustom(type, customIndexMetaData);
}
return builder.build();
Expand Down Expand Up @@ -779,12 +769,12 @@ public ClusterStateDiff(StreamInput in, ClusterState proto) throws IOException {
new DiffableUtils.DiffableValueSerializer<String, Custom>() {
@Override
public Custom read(StreamInput in, String key) throws IOException {
return lookupPrototypeSafe(key).readFrom(in);
return lookupPrototype(key).readFrom(in);
}

@Override
public Diff<Custom> readDiff(StreamInput in, String key) throws IOException {
return lookupPrototypeSafe(key).readDiffFrom(in);
return lookupPrototype(key).readDiffFrom(in);
}
});
}
Expand Down