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


Java ClusterState.hasCollection方法代码示例

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


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

示例1: checkForMissingCollection

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
protected void checkForMissingCollection(String collectionName)
    throws Exception {
  // check for a  collection - we poll the state
  long timeoutAt = System.currentTimeMillis() + 45000;
  boolean found = true;
  while (System.currentTimeMillis() < timeoutAt) {
    getCommonCloudSolrServer().getZkStateReader().updateClusterState(true);
    ClusterState clusterState = getCommonCloudSolrServer().getZkStateReader().getClusterState();
    if (!clusterState.hasCollection(collectionName)) {
      found = false;
      break;
    }
    Thread.sleep(100);
  }
  if (found) {
    fail("Found collection that should be gone " + collectionName);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:AbstractFullDistribZkTestBase.java

示例2: buildCollection

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private ClusterState buildCollection(ClusterState clusterState, ZkNodeProps message) {
  String collection = message.getStr("name");
  log.info("building a new collection: " + collection);
  if(clusterState.hasCollection(collection) ){
    log.warn("Collection {} already exists. exit" ,collection);
    return clusterState;
  }

  ArrayList<String> shardNames = new ArrayList<>();

  if(ImplicitDocRouter.NAME.equals( message.getStr("router.name",DocRouter.DEFAULT_NAME))){
    getShardNames(shardNames,message.getStr("shards",DocRouter.DEFAULT_NAME));
  } else {
    int numShards = message.getInt(ZkStateReader.NUM_SHARDS_PROP, -1);
    if(numShards<1) throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"numShards is a required parameter for 'compositeId' router");
    getShardNames(numShards, shardNames);
  }

  return createCollection(clusterState,collection,shardNames,message);
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:Overseer.java

示例3: buildCollection

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private ClusterState buildCollection(ClusterState clusterState, ZkNodeProps message) {
  String collection = message.getStr("name");
  log.info("building a new collection: " + collection);
  if(clusterState.hasCollection(collection) ){
    log.warn("Collection {} already exists. exit" ,collection);
    return clusterState;
  }

  ArrayList<String> shardNames = new ArrayList<String>();

  if(ImplicitDocRouter.NAME.equals( message.getStr("router.name",DocRouter.DEFAULT_NAME))){
    getShardNames(shardNames,message.getStr("shards",DocRouter.DEFAULT_NAME));
  } else {
    int numShards = message.getInt(ZkStateReader.NUM_SHARDS_PROP, -1);
    if(numShards<1) throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"numShards is a required parameter for 'compositeId' router");
    getShardNames(numShards, shardNames);
  }

  return createCollection(clusterState,collection,shardNames,message);
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:21,代码来源:Overseer.java

示例4: checkCollectionExpectations

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private String checkCollectionExpectations(String collectionName, List<Integer> numShardsNumReplicaList, List<String> nodesAllowedToRunShards) {
    ClusterState clusterState = getCommonCloudSolrServer().getZkStateReader().getClusterState();
    
    int expectedSlices = numShardsNumReplicaList.get(0);
    // The Math.min thing is here, because we expect replication-factor to be reduced to if there are not enough live nodes to spread all shards of a collection over different nodes
    int expectedShardsPerSlice = numShardsNumReplicaList.get(1);
    int expectedTotalShards = expectedSlices * expectedShardsPerSlice;
    
//      Map<String,DocCollection> collections = clusterState
//          .getCollectionStates();
      if (clusterState.hasCollection(collectionName)) {
        Map<String,Slice> slices = clusterState.getCollection(collectionName).getSlicesMap();
        // did we find expectedSlices slices/shards?
      if (slices.size() != expectedSlices) {
        return "Found new collection " + collectionName + ", but mismatch on number of slices. Expected: " + expectedSlices + ", actual: " + slices.size();
      }
      int totalShards = 0;
      for (String sliceName : slices.keySet()) {
        for (Replica replica : slices.get(sliceName).getReplicas()) {
          if (nodesAllowedToRunShards != null && !nodesAllowedToRunShards.contains(replica.getStr(ZkStateReader.NODE_NAME_PROP))) {
            return "Shard " + replica.getName() + " created on node " + replica.getNodeName() + " not allowed to run shards for the created collection " + collectionName;
          }
        }
        totalShards += slices.get(sliceName).getReplicas().size();
      }
      if (totalShards != expectedTotalShards) {
        return "Found new collection " + collectionName + " with correct number of slices, but mismatch on number of shards. Expected: " + expectedTotalShards + ", actual: " + totalShards; 
        }
      return null;
    } else {
      return "Could not find new collection " + collectionName;
    }
  }
 
开发者ID:europeana,项目名称:search,代码行数:34,代码来源:AbstractFullDistribZkTestBase.java

示例5: collectStartTimes

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private void collectStartTimes(String collectionName,
      Map<String,Long> urlToTime) throws SolrServerException, IOException {
    ClusterState clusterState = getCommonCloudSolrServer().getZkStateReader()
        .getClusterState();
//    Map<String,DocCollection> collections = clusterState.getCollectionStates();
    if (clusterState.hasCollection(collectionName)) {
      Map<String,Slice> slices = clusterState.getSlicesMap(collectionName);

      Iterator<Entry<String,Slice>> it = slices.entrySet().iterator();
      while (it.hasNext()) {
        Entry<String,Slice> sliceEntry = it.next();
        Map<String,Replica> sliceShards = sliceEntry.getValue().getReplicasMap();
        Iterator<Entry<String,Replica>> shardIt = sliceShards.entrySet()
            .iterator();
        while (shardIt.hasNext()) {
          Entry<String,Replica> shardEntry = shardIt.next();
          ZkCoreNodeProps coreProps = new ZkCoreNodeProps(shardEntry.getValue());
          HttpSolrServer server = new HttpSolrServer(coreProps.getBaseUrl());
          CoreAdminResponse mcr;
          try {
            mcr = CoreAdminRequest.getStatus(coreProps.getCoreName(), server);
          } finally {
            server.shutdown();
          }
          long before = mcr.getStartTime(coreProps.getCoreName()).getTime();
          urlToTime.put(coreProps.getCoreUrl(), before);
        }
      }
    } else {
      throw new IllegalArgumentException("Could not find collection in :"
          + clusterState.getCollections());
    }
  }
 
开发者ID:europeana,项目名称:search,代码行数:34,代码来源:CollectionsAPIDistributedZkTest.java


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