Search in sources :

Example 1 with ClusterBlockLevel

use of org.opensearch.cluster.block.ClusterBlockLevel in project OpenSearch by opensearch-project.

the class TransportReplicationAction method blockExceptions.

private ClusterBlockException blockExceptions(final ClusterState state, final String indexName) {
    ClusterBlockLevel globalBlockLevel = globalBlockLevel();
    if (globalBlockLevel != null) {
        ClusterBlockException blockException = state.blocks().globalBlockedException(globalBlockLevel);
        if (blockException != null) {
            return blockException;
        }
    }
    ClusterBlockLevel indexBlockLevel = indexBlockLevel();
    if (indexBlockLevel != null) {
        ClusterBlockException blockException = state.blocks().indexBlockedException(indexBlockLevel, indexName);
        if (blockException != null) {
            return blockException;
        }
    }
    return null;
}
Also used : ClusterBlockLevel(org.opensearch.cluster.block.ClusterBlockLevel) ClusterBlockException(org.opensearch.cluster.block.ClusterBlockException)

Example 2 with ClusterBlockLevel

use of org.opensearch.cluster.block.ClusterBlockLevel in project OpenSearch by opensearch-project.

the class AbstractDisruptionTestCase method assertNoMaster.

void assertNoMaster(final String node, @Nullable final ClusterBlock expectedBlocks, TimeValue maxWaitTime) throws Exception {
    assertBusy(() -> {
        ClusterState state = getNodeClusterState(node);
        final DiscoveryNodes nodes = state.nodes();
        assertNull("node [" + node + "] still has [" + nodes.getMasterNode() + "] as master", nodes.getMasterNode());
        if (expectedBlocks != null) {
            for (ClusterBlockLevel level : expectedBlocks.levels()) {
                assertTrue("node [" + node + "] does have level [" + level + "] in it's blocks", state.getBlocks().hasGlobalBlockWithLevel(level));
            }
        }
    }, maxWaitTime.getMillis(), TimeUnit.MILLISECONDS);
}
Also used : ClusterState(org.opensearch.cluster.ClusterState) ClusterBlockLevel(org.opensearch.cluster.block.ClusterBlockLevel) DiscoveryNodes(org.opensearch.cluster.node.DiscoveryNodes)

Aggregations

ClusterBlockLevel (org.opensearch.cluster.block.ClusterBlockLevel)2 ClusterState (org.opensearch.cluster.ClusterState)1 ClusterBlockException (org.opensearch.cluster.block.ClusterBlockException)1 DiscoveryNodes (org.opensearch.cluster.node.DiscoveryNodes)1