org.elasticsearch.action.support.broadcast.BroadcastResponse Java Examples

The following examples show how to use org.elasticsearch.action.support.broadcast.BroadcastResponse. 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: ElasticsearchAssertions.java    From crate with Apache License 2.0 5 votes vote down vote up
/**
 * 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(), equalTo(replicatedBroadcastResponse.getTotalShards()));
    for (DefaultShardOperationFailedException 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));
    }
}
 
Example #2
Source File: ElasticsearchAssertions.java    From crate with Apache License 2.0 5 votes vote down vote up
public static String formatShardStatus(BroadcastResponse response) {
    StringBuilder msg = new StringBuilder();
    msg.append(" Total shards: ").append(response.getTotalShards())
       .append(" Successful shards: ").append(response.getSuccessfulShards())
       .append(" & ").append(response.getFailedShards()).append(" shard failures:");
    for (DefaultShardOperationFailedException failure : response.getShardFailures()) {
        msg.append("\n ").append(failure);
    }
    return msg.toString();
}
 
Example #3
Source File: RestActions.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public static void buildBroadcastShardsHeader(XContentBuilder builder, ToXContent.Params params, BroadcastResponse response) throws IOException {
    buildBroadcastShardsHeader(builder, params, response.getTotalShards(), response.getSuccessfulShards(), response.getFailedShards(), response.getShardFailures());
}
 
Example #4
Source File: ElasticSearchServiceMapper.java    From vertx-elasticsearch-service with Apache License 2.0 4 votes vote down vote up
private static Shards mapToShards(BroadcastResponse esSearchResponse) {
    return new Shards()
            .setFailed(esSearchResponse.getFailedShards())
            .setSuccessful(esSearchResponse.getSuccessfulShards())
            .setTotal(esSearchResponse.getTotalShards());
}
 
Example #5
Source File: TransportBroadcastReplicationAction.java    From crate with Apache License 2.0 4 votes vote down vote up
protected abstract BroadcastResponse newResponse(int successfulShards, int failedShards, int totalNumCopies,
List<DefaultShardOperationFailedException> shardFailures);
 
Example #6
Source File: ElasticsearchAssertions.java    From crate with Apache License 2.0 4 votes vote down vote up
public static void assertNoFailures(BroadcastResponse response) {
    assertThat("Unexpected ShardFailures: " + Arrays.toString(response.getShardFailures()), response.getFailedShards(), equalTo(0));
}
 
Example #7
Source File: ElasticsearchAssertions.java    From crate with Apache License 2.0 4 votes vote down vote up
public static void assertAllSuccessful(BroadcastResponse response) {
    assertNoFailures(response);
    assertThat("Expected all shards successful",
            response.getSuccessfulShards(), equalTo(response.getTotalShards()));
}
 
Example #8
Source File: TransportBroadcastReplicationAction.java    From Elasticsearch with Apache License 2.0 votes vote down vote up
protected abstract BroadcastResponse newResponse(int successfulShards, int failedShards, int totalNumCopies, List<ShardOperationFailedException> shardFailures);