org.elasticsearch.cluster.ClusterState.supersedes()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(72)

本文整理了Java中org.elasticsearch.cluster.ClusterState.supersedes()方法的一些代码示例,展示了ClusterState.supersedes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ClusterState.supersedes()方法的具体详情如下:
包路径:org.elasticsearch.cluster.ClusterState
类名称:ClusterState
方法名:supersedes

ClusterState.supersedes介绍

[英]a cluster state supersedes another state if they are from the same master and the version of this state is higher than that of the other state.

In essence that means that all the changes from the other cluster state are also reflected by the current one
[中]如果群集状态来自同一主机,并且此状态的版本高于其他状态,则群集状态将取代其他状态。
本质上,这意味着来自其他集群状态的所有更改也会反映在当前集群状态中

代码示例

代码示例来源:origin: org.elasticsearch/elasticsearch

ClusterStateContext potentialState = pendingStates.get(index);
if (potentialState.state.supersedes(stateToProcess.state) && potentialState.committed()) {

代码示例来源:origin: org.elasticsearch/elasticsearch

statesToRemove.add(pendingContext);
  pendingContext.listener.onNewClusterStateFailed(reason);
} else if (state.supersedes(pendingState)) {
  statesToRemove.add(pendingContext);
  logger.debug("failing committed state {} together with state {}", pendingContext, failedContext);

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
 * In the case we follow an elected master the new cluster state needs to have the same elected master and
 * the new cluster state version needs to be equal or higher than our cluster state version.
 * If the first condition fails we reject the cluster state and throw an error.
 * If the second condition fails we ignore the cluster state.
 */
public static boolean shouldIgnoreOrRejectNewClusterState(Logger logger, ClusterState currentState, ClusterState newClusterState) {
  validateStateIsFromCurrentMaster(logger, currentState.nodes(), newClusterState);
  // reject cluster states that are not new from the same master
  if (currentState.supersedes(newClusterState) ||
      (newClusterState.nodes().getMasterNodeId().equals(currentState.nodes().getMasterNodeId()) &&
        currentState.version() == newClusterState.version())) {
    // if the new state has a smaller version, and it has the same master node, then no need to process it
    logger.debug("received a cluster state that is not newer than the current one, ignoring (received {}, current {})",
      newClusterState.version(), currentState.version());
    return true;
  }
  // reject older cluster states if we are following a master
  if (currentState.nodes().getMasterNodeId() != null && newClusterState.version() < currentState.version()) {
    logger.debug("received a cluster state that has a lower version than the current one, ignoring (received {}, current {})",
      newClusterState.version(), currentState.version());
    return true;
  }
  return false;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

ClusterStateContext potentialState = pendingStates.get(index);
if (potentialState.state.supersedes(stateToProcess.state) && potentialState.committed()) {

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

ClusterStateContext potentialState = pendingStates.get(index);
if (potentialState.state.supersedes(stateToProcess.state) && potentialState.committed()) {

代码示例来源:origin: apache/servicemix-bundles

ClusterStateContext potentialState = pendingStates.get(index);
if (potentialState.state.supersedes(stateToProcess.state) && potentialState.committed()) {

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

statesToRemove.add(pendingContext);
  pendingContext.listener.onNewClusterStateFailed(reason);
} else if (state.supersedes(pendingState)) {
  statesToRemove.add(pendingContext);
  logger.debug("failing committed state {} together with state {}", pendingContext, failedContext);

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

statesToRemove.add(pendingContext);
  pendingContext.listener.onNewClusterStateFailed(reason);
} else if (state.supersedes(pendingState)) {
  statesToRemove.add(pendingContext);
  logger.debug("failing committed state {} together with state {}", pendingContext, failedContext);

代码示例来源:origin: apache/servicemix-bundles

statesToRemove.add(pendingContext);
  pendingContext.listener.onNewClusterStateFailed(reason);
} else if (state.supersedes(pendingState)) {
  statesToRemove.add(pendingContext);
  logger.debug("failing committed state {} together with state {}", pendingContext, failedContext);

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

/**
 * In the case we follow an elected master the new cluster state needs to have the same elected master and
 * the new cluster state version needs to be equal or higher than our cluster state version.
 * If the first condition fails we reject the cluster state and throw an error.
 * If the second condition fails we ignore the cluster state.
 */
public static boolean shouldIgnoreOrRejectNewClusterState(Logger logger, ClusterState currentState, ClusterState newClusterState) {
  validateStateIsFromCurrentMaster(logger, currentState.nodes(), newClusterState);
  // reject cluster states that are not new from the same master
  if (currentState.supersedes(newClusterState) ||
      (newClusterState.nodes().getMasterNodeId().equals(currentState.nodes().getMasterNodeId()) && currentState.version() == newClusterState.version())) {
    // if the new state has a smaller version, and it has the same master node, then no need to process it
    logger.debug("received a cluster state that is not newer than the current one, ignoring (received {}, current {})", newClusterState.version(), currentState.version());
    return true;
  }
  // reject older cluster states if we are following a master
  if (currentState.nodes().getMasterNodeId() != null && newClusterState.version() < currentState.version()) {
    logger.debug("received a cluster state that has a lower version than the current one, ignoring (received {}, current {})", newClusterState.version(), currentState.version());
    return true;
  }
  return false;
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

/**
 * In the case we follow an elected master the new cluster state needs to have the same elected master and
 * the new cluster state version needs to be equal or higher than our cluster state version.
 * If the first condition fails we reject the cluster state and throw an error.
 * If the second condition fails we ignore the cluster state.
 */
public static boolean shouldIgnoreOrRejectNewClusterState(Logger logger, ClusterState currentState, ClusterState newClusterState) {
  validateStateIsFromCurrentMaster(logger, currentState.nodes(), newClusterState);
  // reject cluster states that are not new from the same master
  if (currentState.supersedes(newClusterState) ||
      (newClusterState.nodes().getMasterNodeId().equals(currentState.nodes().getMasterNodeId()) && currentState.version() == newClusterState.version())) {
    // if the new state has a smaller version, and it has the same master node, then no need to process it
    logger.debug("received a cluster state that is not newer than the current one, ignoring (received {}, current {})", newClusterState.version(), currentState.version());
    return true;
  }
  // reject older cluster states if we are following a master
  if (currentState.nodes().getMasterNodeId() != null && newClusterState.version() < currentState.version()) {
    logger.debug("received a cluster state that has a lower version than the current one, ignoring (received {}, current {})", newClusterState.version(), currentState.version());
    return true;
  }
  return false;
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * In the case we follow an elected master the new cluster state needs to have the same elected master and
 * the new cluster state version needs to be equal or higher than our cluster state version.
 * If the first condition fails we reject the cluster state and throw an error.
 * If the second condition fails we ignore the cluster state.
 */
public static boolean shouldIgnoreOrRejectNewClusterState(Logger logger, ClusterState currentState, ClusterState newClusterState) {
  validateStateIsFromCurrentMaster(logger, currentState.nodes(), newClusterState);
  // reject cluster states that are not new from the same master
  if (currentState.supersedes(newClusterState) ||
      (newClusterState.nodes().getMasterNodeId().equals(currentState.nodes().getMasterNodeId()) && currentState.version() == newClusterState.version())) {
    // if the new state has a smaller version, and it has the same master node, then no need to process it
    logger.debug("received a cluster state that is not newer than the current one, ignoring (received {}, current {})", newClusterState.version(), currentState.version());
    return true;
  }
  // reject older cluster states if we are following a master
  if (currentState.nodes().getMasterNodeId() != null && newClusterState.version() < currentState.version()) {
    logger.debug("received a cluster state that has a lower version than the current one, ignoring (received {}, current {})", newClusterState.version(), currentState.version());
    return true;
  }
  return false;
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

@Override
public ClusterTasksResult<LocalClusterUpdateTask> execute(ClusterState currentState) {
  if (currentState.supersedes(nodeSpecificClusterState)) {
    return unchanged();
  }
  if (currentState.blocks().hasGlobalBlock(discoverySettings.getNoMasterBlock())) {
    // its a fresh update from the master as we transition from a start of not having a master to having one
    logger.debug("got first state from fresh master [{}]", nodeSpecificClusterState.nodes().getMasterNodeId());
    return newState(nodeSpecificClusterState);
  }
  ClusterState.Builder builder = ClusterState.builder(nodeSpecificClusterState);
  // if the routing table did not change, use the original one
  if (nodeSpecificClusterState.routingTable().version() == currentState.routingTable().version()) {
    builder.routingTable(currentState.routingTable());
  }
  if (nodeSpecificClusterState.metaData().version() == currentState.metaData().version()) {
    builder.metaData(currentState.metaData());
  }
  return newState(builder.build());
}

相关文章