本文整理匯總了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;
}