org.elasticsearch.cluster.node.DiscoveryNodes.getDataNodes()方法的使用及代码示例

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

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

DiscoveryNodes.getDataNodes介绍

[英]Get a Map of the discovered data nodes arranged by their ids
[中]获取按ID排列的已发现数据节点的映射

代码示例

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

static int defaultMaxConcurrentSearches(int availableProcessors, ClusterState state) {
  int numDateNodes = state.getNodes().getDataNodes().size();
  // availableProcessors will never be larger than 32, so max defaultMaxConcurrentSearches will never be larger than 49,
  // but we don't know about about other search requests that are being executed so lets cap at 10 per node
  int defaultSearchThreadPoolSize = Math.min(ThreadPool.searchThreadPoolSize(availableProcessors), 10);
  return Math.max(1, numDateNodes * defaultSearchThreadPoolSize);
}

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

/**
 * Fills the shard fetched data with new (data) nodes and a fresh NodeEntry, and removes from
 * it nodes that are no longer part of the state.
 */
private void fillShardCacheWithDataNodes(Map<String, NodeEntry<T>> shardCache, DiscoveryNodes nodes) {
  // verify that all current data nodes are there
  for (ObjectObjectCursor<String, DiscoveryNode> cursor : nodes.getDataNodes()) {
    DiscoveryNode node = cursor.value;
    if (shardCache.containsKey(node.getId()) == false) {
      shardCache.put(node.getId(), new NodeEntry<T>(node.getId()));
    }
  }
  // remove nodes that are not longer part of the data nodes set
  shardCache.keySet().removeIf(nodeId -> !nodes.nodeExists(nodeId));
}

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

private boolean hasDeadNodes(RoutingAllocation allocation) {
  for (RoutingNode routingNode : allocation.routingNodes()) {
    if (allocation.nodes().getDataNodes().containsKey(routingNode.nodeId()) == false) {
      return true;
    }
  }
  return false;
}

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

continue;
for (ObjectCursor<DiscoveryNode> cursor : entry.getValue().getState().nodes().getDataNodes().values()) {
  newNodes.add(cursor.value);

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

/**
   * Checks if the are replicas with the auto-expand feature that need to be adapted.
   * Returns a map of updates, which maps the indices to be updated to the desired number of replicas.
   * The map has the desired number of replicas as key and the indices to update as value, as this allows the result
   * of this method to be directly applied to RoutingTable.Builder#updateNumberOfReplicas.
   */
  public static Map<Integer, List<String>> getAutoExpandReplicaChanges(MetaData metaData, DiscoveryNodes discoveryNodes) {
    // used for translating "all" to a number
    final int dataNodeCount = discoveryNodes.getDataNodes().size();

    Map<Integer, List<String>> nrReplicasChanged = new HashMap<>();

    for (final IndexMetaData indexMetaData : metaData) {
      if (indexMetaData.getState() != IndexMetaData.State.CLOSE) {
        AutoExpandReplicas autoExpandReplicas = SETTING.get(indexMetaData.getSettings());
        autoExpandReplicas.getDesiredNumberOfReplicas(dataNodeCount).ifPresent(numberOfReplicas -> {
          if (numberOfReplicas != indexMetaData.getNumberOfReplicas()) {
            nrReplicasChanged.computeIfAbsent(numberOfReplicas, ArrayList::new).add(indexMetaData.getIndex().getName());
          }
        });
      }
    }
    return nrReplicasChanged;
  }
}

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

@Override
public void onMaster() {
  this.isMaster = true;
  if (logger.isTraceEnabled()) {
    logger.trace("I have been elected master, scheduling a ClusterInfoUpdateJob");
  }
  try {
    // Submit a job that will start after DEFAULT_STARTING_INTERVAL, and reschedule itself after running
    threadPool.schedule(updateFrequency, executorName(), new SubmitReschedulingClusterInfoUpdatedJob());
    if (clusterService.state().getNodes().getDataNodes().size() > 1) {
      // Submit an info update job to be run immediately
      threadPool.executor(executorName()).execute(() -> maybeRefresh());
    }
  } catch (EsRejectedExecutionException ex) {
    if (logger.isDebugEnabled()) {
      logger.debug("Couldn't schedule cluster info update task - node might be shutting down", ex);
    }
  }
}

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

for (ObjectCursor<DiscoveryNode> cursor : clusterState.nodes().getDataNodes().values()) {
  nodesToShards.put(cursor.value.getId(), new LinkedHashMap<>()); // LinkedHashMap to preserve order

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

int nodeCount = state.getNodes().getDataNodes().size();

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

executeSearch((SearchTask)task, timeProvider, searchRequest, localIndices, Collections.emptyList(),
    (clusterName, nodeId) -> null, clusterState, Collections.emptyMap(), listener,
    clusterState.getNodes().getDataNodes().size(), SearchResponse.Clusters.EMPTY);
} else {
  remoteClusterService.collectSearchShards(searchRequest.indicesOptions(), searchRequest.preference(),
        remoteClusterIndices, remoteShardIterators, remoteAliasFilters);
      int numNodesInvolved = searchShardsResponses.values().stream().mapToInt(r -> r.getNodes().length).sum()
        + clusterState.getNodes().getDataNodes().size();
      SearchResponse.Clusters clusters = buildClusters(localIndices, remoteClusterIndices, searchShardsResponses);
      executeSearch((SearchTask) task, timeProvider, searchRequest, localIndices,

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

private Decision earlyTerminate(RoutingAllocation allocation, ImmutableOpenMap<String, DiskUsage> usages) {
  // Always allow allocation if the decider is disabled
  if (diskThresholdSettings.isEnabled() == false) {
    return allocation.decision(Decision.YES, NAME, "the disk threshold decider is disabled");
  }
  // Allow allocation regardless if only a single data node is available
  if (allocation.nodes().getDataNodes().size() <= 1) {
    if (logger.isTraceEnabled()) {
      logger.trace("only a single data node is present, allowing allocation");
    }
    return allocation.decision(Decision.YES, NAME, "there is only a single data node present");
  }
  // Fail open there is no info available
  final ClusterInfo clusterInfo = allocation.clusterInfo();
  if (clusterInfo == null) {
    if (logger.isTraceEnabled()) {
      logger.trace("cluster info unavailable for disk threshold decider, allowing allocation.");
    }
    return allocation.decision(Decision.YES, NAME, "the cluster info is unavailable");
  }
  // Fail open if there are no disk usages available
  if (usages.isEmpty()) {
    if (logger.isTraceEnabled()) {
      logger.trace("unable to determine disk usages for disk-aware allocation, allowing allocation");
    }
    return allocation.decision(Decision.YES, NAME, "disk usages are unavailable");
  }
  return null;
}

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

private void deassociateDeadNodes(RoutingAllocation allocation) {
  for (Iterator<RoutingNode> it = allocation.routingNodes().mutableIterator(); it.hasNext(); ) {
    RoutingNode node = it.next();
    if (allocation.nodes().getDataNodes().containsKey(node.nodeId())) {
      // its a live node, continue
      continue;
    }
    // now, go over all the shards routing on the node, and fail them
    for (ShardRouting shardRouting : node.copyShards()) {
      final IndexMetaData indexMetaData = allocation.metaData().getIndexSafe(shardRouting.index());
      boolean delayed = INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.get(indexMetaData.getSettings()).nanos() > 0;
      UnassignedInfo unassignedInfo = new UnassignedInfo(UnassignedInfo.Reason.NODE_LEFT, "node_left[" + node.nodeId() + "]",
        null, 0, allocation.getCurrentNanoTime(), System.currentTimeMillis(), delayed, AllocationStatus.NO_ATTEMPT);
      allocation.routingNodes().failShard(logger, shardRouting, unassignedInfo, indexMetaData, allocation.changes());
    }
    // its a dead node, remove it, note, its important to remove it *after* we apply failed shard
    // since it relies on the fact that the RoutingNode exists in the list of nodes
    it.remove();
  }
}

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

logger.debug("not recovering from gateway, nodes_size (data+master) [{}] < recover_after_nodes [{}]",
    nodes.getMasterAndDataNodes().size(), recoverAfterNodes);
} else if (recoverAfterDataNodes != -1 && nodes.getDataNodes().size() < recoverAfterDataNodes) {
  logger.debug("not recovering from gateway, nodes_size (data) [{}] < recover_after_data_nodes [{}]",
    nodes.getDataNodes().size(), recoverAfterDataNodes);
} else if (recoverAfterMasterNodes != -1 && nodes.getMasterNodes().size() < recoverAfterMasterNodes) {
  logger.debug("not recovering from gateway, nodes_size (master) [{}] < recover_after_master_nodes [{}]",
      enforceRecoverAfterTime = true;
      reason = "expecting [" + expectedNodes + "] nodes, but only have [" + nodes.getMasterAndDataNodes().size() + "]";
    } else if (expectedDataNodes != -1 && (nodes.getDataNodes().size() < expectedDataNodes)) { // does not meet the expected...
      enforceRecoverAfterTime = true;
      reason = "expecting [" + expectedDataNodes + "] data nodes, but only have [" + nodes.getDataNodes().size() + "]";
    } else if (expectedMasterNodes != -1 && (nodes.getMasterNodes().size() < expectedMasterNodes)) {

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

final boolean explain = allocation.debugDecision();
Map<String, NodeAllocationResult> nodeDecisions = explain ? new HashMap<>() : null;
for (ObjectCursor<DiscoveryNode> cursor : allocation.nodes().getDataNodes().values()) {
  RoutingNode node = allocation.routingNodes().node(cursor.value.getId());
  if (node == null) {

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

if (this.isMaster && dataNodeAdded && event.state().getNodes().getDataNodes().size() > 1) {
  if (logger.isDebugEnabled()) {
    logger.debug("data node was added, retrieving new cluster info");

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

numberOfDataNodes = clusterState.nodes().getDataNodes().size();
indices = new HashMap<>();
for (String index : concreteIndices) {

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

static int defaultMaxConcurrentSearches(int availableProcessors, ClusterState state) {
  int numDateNodes = state.getNodes().getDataNodes().size();
  // availableProcessors will never be larger than 32, so max defaultMaxConcurrentSearches will never be larger than 49,
  // but we don't know about about other search requests that are being executed so lets cap at 10 per node
  int defaultSearchThreadPoolSize = Math.min(ThreadPool.searchThreadPoolSize(availableProcessors), 10);
  return Math.max(1, numDateNodes * defaultSearchThreadPoolSize);
}

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

static int defaultMaxConcurrentSearches(int availableProcessors, ClusterState state) {
  int numDateNodes = state.getNodes().getDataNodes().size();
  // availableProcessors will never be larger than 32, so max defaultMaxConcurrentSearches will never be larger than 49,
  // but we don't know about about other search requests that are being executed so lets cap at 10 per node
  int defaultSearchThreadPoolSize = Math.min(ThreadPool.searchThreadPoolSize(availableProcessors), 10);
  return Math.max(1, numDateNodes * defaultSearchThreadPoolSize);
}

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

static int defaultMaxConcurrentSearches(int availableProcessors, ClusterState state) {
  int numDateNodes = state.getNodes().getDataNodes().size();
  // availableProcessors will never be larger than 32, so max defaultMaxConcurrentSearches will never be larger than 49,
  // but we don't know about about other search requests that are being executed so lets cap at 10 per node
  int defaultSearchThreadPoolSize = Math.min(ThreadPool.searchThreadPoolSize(availableProcessors), 10);
  return Math.max(1, numDateNodes * defaultSearchThreadPoolSize);
}

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

private boolean hasDeadNodes(RoutingAllocation allocation) {
  for (RoutingNode routingNode : allocation.routingNodes()) {
    if (allocation.nodes().getDataNodes().containsKey(routingNode.nodeId()) == false) {
      return true;
    }
  }
  return false;
}

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

private boolean hasDeadNodes(RoutingAllocation allocation) {
  for (RoutingNode routingNode : allocation.routingNodes()) {
    if (allocation.nodes().getDataNodes().containsKey(routingNode.nodeId()) == false) {
      return true;
    }
  }
  return false;
}

相关文章

微信公众号

最新文章

更多