Java 类org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException 实例源码

项目:fuck_zookeeper    文件:ZooKeeperServerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    try {
        ManagedUtil.registerLog4jMBeans();
    } catch (JMException e) {
        LOG.warn("Unable to register log4j JMX control", e);
    }
    //再次解析配置文件(我也是醉了呀,又解析一遍!!!,写这段的人你出来我保证不打你)
    ServerConfig config = new ServerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    } else {
        config.parse(args);
    }

    runFromConfig(config);
}
项目:https-github.com-apache-zookeeper    文件:QuorumMaj.java   
public QuorumMaj(Properties props) throws ConfigException {
    for (Entry<Object, Object> entry : props.entrySet()) {
        String key = entry.getKey().toString();
        String value = entry.getValue().toString();

        if (key.startsWith("server.")) {
            int dot = key.indexOf('.');
            long sid = Long.parseLong(key.substring(dot + 1));
            QuorumServer qs = new QuorumServer(sid, value);
            allMembers.put(Long.valueOf(sid), qs);
            if (qs.type == LearnerType.PARTICIPANT)
                votingMembers.put(Long.valueOf(sid), qs);
            else {
                observingMembers.put(Long.valueOf(sid), qs);
            }
        } else if (key.equals("version")) {
            version = Long.parseLong(value, 16);
        }
    }
    half = votingMembers.size() / 2;
}
项目:https-github.com-apache-zookeeper    文件:QuorumPeer.java   
private static String[] splitWithLeadingHostname(String s)
        throws ConfigException
{
    /* Does it start with an IPv6 literal? */
    if (s.startsWith("[")) {
        int i = s.indexOf("]:");
        if (i < 0) {
            throw new ConfigException(s + " starts with '[' but has no matching ']:'");
        }

        String[] sa = s.substring(i + 2).split(":");
        String[] nsa = new String[sa.length + 1];
        nsa[0] = s.substring(1, i);
        System.arraycopy(sa, 0, nsa, 1, sa.length);

        return nsa;
    } else {
        return s.split(":");
    }
}
项目:https-github.com-apache-zookeeper    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException, AdminServerException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();

    if (args.length == 1 && config.isDistributed()) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}
项目:https-github.com-apache-zookeeper    文件:ZooKeeperServerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException, AdminServerException
{
    try {
        ManagedUtil.registerLog4jMBeans();
    } catch (JMException e) {
        LOG.warn("Unable to register log4j JMX control", e);
    }

    ServerConfig config = new ServerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    } else {
        config.parse(args);
    }

    runFromConfig(config);
}
项目:https-github.com-apache-zookeeper    文件:ZKConfig.java   
/**
 * Add a configuration resource. The properties form this configuration will
 * overwrite corresponding already loaded property and system property
 *
 * @param configFile
 *            Configuration file.
 */
public void addConfiguration(File configFile) throws ConfigException {
    LOG.info("Reading configuration from: {}", configFile.getAbsolutePath());
    try {
        configFile = (new VerifyingFileFactory.Builder(LOG).warnForRelativePath().failForNonExistingPath().build())
                .validate(configFile);
        Properties cfg = new Properties();
        FileInputStream in = new FileInputStream(configFile);
        try {
            cfg.load(in);
        } finally {
            in.close();
        }
        parseProperties(cfg);
    } catch (IOException | IllegalArgumentException e) {
        LOG.error("Error while configuration from: {}", configFile.getAbsolutePath(), e);
        throw new ConfigException("Error while processing " + configFile.getAbsolutePath(), e);
    }
}
项目:https-github.com-apache-zookeeper    文件:ZooKeeperServerMainTest.java   
/**
 * Test verifies that the server shouldn't allow minsessiontimeout >
 * maxsessiontimeout
 */
@Test
public void testWithMinSessionTimeoutGreaterThanMaxSessionTimeout()
        throws Exception {
    ClientBase.setupTestEnv();

    final int CLIENT_PORT = PortAssignment.unique();
    final int tickTime = 2000;
    final int minSessionTimeout = 20 * tickTime + 1000; // min is higher
    final int maxSessionTimeout = tickTime * 2 - 100; // max is lower
    final String configs = "maxSessionTimeout=" + maxSessionTimeout + "\n"
            + "minSessionTimeout=" + minSessionTimeout + "\n";
    MainThread main = new MainThread(CLIENT_PORT, true, configs);
    String args[] = new String[1];
    args[0] = main.confFile.toString();
    try {
        main.main.initializeAndRun(args);
        Assert.fail("Must throw exception as "
                + "minsessiontimeout > maxsessiontimeout");
    } catch (ConfigException iae) {
        // expected
    }
}
项目:ZooKeeper    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();

    if (args.length == 1 && config.servers.size() > 0) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}
项目:ZooKeeper    文件:ZooKeeperServerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    try {
        ManagedUtil.registerLog4jMBeans();
    } catch (JMException e) {
        LOG.warn("Unable to register log4j JMX control", e);
    }

    ServerConfig config = new ServerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    } else {
        config.parse(args);
    }

    runFromConfig(config);
}
项目:StreamProcessingInfrastructure    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();

    if (args.length == 1 && config.servers.size() > 0) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}
项目:StreamProcessingInfrastructure    文件:ZooKeeperServerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    try {
        ManagedUtil.registerLog4jMBeans();
    } catch (JMException e) {
        LOG.warn("Unable to register log4j JMX control", e);
    }

    ServerConfig config = new ServerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    } else {
        config.parse(args);
    }

    runFromConfig(config);
}
项目:bigstreams    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();

    if (args.length == 1 && config.servers.size() > 0) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}
项目:bigstreams    文件:ZooKeeperServerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    try {
        ManagedUtil.registerLog4jMBeans();
    } catch (JMException e) {
        LOG.warn("Unable to register log4j JMX control", e);
    }

    ServerConfig config = new ServerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    } else {
        config.parse(args);
    }

    runFromConfig(config);
}
项目:bigstreams    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }

    if (args.length == 1 && config.servers.size() > 0) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}
项目:bigstreams    文件:ZooKeeperServerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    try {
        ManagedUtil.registerLog4jMBeans();
    } catch (JMException e) {
        LOG.warn("Unable to register log4j JMX control", e);
    }

    ServerConfig config = new ServerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    } else {
        config.parse(args);
    }

    runFromConfig(config);
}
项目:zookeeper-src-learning    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();

    if (args.length == 1 && config.servers.size() > 0) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}
项目:zookeeper-src-learning    文件:ZooKeeperServerMain.java   
protected void initializeAndRun(String[] args)
        throws ConfigException, IOException {
    try {
        ManagedUtil.registerLog4jMBeans();
    } catch (JMException e) {
        LOG.warn("Unable to register log4j JMX control", e);
    }

    ServerConfig config = new ServerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    } else {
        config.parse(args);
    }

    runFromConfig(config);
}
项目:zookeeper    文件:ZooKeeperServerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    try {
        ManagedUtil.registerLog4jMBeans();
    } catch (JMException e) {
        LOG.warn("Unable to register log4j JMX control", e);
    }

    ServerConfig config = new ServerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    } else {
        config.parse(args);
    }

    runFromConfig(config);
}
项目:SecureKeeper    文件:QuorumMaj.java   
public QuorumMaj(Properties props) throws ConfigException {
    for (Entry<Object, Object> entry : props.entrySet()) {
        String key = entry.getKey().toString();
        String value = entry.getValue().toString();

        if (key.startsWith("server.")) {
            int dot = key.indexOf('.');
            long sid = Long.parseLong(key.substring(dot + 1));
            QuorumServer qs = new QuorumServer(sid, value);
            allMembers.put(Long.valueOf(sid), qs);
            if (qs.type == LearnerType.PARTICIPANT)
                votingMembers.put(Long.valueOf(sid), qs);
            else {
                observingMembers.put(Long.valueOf(sid), qs);
            }
        } else if (key.equals("version")) {
            version = Long.parseLong(value, 16);
        }
    }
    half = votingMembers.size() / 2;
}
项目:SecureKeeper    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException, AdminServerException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();

    if (args.length == 1 && config.isDistributed()) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}
项目:SecureKeeper    文件:ZooKeeperServerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException, AdminServerException
{
    try {
        ManagedUtil.registerLog4jMBeans();
    } catch (JMException e) {
        LOG.warn("Unable to register log4j JMX control", e);
    }

    ServerConfig config = new ServerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    } else {
        config.parse(args);
    }

    runFromConfig(config);
}
项目:SecureKeeper    文件:ZooKeeperServerMainTest.java   
/**
 * Test verifies that the server shouldn't allow minsessiontimeout >
 * maxsessiontimeout
 */
@Test
public void testWithMinSessionTimeoutGreaterThanMaxSessionTimeout()
        throws Exception {
    ClientBase.setupTestEnv();

    final int CLIENT_PORT = PortAssignment.unique();
    final int tickTime = 2000;
    final int minSessionTimeout = 20 * tickTime + 1000; // min is higher
    final int maxSessionTimeout = tickTime * 2 - 100; // max is lower
    final String configs = "maxSessionTimeout=" + maxSessionTimeout + "\n"
            + "minSessionTimeout=" + minSessionTimeout + "\n";
    MainThread main = new MainThread(CLIENT_PORT, false, configs);
    String args[] = new String[1];
    args[0] = main.confFile.toString();
    try {
        main.main.initializeAndRun(args);
        Assert.fail("Must throw exception as "
                + "minsessiontimeout > maxsessiontimeout");
    } catch (ConfigException iae) {
        // expected
    }
}
项目:SecureKeeper    文件:QuorumMaj.java   
public QuorumMaj(Properties props) throws ConfigException {
    for (Entry<Object, Object> entry : props.entrySet()) {
        String key = entry.getKey().toString();
        String value = entry.getValue().toString();

        if (key.startsWith("server.")) {
            int dot = key.indexOf('.');
            long sid = Long.parseLong(key.substring(dot + 1));
            QuorumServer qs = new QuorumServer(sid, value);
            allMembers.put(Long.valueOf(sid), qs);
            if (qs.type == LearnerType.PARTICIPANT)
                votingMembers.put(Long.valueOf(sid), qs);
            else {
                observingMembers.put(Long.valueOf(sid), qs);
            }
        } else if (key.equals("version")) {
            version = Long.parseLong(value, 16);
        }
    }
    half = votingMembers.size() / 2;
}
项目:SecureKeeper    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException, AdminServerException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();

    if (args.length == 1 && config.isDistributed()) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}
项目:SecureKeeper    文件:ZooKeeperServerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException, AdminServerException
{
    try {
        ManagedUtil.registerLog4jMBeans();
    } catch (JMException e) {
        LOG.warn("Unable to register log4j JMX control", e);
    }

    ServerConfig config = new ServerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    } else {
        config.parse(args);
    }

    runFromConfig(config);
}
项目:SecureKeeper    文件:ZooKeeperServerMainTest.java   
/**
 * Test verifies that the server shouldn't allow minsessiontimeout >
 * maxsessiontimeout
 */
@Test
public void testWithMinSessionTimeoutGreaterThanMaxSessionTimeout()
        throws Exception {
    ClientBase.setupTestEnv();

    final int CLIENT_PORT = PortAssignment.unique();
    final int tickTime = 2000;
    final int minSessionTimeout = 20 * tickTime + 1000; // min is higher
    final int maxSessionTimeout = tickTime * 2 - 100; // max is lower
    final String configs = "maxSessionTimeout=" + maxSessionTimeout + "\n"
            + "minSessionTimeout=" + minSessionTimeout + "\n";
    MainThread main = new MainThread(CLIENT_PORT, false, configs);
    String args[] = new String[1];
    args[0] = main.confFile.toString();
    try {
        main.main.initializeAndRun(args);
        Assert.fail("Must throw exception as "
                + "minsessiontimeout > maxsessiontimeout");
    } catch (ConfigException iae) {
        // expected
    }
}
项目:hadoop-EAR    文件:TestSimpleGetNotification.java   
@Before
public void setUp() throws IOException, ConfigException, InterruptedException {
  new File(TEST_DIR).mkdirs();

  conf = NotifierTestUtil.initGenericConf();
  String editsLocation = TEST_DIR + "/tmp/hadoop/name";
  conf.set(AvatarNode.DFS_SHARED_EDITS_DIR0_KEY, editsLocation + "0");
  conf.set(AvatarNode.DFS_SHARED_EDITS_DIR1_KEY, editsLocation + "1");
  cluster = new MiniAvatarCluster.Builder(conf).numDataNodes(3).enableQJM(false)
      .federation(true).build();

  nameService = conf.get(FSConstants.DFS_FEDERATION_NAMESERVICES);
  fileSys = cluster.getFileSystem();
  localhostAddr = InetAddress.getLocalHost().getHostName(); 
  DFSUtil.setGenericConf(conf, nameService, AvatarNode.DFS_SHARED_EDITS_DIR0_KEY, 
                                            AvatarNode.DFS_SHARED_EDITS_DIR1_KEY);
}
项目:hadoop-EAR    文件:MiniAvatarCluster.java   
/**
 * Modify the config and start up the servers.  The rpc and info ports for
 * servers are guaranteed to use free ports.
 * <p>
 * NameNode and DataNode directory creation and configuration will be
 * managed by this class.
 *
 * @param conf the base configuration to use in starting the servers.  This
 *          will be modified as necessary.
 * @param numDataNodes Number of DataNodes to start; may be zero
 * @param format if true, format the NameNode and DataNodes before starting up
 * @param racks array of strings indicating the rack that each DataNode is on
 * @param hosts array of strings indicating the hostname of each DataNode
 * @param numNameNodes Number of NameNodes to start; 
 * @param federation if true, we start it with federation configure;
 */
public MiniAvatarCluster(Configuration conf,
                         int numDataNodes,
                         boolean format,
                         String[] racks,
                         String[] hosts,
                         int numNameNodes,
                         boolean federation,
                         long[] simulatedCapacities)
  throws IOException, ConfigException, InterruptedException {
    this(new Builder(conf).numDataNodes(numDataNodes).format(format)
      .racks(racks)
      .hosts(hosts)
      .numNameNodes(numNameNodes)
      .federation(federation)
      .simulatedCapacities(simulatedCapacities));
}
项目:hadoop-EAR    文件:MiniAvatarCluster.java   
private static ServerConfig createZooKeeperConf() 
  throws IOException, ConfigException {

  // create conf file
  File zkConfDir = new File(TEST_DIR);
  zkConfDir.mkdirs();
  File zkConfFile = new File(ZK_CONF_FILE);
  zkConfFile.delete();
  zkConfFile.createNewFile();

  Properties zkConfProps = new Properties();
  zkConfProps.setProperty("tickTime", "2000");
  zkConfProps.setProperty("dataDir", ZK_DATA_DIR);
  zkConfProps.setProperty("clientPort", new Integer(zkClientPort).toString());
  zkConfProps.setProperty("maxClientCnxns", "500");
  zkConfProps.store(new FileOutputStream(zkConfFile), "");

  // create config object
  ServerConfig zkConf = new ServerConfig();
  zkConf.parse(ZK_CONF_FILE);

  return zkConf;
}
项目:hadoop-EAR    文件:MiniAvatarCluster.java   
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");
}
项目:StreamBench    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();

    if (args.length == 1 && config.servers.size() > 0) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}
项目:StreamBench    文件:ZooKeeperServerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    try {
        ManagedUtil.registerLog4jMBeans();
    } catch (JMException e) {
        LOG.warn("Unable to register log4j JMX control", e);
    }

    ServerConfig config = new ServerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    } else {
        config.parse(args);
    }

    runFromConfig(config);
}
项目:ACaZoo    文件:ZooKeeperServerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    try {
        ManagedUtil.registerLog4jMBeans();
    } catch (JMException e) {
        LOG.warn("Unable to register log4j JMX control", e);
    }

    ServerConfig config = new ServerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    } else {
        config.parse(args);
    }

    runFromConfig(config);
}
项目:StreamCQL    文件:LocalTaskCommons.java   
/**
 * 启动zookeeper服务
 */
public static void startZookeeperServer()
    throws ConfigException, IOException
{
    String classPath = ApplicationParseTest.class.getResource("/").getPath();
    String[] args = {classPath + File.separator + "zoo.cfg"};
    ServerConfig config = new ServerConfig();
    if (args.length == 1)
    {
        config.parse(args[0]);
    }
    else
    {
        config.parse(args);
    }

    LOG.info("start to startup zookeeper server");
    runFromConfig(config);
}
项目:search    文件:ZkTestServer.java   
protected void initializeAndRun(String[] args) throws ConfigException,
    IOException {
  try {
    ManagedUtil.registerLog4jMBeans();
  } catch (JMException e) {
    log.warn("Unable to register log4j JMX control", e);
  }

  ServerConfig config = new ServerConfig();
  if (args.length == 1) {
    config.parse(args[0]);
  } else {
    config.parse(args);
  }

  runFromConfig(config);
}
项目:NeverwinterDP-Commons    文件:ZookeeperClusterService.java   
ZookeeperLaucher create(Properties zkProperties) throws ConfigException, IOException {
  QuorumPeerConfig zkConfig = new QuorumPeerConfig();
  zkConfig.parseProperties(zkProperties);
  DatadirCleanupManager purgeMgr = new DatadirCleanupManager(
      zkConfig.getDataDir(), 
      zkConfig.getDataLogDir(), 
      zkConfig.getSnapRetainCount(), 
      zkConfig.getPurgeInterval());
  purgeMgr.start();

  if (zkConfig.getServers().size() > 0) {
    return new QuorumPeerMainExt(zkConfig);
  } else {
    logger.warn(
      "Either no config or no quorum defined in config, running in standalone mode"
    );
    // there is only server in the quorum -- run as standalone
    return new ZooKeeperServerMainExt(zkConfig) ;
  }
}
项目:NYBC    文件:ZkTestServer.java   
protected void initializeAndRun(String[] args) throws ConfigException,
    IOException {
  try {
    ManagedUtil.registerLog4jMBeans();
  } catch (JMException e) {
    log.warn("Unable to register log4j JMX control", e);
  }

  ServerConfig config = new ServerConfig();
  if (args.length == 1) {
    config.parse(args[0]);
  } else {
    config.parse(args);
  }

  runFromConfig(config);
}
项目:LoadBalanced_zk    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();

    if (args.length == 1 && config.servers.size() > 0) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}
项目:LoadBalanced_zk    文件:ZooKeeperServerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    try {
        ManagedUtil.registerLog4jMBeans();
    } catch (JMException e) {
        LOG.warn("Unable to register log4j JMX control", e);
    }

    ServerConfig config = new ServerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    } else {
        config.parse(args);
    }

    runFromConfig(config);
}
项目:LoadBalanced_zk    文件:QuorumPeerMain.java   
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    QuorumPeerConfig config = new QuorumPeerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    }

    // Start and schedule the the purge task
    DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
            .getDataDir(), config.getDataLogDir(), config
            .getSnapRetainCount(), config.getPurgeInterval());
    purgeMgr.start();

    if (args.length == 1 && config.servers.size() > 0) {
        runFromConfig(config);
    } else {
        LOG.warn("Either no config or no quorum defined in config, running "
                + " in standalone mode");
        // there is only server in the quorum -- run as standalone
        ZooKeeperServerMain.main(args);
    }
}