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


Java DocCollection.getRouter方法代码示例

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


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

示例1: removeShard

import org.apache.solr.common.cloud.DocCollection; //导入方法依赖的package包/类
private ClusterState removeShard(final ClusterState clusterState, ZkNodeProps message) {
  final String sliceId = message.getStr(ZkStateReader.SHARD_ID_PROP);
  final String collection = message.getStr(ZkStateReader.COLLECTION_PROP);
  if (!checkCollectionKeyExistence(message)) return clusterState;

  log.info("Removing collection: " + collection + " shard: " + sliceId + " from clusterstate");

  DocCollection coll = clusterState.getCollection(collection);

  Map<String, Slice> newSlices = new LinkedHashMap<>(coll.getSlicesMap());
  newSlices.remove(sliceId);

  DocCollection newCollection = new DocCollection(coll.getName(), newSlices, coll.getProperties(), coll.getRouter());
  return newState(clusterState, singletonMap(collection,newCollection));
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:Overseer.java

示例2: doQuery

import org.apache.solr.common.cloud.DocCollection; //导入方法依赖的package包/类
public void doQuery(DocCollection coll, String id, String expectedShards) {
  DocRouter router = coll.getRouter();
  Collection<Slice> slices = router.getSearchSlices(id, null, coll);

  List<String> expectedShardStr = StrUtils.splitSmart(expectedShards, ",", true);

  HashSet<String> expectedSet = new HashSet<>(expectedShardStr);
  HashSet<String> obtainedSet = new HashSet<>();
  for (Slice slice : slices) {
    obtainedSet.add(slice.getName());
  }

  assertEquals(slices.size(), obtainedSet.size());  // make sure no repeated slices
  assertEquals(expectedSet, obtainedSet);
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:TestHashPartitioner.java

示例3: doQuery

import org.apache.solr.common.cloud.DocCollection; //导入方法依赖的package包/类
public void doQuery(DocCollection coll, String id, String expectedShards) {
  DocRouter router = coll.getRouter();
  Collection<Slice> slices = router.getSearchSlices(id, null, coll);

  List<String> expectedShardStr = StrUtils.splitSmart(expectedShards, ",", true);

  HashSet<String> expectedSet = new HashSet<String>(expectedShardStr);
  HashSet<String> obtainedSet = new HashSet<String>();
  for (Slice slice : slices) {
    obtainedSet.add(slice.getName());
  }

  assertEquals(slices.size(), obtainedSet.size());  // make sure no repeated slices
  assertEquals(expectedSet, obtainedSet);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:16,代码来源:TestHashPartitioner.java

示例4: removeShard

import org.apache.solr.common.cloud.DocCollection; //导入方法依赖的package包/类
private ClusterState removeShard(final ClusterState clusterState, ZkNodeProps message) {
  final String sliceId = message.getStr(ZkStateReader.SHARD_ID_PROP);
  final String collection = message.getStr(ZkStateReader.COLLECTION_PROP);
  if (!checkCollectionKeyExistence(message)) return clusterState;

  log.info("Removing collection: " + collection + " shard: " + sliceId + " from clusterstate");

  DocCollection coll = clusterState.getCollection(collection);

  Map<String, Slice> newSlices = new LinkedHashMap<String, Slice>(coll.getSlicesMap());
  newSlices.remove(sliceId);

  DocCollection newCollection = new DocCollection(coll.getName(), newSlices, coll.getProperties(), coll.getRouter());
  return newState(clusterState, singletonMap(collection,newCollection));
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:16,代码来源:Overseer.java

示例5: migrate

import org.apache.solr.common.cloud.DocCollection; //导入方法依赖的package包/类
private void migrate(ClusterState clusterState, ZkNodeProps message, NamedList results) throws KeeperException, InterruptedException {
  String sourceCollectionName = message.getStr("collection");
  String splitKey = message.getStr("split.key");
  String targetCollectionName = message.getStr("target.collection");
  int timeout = message.getInt("forward.timeout", 10 * 60) * 1000;

  DocCollection sourceCollection = clusterState.getCollection(sourceCollectionName);
  if (sourceCollection == null) {
    throw new SolrException(ErrorCode.BAD_REQUEST, "Unknown source collection: " + sourceCollectionName);
  }
  DocCollection targetCollection = clusterState.getCollection(targetCollectionName);
  if (targetCollection == null) {
    throw new SolrException(ErrorCode.BAD_REQUEST, "Unknown target collection: " + sourceCollectionName);
  }
  if (!(sourceCollection.getRouter() instanceof CompositeIdRouter))  {
    throw new SolrException(ErrorCode.BAD_REQUEST, "Source collection must use a compositeId router");
  }
  if (!(targetCollection.getRouter() instanceof CompositeIdRouter))  {
    throw new SolrException(ErrorCode.BAD_REQUEST, "Target collection must use a compositeId router");
  }
  CompositeIdRouter sourceRouter = (CompositeIdRouter) sourceCollection.getRouter();
  CompositeIdRouter targetRouter = (CompositeIdRouter) targetCollection.getRouter();
  Collection<Slice> sourceSlices = sourceRouter.getSearchSlicesSingle(splitKey, null, sourceCollection);
  if (sourceSlices.isEmpty()) {
    throw new SolrException(ErrorCode.BAD_REQUEST,
        "No active slices available in source collection: " + sourceCollection + "for given split.key: " + splitKey);
  }
  Collection<Slice> targetSlices = targetRouter.getSearchSlicesSingle(splitKey, null, targetCollection);
  if (targetSlices.isEmpty()) {
    throw new SolrException(ErrorCode.BAD_REQUEST,
        "No active slices available in target collection: " + targetCollection + "for given split.key: " + splitKey);
  }

  for (Slice sourceSlice : sourceSlices) {
    for (Slice targetSlice : targetSlices) {
      log.info("Migrating source shard: {} to target shard: {} for split.key = " + splitKey, sourceSlice, targetSlice);
      migrateKey(clusterState, sourceCollection, sourceSlice, targetCollection, targetSlice, splitKey, timeout, results);
    }
  }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:41,代码来源:OverseerCollectionProcessor.java

示例6: migrate

import org.apache.solr.common.cloud.DocCollection; //导入方法依赖的package包/类
private void migrate(ClusterState clusterState, ZkNodeProps message, NamedList results) throws KeeperException, InterruptedException {
  String sourceCollectionName = message.getStr("collection");
  String splitKey = message.getStr("split.key");
  String targetCollectionName = message.getStr("target.collection");
  int timeout = message.getInt("forward.timeout", 10 * 60) * 1000;

  DocCollection sourceCollection = clusterState.getCollection(sourceCollectionName);
  if (sourceCollection == null) {
    throw new SolrException(ErrorCode.BAD_REQUEST, "Unknown source collection: " + sourceCollectionName);
  }
  DocCollection targetCollection = clusterState.getCollection(targetCollectionName);
  if (targetCollection == null) {
    throw new SolrException(ErrorCode.BAD_REQUEST, "Unknown target collection: " + sourceCollectionName);
  }
  if (!(sourceCollection.getRouter() instanceof CompositeIdRouter))  {
    throw new SolrException(ErrorCode.BAD_REQUEST, "Source collection must use a compositeId router");
  }
  if (!(targetCollection.getRouter() instanceof CompositeIdRouter))  {
    throw new SolrException(ErrorCode.BAD_REQUEST, "Target collection must use a compositeId router");
  }
  CompositeIdRouter sourceRouter = (CompositeIdRouter) sourceCollection.getRouter();
  CompositeIdRouter targetRouter = (CompositeIdRouter) targetCollection.getRouter();
  Collection<Slice> sourceSlices = sourceRouter.getSearchSlicesSingle(splitKey, null, sourceCollection);
  if (sourceSlices.isEmpty()) {
    throw new SolrException(ErrorCode.BAD_REQUEST,
        "No active slices available in source collection: " + sourceCollection + "for given split.key: " + splitKey);
  }
  Collection<Slice> targetSlices = targetRouter.getSearchSlicesSingle(splitKey, null, targetCollection);
  if (targetSlices.isEmpty()) {
    throw new SolrException(ErrorCode.BAD_REQUEST,
        "No active slices available in target collection: " + targetCollection + "for given split.key: " + splitKey);
  }

  String asyncId = null;
  if(message.containsKey(ASYNC) && message.get(ASYNC) != null)
    asyncId = message.getStr(ASYNC);

  for (Slice sourceSlice : sourceSlices) {
    for (Slice targetSlice : targetSlices) {
      log.info("Migrating source shard: {} to target shard: {} for split.key = " + splitKey, sourceSlice, targetSlice);
      migrateKey(clusterState, sourceCollection, sourceSlice, targetCollection, targetSlice, splitKey,
          timeout, results, asyncId, message);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:46,代码来源:OverseerCollectionProcessor.java

示例7: doIndex

import org.apache.solr.common.cloud.DocCollection; //导入方法依赖的package包/类
public void doIndex(DocCollection coll, String id, String expectedShard) {
  DocRouter router = coll.getRouter();
  Slice target = router.getTargetSlice(id, null, null, coll);
  assertEquals(expectedShard, target.getName());
}
 
开发者ID:europeana,项目名称:search,代码行数:6,代码来源:TestHashPartitioner.java


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