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


Java ClusterState.copyWith方法代码示例

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


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

示例1: createCollection

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private ClusterState createCollection(ClusterState state, String collectionName, List<String> shards , ZkNodeProps message) {
        log.info("Create collection {} with shards {}", collectionName, shards);

        Map<String, Object> routerSpec = DocRouter.getRouterSpec(message);
        String routerName = routerSpec.get("name") == null ? DocRouter.DEFAULT_NAME : (String) routerSpec.get("name");
        DocRouter router = DocRouter.getDocRouter(routerName);

        List<DocRouter.Range> ranges = router.partitionRange(shards.size(), router.fullRange());

//        Map<String, DocCollection> newCollections = new LinkedHashMap<String,DocCollection>();


        Map<String, Slice> newSlices = new LinkedHashMap<>();
//        newCollections.putAll(state.getCollectionStates());
        for (int i = 0; i < shards.size(); i++) {
          String sliceName = shards.get(i);
        /*}
        for (int i = 0; i < numShards; i++) {
          final String sliceName = "shard" + (i+1);*/

          Map<String, Object> sliceProps = new LinkedHashMap<>(1);
          sliceProps.put(Slice.RANGE, ranges == null? null: ranges.get(i));

          newSlices.put(sliceName, new Slice(sliceName, null, sliceProps));
        }

        // TODO: fill in with collection properties read from the /collections/<collectionName> node
        Map<String,Object> collectionProps = new HashMap<>();

        for (Entry<String, Object> e : OverseerCollectionProcessor.COLL_PROPS.entrySet()) {
          Object val = message.get(e.getKey());
          if(val == null){
            val = OverseerCollectionProcessor.COLL_PROPS.get(e.getKey());
          }
          if(val != null) collectionProps.put(e.getKey(),val);
        }
        collectionProps.put(DocCollection.DOC_ROUTER, routerSpec);

        if(message.getStr("fromApi") == null) collectionProps.put("autoCreated","true");
        DocCollection newCollection = new DocCollection(collectionName, newSlices, collectionProps, router);

//        newCollections.put(collectionName, newCollection);
          return state.copyWith(singletonMap(newCollection.getName(), newCollection));
//        ClusterState newClusterState = new ClusterState(state.getLiveNodes(), newCollections);
//        return newClusterState;
      }
 
开发者ID:europeana,项目名称:search,代码行数:47,代码来源:Overseer.java

示例2: newState

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private ClusterState newState(ClusterState state, Map<String, DocCollection> colls) {
  return state.copyWith(colls);
}
 
开发者ID:europeana,项目名称:search,代码行数:4,代码来源:Overseer.java

示例3: removeCollection

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private ClusterState removeCollection(final ClusterState clusterState, ZkNodeProps message) {
  final String collection = message.getStr("name");
  if (!checkKeyExistence(message, "name")) return clusterState;

  return clusterState.copyWith(singletonMap(collection, (DocCollection)null));
}
 
开发者ID:europeana,项目名称:search,代码行数:7,代码来源:Overseer.java

示例4: createCollection

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private ClusterState createCollection(ClusterState state, String collectionName, List<String> shards , ZkNodeProps message) {
        log.info("Create collection {} with shards {}", collectionName, shards);

        Map<String, Object> routerSpec = DocRouter.getRouterSpec(message);
        String routerName = routerSpec.get("name") == null ? DocRouter.DEFAULT_NAME : (String) routerSpec.get("name");
        DocRouter router = DocRouter.getDocRouter(routerName);

        List<DocRouter.Range> ranges = router.partitionRange(shards.size(), router.fullRange());

//        Map<String, DocCollection> newCollections = new LinkedHashMap<String,DocCollection>();


        Map<String, Slice> newSlices = new LinkedHashMap<String,Slice>();
//        newCollections.putAll(state.getCollectionStates());
        for (int i = 0; i < shards.size(); i++) {
          String sliceName = shards.get(i);
        /*}
        for (int i = 0; i < numShards; i++) {
          final String sliceName = "shard" + (i+1);*/

          Map<String, Object> sliceProps = new LinkedHashMap<String, Object>(1);
          sliceProps.put(Slice.RANGE, ranges == null? null: ranges.get(i));

          newSlices.put(sliceName, new Slice(sliceName, null, sliceProps));
        }

        // TODO: fill in with collection properties read from the /collections/<collectionName> node
        Map<String,Object> collectionProps = new HashMap<String,Object>();

        for (Entry<String, Object> e : OverseerCollectionProcessor.COLL_PROPS.entrySet()) {
          Object val = message.get(e.getKey());
          if(val == null){
            val = OverseerCollectionProcessor.COLL_PROPS.get(e.getKey());
          }
          if(val != null) collectionProps.put(e.getKey(),val);
        }
        collectionProps.put(DocCollection.DOC_ROUTER, routerSpec);

        if(message.getStr("fromApi") == null) collectionProps.put("autoCreated","true");
        DocCollection newCollection = new DocCollection(collectionName, newSlices, collectionProps, router);

//        newCollections.put(collectionName, newCollection);
          return state.copyWith(singletonMap(newCollection.getName(), newCollection));
//        ClusterState newClusterState = new ClusterState(state.getLiveNodes(), newCollections);
//        return newClusterState;
      }
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:47,代码来源:Overseer.java


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