Search in sources :

Example 1 with OSMXBean

use of org.apache.zookeeper.server.util.OSMXBean in project zookeeper by apache.

the class MonitorCommand method commandRun.

@Override
public void commandRun() {
    if (!isZKServerRunning()) {
        pw.println(ZK_NOT_SERVING);
        return;
    }
    ZKDatabase zkdb = zkServer.getZKDatabase();
    ServerStats stats = zkServer.serverStats();
    print("version", Version.getFullVersion());
    print("avg_latency", stats.getAvgLatency());
    print("max_latency", stats.getMaxLatency());
    print("min_latency", stats.getMinLatency());
    print("packets_received", stats.getPacketsReceived());
    print("packets_sent", stats.getPacketsSent());
    print("num_alive_connections", stats.getNumAliveClientConnections());
    print("outstanding_requests", stats.getOutstandingRequests());
    print("server_state", stats.getServerState());
    print("znode_count", zkdb.getNodeCount());
    print("watch_count", zkdb.getDataTree().getWatchCount());
    print("ephemerals_count", zkdb.getDataTree().getEphemeralsCount());
    print("approximate_data_size", zkdb.getDataTree().approximateDataSize());
    OSMXBean osMbean = new OSMXBean();
    if (osMbean != null && osMbean.getUnix() == true) {
        print("open_file_descriptor_count", osMbean.getOpenFileDescriptorCount());
        print("max_file_descriptor_count", osMbean.getMaxFileDescriptorCount());
    }
    if (stats.getServerState().equals("leader")) {
        Leader leader = ((LeaderZooKeeperServer) zkServer).getLeader();
        print("followers", leader.getLearners().size());
        print("synced_followers", leader.getForwardingFollowers().size());
        print("pending_syncs", leader.getNumPendingSyncs());
    }
}
Also used : OSMXBean(org.apache.zookeeper.server.util.OSMXBean) Leader(org.apache.zookeeper.server.quorum.Leader) ServerStats(org.apache.zookeeper.server.ServerStats) ZKDatabase(org.apache.zookeeper.server.ZKDatabase) LeaderZooKeeperServer(org.apache.zookeeper.server.quorum.LeaderZooKeeperServer)

Example 2 with OSMXBean

use of org.apache.zookeeper.server.util.OSMXBean in project zookeeper by apache.

the class OSMXBeanTest method initialize.

@Before
public void initialize() {
    this.osMbean = new OSMXBean();
    Assert.assertNotNull("Could not initialize OSMXBean object!", osMbean);
}
Also used : OSMXBean(org.apache.zookeeper.server.util.OSMXBean) Before(org.junit.Before)

Example 3 with OSMXBean

use of org.apache.zookeeper.server.util.OSMXBean in project zookeeper by apache.

the class QuorumBase method tearDown.

@Override
public void tearDown() throws Exception {
    LOG.info("TearDown started");
    OSMXBean osMbean = new OSMXBean();
    if (osMbean.getUnix() == true) {
        LOG.info("fdcount after test is: " + osMbean.getOpenFileDescriptorCount());
    }
    shutdownServers();
    for (String hp : hostPort.split(",")) {
        Assert.assertTrue("waiting for server down", ClientBase.waitForServerDown(hp, ClientBase.CONNECTION_TIMEOUT));
        LOG.info(hp + " is no longer accepting client connections");
    }
    JMXEnv.tearDown();
}
Also used : OSMXBean(org.apache.zookeeper.server.util.OSMXBean)

Example 4 with OSMXBean

use of org.apache.zookeeper.server.util.OSMXBean in project zookeeper by apache.

the class ClientBase method setUp.

@Before
public void setUp() throws Exception {
    /* some useful information - log the number of fds used before
         * and after a test is run. Helps to verify we are freeing resources
         * correctly. Unfortunately this only works on unix systems (the
         * only place sun has implemented as part of the mgmt bean api.
         */
    OSMXBean osMbean = new OSMXBean();
    if (osMbean.getUnix() == true) {
        initialFdCount = osMbean.getOpenFileDescriptorCount();
        LOG.info("Initial fdcount is: " + initialFdCount);
    }
    setupTestEnv();
    JMXEnv.setUp();
    setUpAll();
    tmpDir = createTmpDir(BASETEST, true);
    startServer();
    LOG.info("Client test setup finished");
}
Also used : OSMXBean(org.apache.zookeeper.server.util.OSMXBean) Before(org.junit.Before)

Example 5 with OSMXBean

use of org.apache.zookeeper.server.util.OSMXBean in project zookeeper by apache.

the class ClientBase method tearDown.

@After
public void tearDown() throws Exception {
    LOG.info("tearDown starting");
    tearDownAll();
    stopServer();
    if (tmpDir != null) {
        Assert.assertTrue("delete " + tmpDir.toString(), recursiveDelete(tmpDir));
    }
    // This has to be set to null when the same instance of this class is reused between test cases
    serverFactory = null;
    JMXEnv.tearDown();
    /* some useful information - log the number of fds used before
         * and after a test is run. Helps to verify we are freeing resources
         * correctly. Unfortunately this only works on unix systems (the
         * only place sun has implemented as part of the mgmt bean api.
         */
    OSMXBean osMbean = new OSMXBean();
    if (osMbean.getUnix() == true) {
        long fdCount = osMbean.getOpenFileDescriptorCount();
        String message = "fdcount after test is: " + fdCount + " at start it was " + initialFdCount;
        LOG.info(message);
        if (fdCount > initialFdCount) {
            LOG.info("sleeping for 20 secs");
        //Thread.sleep(60000);
        //assertTrue(message, fdCount <= initialFdCount);
        }
    }
}
Also used : OSMXBean(org.apache.zookeeper.server.util.OSMXBean) After(org.junit.After)

Aggregations

OSMXBean (org.apache.zookeeper.server.util.OSMXBean)9 Before (org.junit.Before)2 Test (org.junit.Test)2 InetSocketAddress (java.net.InetSocketAddress)1 NIOServerCnxnFactory (org.apache.zookeeper.server.NIOServerCnxnFactory)1 ServerStats (org.apache.zookeeper.server.ServerStats)1 ZKDatabase (org.apache.zookeeper.server.ZKDatabase)1 Leader (org.apache.zookeeper.server.quorum.Leader)1 LeaderZooKeeperServer (org.apache.zookeeper.server.quorum.LeaderZooKeeperServer)1 After (org.junit.After)1