public ClusterBlockException globalBlockedException(ClusterBlockLevel level) { if (globalBlocked(level) == false) { return null; } return new ClusterBlockException(global(level)); }
public void globalBlockedRaiseException(ClusterBlockLevel level) throws ClusterBlockException { ClusterBlockException blockException = globalBlockedException(level); if (blockException != null) { throw blockException; } }
public void indexBlockedRaiseException(ClusterBlockLevel level, String index) throws ClusterBlockException { ClusterBlockException blockException = indexBlockedException(level, index); if (blockException != null) { throw blockException; } }
private static String buildMessage(Set<ClusterBlock> blocks) { StringBuilder sb = new StringBuilder("blocked by: "); for (ClusterBlock block : blocks) { sb.append("[").append(block.status()).append("/").append(block.id()).append("/").append(block.description()).append("];"); } return sb.toString(); }
@Override protected ClusterBlockException checkRequestBlock(ClusterState state, ClearIndicesCacheRequest request, String[] concreteIndices) { return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, concreteIndices); } }
public static ClusterBlock readClusterBlock(StreamInput in) throws IOException { ClusterBlock block = new ClusterBlock(); block.readFrom(in); return block; }
public boolean hasGlobalBlock(int blockId) { for (ClusterBlock clusterBlock : global) { if (clusterBlock.id() == blockId) { return true; } } return false; }
public boolean retryable() { for (ClusterBlock block : blocks) { if (!block.retryable()) { return false; } } return true; }
/** * Returns {@code true} if one of the global blocks as its disable state persistence flag set. */ public boolean disableStatePersistence() { for (ClusterBlock clusterBlock : global) { if (clusterBlock.disableStatePersistence()) { return true; } } return false; }
public ClusterBlockException(Set<ClusterBlock> blocks) { super(buildMessage(blocks)); this.blocks = blocks; }
public static Builder builder() { return new Builder(); }
public PingResponse(DiscoveryNode node, DiscoveryNode master, ClusterState state) { this(node, master, state.getClusterName(), state.blocks().hasGlobalBlock(STATE_NOT_RECOVERED_BLOCK) ? ElectMasterService.MasterCandidate.UNRECOVERED_CLUSTER_VERSION : state.version()); }
ClusterBlocks(Set<ClusterBlock> global, ImmutableOpenMap<String, Set<ClusterBlock>> indicesBlocks) { this.global = global; this.indicesBlocks = indicesBlocks; levelHolders = generateLevelHolders(global, indicesBlocks); }
boolean isRetryableClusterBlockException(final Throwable e) { if (e instanceof ClusterBlockException) { return ((ClusterBlockException) e).retryable(); } return false; }
@Override protected ClusterBlockException checkBlock(DeleteSnapshotRequest request, ClusterState state) { // Cluster is not affected but we look up repositories in metadata return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_READ); }
@Override protected ClusterBlockException checkRequestBlock(ClusterState state, RecoveryRequest request, String[] concreteIndices) { return state.blocks().indicesBlockedException(ClusterBlockLevel.READ, concreteIndices); } }
@Override protected ClusterBlockException checkBlock(Request request, ClusterState state) { // Cluster is not affected but we look up repositories in metadata return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE); }
@Override protected ClusterBlockException checkBlock(Request request, ClusterState state) { // Cluster is not affected but we look up repositories in metadata return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE); }
@Override protected ClusterBlockException checkBlock(RestoreSnapshotRequest request, ClusterState state) { // Restoring a snapshot might change the global state and create/change an index, // so we need to check for METADATA_WRITE and WRITE blocks ClusterBlockException blockException = state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE); if (blockException != null) { return blockException; } return state.blocks().globalBlockedException(ClusterBlockLevel.WRITE); }
@Override protected ClusterBlockException checkBlock(Request request, ClusterState state) { // Cluster is not affected but we look up repositories in metadata return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE); }