當前位置: 首頁>>代碼示例>>Java>>正文


Java ServerConfig.getDataDir方法代碼示例

本文整理匯總了Java中org.apache.zookeeper.server.ServerConfig.getDataDir方法的典型用法代碼示例。如果您正苦於以下問題:Java ServerConfig.getDataDir方法的具體用法?Java ServerConfig.getDataDir怎麽用?Java ServerConfig.getDataDir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.zookeeper.server.ServerConfig的用法示例。


在下文中一共展示了ServerConfig.getDataDir方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createAndStartZooKeeper

import org.apache.zookeeper.server.ServerConfig; //導入方法依賴的package包/類
public static void createAndStartZooKeeper() 
  throws IOException, ConfigException, InterruptedException {
  logStateChange("Creating zookeeper server");
  AvatarShell.retrySleep = 1000;
  ServerConfig zkConf = createZooKeeperConf();

  zooKeeper = new ZooKeeperServer();
  FileTxnSnapLog ftxn = new 
    FileTxnSnapLog(new File(zkConf.getDataLogDir()),
                   new File(zkConf.getDataDir()));
  zooKeeper.setTxnLogFactory(ftxn);
  zooKeeper.setTickTime(zkConf.getTickTime());
  zooKeeper.setMinSessionTimeout(zkConf.getMinSessionTimeout());
  zooKeeper.setMaxSessionTimeout(zkConf.getMaxSessionTimeout());

  cnxnFactory = new NIOServerCnxnFactory();
  cnxnFactory.configure(zkConf.getClientPortAddress(),
      zkConf.getMaxClientCnxns());
  cnxnFactory.startup(zooKeeper);
  logStateChange("Creating zookeeper server - completed");
}
 
開發者ID:rhli,項目名稱:hadoop-EAR,代碼行數:22,代碼來源:MiniAvatarCluster.java

示例2: runFromConfig

import org.apache.zookeeper.server.ServerConfig; //導入方法依賴的package包/類
private void runFromConfig(ServerConfig config) throws IOException {
    zkServer = new ZooKeeperServer();
    try {

        txnLog = new FileTxnSnapLog(new File(config.getDataLogDir()), new File(config.getDataDir()));
        zkServer.setTxnLogFactory(txnLog);
        zkServer.setTickTime(config.getTickTime());
        zkServer.setMinSessionTimeout(config.getMinSessionTimeout());
        zkServer.setMaxSessionTimeout(config.getMaxSessionTimeout());
        cnxnFactory = ServerCnxnFactory.createFactory();
        cnxnFactory.configure(config.getClientPortAddress(),
                config.getMaxClientCnxns());
        cnxnFactory.startup(zkServer);
    } catch (InterruptedException e) {
        if (zkServer.isRunning()) {
            zkServer.shutdown();
        }
    }
}
 
開發者ID:intropro,項目名稱:prairie,代碼行數:20,代碼來源:ZookeeperUnit.java

示例3: createAndStartZooKeeper

import org.apache.zookeeper.server.ServerConfig; //導入方法依賴的package包/類
public static void createAndStartZooKeeper() 
  throws IOException, ConfigException, InterruptedException {
  ServerConfig zkConf = createZooKeeperConf();

  zooKeeper = new ZooKeeperServer();
  FileTxnSnapLog ftxn = new 
    FileTxnSnapLog(new File(zkConf.getDataLogDir()),
                   new File(zkConf.getDataDir()));
  zooKeeper.setTxnLogFactory(ftxn);
  zooKeeper.setTickTime(zkConf.getTickTime());
  zooKeeper.setMinSessionTimeout(zkConf.getMinSessionTimeout());
  zooKeeper.setMaxSessionTimeout(zkConf.getMaxSessionTimeout());

  cnxnFactory =
    new NIOServerCnxn.Factory(zkConf.getClientPortAddress(),
                              zkConf.getMaxClientCnxns());
  cnxnFactory.startup(zooKeeper);

}
 
開發者ID:iVCE,項目名稱:RDFS,代碼行數:20,代碼來源:MiniAvatarCluster.java

示例4: runFromConfig

import org.apache.zookeeper.server.ServerConfig; //導入方法依賴的package包/類
/**
     * Run from a ServerConfig.
     * @param config ServerConfig to use.
     * @throws IOException on any error
     */
    public void runFromConfig(ServerConfig config) throws IOException {
    	LOG.info(">>>>> Starting Test ZooKeep Server...");
        FileTxnSnapLog txnLog = null;
        try {
            // Note that this thread isn't going to be doing anything else,
            // so rather than spawning another thread, we will just call
            // run() in this thread.
            // create a file logger url from the command line args
            zkServer = new ZooKeeperServer();

            txnLog = new FileTxnSnapLog(new File(config.getDataLogDir()), new File(
                    config.getDataDir()));
            zkServer.setTxnLogFactory(txnLog);
            zkServer.setTickTime(config.getTickTime());
            zkServer.setMinSessionTimeout(config.getMinSessionTimeout());
            zkServer.setMaxSessionTimeout(config.getMaxSessionTimeout());
            cnxnFactory = ServerCnxnFactory.createFactory();
            cnxnFactory.configure(config.getClientPortAddress(),
                    config.getMaxClientCnxns());
            cnxnFactory.startup(zkServer);
            LOG.info("<<<<< Test ZooKeep Server Started.");
//            cnxnFactory.join();
//            if (zkServer.isRunning()) {
//                zkServer.shutdown();
//            }            
        } catch (InterruptedException e) {
            // warn, but generally this is ok
            LOG.warn("Server interrupted", e);
        } finally {
//            if (txnLog != null) {
//                txnLog.close();
//            }
        }
    }
 
開發者ID:nickman,項目名稱:HeliosStreams,代碼行數:40,代碼來源:TestZooKeeperServer.java

示例5: runFromConfig

import org.apache.zookeeper.server.ServerConfig; //導入方法依賴的package包/類
/**
 * Run from a ServerConfig.
 * @param config ServerConfig to use.
 * @throws IOException If there is a low-level I/O error.
 */
public void runFromConfig(ServerConfig config) throws IOException {
  log.info("Starting server");
  try {
    // Note that this thread isn't going to be doing anything else,
    // so rather than spawning another thread, we will just call
    // run() in this thread.
    // create a file logger url from the command line args
    zooKeeperServer = new ZooKeeperServer();
    
    FileTxnSnapLog ftxn = new FileTxnSnapLog(new File(
        config.getDataLogDir()), new File(config.getDataDir()));
    zooKeeperServer.setTxnLogFactory(ftxn);
    zooKeeperServer.setTickTime(config.getTickTime());
    zooKeeperServer.setMinSessionTimeout(config.getMinSessionTimeout());
    zooKeeperServer.setMaxSessionTimeout(config.getMaxSessionTimeout());
    cnxnFactory = ServerCnxnFactory.createFactory();
    cnxnFactory.configure(config.getClientPortAddress(),
        config.getMaxClientCnxns());
    cnxnFactory.startup(zooKeeperServer);
    cnxnFactory.join();
   // if (zooKeeperServer.isRunning()) {
      zkServer.shutdown();
   // }
  } catch (InterruptedException e) {
    // warn, but generally this is ok
    log.warn("Server interrupted", e);
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:34,代碼來源:ZkTestServer.java

示例6: ZooKeeperServerFactory

import org.apache.zookeeper.server.ServerConfig; //導入方法依賴的package包/類
public ZooKeeperServerFactory(QuorumPeerConfig config) throws IOException, InterruptedException {
    LOGGER.info("Creating zookeeper server with: {}", config);
    ServerConfig serverConfig = getServerConfig(config);
    ZooKeeperServer zkServer = new ZooKeeperServer();
    FileTxnSnapLog ftxn = new FileTxnSnapLog(new File(serverConfig.getDataLogDir()), new File(serverConfig.getDataDir()));
    zkServer.setTxnLogFactory(ftxn);
    zkServer.setTickTime(serverConfig.getTickTime());
    zkServer.setMinSessionTimeout(serverConfig.getMinSessionTimeout());
    zkServer.setMaxSessionTimeout(serverConfig.getMaxSessionTimeout());
    NIOServerCnxnFactory cnxnFactory = new NIOServerCnxnFactory() {
        protected void configureSaslLogin() throws IOException {
        }
    };
    InetSocketAddress clientPortAddress = serverConfig.getClientPortAddress();
    cnxnFactory.configure(clientPortAddress, serverConfig.getMaxClientCnxns());
    updateZooKeeperURL(cnxnFactory.getLocalAddress(), cnxnFactory.getLocalPort());

    try {
        LOGGER.debug("Starting ZooKeeper server on address %s", serverConfig.getClientPortAddress());
        cnxnFactory.startup(zkServer);
        LOGGER.debug("Started ZooKeeper server");
    } catch (Exception e) {
        LOGGER.warn(String.format("Failed to start ZooKeeper server, reason : %s", e));
        cnxnFactory.shutdown();
        throw e;
    }
}
 
開發者ID:fabric8io,項目名稱:jube,代碼行數:28,代碼來源:ZooKeeperServerFactory.java

示例7: start

import org.apache.zookeeper.server.ServerConfig; //導入方法依賴的package包/類
/**
 * Starts the test ZooKeeper server
 */
public void start() {
  if (started) {
    LOG.debug("Already started");
    return;
  }
  try {
    LOG.debug("Starting...");
    ServerConfig config = new ServerConfig();
    config.parse(new String[] { port.toString(), ZK_DIR.getCanonicalPath(), ticktime.toString() });

    zkServer = new ZooKeeperServer();

    FileTxnSnapLog ftxn = new FileTxnSnapLog(new File(config.getDataLogDir()), new File(config.getDataDir()));
    zkServer.setTxnLogFactory(ftxn);
    zkServer.setTickTime(config.getTickTime());
    zkServer.setMinSessionTimeout(config.getMinSessionTimeout());
    zkServer.setMaxSessionTimeout(config.getMaxSessionTimeout());

    cnxnFactory = ServerCnxnFactory.createFactory();
    cnxnFactory.configure(config.getClientPortAddress(), config.getMaxClientCnxns());
    cnxnFactory.startup(zkServer);
    started = true;
    LOG.info("Started, {}", getConnectString());
  } catch (Exception e) {
    LOG.error("Failed to start: " + e.getMessage(), e);
  }
}
 
開發者ID:Comcast,項目名稱:flume2storm,代碼行數:31,代碼來源:ZkTestServer.java

示例8: runFromConfig

import org.apache.zookeeper.server.ServerConfig; //導入方法依賴的package包/類
/**
 * Run from a ServerConfig.
 * @param config ServerConfig to use.
 * @throws IOException If there is a low-level I/O error.
 */
public void runFromConfig(ServerConfig config) throws IOException {
  log.info("Starting server");
  try {
    // Note that this thread isn't going to be doing anything else,
    // so rather than spawning another thread, we will just call
    // run() in this thread.
    // create a file logger url from the command line args
    zooKeeperServer = new ZooKeeperServer();
    
    FileTxnSnapLog ftxn = new FileTxnSnapLog(new File(
        config.getDataLogDir()), new File(config.getDataDir()));
    zooKeeperServer.setTxnLogFactory(ftxn);
    zooKeeperServer.setTickTime(config.getTickTime());
    zooKeeperServer.setMinSessionTimeout(config.getMinSessionTimeout());
    zooKeeperServer.setMaxSessionTimeout(config.getMaxSessionTimeout());
    cnxnFactory = ServerCnxnFactory.createFactory();
    cnxnFactory.configure(config.getClientPortAddress(),
        config.getMaxClientCnxns());
    cnxnFactory.startup(zooKeeperServer);
    cnxnFactory.join();
    if (zooKeeperServer.isRunning()) {
      zkServer.shutdown();
    }
  } catch (InterruptedException e) {
    // warn, but generally this is ok
    log.warn("Server interrupted", e);
  }
}
 
開發者ID:pkarmstr,項目名稱:NYBC,代碼行數:34,代碼來源:ZkTestServer.java

示例9: runZKFromConfig

import org.apache.zookeeper.server.ServerConfig; //導入方法依賴的package包/類
public static void runZKFromConfig(ServerConfig config,ServerCnxnFactory cnxnFactory) throws IOException {
    AiravataZKUtils.logger.info("Starting Zookeeper server...");
    FileTxnSnapLog txnLog = null;
    try {
        // Note that this thread isn't going to be doing anything else,
        // so rather than spawning another thread, we will just call
        // run() in this thread.
        // create a file logger url from the command line args
        ZooKeeperServer zkServer = new ZooKeeperServer();

        txnLog = new FileTxnSnapLog(new File(config.getDataDir()), new File(
                config.getDataDir()));
        zkServer.setTxnLogFactory(txnLog);
        zkServer.setTickTime(config.getTickTime());
        zkServer.setMinSessionTimeout(config.getMinSessionTimeout());
        zkServer.setMaxSessionTimeout(config.getMaxSessionTimeout());
        cnxnFactory = ServerCnxnFactory.createFactory();
        cnxnFactory.configure(config.getClientPortAddress(),
                config.getMaxClientCnxns());
        cnxnFactory.startup(zkServer);
        cnxnFactory.join();
        if (zkServer.isRunning()) {
            zkServer.shutdown();
        }
    } catch (InterruptedException e) {
        // warn, but generally this is ok
        AiravataZKUtils.logger.warn("Server interrupted", e);
        System.exit(1);
    } finally {
        if (txnLog != null) {
            txnLog.close();
        }
    }
}
 
開發者ID:apache,項目名稱:airavata,代碼行數:35,代碼來源:AiravataZKUtils.java

示例10: clearZooKeeperData

import org.apache.zookeeper.server.ServerConfig; //導入方法依賴的package包/類
public static boolean clearZooKeeperData() throws Exception {
  ServerConfig zkConf = getZooKeeperConf();
  File dataLogDir = new File(zkConf.getDataLogDir());
  File dataDir = new File(zkConf.getDataDir());
  return (FileUtil.fullyDelete(dataLogDir) && FileUtil.fullyDelete(dataDir));
}
 
開發者ID:rhli,項目名稱:hadoop-EAR,代碼行數:7,代碼來源:MiniAvatarCluster.java

示例11: runFromConfig

import org.apache.zookeeper.server.ServerConfig; //導入方法依賴的package包/類
@Override
public void runFromConfig(final ServerConfig config) throws IOException {
  ServerConfig newServerConfig = new ServerConfig() {

    public void parse(String[] args) {
      config.parse(args);
    }

    public void parse(String path)
        throws QuorumPeerConfig.ConfigException {
      config.parse(path);
    }

    public void readFrom(QuorumPeerConfig otherConfig) {
      config.readFrom(otherConfig);
    }

    public InetSocketAddress getClientPortAddress() {
      return config.getClientPortAddress();
    }

    public String getDataDir() {
      return config.getDataDir();
    }

    public String getDataLogDir() {
      return config.getDataLogDir();
    }

    public int getTickTime() {
      return config.getTickTime();
    }

    public int getMaxClientCnxns() {
      dataDir = getDataDir();
      dataLogDir = getDataLogDir();
      tickTime = getTickTime();
      minSessionTimeout = getMinSessionTimeout();
      maxSessionTimeout = getMaxSessionTimeout();
      maxClientCnxns = 0;
      return 0;
    }

    public int getMinSessionTimeout() {
      return config.getMinSessionTimeout();
    }

    public int getMaxSessionTimeout() {
      return config.getMaxSessionTimeout();
    }
  };

  newServerConfig.getMaxClientCnxns();

  super.runFromConfig(newServerConfig);
}
 
開發者ID:linkedin,項目名稱:pinot,代碼行數:57,代碼來源:ZkStarter.java


注:本文中的org.apache.zookeeper.server.ServerConfig.getDataDir方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。