-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Internal: Add support for sending cluster state using diffs #9220
Changes from all commits
a2b2d54
093c12f
2623344
51712e4
dceedd0
b671b59
c1e9111
357343d
ef4d604
7f9477d
474bcae
188da91
afab5d2
eb8a4e7
66b9dfd
a000e81
c02ed4a
4f7b5ed
447fce4
0416151
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,7 +55,7 @@ public ClusterName getClusterName() { | |
public void readFrom(StreamInput in) throws IOException { | ||
super.readFrom(in); | ||
clusterName = ClusterName.readClusterName(in); | ||
clusterState = ClusterState.Builder.readFrom(in, null, clusterName); | ||
clusterState = ClusterState.Builder.readFrom(in, null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe it's more intuitive to have a |
||
} | ||
|
||
@Override | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,8 @@ | |
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; | ||
import org.elasticsearch.action.support.IndicesOptions; | ||
import org.elasticsearch.action.support.master.MasterNodeOperationRequest; | ||
import org.elasticsearch.cluster.ClusterStatePart; | ||
import org.elasticsearch.cluster.metadata.IndexClusterStatePart; | ||
import org.elasticsearch.cluster.metadata.IndexMetaData; | ||
import org.elasticsearch.common.bytes.BytesArray; | ||
import org.elasticsearch.common.bytes.BytesReference; | ||
|
@@ -71,7 +73,7 @@ public class PutIndexTemplateRequest extends MasterNodeOperationRequest<PutIndex | |
|
||
private final Set<Alias> aliases = newHashSet(); | ||
|
||
private Map<String, IndexMetaData.Custom> customs = newHashMap(); | ||
private Map<String, IndexClusterStatePart> customs = newHashMap(); | ||
|
||
PutIndexTemplateRequest() { | ||
} | ||
|
@@ -294,10 +296,10 @@ public PutIndexTemplateRequest source(Map templateSource) { | |
aliases((Map<String, Object>) entry.getValue()); | ||
} else { | ||
// maybe custom? | ||
IndexMetaData.Custom.Factory factory = IndexMetaData.lookupFactory(name); | ||
ClusterStatePart.Factory<IndexClusterStatePart> factory = IndexMetaData.FACTORY.lookupFactory(name); | ||
if (factory != null) { | ||
try { | ||
customs.put(name, factory.fromMap((Map<String, Object>) entry.getValue())); | ||
customs.put(name, factory.fromMap((Map<String, Object>) entry.getValue(), null)); | ||
} catch (IOException e) { | ||
throw new ElasticsearchParseException("failed to parse custom metadata for [" + name + "]"); | ||
} | ||
|
@@ -347,12 +349,12 @@ public PutIndexTemplateRequest source(BytesReference source) { | |
} | ||
} | ||
|
||
public PutIndexTemplateRequest custom(IndexMetaData.Custom custom) { | ||
customs.put(custom.type(), custom); | ||
public PutIndexTemplateRequest custom(IndexClusterStatePart custom) { | ||
customs.put(custom.partType(), custom); | ||
return this; | ||
} | ||
|
||
Map<String, IndexMetaData.Custom> customs() { | ||
Map<String, IndexClusterStatePart> customs() { | ||
return this.customs; | ||
} | ||
|
||
|
@@ -442,7 +444,7 @@ public void readFrom(StreamInput in) throws IOException { | |
int customSize = in.readVInt(); | ||
for (int i = 0; i < customSize; i++) { | ||
String type = in.readString(); | ||
IndexMetaData.Custom customIndexMetaData = IndexMetaData.lookupFactorySafe(type).readFrom(in); | ||
IndexClusterStatePart customIndexMetaData = IndexMetaData.FACTORY.lookupFactorySafe(type).readFrom(in, null); | ||
customs.put(type, customIndexMetaData); | ||
} | ||
int aliasesSize = in.readVInt(); | ||
|
@@ -466,9 +468,12 @@ public void writeTo(StreamOutput out) throws IOException { | |
out.writeString(entry.getValue()); | ||
} | ||
out.writeVInt(customs.size()); | ||
for (Map.Entry<String, IndexMetaData.Custom> entry : customs.entrySet()) { | ||
out.writeString(entry.getKey()); | ||
IndexMetaData.lookupFactorySafe(entry.getKey()).writeTo(entry.getValue(), out); | ||
for (Map.Entry<String, IndexClusterStatePart> entry : customs.entrySet()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have seen this loop twice maybe we can have a utility method for this? |
||
IndexClusterStatePart.Factory<IndexClusterStatePart> factory = IndexMetaData.FACTORY.lookupFactorySafe(entry.getKey()); | ||
if(factory.addedIn().onOrAfter(out.getVersion())) { | ||
out.writeString(entry.getKey()); | ||
factory.writeTo(entry.getValue(), out); | ||
} | ||
} | ||
out.writeVInt(aliases.size()); | ||
for (Alias alias : aliases) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why this was removed?