• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ZkServer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.I0Itec.zkclient.ZkServer的典型用法代码示例。如果您正苦于以下问题:Java ZkServer类的具体用法?Java ZkServer怎么用?Java ZkServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ZkServer类属于org.I0Itec.zkclient包,在下文中一共展示了ZkServer类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: execute

import org.I0Itec.zkclient.ZkServer; //导入依赖的package包/类
@Override
public boolean execute() throws IOException {
  LOGGER.info("Executing command: " + toString());
  _tmpdir = createAutoDeleteTempDir();

  File logdir = new File(_tmpdir + File.separator + "translog");
  File datadir = new File(_tmpdir + File.separator + "snapshot");

  IDefaultNameSpace _defaultNameSpace = new IDefaultNameSpace() {
    @Override
    public void createDefaultNameSpace(org.I0Itec.zkclient.ZkClient zkClient) {
      // init any zk paths if needed
    }
  };

  ZkServer zkServer =
      new ZkServer(datadir.getAbsolutePath(), logdir.getAbsolutePath(),
          _defaultNameSpace, _zkPort, _tickTime, _minSessionTimeout);
  zkServer.start();

  LOGGER.info("Start zookeeper at localhost:" + zkServer.getPort() + " in thread "
      + Thread.currentThread().getName());

  savePID(System.getProperty("java.io.tmpdir") + File.separator + ".zooKeeper.pid");
  return true;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:27,代码来源:StartZookeeperCommand.java


示例2: start

import org.I0Itec.zkclient.ZkServer; //导入依赖的package包/类
public boolean start(int port) {
  
  File tmpdir = createAutoDeleteTempDir();
  File logdir = new File(tmpdir + File.separator + "translog");
  File datadir = new File(tmpdir + File.separator + "snapshot");

  IDefaultNameSpace defaultNameSpace = new IDefaultNameSpace() {
    @Override
    public void createDefaultNameSpace(org.I0Itec.zkclient.ZkClient zkClient) {
      // init any zk paths if needed
    }
  };
  ZkServer zkServer =
      new ZkServer(datadir.getAbsolutePath(), logdir.getAbsolutePath(), defaultNameSpace, port, 30000, 60000);
  zkServer.start();

  LOGGER.info("Start zookeeper at localhost:" + zkServer.getPort() + " in thread "
      + Thread.currentThread().getName());
  return true;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:21,代码来源:ZookeeperLauncher.java


示例3: setup

import org.I0Itec.zkclient.ZkServer; //导入依赖的package包/类
private static void setup() {

    IDefaultNameSpace defaultNameSpace = new IDefaultNameSpace() {
      @Override
      public void createDefaultNameSpace(org.I0Itec.zkclient.ZkClient client) {
        client.deleteRecursive("/" + clusterName);

      }
    };

    zkServer = new ZkServer(dataDir, logDir, defaultNameSpace, port);
    zkServer.start();
    ClusterSetup clusterSetup = new ClusterSetup(zkConnectString);
    clusterSetup.setupTestCluster(clusterName);
    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
 
开发者ID:apache,项目名称:helix,代码行数:21,代码来源:MockSpectatorProcess.java


示例4: beforeClass

import org.I0Itec.zkclient.ZkServer; //导入依赖的package包/类
@BeforeClass
public void beforeClass() {
  // Start ZK
  zkRoot = new File(System.getProperty("java.io.tmpdir"), TestHelixServiceDiscoveryBundle.class.getSimpleName());
  zkServer = new ZkServer(new File(zkRoot, "data").getAbsolutePath(),
      new File(zkRoot, "log").getAbsolutePath(),
      new IDefaultNameSpace() {
        @Override
        public void createDefaultNameSpace(ZkClient zkClient) {
          // NOP
        }
      }, zkPort);
  zkServer.start();
}
 
开发者ID:brandtg,项目名称:dropwizard-helix,代码行数:15,代码来源:TestHelixServiceDiscoveryBundle.java


示例5: start

import org.I0Itec.zkclient.ZkServer; //导入依赖的package包/类
@BeforeClass
public static void start() {

    zkData = TestUtils.tempDir();
    zkLogs = TestUtils.tempDir();

    zkServer = new ZkServer(zkData.getAbsolutePath(),zkLogs.getAbsolutePath(), DEFAULT_NAME_SPACE, ZK_PORT);
    LOGGER.debug("starting zk server ...");
    zkServer.start();
    LOGGER.debug("started zk server");

    // does not work for some reason
    // zkClient = zkServer.getZkClient();
    zkClient = new ZkClient(ZK_HOST, ZK_CLIENT_TIMEOUT, ZK_CLIENT_TIMEOUT, ZKStringSerializer$.MODULE$);
    zkUtils =  ZkUtils.apply(zkClient, false);

    kafkaServers = new ArrayList<>();
    for (int i = 0; i < BROKER_COUNT; i++) {
        LOGGER.info("starting test broker id: [{}] at port: [{}]", START_BROKER_ID + i, START_PORT + i);

        Properties properties = TestUtils.createBrokerConfig(START_BROKER_ID + i,ZK_HOST,
                true,
                true,
                START_PORT + i,
                Option.apply(SecurityProtocol.PLAINTEXT),
                Option.<File>empty(),
                Option.<Properties>empty(),
                true,
                false,
                0,
                false,
                0,
                false,
                0,
                Option.<String>empty()
        );

        kafkaServers.add(TestUtils.createServer(new KafkaConfig(properties), new MockTime()));
    }
}
 
开发者ID:milenkovicm,项目名称:netty-kafka-producer,代码行数:41,代码来源:AbstractMultiBrokerTest.java


示例6: startZkServer

import org.I0Itec.zkclient.ZkServer; //导入依赖的package包/类
public static ZkServer startZkServer(String zkAddr) {
  System.out.println("Start zookeeper at " + zkAddr + " in thread "
      + Thread.currentThread().getName());

  String zkDir = zkAddr.replace(':', '_');
  final String logDir = "/tmp/" + zkDir + "/logs";
  final String dataDir = "/tmp/" + zkDir + "/dataDir";
  try {
    FileUtils.deleteDirectory(new File(dataDir));
    FileUtils.deleteDirectory(new File(logDir));
  } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }

  IDefaultNameSpace defaultNameSpace = new IDefaultNameSpace() {
    @Override
    public void createDefaultNameSpace(org.I0Itec.zkclient.ZkClient zkClient) {
      // do nothing
    }
  };

  int port = Integer.parseInt(zkAddr.substring(zkAddr.lastIndexOf(':') + 1));
  ZkServer zkServer = new ZkServer(dataDir, logDir, defaultNameSpace, port);
  zkServer.start();

  return zkServer;
}
 
开发者ID:apache,项目名称:helix,代码行数:29,代码来源:ExampleHelper.java


示例7: stopZkServer

import org.I0Itec.zkclient.ZkServer; //导入依赖的package包/类
public static void stopZkServer(ZkServer zkServer) {
  if (zkServer != null) {
    zkServer.shutdown();
    System.out.println("Shut down zookeeper at port " + zkServer.getPort() + " in thread "
        + Thread.currentThread().getName());
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:8,代码来源:ExampleHelper.java


示例8: startZookeeper

import org.I0Itec.zkclient.ZkServer; //导入依赖的package包/类
public static void startZookeeper() {
  echo("STARTING Zookeeper at " + ZK_ADDRESS);
  IDefaultNameSpace defaultNameSpace = new IDefaultNameSpace() {
    @Override
    public void createDefaultNameSpace(ZkClient zkClient) {
    }
  };
  new File("/tmp/helix-quickstart").mkdirs();
  // start zookeeper
  ZkServer server =
      new ZkServer("/tmp/helix-quickstart/dataDir", "/tmp/helix-quickstart/logDir",
          defaultNameSpace, 2199);
  server.start();
}
 
开发者ID:apache,项目名称:helix,代码行数:15,代码来源:Quickstart.java


示例9: start

import org.I0Itec.zkclient.ZkServer; //导入依赖的package包/类
public void start(int port, String dataDir, String logDir) throws Exception {

    IDefaultNameSpace defaultNameSpace = new IDefaultNameSpace() {

      @Override
      public void createDefaultNameSpace(ZkClient zkClient) {

      }
    };
    ZkServer server = new ZkServer(dataDir, logDir, defaultNameSpace, port);
    server.start();
    Thread.currentThread().join();
  }
 
开发者ID:apache,项目名称:helix,代码行数:14,代码来源:LocalZKServer.java


示例10: startZkServer

import org.I0Itec.zkclient.ZkServer; //导入依赖的package包/类
static public ZkServer startZkServer(final String zkAddress, final List<String> rootNamespaces,
    boolean overwrite) throws Exception {
  System.out.println("Start zookeeper at " + zkAddress + " in thread "
      + Thread.currentThread().getName());

  String zkDir = zkAddress.replace(':', '_');
  final String logDir = "/tmp/" + zkDir + "/logs";
  final String dataDir = "/tmp/" + zkDir + "/dataDir";
  if (overwrite) {
    FileUtils.deleteDirectory(new File(dataDir));
    FileUtils.deleteDirectory(new File(logDir));
  }
  ZKClientPool.reset();

  IDefaultNameSpace defaultNameSpace = new IDefaultNameSpace() {
    @Override
    public void createDefaultNameSpace(org.I0Itec.zkclient.ZkClient zkClient) {
      if (rootNamespaces == null) {
        return;
      }

      for (String rootNamespace : rootNamespaces) {
        try {
          zkClient.deleteRecursive(rootNamespace);
        } catch (Exception e) {
          LOG.error("fail to deleteRecursive path:" + rootNamespace, e);
        }
      }
    }
  };

  int port = Integer.parseInt(zkAddress.substring(zkAddress.lastIndexOf(':') + 1));
  ZkServer zkServer = new ZkServer(dataDir, logDir, defaultNameSpace, port);
  zkServer.start();

  return zkServer;
}
 
开发者ID:apache,项目名称:helix,代码行数:38,代码来源:TestHelper.java


示例11: stopZkServer

import org.I0Itec.zkclient.ZkServer; //导入依赖的package包/类
static public void stopZkServer(ZkServer zkServer) {
  if (zkServer != null) {
    zkServer.shutdown();
    System.out.println("Shut down zookeeper at port " + zkServer.getPort() + " in thread "
        + Thread.currentThread().getName());
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:8,代码来源:TestHelper.java


示例12: start

import org.I0Itec.zkclient.ZkServer; //导入依赖的package包/类
public boolean start(int zkPort) {
  IDefaultNameSpace defaultNameSpace = new IDefaultNameSpace() {
    @Override
    public void createDefaultNameSpace(org.I0Itec.zkclient.ZkClient zkClient) {
      // init any zk paths if needed
    }
  };
  LOGGER.info("Starting zookeeper at localhost:{} in thread: {}", zkPort, Thread.currentThread().getName());
  _zkServer = new ZkServer(_dataDir, _logDir, defaultNameSpace, zkPort, 30000, 60000);
  _zkServer.start();
  return true;
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:13,代码来源:ZookeeperLauncher.java


示例13: startZkServer

import org.I0Itec.zkclient.ZkServer; //导入依赖的package包/类
private void startZkServer(int port, String dataDir, String logDir) {
  IDefaultNameSpace defaultNameSpace = zkClient -> {
  };
  // start zookeeper
  zkServer = new ZkServer(dataDir, logDir, defaultNameSpace, port);
  zkServer.start();
}
 
开发者ID:linkedin,项目名称:ambry,代码行数:8,代码来源:TestUtils.java


示例14: startZKServer

import org.I0Itec.zkclient.ZkServer; //导入依赖的package包/类
public static void startZKServer() {
	String temp = System.getProperty("java.io.tmpdir");
	ZkServer zk = new ZkServer(temp, temp, zkClient -> {
	});
	zk.start();
}
 
开发者ID:youtongluan,项目名称:sumk,代码行数:7,代码来源:SOAServer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JPaymentSelectRefund类代码示例发布时间:2022-05-22
下一篇:
Java GregorianCalendar类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap