use of org.elasticsearch.action.ShardOperationFailedException in project crate by crate.
the class FailedShardsExceptionTest method testShardFailureReasonIsNull.
@Test
public void testShardFailureReasonIsNull() throws Exception {
FailedShardsException exception = new FailedShardsException(new ShardOperationFailedException[] { new ShardOperationFailedException() {
@Override
public String index() {
return null;
}
@Override
public int shardId() {
return 0;
}
@Override
public String reason() {
return null;
}
@Override
public RestStatus status() {
return null;
}
@Override
public void readFrom(StreamInput in) throws IOException {
}
@Override
public void writeTo(StreamOutput out) throws IOException {
}
@Override
public Throwable getCause() {
return null;
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
return null;
}
}, null });
assertThat(exception.getMessage(), is("query failed on shards 0 ( null )"));
}
use of org.elasticsearch.action.ShardOperationFailedException in project elasticsearch by elastic.
the class ElasticsearchAssertions method assertBlocked.
/**
* Checks that all shard requests of a replicated broadcast request failed due to a cluster block
*
* @param replicatedBroadcastResponse the response that should only contain failed shard responses
*
* */
public static void assertBlocked(BroadcastResponse replicatedBroadcastResponse) {
assertThat("all shard requests should have failed", replicatedBroadcastResponse.getFailedShards(), Matchers.equalTo(replicatedBroadcastResponse.getTotalShards()));
for (ShardOperationFailedException exception : replicatedBroadcastResponse.getShardFailures()) {
ClusterBlockException clusterBlockException = (ClusterBlockException) ExceptionsHelper.unwrap(exception.getCause(), ClusterBlockException.class);
assertNotNull("expected the cause of failure to be a ClusterBlockException but got " + exception.getCause().getMessage(), clusterBlockException);
assertThat(clusterBlockException.blocks().size(), greaterThan(0));
assertThat(clusterBlockException.status(), CoreMatchers.equalTo(RestStatus.FORBIDDEN));
}
}
use of org.elasticsearch.action.ShardOperationFailedException in project elasticsearch by elastic.
the class ESIntegTestCase method flush.
/**
* Flush some or all indices in the cluster.
*/
protected final FlushResponse flush(String... indices) {
waitForRelocation();
FlushResponse actionGet = client().admin().indices().prepareFlush(indices).execute().actionGet();
for (ShardOperationFailedException failure : actionGet.getShardFailures()) {
assertThat("unexpected flush failure " + failure.reason(), failure.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
}
return actionGet;
}
use of org.elasticsearch.action.ShardOperationFailedException in project elasticsearch by elastic.
the class SearchPhaseExecutionException method metadataToXContent.
@Override
protected void metadataToXContent(XContentBuilder builder, Params params) throws IOException {
builder.field("phase", phaseName);
// we group by default
final boolean group = params.paramAsBoolean("group_shard_failures", true);
// notify that it's grouped
builder.field("grouped", group);
builder.field("failed_shards");
builder.startArray();
ShardOperationFailedException[] failures = params.paramAsBoolean("group_shard_failures", true) ? ExceptionsHelper.groupBy(shardFailures) : shardFailures;
for (ShardOperationFailedException failure : failures) {
builder.startObject();
failure.toXContent(builder, params);
builder.endObject();
}
builder.endArray();
}
use of org.elasticsearch.action.ShardOperationFailedException in project elasticsearch by elastic.
the class BroadcastResponse method writeTo.
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeVInt(totalShards);
out.writeVInt(successfulShards);
out.writeVInt(failedShards);
out.writeVInt(shardFailures.length);
for (ShardOperationFailedException exp : shardFailures) {
exp.writeTo(out);
}
}
Aggregations