本文整理汇总了Java中org.apache.solr.common.cloud.SolrZkClient.makePath方法的典型用法代码示例。如果您正苦于以下问题:Java SolrZkClient.makePath方法的具体用法?Java SolrZkClient.makePath怎么用?Java SolrZkClient.makePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.common.cloud.SolrZkClient
的用法示例。
在下文中一共展示了SolrZkClient.makePath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkChrootPath
import org.apache.solr.common.cloud.SolrZkClient; //导入方法依赖的package包/类
/**
* Validates if the chroot exists in zk (or if it is successfully created).
* Optionally, if create is set to true this method will create the path in
* case it doesn't exist
*
* @return true if the path exists or is created false if the path doesn't
* exist and 'create' = false
*/
public static boolean checkChrootPath(String zkHost, boolean create)
throws KeeperException, InterruptedException {
if (!containsChroot(zkHost)) {
return true;
}
log.info("zkHost includes chroot");
String chrootPath = zkHost.substring(zkHost.indexOf("/"), zkHost.length());
SolrZkClient tmpClient = new SolrZkClient(zkHost.substring(0,
zkHost.indexOf("/")), 60 * 1000);
boolean exists = tmpClient.exists(chrootPath, true);
if (!exists && create) {
tmpClient.makePath(chrootPath, false, true);
exists = true;
}
tmpClient.close();
return exists;
}
示例2: setUp
import org.apache.solr.common.cloud.SolrZkClient; //导入方法依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
super.setUp();
dataDir1 = createTempDir();
dataDir2 = createTempDir();
home = ExternalPaths.EXAMPLE_MULTICORE_HOME;
System.setProperty("solr.solr.home", home);
System.setProperty( "solr.core0.data.dir", dataDir1.getCanonicalPath() );
System.setProperty( "solr.core1.data.dir", dataDir2.getCanonicalPath() );
zkDir = dataDir1.getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
zkServer = new ZkTestServer(zkDir);
zkServer.run();
SolrZkClient zkClient = new SolrZkClient(zkServer.getZkHost(), AbstractZkTestCase.TIMEOUT);
zkClient.makePath("/solr", false, true);
zkClient.close();
System.setProperty("zkHost", zkServer.getZkAddress());
}
示例3: setUp
import org.apache.solr.common.cloud.SolrZkClient; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
log.info("####SETUP_START " + getTestName());
createTempDir();
zkDir = dataDir.getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
log.info("ZooKeeper dataDir:" + zkDir);
zkServer = new ZkTestServer(zkDir);
zkServer.run();
System.setProperty("zkHost", zkServer.getZkAddress());
SolrZkClient zkClient = new SolrZkClient(zkServer.getZkHost(), AbstractZkTestCase.TIMEOUT);
zkClient.makePath("/solr", false, true);
zkClient.close();
this.zkClient = new SolrZkClient(zkServer.getZkAddress(),
AbstractZkTestCase.TIMEOUT);
log.info("####SETUP_END " + getTestName());
}
示例4: setUp
import org.apache.solr.common.cloud.SolrZkClient; //导入方法依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
super.setUp();
createTempDir();
dataDir2 = new File(TEMP_DIR, getSimpleClassName() + "-core1-"
+ System.currentTimeMillis());
dataDir2.mkdirs();
home = ExternalPaths.EXAMPLE_MULTICORE_HOME;
System.setProperty("solr.solr.home", home);
System.setProperty( "solr.core0.data.dir", dataDir.getCanonicalPath() );
System.setProperty( "solr.core1.data.dir", dataDir2.getCanonicalPath() );
zkDir = dataDir.getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
zkServer = new ZkTestServer(zkDir);
zkServer.run();
SolrZkClient zkClient = new SolrZkClient(zkServer.getZkHost(), AbstractZkTestCase.TIMEOUT);
zkClient.makePath("/solr", false, true);
zkClient.close();
System.setProperty("zkHost", zkServer.getZkAddress());
}
示例5: putConfig
import org.apache.solr.common.cloud.SolrZkClient; //导入方法依赖的package包/类
public static void putConfig(String confName, SolrZkClient zkClient, File solrhome, final String srcName,
String destName) throws Exception {
File file = new File(solrhome, "collection1" + File.separator + "conf" + File.separator + srcName);
if (!file.exists()) {
log.info("zk skipping " + file.getAbsolutePath() + " because it doesn't exist");
return;
}
String destPath = "/configs/" + confName + "/" + destName;
log.info("zk put " + file.getAbsolutePath() + " to " + destPath);
zkClient.makePath(destPath, file, false, true);
}
示例6: putConfig
import org.apache.solr.common.cloud.SolrZkClient; //导入方法依赖的package包/类
public static void putConfig(String confName, SolrZkClient zkClient, File solrhome, final String srcName, String destName)
throws Exception {
File file = new File(solrhome, "collection1"
+ File.separator + "conf" + File.separator + srcName);
if (!file.exists()) {
log.info("skipping " + file.getAbsolutePath() + " because it doesn't exist");
return;
}
String destPath = "/configs/" + confName + "/" + destName;
log.info("put " + file.getAbsolutePath() + " to " + destPath);
zkClient.makePath(destPath, file, false, true);
}
示例7: putConfig
import org.apache.solr.common.cloud.SolrZkClient; //导入方法依赖的package包/类
private static void putConfig(SolrZkClient zkClient, File solrhome, String srcName, String destName)
throws Exception {
File file = new File(solrhome, "conf" + File.separator + srcName);
if (!file.exists()) {
// LOG.info("skipping " + file.getAbsolutePath() +
// " because it doesn't exist");
return;
}
String destPath = "/configs/conf1/" + destName;
// LOG.info("put " + file.getAbsolutePath() + " to " + destPath);
zkClient.makePath(destPath, file, false, true);
}
示例8: uploadToZK
import org.apache.solr.common.cloud.SolrZkClient; //导入方法依赖的package包/类
public static void uploadToZK(SolrZkClient zkClient, File dir, String zkPath) throws IOException, KeeperException, InterruptedException {
File[] files = dir.listFiles();
if (files == null) {
throw new IllegalArgumentException("Illegal directory: " + dir);
}
for(File file : files) {
if (!file.getName().startsWith(".")) {
if (!file.isDirectory()) {
zkClient.makePath(zkPath + "/" + file.getName(), file, false, true);
} else {
uploadToZK(zkClient, file, zkPath + "/" + file.getName());
}
}
}
}
示例9: setUp
import org.apache.solr.common.cloud.SolrZkClient; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
log.info("####SETUP_START " + getTestName());
boolean useNewSolrXml = random().nextBoolean();
File tmpDir = createTempDir();
if (useNewSolrXml) {
solrHome = ExternalPaths.EXAMPLE_HOME;
} else {
File tmpSolrHome = new File(tmpDir, "tmp-solr-home");
FileUtils.copyDirectory(new File(ExternalPaths.EXAMPLE_HOME), tmpSolrHome);
FileUtils.copyFile(getFile("old-solr-example/solr.xml"), new File(tmpSolrHome, "solr.xml"));
solrHome = tmpSolrHome.getAbsolutePath();
}
zkDir = tmpDir.getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
log.info("ZooKeeper dataDir:" + zkDir);
zkServer = new ZkTestServer(zkDir);
zkServer.run();
System.setProperty("zkHost", zkServer.getZkAddress());
SolrZkClient zkClient = new SolrZkClient(zkServer.getZkHost(), AbstractZkTestCase.TIMEOUT);
zkClient.makePath("/solr", false, true);
zkClient.close();
this.zkClient = new SolrZkClient(zkServer.getZkAddress(),
AbstractZkTestCase.TIMEOUT);
log.info("####SETUP_END " + getTestName());
}
示例10: testClean
import org.apache.solr.common.cloud.SolrZkClient; //导入方法依赖的package包/类
public void testClean() throws Exception {
try (ZkConnection conn = new ZkConnection ()) {
final SolrZkClient zkClient = conn.getClient();
zkClient.makePath("/test/path/here", true);
zkClient.makePath("/zz/path/here", true);
zkClient.clean("/");
assertFalse(zkClient.exists("/test", true));
assertFalse(zkClient.exists("/zz", true));
}
}
示例11: testMultipleWatchesAsync
import org.apache.solr.common.cloud.SolrZkClient; //导入方法依赖的package包/类
public void testMultipleWatchesAsync() throws Exception {
try (ZkConnection conn = new ZkConnection ()) {
final SolrZkClient zkClient = conn.getClient();
zkClient.makePath("/collections", true);
final int numColls = random().nextInt(100);
final CountDownLatch latch = new CountDownLatch(numColls);
for (int i = 1; i <= numColls; i ++) {
String collPath = "/collections/collection" + i;
zkClient.makePath(collPath, true);
zkClient.getChildren(collPath, new Watcher() {
@Override
public void process(WatchedEvent event) {
latch.countDown();
try {
Thread.sleep(1000);
}
catch (InterruptedException e) {}
}
}, true);
}
for (int i = 1; i <= numColls; i ++) {
String shardsPath = "/collections/collection" + i + "/shards";
zkClient.makePath(shardsPath, true);
}
assertTrue(latch.await(1000, TimeUnit.MILLISECONDS));
}
}
示例12: MockZKController
import org.apache.solr.common.cloud.SolrZkClient; //导入方法依赖的package包/类
public MockZKController(String zkAddress, String nodeName) throws InterruptedException, TimeoutException, IOException, KeeperException {
this.nodeName = nodeName;
zkClient = new SolrZkClient(zkAddress, TIMEOUT);
zkStateReader = new ZkStateReader(zkClient);
zkStateReader.createClusterStateWatchersAndUpdate();
// live node
final String nodePath = ZkStateReader.LIVE_NODES_ZKNODE + "/" + nodeName;
zkClient.makePath(nodePath, CreateMode.EPHEMERAL, true);
elector = new LeaderElector(zkClient);
}
示例13: MockZKController
import org.apache.solr.common.cloud.SolrZkClient; //导入方法依赖的package包/类
public MockZKController(String zkAddress, String nodeName, String collection) throws InterruptedException, TimeoutException, IOException, KeeperException {
this.nodeName = nodeName;
this.collection = collection;
zkClient = new SolrZkClient(zkAddress, TIMEOUT);
zkStateReader = new ZkStateReader(zkClient);
zkStateReader.createClusterStateWatchersAndUpdate();
// live node
final String nodePath = ZkStateReader.LIVE_NODES_ZKNODE + "/" + nodeName;
zkClient.makePath(nodePath, CreateMode.EPHEMERAL, true);
elector = new LeaderElector(zkClient);
}
示例14: makeSolrZkNode
import org.apache.solr.common.cloud.SolrZkClient; //导入方法依赖的package包/类
public static void makeSolrZkNode(String zkHost) throws Exception {
SolrZkClient zkClient = new SolrZkClient(zkHost, TIMEOUT);
zkClient.makePath("/solr", false, true);
zkClient.close();
}
示例15: putConfig
import org.apache.solr.common.cloud.SolrZkClient; //导入方法依赖的package包/类
private void putConfig(SolrZkClient zkClient, String name) throws Exception {
File file = new File(new File(SOLR_CONF_DIR, "conf"), name);
String destPath = "/configs/conf1/" + name;
System.out.println("put " + file.getAbsolutePath() + " to " + destPath);
zkClient.makePath(destPath, file, false, true);
}