@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); cause = in.readString(); index = in.readString(); settings = readSettingsFromStream(in); readTimeout(in); int size = in.readVInt(); for (int i = 0; i < size; i++) { mappings.put(in.readString(), in.readString()); } int customSize = in.readVInt(); for (int i = 0; i < customSize; i++) { String type = in.readString(); IndexMetaData.Custom customIndexMetaData = IndexMetaData.lookupPrototypeSafe(type).readFrom(in); customs.put(type, customIndexMetaData); } int aliasesSize = in.readVInt(); for (int i = 0; i < aliasesSize; i++) { aliases.add(Alias.read(in)); } updateAllTypes = in.readBoolean(); waitForActiveShards = ActiveShardCount.readFrom(in); }
/** Sets the aliases that will be associated with the index when it gets created */ public CreateIndexRequest aliases(BytesReference source) { try (XContentParser parser = XContentHelper.createParser(source)) { // move to the first alias parser.nextToken(); while ((parser.nextToken()) != XContentParser.Token.END_OBJECT) { alias(Alias.fromXContent(parser)); } return this; } catch (IOException e) { throw new ElasticsearchParseException("Failed to parse aliases", e); } }
@Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeString(cause); out.writeString(index); writeSettingsToStream(settings, out); writeTimeout(out); out.writeVInt(mappings.size()); for (Map.Entry<String, String> entry : mappings.entrySet()) { out.writeString(entry.getKey()); out.writeString(entry.getValue()); } out.writeVInt(customs.size()); for (Map.Entry<String, IndexMetaData.Custom> entry : customs.entrySet()) { out.writeString(entry.getKey()); entry.getValue().writeTo(out); } out.writeVInt(aliases.size()); for (Alias alias : aliases) { alias.writeTo(out); } out.writeBoolean(updateAllTypes); waitForActiveShards.writeTo(out); }