gpt4 book ai didi

ml.shifu.guagua.coordinator.zk.ZooKeeperUtils类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 12:42:19 27 4
gpt4 key购买 nike

本文整理了Java中ml.shifu.guagua.coordinator.zk.ZooKeeperUtils类的一些代码示例,展示了ZooKeeperUtils类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperUtils类的具体详情如下:
包路径:ml.shifu.guagua.coordinator.zk.ZooKeeperUtils
类名称:ZooKeeperUtils

ZooKeeperUtils介绍

[英]ZooKeeperUtils is a helper used to start embed zookeeper server in CLI host.

For big data guagua application, independent zookeeper instance is recommended, embed server is for user easy to use guagua if there is no zookeeper server in hand.
[中]ZooKeeperUtils是用于在CLI主机中启动嵌入zookeeper服务器的助手。
对于大数据guagua应用,建议使用独立的zookeeper实例,如果手头没有zookeeper服务器,则嵌入式服务器便于用户使用guagua。

代码示例

代码示例来源:origin: ml.shifu/guagua-mapreduce

/**
 * Start zookeeper server in thread of master node.
 */
private String startZookeeperServer(String localHostName) {
  int embedZkClientPort = 0;
  try {
    embedZkClientPort = ZooKeeperUtils.startEmbedZooKeeper();
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
  // 2. check if it is started.
  ZooKeeperUtils.checkIfEmbedZooKeeperStarted(embedZkClientPort);
  return localHostName + ":" + embedZkClientPort;
}

代码示例来源:origin: ShifuML/guagua

String zooKeeperWorkingDir = getZooKeeperWorkingDir();
boolean isSuccessful = createFolder(zooKeeperWorkingDir);
  zooKeeperWorkingDir = getZooKeeperWorkingDir("zookeeper_" + System.currentTimeMillis());
  createFolder(zooKeeperWorkingDir);
int validZkPort = getValidZooKeeperPort();
prepZooKeeperConf(zooKeeperWorkingDir, confName, validZkPort + "");

代码示例来源:origin: ShifuML/guagua

/**
 * Retrieve zookeeper working folder.
 */
private static String getZooKeeperWorkingDir() {
  return getUserDir() + File.separator + "zookeeper";
}

代码示例来源:origin: ShifuML/guagua

embedZkClientPort = ZooKeeperUtils.startEmbedZooKeeper();
      } catch (IOException e) {
        throw new RuntimeException(e);
      ZooKeeperUtils.checkIfEmbedZooKeeperStarted(embedZkClientPort);
      try {
        embededZooKeeperServer = InetAddress.getLocalHost().getHostName() + ":" + embedZkClientPort;
      "Zookeeper servers should be provided by '-z' parameter with non-empty value.");
if(ZooKeeperUtils.checkServers(zkServers)) {
  conf.set(GuaguaConstants.GUAGUA_ZK_SERVERS, zkServers.trim());
} else {

代码示例来源:origin: ShifuML/guagua

String zooKeeperWorkingDir = getZooKeeperWorkingDir();
boolean isSuccessful = createFolder(zooKeeperWorkingDir);
  zooKeeperWorkingDir = getZooKeeperWorkingDir("zookeeper_" + System.currentTimeMillis());
  createFolder(zooKeeperWorkingDir);
int validZkPort = getValidZooKeeperPort();
prepZooKeeperConf(zooKeeperWorkingDir, confName, validZkPort + "");
commandList.add(findContainingJar(Log4jLoggerAdapter.class) + ":" + findContainingJar(Logger.class) + ":"
    + findContainingJar(org.apache.log4j.Logger.class) + ":" + findContainingJar(ZooKeeperUtils.class)
    + ":" + findContainingJar(QuorumPeerMain.class));
commandList.add(ZooKeeperMain.class.getName());
commandList.add(confName);
String hostname = getLocalHostName();
if(isServerAlive(hostname, validZkPort)) {
  return hostname + ":" + validZkPort;
} else {

代码示例来源:origin: ShifuML/guagua

@Override
public void preApplication(MasterContext<MASTER_RESULT, WORKER_RESULT> context) {
  String zkServers = context.getProps().getProperty(GuaguaConstants.GUAGUA_ZK_SERVERS);
  if(zkServers == null || zkServers.length() == 0 || !ZooKeeperUtils.checkServers(zkServers)) {
    this.isNeedStartZookeeper = true;
    if(fileSystem == null) {
    String zookeeperServer;
    try {
      zookeeperServer = ZooKeeperUtils.startChildZooKeeperProcess(zkJavaOpts);
    } catch (IOException e) {
      LOG.error("Error in start child zookeeper process.", e);

代码示例来源:origin: ml.shifu/guagua-mapreduce

@Override
public void preApplication(WorkerContext<MASTER_RESULT, WORKER_RESULT> context) {
  String zkServers = context.getProps().getProperty(GuaguaConstants.GUAGUA_ZK_SERVERS);
  if(zkServers == null || zkServers.length() == 0 || !ZooKeeperUtils.checkServers(zkServers)) {
    this.sleepTime = NumberFormatUtils.getLong(
        context.getProps().getProperty(GuaguaConstants.GUAGUA_COORDINATOR_SLEEP_UNIT), WAIT_SLOT_MILLS);

代码示例来源:origin: ShifuML/guagua

/**
 * Create zookeeper file with specified name and client port setting.
 */
public static void prepZooKeeperConf(String zkFolder, String fileName, String clientPort) throws IOException {
  Map<String, String> props = new HashMap<String, String>();
  String dataDir = zkFolder + File.separator + "zkdata";
  createFolder(dataDir);
  String dataLogDir = zkFolder + File.separator + "zklog";
  createFolder(dataLogDir);
  props.put("tickTime", "2000");
  props.put("initLimit", "10");
  props.put("syncLimit", "5");
  props.put("dataDir", dataDir);
  props.put("dataLogDir", dataLogDir);
  props.put("clientPort", clientPort);
  props.put("minSessionTimeout", "10000");
  props.put("maxSessionTimeout", "30000000");
  // The number of snapshots to retain in dataDir
  props.put("autopurge.snapRetainCount", "3");
  // Purge task interval in hours set to "0" to disable auto purge feature
  props.put("autopurge.purgeInterval", "1");
  populateZooKeeperConfFile(fileName, props);
}

代码示例来源:origin: ml.shifu/guagua-yarn

embedZkClientPort = ZooKeeperUtils.startEmbedZooKeeper();
      } catch (IOException e) {
        throw new RuntimeException(e);
      ZooKeeperUtils.checkIfEmbedZooKeeperStarted(embedZkClientPort);
      try {
        embededZooKeeperServer = InetAddress.getLocalHost().getHostName() + ":" + embedZkClientPort;
      "Zookeeper servers should be provided by '-z' parameter with non-empty value.");
if(ZooKeeperUtils.checkServers(zkServers)) {
  conf.set(GuaguaConstants.GUAGUA_ZK_SERVERS, zkServers.trim());
} else {

代码示例来源:origin: ml.shifu/guagua-yarn

@Override
public void preApplication(MasterContext<MASTER_RESULT, WORKER_RESULT> context) {
  String zkServers = context.getProps().getProperty(GuaguaConstants.GUAGUA_ZK_SERVERS);
  if(zkServers == null || zkServers.length() == 0 || !ZooKeeperUtils.checkServers(zkServers)) {
    this.isNeedStartZookeeper = true;
    if(fileSystem == null) {
    String zookeeperServer;
    try {
      zookeeperServer = ZooKeeperUtils.startChildZooKeeperProcess(zkJavaOpts);
    } catch (IOException e) {
      LOG.error("Error in start child zookeeper process.", e);

代码示例来源:origin: ShifuML/guagua

@Override
public void preApplication(WorkerContext<MASTER_RESULT, WORKER_RESULT> context) {
  String zkServers = context.getProps().getProperty(GuaguaConstants.GUAGUA_ZK_SERVERS);
  if(zkServers == null || zkServers.length() == 0 || !ZooKeeperUtils.checkServers(zkServers)) {
    this.sleepTime = NumberFormatUtils.getLong(
        context.getProps().getProperty(GuaguaConstants.GUAGUA_COORDINATOR_SLEEP_UNIT), WAIT_SLOT_MILLS);

代码示例来源:origin: ml.shifu/guagua-mapreduce

embedZkClientPort = ZooKeeperUtils.startEmbedZooKeeper();
      } catch (IOException e) {
        throw new RuntimeException(e);
      ZooKeeperUtils.checkIfEmbedZooKeeperStarted(embedZkClientPort);
      try {
        embededZooKeeperServer = InetAddress.getLocalHost().getHostName() + ":" + embedZkClientPort;
      "Zookeeper servers should be provided by '-z' parameter with non-empty value.");
if(ZooKeeperUtils.checkServers(zkServers)) {
  conf.set(GuaguaConstants.GUAGUA_ZK_SERVERS, zkServers.trim());
} else {

代码示例来源:origin: ShifuML/guagua

/**
 * Start zookeeper server in thread of master node.
 */
private String startZookeeperServer(String localHostName) {
  int embedZkClientPort = 0;
  try {
    embedZkClientPort = ZooKeeperUtils.startEmbedZooKeeper();
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
  // 2. check if it is started.
  ZooKeeperUtils.checkIfEmbedZooKeeperStarted(embedZkClientPort);
  return localHostName + ":" + embedZkClientPort;
}

代码示例来源:origin: ml.shifu/guagua-mapreduce

@Override
public void preApplication(MasterContext<MASTER_RESULT, WORKER_RESULT> context) {
  String zkServers = context.getProps().getProperty(GuaguaConstants.GUAGUA_ZK_SERVERS);
  if(zkServers == null || zkServers.length() == 0 || !ZooKeeperUtils.checkServers(zkServers)) {
    this.isNeedStartZookeeper = true;
    if(fileSystem == null) {
    String zookeeperServer;
    try {
      zookeeperServer = ZooKeeperUtils.startChildZooKeeperProcess(zkJavaOpts);
    } catch (IOException e) {
      LOG.error("Error in start child zookeeper process.", e);

代码示例来源:origin: ShifuML/guagua

@Override
public void preApplication(WorkerContext<MASTER_RESULT, WORKER_RESULT> context) {
  String zkServers = context.getProps().getProperty(GuaguaConstants.GUAGUA_ZK_SERVERS);
  if(zkServers == null || zkServers.length() == 0 || !ZooKeeperUtils.checkServers(zkServers)) {
    this.sleepTime = NumberFormatUtils.getLong(
        context.getProps().getProperty(GuaguaConstants.GUAGUA_COORDINATOR_SLEEP_UNIT), WAIT_SLOT_MILLS);

代码示例来源:origin: ShifuML/guagua

/**
 * Retrieve zookeeper working folder.
 */
private static String getZooKeeperWorkingDir(String subFolder) {
  return getUserDir() + File.separator + subFolder;
}

代码示例来源:origin: ShifuML/guagua

embedZkClientPort = ZooKeeperUtils.startEmbedZooKeeper();
      } catch (IOException e) {
        throw new RuntimeException(e);
      ZooKeeperUtils.checkIfEmbedZooKeeperStarted(embedZkClientPort);
      try {
        embededZooKeeperServer = InetAddress.getLocalHost().getHostName() + ":" + embedZkClientPort;
      "Zookeeper servers should be provided by '-z' parameter with non-empty value.");
if(ZooKeeperUtils.checkServers(zkServers)) {
  conf.set(GuaguaConstants.GUAGUA_ZK_SERVERS, zkServers.trim());
} else {

代码示例来源:origin: ml.shifu/guagua-yarn

/**
 * Start zookeeper server in thread of master node.
 */
private String startZookeeperServer(String localHostName) {
  int embedZkClientPort = 0;
  try {
    embedZkClientPort = ZooKeeperUtils.startEmbedZooKeeper();
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
  // 2. check if it is started.
  ZooKeeperUtils.checkIfEmbedZooKeeperStarted(embedZkClientPort);
  return localHostName + ":" + embedZkClientPort;
}

代码示例来源:origin: ShifuML/guagua

@Override
public void preApplication(MasterContext<MASTER_RESULT, WORKER_RESULT> context) {
  String zkServers = context.getProps().getProperty(GuaguaConstants.GUAGUA_ZK_SERVERS);
  if(zkServers == null || zkServers.length() == 0 || !ZooKeeperUtils.checkServers(zkServers)) {
    this.isNeedStartZookeeper = true;
    if(fileSystem == null) {
    String zookeeperServer;
    try {
      zookeeperServer = ZooKeeperUtils.startChildZooKeeperProcess(zkJavaOpts);
    } catch (IOException e) {
      LOG.error("Error in start child zookeeper process.", e);

代码示例来源:origin: ml.shifu/guagua-yarn

@Override
public void preApplication(WorkerContext<MASTER_RESULT, WORKER_RESULT> context) {
  String zkServers = context.getProps().getProperty(GuaguaConstants.GUAGUA_ZK_SERVERS);
  if(zkServers == null || zkServers.length() == 0 || !ZooKeeperUtils.checkServers(zkServers)) {
    this.sleepTime = NumberFormatUtils.getLong(
        context.getProps().getProperty(GuaguaConstants.GUAGUA_COORDINATOR_SLEEP_UNIT), WAIT_SLOT_MILLS);

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com