Tabnine Logo
DiscoveryNodes$Builder.remove
Code IndexAdd Tabnine to your IDE (free)

How to use
remove
method
in
org.elasticsearch.cluster.node.DiscoveryNodes$Builder

Best Java code snippets using org.elasticsearch.cluster.node.DiscoveryNodes$Builder.remove (Showing top 14 results out of 315)

origin: org.elasticsearch/elasticsearch

@Override
public ClusterTasksResult<Task> execute(final ClusterState currentState, final List<Task> tasks) throws Exception {
  final DiscoveryNodes.Builder remainingNodesBuilder = DiscoveryNodes.builder(currentState.nodes());
  boolean removed = false;
  for (final Task task : tasks) {
    if (currentState.nodes().nodeExists(task.node())) {
      remainingNodesBuilder.remove(task.node());
      removed = true;
    } else {
      logger.debug("node [{}] does not exist in cluster state, ignoring", task);
    }
  }
  if (!removed) {
    // no nodes to remove, keep the current cluster state
    return ClusterTasksResult.<Task>builder().successes(tasks).build(currentState);
  }
  final ClusterState remainingNodesClusterState = remainingNodesClusterState(currentState, remainingNodesBuilder);
  final ClusterTasksResult.Builder<Task> resultBuilder = ClusterTasksResult.<Task>builder().successes(tasks);
  if (electMasterService.hasEnoughMasterNodes(remainingNodesClusterState.nodes()) == false) {
    final int masterNodes = electMasterService.countMasterNodes(remainingNodesClusterState.nodes());
    rejoin.accept(LoggerMessageFormat.format("not enough master nodes (has [{}], but needed [{}])",
                         masterNodes, electMasterService.minimumMasterNodes()));
    return resultBuilder.build(currentState);
  } else {
    return resultBuilder.build(allocationService.deassociateDeadNodes(remainingNodesClusterState, true, describeTasks(tasks)));
  }
}
origin: org.elasticsearch/elasticsearch

private ClusterState.Builder becomeMasterAndTrimConflictingNodes(ClusterState currentState, List<DiscoveryNode> joiningNodes) {
  assert currentState.nodes().getMasterNodeId() == null : currentState;
  DiscoveryNodes currentNodes = currentState.nodes();
  DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(currentNodes);
  nodesBuilder.masterNodeId(currentState.nodes().getLocalNodeId());
  for (final DiscoveryNode joiningNode : joiningNodes) {
    final DiscoveryNode nodeWithSameId = nodesBuilder.get(joiningNode.getId());
    if (nodeWithSameId != null && nodeWithSameId.equals(joiningNode) == false) {
      logger.debug("removing existing node [{}], which conflicts with incoming join from [{}]", nodeWithSameId, joiningNode);
      nodesBuilder.remove(nodeWithSameId.getId());
    }
    final DiscoveryNode nodeWithSameAddress = currentNodes.findByAddress(joiningNode.getAddress());
    if (nodeWithSameAddress != null && nodeWithSameAddress.equals(joiningNode) == false) {
      logger.debug("removing existing node [{}], which conflicts with incoming join from [{}]", nodeWithSameAddress,
        joiningNode);
      nodesBuilder.remove(nodeWithSameAddress.getId());
    }
  }
  // now trim any left over dead nodes - either left there when the previous master stepped down
  // or removed by us above
  ClusterState tmpState = ClusterState.builder(currentState).nodes(nodesBuilder).blocks(ClusterBlocks.builder()
    .blocks(currentState.blocks())
    .removeGlobalBlock(DiscoverySettings.NO_MASTER_BLOCK_ID)).build();
  return ClusterState.builder(allocationService.deassociateDeadNodes(tmpState, false,
    "removed dead nodes on election"));
}
origin: harbby/presto-connectors

for (DiscoveryNode existingNode : currentState.nodes()) {
  if (node.address().equals(existingNode.address())) {
    nodesBuilder.remove(existingNode.id());
    logger.warn("received join request from node [{}], but found existing node {} with same address, removing existing node", node, existingNode);
origin: harbby/presto-connectors

clusterStateChanged = true;
logger.info("[{}] removing node [{}]", tribeName, discoNode);
nodes.remove(discoNode.id());
origin: org.codelibs.elasticsearch.module/tribe

  clusterStateChanged = true;
  logger.info("[{}] removing node [{}]", tribeName, discoNode);
  nodes.remove(discoNode.getId());
clusterStateChanged = true;
logger.info("[{}] adding node [{}]", tribeName, discoNode);
nodes.remove(tribe.getId()); // remove any existing node with the same id but different ephemeral id
nodes.add(discoNode);
origin: com.strapdata.elasticsearch/elasticsearch

  clusterStateChanged = true;
  logger.info("[{}] removing node [{}]", tribeName, discoNode);
  nodes.remove(discoNode.getId());
clusterStateChanged = true;
logger.info("[{}] adding node [{}]", tribeName, discoNode);
nodes.remove(tribe.getId()); // remove any existing node with the same id but different ephemeral id
nodes.add(discoNode);
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

@Override
public ClusterTasksResult<Task> execute(final ClusterState currentState, final List<Task> tasks) throws Exception {
  final DiscoveryNodes.Builder remainingNodesBuilder = DiscoveryNodes.builder(currentState.nodes());
  boolean removed = false;
  for (final Task task : tasks) {
    if (currentState.nodes().nodeExists(task.node())) {
      remainingNodesBuilder.remove(task.node());
      removed = true;
    } else {
      logger.debug("node [{}] does not exist in cluster state, ignoring", task);
    }
  }
  if (!removed) {
    // no nodes to remove, keep the current cluster state
    return ClusterTasksResult.<Task>builder().successes(tasks).build(currentState);
  }
  final ClusterState remainingNodesClusterState = remainingNodesClusterState(currentState, remainingNodesBuilder);
  final ClusterTasksResult.Builder<Task> resultBuilder = ClusterTasksResult.<Task>builder().successes(tasks);
  if (electMasterService.hasEnoughMasterNodes(remainingNodesClusterState.nodes()) == false) {
    final int masterNodes = electMasterService.countMasterNodes(remainingNodesClusterState.nodes());
    rejoin.accept(LoggerMessageFormat.format("not enough master nodes (has [{}], but needed [{}])",
                         masterNodes, electMasterService.minimumMasterNodes()));
    return resultBuilder.build(currentState);
  } else {
    return resultBuilder.build(allocationService.deassociateDeadNodes(remainingNodesClusterState, true, describeTasks(tasks)));
  }
}
origin: com.strapdata.elasticsearch/elasticsearch

@Override
public ClusterTasksResult<Task> execute(final ClusterState currentState, final List<Task> tasks) throws Exception {
  final DiscoveryNodes.Builder remainingNodesBuilder = DiscoveryNodes.builder(currentState.nodes());
  boolean removed = false;
  for (final Task task : tasks) {
    if (currentState.nodes().nodeExists(task.node())) {
      remainingNodesBuilder.remove(task.node());
      removed = true;
    } else {
      logger.debug("node [{}] does not exist in cluster state, ignoring", task);
    }
  }
  if (!removed) {
    // no nodes to remove, keep the current cluster state
    return ClusterTasksResult.<Task>builder().successes(tasks).build(currentState);
  }
  final ClusterState remainingNodesClusterState = remainingNodesClusterState(currentState, remainingNodesBuilder);
  final ClusterTasksResult.Builder<Task> resultBuilder = ClusterTasksResult.<Task>builder().successes(tasks);
  if (electMasterService.hasEnoughMasterNodes(remainingNodesClusterState.nodes()) == false) {
    final int masterNodes = electMasterService.countMasterNodes(remainingNodesClusterState.nodes());
    rejoin.accept(LoggerMessageFormat.format("not enough master nodes (has [{}], but needed [{}])",
                         masterNodes, electMasterService.minimumMasterNodes()));
    return resultBuilder.build(currentState);
  } else {
    return resultBuilder.build(allocationService.deassociateDeadNodes(remainingNodesClusterState, true, describeTasks(tasks)));
  }
}
origin: com.strapdata.elasticsearch/elasticsearch

private ClusterState.Builder becomeMasterAndTrimConflictingNodes(ClusterState currentState, List<DiscoveryNode> joiningNodes) {
  assert currentState.nodes().getMasterNodeId() == null : currentState;
  DiscoveryNodes currentNodes = currentState.nodes();
  DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(currentNodes);
  nodesBuilder.masterNodeId(currentState.nodes().getLocalNodeId());
  for (final DiscoveryNode joiningNode : joiningNodes) {
    if (joiningNode == FINISH_ELECTION_TASK || joiningNode == BECOME_MASTER_TASK) {
      continue;
    }
    final DiscoveryNode nodeWithSameId = nodesBuilder.get(joiningNode.getId());
    if (nodeWithSameId != null && nodeWithSameId.equals(joiningNode) == false) {
      logger.debug("removing existing node [{}], which conflicts with incoming join from [{}]", nodeWithSameId, joiningNode);
      nodesBuilder.remove(nodeWithSameId.getId());
    }
    final DiscoveryNode nodeWithSameAddress = currentNodes.findByAddress(joiningNode.getAddress());
    if (nodeWithSameAddress != null && nodeWithSameAddress.equals(joiningNode) == false) {
      logger.debug("removing existing node [{}], which conflicts with incoming join from [{}]", nodeWithSameAddress,
        joiningNode);
      nodesBuilder.remove(nodeWithSameAddress.getId());
    }
  }
  // now trim any left over dead nodes - either left there when the previous master stepped down
  // or removed by us above
  ClusterState tmpState = ClusterState.builder(currentState).nodes(nodesBuilder).build();
  return ClusterState.builder(allocationService.deassociateDeadNodes(tmpState, false,
    "removed dead nodes on election"));
}
origin: harbby/presto-connectors

@Override
public BatchResult<Task> execute(final ClusterState currentState, final List<Task> tasks) throws Exception {
  final DiscoveryNodes.Builder remainingNodesBuilder = DiscoveryNodes.builder(currentState.nodes());
  boolean removed = false;
  for (final Task task : tasks) {
    if (currentState.nodes().nodeExists(task.node().getId())) {
      remainingNodesBuilder.remove(task.node().getId());
      removed = true;
    } else {
      logger.debug("node [{}] does not exist in cluster state, ignoring", task);
    }
  }
  if (!removed) {
    // no nodes to remove, keep the current cluster state
    return BatchResult.<Task>builder().successes(tasks).build(currentState);
  }
  final ClusterState remainingNodesClusterState = remainingNodesClusterState(currentState, remainingNodesBuilder);
  final BatchResult.Builder<Task> resultBuilder = BatchResult.<Task>builder().successes(tasks);
  if (!electMasterService.hasEnoughMasterNodes(remainingNodesClusterState.nodes())) {
    return resultBuilder.build(rejoin.apply(remainingNodesClusterState, "not enough master nodes"));
  } else {
    final RoutingAllocation.Result routingResult = allocationService.reroute(remainingNodesClusterState, Joiner.on(",").join(tasks));
    return resultBuilder.build(ClusterState.builder(remainingNodesClusterState).routingResult(routingResult).build());
  }
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

private ClusterState.Builder becomeMasterAndTrimConflictingNodes(ClusterState currentState, List<DiscoveryNode> joiningNodes) {
  assert currentState.nodes().getMasterNodeId() == null : currentState;
  DiscoveryNodes currentNodes = currentState.nodes();
  DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(currentNodes);
  nodesBuilder.masterNodeId(currentState.nodes().getLocalNodeId());
  for (final DiscoveryNode joiningNode : joiningNodes) {
    final DiscoveryNode nodeWithSameId = nodesBuilder.get(joiningNode.getId());
    if (nodeWithSameId != null && nodeWithSameId.equals(joiningNode) == false) {
      logger.debug("removing existing node [{}], which conflicts with incoming join from [{}]", nodeWithSameId, joiningNode);
      nodesBuilder.remove(nodeWithSameId.getId());
    }
    final DiscoveryNode nodeWithSameAddress = currentNodes.findByAddress(joiningNode.getAddress());
    if (nodeWithSameAddress != null && nodeWithSameAddress.equals(joiningNode) == false) {
      logger.debug("removing existing node [{}], which conflicts with incoming join from [{}]", nodeWithSameAddress,
        joiningNode);
      nodesBuilder.remove(nodeWithSameAddress.getId());
    }
  }
  // now trim any left over dead nodes - either left there when the previous master stepped down
  // or removed by us above
  ClusterState tmpState = ClusterState.builder(currentState).nodes(nodesBuilder).blocks(ClusterBlocks.builder()
    .blocks(currentState.blocks())
    .removeGlobalBlock(DiscoverySettings.NO_MASTER_BLOCK_ID)).build();
  return ClusterState.builder(allocationService.deassociateDeadNodes(tmpState, false,
    "removed dead nodes on election"));
}
origin: apache/servicemix-bundles

@Override
public ClusterTasksResult<Task> execute(final ClusterState currentState, final List<Task> tasks) throws Exception {
  final DiscoveryNodes.Builder remainingNodesBuilder = DiscoveryNodes.builder(currentState.nodes());
  boolean removed = false;
  for (final Task task : tasks) {
    if (currentState.nodes().nodeExists(task.node())) {
      remainingNodesBuilder.remove(task.node());
      removed = true;
    } else {
      logger.debug("node [{}] does not exist in cluster state, ignoring", task);
    }
  }
  if (!removed) {
    // no nodes to remove, keep the current cluster state
    return ClusterTasksResult.<Task>builder().successes(tasks).build(currentState);
  }
  final ClusterState remainingNodesClusterState = remainingNodesClusterState(currentState, remainingNodesBuilder);
  final ClusterTasksResult.Builder<Task> resultBuilder = ClusterTasksResult.<Task>builder().successes(tasks);
  if (electMasterService.hasEnoughMasterNodes(remainingNodesClusterState.nodes()) == false) {
    final int masterNodes = electMasterService.countMasterNodes(remainingNodesClusterState.nodes());
    rejoin.accept(LoggerMessageFormat.format("not enough master nodes (has [{}], but needed [{}])",
                         masterNodes, electMasterService.minimumMasterNodes()));
    return resultBuilder.build(currentState);
  } else {
    return resultBuilder.build(allocationService.deassociateDeadNodes(remainingNodesClusterState, true, describeTasks(tasks)));
  }
}
origin: apache/servicemix-bundles

private ClusterState.Builder becomeMasterAndTrimConflictingNodes(ClusterState currentState, List<DiscoveryNode> joiningNodes) {
  assert currentState.nodes().getMasterNodeId() == null : currentState;
  DiscoveryNodes currentNodes = currentState.nodes();
  DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(currentNodes);
  nodesBuilder.masterNodeId(currentState.nodes().getLocalNodeId());
  for (final DiscoveryNode joiningNode : joiningNodes) {
    final DiscoveryNode nodeWithSameId = nodesBuilder.get(joiningNode.getId());
    if (nodeWithSameId != null && nodeWithSameId.equals(joiningNode) == false) {
      logger.debug("removing existing node [{}], which conflicts with incoming join from [{}]", nodeWithSameId, joiningNode);
      nodesBuilder.remove(nodeWithSameId.getId());
    }
    final DiscoveryNode nodeWithSameAddress = currentNodes.findByAddress(joiningNode.getAddress());
    if (nodeWithSameAddress != null && nodeWithSameAddress.equals(joiningNode) == false) {
      logger.debug("removing existing node [{}], which conflicts with incoming join from [{}]", nodeWithSameAddress,
        joiningNode);
      nodesBuilder.remove(nodeWithSameAddress.getId());
    }
  }
  // now trim any left over dead nodes - either left there when the previous master stepped down
  // or removed by us above
  ClusterState tmpState = ClusterState.builder(currentState).nodes(nodesBuilder).blocks(ClusterBlocks.builder()
    .blocks(currentState.blocks())
    .removeGlobalBlock(DiscoverySettings.NO_MASTER_BLOCK_ID)).build();
  return ClusterState.builder(allocationService.deassociateDeadNodes(tmpState, false,
    "removed dead nodes on election"));
}
origin: harbby/presto-connectors

@Override
public ClusterState execute(ClusterState currentState) {
  if (!masterNode.id().equals(currentState.nodes().masterNodeId())) {
    // master got switched on us, no need to send anything
    return currentState;
  }
  DiscoveryNodes discoveryNodes = DiscoveryNodes.builder(currentState.nodes())
      // make sure the old master node, which has failed, is not part of the nodes we publish
      .remove(masterNode.id())
      .masterNodeId(null).build();
  // flush any pending cluster states from old master, so it will not be set as master again
  ArrayList<ProcessClusterState> pendingNewClusterStates = new ArrayList<>();
  processNewClusterStates.drainTo(pendingNewClusterStates);
  logger.trace("removed [{}] pending cluster states", pendingNewClusterStates.size());
  return rejoin(ClusterState.builder(currentState).nodes(discoveryNodes).build(), "master left (reason = " + reason + ")");
}
org.elasticsearch.cluster.nodeDiscoveryNodes$Builderremove

Popular methods of DiscoveryNodes$Builder

  • localNodeId
  • build
  • masterNodeId
  • add
    adds a disco node to the builder. Will throw an IllegalArgumentException if the supplied node doesn'
  • <init>
  • put
  • get
    Get a node by its id
  • isLocalNodeElectedMaster
  • putUnsafe
  • validateAdd
    Checks that a node can be safely added to this node collection.
  • readFrom
  • readFrom

Popular in Java

  • Running tasks concurrently on multiple threads
  • getApplicationContext (Context)
  • onRequestPermissionsResult (Fragment)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Best plugins for Eclipse
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