broadcast API to by default ignore missing / illegal shard state

this happens for example because we list assigned shards, and they might not have been allocated on the relevant node yet, no need to list those as actual failures in some APIs
This commit is contained in:
Shay Banon 2013-03-19 10:22:43 +01:00
parent bea7bdde4c
commit c92207f483
2 changed files with 31 additions and 19 deletions

View File

@ -20,7 +20,6 @@
package org.elasticsearch.action.admin.indices.refresh;
import org.elasticsearch.ElasticSearchException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.action.ShardOperationFailedException;
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
import org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException;
@ -33,11 +32,8 @@ import org.elasticsearch.cluster.routing.GroupShardsIterator;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexShardMissingException;
import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.shard.IllegalIndexShardStateException;
import org.elasticsearch.index.shard.service.IndexShard;
import org.elasticsearch.indices.IndexMissingException;
import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
@ -81,21 +77,6 @@ public class TransportRefreshAction extends TransportBroadcastOperationAction<Re
return true;
}
@Override
protected boolean ignoreException(Throwable t) {
Throwable actual = ExceptionsHelper.unwrapCause(t);
if (actual instanceof IllegalIndexShardStateException) {
return true;
}
if (actual instanceof IndexMissingException) {
return true;
}
if (actual instanceof IndexShardMissingException) {
return true;
}
return false;
}
@Override
protected RefreshResponse newResponse(RefreshRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) {
int successfulShards = 0;

View File

@ -20,6 +20,7 @@
package org.elasticsearch.action.support.broadcast;
import org.elasticsearch.ElasticSearchException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.TransportAction;
import org.elasticsearch.cluster.ClusterService;
@ -32,6 +33,9 @@ import org.elasticsearch.cluster.routing.ShardIterator;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexShardMissingException;
import org.elasticsearch.index.shard.IllegalIndexShardStateException;
import org.elasticsearch.indices.IndexMissingException;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.*;
@ -95,14 +99,41 @@ public abstract class TransportBroadcastOperationAction<Request extends Broadcas
return true;
}
/**
* Override this method to ignore specific exception, note, the result should be OR'ed with the call
* to super#ignoreException since there is additional logic here....
*/
protected boolean ignoreException(Throwable t) {
if (ignoreIllegalShardState()) {
Throwable actual = ExceptionsHelper.unwrapCause(t);
if (actual instanceof IllegalIndexShardStateException) {
return true;
}
if (actual instanceof IndexMissingException) {
return true;
}
if (actual instanceof IndexShardMissingException) {
return true;
}
}
return false;
}
/**
* Should non active routing shard state be ignore or node, defaults to false.
*/
protected boolean ignoreNonActiveExceptions() {
return false;
}
/**
* Should the API ignore illegal shard state cases, for example, if the shard is actually missing on the
* target node (cause it hasn't been allocated there for example). Defaults to true.
*/
protected boolean ignoreIllegalShardState() {
return true;
}
protected abstract ClusterBlockException checkGlobalBlock(ClusterState state, Request request);
protected abstract ClusterBlockException checkRequestBlock(ClusterState state, Request request, String[] concreteIndices);