Search in sources :

Example 11 with ClusterBlockException

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();
    }
}
Also used : IndicesExistsResponse(org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse) ClusterBlockException(org.elasticsearch.cluster.block.ClusterBlockException)

Example 12 with ClusterBlockException

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();
    }
}
Also used : IndexRequestBuilder(org.elasticsearch.action.index.IndexRequestBuilder) IndexResponse(org.elasticsearch.action.index.IndexResponse) CreateIndexResponse(org.elasticsearch.action.admin.indices.create.CreateIndexResponse) ClusterBlockException(org.elasticsearch.cluster.block.ClusterBlockException)

Example 13 with ClusterBlockException

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
    }
}
Also used : IndexRequestBuilder(org.elasticsearch.action.index.IndexRequestBuilder) ClusterBlockException(org.elasticsearch.cluster.block.ClusterBlockException)

Example 14 with ClusterBlockException

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());
    }
}
Also used : BroadcastResponse(org.elasticsearch.action.support.broadcast.BroadcastResponse) TransportResponse(org.elasticsearch.transport.TransportResponse) ClusterBlock(org.elasticsearch.cluster.block.ClusterBlock) PlainActionFuture(org.elasticsearch.action.support.PlainActionFuture) ClusterBlocks(org.elasticsearch.cluster.block.ClusterBlocks) IndicesRequest(org.elasticsearch.action.IndicesRequest) BroadcastRequest(org.elasticsearch.action.support.broadcast.BroadcastRequest) ClusterBlockException(org.elasticsearch.cluster.block.ClusterBlockException)

Example 15 with ClusterBlockException

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());
    }
}
Also used : BroadcastResponse(org.elasticsearch.action.support.broadcast.BroadcastResponse) TransportResponse(org.elasticsearch.transport.TransportResponse) ClusterBlock(org.elasticsearch.cluster.block.ClusterBlock) PlainActionFuture(org.elasticsearch.action.support.PlainActionFuture) ClusterBlocks(org.elasticsearch.cluster.block.ClusterBlocks) IndicesRequest(org.elasticsearch.action.IndicesRequest) BroadcastRequest(org.elasticsearch.action.support.broadcast.BroadcastRequest) ClusterBlockException(org.elasticsearch.cluster.block.ClusterBlockException)

Aggregations

ClusterBlockException (org.elasticsearch.cluster.block.ClusterBlockException)18 PlainActionFuture (org.elasticsearch.action.support.PlainActionFuture)4 ClusterBlock (org.elasticsearch.cluster.block.ClusterBlock)4 IndicesRequest (org.elasticsearch.action.IndicesRequest)3 ClusterBlocks (org.elasticsearch.cluster.block.ClusterBlocks)3 Settings (org.elasticsearch.common.settings.Settings)3 DiscoverySettings (org.elasticsearch.discovery.DiscoverySettings)3 IOException (java.io.IOException)2 ExecutionException (java.util.concurrent.ExecutionException)2 ActionResponse (org.elasticsearch.action.ActionResponse)2 CreateIndexResponse (org.elasticsearch.action.admin.indices.create.CreateIndexResponse)2 IndexRequestBuilder (org.elasticsearch.action.index.IndexRequestBuilder)2 BroadcastRequest (org.elasticsearch.action.support.broadcast.BroadcastRequest)2 BroadcastResponse (org.elasticsearch.action.support.broadcast.BroadcastResponse)2 Releasable (org.elasticsearch.common.lease.Releasable)2 TransportResponse (org.elasticsearch.transport.TransportResponse)2 FeedException (com.rometools.rome.io.FeedException)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 Collections.emptyList (java.util.Collections.emptyList)1