|
39 | 39 | import org.elasticsearch.cluster.block.ClusterBlock;
|
40 | 40 | import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
41 | 41 | import org.elasticsearch.cluster.block.ClusterBlocks;
|
42 |
| -import org.elasticsearch.cluster.metadata.IndexMetaData.State; |
43 | 42 | import org.elasticsearch.cluster.node.DiscoveryNodes;
|
44 | 43 | import org.elasticsearch.cluster.routing.IndexRoutingTable;
|
45 | 44 | import org.elasticsearch.cluster.routing.RoutingTable;
|
@@ -294,8 +293,6 @@ public ClusterState execute(ClusterState currentState) throws Exception {
|
294 | 293 | List<IndexTemplateMetaData> templates =
|
295 | 294 | MetaDataIndexTemplateService.findTemplates(currentState.metaData(), request.index());
|
296 | 295 |
|
297 |
| - Map<String, Map<String, String>> customs = new HashMap<>(); |
298 |
| - |
299 | 296 | // add the request mapping
|
300 | 297 | Map<String, Map<String, Object>> mappings = new HashMap<>();
|
301 | 298 |
|
@@ -542,11 +539,7 @@ public ClusterState execute(ClusterState currentState) throws Exception {
|
542 | 539 | indexMetaDataBuilder.putAlias(aliasMetaData);
|
543 | 540 | }
|
544 | 541 |
|
545 |
| - for (Map.Entry<String, Map<String, String>> customEntry : customs.entrySet()) { |
546 |
| - indexMetaDataBuilder.putCustom(customEntry.getKey(), customEntry.getValue()); |
547 |
| - } |
548 |
| - |
549 |
| - indexMetaDataBuilder.state(request.state()); |
| 542 | + indexMetaDataBuilder.state(IndexMetaData.State.OPEN); |
550 | 543 |
|
551 | 544 | final IndexMetaData indexMetaData;
|
552 | 545 | try {
|
@@ -577,13 +570,11 @@ public ClusterState execute(ClusterState currentState) throws Exception {
|
577 | 570 |
|
578 | 571 | ClusterState updatedState = ClusterState.builder(currentState).blocks(blocks).metaData(newMetaData).build();
|
579 | 572 |
|
580 |
| - if (request.state() == State.OPEN) { |
581 |
| - RoutingTable.Builder routingTableBuilder = RoutingTable.builder(updatedState.routingTable()) |
582 |
| - .addAsNew(updatedState.metaData().index(request.index())); |
583 |
| - updatedState = allocationService.reroute( |
584 |
| - ClusterState.builder(updatedState).routingTable(routingTableBuilder.build()).build(), |
585 |
| - "index [" + request.index() + "] created"); |
586 |
| - } |
| 573 | + RoutingTable.Builder routingTableBuilder = RoutingTable.builder(updatedState.routingTable()) |
| 574 | + .addAsNew(updatedState.metaData().index(request.index())); |
| 575 | + updatedState = allocationService.reroute( |
| 576 | + ClusterState.builder(updatedState).routingTable(routingTableBuilder.build()).build(), |
| 577 | + "index [" + request.index() + "] created"); |
587 | 578 | removalExtraInfo = "cleaning up after validating index on master";
|
588 | 579 | removalReason = IndexRemovalReason.NO_LONGER_ASSIGNED;
|
589 | 580 | return updatedState;
|
@@ -626,11 +617,11 @@ public void onFailure(String source, Exception e) {
|
626 | 617 |
|
627 | 618 | private void validate(CreateIndexClusterStateUpdateRequest request, ClusterState state) {
|
628 | 619 | validateIndexName(request.index(), state);
|
629 |
| - validateIndexSettings(request.index(), request.settings(), state, forbidPrivateIndexSettings); |
| 620 | + validateIndexSettings(request.index(), request.settings(), forbidPrivateIndexSettings); |
630 | 621 | }
|
631 | 622 |
|
632 |
| - public void validateIndexSettings(String indexName, final Settings settings, final ClusterState clusterState, |
633 |
| - final boolean forbidPrivateIndexSettings) throws IndexCreationException { |
| 623 | + public void validateIndexSettings(String indexName, final Settings settings, final boolean forbidPrivateIndexSettings) |
| 624 | + throws IndexCreationException { |
634 | 625 | List<String> validationErrors = getIndexSettingsValidationErrors(settings, forbidPrivateIndexSettings);
|
635 | 626 |
|
636 | 627 | if (validationErrors.isEmpty() == false) {
|
@@ -736,9 +727,9 @@ static void validateSplitIndex(ClusterState state, String sourceIndex,
|
736 | 727 |
|
737 | 728 | }
|
738 | 729 |
|
739 |
| - static IndexMetaData validateResize(ClusterState state, String sourceIndex, |
740 |
| - Set<String> targetIndexMappingsTypes, String targetIndexName, |
741 |
| - Settings targetIndexSettings) { |
| 730 | + private static IndexMetaData validateResize(ClusterState state, String sourceIndex, |
| 731 | + Set<String> targetIndexMappingsTypes, String targetIndexName, |
| 732 | + Settings targetIndexSettings) { |
742 | 733 | if (state.metaData().hasIndex(targetIndexName)) {
|
743 | 734 | throw new ResourceAlreadyExistsException(state.metaData().index(targetIndexName).getIndex());
|
744 | 735 | }
|
|
0 commit comments