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


Java ServerConfig.parse方法代码示例

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


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

示例1: startZookeeper

import org.apache.zookeeper.server.ServerConfig; //导入方法依赖的package包/类
private void startZookeeper() throws IOException, InterruptedException {
    File zkDir = folder.mkSubDir("embedded-zk-" + zookeeperPort);
    ServerConfig config = new ServerConfig();

    config.parse(new String[]{String.valueOf(zookeeperPort), zkDir.getAbsolutePath()});
    zookeeperThread = new Thread(() -> {
        try {
            zookeeperServer.runFromConfig(config);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    });
    zookeeperThread.setDaemon(true);
    zookeeperThread.start();
    // Await zookeeper startup.
    zookeeperThread.join(ZOOKEEPER_AWAIT_TIME);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:18,代码来源:EmbeddedKafka.java

示例2: createZooKeeperConf

import org.apache.zookeeper.server.ServerConfig; //导入方法依赖的package包/类
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;
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:24,代码来源:MiniAvatarCluster.java

示例3: setUp

import org.apache.zookeeper.server.ServerConfig; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    final String clientPort = "21818";
    final String dataDirectory = System.getProperty("java.io.tmpdir");
    zookeeperHost = "localhost:" + clientPort;

    ServerConfig config = new ServerConfig();
    config.parse(new String[] { clientPort, dataDirectory });

    testConfig = new BaseConfiguration();
    testConfig.setProperty("quorum", zookeeperHost);
    testConfig.setProperty("znode", "/config");
    testConfig.setProperty(APPNAME_PROPERTY, "test");
    testConfig.setProperty(ROOTCONFIG_PROPERTY, "test");

    zkServer = new ZookeeperTestUtil.ZooKeeperThread(config);
    server = new Thread(zkServer);
    server.start();

    zookeeper = connect(zookeeperHost);
}
 
开发者ID:LableOrg,项目名称:java-dynamicconfig,代码行数:22,代码来源:ZookeepersAsConfigSourceIT.java

示例4: startZookeeperServer

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

示例5: initializeAndRun

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

示例6: createZooKeeperConf

import org.apache.zookeeper.server.ServerConfig; //导入方法依赖的package包/类
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", "30");
  zkConfProps.store(new FileOutputStream(zkConfFile), "");

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

  return zkConf;
}
 
开发者ID:iVCE,项目名称:RDFS,代码行数:24,代码来源:MiniAvatarCluster.java

示例7: getZooKeeperConf

import org.apache.zookeeper.server.ServerConfig; //导入方法依赖的package包/类
private static ServerConfig getZooKeeperConf() throws Exception {
  if (new File(ZK_CONF_FILE).exists()) {
    ServerConfig zkConf = new ServerConfig();
    zkConf.parse(ZK_CONF_FILE);

    return zkConf;
  } else {
    return createZooKeeperConf();
  }
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:11,代码来源:MiniAvatarCluster.java

示例8: before

import org.apache.zookeeper.server.ServerConfig; //导入方法依赖的package包/类
@Override
public void before() throws Throwable {
    tempFolder = createTempDir();
    String zookeeperHost = "localhost:" + serverPort;
    ServerConfig config = new ServerConfig();
    config.parse(new String[]{serverPort, tempFolder.getAbsolutePath()});

    zkThread = new ZooKeeperThread(config);
    new Thread(zkThread).start();

    final CountDownLatch latch = new CountDownLatch(1);

    // Connect to the quorum and wait for the successful connection callback.
    zookeeper = new ZooKeeper(zookeeperHost, (int) TimeUnit.SECONDS.toMillis(10), watchedEvent -> {
        if (watchedEvent.getState() == Watcher.Event.KeeperState.SyncConnected) {
            // Signal that the Zookeeper connection is established.
            latch.countDown();
        }
    });

    // Wait for the connection to be established.
    boolean successfullyConnected = latch.await(12, TimeUnit.SECONDS);
    if (!successfullyConnected) {
        tempFolder.delete();
        throw new Exception("Could not start a local ZooKeeper quorum for testing.");
    }
}
 
开发者ID:LableOrg,项目名称:java-uniqueid,代码行数:28,代码来源:ZooKeeperInstance.java

示例9: RunServer

import org.apache.zookeeper.server.ServerConfig; //导入方法依赖的package包/类
public RunServer(File zooCfg) {
  config = new ServerConfig();
  try {
    config.parse(zooCfg.getAbsolutePath());
  } catch (ConfigException e) {
    throw new IllegalArgumentException("Bad configuration file", e);
  }
}
 
开发者ID:revelc,项目名称:zookeeper-maven-plugin,代码行数:9,代码来源:ZooKeeperLauncher.java

示例10: 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

示例11: zookeeper

import org.apache.zookeeper.server.ServerConfig; //导入方法依赖的package包/类
/** Run a full Zookeepr here */
public static void zookeeper(int port, String zkConfDir) {
    FmtLog.info(logConf, "Start Zookeeper %s : %d", zkConfDir, port) ;
    ServerConfig config = new ServerConfig();
    config.parse(new String[] {Integer.toString(port), zkConfDir}) ;
    ZooKeeperServerMain zk = new ZooKeeperServerMain();
    L.async(()-> {
        try { zk.runFromConfig(config) ; }
        catch (Exception e) { FmtLog.warn(logConf, "Failed to run zookeeper: "+e.getMessage(), e); }
    }) ;
}
 
开发者ID:afs,项目名称:lizard,代码行数:12,代码来源:LzBuildZk.java

示例12: getKafkaServer

import org.apache.zookeeper.server.ServerConfig; //导入方法依赖的package包/类
private KafkaServerStartable getKafkaServer() throws Exception {

        ZooKeeperServerMain zookeeper = new ZooKeeperServerMain();
        ServerConfig zooCfg = new ServerConfig();
        zooCfg.parse(new String[]{"2181","/tmp/zk"});

        new Thread(() -> {
            try {
                zookeeper.runFromConfig(zooCfg);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }).start();


        Properties properties = new Properties();

        properties.put("port", 9092);
        properties.put("zookeeper.connect", "127.0.0.1:2181");


        KafkaConfig config = new KafkaConfig(properties);

        return new KafkaServerStartable(config);

    }
 
开发者ID:mysql-time-machine,项目名称:validator,代码行数:27,代码来源:FunctionalTest.java

示例13: 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.parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。