org.elasticsearch.action.UnavailableShardsException Java Examples
The following examples show how to use
org.elasticsearch.action.UnavailableShardsException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransportActions.java From Elasticsearch with Apache License 2.0 | 5 votes |
public static boolean isShardNotAvailableException(Throwable t) { Throwable actual = ExceptionsHelper.unwrapCause(t); if (actual instanceof ShardNotFoundException || actual instanceof IndexNotFoundException || actual instanceof IllegalIndexShardStateException || actual instanceof NoShardAvailableActionException || actual instanceof UnavailableShardsException || actual instanceof AlreadyClosedException) { return true; } return false; }
Example #2
Source File: TransportActions.java From crate with Apache License 2.0 | 5 votes |
public static boolean isShardNotAvailableException(final Throwable e) { final Throwable actual = ExceptionsHelper.unwrapCause(e); return (actual instanceof ShardNotFoundException || actual instanceof IndexNotFoundException || actual instanceof IllegalIndexShardStateException || actual instanceof NoShardAvailableActionException || actual instanceof UnavailableShardsException || actual instanceof AlreadyClosedException); }
Example #3
Source File: TransportReplicationAction.java From Elasticsearch with Apache License 2.0 | 4 votes |
void retryBecauseUnavailable(ShardId shardId, String message) { retry(new UnavailableShardsException(shardId, "{} Timeout: [{}], request: [{}]", message, request.timeout(), request)); }
Example #4
Source File: TransportReplicationAction.java From Elasticsearch with Apache License 2.0 | 4 votes |
void finishBecauseUnavailable(ShardId shardId, String message) { finishAsFailed(new UnavailableShardsException(shardId, "{} Timeout: [{}], request: [{}]", message, request.timeout(), request)); }
Example #5
Source File: TransportReplicationAction.java From crate with Apache License 2.0 | 4 votes |
void retryBecauseUnavailable(ShardId shardId, String message) { retry(new UnavailableShardsException(shardId, "{} Timeout: [{}], request: [{}]", message, request.timeout(), request)); }
Example #6
Source File: ReplicationOperationTests.java From crate with Apache License 2.0 | 4 votes |
@Test public void testWaitForActiveShards() throws Exception { final String index = "test"; final ShardId shardId = new ShardId(index, "_na_", 0); final int assignedReplicas = randomInt(2); final int unassignedReplicas = randomInt(2); final int totalShards = 1 + assignedReplicas + unassignedReplicas; final int activeShardCount = randomIntBetween(0, totalShards); Request request = new Request(shardId).waitForActiveShards( activeShardCount == totalShards ? ActiveShardCount.ALL : ActiveShardCount.from(activeShardCount)); final boolean passesActiveShardCheck = activeShardCount <= assignedReplicas + 1; ShardRoutingState[] replicaStates = new ShardRoutingState[assignedReplicas + unassignedReplicas]; for (int i = 0; i < assignedReplicas; i++) { replicaStates[i] = randomFrom(ShardRoutingState.STARTED, ShardRoutingState.RELOCATING); } for (int i = assignedReplicas; i < replicaStates.length; i++) { replicaStates[i] = ShardRoutingState.UNASSIGNED; } final ClusterState state = state(index, true, ShardRoutingState.STARTED, replicaStates); logger.debug("using active shard count of [{}], assigned shards [{}], total shards [{}]." + " expecting op to [{}]. using state: \n{}", request.waitForActiveShards(), 1 + assignedReplicas, 1 + assignedReplicas + unassignedReplicas, passesActiveShardCheck ? "succeed" : "retry", state); final long primaryTerm = state.metaData().index(index).primaryTerm(shardId.id()); final IndexShardRoutingTable shardRoutingTable = state.routingTable().index(index).shard(shardId.id()); final Set<String> inSyncAllocationIds = state.metaData().index(index).inSyncAllocationIds(0); Set<String> trackedShards = new HashSet<>(); addTrackingInfo(shardRoutingTable, null, trackedShards, new HashSet<>()); final ReplicationGroup initialReplicationGroup = new ReplicationGroup(shardRoutingTable, inSyncAllocationIds, trackedShards); PlainActionFuture<TestPrimary.Result> listener = new PlainActionFuture<>(); final ShardRouting primaryShard = shardRoutingTable.primaryShard(); final TestReplicationOperation op = new TestReplicationOperation(request, new TestPrimary(primaryShard, () -> initialReplicationGroup), listener, new TestReplicaProxy(primaryTerm), logger, "test"); if (passesActiveShardCheck) { assertThat(op.checkActiveShardCount(), nullValue()); op.execute(); assertTrue("operations should have been performed, active shard count is met", request.processedOnPrimary.get()); } else { assertThat(op.checkActiveShardCount(), notNullValue()); op.execute(); assertFalse("operations should not have been perform, active shard count is *NOT* met", request.processedOnPrimary.get()); assertListenerThrows("should throw exception to trigger retry", listener, UnavailableShardsException.class); } }