tmpImdBuilder.setRoutingNumShards(routingNumShards); tmpImdBuilder.settings(actualIndexSettings); .max() .getAsLong(); for (int shardId = 0; shardId < tmpImdBuilder.numberOfShards(); shardId++) { tmpImdBuilder.primaryTerm(shardId, primaryTerm); final IndexMetaData tmpImd = tmpImdBuilder.build(); ActiveShardCount waitForActiveShards = request.waitForActiveShards(); if (waitForActiveShards == ActiveShardCount.DEFAULT) { .settings(actualIndexSettings) .setRoutingNumShards(routingNumShards); indexMetaDataBuilder.primaryTerm(shardId, tmpImd.primaryTerm(shardId)); indexMetaDataBuilder.putMapping(mappingMd); indexMetaDataBuilder.putAlias(aliasMetaData); indexMetaDataBuilder.putAlias(aliasMetaData); indexMetaDataBuilder.putCustom(customEntry.getKey(), customEntry.getValue()); indexMetaDataBuilder.state(request.state()); indexMetaData = indexMetaDataBuilder.build();
} else if ("indices".equals(currentFieldName)) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { builder.put(IndexMetaData.Builder.fromXContent(parser), false);
Builder builder = new Builder(parser.currentName()); } else if (token == XContentParser.Token.START_OBJECT) { if (KEY_SETTINGS.equals(currentFieldName)) { builder.settings(Settings.fromXContent(parser)); } else if (KEY_MAPPINGS.equals(currentFieldName)) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { Map<String, Object> mappingSource = MapBuilder.<String, Object>newMapBuilder().put(mappingType, parser.mapOrdered()).map(); builder.putMapping(new MappingMetaData(mappingType, mappingSource)); } else { throw new IllegalArgumentException("Unexpected token: " + token); builder.putAlias(AliasMetaData.Builder.fromXContent(parser)); builder.putInSyncAllocationIds(Integer.valueOf(shardId), allocationIds); } else { throw new IllegalArgumentException("Unexpected token: " + token); currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_OBJECT) { builder.putRolloverInfo(RolloverInfo.parse(parser, currentFieldName)); } else { throw new IllegalArgumentException("Unexpected token: " + token); builder.putCustom(currentFieldName, parser.mapStrings()); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
.max() .getAsLong(); for (int shardId = 0; shardId < tmpImdBuilder.numberOfShards(); shardId++) { tmpImdBuilder.primaryTerm(shardId, primaryTerm); indexMetaDataBuilder.putMapping(mappingMd); indexMetaDataBuilder.putAlias(aliasMetaData); .indexRouting(alias.indexRouting()).searchRouting(alias.searchRouting()).writeIndex(alias.writeIndex()).build(); indexMetaDataBuilder.putAlias(aliasMetaData); indexMetaDataBuilder.putCustom(customEntry.getKey(), customEntry.getValue());
tmpImdBuilder.setRoutingNumShards(routingNumShards); tmpImdBuilder.settings(actualIndexSettings); .max() .getAsLong(); for (int shardId = 0; shardId < tmpImdBuilder.numberOfShards(); shardId++) { tmpImdBuilder.primaryTerm(shardId, primaryTerm); final IndexMetaData tmpImd = tmpImdBuilder.build(); ActiveShardCount waitForActiveShards = request.waitForActiveShards(); if (waitForActiveShards == ActiveShardCount.DEFAULT) { .settings(actualIndexSettings) .setRoutingNumShards(routingNumShards); indexMetaDataBuilder.primaryTerm(shardId, tmpImd.primaryTerm(shardId)); indexMetaDataBuilder.putMapping(mappingMd); indexMetaDataBuilder.putAlias(aliasMetaData); indexMetaDataBuilder.putAlias(aliasMetaData); indexMetaDataBuilder.putCustom(customEntry.getKey(), customEntry.getValue()); indexMetaDataBuilder.state(request.state()); indexMetaData = indexMetaDataBuilder.build();
throw new IllegalArgumentException("expected field name but got a " + parser.currentToken()); Builder builder = new Builder(parser.currentName()); builder.putAlias(AliasMetaData.Builder.fromXContent(parser)); builder.putInSyncAllocationIds(Integer.valueOf(shardId), allocationIds); } else { throw new IllegalArgumentException("Unexpected token: " + token); currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_OBJECT) { builder.putRolloverInfo(RolloverInfo.parse(parser, currentFieldName)); } else { throw new IllegalArgumentException("Unexpected token: " + token); } else { Custom custom = proto.fromXContent(parser); builder.putCustom(custom.type(), custom); builder.state(State.fromString(parser.text())); } else if (KEY_VERSION.equals(currentFieldName)) { builder.version(parser.longValue()); } else if (KEY_ROUTING_NUM_SHARDS.equals(currentFieldName)) { builder.setRoutingNumShards(parser.intValue()); } else { throw new IllegalArgumentException("Unexpected field [" + currentFieldName + "]");
IndexMetaData.Builder indexMdBuilder = IndexMetaData.builder(snapshotIndexMetaData).state(IndexMetaData.State.OPEN).index(renamedIndexName); indexMdBuilder.settings(Settings.builder().put(snapshotIndexMetaData.getSettings()).put(IndexMetaData.SETTING_INDEX_UUID, UUIDs.randomBase64UUID())); if (!request.includeAliases() && !snapshotIndexMetaData.getAliases().isEmpty()) { indexMdBuilder.removeAllAliases(); } else { for (ObjectCursor<String> alias : snapshotIndexMetaData.getAliases().keys()) { IndexMetaData updatedIndexMetaData = indexMdBuilder.build(); if (partial) { populateIgnoredShards(index, ignoreShards); validateExistingIndex(currentIndexMetaData, snapshotIndexMetaData, renamedIndexName, partial); IndexMetaData.Builder indexMdBuilder = IndexMetaData.builder(snapshotIndexMetaData).state(IndexMetaData.State.OPEN); indexMdBuilder.version(Math.max(snapshotIndexMetaData.getVersion(), currentIndexMetaData.getVersion() + 1)); indexMdBuilder.mappingVersion(Math.max(snapshotIndexMetaData.getMappingVersion(), currentIndexMetaData.getMappingVersion() + 1)); indexMdBuilder.settingsVersion(Math.max(snapshotIndexMetaData.getSettingsVersion(), currentIndexMetaData.getSettingsVersion() + 1)); if (!request.includeAliases()) { indexMdBuilder.removeAllAliases(); indexMdBuilder.putAlias(alias.value); indexMdBuilder.settings(Settings.builder().put(snapshotIndexMetaData.getSettings()).put(IndexMetaData.SETTING_INDEX_UUID, currentIndexMetaData.getIndexUUID())); IndexMetaData updatedIndexMetaData = indexMdBuilder.index(renamedIndexName).build(); rtBuilder.addAsRestore(updatedIndexMetaData, recoverySource); blocks.updateBlocks(updatedIndexMetaData);
IndexMetaData.Builder indexMdBuilder = IndexMetaData.builder(snapshotIndexMetaData).state(IndexMetaData.State.OPEN).index(renamedIndexName); indexMdBuilder.settings(Settings.builder().put(snapshotIndexMetaData.getSettings()).put(IndexMetaData.SETTING_INDEX_UUID, UUIDs.randomBase64UUID())); if (!request.includeAliases() && !snapshotIndexMetaData.getAliases().isEmpty()) { indexMdBuilder.removeAllAliases(); } else { for (ObjectCursor<String> alias : snapshotIndexMetaData.getAliases().keys()) { IndexMetaData updatedIndexMetaData = indexMdBuilder.build(); if (partial) { populateIgnoredShards(index, ignoreShards); validateExistingIndex(currentIndexMetaData, snapshotIndexMetaData, renamedIndexName, partial); IndexMetaData.Builder indexMdBuilder = IndexMetaData.builder(snapshotIndexMetaData).state(IndexMetaData.State.OPEN); indexMdBuilder.version(Math.max(snapshotIndexMetaData.getVersion(), currentIndexMetaData.getVersion() + 1)); if (!request.includeAliases()) { indexMdBuilder.removeAllAliases(); indexMdBuilder.putAlias(alias.value); indexMdBuilder.settings(Settings.builder().put(snapshotIndexMetaData.getSettings()).put(IndexMetaData.SETTING_INDEX_UUID, currentIndexMetaData.getIndexUUID())); IndexMetaData updatedIndexMetaData = indexMdBuilder.index(renamedIndexName).build(); rtBuilder.addAsRestore(updatedIndexMetaData, recoverySource); blocks.updateBlocks(updatedIndexMetaData);
IndexMetaData.Builder indexMdBuilder = IndexMetaData.builder(snapshotIndexMetaData).state(IndexMetaData.State.OPEN).index(renamedIndexName); indexMdBuilder.settings(Settings.builder().put(snapshotIndexMetaData.getSettings()).put(IndexMetaData.SETTING_INDEX_UUID, UUIDs.randomBase64UUID())); if (!request.includeAliases() && !snapshotIndexMetaData.getAliases().isEmpty()) { indexMdBuilder.removeAllAliases(); } else { for (ObjectCursor<String> alias : snapshotIndexMetaData.getAliases().keys()) { IndexMetaData updatedIndexMetaData = indexMdBuilder.build(); if (partial) { populateIgnoredShards(index, ignoreShards); validateExistingIndex(currentIndexMetaData, snapshotIndexMetaData, renamedIndexName, partial); IndexMetaData.Builder indexMdBuilder = IndexMetaData.builder(snapshotIndexMetaData).state(IndexMetaData.State.OPEN); indexMdBuilder.version(Math.max(snapshotIndexMetaData.getVersion(), currentIndexMetaData.getVersion() + 1)); if (!request.includeAliases()) { indexMdBuilder.removeAllAliases(); indexMdBuilder.putAlias(alias.value); indexMdBuilder.settings(Settings.builder().put(snapshotIndexMetaData.getSettings()).put(IndexMetaData.SETTING_INDEX_UUID, currentIndexMetaData.getIndexUUID())); IndexMetaData updatedIndexMetaData = indexMdBuilder.index(renamedIndexName).build(); rtBuilder.addAsRestore(updatedIndexMetaData, recoverySource); blocks.updateBlocks(updatedIndexMetaData);
Builder builder = new Builder(parser.currentName()); } else if (token == XContentParser.Token.START_OBJECT) { if (KEY_SETTINGS.equals(currentFieldName)) { builder.settings(Settings.fromXContent(parser)); } else if (KEY_MAPPINGS.equals(currentFieldName)) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { String mappingType = currentFieldName; Map<String, Object> mappingSource = MapBuilder.<String, Object>newMapBuilder().put(mappingType, parser.mapOrdered()).map(); builder.putMapping(new MappingMetaData(mappingType, mappingSource)); } else { throw new IllegalArgumentException("Unexpected token: " + token); builder.putAlias(AliasMetaData.Builder.fromXContent(parser)); builder.putInSyncAllocationIds(Integer.valueOf(shardId), allocationIds); } else { throw new IllegalArgumentException("Unexpected token: " + token); currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_OBJECT) { builder.putRolloverInfo(RolloverInfo.parse(parser, currentFieldName)); } else { throw new IllegalArgumentException("Unexpected token: " + token); builder.putCustom(currentFieldName, parser.mapStrings()); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
IndexMetaData.Builder indexMdBuilder = IndexMetaData.builder(snapshotIndexMetaData).state(IndexMetaData.State.OPEN).index(renamedIndex); indexMdBuilder.settings(Settings.settingsBuilder().put(snapshotIndexMetaData.getSettings()).put(IndexMetaData.SETTING_INDEX_UUID, Strings.randomBase64UUID())); if (!request.includeAliases() && !snapshotIndexMetaData.getAliases().isEmpty()) { indexMdBuilder.removeAllAliases(); } else { for (ObjectCursor<String> alias : snapshotIndexMetaData.getAliases().keys()) { IndexMetaData updatedIndexMetaData = indexMdBuilder.build(); if (partial) { populateIgnoredShards(index, ignoreShards); validateExistingIndex(currentIndexMetaData, snapshotIndexMetaData, renamedIndex, partial); IndexMetaData.Builder indexMdBuilder = IndexMetaData.builder(snapshotIndexMetaData).state(IndexMetaData.State.OPEN); indexMdBuilder.version(Math.max(snapshotIndexMetaData.getVersion(), currentIndexMetaData.getVersion() + 1)); if (!request.includeAliases()) { indexMdBuilder.removeAllAliases(); indexMdBuilder.putAlias(alias.value); indexMdBuilder.settings(Settings.settingsBuilder().put(snapshotIndexMetaData.getSettings()).put(IndexMetaData.SETTING_INDEX_UUID, currentIndexMetaData.getIndexUUID())); IndexMetaData updatedIndexMetaData = indexMdBuilder.index(renamedIndex).build(); rtBuilder.addAsRestore(updatedIndexMetaData, restoreSource); blocks.updateBlocks(updatedIndexMetaData);
indexMetaDataBuilder.putMapping(mappingMd);
Builder builder = new Builder(parser.currentName()); } else if (token == XContentParser.Token.START_OBJECT) { if (KEY_SETTINGS.equals(currentFieldName)) { builder.settings(Settings.builder().put(SettingsLoader.Helper.loadNestedFromMap(parser.mapOrdered()))); } else if (KEY_MAPPINGS.equals(currentFieldName)) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { String mappingType = currentFieldName; Map<String, Object> mappingSource = MapBuilder.<String, Object>newMapBuilder().put(mappingType, parser.mapOrdered()).map(); builder.putMapping(new MappingMetaData(mappingType, mappingSource)); } else { throw new IllegalArgumentException("Unexpected token: " + token); builder.putAlias(AliasMetaData.Builder.fromXContent(parser)); builder.putInSyncAllocationIds(Integer.valueOf(shardId), allocationIds); } else { throw new IllegalArgumentException("Unexpected token: " + token); } else { Custom custom = proto.fromXContent(parser); builder.putCustom(custom.type(), custom); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { if (token == XContentParser.Token.VALUE_EMBEDDED_OBJECT) { builder.putMapping(new MappingMetaData(new CompressedXContent(parser.binaryValue()))); } else { Map<String, Object> mapping = parser.mapOrdered();
if (routingPartitionSize != 1 && routingPartitionSize >= getRoutingNumShards()) { throw new IllegalArgumentException("routing partition size [" + routingPartitionSize + "] should be a positive number" + " less than the number of shards [" + getRoutingNumShards() + "] for [" + index + "]"); initializePrimaryTerms(); } else if (primaryTerms.length != numberOfShards) { throw new IllegalStateException("primaryTerms length is [" + primaryTerms.length + "] but should be equal to number of shards [" + numberOfShards() + "]"); indexCreatedVersion, indexUpgradedVersion, getRoutingNumShards(), routingPartitionSize, waitForActiveShards, rolloverInfos.build());
if (routingPartitionSize != 1 && routingPartitionSize >= getRoutingNumShards()) { throw new IllegalArgumentException("routing partition size [" + routingPartitionSize + "] should be a positive number" + " less than the number of shards [" + getRoutingNumShards() + "] for [" + index + "]"); initializePrimaryTerms(); } else if (primaryTerms.length != numberOfShards) { throw new IllegalStateException("primaryTerms length is [" + primaryTerms.length + "] but should be equal to number of shards [" + numberOfShards() + "]"); return new IndexMetaData(new Index(index, uuid), version, primaryTerms, state, tmpSettings, mappings.build(), tmpAliases.build(), customs.build(), filledInSyncAllocationIds.build(), requireFilters, initialRecoveryFilters, includeFilters, excludeFilters, indexCreatedVersion, indexUpgradedVersion, getRoutingNumShards(), routingPartitionSize, waitForActiveShards);
} else if ("indices".equals(currentFieldName)) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { builder.put(IndexMetaData.Builder.fromXContent(parser), false);
} else if ("indices".equals(currentFieldName)) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { builder.put(IndexMetaData.Builder.fromXContent(parser), false);
Builder builder = new Builder(parser.currentName()); } else if (token == XContentParser.Token.START_OBJECT) { if ("settings".equals(currentFieldName)) { builder.settings(Settings.settingsBuilder().put(SettingsLoader.Helper.loadNestedFromMap(parser.mapOrdered()))); } else if ("mappings".equals(currentFieldName)) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { String mappingType = currentFieldName; Map<String, Object> mappingSource = MapBuilder.<String, Object>newMapBuilder().put(mappingType, parser.mapOrdered()).map(); builder.putMapping(new MappingMetaData(mappingType, mappingSource)); builder.putAlias(AliasMetaData.Builder.fromXContent(parser)); } else { Custom custom = proto.fromXContent(parser); builder.putCustom(custom.type(), custom); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { if (token == XContentParser.Token.VALUE_EMBEDDED_OBJECT) { builder.putMapping(new MappingMetaData(new CompressedXContent(parser.binaryValue()))); } else { Map<String, Object> mapping = parser.mapOrdered(); if (mapping.size() == 1) { String mappingType = mapping.keySet().iterator().next(); builder.putMapping(new MappingMetaData(mappingType, mapping)); builder.state(State.fromString(parser.text())); } else if ("version".equals(currentFieldName)) {
} else if ("indices".equals(currentFieldName)) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { builder.put(IndexMetaData.Builder.fromXContent(parser), false);
parser = XContentHelper.createParser(data, 0, data.length); indexMetaData = IndexMetaData.Builder.fromXContent(parser); highestVersion = version; } finally {