当前位置: 首页>>代码示例>>Java>>正文


Java NIOServerCnxnFactory.shutdown方法代码示例

本文整理汇总了Java中org.apache.zookeeper.server.NIOServerCnxnFactory.shutdown方法的典型用法代码示例。如果您正苦于以下问题:Java NIOServerCnxnFactory.shutdown方法的具体用法?Java NIOServerCnxnFactory.shutdown怎么用?Java NIOServerCnxnFactory.shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.zookeeper.server.NIOServerCnxnFactory的用法示例。


在下文中一共展示了NIOServerCnxnFactory.shutdown方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shutdown

import org.apache.zookeeper.server.NIOServerCnxnFactory; //导入方法依赖的package包/类
/**
 * @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();

  LOG.info("Shutdown MiniZK cluster with all ZK servers");
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:29,代码来源:MiniZooKeeperCluster.java

示例2: killOneBackupZooKeeperServer

import org.apache.zookeeper.server.NIOServerCnxnFactory; //导入方法依赖的package包/类
/**
 * 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);
  LOG.info("Kill one backup ZK servers in the cluster " +
    "on client port: " + clientPort);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:32,代码来源:MiniZooKeeperCluster.java

示例3: killOneBackupZooKeeperServer

import org.apache.zookeeper.server.NIOServerCnxnFactory; //导入方法依赖的package包/类
/**
 * 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);
  LOG.info("Kill one backup ZK servers in the cluster " +
      "on client port: " + clientPort);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:31,代码来源:MiniZooKeeperCluster.java

示例4: killOneBackupZooKeeperServer

import org.apache.zookeeper.server.NIOServerCnxnFactory; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:apache,项目名称:hbase,代码行数:31,代码来源:MiniZooKeeperCluster.java

示例5: shutdown

import org.apache.zookeeper.server.NIOServerCnxnFactory; //导入方法依赖的package包/类
/**
 * @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();
  
  LOG.info("Shutdown MiniZK cluster with all ZK servers");
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:29,代码来源:MiniZooKeeperCluster.java

示例6: killOneBackupZooKeeperServer

import org.apache.zookeeper.server.NIOServerCnxnFactory; //导入方法依赖的package包/类
/**
 * 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);    
  LOG.info("Kill one backup ZK servers in the cluster " +
      "on client port: " + clientPort);
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:31,代码来源:MiniZooKeeperCluster.java

示例7: killCurrentActiveZooKeeperServer

import org.apache.zookeeper.server.NIOServerCnxnFactory; //导入方法依赖的package包/类
/**
 * @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);
  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;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:40,代码来源:MiniZooKeeperCluster.java

示例8: testFileDescriptorLeak

import org.apache.zookeeper.server.NIOServerCnxnFactory; //导入方法依赖的package包/类
@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));
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:30,代码来源:NIOConnectionFactoryFdLeakTest.java

示例9: shutdown

import org.apache.zookeeper.server.NIOServerCnxnFactory; //导入方法依赖的package包/类
/**
 * @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");
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:32,代码来源:MiniZooKeeperCluster.java

示例10: killCurrentActiveZooKeeperServer

import org.apache.zookeeper.server.NIOServerCnxnFactory; //导入方法依赖的package包/类
/**@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;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:41,代码来源:MiniZooKeeperCluster.java

示例11: killOneBackupZooKeeperServer

import org.apache.zookeeper.server.NIOServerCnxnFactory; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:33,代码来源:MiniZooKeeperCluster.java

示例12: stop

import org.apache.zookeeper.server.NIOServerCnxnFactory; //导入方法依赖的package包/类
public void stop() {
    ZooKeeperServer zs = this.server.getAndSet(null);
    if (zs != null) {
        zs.shutdown();
    }

    NIOServerCnxnFactory sf = this.serverFactory.getAndSet(null);
    if (sf != null) {
        sf.closeAll();
        sf.shutdown();
    }
}
 
开发者ID:pravega,项目名称:pravega,代码行数:13,代码来源:ZooKeeperServiceRunner.java

示例13: shutdown

import org.apache.zookeeper.server.NIOServerCnxnFactory; //导入方法依赖的package包/类
/**
 * @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");
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:34,代码来源:MiniZooKeeperCluster.java

示例14: killCurrentActiveZooKeeperServer

import org.apache.zookeeper.server.NIOServerCnxnFactory; //导入方法依赖的package包/类
/**@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);
  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;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:39,代码来源:MiniZooKeeperCluster.java

示例15: killCurrentActiveZooKeeperServer

import org.apache.zookeeper.server.NIOServerCnxnFactory; //导入方法依赖的package包/类
/**@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;
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:41,代码来源:MiniZooKeeperCluster.java


注:本文中的org.apache.zookeeper.server.NIOServerCnxnFactory.shutdown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。