本文整理汇总了Java中org.apache.zookeeper.server.ZooKeeperServer.getZKDatabase方法的典型用法代码示例。如果您正苦于以下问题:Java ZooKeeperServer.getZKDatabase方法的具体用法?Java ZooKeeperServer.getZKDatabase怎么用?Java ZooKeeperServer.getZKDatabase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.zookeeper.server.ZooKeeperServer
的用法示例。
在下文中一共展示了ZooKeeperServer.getZKDatabase方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shutdownServerInstance
import org.apache.zookeeper.server.ZooKeeperServer; //导入方法依赖的package包/类
static void shutdownServerInstance(ServerCnxnFactory factory,
String hostPort)
{
if (factory != null) {
ZKDatabase zkDb;
{
ZooKeeperServer zs = getServer(factory);
zkDb = zs.getZKDatabase();
}
factory.shutdown();
try {
zkDb.close();
} catch (IOException ie) {
LOG.warn("Error closing logs ", ie);
}
final int PORT = getPort(hostPort);
Assert.assertTrue("waiting for server down",
ClientBaseWithFixes.waitForServerDown("127.0.0.1:" + PORT,
CONNECTION_TIMEOUT));
}
}
示例2: shutdownServerInstance
import org.apache.zookeeper.server.ZooKeeperServer; //导入方法依赖的package包/类
static void shutdownServerInstance(ServerCnxnFactory factory,
String hostPort)
{
if (factory != null) {
ZKDatabase zkDb = null;
{
ZooKeeperServer zs = getServer(factory);
if (zs != null) {
zkDb = zs.getZKDatabase();
}
}
factory.shutdown();
try {
if (zkDb != null) {
zkDb.close();
}
} catch (IOException ie) {
LOG.warn("Error closing logs ", ie);
}
final int PORT = getPort(hostPort);
Assert.assertTrue("waiting for server down",
ClientBase.waitForServerDown("127.0.0.1:" + PORT,
CONNECTION_TIMEOUT));
}
}
示例3: getKey
import org.apache.zookeeper.server.ZooKeeperServer; //导入方法依赖的package包/类
private byte[] getKey(ZooKeeperServer zks) {
ZKDatabase db = zks.getZKDatabase();
if (db != null) {
try {
Stat stat = new Stat();
return db.getData("/key", stat, null);
} catch (NoNodeException e) {
LOG.error("getData failed", e);
}
}
return null;
}
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:13,代码来源:KeyAuthenticationProvider.java
示例4: shutdownServerInstance
import org.apache.zookeeper.server.ZooKeeperServer; //导入方法依赖的package包/类
static void shutdownServerInstance(ServerCnxnFactory factory,
String hostPort)
{
if (factory != null) {
ZKDatabase zkDb = null;
{
ZooKeeperServer zs = getServer(factory);
if (zs != null) {
zkDb = zs.getZKDatabase();
}
}
factory.shutdown();
try {
if (zkDb != null) {
zkDb.close();
}
} catch (IOException ie) {
LOG.warn("Error closing logs ", ie);
}
final int PORT = getPort(hostPort);
Assert.assertTrue("waiting for server down",
ClientBase.waitForServerDown("127.0.0.1:" + PORT,
CONNECTION_TIMEOUT,
factory.isSecure()));
}
}
示例5: run
import org.apache.zookeeper.server.ZooKeeperServer; //导入方法依赖的package包/类
@Override
public CommandResponse run(ZooKeeperServer zkServer, Map<String, String> kwargs) {
ZKDatabase zkdb = zkServer.getZKDatabase();
ServerStats stats = zkServer.serverStats();
CommandResponse response = initializeResponse();
response.put("version", Version.getFullVersion());
response.put("avg_latency", stats.getAvgLatency());
response.put("max_latency", stats.getMaxLatency());
response.put("min_latency", stats.getMinLatency());
response.put("packets_received", stats.getPacketsReceived());
response.put("packets_sent", stats.getPacketsSent());
response.put("num_alive_connections", stats.getNumAliveClientConnections());
response.put("outstanding_requests", stats.getOutstandingRequests());
response.put("server_state", stats.getServerState());
response.put("znode_count", zkdb.getNodeCount());
response.put("watch_count", zkdb.getDataTree().getWatchCount());
response.put("ephemerals_count", zkdb.getDataTree().getEphemeralsCount());
response.put("approximate_data_size", zkdb.getDataTree().approximateDataSize());
OSMXBean osMbean = new OSMXBean();
response.put("open_file_descriptor_count", osMbean.getOpenFileDescriptorCount());
response.put("max_file_descriptor_count", osMbean.getMaxFileDescriptorCount());
if (zkServer instanceof LeaderZooKeeperServer) {
Leader leader = ((LeaderZooKeeperServer) zkServer).getLeader();
response.put("followers", leader.getLearners().size());
response.put("synced_followers", leader.getForwardingFollowers().size());
response.put("pending_syncs", leader.getNumPendingSyncs());
}
return response;
}