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


Java ZooKeeperServer.getZKDatabase方法代碼示例

本文整理匯總了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));
    }
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:24,代碼來源:ClientBaseWithFixes.java

示例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));
    }
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:27,代碼來源:ClientBase.java

示例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()));
    }
}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:28,代碼來源:ClientBase.java

示例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;

}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:42,代碼來源:Commands.java


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