use of org.apache.zookeeper.server.NIOServerCnxnFactory in project zookeeper by apache.
the class NIOConnectionFactoryFdLeakTest method testFileDescriptorLeak.
@Test
public void testFileDescriptorLeak() throws Exception {
OSMXBean osMbean = new OSMXBean();
if (!osMbean.getUnix()) {
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.
assertTrue(((endFdCount - startFdCount) < 50), "Possible fd leakage");
}
use of org.apache.zookeeper.server.NIOServerCnxnFactory in project apex-malhar by apache.
the class HBaseTestHelper method startZooKeeperServer.
private static void startZooKeeperServer() throws IOException, InterruptedException {
String zooLocation = System.getProperty("java.io.tmpdir");
File zooFile = new File(zooLocation, "zookeeper-malhartest");
ZooKeeperServer zooKeeper = new ZooKeeperServer(zooFile, zooFile, 2000);
NIOServerCnxnFactory serverFactory = new NIOServerCnxnFactory();
serverFactory.configure(new InetSocketAddress(2181), 10);
serverFactory.startup(zooKeeper);
}
use of org.apache.zookeeper.server.NIOServerCnxnFactory in project parseq by linkedin.
the class ZKServer method restart.
public void restart() throws IOException, InterruptedException {
shutdown(false);
_zk = new ZooKeeperServer(_dataDir, _logDir, 5000);
_factory = new NIOServerCnxnFactory();
_factory.configure(new InetSocketAddress(_port), 60);
startup();
}
use of org.apache.zookeeper.server.NIOServerCnxnFactory in project incubator-pulsar by apache.
the class ZookeeperServerTest method start.
public void start() throws IOException {
try {
zks = new ZooKeeperServer(zkTmpDir, zkTmpDir, ZooKeeperServer.DEFAULT_TICK_TIME);
zks.setMaxSessionTimeout(20000);
serverFactory = new NIOServerCnxnFactory();
serverFactory.configure(new InetSocketAddress(zkPort), 1000);
serverFactory.startup(zks);
} catch (Exception e) {
log.error("Exception while instantiating ZooKeeper", e);
}
LocalBookkeeperEnsemble.waitForServerUp(hostPort, 30000);
log.info("ZooKeeper started at {}", hostPort);
}
use of org.apache.zookeeper.server.NIOServerCnxnFactory in project incubator-pulsar by apache.
the class LocalBookkeeperEnsemble method runZookeeper.
/**
* @param args
*/
private void runZookeeper(int maxCC) throws IOException {
// create a ZooKeeper server(dataDir, dataLogDir, port)
LOG.info("Starting ZK server");
// ServerStats.registerAsConcrete();
// ClientBase.setupTestEnv();
File zkDataDir = isNotBlank(zkDataDirName) ? Files.createDirectories(Paths.get(zkDataDirName)).toFile() : Files.createTempDirectory("zktest").toFile();
if (this.clearOldData) {
cleanDirectory(zkDataDir);
}
try {
zks = new ZooKeeperServer(zkDataDir, zkDataDir, ZooKeeperServer.DEFAULT_TICK_TIME);
serverFactory = new NIOServerCnxnFactory();
serverFactory.configure(new InetSocketAddress(ZooKeeperDefaultPort), maxCC);
serverFactory.startup(zks);
} catch (Exception e) {
// TODO Auto-generated catch block
LOG.error("Exception while instantiating ZooKeeper", e);
}
boolean b = waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT);
LOG.info("ZooKeeper server up: {}", b);
LOG.debug("Local ZK started (port: {}, data_directory: {})", ZooKeeperDefaultPort, zkDataDir.getAbsolutePath());
}
Aggregations