Java Code Examples for org.apache.zookeeper.server.NIOServerCnxnFactory#shutdown()
The following examples show how to use
org.apache.zookeeper.server.NIOServerCnxnFactory#shutdown() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MiniZooKeeperCluster.java From dremio-oss with Apache License 2.0 | 6 votes |
/** * @throws IOException */ public void shutdown() throws IOException { if (!started) { return; } // shut down all the zk servers for (int i = 0; i < standaloneServerFactoryList.size(); i++) { NIOServerCnxnFactory standaloneServerFactory = standaloneServerFactoryList.get(i); int clientPort = clientPortList.get(i); standaloneServerFactory.shutdown(); if (!waitForServerDown(clientPort, CONNECTION_TIMEOUT)) { throw new IOException("Waiting for shutdown of standalone server"); } } // clear everything started = false; activeZKServerIndex = 0; standaloneServerFactoryList.clear(); clientPortList.clear(); zooKeeperServers.clear(); logger.info("Shutdown MiniZK cluster with all ZK servers"); }
Example 2
Source File: MiniZooKeeperCluster.java From dremio-oss with Apache License 2.0 | 6 votes |
/** * Kill one back up ZK servers * * @throws IOException * @throws InterruptedException */ public void killOneBackupZooKeeperServer() throws IOException, InterruptedException { if (!started || activeZKServerIndex < 0 || standaloneServerFactoryList.size() <= 1) { return; } int backupZKServerIndex = activeZKServerIndex + 1; // Shutdown the current active one NIOServerCnxnFactory standaloneServerFactory = standaloneServerFactoryList.get(backupZKServerIndex); int clientPort = clientPortList.get(backupZKServerIndex); standaloneServerFactory.shutdown(); if (!waitForServerDown(clientPort, CONNECTION_TIMEOUT)) { throw new IOException("Waiting for shutdown of standalone server"); } // remove this backup zk server standaloneServerFactoryList.remove(backupZKServerIndex); clientPortList.remove(backupZKServerIndex); zooKeeperServers.remove(backupZKServerIndex); logger.info("Kill one backup ZK servers in the cluster " + "on client port: " + clientPort); }
Example 3
Source File: MiniZooKeeperCluster.java From hbase with Apache License 2.0 | 6 votes |
/** * Kill one back up ZK servers. * * @throws IOException if waiting for the shutdown of a server fails */ public void killOneBackupZooKeeperServer() throws IOException, InterruptedException { if (!started || activeZKServerIndex < 0 || standaloneServerFactoryList.size() <= 1) { return ; } int backupZKServerIndex = activeZKServerIndex+1; // Shutdown the current active one NIOServerCnxnFactory standaloneServerFactory = standaloneServerFactoryList.get(backupZKServerIndex); int clientPort = clientPortList.get(backupZKServerIndex); standaloneServerFactory.shutdown(); if (!waitForServerDown(clientPort, connectionTimeout)) { throw new IOException("Waiting for shutdown of standalone server"); } zooKeeperServers.get(backupZKServerIndex).getZKDatabase().close(); // remove this backup zk server standaloneServerFactoryList.remove(backupZKServerIndex); clientPortList.remove(backupZKServerIndex); zooKeeperServers.remove(backupZKServerIndex); LOG.info("Kill one backup ZK servers in the cluster on client port: {}", clientPort); }
Example 4
Source File: MiniZooKeeperCluster.java From dremio-oss with Apache License 2.0 | 5 votes |
/** * @return clientPort return clientPort if there is another ZK backup can run * when killing the current active; return -1, if there is no backups. * @throws IOException * @throws InterruptedException */ public int killCurrentActiveZooKeeperServer() throws IOException, InterruptedException { if (!started || activeZKServerIndex < 0) { return -1; } // Shutdown the current active one NIOServerCnxnFactory standaloneServerFactory = standaloneServerFactoryList.get(activeZKServerIndex); int clientPort = clientPortList.get(activeZKServerIndex); standaloneServerFactory.shutdown(); if (!waitForServerDown(clientPort, CONNECTION_TIMEOUT)) { throw new IOException("Waiting for shutdown of standalone server"); } // remove the current active zk server standaloneServerFactoryList.remove(activeZKServerIndex); clientPortList.remove(activeZKServerIndex); zooKeeperServers.remove(activeZKServerIndex); logger.info("Kill the current active ZK servers in the cluster " + "on client port: " + clientPort); if (standaloneServerFactoryList.size() == 0) { // there is no backup servers; return -1; } clientPort = clientPortList.get(activeZKServerIndex); logger.info("Activate a backup zk server in the cluster " + "on client port: " + clientPort); // return the next back zk server's port return clientPort; }
Example 5
Source File: LocalBookkeeperEnsemble.java From pulsar with Apache License 2.0 | 5 votes |
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 { // Allow all commands on ZK control port System.setProperty("zookeeper.4lw.commands.whitelist", "*"); zks = new ZooKeeperServer(zkDataDir, zkDataDir, ZooKeeperServer.DEFAULT_TICK_TIME); serverFactory = new NIOServerCnxnFactory(); serverFactory.configure(new InetSocketAddress(zkPort), maxCC); serverFactory.startup(zks); } catch (Exception e) { LOG.error("Exception while instantiating ZooKeeper", e); if (serverFactory != null) { serverFactory.shutdown(); } throw new IOException(e); } this.zkPort = serverFactory.getLocalPort(); this.HOSTPORT = "127.0.0.1:" + zkPort; boolean b = waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT); LOG.info("ZooKeeper server up: {}", b); LOG.debug("Local ZK started (port: {}, data_directory: {})", zkPort, zkDataDir.getAbsolutePath()); }
Example 6
Source File: MiniZooKeeperCluster.java From hbase-tools with Apache License 2.0 | 5 votes |
/** * @throws IOException */ public void shutdown() throws IOException { // shut down all the zk servers for (int i = 0; i < standaloneServerFactoryList.size(); i++) { NIOServerCnxnFactory standaloneServerFactory = standaloneServerFactoryList.get(i); int clientPort = clientPortList.get(i); standaloneServerFactory.shutdown(); if (!waitForServerDown(clientPort, CONNECTION_TIMEOUT)) { throw new IOException("Waiting for shutdown of standalone server"); } } standaloneServerFactoryList.clear(); for (ZooKeeperServer zkServer: zooKeeperServers) { //explicitly close ZKDatabase since ZookeeperServer does not close them zkServer.getZKDatabase().close(); } zooKeeperServers.clear(); // clear everything if (started) { started = false; activeZKServerIndex = 0; clientPortList.clear(); LOG.info("Shutdown MiniZK cluster with all ZK servers"); } }
Example 7
Source File: MiniZooKeeperCluster.java From hbase-tools with Apache License 2.0 | 5 votes |
/**@return clientPort return clientPort if there is another ZK backup can run * when killing the current active; return -1, if there is no backups. * @throws IOException * @throws InterruptedException */ public int killCurrentActiveZooKeeperServer() throws IOException, InterruptedException { if (!started || activeZKServerIndex < 0) { return -1; } // Shutdown the current active one NIOServerCnxnFactory standaloneServerFactory = standaloneServerFactoryList.get(activeZKServerIndex); int clientPort = clientPortList.get(activeZKServerIndex); standaloneServerFactory.shutdown(); if (!waitForServerDown(clientPort, CONNECTION_TIMEOUT)) { throw new IOException("Waiting for shutdown of standalone server"); } zooKeeperServers.get(activeZKServerIndex).getZKDatabase().close(); // remove the current active zk server standaloneServerFactoryList.remove(activeZKServerIndex); clientPortList.remove(activeZKServerIndex); zooKeeperServers.remove(activeZKServerIndex); LOG.info("Kill the current active ZK servers in the cluster " + "on client port: " + clientPort); if (standaloneServerFactoryList.size() == 0) { // there is no backup servers; return -1; } clientPort = clientPortList.get(activeZKServerIndex); LOG.info("Activate a backup zk server in the cluster " + "on client port: " + clientPort); // return the next back zk server's port return clientPort; }
Example 8
Source File: MiniZooKeeperCluster.java From hbase-tools with Apache License 2.0 | 5 votes |
/** * Kill one back up ZK servers * @throws IOException * @throws InterruptedException */ public void killOneBackupZooKeeperServer() throws IOException, InterruptedException { if (!started || activeZKServerIndex < 0 || standaloneServerFactoryList.size() <= 1) { return ; } int backupZKServerIndex = activeZKServerIndex+1; // Shutdown the current active one NIOServerCnxnFactory standaloneServerFactory = standaloneServerFactoryList.get(backupZKServerIndex); int clientPort = clientPortList.get(backupZKServerIndex); standaloneServerFactory.shutdown(); if (!waitForServerDown(clientPort, CONNECTION_TIMEOUT)) { throw new IOException("Waiting for shutdown of standalone server"); } zooKeeperServers.get(backupZKServerIndex).getZKDatabase().close(); // remove this backup zk server standaloneServerFactoryList.remove(backupZKServerIndex); clientPortList.remove(backupZKServerIndex); zooKeeperServers.remove(backupZKServerIndex); LOG.info("Kill one backup ZK servers in the cluster " + "on client port: " + clientPort); }
Example 9
Source File: MiniZooKeeperCluster.java From hbase-tools with Apache License 2.0 | 5 votes |
/** * @throws IOException */ public void shutdown() throws IOException { if (!started) { return; } // shut down all the zk servers for (int i = 0; i < standaloneServerFactoryList.size(); i++) { NIOServerCnxnFactory standaloneServerFactory = standaloneServerFactoryList.get(i); int clientPort = clientPortList.get(i); standaloneServerFactory.shutdown(); if (!waitForServerDown(clientPort, CONNECTION_TIMEOUT)) { throw new IOException("Waiting for shutdown of standalone server"); } } for (ZooKeeperServer zkServer: zooKeeperServers) { //explicitly close ZKDatabase since ZookeeperServer does not close them zkServer.getZKDatabase().close(); } // clear everything started = false; activeZKServerIndex = 0; standaloneServerFactoryList.clear(); clientPortList.clear(); zooKeeperServers.clear(); LOG.info("Shutdown MiniZK cluster with all ZK servers"); }
Example 10
Source File: MiniZooKeeperCluster.java From hbase-tools with Apache License 2.0 | 5 votes |
/**@return clientPort return clientPort if there is another ZK backup can run * when killing the current active; return -1, if there is no backups. * @throws IOException * @throws InterruptedException */ public int killCurrentActiveZooKeeperServer() throws IOException, InterruptedException { if (!started || activeZKServerIndex < 0 ) { return -1; } // Shutdown the current active one NIOServerCnxnFactory standaloneServerFactory = standaloneServerFactoryList.get(activeZKServerIndex); int clientPort = clientPortList.get(activeZKServerIndex); standaloneServerFactory.shutdown(); if (!waitForServerDown(clientPort, CONNECTION_TIMEOUT)) { throw new IOException("Waiting for shutdown of standalone server"); } zooKeeperServers.get(activeZKServerIndex).getZKDatabase().close(); // remove the current active zk server standaloneServerFactoryList.remove(activeZKServerIndex); clientPortList.remove(activeZKServerIndex); zooKeeperServers.remove(activeZKServerIndex); LOG.info("Kill the current active ZK servers in the cluster " + "on client port: " + clientPort); if (standaloneServerFactoryList.size() == 0) { // there is no backup servers; return -1; } clientPort = clientPortList.get(activeZKServerIndex); LOG.info("Activate a backup zk server in the cluster " + "on client port: " + clientPort); // return the next back zk server's port return clientPort; }
Example 11
Source File: MiniZooKeeperCluster.java From hbase-tools with Apache License 2.0 | 5 votes |
/** * Kill one back up ZK servers * @throws IOException * @throws InterruptedException */ public void killOneBackupZooKeeperServer() throws IOException, InterruptedException { if (!started || activeZKServerIndex < 0 || standaloneServerFactoryList.size() <= 1) { return ; } int backupZKServerIndex = activeZKServerIndex+1; // Shutdown the current active one NIOServerCnxnFactory standaloneServerFactory = standaloneServerFactoryList.get(backupZKServerIndex); int clientPort = clientPortList.get(backupZKServerIndex); standaloneServerFactory.shutdown(); if (!waitForServerDown(clientPort, CONNECTION_TIMEOUT)) { throw new IOException("Waiting for shutdown of standalone server"); } zooKeeperServers.get(backupZKServerIndex).getZKDatabase().close(); // remove this backup zk server standaloneServerFactoryList.remove(backupZKServerIndex); clientPortList.remove(backupZKServerIndex); zooKeeperServers.remove(backupZKServerIndex); LOG.info("Kill one backup ZK servers in the cluster " + "on client port: " + clientPort); }
Example 12
Source File: MiniZooKeeperCluster.java From hbase-tools with Apache License 2.0 | 5 votes |
/** * @throws IOException */ public void shutdown() throws IOException { if (!started) { return; } // shut down all the zk servers for (int i = 0; i < standaloneServerFactoryList.size(); i++) { NIOServerCnxnFactory standaloneServerFactory = standaloneServerFactoryList.get(i); int clientPort = clientPortList.get(i); standaloneServerFactory.shutdown(); if (!waitForServerDown(clientPort, CONNECTION_TIMEOUT)) { throw new IOException("Waiting for shutdown of standalone server"); } } for (ZooKeeperServer zkServer: zooKeeperServers) { //explicitly close ZKDatabase since ZookeeperServer does not close them zkServer.getZKDatabase().close(); } // clear everything started = false; activeZKServerIndex = 0; standaloneServerFactoryList.clear(); clientPortList.clear(); zooKeeperServers.clear(); LOG.info("Shutdown MiniZK cluster with all ZK servers"); }
Example 13
Source File: MiniZooKeeperCluster.java From hbase-tools with Apache License 2.0 | 5 votes |
/**@return clientPort return clientPort if there is another ZK backup can run * when killing the current active; return -1, if there is no backups. * @throws IOException * @throws InterruptedException */ public int killCurrentActiveZooKeeperServer() throws IOException, InterruptedException { if (!started || activeZKServerIndex < 0 ) { return -1; } // Shutdown the current active one NIOServerCnxnFactory standaloneServerFactory = standaloneServerFactoryList.get(activeZKServerIndex); int clientPort = clientPortList.get(activeZKServerIndex); standaloneServerFactory.shutdown(); if (!waitForServerDown(clientPort, CONNECTION_TIMEOUT)) { throw new IOException("Waiting for shutdown of standalone server"); } zooKeeperServers.get(activeZKServerIndex).getZKDatabase().close(); // remove the current active zk server standaloneServerFactoryList.remove(activeZKServerIndex); clientPortList.remove(activeZKServerIndex); zooKeeperServers.remove(activeZKServerIndex); LOG.info("Kill the current active ZK servers in the cluster " + "on client port: " + clientPort); if (standaloneServerFactoryList.size() == 0) { // there is no backup servers; return -1; } clientPort = clientPortList.get(activeZKServerIndex); LOG.info("Activate a backup zk server in the cluster " + "on client port: " + clientPort); // return the next back zk server's port return clientPort; }
Example 14
Source File: MiniZooKeeperCluster.java From hbase-tools with Apache License 2.0 | 5 votes |
/** * Kill one back up ZK servers * @throws IOException * @throws InterruptedException */ public void killOneBackupZooKeeperServer() throws IOException, InterruptedException { if (!started || activeZKServerIndex < 0 || standaloneServerFactoryList.size() <= 1) { return ; } int backupZKServerIndex = activeZKServerIndex+1; // Shutdown the current active one NIOServerCnxnFactory standaloneServerFactory = standaloneServerFactoryList.get(backupZKServerIndex); int clientPort = clientPortList.get(backupZKServerIndex); standaloneServerFactory.shutdown(); if (!waitForServerDown(clientPort, CONNECTION_TIMEOUT)) { throw new IOException("Waiting for shutdown of standalone server"); } zooKeeperServers.get(backupZKServerIndex).getZKDatabase().close(); // remove this backup zk server standaloneServerFactoryList.remove(backupZKServerIndex); clientPortList.remove(backupZKServerIndex); zooKeeperServers.remove(backupZKServerIndex); LOG.info("Kill one backup ZK servers in the cluster " + "on client port: " + clientPort); }
Example 15
Source File: MiniZooKeeperCluster.java From hbase with Apache License 2.0 | 5 votes |
/** * @throws IOException if waiting for the shutdown of a server fails */ public void shutdown() throws IOException { // shut down all the zk servers for (int i = 0; i < standaloneServerFactoryList.size(); i++) { NIOServerCnxnFactory standaloneServerFactory = standaloneServerFactoryList.get(i); int clientPort = clientPortList.get(i); standaloneServerFactory.shutdown(); if (!waitForServerDown(clientPort, connectionTimeout)) { throw new IOException("Waiting for shutdown of standalone server at port=" + clientPort + ", timeout=" + this.connectionTimeout); } } standaloneServerFactoryList.clear(); for (ZooKeeperServer zkServer: zooKeeperServers) { // Explicitly close ZKDatabase since ZookeeperServer does not close them zkServer.getZKDatabase().close(); } zooKeeperServers.clear(); // clear everything if (started) { started = false; activeZKServerIndex = 0; clientPortList.clear(); LOG.info("Shutdown MiniZK cluster with all ZK servers"); } }
Example 16
Source File: MiniZooKeeperCluster.java From hbase with Apache License 2.0 | 5 votes |
/** * @return clientPort return clientPort if there is another ZK backup can run * when killing the current active; return -1, if there is no backups. * @throws IOException if waiting for the shutdown of a server fails */ public int killCurrentActiveZooKeeperServer() throws IOException, InterruptedException { if (!started || activeZKServerIndex < 0) { return -1; } // Shutdown the current active one NIOServerCnxnFactory standaloneServerFactory = standaloneServerFactoryList.get(activeZKServerIndex); int clientPort = clientPortList.get(activeZKServerIndex); standaloneServerFactory.shutdown(); if (!waitForServerDown(clientPort, connectionTimeout)) { throw new IOException("Waiting for shutdown of standalone server"); } zooKeeperServers.get(activeZKServerIndex).getZKDatabase().close(); // remove the current active zk server standaloneServerFactoryList.remove(activeZKServerIndex); clientPortList.remove(activeZKServerIndex); zooKeeperServers.remove(activeZKServerIndex); LOG.info("Kill the current active ZK servers in the cluster on client port: {}", clientPort); if (standaloneServerFactoryList.isEmpty()) { // there is no backup servers; return -1; } clientPort = clientPortList.get(activeZKServerIndex); LOG.info("Activate a backup zk server in the cluster on client port: {}", clientPort); // return the next back zk server's port return clientPort; }