- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.twitter.common.zookeeper.testing.ZooKeeperTestServer
类的一些代码示例,展示了ZooKeeperTestServer
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperTestServer
类的具体详情如下:
包路径:com.twitter.common.zookeeper.testing.ZooKeeperTestServer
类名称:ZooKeeperTestServer
[英]A helper class for starting in-process ZooKeeper server and clients. Note that this class is not thread safe. Calls to server lifecycle methods in this class must be externally synchronized if made by multiple threads.
This is ONLY meant to be used for testing.
[中]用于启动进程内ZooKeeper服务器和客户端的助手类。注意,这个类不是线程安全的。如果由多个线程调用此类中的服务器生命周期方法,则必须进行外部同步。
这只用于测试。
代码示例来源:origin: com.twitter.common/zookeeper-testing
/**
* Returns a new unauthenticated zookeeper client connected to the in-process zookeeper server
* with the default session timeout.
*/
protected final ZooKeeperClient createZkClient() {
return zkTestServer.createClient();
}
代码示例来源:origin: com.twitter.common/zookeeper-testing
/**
* Returns the current port to connect to the in-process zookeeper instance.
*/
protected final int getPort() {
return zkTestServer.getPort();
}
代码示例来源:origin: com.twitter.common/zookeeper-testing
/**
* Returns the current port to connect to the in-process zookeeper instance.
*/
public final int getPort() {
checkEphemeralPortAssigned();
return port;
}
代码示例来源:origin: com.twitter.common.zookeeper.guice/client
@Override
public ZooKeeperClient get() {
ZooKeeperTestServer zooKeeperServer;
try {
zooKeeperServer = new ZooKeeperTestServer(0, shutdownRegistry);
zooKeeperServer.startNetwork();
} catch (IOException e) {
throw Throwables.propagate(e);
} catch (InterruptedException e) {
throw Throwables.propagate(e);
}
LOG.info("Embedded zookeeper cluster started on port " + zooKeeperServer.getPort());
return zooKeeperServer.createClient(config.sessionTimeout, config.credentials);
}
}
代码示例来源:origin: com.twitter.common/zookeeper-testing
@Before
public final void setUp() throws Exception {
final ShutdownRegistryImpl shutdownRegistry = new ShutdownRegistryImpl();
addTearDown(new TearDown() {
@Override public void tearDown() {
shutdownRegistry.execute();
}
});
zkTestServer = new ZooKeeperTestServer(0, shutdownRegistry, defaultSessionTimeout);
zkTestServer.startNetwork();
}
代码示例来源:origin: com.twitter.common/zookeeper-testing
/**
* Starts zookeeper back up on the last used port.
*/
public final void restartNetwork() throws IOException, InterruptedException {
checkEphemeralPortAssigned();
Preconditions.checkState(!isStarted, "Must call shutdownNetwork() before restarting network");
startNetwork();
}
代码示例来源:origin: com.twitter.common/zookeeper-testing
/**
* Shuts down the in-process zookeeper network server.
*/
protected final void shutdownNetwork() {
zkTestServer.shutdownNetwork();
}
代码示例来源:origin: com.twitter.common/zookeeper-testing
/**
* Starts zookeeper back up on the last used port.
*/
protected final void restartNetwork() throws IOException, InterruptedException {
zkTestServer.restartNetwork();
}
代码示例来源:origin: com.twitter.common/zookeeper-testing
/**
* Expires the active session for the given client. The client should be one returned from
* {@link #createZkClient}.
*
* @param zkClient the client to expire
* @throws ZooKeeperClient.ZooKeeperConnectionException if a problem is encountered connecting to
* the local zk server while trying to expire the session
* @throws InterruptedException if interrupted while requesting expiration
*/
protected final void expireSession(ZooKeeperClient zkClient)
throws ZooKeeperConnectionException, InterruptedException {
zkTestServer.expireClientSession(zkClient);
}
代码示例来源:origin: com.twitter.common/zookeeper-testing
/**
* @param port the port to start the zookeeper server on - {@code 0} picks an ephemeral port
* @param shutdownRegistry a registry that will be used to register client and server shutdown
* commands. It is up to the caller to execute the registered actions at an appropriate time.
* @param defaultSessionTimeout the default session timeout for clients created with
* {@link #createClient()}.
* @throws IOException if there was a problem creating the server's database
*/
public ZooKeeperTestServer(int port, ShutdownRegistry shutdownRegistry,
Amount<Integer, Time> defaultSessionTimeout) throws IOException {
Preconditions.checkArgument(0 <= port && port <= 0xFFFF);
this.port = port;
this.shutdownRegistry = Preconditions.checkNotNull(shutdownRegistry);
this.defaultSessionTimeout = Preconditions.checkNotNull(defaultSessionTimeout);
zooKeeperServer =
new ZooKeeperServer(
createTempDir(),
createTempDir(),
ZooKeeperServer.DEFAULT_TICK_TIME) {
// Allow the ability to restart the ZooKeeperServer. Trying to re-start a closed
// sessionTracker (i.e. Thread) will throw IllegalThreadStateException. Nulling it out
// will force a new one to be created upon restart.
@Override public void shutdown() {
super.shutdown();
sessionTracker = null;
}
};
}
代码示例来源:origin: com.twitter.common/zookeeper-testing
@Override public void execute() {
shutdownNetwork();
}
});
代码示例来源:origin: com.twitter.common/zookeeper-testing
/**
* Returns a new authenticated zookeeper client connected to the in-process zookeeper server with
* the default session timeout and the custom chroot path.
*/
protected final ZooKeeperClient createZkClient(String chrootPath) {
return zkTestServer.createClient(chrootPath);
}
}
代码示例来源:origin: com.twitter.common/zookeeper-testing
/**
* Returns a new authenticated zookeeper client connected to the in-process zookeeper server with
* a custom {@code sessionTimeout}.
*/
protected final ZooKeeperClient createZkClient(Amount<Integer, Time> sessionTimeout,
Credentials credentials) {
return zkTestServer.createClient(sessionTimeout, credentials);
}
代码示例来源:origin: com.twitter.common/zookeeper-testing
/**
* Returns a new authenticated zookeeper client connected to the in-process zookeeper server with
* the default session timeout.
*/
protected final ZooKeeperClient createZkClient(Credentials credentials) {
return zkTestServer.createClient(credentials);
}
代码示例来源:origin: com.twitter.common/zookeeper-testing
/**
* Returns a new unauthenticated zookeeper client connected to the in-process zookeeper server
* with a custom {@code sessionTimeout}.
*/
protected final ZooKeeperClient createZkClient(Amount<Integer, Time> sessionTimeout) {
return zkTestServer.createClient(sessionTimeout);
}
代码示例来源:origin: com.twitter.common/zookeeper-testing
/**
* Returns a new unauthenticated zookeeper client connected to the in-process zookeeper server
* with the default session timeout.
*/
public final ZooKeeperClient createClient() {
return createClient(defaultSessionTimeout);
}
代码示例来源:origin: com.twitter.common/zookeeper-testing
/**
* Returns a new unauthenticated zookeeper client connected to the in-process zookeeper server
* with the default session timeout and a custom {@code chrootPath}.
*/
public final ZooKeeperClient createClient(String chrootPath) {
return createClient(defaultSessionTimeout, Credentials.NONE, Optional.of(chrootPath));
}
代码示例来源:origin: com.twitter.common/zookeeper-testing
/**
* Returns a new authenticated zookeeper client connected to the in-process zookeeper server with
* a custom {@code sessionTimeout}.
*/
public final ZooKeeperClient createClient(Amount<Integer, Time> sessionTimeout,
Credentials credentials) {
return createClient(sessionTimeout, credentials, Optional.<String>absent());
}
代码示例来源:origin: com.twitter.common/zookeeper-testing
/**
* Returns a new unauthenticated zookeeper client connected to the in-process zookeeper server
* with a custom {@code sessionTimeout}.
*/
public final ZooKeeperClient createClient(Amount<Integer, Time> sessionTimeout) {
return createClient(sessionTimeout, Credentials.NONE, Optional.<String>absent());
}
代码示例来源:origin: com.twitter.common/zookeeper-testing
/**
* Returns a new authenticated zookeeper client connected to the in-process zookeeper server with
* the default session timeout.
*/
public final ZooKeeperClient createClient(Credentials credentials) {
return createClient(defaultSessionTimeout, credentials, Optional.<String>absent());
}
本文整理了Java中com.salesforce.kafka.test.ZookeeperTestServer.start()方法的一些代码示例,展示了ZookeeperTestServer.star
本文整理了Java中com.salesforce.kafka.test.ZookeeperTestServer.stop()方法的一些代码示例,展示了ZookeeperTestServer.stop(
本文整理了Java中com.twitter.common.zookeeper.testing.ZooKeeperTestServer.()方法的一些代码示例,展示了ZooKeeperTestServe
本文整理了Java中com.twitter.common.zookeeper.testing.ZooKeeperTestServer.createClient()方法的一些代码示例,展示了ZooKee
本文整理了Java中com.twitter.common.zookeeper.testing.ZooKeeperTestServer.getPort()方法的一些代码示例,展示了ZooKeeperTe
本文整理了Java中com.twitter.common.zookeeper.testing.ZooKeeperTestServer.startNetwork()方法的一些代码示例,展示了ZooKee
我是一名优秀的程序员,十分优秀!