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());
}
}
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);
}
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();
}
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");
}
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);
}
}
}
Aggregations