当前位置: 首页>>代码示例>>Java>>正文


Java ClusterState.liveNodesContain方法代码示例

本文整理汇总了Java中org.apache.solr.common.cloud.ClusterState.liveNodesContain方法的典型用法代码示例。如果您正苦于以下问题:Java ClusterState.liveNodesContain方法的具体用法?Java ClusterState.liveNodesContain怎么用?Java ClusterState.liveNodesContain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.common.cloud.ClusterState的用法示例。


在下文中一共展示了ClusterState.liveNodesContain方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUrlFromZk

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
public static String getUrlFromZk(ClusterState clusterState, String collection) {
  Map<String,Slice> slices = clusterState.getCollection(collection).getSlicesMap();

  if (slices == null) {
    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Could not find collection:" + collection);
  }

  for (Map.Entry<String,Slice> entry : slices.entrySet()) {
    Slice slice = entry.getValue();
    Map<String,Replica> shards = slice.getReplicasMap();
    Set<Map.Entry<String,Replica>> shardEntries = shards.entrySet();
    for (Map.Entry<String,Replica> shardEntry : shardEntries) {
      final ZkNodeProps node = shardEntry.getValue();
      if (clusterState.liveNodesContain(node.getStr(ZkStateReader.NODE_NAME_PROP))) {
        return ZkCoreNodeProps.getCoreUrl(node.getStr(ZkStateReader.BASE_URL_PROP), collection); //new ZkCoreNodeProps(node).getCoreUrl();
      }
    }
  }

  throw new RuntimeException("Could not find a live node for collection:" + collection);
}
 
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:AbstractFullDistribZkTestBase.java

示例2: getCollectionUrls

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private List<Node> getCollectionUrls(SolrQueryRequest req, String collection) {
  ClusterState clusterState = req.getCore().getCoreDescriptor()
      .getCoreContainer().getZkController().getClusterState();
  List<Node> urls = new ArrayList<>();
  Map<String,Slice> slices = clusterState.getSlicesMap(collection);
  if (slices == null) {
    throw new ZooKeeperException(ErrorCode.BAD_REQUEST,
        "Could not find collection in zk: " + clusterState);
  }
  for (Map.Entry<String,Slice> sliceEntry : slices.entrySet()) {
    Slice replicas = slices.get(sliceEntry.getKey());

    Map<String,Replica> shardMap = replicas.getReplicasMap();
    
    for (Entry<String,Replica> entry : shardMap.entrySet()) {
      ZkCoreNodeProps nodeProps = new ZkCoreNodeProps(entry.getValue());
      if (clusterState.liveNodesContain(nodeProps.getNodeName())) {
        urls.add(new StdNode(nodeProps, collection, replicas.getName()));
      }
    }
  }
  if (urls.size() == 0) {
    return null;
  }
  return urls;
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:DistributedUpdateProcessor.java

示例3: replicaAlreadyExistsOnNode

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private static boolean replicaAlreadyExistsOnNode(ClusterState clusterState, Collection<Replica> replicas, DownReplica badReplica, String baseUrl) {
  if (replicas != null) {
    log.debug("check if replica already exists on node using replicas {}", getNames(replicas));
    for (Replica replica : replicas) {
      if (!replica.getName().equals(badReplica.replica.getName()) && replica.getStr(ZkStateReader.BASE_URL_PROP).equals(baseUrl)
          && clusterState.liveNodesContain(replica.getNodeName())
          && (replica.getStr(ZkStateReader.STATE_PROP).equals(
              ZkStateReader.ACTIVE)
              || replica.getStr(ZkStateReader.STATE_PROP).equals(
                  ZkStateReader.DOWN) || replica.getStr(
              ZkStateReader.STATE_PROP).equals(ZkStateReader.RECOVERING))) {
        log.debug("replica already exists on node, bad replica={}, existing replica={}, node name={}", badReplica.replica.getName(), replica.getName(), replica.getNodeName());
        return true;
      }
    }
  }
  log.debug("replica does not yet exist on node: {}", baseUrl);
  return false;
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:OverseerAutoReplicaFailoverThread.java

示例4: waitTillRecovered

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private void waitTillRecovered() throws Exception {
  for (int i = 0; i < 30; i++) {
    Thread.sleep(3000);
    ZkStateReader zkStateReader = cloudClient.getZkStateReader();
    zkStateReader.updateClusterState(true);
    ClusterState clusterState = zkStateReader.getClusterState();
    DocCollection collection1 = clusterState.getCollection("collection1");
    Slice slice = collection1.getSlice("shard1");
    Collection<Replica> replicas = slice.getReplicas();
    boolean allActive = true;
    for (Replica replica : replicas) {
      if (!clusterState.liveNodesContain(replica.getNodeName())
          || !replica.get(ZkStateReader.STATE_PROP).equals(
          ZkStateReader.ACTIVE)) {
        allActive = false;
        break;
      }
    }
    if (allActive) {
      return;
    }
  }
  printLayout();
  fail("timeout waiting to see recovered node");
}
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:ChaosMonkeyShardSplitTest.java

示例5: waitTillAllNodesActive

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private void waitTillAllNodesActive() throws Exception {
  for (int i = 0; i < 60; i++) { 
    Thread.sleep(3000);
    ZkStateReader zkStateReader = cloudClient.getZkStateReader();
    zkStateReader.updateClusterState(true);
    ClusterState clusterState = zkStateReader.getClusterState();
    DocCollection collection1 = clusterState.getCollection("collection1");
    Slice slice = collection1.getSlice("shard1");
    Collection<Replica> replicas = slice.getReplicas();
    boolean allActive = true;
    for (Replica replica : replicas) {
      if (!clusterState.liveNodesContain(replica.getNodeName())
          || !replica.get(ZkStateReader.STATE_PROP).equals(
              ZkStateReader.ACTIVE)) {
        allActive = false;
        break;
      }
    }
    if (allActive) {
      return;
    }
  }
  printLayout();
  fail("timeout waiting to see all nodes active");
}
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:SyncSliceTest.java

示例6: getUrlFromZk

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private String getUrlFromZk(String collection) {
  ClusterState clusterState = getCommonCloudSolrServer().getZkStateReader().getClusterState();
  Map<String,Slice> slices = clusterState.getSlicesMap(collection);
  
  if (slices == null) {
    throw new SolrException(ErrorCode.BAD_REQUEST, "Could not find collection:" + collection);
  }
  
  for (Map.Entry<String,Slice> entry : slices.entrySet()) {
    Slice slice = entry.getValue();
    Map<String,Replica> shards = slice.getReplicasMap();
    Set<Map.Entry<String,Replica>> shardEntries = shards.entrySet();
    for (Map.Entry<String,Replica> shardEntry : shardEntries) {
      final ZkNodeProps node = shardEntry.getValue();
      if (clusterState.liveNodesContain(node.getStr(ZkStateReader.NODE_NAME_PROP))) {
        return ZkCoreNodeProps.getCoreUrl(node.getStr(ZkStateReader.BASE_URL_PROP), collection); //new ZkCoreNodeProps(node).getCoreUrl();
      }
    }
  }
  
  throw new RuntimeException("Could not find a live node for collection:" + collection);
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:CollectionsAPIDistributedZkTest.java

示例7: getCollectionUrls

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private List<Node> getCollectionUrls(SolrQueryRequest req, String collection, String coreNodeName) {
  ClusterState clusterState = req.getCore().getCoreDescriptor()
      .getCoreContainer().getZkController().getClusterState();
  List<Node> urls = new ArrayList<Node>();
  Map<String,Slice> slices = clusterState.getSlicesMap(collection);
  if (slices == null) {
    throw new ZooKeeperException(ErrorCode.BAD_REQUEST,
        "Could not find collection in zk: " + clusterState);
  }
  for (Map.Entry<String,Slice> sliceEntry : slices.entrySet()) {
    Slice replicas = slices.get(sliceEntry.getKey());

    Map<String,Replica> shardMap = replicas.getReplicasMap();
    
    for (Entry<String,Replica> entry : shardMap.entrySet()) {
      ZkCoreNodeProps nodeProps = new ZkCoreNodeProps(entry.getValue());
      if (clusterState.liveNodesContain(nodeProps.getNodeName()) && !entry.getKey().equals(coreNodeName)) {
        urls.add(new StdNode(nodeProps));
      }
    }
  }
  if (urls.size() == 0) {
    return null;
  }
  return urls;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:27,代码来源:DistributedUpdateProcessor.java

示例8: areAnyOtherReplicasActive

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private boolean areAnyOtherReplicasActive(ZkController zkController,
    ZkNodeProps leaderProps, String collection, String shardId) {
  ClusterState clusterState = zkController.getZkStateReader()
      .getClusterState();
  Map<String,Slice> slices = clusterState.getSlicesMap(collection);
  Slice slice = slices.get(shardId);
  Map<String,Replica> replicasMap = slice.getReplicasMap();
  for (Map.Entry<String,Replica> shard : replicasMap.entrySet()) {
    String state = shard.getValue().getStr(ZkStateReader.STATE_PROP);
    // System.out.println("state:"
    // + state
    // + shard.getValue().get(ZkStateReader.NODE_NAME_PROP)
    // + " live: "
    // + clusterState.liveNodesContain(shard.getValue().get(
    // ZkStateReader.NODE_NAME_PROP)));
    if (state.equals(ZkStateReader.ACTIVE)
        && clusterState.liveNodesContain(shard.getValue().getStr(
            ZkStateReader.NODE_NAME_PROP))
        && !new ZkCoreNodeProps(shard.getValue()).getCoreUrl().equals(
            new ZkCoreNodeProps(leaderProps).getCoreUrl())) {
      return true;
    }
  }
  
  return false;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:27,代码来源:ElectionContext.java

示例9: waitTillRecovered

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private void waitTillRecovered() throws Exception {
  for (int i = 0; i < 30; i++) { 
    Thread.sleep(3000);
    ZkStateReader zkStateReader = cloudClient.getZkStateReader();
    zkStateReader.updateClusterState(true);
    ClusterState clusterState = zkStateReader.getClusterState();
    DocCollection collection1 = clusterState.getCollection("collection1");
    Slice slice = collection1.getSlice("shard1");
    Collection<Replica> replicas = slice.getReplicas();
    boolean allActive = true;
    for (Replica replica : replicas) {
      if (!clusterState.liveNodesContain(replica.getNodeName())
          || !replica.get(ZkStateReader.STATE_PROP).equals(
              ZkStateReader.ACTIVE)) {
        allActive = false;
        break;
      }
    }
    if (allActive) {
      return;
    }
  }
  printLayout();
  fail("timeout waiting to see recovered node");
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:26,代码来源:SyncSliceTest.java

示例10: getUrlFromZk

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private String getUrlFromZk(String collection) {
  ClusterState clusterState = getCommonCloudSolrServer().getZkStateReader().getClusterState();
  Map<String,Slice> slices = clusterState.getCollectionStates().get(collection).getSlicesMap();
  
  if (slices == null) {
    throw new SolrException(ErrorCode.BAD_REQUEST, "Could not find collection:" + collection);
  }
  
  for (Map.Entry<String,Slice> entry : slices.entrySet()) {
    Slice slice = entry.getValue();
    Map<String,Replica> shards = slice.getReplicasMap();
    Set<Map.Entry<String,Replica>> shardEntries = shards.entrySet();
    for (Map.Entry<String,Replica> shardEntry : shardEntries) {
      final ZkNodeProps node = shardEntry.getValue();
      if (clusterState.liveNodesContain(node.getStr(ZkStateReader.NODE_NAME_PROP))) {
        return ZkCoreNodeProps.getCoreUrl(node.getStr(ZkStateReader.BASE_URL_PROP), collection); //new ZkCoreNodeProps(node).getCoreUrl();
      }
    }
  }
  
  throw new RuntimeException("Could not find a live node for collection:" + collection);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:23,代码来源:CollectionsAPIDistributedZkTest.java

示例11: getCollectionUrls

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private List<Node> getCollectionUrls(SolrQueryRequest req, String collection) {
  ClusterState clusterState = req.getCore().getCoreDescriptor()
      .getCoreContainer().getZkController().getClusterState();
  List<Node> urls = new ArrayList<Node>();
  Map<String,Slice> slices = clusterState.getSlicesMap(collection);
  if (slices == null) {
    throw new ZooKeeperException(ErrorCode.BAD_REQUEST,
        "Could not find collection in zk: " + clusterState);
  }
  for (Map.Entry<String,Slice> sliceEntry : slices.entrySet()) {
    Slice replicas = slices.get(sliceEntry.getKey());

    Map<String,Replica> shardMap = replicas.getReplicasMap();
    
    for (Entry<String,Replica> entry : shardMap.entrySet()) {
      ZkCoreNodeProps nodeProps = new ZkCoreNodeProps(entry.getValue());
      if (clusterState.liveNodesContain(nodeProps.getNodeName())) {
        urls.add(new StdNode(nodeProps));
      }
    }
  }
  if (urls.size() == 0) {
    return null;
  }
  return urls;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:27,代码来源:DistributedUpdateProcessor.java

示例12: waitForRecoveriesToFinish

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
/**
 * Wait for all the collection shards to be ready.
 */
private static void waitForRecoveriesToFinish(CloudSolrClient server, String collection) throws KeeperException, InterruptedException {
    ZkStateReader zkStateReader = server.getZkStateReader();
    try {
        boolean cont = true;

        while (cont) {
            boolean sawLiveRecovering = false;
            zkStateReader.updateClusterState(true);
            ClusterState clusterState = zkStateReader.getClusterState();
            Map<String, Slice> slices = clusterState.getSlicesMap(collection);
            Preconditions.checkNotNull("Could not find collection:" + collection, slices);

           // change paths for Replica.State per Solr refactoring
           // remove SYNC state per: http://tinyurl.com/pag6rwt
           for (Map.Entry<String, Slice> entry : slices.entrySet()) {
                Map<String, Replica> shards = entry.getValue().getReplicasMap();
                for (Map.Entry<String, Replica> shard : shards.entrySet()) {
                    String state = shard.getValue().getStr(ZkStateReader.STATE_PROP);
                    if ((state.equals(Replica.State.RECOVERING) || state.equals(Replica.State.DOWN))
                            && clusterState.liveNodesContain(shard.getValue().getStr(
                            ZkStateReader.NODE_NAME_PROP))) {
                        sawLiveRecovering = true;
                    }
                }
            }


            if (!sawLiveRecovering) {
                cont = false;
            } else {
                Thread.sleep(1000);
            }
        }
    } finally {
        logger.info("Exiting solr wait");
    }
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:41,代码来源:SolrIndex.java

示例13: waitForRecoveriesToFinish

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
/**
 * Wait for all the collection shards to be ready.
 */
private static void waitForRecoveriesToFinish(CloudSolrClient server, String collection) throws KeeperException, InterruptedException {
    ZkStateReader zkStateReader = server.getZkStateReader();
    try {
        boolean cont = true;

        while (cont) {
            boolean sawLiveRecovering = false;
            zkStateReader.updateClusterState();
            ClusterState clusterState = zkStateReader.getClusterState();
            Map<String, Slice> slices = clusterState.getSlicesMap(collection);
            Preconditions.checkNotNull("Could not find collection:" + collection, slices);

            for (Map.Entry<String, Slice> entry : slices.entrySet()) {
                Map<String, Replica> shards = entry.getValue().getReplicasMap();
                for (Map.Entry<String, Replica> shard : shards.entrySet()) {
                    String state = shard.getValue().getStr(ZkStateReader.STATE_PROP);
                    if ((state.equals(Replica.State.RECOVERING.toString())
                            || state.equals(Replica.State.DOWN.toString()))
                            && clusterState.liveNodesContain(shard.getValue().getStr(
                            ZkStateReader.NODE_NAME_PROP))) {
                        sawLiveRecovering = true;
                    }
                }
            }
            if (!sawLiveRecovering) {
                cont = false;
            } else {
                Thread.sleep(1000);
            }
        }
    } finally {
        logger.info("Exiting solr wait");
    }
}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:38,代码来源:Solr5Index.java

示例14: findDownReplicasInSlice

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private static int findDownReplicasInSlice(ClusterState clusterState, DocCollection collection, Slice slice, final Collection<DownReplica> badReplicas) {
  int goodReplicas = 0;
  Collection<Replica> replicas = slice.getReplicas();
  if (replicas != null) {
    for (Replica replica : replicas) {
      // on a live node?
      boolean live = clusterState.liveNodesContain(replica.getNodeName());
      String state = replica.getStr(ZkStateReader.STATE_PROP);
      
      boolean okayState = (state.equals(ZkStateReader.DOWN)
          || state.equals(ZkStateReader.RECOVERING) || state
          .equals(ZkStateReader.ACTIVE));
      
      log.debug("Process replica name={} live={} state={}", replica.getName(), live, state);
      
      if (live && okayState) {
        goodReplicas++;
      } else {
        DownReplica badReplica = new DownReplica();
        badReplica.replica = replica;
        badReplica.slice = slice;
        badReplica.collection = collection;
        badReplicas.add(badReplica);
      }
    }
  }
  log.debug("bad replicas for slice {}", badReplicas);
  return goodReplicas;
}
 
开发者ID:europeana,项目名称:search,代码行数:30,代码来源:OverseerAutoReplicaFailoverThread.java

示例15: sliceCmd

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private void sliceCmd(ClusterState clusterState, ModifiableSolrParams params, String stateMatcher,
                      Slice slice, ShardHandler shardHandler) {
  Map<String,Replica> shards = slice.getReplicasMap();
  Set<Map.Entry<String,Replica>> shardEntries = shards.entrySet();
  for (Map.Entry<String,Replica> shardEntry : shardEntries) {
    final ZkNodeProps node = shardEntry.getValue();
    if (clusterState.liveNodesContain(node.getStr(ZkStateReader.NODE_NAME_PROP)) && (stateMatcher != null ? node.getStr(ZkStateReader.STATE_PROP).equals(stateMatcher) : true)) {
      // For thread safety, only simple clone the ModifiableSolrParams
      ModifiableSolrParams cloneParams = new ModifiableSolrParams();
      cloneParams.add(params);
      cloneParams.set(CoreAdminParams.CORE,
          node.getStr(ZkStateReader.CORE_NAME_PROP));

      String replica = node.getStr(ZkStateReader.BASE_URL_PROP);
      ShardRequest sreq = new ShardRequest();
      sreq.nodeName = node.getStr(ZkStateReader.NODE_NAME_PROP);
      // yes, they must use same admin handler path everywhere...
      cloneParams.set("qt", adminPath);
      sreq.purpose = 1;
      sreq.shards = new String[] {replica};
      sreq.actualShards = sreq.shards;
      sreq.params = cloneParams;
      log.info("Collection Admin sending CoreAdmin cmd to " + replica
          + " params:" + sreq.params);
      shardHandler.submit(sreq, replica, sreq.params);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:29,代码来源:OverseerCollectionProcessor.java


注:本文中的org.apache.solr.common.cloud.ClusterState.liveNodesContain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。