_factory.configure(new InetSocketAddress(_port), maxClientCnxns); LOG.debug("Zookeeper server successfully binded at port " + _port); break;
@Before public void setUp() throws IOException { listenAddress = new InetSocketAddress(PortAssignment.unique()); factory = new NIOServerCnxnFactory(); factory.configure(listenAddress, 100); }
try { standaloneServerFactory = new NIOServerCnxnFactory(); standaloneServerFactory.configure( new InetSocketAddress(currentClientPort), configuration.getInt(HConstants.ZOOKEEPER_MAX_CLIENT_CNXNS,
public void startServer() throws Exception { // create a ZooKeeper server(dataDir, dataLogDir, port) LOG.debug("Running ZK server"); // ServerStats.registerAsConcrete(); ClientBase.setupTestEnv(); ZkTmpDir = File.createTempFile("zookeeper", "test"); ZkTmpDir.delete(); ZkTmpDir.mkdir(); zks = new ZooKeeperServer(ZkTmpDir, ZkTmpDir, ZooKeeperServer.DEFAULT_TICK_TIME); serverFactory = new NIOServerCnxnFactory(); serverFactory.configure(zkaddr, 100); serverFactory.startup(zks); boolean b = ClientBase.waitForServerUp(getZooKeeperConnectString(), ClientBase.CONNECTION_TIMEOUT); LOG.debug("Server up: " + b); // create a zookeeper client LOG.debug("Instantiate ZK Client"); zkc = ZooKeeperClient.newBuilder().connectString(getZooKeeperConnectString()).build(); // initialize the zk client with values zkc.create("/ledgers", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); zkc.create("/ledgers/available", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); }
@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)); } }
try { standaloneServerFactory = new NIOServerCnxnFactory(); standaloneServerFactory.configure(new InetSocketAddress(currentClientPort), configuration.getInt(HConstants.ZOOKEEPER_MAX_CLIENT_CNXNS, HConstants.DEFAULT_ZOOKEPER_MAX_CLIENT_CNXNS)); } catch (BindException e) {
EmbeddedZooKeeper() throws IOException, InterruptedException { this.tmpDir = Files.createTempDirectory(null).toFile(); this.factory = new NIOServerCnxnFactory(); this.zookeeper = new ZooKeeperServer(new File(tmpDir, "data"), new File(tmpDir, "log"), TICK_TIME); InetSocketAddress addr = new InetSocketAddress("127.0.0.1", 0); factory.configure(addr, 0); factory.startup(zookeeper); this.port = zookeeper.getClientPort(); }
public EmbeddedZkServer(int port) throws Exception { snapshotDir = Files.createTempDirectory("zookeeper-snapshot-"); logDir = Files.createTempDirectory("zookeeper-log-"); int tickTime = 500; zookeeper = new ZooKeeperServer(snapshotDir.toFile(), logDir.toFile(), tickTime); factory = new NIOServerCnxnFactory(); InetSocketAddress addr = new InetSocketAddress(InetAddress.getLocalHost().getHostAddress(), port); LOGGER.info("Starting Zookeeper at " + addr); factory.configure(addr, 0); factory.startup(zookeeper); }
public EmbeddedZookeeper(int port) throws Exception { this.port = port; zookeeper = new ZooKeeperServer(snapshotDir, logDir, tickTime); addr = new InetSocketAddress("127.0.0.1", port); factory.configure(addr, 0); factory.startup(zookeeper); }
@Override public void initialize(File snapDir, File logDir, int zkPort, int maxCC) throws IOException { zks = new ZooKeeperServer(snapDir, logDir, ZooKeeperServer.DEFAULT_TICK_TIME); serverFactory = new NIOServerCnxnFactory(); serverFactory.configure(new InetSocketAddress(zkPort), maxCC); }
private void start(InetSocketAddress addr) throws IOException, InterruptedException { factory = new NIOServerCnxnFactory(); factory.configure(addr, 20); factory.startup(zk); }
public void run() throws Exception { File dir = new File(dataDirectory, "zookeeper").getAbsoluteFile(); NIOServerCnxnFactory factory = new NIOServerCnxnFactory(); ZooKeeperServer server = new ZooKeeperServer(dir, dir, tickTime); factory.setZooKeeperServer(server); factory.setMaxClientCnxnsPerHost(numConnections); factory.configure(new InetSocketAddress(clientPort), numConnections); factory.startup(server); }
public EmbeddedZookeeperInternal(int port) throws IOException, InterruptedException { this.port = port; logDir = TestUtils.tempDir(); snapshotDir = TestUtils.tempDir(); zooKeeperServer = new ZooKeeperServer(snapshotDir, logDir, 500); nioServerCnxnFactory = new NIOServerCnxnFactory(); InetSocketAddress inetSocketAddress = new InetSocketAddress("127.0.0.1", port); nioServerCnxnFactory.configure(inetSocketAddress, 0); nioServerCnxnFactory.startup(zooKeeperServer); }
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); }
private void startSingleZkServer(final int tickTime, final File dataDir, final File dataLogDir, final int port) { try { _zk = new ZooKeeperServer(dataDir, dataLogDir, tickTime); _zk.setMinSessionTimeout(_minSessionTimeout); _nioFactory = new NIOServerCnxnFactory(); int maxClientConnections = 0; // 0 means unlimited _nioFactory.configure(new InetSocketAddress(port), maxClientConnections); _nioFactory.startup(_zk); } catch (IOException e) { throw new ZkException("Unable to start single ZooKeeper server.", e); } catch (InterruptedException e) { throw new ZkInterruptedException(e); } }
public EmbeddedZookeeper(int port) throws IOException { zkDataDir = Files.createTempDir(); zkServer = new ZooKeeperServer(); FileTxnSnapLog ftxn = new FileTxnSnapLog(zkDataDir, zkDataDir); zkServer.setTxnLogFactory(ftxn); cnxnFactory = new NIOServerCnxnFactory(); cnxnFactory.configure(new InetSocketAddress(port), 0); }
@Before public void setUp() throws Exception { zkDir = Files.createTempDir().getAbsoluteFile(); zkPort = Utils.getFreePorts(1)[0]; ZooKeeperServer zkServer = new ZooKeeperServer(zkDir, zkDir, 2000); standaloneServerFactory = new NIOServerCnxnFactory(); standaloneServerFactory.configure(new InetSocketAddress(zkPort.value), 5000); standaloneServerFactory.startup(zkServer); }
public void afterPropertiesSet() throws Exception { if( purge ) { deleteFilesInDir(getDataLogDir()); deleteFilesInDir(getDataDir()); } FileTxnSnapLog ftxn = new FileTxnSnapLog(getDataLogDir(), getDataDir()); zooKeeperServer.setTxnLogFactory(ftxn); zooKeeperServer.setTickTime(getTickTime()); zooKeeperServer.setMinSessionTimeout(getMinSessionTimeout()); zooKeeperServer.setMaxSessionTimeout(getMaxSessionTimeout()); connectionFactory = new NIOServerCnxnFactory(); connectionFactory.configure(getClientPortAddress(), getMaxClientConnections()); connectionFactory.startup(zooKeeperServer); }
public void afterPropertiesSet() throws Exception { if( purge ) { deleteFilesInDir(getDataLogDir()); deleteFilesInDir(getDataDir()); } FileTxnSnapLog ftxn = new FileTxnSnapLog(getDataLogDir(), getDataDir()); zooKeeperServer.setTxnLogFactory(ftxn); zooKeeperServer.setTickTime(getTickTime()); zooKeeperServer.setMinSessionTimeout(getMinSessionTimeout()); zooKeeperServer.setMaxSessionTimeout(getMaxSessionTimeout()); connectionFactory = new NIOServerCnxnFactory(); connectionFactory.configure(getClientPortAddress(), getMaxClientConnections()); connectionFactory.startup(zooKeeperServer); }
public void afterPropertiesSet() throws Exception { if( purge ) { deleteFilesInDir(getDataLogDir()); deleteFilesInDir(getDataDir()); } FileTxnSnapLog ftxn = new FileTxnSnapLog(getDataLogDir(), getDataDir()); zooKeeperServer.setTxnLogFactory(ftxn); zooKeeperServer.setTickTime(getTickTime()); zooKeeperServer.setMinSessionTimeout(getMinSessionTimeout()); zooKeeperServer.setMaxSessionTimeout(getMaxSessionTimeout()); connectionFactory = new NIOServerCnxnFactory(); connectionFactory.configure(getClientPortAddress(), getMaxClientConnections()); connectionFactory.startup(zooKeeperServer); }