gpt4 book ai didi

org.apache.hadoop.hbase.zookeeper.ZKUtil.connect()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 02:40:40 27 4
gpt4 key购买 nike

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

ZKUtil.connect介绍

[英]Creates a new connection to ZooKeeper, pulling settings and ensemble config from the specified configuration object using methods from ZKConfig. Sets the connection status monitoring watcher to the specified watcher.
[中]创建到ZooKeeper的新连接,使用ZKConfig中的方法从指定的配置对象中提取设置和集合配置。将连接状态监视监视程序设置为指定的监视程序。

代码示例

代码示例来源:origin: apache/hbase

public static RecoverableZooKeeper connect(Configuration conf, String ensemble,
  Watcher watcher)
 throws IOException {
 return connect(conf, ensemble, watcher, null);
}

代码示例来源:origin: apache/hbase

/**
 * Creates a new connection to ZooKeeper, pulling settings and ensemble config
 * from the specified configuration object using methods from {@link ZKConfig}.
 *
 * Sets the connection status monitoring watcher to the specified watcher.
 *
 * @param conf configuration to pull ensemble and other settings from
 * @param watcher watcher to monitor connection changes
 * @return connection to zookeeper
 * @throws IOException if unable to connect to zk or config problem
 */
public static RecoverableZooKeeper connect(Configuration conf, Watcher watcher)
 throws IOException {
 String ensemble = ZKConfig.getZKQuorumServersString(conf);
 return connect(conf, ensemble, watcher);
}

代码示例来源:origin: apache/hbase

private void testZNodeACLs() throws IOException, KeeperException, InterruptedException {
 ZKWatcher watcher = new ZKWatcher(conf, "IntegrationTestZnodeACLs", null);
 RecoverableZooKeeper zk = ZKUtil.connect(this.conf, watcher);
 String baseZNode = watcher.getZNodePaths().baseZNode;
 LOG.info("");
 LOG.info("***********************************************************************************");
 LOG.info("Checking ZK permissions, root znode: " + baseZNode);
 LOG.info("***********************************************************************************");
 LOG.info("");
 checkZnodePermsRecursive(watcher, zk, baseZNode);
 LOG.info("Checking ZK permissions: SUCCESS");
}

代码示例来源:origin: apache/hbase

this.znodePaths = new ZNodePaths(conf);
PendingWatcher pendingWatcher = new PendingWatcher();
this.recoverableZooKeeper = ZKUtil.connect(conf, quorum, pendingWatcher, identifier);
pendingWatcher.prepare(this);
if (canCreateBaseZNode) {

代码示例来源:origin: apache/hbase

@Test
public void testSetDataVersionMismatchInLoop() throws Exception {
 String znode = "/hbase/splitWAL/9af7cfc9b15910a0b3d714bf40a3248f";
 Configuration conf = TEST_UTIL.getConfiguration();
 ZKWatcher zkw = new ZKWatcher(conf, "testSetDataVersionMismatchInLoop",
   abortable, true);
 String ensemble = ZKConfig.getZKQuorumServersString(conf);
 RecoverableZooKeeper rzk = ZKUtil.connect(conf, ensemble, zkw);
 rzk.create(znode, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
 rzk.setData(znode, "OPENING".getBytes(), 0);
 Field zkField = RecoverableZooKeeper.class.getDeclaredField("zk");
 zkField.setAccessible(true);
 int timeout = conf.getInt(HConstants.ZK_SESSION_TIMEOUT, HConstants.DEFAULT_ZK_SESSION_TIMEOUT);
 ZookeeperStub zkStub = new ZookeeperStub(ensemble, timeout, zkw);
 zkStub.setThrowExceptionInNumOperations(1);
 zkField.set(rzk, zkStub);
 byte[] opened = "OPENED".getBytes();
 rzk.setData(znode, opened, 1);
 byte[] data = rzk.getData(znode, false, new Stat());
 assertTrue(Bytes.equals(opened, data));
}

代码示例来源:origin: co.cask.hbase/hbase

public static RecoverableZooKeeper connect(Configuration conf, String ensemble,
  Watcher watcher)
throws IOException {
 return connect(conf, ensemble, watcher, "");
}

代码示例来源:origin: org.apache.hbase/hbase-zookeeper

public static RecoverableZooKeeper connect(Configuration conf, String ensemble,
  Watcher watcher)
 throws IOException {
 return connect(conf, ensemble, watcher, null);
}

代码示例来源:origin: harbby/presto-connectors

public static RecoverableZooKeeper connect(Configuration conf, String ensemble,
  Watcher watcher)
throws IOException {
 return connect(conf, ensemble, watcher, null);
}

代码示例来源:origin: org.apache.hbase/hbase-zookeeper

/**
 * Creates a new connection to ZooKeeper, pulling settings and ensemble config
 * from the specified configuration object using methods from {@link ZKConfig}.
 *
 * Sets the connection status monitoring watcher to the specified watcher.
 *
 * @param conf configuration to pull ensemble and other settings from
 * @param watcher watcher to monitor connection changes
 * @return connection to zookeeper
 * @throws IOException if unable to connect to zk or config problem
 */
public static RecoverableZooKeeper connect(Configuration conf, Watcher watcher)
 throws IOException {
 String ensemble = ZKConfig.getZKQuorumServersString(conf);
 return connect(conf, ensemble, watcher);
}

代码示例来源:origin: harbby/presto-connectors

/**
 * Creates a new connection to ZooKeeper, pulling settings and ensemble config
 * from the specified configuration object using methods from {@link ZKConfig}.
 *
 * Sets the connection status monitoring watcher to the specified watcher.
 *
 * @param conf configuration to pull ensemble and other settings from
 * @param watcher watcher to monitor connection changes
 * @return connection to zookeeper
 * @throws IOException if unable to connect to zk or config problem
 */
public static RecoverableZooKeeper connect(Configuration conf, Watcher watcher)
throws IOException {
 String ensemble = ZKConfig.getZKQuorumServersString(conf);
 return connect(conf, ensemble, watcher);
}

代码示例来源:origin: co.cask.hbase/hbase

/**
 * Creates a new connection to ZooKeeper, pulling settings and ensemble config
 * from the specified configuration object using methods from {@link ZKConfig}.
 *
 * Sets the connection status monitoring watcher to the specified watcher.
 *
 * @param conf configuration to pull ensemble and other settings from
 * @param watcher watcher to monitor connection changes
 * @return connection to zookeeper
 * @throws IOException if unable to connect to zk or config problem
 */
public static RecoverableZooKeeper connect(Configuration conf, Watcher watcher)
throws IOException {
 Properties properties = ZKConfig.makeZKProps(conf);
 String ensemble = ZKConfig.getZKQuorumServersString(properties);
 return connect(conf, ensemble, watcher);
}

代码示例来源:origin: co.cask.hbase/hbase

/**
 * Instantiate a ZooKeeper connection and watcher.
 * @param descriptor Descriptive string that is added to zookeeper sessionid
 * and used as identifier for this instance.
 * @throws IOException
 * @throws ZooKeeperConnectionException
 */
public ZooKeeperWatcher(Configuration conf, String descriptor,
  Abortable abortable, boolean canCreateBaseZNode)
throws IOException, ZooKeeperConnectionException {
 this.conf = conf;
 // Capture a stack trace now.  Will print it out later if problem so we can
 // distingush amongst the myriad ZKWs.
 try {
  throw new Exception("ZKW CONSTRUCTOR STACK TRACE FOR DEBUGGING");
 } catch (Exception e) {
  this.constructorCaller = e;
 }
 this.quorum = ZKConfig.getZKQuorumServersString(conf);
 // Identifier will get the sessionid appended later below down when we
 // handle the syncconnect event.
 this.identifier = descriptor;
 this.abortable = abortable;
 setNodeNames(conf);
 this.recoverableZooKeeper = ZKUtil.connect(conf, quorum, this, descriptor);
 if (canCreateBaseZNode) {
  createBaseZNodes();
 }
}

代码示例来源:origin: org.apache.hbase/hbase-it

private void testZNodeACLs() throws IOException, KeeperException, InterruptedException {
 ZKWatcher watcher = new ZKWatcher(conf, "IntegrationTestZnodeACLs", null);
 RecoverableZooKeeper zk = ZKUtil.connect(this.conf, watcher);
 String baseZNode = watcher.getZNodePaths().baseZNode;
 LOG.info("");
 LOG.info("***********************************************************************************");
 LOG.info("Checking ZK permissions, root znode: " + baseZNode);
 LOG.info("***********************************************************************************");
 LOG.info("");
 checkZnodePermsRecursive(watcher, zk, baseZNode);
 LOG.info("Checking ZK permissions: SUCCESS");
}

代码示例来源:origin: harbby/presto-connectors

this.abortable = abortable;
setNodeNames(conf);
this.recoverableZooKeeper = ZKUtil.connect(conf, quorum, this, identifier);
if (canCreateBaseZNode) {
 createBaseZNodes();

代码示例来源:origin: org.apache.hbase/hbase-zookeeper

this.znodePaths = new ZNodePaths(conf);
PendingWatcher pendingWatcher = new PendingWatcher();
this.recoverableZooKeeper = ZKUtil.connect(conf, quorum, pendingWatcher, identifier);
pendingWatcher.prepare(this);
if (canCreateBaseZNode) {

代码示例来源:origin: org.apache.hbase/hbase-zookeeper

@Test
public void testSetDataVersionMismatchInLoop() throws Exception {
 String znode = "/hbase/splitWAL/9af7cfc9b15910a0b3d714bf40a3248f";
 Configuration conf = TEST_UTIL.getConfiguration();
 ZKWatcher zkw = new ZKWatcher(conf, "testSetDataVersionMismatchInLoop",
   abortable, true);
 String ensemble = ZKConfig.getZKQuorumServersString(conf);
 RecoverableZooKeeper rzk = ZKUtil.connect(conf, ensemble, zkw);
 rzk.create(znode, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
 rzk.setData(znode, "OPENING".getBytes(), 0);
 Field zkField = RecoverableZooKeeper.class.getDeclaredField("zk");
 zkField.setAccessible(true);
 int timeout = conf.getInt(HConstants.ZK_SESSION_TIMEOUT, HConstants.DEFAULT_ZK_SESSION_TIMEOUT);
 ZookeeperStub zkStub = new ZookeeperStub(ensemble, timeout, zkw);
 zkStub.setThrowExceptionInNumOperations(1);
 zkField.set(rzk, zkStub);
 byte[] opened = "OPENED".getBytes();
 rzk.setData(znode, opened, 1);
 byte[] data = rzk.getData(znode, false, new Stat());
 assertTrue(Bytes.equals(opened, data));
}

代码示例来源:origin: com.aliyun.hbase/alihbase-zookeeper

@Test
public void testSetDataVersionMismatchInLoop() throws Exception {
 String znode = "/hbase/splitWAL/9af7cfc9b15910a0b3d714bf40a3248f";
 Configuration conf = TEST_UTIL.getConfiguration();
 ZKWatcher zkw = new ZKWatcher(conf, "testSetDataVersionMismatchInLoop",
   abortable, true);
 String ensemble = ZKConfig.getZKQuorumServersString(conf);
 RecoverableZooKeeper rzk = ZKUtil.connect(conf, ensemble, zkw);
 rzk.create(znode, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
 rzk.setData(znode, "OPENING".getBytes(), 0);
 Field zkField = RecoverableZooKeeper.class.getDeclaredField("zk");
 zkField.setAccessible(true);
 int timeout = conf.getInt(HConstants.ZK_SESSION_TIMEOUT, HConstants.DEFAULT_ZK_SESSION_TIMEOUT);
 ZookeeperStub zkStub = new ZookeeperStub(ensemble, timeout, zkw);
 zkStub.setThrowExceptionInNumOperations(1);
 zkField.set(rzk, zkStub);
 byte[] opened = "OPENED".getBytes();
 rzk.setData(znode, opened, 1);
 byte[] data = rzk.getData(znode, false, new Stat());
 assertTrue(Bytes.equals(opened, data));
}

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