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(); }
public static ClusterBlock readClusterBlock(StreamInput in) throws IOException { ClusterBlock block = new ClusterBlock(); block.readFrom(in); return block; }
private static EnumMap<ClusterBlockLevel, ImmutableLevelHolder> generateLevelHolders(Set<ClusterBlock> global, ImmutableOpenMap<String, Set<ClusterBlock>> indicesBlocks) { EnumMap<ClusterBlockLevel, ImmutableLevelHolder> levelHolders = new EnumMap<>(ClusterBlockLevel.class); for (final ClusterBlockLevel level : ClusterBlockLevel.values()) { Predicate<ClusterBlock> containsLevel = block -> block.contains(level); Set<ClusterBlock> newGlobal = unmodifiableSet(global.stream() .filter(containsLevel) .collect(toSet())); ImmutableOpenMap.Builder<String, Set<ClusterBlock>> indicesBuilder = ImmutableOpenMap.builder(); for (ObjectObjectCursor<String, Set<ClusterBlock>> entry : indicesBlocks) { indicesBuilder.put(entry.key, unmodifiableSet(entry.value.stream() .filter(containsLevel) .collect(toSet()))); } levelHolders.put(level, new ImmutableLevelHolder(newGlobal, indicesBuilder.build())); } return levelHolders; }
public boolean hasGlobalBlock(int blockId) { for (ClusterBlock clusterBlock : global) { if (clusterBlock.id() == blockId) { return true; } } return false; }
public ClusterBlockException(StreamInput in) throws IOException { super(in); int totalBlocks = in.readVInt(); Set<ClusterBlock> blocks = new HashSet<>(totalBlocks); for (int i = 0; i < totalBlocks;i++) { blocks.add(ClusterBlock.readClusterBlock(in)); } this.blocks = unmodifiableSet(blocks); }
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; }
builder.startObject("global"); for (ClusterBlock block : blocks().global()) { block.toXContent(builder, params); builder.startObject(entry.key); for (ClusterBlock block : entry.value) { block.toXContent(builder, params);
public interface Custom extends NamedDiffable<Custom>, ToXContentFragment, ClusterState.FeatureAware { EnumSet<XContentContext> context(); }
public Builder removeGlobalBlock(int blockId) { global.removeIf(block -> block.id() == blockId); return this; }
private static Set<ClusterBlock> readBlockSet(StreamInput in) throws IOException { int totalBlocks = in.readVInt(); Set<ClusterBlock> blocks = new HashSet<>(totalBlocks); for (int i = 0; i < totalBlocks;i++) { blocks.add(ClusterBlock.readClusterBlock(in)); } return unmodifiableSet(blocks); }
/** * Is there a global block with the provided status? */ public boolean hasGlobalBlock(RestStatus status) { for (ClusterBlock clusterBlock : global) { if (clusterBlock.status().equals(status)) { return true; } } return false; }
public boolean retryable() { for (ClusterBlock block : blocks) { if (!block.retryable()) { return false; } } return true; }
/** * Returns <tt>true</tt> 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; }
builder.startObject("global"); for (ClusterBlock block : blocks().global()) { block.toXContent(builder, params); builder.startObject(entry.getKey()); for (ClusterBlock block : entry.getValue()) { block.toXContent(builder, params);
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(); }
public boolean hasGlobalBlock(int blockId) { for (ClusterBlock clusterBlock : global) { if (clusterBlock.id() == blockId) { return true; } } return false; }
public static ClusterBlock readClusterBlock(StreamInput in) throws IOException { ClusterBlock block = new ClusterBlock(); block.readFrom(in); return block; }
public ClusterBlockException(StreamInput in) throws IOException { super(in); int totalBlocks = in.readVInt(); Set<ClusterBlock> blocks = new HashSet<>(totalBlocks); for (int i = 0; i < totalBlocks;i++) { blocks.add(ClusterBlock.readClusterBlock(in)); } this.blocks = unmodifiableSet(blocks); }