• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java CuratorService类的典型用法和代码示例

java 1次浏览

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

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

示例1: userZookeeperToCreateRoot

点赞 3

import org.apache.hadoop.registry.client.impl.zk.CuratorService; //导入依赖的package包/类
/**
 * have the ZK user create the root dir.
 * This logs out the ZK user after and stops its curator instance,
 * to avoid contamination
 * @throws Throwable
 */
public void userZookeeperToCreateRoot() throws Throwable {

  System.setProperty("curator-log-events", "true");
  CuratorService curator = null;
  LoginContext login = login(ZOOKEEPER_LOCALHOST,
      ZOOKEEPER_CLIENT_CONTEXT,
      keytab_zk);
  try {
    logLoginDetails(ZOOKEEPER, login);
    RegistrySecurity.setZKSaslClientProperties(ZOOKEEPER,
        ZOOKEEPER_CLIENT_CONTEXT);
    curator = startCuratorServiceInstance("ZK", true);
    LOG.info(curator.toString());

    addToTeardown(curator);
    curator.zkMkPath("/", CreateMode.PERSISTENT, false,
        RegistrySecurity.WorldReadWriteACL);
    ZKPathDumper pathDumper = curator.dumpPath(true);
    LOG.info(pathDumper.toString());
  } finally {
    logout(login);
    ServiceOperations.stop(curator);
  }
}
 

开发者ID:naver,
项目名称:hadoop,
代码行数:31,
代码来源:TestSecureRegistry.java

示例2: createCuratorService

点赞 2

import org.apache.hadoop.registry.client.impl.zk.CuratorService; //导入依赖的package包/类
/**
 * Create an instance
 */
protected void createCuratorService() throws IOException {
  curatorService = new CuratorService("curatorService");
  curatorService.init(createRegistryConfiguration());
  curatorService.start();
  rootACL = RegistrySecurity.WorldReadWriteACL;
  curatorService.maybeCreate("", CreateMode.PERSISTENT, rootACL, true);
}
 

开发者ID:naver,
项目名称:hadoop,
代码行数:11,
代码来源:TestCuratorService.java

示例3: testInsecureClientToZK

点赞 2

import org.apache.hadoop.registry.client.impl.zk.CuratorService; //导入依赖的package包/类
@Test
public void testInsecureClientToZK() throws Throwable {
  startSecureZK();
  userZookeeperToCreateRoot();
  RegistrySecurity.clearZKSaslClientProperties();

  CuratorService curatorService =
      startCuratorServiceInstance("insecure client", false);

  curatorService.zkList("/");
  curatorService.zkMkPath("", CreateMode.PERSISTENT, false,
      RegistrySecurity.WorldReadWriteACL);
}
 

开发者ID:naver,
项目名称:hadoop,
代码行数:14,
代码来源:TestSecureRegistry.java

示例4: testZookeeperCanWrite

点赞 2

import org.apache.hadoop.registry.client.impl.zk.CuratorService; //导入依赖的package包/类
/**
 * test that ZK can write as itself
 * @throws Throwable
 */
@Test
public void testZookeeperCanWrite() throws Throwable {

  System.setProperty("curator-log-events", "true");
  startSecureZK();
  CuratorService curator = null;
  LoginContext login = login(ZOOKEEPER_LOCALHOST,
      ZOOKEEPER_CLIENT_CONTEXT,
      keytab_zk);
  try {
    logLoginDetails(ZOOKEEPER, login);
    RegistrySecurity.setZKSaslClientProperties(ZOOKEEPER,
                                              ZOOKEEPER_CLIENT_CONTEXT);
    curator = startCuratorServiceInstance("ZK", true);
    LOG.info(curator.toString());

    addToTeardown(curator);
    curator.zkMkPath("/", CreateMode.PERSISTENT, false,
        RegistrySecurity.WorldReadWriteACL);
    curator.zkList("/");
    curator.zkMkPath("/zookeeper", CreateMode.PERSISTENT, false,
        RegistrySecurity.WorldReadWriteACL);
  } finally {
    logout(login);
    ServiceOperations.stop(curator);
  }
}
 

开发者ID:naver,
项目名称:hadoop,
代码行数:32,
代码来源:TestSecureRegistry.java

示例5: startCuratorServiceInstance

点赞 2

import org.apache.hadoop.registry.client.impl.zk.CuratorService; //导入依赖的package包/类
/**
 * Start a curator service instance
 * @param name name
 * @param secure flag to indicate the cluster is secure
 * @return an inited and started curator service
 */
protected CuratorService startCuratorServiceInstance(String name,
    boolean secure) {
  Configuration clientConf = new Configuration();
  clientConf.set(KEY_REGISTRY_ZK_ROOT, "/");
  clientConf.setBoolean(KEY_REGISTRY_SECURE, secure);
  describe(LOG, "Starting Curator service");
  CuratorService curatorService = new CuratorService(name, secureZK);
  curatorService.init(clientConf);
  curatorService.start();
  LOG.info("Curator Binding {}",
      curatorService.bindingDiagnosticDetails());
  return curatorService;
}
 

开发者ID:naver,
项目名称:hadoop,
代码行数:20,
代码来源:TestSecureRegistry.java

示例6: testUseZKServiceForBinding

点赞 2

import org.apache.hadoop.registry.client.impl.zk.CuratorService; //导入依赖的package包/类
@Test
public void testUseZKServiceForBinding() throws Throwable {
  CuratorService cs2 = new CuratorService("curator", zookeeper);
  cs2.init(new Configuration());
  cs2.start();
}
 

开发者ID:naver,
项目名称:hadoop,
代码行数:7,
代码来源:TestCuratorService.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)