gpt4 book ai didi

org.apache.solr.client.solrj.impl.ZkClientClusterStateProvider类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 13:00:55 35 4
gpt4 key购买 nike

本文整理了Java中org.apache.solr.client.solrj.impl.ZkClientClusterStateProvider类的一些代码示例,展示了ZkClientClusterStateProvider类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkClientClusterStateProvider类的具体详情如下:
包路径:org.apache.solr.client.solrj.impl.ZkClientClusterStateProvider
类名称:ZkClientClusterStateProvider

ZkClientClusterStateProvider介绍

暂无

代码示例

代码示例来源:origin: org.apache.solr/solr-solrj

public ZkClientClusterStateProvider(Collection<String> zkHosts, String chroot) {
 zkHost = buildZkHostString(zkHosts,chroot);
}

代码示例来源:origin: org.apache.solr/solr-solrj

/**
 * Download a named config from Zookeeper to a location on the filesystem
 * @param configName    the name of the config
 * @param downloadPath  the path to write config files to
 * @throws IOException  if an I/O exception occurs
 */
public void downloadConfig(String configName, Path downloadPath) throws IOException {
 connect();
 zkStateReader.getConfigManager().downloadConfigDir(configName, downloadPath);
}

代码示例来源:origin: org.apache.solr/solr-solrj

public boolean isNodeAlive(String node) {
 if (zkClientClusterStateProvider != null) {
  return zkClientClusterStateProvider.getLiveNodes().contains(node);
 }
 return true;
}
public ClientSnitchCtx(SnitchInfo perSnitch,

代码示例来源:origin: edu.byu.hbll/solr

/**
 * Creates a SolrCloud collection if it doesn't already exist with the given config set.
 *
 * @deprecated since 1.2.0 use {@link SolrCollectionInitializer} instead.
 * @param zkHost host and optional port of one of a zookeeper instance (localhost:2181)
 * @param collectionName name of the collection to be created
 * @param configSetName name of the config set to use
 * @param configSetPath location of the config set (folder containing solr configs such as
 *     solrconfig.xml)
 * @throws IOException if something goes wrong with the upload
 * @throws SolrServerException if something goes wrong with the upload
 */
@Deprecated
public static void initSolr(
  String zkHost, String collectionName, String configSetName, Path configSetPath)
  throws IOException, SolrServerException {
 try (ZkClientClusterStateProvider provider = new ZkClientClusterStateProvider(zkHost)) {
  provider.uploadConfig(configSetPath, configSetName);
 }
 try (SolrClient solr = new CloudSolrClient.Builder().withZkHost(zkHost).build()) {
  List<String> existingCollectionNames = CollectionAdminRequest.listCollections(solr);
  if (!existingCollectionNames.contains(collectionName)) {
   solr.request(CollectionAdminRequest.createCollection(collectionName, configSetName, 1, 1));
  }
 }
}

代码示例来源:origin: org.apache.solr/solr-solrj

/**
 * Create a {@link CloudSolrClient} based on the provided configuration.
 */
public CloudSolrClient build() {
 if (stateProvider == null) {
  if (!zkHosts.isEmpty()) {
   stateProvider = new ZkClientClusterStateProvider(zkHosts, zkChroot);
  }
  else if (!this.solrUrls.isEmpty()) {
   try {
    stateProvider = new HttpClusterStateProvider(solrUrls, httpClient);
   } catch (Exception e) {
    throw new RuntimeException("Couldn't initialize a HttpClusterStateProvider (is/are the "
      + "Solr server(s), "  + solrUrls + ", down?)", e);
   }
  } else {
   throw new IllegalArgumentException("Both zkHosts and solrUrl cannot be null.");
  }
 }
 return new CloudSolrClient(this);
}

代码示例来源:origin: org.apache.solr/solr-test-framework

/**
 * Configure, run and return the {@link MiniSolrCloudCluster}
 * @throws Exception if an error occurs on startup
 */
public MiniSolrCloudCluster build() throws Exception {
 MiniSolrCloudCluster cluster = new MiniSolrCloudCluster(nodeCount, baseDir, solrxml, jettyConfig, null, securityJson);
 CloudSolrClient client = cluster.getSolrClient();
 for (Config config : configs) {
  ((ZkClientClusterStateProvider)client.getClusterStateProvider()).uploadConfig(config.path, config.name);
 }
 if (clusterProperties.size() > 0) {
  ClusterProperties props = new ClusterProperties(cluster.getSolrClient().getZkStateReader().getZkClient());
  for (Map.Entry<String, String> entry : clusterProperties.entrySet()) {
   props.setClusterProperty(entry.getKey(), entry.getValue());
  }
 }
 return cluster;
}

代码示例来源:origin: org.apache.solr/solr-solrj

@Override
public Map getZkJson(String path) throws KeeperException, InterruptedException {
 return Utils.getJson(zkClientClusterStateProvider.getZkStateReader().getZkClient(), path, true);
}

代码示例来源:origin: org.apache.solr/solr-solrj

@Override
public String getPolicyNameByCollection(String coll) {
 ClusterState.CollectionRef state = getState(coll);
 return state == null || state.get() == null ? null : (String) state.get().getProperties().get("policy");
}

代码示例来源:origin: edu.byu.hbll/solr

new ZkClientClusterStateProvider(zkHosts, chroot)) {
provider.uploadConfig(configsetPath, configsetName);

代码示例来源:origin: org.apache.solr/solr-solrj

this.stateProvider = new ZkClientClusterStateProvider(builder.zkHosts, builder.zkChroot);
} else if (builder.solrUrls != null && !builder.solrUrls.isEmpty()) {
 try {

代码示例来源:origin: org.apache.solr/solr-solrj

public SimpleSolrResponse invoke(String solrNode, String path, SolrParams params)
  throws IOException, SolrServerException {
 String url = zkClientClusterStateProvider.getZkStateReader().getBaseUrlForNodeName(solrNode);
 GenericSolrRequest request = new GenericSolrRequest(SolrRequest.METHOD.POST, path, params);
 try (HttpSolrClient client = new HttpSolrClient.Builder()
   .withHttpClient(solrClient.getHttpClient())
   .withBaseSolrUrl(url)
   .withResponseParser(new BinaryResponseParser())
   .build()) {
  NamedList<Object> rsp = client.request(request);
  request.response.nl = rsp;
  return request.response;
 }
}

代码示例来源:origin: org.apache.solr/solr-solrj

/**
 * Upload a set of config files to Zookeeper and give it a name
 *
 * NOTE: You should only allow trusted users to upload configs.  If you
 * are allowing client access to zookeeper, you should protect the
 * /configs node against unauthorised write access.
 *
 * @param configPath {@link java.nio.file.Path} to the config files
 * @param configName the name of the config
 * @throws IOException if an IO error occurs
 */
public void uploadConfig(Path configPath, String configName) throws IOException {
 connect();
 zkStateReader.getConfigManager().uploadConfigDir(configPath, configName);
}

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com