本文整理匯總了Java中org.apache.curator.test.TestingServer.close方法的典型用法代碼示例。如果您正苦於以下問題:Java TestingServer.close方法的具體用法?Java TestingServer.close怎麽用?Java TestingServer.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.curator.test.TestingServer
的用法示例。
在下文中一共展示了TestingServer.close方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import org.apache.curator.test.TestingServer; //導入方法依賴的package包/類
/**
* 測試入口
*/
public static void main(String[] args) throws Exception {
String path = "/zookeeper";
TestingServer server = new TestingServer(2181, new File(
"/download/zk/data"));
CuratorFramework client = CuratorFrameworkFactory.builder()
.connectString(server.getConnectString())
.sessionTimeoutMs(50000).connectionTimeoutMs(100000)
.retryPolicy(new ExponentialBackoffRetry(1000, 5)).build();
client.start();
System.out.println(client.getChildren().forPath(path));
server.close();
}
示例2: closeServer
import org.apache.curator.test.TestingServer; //導入方法依賴的package包/類
/**
* 關閉內嵌的Zookeeper服務.
*
* @param port 端口號
*/
public void closeServer(final int port) {
TestingServer nestedServer = nestedServers.get(port);
if (null == nestedServer) {
return;
}
try {
nestedServer.close();
nestedServers.remove(port);
} catch (final IOException ex) {
RegExceptionHandler.handleException(ex);
}
}
示例3: closeServer
import org.apache.curator.test.TestingServer; //導入方法依賴的package包/類
/**
* 關閉內嵌的Zookeeper服務.
*
* @param port 端口號
*/
public void closeServer(final int port) {
TestingServer nestedServer = nestedServers.get(port);
if (null == nestedServer) {
return;
}
try {
nestedServer.close();
nestedServers.remove(port);
}
catch (final IOException ex) {
RegisterExceptionHandler.handleException(ex);
}
}
示例4: testOwnershipOfExistingBucket
import org.apache.curator.test.TestingServer; //導入方法依賴的package包/類
@Test(timeout = 10000)
public void testOwnershipOfExistingBucket() throws Exception {
TestingServer zkServer2 = new TestingServerStarter().start();
zkServer2.start();
CuratorFramework zkClient2 = CuratorFrameworkFactory.newClient(zkServer2.getConnectString(), 10000, 1000,
(r, e, s) -> false);
zkClient2.start();
ScheduledExecutorService executor2 = Executors.newScheduledThreadPool(10);
String hostId = UUID.randomUUID().toString();
StreamMetadataStore streamMetadataStore2 = StreamStoreFactory.createZKStore(zkClient2, 1, executor2);
TaskMetadataStore taskMetadataStore = TaskStoreFactory.createInMemoryStore(executor2);
HostControllerStore hostStore = HostStoreFactory.createInMemoryStore(HostMonitorConfigImpl.dummyConfig());
SegmentHelper segmentHelper = SegmentHelperMock.getSegmentHelperMock();
ConnectionFactoryImpl connectionFactory = new ConnectionFactoryImpl(false);
StreamMetadataTasks streamMetadataTasks2 = new StreamMetadataTasks(streamMetadataStore2, hostStore, taskMetadataStore, segmentHelper, executor2, hostId, connectionFactory);
String scope = "scope1";
String streamName = "stream1";
streamMetadataStore2.addUpdateStreamForAutoStreamCut(scope, streamName, RetentionPolicy.builder().build(), null, executor2).join();
String scope2 = "scope2";
String streamName2 = "stream2";
streamMetadataStore2.addUpdateStreamForAutoStreamCut(scope2, streamName2, RetentionPolicy.builder().build(), null, executor2).join();
StreamCutService service2 = new StreamCutService(1, hostId, streamMetadataStore2, streamMetadataTasks2, executor2);
service2.startAsync();
service2.awaitRunning();
assertTrue(service2.getBuckets().stream().allMatch(x -> x.getRetentionFutureMap().size() == 2));
service2.stopAsync();
service2.awaitTerminated();
zkClient2.close();
zkServer2.close();
streamMetadataTasks2.close();
connectionFactory.close();
executor2.shutdown();
}