Tabnine Logo
ClusterBlocks
Code IndexAdd Tabnine to your IDE (free)

How to use
ClusterBlocks
in
org.elasticsearch.cluster.block

Best Java code snippets using org.elasticsearch.cluster.block.ClusterBlocks (Showing top 20 results out of 315)

origin: org.elasticsearch/elasticsearch

public void globalBlockedRaiseException(ClusterBlockLevel level) throws ClusterBlockException {
  ClusterBlockException blockException = globalBlockedException(level);
  if (blockException != null) {
    throw blockException;
  }
}
origin: org.elasticsearch/elasticsearch

  @Override
  protected ClusterBlockException checkRequestBlock(ClusterState state, ClearIndicesCacheRequest request, String[] concreteIndices) {
    return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, concreteIndices);
  }
}
origin: org.elasticsearch/elasticsearch

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;
}
origin: org.elasticsearch/elasticsearch

public boolean indexBlocked(ClusterBlockLevel level, String index) {
  return globalBlocked(level) || blocksForIndex(level, index).isEmpty() == false;
}
origin: org.elasticsearch/elasticsearch

public ClusterBlockException globalBlockedException(ClusterBlockLevel level) {
  if (globalBlocked(level) == false) {
    return null;
  }
  return new ClusterBlockException(global(level));
}
origin: org.elasticsearch/elasticsearch

public Builder blocks(ClusterBlocks blocks) {
  global.addAll(blocks.global());
  for (ObjectObjectCursor<String, Set<ClusterBlock>> entry : blocks.indices()) {
    if (!indices.containsKey(entry.key)) {
      indices.put(entry.key, new HashSet<>());
    }
    indices.get(entry.key).addAll(entry.value);
  }
  return this;
}
origin: org.elasticsearch/elasticsearch

@Override
protected ClusterBlockException checkBlock(CreateSnapshotRequest request, ClusterState state) {
  // We are reading the cluster metadata and indices - so we need to check both blocks
  ClusterBlockException clusterBlockException = state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_READ);
  if (clusterBlockException != null) {
    return clusterBlockException;
  }
  return state.blocks()
    .indicesBlockedException(ClusterBlockLevel.READ, indexNameExpressionResolver.concreteIndexNames(state, request));
}
origin: org.elasticsearch/elasticsearch

@Override
protected void doStart() {
  DiscoveryNode localNode = transportService.getLocalNode();
  assert localNode != null;
  synchronized (stateMutex) {
    // set initial state
    assert committedState.get() == null;
    assert localNode != null;
    ClusterState.Builder builder = clusterApplier.newClusterStateBuilder();
    ClusterState initialState = builder
      .blocks(ClusterBlocks.builder()
        .addGlobalBlock(STATE_NOT_RECOVERED_BLOCK)
        .addGlobalBlock(discoverySettings.getNoMasterBlock()))
      .nodes(DiscoveryNodes.builder().add(localNode).localNodeId(localNode.getId()))
      .build();
    committedState.set(initialState);
    clusterApplier.setInitialState(initialState);
    nodesFD.setLocalNode(localNode);
    joinThreadControl.start();
  }
  zenPing.start();
}
origin: org.elasticsearch/elasticsearch

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())));
}
origin: org.elasticsearch/elasticsearch

@Override
protected void doExecute(MultiSearchRequest request, ActionListener<MultiSearchResponse> listener) {
  ClusterState clusterState = clusterService.state();
  clusterState.blocks().globalBlockedRaiseException(ClusterBlockLevel.READ);
  int maxConcurrentSearches = request.maxConcurrentSearchRequests();
  if (maxConcurrentSearches == MultiSearchRequest.MAX_CONCURRENT_SEARCH_REQUESTS_DEFAULT) {
    maxConcurrentSearches = defaultMaxConcurrentSearches(availableProcessors, clusterState);
  }
  Queue<SearchRequestSlot> searchRequestSlots = new ConcurrentLinkedQueue<>();
  for (int i = 0; i < request.requests().size(); i++) {
    SearchRequest searchRequest = request.requests().get(i);
    searchRequestSlots.add(new SearchRequestSlot(searchRequest, i));
  }
  int numRequests = request.requests().size();
  final AtomicArray<MultiSearchResponse.Item> responses = new AtomicArray<>(numRequests);
  final AtomicInteger responseCounter = new AtomicInteger(numRequests);
  int numConcurrentSearches = Math.min(numRequests, maxConcurrentSearches);
  for (int i = 0; i < numConcurrentSearches; i++) {
    executeSearch(searchRequestSlots, responses, responseCounter, listener);
  }
}
origin: org.elasticsearch/elasticsearch

public void indexBlockedRaiseException(ClusterBlockLevel level, String index) throws ClusterBlockException {
  ClusterBlockException blockException = indexBlockedException(level, index);
  if (blockException != null) {
    throw blockException;
  }
}
origin: org.elasticsearch/elasticsearch

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())));
}
origin: org.elasticsearch/elasticsearch

protected void rejoin(String reason) {
  assert Thread.holdsLock(stateMutex);
  ClusterState clusterState = committedState.get();
  logger.warn("{}, current nodes: {}", reason, clusterState.nodes());
  nodesFD.stop();
  masterFD.stop(reason);
  // TODO: do we want to force a new thread if we actively removed the master? this is to give a full pinging cycle
  // before a decision is made.
  joinThreadControl.startNewThreadIfNotRunning();
  if (clusterState.nodes().getMasterNodeId() != null) {
    // remove block if it already exists before adding new one
    assert clusterState.blocks().hasGlobalBlock(discoverySettings.getNoMasterBlock().id()) == false :
      "NO_MASTER_BLOCK should only be added by ZenDiscovery";
    ClusterBlocks clusterBlocks = ClusterBlocks.builder().blocks(clusterState.blocks())
      .addGlobalBlock(discoverySettings.getNoMasterBlock())
      .build();
    DiscoveryNodes discoveryNodes = new DiscoveryNodes.Builder(clusterState.nodes()).masterNodeId(null).build();
    clusterState = ClusterState.builder(clusterState)
      .blocks(clusterBlocks)
      .nodes(discoveryNodes)
      .build();
    committedState.set(clusterState);
    clusterApplier.onNewClusterState(reason, this::clusterState, (source, e) -> {}); // don't wait for state to be applied
  }
}
origin: org.elasticsearch/elasticsearch

@Override
public ClusterState execute(ClusterState currentState) {
  if (currentState.blocks().disableStatePersistence()) {
    return currentState;
  ClusterBlocks.Builder blocks = ClusterBlocks.builder().blocks(currentState.blocks());
  RoutingTable.Builder routingTableBuilder = RoutingTable.builder(currentState.routingTable());
  final Version minIndexCompatibilityVersion = currentState.getNodes().getMaxNodeVersion()
origin: org.elasticsearch/elasticsearch

  @Override
  public void clusterChanged(ClusterChangedEvent event) {
    if (event.state().blocks().disableStatePersistence() == false) {
      processDanglingIndices(event.state().metaData());
    }
  }
}
origin: org.elasticsearch/elasticsearch

  public ClusterBlocks build() {
    // We copy the block sets here in case of the builder is modified after build is called
    ImmutableOpenMap.Builder<String, Set<ClusterBlock>> indicesBuilder = ImmutableOpenMap.builder(indices.size());
    for (Map.Entry<String, Set<ClusterBlock>> entry : indices.entrySet()) {
      indicesBuilder.put(entry.getKey(), unmodifiableSet(new HashSet<>(entry.getValue())));
    }
    return new ClusterBlocks(unmodifiableSet(new HashSet<>(global)), indicesBuilder.build());
  }
}
origin: harbby/presto-connectors

protected AbstractSearchAsyncAction(ESLogger logger, SearchServiceTransportAction searchService, ClusterService clusterService,
                  IndexNameExpressionResolver indexNameExpressionResolver,
                  SearchPhaseController searchPhaseController, ThreadPool threadPool,
                  SearchRequest request, ActionListener<SearchResponse> listener) {
  this.logger = logger;
  this.searchService = searchService;
  this.indexNameExpressionResolver = indexNameExpressionResolver;
  this.searchPhaseController = searchPhaseController;
  this.threadPool = threadPool;
  this.request = request;
  this.listener = listener;
  this.clusterState = clusterService.state();
  nodes = clusterState.nodes();
  clusterState.blocks().globalBlockedRaiseException(ClusterBlockLevel.READ);
  // TODO: I think startTime() should become part of ActionRequest and that should be used both for index name
  // date math expressions and $now in scripts. This way all apis will deal with now in the same way instead
  // of just for the _search api
  String[] concreteIndices = indexNameExpressionResolver.concreteIndices(clusterState, request.indicesOptions(), startTime(), request.indices());
  for (String index : concreteIndices) {
    clusterState.blocks().indexBlockedRaiseException(ClusterBlockLevel.READ, index);
  }
  Map<String, Set<String>> routingMap = indexNameExpressionResolver.resolveSearchRouting(clusterState, request.routing(), request.indices());
  shardsIts = clusterService.operationRouting().searchShards(clusterState, concreteIndices, routingMap, request.preference());
  expectedSuccessfulOps = shardsIts.size();
  // we need to add 1 for non active partition, since we count it in the total!
  expectedTotalOps = shardsIts.totalSizeWith1ForEmpty();
  firstResults = new AtomicArray<>(shardsIts.size());
}
origin: org.elasticsearch/elasticsearch

/**
 * Returns <code>true</code> iff non of the given have a {@link ClusterBlockLevel#METADATA_WRITE} in place where the
 * {@link ClusterBlock#isAllowReleaseResources()} returns <code>false</code>. This is used in places where resources will be released
 * like the deletion of an index to free up resources on nodes.
 * @param indices the indices to check
 */
public ClusterBlockException indicesAllowReleaseResources(String[] indices) {
  final Function<String, Stream<ClusterBlock>> blocksForIndexAtLevel = index ->
    blocksForIndex(ClusterBlockLevel.METADATA_WRITE, index).stream();
  Stream<ClusterBlock> blocks = concat(
    global(ClusterBlockLevel.METADATA_WRITE).stream(),
    Stream.of(indices).flatMap(blocksForIndexAtLevel)).filter(clusterBlock -> clusterBlock.isAllowReleaseResources() == false);
  Set<ClusterBlock> clusterBlocks = unmodifiableSet(blocks.collect(toSet()));
  if (clusterBlocks.isEmpty()) {
    return null;
  }
  return new ClusterBlockException(clusterBlocks);
}
origin: harbby/presto-connectors

public boolean indexBlocked(ClusterBlockLevel level, String index) {
  if (globalBlocked(level)) {
    return true;
  }
  ImmutableSet<ClusterBlock> indexBlocks = indices(level).get(index);
  if (indexBlocks != null && !indexBlocks.isEmpty()) {
    return true;
  }
  return false;
}
origin: harbby/presto-connectors

@Override
public ClusterBlocks readFrom(StreamInput in) throws IOException {
  ImmutableSet<ClusterBlock> global = readBlockSet(in);
  ImmutableMap.Builder<String, ImmutableSet<ClusterBlock>> indicesBuilder = ImmutableMap.builder();
  int size = in.readVInt();
  for (int j = 0; j < size; j++) {
    indicesBuilder.put(in.readString().intern(), readBlockSet(in));
  }
  return new ClusterBlocks(global, indicesBuilder.build());
}
org.elasticsearch.cluster.blockClusterBlocks

Javadoc

Represents current cluster level blocks to block dirty operations done against the cluster.

Most used methods

  • globalBlockedException
  • indicesBlockedException
  • builder
  • globalBlockedRaiseException
  • indexBlockedException
  • <init>
  • diff
  • disableStatePersistence
    Returns true if one of the global blocks as its disable state persistence flag set.
  • global
  • globalBlocked
  • hasGlobalBlock
    Is there a global block with the provided status?
  • indexBlocked
  • hasGlobalBlock,
  • indexBlocked,
  • indexBlockedRaiseException,
  • indices,
  • readBlockSet,
  • readDiffFrom,
  • writeBlockSet,
  • writeTo,
  • blocksForIndex,
  • generateLevelHolders

Popular in Java

  • Making http requests using okhttp
  • scheduleAtFixedRate (Timer)
  • addToBackStack (FragmentTransaction)
  • getSupportFragmentManager (FragmentActivity)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • String (java.lang)
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now