@Before public void initialize() { this.osMbean = new OSMXBean(); Assert.assertNotNull("Could not initialize OSMXBean object!", osMbean); }
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()); } shutdownAll(); JMXEnv.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(); } public void shutdownServers() {
OSMXBean osMbean = new OSMXBean(); if (osMbean.getUnix() == false) { LOG.warn("skipping testClientCleanup, only available on Unix");
@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); } } }
protected void setUpWithServerId(int serverId) 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(serverId); LOG.info("Client test setup finished"); }
@Test public void testFileDescriptorLeak() throws Exception { OSMXBean osMbean = new OSMXBean(); if (osMbean.getUnix() != true) { LOG.info("Unable to run test on non-unix system"); return; } long startFdCount = osMbean.getOpenFileDescriptorCount(); LOG.info("Start fdcount is: " + startFdCount); for (int i = 0; i < 50; ++i) { NIOServerCnxnFactory factory = new NIOServerCnxnFactory(); factory.configure( new InetSocketAddress( "127.0.0.1", PortAssignment.unique()), 10); factory.start(); Thread.sleep(100); factory.shutdown(); } long endFdCount = osMbean.getOpenFileDescriptorCount(); LOG.info("End fdcount is: " + endFdCount); // On my box, if selector.close() is not called fd diff is > 700. Assert.assertTrue("Possible fd leakage", ((endFdCount - startFdCount) < 50)); } }
print("approximate_data_size", zkdb.getDataTree().cachedApproximateDataSize()); OSMXBean osMbean = new OSMXBean(); if (osMbean != null && osMbean.getUnix() == true) { print("open_file_descriptor_count", osMbean.getOpenFileDescriptorCount());
OSMXBean osMbean = new OSMXBean(); if (osMbean.getUnix() == true) { LOG.info("Initial fdcount is: "
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("approximate_data_size", zkdb.getDataTree().approximateDataSize()); OSMXBean osMbean = new OSMXBean(); if (osMbean != null && osMbean.getUnix() == true) { print("open_file_descriptor_count", osMbean.getOpenFileDescriptorCount());
zkServer.getSessionTracker().getLocalSessionCount()); OSMXBean osMbean = new OSMXBean(); response.put("open_file_descriptor_count", osMbean.getOpenFileDescriptorCount()); response.put("max_file_descriptor_count", osMbean.getMaxFileDescriptorCount());