public ClusterBlockException indexBlockedException(ClusterBlockLevel level, String index) { if (!indexBlocked(level, index)) { return null; } Stream<ClusterBlock> blocks = concat( global(level).stream(), blocksForIndex(level, index).stream()); return new ClusterBlockException(unmodifiableSet(blocks.collect(toSet()))); }
public ClusterBlockException indicesBlockedException(ClusterBlockLevel level, String[] indices) { boolean indexIsBlocked = false; for (String index : indices) { if (indexBlocked(level, index)) { indexIsBlocked = true; } } if (globalBlocked(level) == false && indexIsBlocked == false) { return null; } Function<String, Stream<ClusterBlock>> blocksForIndexAtLevel = index -> blocksForIndex(level, index).stream(); Stream<ClusterBlock> blocks = concat( global(level).stream(), Stream.of(indices).flatMap(blocksForIndexAtLevel)); return new ClusterBlockException(unmodifiableSet(blocks.collect(toSet()))); }
static IndexMetaData validateResize(ClusterState state, String sourceIndex, Set<String> targetIndexMappingsTypes, String targetIndexName, Settings targetIndexSettings) { if (state.metaData().hasIndex(targetIndexName)) { throw new ResourceAlreadyExistsException(state.metaData().index(targetIndexName).getIndex()); } final IndexMetaData sourceMetaData = state.metaData().index(sourceIndex); if (sourceMetaData == null) { throw new IndexNotFoundException(sourceIndex); } // ensure index is read-only if (state.blocks().indexBlocked(ClusterBlockLevel.WRITE, sourceIndex) == false) { throw new IllegalStateException("index " + sourceIndex + " must be read-only to resize index. use \"index.blocks.write=true\""); } if ((targetIndexMappingsTypes.size() > 1 || (targetIndexMappingsTypes.isEmpty() || targetIndexMappingsTypes.contains(MapperService.DEFAULT_MAPPING)) == false)) { throw new IllegalArgumentException("mappings are not allowed when resizing indices" + ", all mappings are copied from the source index"); } if (IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.exists(targetIndexSettings)) { // this method applies all necessary checks ie. if the target shards are less than the source shards // of if the source shards are divisible by the number of target shards IndexMetaData.getRoutingFactor(sourceMetaData.getNumberOfShards(), IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.get(targetIndexSettings)); } return sourceMetaData; }
reroute(); indicesToMarkReadOnly.removeIf(index -> state.getBlocks().indexBlocked(ClusterBlockLevel.WRITE, index)); if (indicesToMarkReadOnly.isEmpty() == false) { markIndicesReadOnly(indicesToMarkReadOnly);
public ClusterBlockException indexBlockedException(ClusterBlockLevel level, String index) { if (!indexBlocked(level, index)) { return null; } Stream<ClusterBlock> blocks = concat( global(level).stream(), blocksForIndex(level, index).stream()); return new ClusterBlockException(unmodifiableSet(blocks.collect(toSet()))); }
public ClusterBlockException indexBlockedException(ClusterBlockLevel level, String index) { if (!indexBlocked(level, index)) { return null; } Stream<ClusterBlock> blocks = concat( global(level).stream(), blocksForIndex(level, index).stream()); return new ClusterBlockException(unmodifiableSet(blocks.collect(toSet()))); }
public ClusterBlockException indexBlockedException(ClusterBlockLevel level, String index) { if (!indexBlocked(level, index)) { return null; } Stream<ClusterBlock> blocks = concat( global(level).stream(), blocksForIndex(level, index).stream()); return new ClusterBlockException(unmodifiableSet(blocks.collect(toSet()))); }
public ClusterBlockException indicesBlockedException(ClusterBlockLevel level, String[] indices) { boolean indexIsBlocked = false; for (String index : indices) { if (indexBlocked(level, index)) { indexIsBlocked = true; } } if (globalBlocked(level) == false && indexIsBlocked == false) { return null; } Function<String, Stream<ClusterBlock>> blocksForIndexAtLevel = index -> blocksForIndex(level, index).stream(); Stream<ClusterBlock> blocks = concat( global(level).stream(), Stream.of(indices).flatMap(blocksForIndexAtLevel)); return new ClusterBlockException(unmodifiableSet(blocks.collect(toSet()))); }
public ClusterBlockException indicesBlockedException(ClusterBlockLevel level, String[] indices) { boolean indexIsBlocked = false; for (String index : indices) { if (indexBlocked(level, index)) { indexIsBlocked = true; } } if (globalBlocked(level) == false && indexIsBlocked == false) { return null; } Function<String, Stream<ClusterBlock>> blocksForIndexAtLevel = index -> blocksForIndex(level, index).stream(); Stream<ClusterBlock> blocks = concat( global(level).stream(), Stream.of(indices).flatMap(blocksForIndexAtLevel)); return new ClusterBlockException(unmodifiableSet(blocks.collect(toSet()))); }
public ClusterBlockException indicesBlockedException(ClusterBlockLevel level, String[] indices) { boolean indexIsBlocked = false; for (String index : indices) { if (indexBlocked(level, index)) { indexIsBlocked = true; } } if (globalBlocked(level) == false && indexIsBlocked == false) { return null; } Function<String, Stream<ClusterBlock>> blocksForIndexAtLevel = index -> blocksForIndex(level, index).stream(); Stream<ClusterBlock> blocks = concat( global(level).stream(), Stream.of(indices).flatMap(blocksForIndexAtLevel)); return new ClusterBlockException(unmodifiableSet(blocks.collect(toSet()))); }
static IndexMetaData validateResize(ClusterState state, String sourceIndex, Set<String> targetIndexMappingsTypes, String targetIndexName, Settings targetIndexSettings) { if (state.metaData().hasIndex(targetIndexName)) { throw new ResourceAlreadyExistsException(state.metaData().index(targetIndexName).getIndex()); } final IndexMetaData sourceMetaData = state.metaData().index(sourceIndex); if (sourceMetaData == null) { throw new IndexNotFoundException(sourceIndex); } // ensure index is read-only if (state.blocks().indexBlocked(ClusterBlockLevel.WRITE, sourceIndex) == false) { throw new IllegalStateException("index " + sourceIndex + " must be read-only to resize index. use \"index.blocks.write=true\""); } if ((targetIndexMappingsTypes.size() > 1 || (targetIndexMappingsTypes.isEmpty() || targetIndexMappingsTypes.contains(MapperService.DEFAULT_MAPPING)) == false)) { throw new IllegalArgumentException("mappings are not allowed when resizing indices" + ", all mappings are copied from the source index"); } if (IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.exists(targetIndexSettings)) { // this method applies all necessary checks ie. if the target shards are less than the source shards // of if the source shards are divisible by the number of target shards IndexMetaData.getRoutingFactor(sourceMetaData.getNumberOfShards(), IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.get(targetIndexSettings)); } return sourceMetaData; }
if (state.blocks().indexBlocked(ClusterBlockLevel.WRITE, sourceIndex) == false) { throw new IllegalStateException("index " + sourceIndex + " must be read-only to shrink index. use \"index.blocks.write=true\"");
static IndexMetaData validateResize(ClusterState state, String sourceIndex, Set<String> targetIndexMappingsTypes, String targetIndexName, Settings targetIndexSettings) { if (state.metaData().hasIndex(targetIndexName)) { throw new ResourceAlreadyExistsException(state.metaData().index(targetIndexName).getIndex()); } final IndexMetaData sourceMetaData = state.metaData().index(sourceIndex); if (sourceMetaData == null) { throw new IndexNotFoundException(sourceIndex); } // ensure index is read-only if (state.blocks().indexBlocked(ClusterBlockLevel.WRITE, sourceIndex) == false) { throw new IllegalStateException("index " + sourceIndex + " must be read-only to resize index. use \"index.blocks.write=true\""); } if ((targetIndexMappingsTypes.size() > 1 || (targetIndexMappingsTypes.isEmpty() || targetIndexMappingsTypes.contains(MapperService.DEFAULT_MAPPING)) == false)) { throw new IllegalArgumentException("mappings are not allowed when resizing indices" + ", all mappings are copied from the source index"); } if (IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.exists(targetIndexSettings)) { // this method applies all necessary checks ie. if the target shards are less than the source shards // of if the source shards are divisible by the number of target shards IndexMetaData.getRoutingFactor(sourceMetaData.getNumberOfShards(), IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.get(targetIndexSettings)); } return sourceMetaData; }
public ClusterBlockException indexBlockedException(ClusterBlockLevel level, String index) { if (!indexBlocked(level, index)) { return null; } ImmutableSet.Builder<ClusterBlock> builder = ImmutableSet.builder(); builder.addAll(global(level)); ImmutableSet<ClusterBlock> indexBlocks = indices(level).get(index); if (indexBlocks != null) { builder.addAll(indexBlocks); } return new ClusterBlockException(builder.build()); }
reroute(); indicesToMarkReadOnly.removeIf(index -> state.getBlocks().indexBlocked(ClusterBlockLevel.WRITE, index)); if (indicesToMarkReadOnly.isEmpty() == false) { markIndicesReadOnly(indicesToMarkReadOnly);
reroute(); indicesToMarkReadOnly.removeIf(index -> state.getBlocks().indexBlocked(ClusterBlockLevel.WRITE, index)); if (indicesToMarkReadOnly.isEmpty() == false) { markIndicesReadOnly(indicesToMarkReadOnly);
public ClusterBlockException indicesBlockedException(ClusterBlockLevel level, String[] indices) { boolean indexIsBlocked = false; for (String index : indices) { if (indexBlocked(level, index)) { indexIsBlocked = true; } } if (globalBlocked(level) == false && indexIsBlocked == false) { return null; } ImmutableSet.Builder<ClusterBlock> builder = ImmutableSet.builder(); builder.addAll(global(level)); for (String index : indices) { ImmutableSet<ClusterBlock> indexBlocks = indices(level).get(index); if (indexBlocks != null) { builder.addAll(indexBlocks); } } return new ClusterBlockException(builder.build()); }