當前位置: 首頁>>代碼示例>>Java>>正文


Java TestingServer.stop方法代碼示例

本文整理匯總了Java中org.apache.curator.test.TestingServer.stop方法的典型用法代碼示例。如果您正苦於以下問題:Java TestingServer.stop方法的具體用法?Java TestingServer.stop怎麽用?Java TestingServer.stop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.curator.test.TestingServer的用法示例。


在下文中一共展示了TestingServer.stop方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testServer

import org.apache.curator.test.TestingServer; //導入方法依賴的package包/類
public void testServer(){
        try {
        TestingServer server=new TestingServer(2181,new File("/"));
        server.start();

        CuratorFramework curatorFramework = CuratorFrameworkFactory.
                builder().
                connectString(server.getConnectString()).
                sessionTimeoutMs(1000).
                retryPolicy(new RetryNTimes(3, 1000)).
                build();
        curatorFramework.start();
        System.out.println(curatorFramework.getChildren().forPath("/"));
        curatorFramework.close();
        server.stop();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
 
開發者ID:mumudemo,項目名稱:mumu-zookeeper,代碼行數:21,代碼來源:CuratorServer.java

示例2: testExternalizedIncrementalRocksDBCheckpointsZookeeper

import org.apache.curator.test.TestingServer; //導入方法依賴的package包/類
@Test
public void testExternalizedIncrementalRocksDBCheckpointsZookeeper() throws Exception {
	TestingServer zkServer = new TestingServer();
	zkServer.start();
	try {
		final File checkpointDir = temporaryFolder.newFolder();
		testExternalizedCheckpoints(
			checkpointDir,
			zkServer.getConnectString(),
			new RocksDBStateBackend(checkpointDir.toURI().toString(), true));
	} finally {
		zkServer.stop();
	}
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:15,代碼來源:ExternalizedCheckpointITCase.java

示例3: testExternalizedFullRocksDBCheckpointsZookeeper

import org.apache.curator.test.TestingServer; //導入方法依賴的package包/類
@Test
public void testExternalizedFullRocksDBCheckpointsZookeeper() throws Exception {
	TestingServer zkServer = new TestingServer();
	zkServer.start();
	try {
		final File checkpointDir = temporaryFolder.newFolder();
		testExternalizedCheckpoints(
			checkpointDir,
			zkServer.getConnectString(),
			new RocksDBStateBackend(checkpointDir.toURI().toString(), false));
	} finally {
		zkServer.stop();
	}
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:15,代碼來源:ExternalizedCheckpointITCase.java

示例4: testExternalizedFSCheckpointsZookeeper

import org.apache.curator.test.TestingServer; //導入方法依賴的package包/類
@Test
public void testExternalizedFSCheckpointsZookeeper() throws Exception {
	TestingServer zkServer = new TestingServer();
	zkServer.start();
	try {
		final File checkpointDir = temporaryFolder.newFolder();
		testExternalizedCheckpoints(
			checkpointDir,
			zkServer.getConnectString(),
			new FsStateBackend(checkpointDir.toURI().toString(), true));
	} finally {
		zkServer.stop();
	}
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:15,代碼來源:ExternalizedCheckpointITCase.java

示例5: main

import org.apache.curator.test.TestingServer; //導入方法依賴的package包/類
public static void main(String... args) throws Exception {
    // Start cassandra if necessary (cassandra.yaml is provided)
    ArgumentParser parser = ArgumentParsers.newArgumentParser("java -jar emodb-web-local*.jar");
    parser.addArgument("server").required(true).help("server");
    parser.addArgument("emo-config").required(true).help("config.yaml - EmoDB's config file");
    parser.addArgument("emo-config-ddl").required(true).help("config-ddl.yaml - EmoDB's cassandra schema file");
    parser.addArgument("cassandra-yaml").nargs("?").help("cassandra.yaml - Cassandra configuration file to start an" +
            " in memory embedded Cassandra.");
    parser.addArgument("-z","--zookeeper").dest("zookeeper").action(Arguments.storeTrue()).help("Starts zookeeper");

    // Get the path to cassandraYaml or if zookeeper is available
    Namespace result = parser.parseArgs(args);
    String cassandraYaml = result.getString("cassandra-yaml");
    boolean startZk = result.getBoolean("zookeeper");

    String[] emoServiceArgs = args;

    // Start ZooKeeper
    TestingServer zooKeeperServer = null;
    if (startZk) {
        zooKeeperServer = isLocalZooKeeperRunning() ? null : startLocalZooKeeper();
        emoServiceArgs = (String[]) ArrayUtils.removeElement(args, "-z");
        emoServiceArgs = (String[]) ArrayUtils.removeElement(emoServiceArgs, "--zookeeper");

    }
    boolean success = false;


    if (cassandraYaml != null) {
        // Replace $DIR$ so we can correctly specify location during runtime
        File templateFile = new File(cassandraYaml);
        String baseFile = Files.toString(templateFile, Charset.defaultCharset());
        // Get the jar location
        String path = EmoServiceWithZK.class.getProtectionDomain().getCodeSource().getLocation().getPath();
        String parentDir = new File(path).getParent();
        String newFile = baseFile.replace("$DATADIR$", new File(parentDir, "data").getAbsolutePath());
        newFile = newFile.replace("$COMMITDIR$", new File(parentDir, "commitlog").getAbsolutePath());
        newFile = newFile.replace("$CACHEDIR$", new File(parentDir, "saved_caches").getAbsolutePath());
        File newYamlFile = new File(templateFile.getParent(), "emo-cassandra.yaml");
        Files.write(newFile, newYamlFile, Charset.defaultCharset());

        startLocalCassandra(newYamlFile.getAbsolutePath());
        emoServiceArgs = (String[]) ArrayUtils.removeElement(emoServiceArgs, cassandraYaml);
    }

    try {
        EmoService.main(emoServiceArgs);
        success = true;

    } catch (Throwable t) {
        t.printStackTrace();
    } finally {
        // The main web server command returns immediately--don't stop ZooKeeper/Cassandra in that case.
        if (zooKeeperServer != null && !(success && args.length > 0 && "server".equals(args[0]))) {
            zooKeeperServer.stop();
            service.shutdown();
        }
    }
}
 
開發者ID:bazaarvoice,項目名稱:emodb,代碼行數:60,代碼來源:EmoServiceWithZK.java


注:本文中的org.apache.curator.test.TestingServer.stop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。