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


Java ClusterState.getLeader方法代码示例

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


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

示例1: handleSyncShardAction

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private void handleSyncShardAction(SolrQueryRequest req, SolrQueryResponse rsp) throws KeeperException, InterruptedException, SolrServerException, IOException {
  log.info("Syncing shard : " + req.getParamString());
  String collection = req.getParams().required().get("collection");
  String shard = req.getParams().required().get("shard");
  
  ClusterState clusterState = coreContainer.getZkController().getClusterState();
  
  ZkNodeProps leaderProps = clusterState.getLeader(collection, shard);
  ZkCoreNodeProps nodeProps = new ZkCoreNodeProps(leaderProps);
  
  HttpSolrServer server = new HttpSolrServer(nodeProps.getBaseUrl());
  server.setConnectionTimeout(15000);
  server.setSoTimeout(30000);
  RequestSyncShard reqSyncShard = new CoreAdminRequest.RequestSyncShard();
  reqSyncShard.setCollection(collection);
  reqSyncShard.setShard(shard);
  reqSyncShard.setCoreName(nodeProps.getCoreName());
  server.request(reqSyncShard);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:20,代码来源:CollectionsHandler.java

示例2: handleSyncShardAction

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private void handleSyncShardAction(SolrQueryRequest req, SolrQueryResponse rsp) throws KeeperException, InterruptedException, SolrServerException, IOException {
  log.info("Syncing shard : " + req.getParamString());
  String collection = req.getParams().required().get("collection");
  String shard = req.getParams().required().get("shard");
  
  ClusterState clusterState = coreContainer.getZkController().getClusterState();
  
  ZkNodeProps leaderProps = clusterState.getLeader(collection, shard);
  ZkCoreNodeProps nodeProps = new ZkCoreNodeProps(leaderProps);
  
  HttpSolrServer server = new HttpSolrServer(nodeProps.getBaseUrl());
  try {
    server.setConnectionTimeout(15000);
    server.setSoTimeout(60000);
    RequestSyncShard reqSyncShard = new CoreAdminRequest.RequestSyncShard();
    reqSyncShard.setCollection(collection);
    reqSyncShard.setShard(shard);
    reqSyncShard.setCoreName(nodeProps.getCoreName());
    server.request(reqSyncShard);
  } finally {
    server.shutdown();
  }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:24,代码来源:CollectionsHandler.java

示例3: getCoreByCollection

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private SolrCore getCoreByCollection(CoreContainer cores, String corename, String path) {
  String collection = corename;
  ZkStateReader zkStateReader = cores.getZkController().getZkStateReader();
  
  ClusterState clusterState = zkStateReader.getClusterState();
  Map<String,Slice> slices = clusterState.getActiveSlicesMap(collection);
  if (slices == null) {
    return null;
  }
  // look for a core on this node
  Set<Entry<String,Slice>> entries = slices.entrySet();
  SolrCore core = null;
  done:
  for (Entry<String,Slice> entry : entries) {
    // first see if we have the leader
    ZkNodeProps leaderProps = clusterState.getLeader(collection, entry.getKey());
    if (leaderProps != null) {
      core = checkProps(cores, path, leaderProps);
    }
    if (core != null) {
      break done;
    }
    
    // check everyone then
    Map<String,Replica> shards = entry.getValue().getReplicasMap();
    Set<Entry<String,Replica>> shardEntries = shards.entrySet();
    for (Entry<String,Replica> shardEntry : shardEntries) {
      Replica zkProps = shardEntry.getValue();
      core = checkProps(cores, path, zkProps);
      if (core != null) {
        break done;
      }
    }
  }
  return core;
}
 
开发者ID:europeana,项目名称:search,代码行数:37,代码来源:SolrDispatchFilter.java

示例4: getLeaderUrlFromZk

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
protected ZkCoreNodeProps getLeaderUrlFromZk(String collection, String slice) {
  ClusterState clusterState = getCommonCloudSolrServer().getZkStateReader().getClusterState();
  ZkNodeProps leader = clusterState.getLeader(collection, slice);
  if (leader == null) {
    throw new RuntimeException("Could not find leader:" + collection + " " + slice);
  }
  return new ZkCoreNodeProps(leader);
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:BasicDistributedZkTest.java

示例5: getCoreByCollection

import org.apache.solr.common.cloud.ClusterState; //导入方法依赖的package包/类
private SolrCore getCoreByCollection(CoreContainer cores, String corename, String path) {
  String collection = corename;
  ZkStateReader zkStateReader = cores.getZkController().getZkStateReader();
  
  ClusterState clusterState = zkStateReader.getClusterState();
  Map<String,Slice> slices = clusterState.getSlicesMap(collection);
  if (slices == null) {
    return null;
  }
  // look for a core on this node
  Set<Entry<String,Slice>> entries = slices.entrySet();
  SolrCore core = null;
  done:
  for (Entry<String,Slice> entry : entries) {
    // first see if we have the leader
    ZkNodeProps leaderProps = clusterState.getLeader(collection, entry.getKey());
    if (leaderProps != null) {
      core = checkProps(cores, path, leaderProps);
    }
    if (core != null) {
      break done;
    }
    
    // check everyone then
    Map<String,Replica> shards = entry.getValue().getReplicasMap();
    Set<Entry<String,Replica>> shardEntries = shards.entrySet();
    for (Entry<String,Replica> shardEntry : shardEntries) {
      Replica zkProps = shardEntry.getValue();
      core = checkProps(cores, path, zkProps);
      if (core != null) {
        break done;
      }
    }
  }
  return core;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:37,代码来源:SolrDispatchFilter.java


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