use of org.elasticsearch.cluster.block.ClusterBlockException in project elasticsearch by elastic.
the class SimpleBlocksIT method canIndexExists.
private void canIndexExists(String index) {
try {
IndicesExistsResponse r = client().admin().indices().prepareExists(index).execute().actionGet();
assertThat(r, notNullValue());
} catch (ClusterBlockException e) {
fail();
}
}
use of org.elasticsearch.cluster.block.ClusterBlockException in project elasticsearch by elastic.
the class SimpleBlocksIT method canIndexDocument.
private void canIndexDocument(String index) {
try {
IndexRequestBuilder builder = client().prepareIndex(index, "zzz");
builder.setSource("foo", "bar");
IndexResponse r = builder.execute().actionGet();
assertThat(r, notNullValue());
} catch (ClusterBlockException e) {
fail();
}
}
use of org.elasticsearch.cluster.block.ClusterBlockException in project elasticsearch by elastic.
the class SimpleBlocksIT method canNotIndexDocument.
private void canNotIndexDocument(String index) {
try {
IndexRequestBuilder builder = client().prepareIndex(index, "zzz");
builder.setSource("foo", "bar");
builder.execute().actionGet();
fail();
} catch (ClusterBlockException e) {
// all is well
}
}
use of org.elasticsearch.cluster.block.ClusterBlockException in project elasticsearch by elastic.
the class TransportBroadcastByNodeActionTests method testGlobalBlock.
public void testGlobalBlock() {
Request request = new Request(new String[] { TEST_INDEX });
PlainActionFuture<Response> listener = new PlainActionFuture<>();
ClusterBlocks.Builder block = ClusterBlocks.builder().addGlobalBlock(new ClusterBlock(1, "test-block", false, true, RestStatus.SERVICE_UNAVAILABLE, ClusterBlockLevel.ALL));
setState(clusterService, ClusterState.builder(clusterService.state()).blocks(block));
try {
action.new AsyncAction(null, request, listener).start();
fail("expected ClusterBlockException");
} catch (ClusterBlockException expected) {
assertEquals("blocked by: [SERVICE_UNAVAILABLE/1/test-block];", expected.getMessage());
}
}
use of org.elasticsearch.cluster.block.ClusterBlockException in project elasticsearch by elastic.
the class TransportBroadcastByNodeActionTests method testRequestBlock.
public void testRequestBlock() {
Request request = new Request(new String[] { TEST_INDEX });
PlainActionFuture<Response> listener = new PlainActionFuture<>();
ClusterBlocks.Builder block = ClusterBlocks.builder().addIndexBlock(TEST_INDEX, new ClusterBlock(1, "test-block", false, true, RestStatus.SERVICE_UNAVAILABLE, ClusterBlockLevel.ALL));
setState(clusterService, ClusterState.builder(clusterService.state()).blocks(block));
try {
action.new AsyncAction(null, request, listener).start();
fail("expected ClusterBlockException");
} catch (ClusterBlockException expected) {
assertEquals("blocked by: [SERVICE_UNAVAILABLE/1/test-block];", expected.getMessage());
}
}
Aggregations