gpt4 book ai didi

org.apache.solr.common.cloud.ZkConfigManager类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 23:38:03 26 4
gpt4 key购买 nike

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

ZkConfigManager介绍

[英]Class that manages named configs in Zookeeper
[中]类,该类管理Zookeeper中的命名配置

代码示例

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

public static void upConfig(SolrZkClient zkClient, Path confPath, String confName) throws IOException {
 ZkConfigManager manager = new ZkConfigManager(zkClient);
 // Try to download the configset
 manager.uploadConfigDir(confPath, confName);
}

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

public static void downConfig(SolrZkClient zkClient, String confName, Path confPath) throws IOException {
 ZkConfigManager manager = new ZkConfigManager(zkClient);
 // Try to download the configset
 manager.downloadConfigDir(confName, confPath);
}

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

/**
 * Copy a config in ZooKeeper
 *
 * @param fromConfig the config to copy from
 * @param toConfig the config to copy to
 * @throws IOException if an I/O error occurs
 */
public void copyConfigDir(String fromConfig, String toConfig) throws IOException {
 copyConfigDir(fromConfig, toConfig, null);
}

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

public ZkStateReader(SolrZkClient zkClient, Runnable securityNodeListener) {
 this.zkClient = zkClient;
 this.configManager = new ZkConfigManager(zkClient);
 this.closeClient = false;
 this.securityNodeListener = securityNodeListener;
}

代码示例来源:origin: com.hynnet/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

/**
 * 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);
}

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

/**
 * Copy a config in ZooKeeper
 *
 * @param fromConfig the config to copy from
 * @param toConfig the config to copy to
 * @param copiedToZkPaths should be an empty Set, will be filled in by function
             with the paths that were actually copied to.
 * @throws IOException if an I/O error occurs
 */
public void copyConfigDir(String fromConfig, String toConfig, Set<String> copiedToZkPaths) throws IOException {
 copyConfigDirFromZk(CONFIGS_ZKNODE + "/" + fromConfig, CONFIGS_ZKNODE + "/" + toConfig, copiedToZkPaths);
}

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

public ZkStateReader(String zkServerAddress, int zkClientTimeout, int zkClientConnectTimeout) {
 this.zkClient = new SolrZkClient(zkServerAddress, zkClientTimeout, zkClientConnectTimeout,
   // on reconnect, reload cloud info
   new OnReconnect() {
    @Override
    public void command() {
     try {
      ZkStateReader.this.createClusterStateWatchersAndUpdate();
     } catch (KeeperException e) {
      log.error("A ZK error has occurred", e);
      throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "A ZK error has occurred", e);
     } catch (InterruptedException e) {
      // Restore the interrupted status
      Thread.currentThread().interrupt();
      log.error("Interrupted", e);
      throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "Interrupted", e);
     }
    }
   });
 this.configManager = new ZkConfigManager(zkClient);
 this.closeClient = true;
 this.securityNodeListener = null;
}

代码示例来源: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: com.hynnet/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);
}

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

private void copyConfigDirFromZk(String fromZkPath, String toZkPath, Set<String> copiedToZkPaths) throws IOException {
 try {
  List<String> files = zkClient.getChildren(fromZkPath, null, true);
  for (String file : files) {
   List<String> children = zkClient.getChildren(fromZkPath + "/" + file, null, true);
   if (children.size() == 0) {
    final String toZkFilePath = toZkPath + "/" + file;
    log.info("Copying zk node {} to {}",
      fromZkPath + "/" + file, toZkFilePath);
    byte[] data = zkClient.getData(fromZkPath + "/" + file, null, null, true);
    zkClient.makePath(toZkFilePath, data, true);
    if (copiedToZkPaths != null) copiedToZkPaths.add(toZkFilePath);
   } else {
    copyConfigDirFromZk(fromZkPath + "/" + file, toZkPath + "/" + file, copiedToZkPaths);
   }
  }
 } catch (KeeperException | InterruptedException e) {
  throw new IOException("Error copying nodes from zookeeper path " + fromZkPath + " to " + toZkPath,
    SolrZkClient.checkInterrupted(e));
 }
}

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

/**
 * Upload a config set
 * @param configDir a path to the config set to upload
 * @param configName the name to give the configset
 */
public void uploadConfigSet(Path configDir, String configName) throws IOException, KeeperException, InterruptedException {
 try(SolrZkClient zkClient = new SolrZkClient(zkServer.getZkAddress(),
   AbstractZkTestCase.TIMEOUT, AbstractZkTestCase.TIMEOUT, null)) {
  ZkConfigManager manager = new ZkConfigManager(zkClient);
  manager.uploadConfigDir(configDir, configName);
 }
}

代码示例来源:origin: kite-sdk/kite

/**
 * Download and return the config directory from ZK
 */
public File downloadConfigDir(SolrZkClient zkClient, String configName, File dir)
throws IOException, InterruptedException, KeeperException {
 Preconditions.checkArgument(dir.exists());
 Preconditions.checkArgument(dir.isDirectory());
 ZkConfigManager manager = new ZkConfigManager(zkClient);
 manager.downloadConfigDir(configName, dir.toPath());
 File confDir = new File(dir, "conf");
 if (!confDir.isDirectory()) {
  // create a temporary directory with "conf" subdir and mv the config in there.  This is
  // necessary because of CDH-11188; solrctl does not generate nor accept directories with e.g.
  // conf/solrconfig.xml which is necessary for proper solr operation.  This should work
  // even if solrctl changes.
  confDir = new File(Files.createTempDir().getAbsolutePath(), "conf");
  confDir.getParentFile().deleteOnExit();
  Files.move(dir, confDir);
  dir = confDir.getParentFile();
 }
 verifyConfigDir(confDir);
 return dir;
}

代码示例来源:origin: com.hynnet/solr-solrj

public ZkStateReader(SolrZkClient zkClient, Runnable securityNodeListener) {
 this.zkClient = zkClient;
 this.cmdExecutor = new ZkCmdExecutor(zkClient.getZkClientTimeout());
 this.configManager = new ZkConfigManager(zkClient);
 this.closeClient = false;
 this.securityNodeListener = securityNodeListener;
}

代码示例来源:origin: NGDATA/hbase-indexer

/**
 * Utility method to upload a Solr config into ZooKeeper. If you don't have the config in the form of
 * a filesystem directory, you might want to use {@link #uploadConfig(String, byte[], byte[])}.
 */
public void uploadConfig(String confName, File confDir) throws IOException {
  SolrZkClient zkClient = new SolrZkClient(zkConnectString, 30000, 30000,
      new OnReconnect() {
        @Override
        public void command() {
        }
      });
  new ZkConfigManager(zkClient).uploadConfigDir(confDir.toPath(), confName);
  zkClient.close();
}

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

/**
 * Download and return the config directory from ZK
 */
public File downloadConfigDir(SolrZkClient zkClient, String configName, File dir)
throws IOException, InterruptedException, KeeperException {
 Preconditions.checkArgument(dir.exists());
 Preconditions.checkArgument(dir.isDirectory());
 ZkConfigManager manager = new ZkConfigManager(zkClient);
 manager.downloadConfigDir(configName, dir.toPath());
 File confDir = new File(dir, "conf");
 if (!confDir.isDirectory()) {
  // create a temporary directory with "conf" subdir and mv the config in there.  This is
  // necessary because of CDH-11188; solrctl does not generate nor accept directories with e.g.
  // conf/solrconfig.xml which is necessary for proper solr operation.  This should work
  // even if solrctl changes.
  confDir = new File(Files.createTempDir().getAbsolutePath(), "conf");
  confDir.getParentFile().deleteOnExit();
  Files.move(dir, confDir);
  dir = confDir.getParentFile();
 }
 verifyConfigDir(confDir);
 return dir;
}

代码示例来源:origin: com.hynnet/solr-solrj

public ZkStateReader(String zkServerAddress, int zkClientTimeout, int zkClientConnectTimeout) {
 this.zkClient = new SolrZkClient(zkServerAddress, zkClientTimeout, zkClientConnectTimeout,
   // on reconnect, reload cloud info
   new OnReconnect() {
    @Override
    public void command() {
     try {
      ZkStateReader.this.createClusterStateWatchersAndUpdate();
     } catch (KeeperException e) {
      log.error("", e);
      throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
        "", e);
     } catch (InterruptedException e) {
      // Restore the interrupted status
      Thread.currentThread().interrupt();
      log.error("", e);
      throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
        "", e);
     }
    }
   });
 this.cmdExecutor = new ZkCmdExecutor(zkClientTimeout);
 this.configManager = new ZkConfigManager(zkClient);
 this.closeClient = true;
 this.securityNodeListener = null;
}

代码示例来源:origin: com.ngdata/hbase-indexer-common

/**
 * Utility method to upload a Solr config into ZooKeeper. If you don't have the config in the form of
 * a filesystem directory, you might want to use {@link #uploadConfig(String, byte[], byte[])}.
 */
public void uploadConfig(String confName, File confDir) throws IOException {
  SolrZkClient zkClient = new SolrZkClient(zkConnectString, 30000, 30000,
      new OnReconnect() {
        @Override
        public void command() {
        }
      });
  new ZkConfigManager(zkClient).uploadConfigDir(confDir.toPath(), confName);
  zkClient.close();
}

代码示例来源:origin: com.cloudera.search/search-mr

File dir = Files.createTempDir();
dir.deleteOnExit();
ZkConfigManager configManager = new ZkConfigManager(zkClient);
configManager.downloadConfigDir(configName, dir.toPath());
File confDir = new File(dir, "conf");
if (!confDir.isDirectory()) {

代码示例来源:origin: jetoile/hadoop-unit

private void populateZkWithCollectionInfo() {
  System.setProperty("zkHost", zkHostString);
  try {
    URL url = ConfigurationUtils.locate(FileSystem.getDefaultFileSystem(), "", solrDirectory + "/collection1/conf");
    if (url == null) {
      try {
        url = new URL(solrDirectory + "/collection1/conf");
      } catch (MalformedURLException e) {
        LOGGER.error("unable to load solr config", e);
      }
    }
    URI solrDirectoryFile = url.toURI();
    try (SolrZkClient zkClient = new SolrZkClient(zkHostString, TIMEOUT, 45000, null)) {
      ZkConfigManager manager = new ZkConfigManager(zkClient);
      manager.uploadConfigDir(Paths.get(solrDirectoryFile), solrCollectionName);
    }
  } catch (URISyntaxException | IOException e) {
    LOGGER.error("unable to populate zookeeper", e);
  }
}

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