diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/close/ShardCloseRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/close/ShardCloseRequest.java deleted file mode 100644 index 901f3ba377163..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/close/ShardCloseRequest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.elasticsearch.action.admin.indices.close; - -import org.elasticsearch.action.support.replication.ReplicationRequest; -import org.elasticsearch.index.shard.ShardId; - -public class ShardCloseRequest extends ReplicationRequest { - - public ShardCloseRequest(){ - } - - public ShardCloseRequest(final ShardId shardId) { - super(shardId); - } - - @Override - public String toString() { - return "close shard {" + shardId + "}"; - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/close/TransportShardCloseAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/close/TransportVerifyShardBeforeCloseAction.java similarity index 78% rename from server/src/main/java/org/elasticsearch/action/admin/indices/close/TransportShardCloseAction.java rename to server/src/main/java/org/elasticsearch/action/admin/indices/close/TransportVerifyShardBeforeCloseAction.java index 78b516e512042..ab895dd7af804 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/close/TransportShardCloseAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/close/TransportVerifyShardBeforeCloseAction.java @@ -21,6 +21,7 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.indices.flush.FlushRequest; import org.elasticsearch.action.support.ActionFilters; +import org.elasticsearch.action.support.replication.ReplicationRequest; import org.elasticsearch.action.support.replication.ReplicationResponse; import org.elasticsearch.action.support.replication.TransportReplicationAction; import org.elasticsearch.cluster.action.shard.ShardStateAction; @@ -38,17 +39,19 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -public class TransportShardCloseAction extends TransportReplicationAction { +public class TransportVerifyShardBeforeCloseAction extends TransportReplicationAction< + TransportVerifyShardBeforeCloseAction.ShardCloseRequest, TransportVerifyShardBeforeCloseAction.ShardCloseRequest, ReplicationResponse> { public static final String NAME = CloseIndexAction.NAME + "[s]"; private static final ClusterBlock EXPECTED_BLOCK = MetaDataIndexStateService.INDEX_CLOSED_BLOCK; @Inject - public TransportShardCloseAction(final Settings settings, final TransportService transportService, final ClusterService clusterService, - final IndicesService indicesService, final ThreadPool threadPool, final ShardStateAction stateAction, - final ActionFilters actionFilters, final IndexNameExpressionResolver indexNameExpressionResolver) { - super(settings, NAME, transportService, clusterService, indicesService, threadPool, stateAction, - actionFilters, indexNameExpressionResolver, ShardCloseRequest::new, ShardCloseRequest::new, ThreadPool.Names.GENERIC); + public TransportVerifyShardBeforeCloseAction(final Settings settings, final TransportService transportService, + final ClusterService clusterService, final IndicesService indicesService, + final ThreadPool threadPool, final ShardStateAction stateAction, + final ActionFilters actionFilters, final IndexNameExpressionResolver resolver) { + super(settings, NAME, transportService, clusterService, indicesService, threadPool, stateAction, actionFilters, resolver, + ShardCloseRequest::new, ShardCloseRequest::new, ThreadPool.Names.MANAGEMENT); } @Override @@ -103,6 +106,21 @@ private void executeShardOperation(final IndexShard indexShard) { + "] mismatches maximum sequence number [" + maxSeqNo + "] on index shard " + shardId); } indexShard.flush(new FlushRequest()); - logger.debug("shard {} is ready for closing", shardId); + logger.debug("{} shard is ready for closing", shardId); + } + + public static class ShardCloseRequest extends ReplicationRequest { + + ShardCloseRequest(){ + } + + public ShardCloseRequest(final ShardId shardId) { + super(shardId); + } + + @Override + public String toString() { + return "close shard {" + shardId + "}"; + } } } diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/close/TransportShardCloseActionTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/close/TransportVerifyShardBeforeCloseActionTests.java similarity index 90% rename from server/src/test/java/org/elasticsearch/action/admin/indices/close/TransportShardCloseActionTests.java rename to server/src/test/java/org/elasticsearch/action/admin/indices/close/TransportVerifyShardBeforeCloseActionTests.java index 35675f7911494..ae1a0b8768946 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/close/TransportShardCloseActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/close/TransportVerifyShardBeforeCloseActionTests.java @@ -45,10 +45,10 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -public class TransportShardCloseActionTests extends ESTestCase { +public class TransportVerifyShardBeforeCloseActionTests extends ESTestCase { private IndexShard indexShard; - private TransportShardCloseAction action; + private TransportVerifyShardBeforeCloseAction action; private ClusterService clusterService; @Override @@ -68,16 +68,18 @@ public void setUp() throws Exception { when(clusterService.state()).thenReturn(new ClusterState.Builder(new ClusterName("test")) .blocks(ClusterBlocks.builder().addIndexBlock("index", INDEX_CLOSED_BLOCK).build()).build()); - action = new TransportShardCloseAction(Settings.EMPTY, mock(TransportService.class), clusterService, + action = new TransportVerifyShardBeforeCloseAction(Settings.EMPTY, mock(TransportService.class), clusterService, mock(IndicesService.class), mock(ThreadPool.class), mock(ShardStateAction.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class)); } private void executeOnPrimaryOrReplica() throws Exception { + final TransportVerifyShardBeforeCloseAction.ShardCloseRequest request = + new TransportVerifyShardBeforeCloseAction.ShardCloseRequest(indexShard.shardId()); if (randomBoolean()) { - assertNotNull(action.shardOperationOnPrimary(new ShardCloseRequest(indexShard.shardId()), indexShard)); + assertNotNull(action.shardOperationOnPrimary(request, indexShard)); } else { - assertNotNull(action.shardOperationOnPrimary(new ShardCloseRequest(indexShard.shardId()), indexShard)); + assertNotNull(action.shardOperationOnPrimary(request, indexShard)); } }