org.apache.hadoop.hbase.zookeeper.ZKWatcher.<init>()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(134)

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

ZKWatcher.<init>介绍

[英]Instantiate a ZooKeeper connection and watcher.
[中]实例化ZooKeeper连接和监视程序。

代码示例

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

@Override
public void setConf(Configuration config) {
 // Make my own Configuration.  Then I'll have my own connection to zk that
 // I can close myself when comes time.
 Configuration conf = new Configuration(config);
 try {
  setConf(conf, new ZKWatcher(conf, "replicationLogCleaner", null));
 } catch (IOException e) {
  LOG.error("Error while configuring " + this.getClass().getName(), e);
 }
}

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

private static ZKWatcher newZK(Configuration conf, String name,
                Abortable abort) throws Exception {
 Configuration copy = HBaseConfiguration.create(conf);
 ZKWatcher zk = new ZKWatcher(copy, name, abort);
 return zk;
}

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

private static ZKWatcher newZK(Configuration conf, String name,
                Abortable abort) throws Exception {
 Configuration copy = HBaseConfiguration.create(conf);
 ZKWatcher zk = new ZKWatcher(copy, name, abort);
 return zk;
}

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

public HFileArchiveManager(Connection connection, Configuration conf)
  throws ZooKeeperConnectionException, IOException {
 this.zooKeeper = new ZKWatcher(conf, "hfileArchiveManager-on-" + connection.toString(),
   connection);
 this.archiveZnode = ZKTableArchiveClient.getArchiveZNode(this.zooKeeper.getConfiguration(),
  this.zooKeeper);
}

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

private static ZKWatcher newZK(Configuration conf, String name,
                 Abortable abort) throws Exception {
  Configuration copy = HBaseConfiguration.create(conf);
  ZKWatcher zk = new ZKWatcher(copy, name, abort);
  return zk;
 }
}

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

@Override
public ZKWatcher getZooKeeper() {
 try {
  return new ZKWatcher(getConfiguration(), "dummy server", this);
 } catch (IOException e) {
  e.printStackTrace();
 }
 return null;
}

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

@Override
public ZKWatcher getZooKeeper() {
 try {
  return new ZKWatcher(getConfiguration(), "dummy server", this);
 } catch (IOException e) {
  e.printStackTrace();
 }
 return null;
}

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

@Override
public ZKWatcher getZooKeeper() {
 try {
  return new ZKWatcher(getConfiguration(), "dummy server", this);
 } catch (IOException e) {
  e.printStackTrace();
 }
 return null;
}

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

/**
 * @param sn Name of this mock regionserver
 * @throws IOException
 * @throws org.apache.hadoop.hbase.ZooKeeperConnectionException
 */
MockRegionServer(final Configuration conf, final ServerName sn)
throws ZooKeeperConnectionException, IOException {
 this.sn = sn;
 this.conf = conf;
 this.zkw = new ZKWatcher(conf, sn.toString(), this, true);
}

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

@Override
public ZKWatcher getZooKeeper() {
 try {
  return new ZKWatcher(getConfiguration(), "dummy server", this);
 } catch (IOException e) {
  e.printStackTrace();
 }
 return null;
}

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

private static void resetAcls(final Configuration conf, boolean eraseAcls)
  throws Exception {
 ZKWatcher zkw = new ZKWatcher(conf, "ZKAclReset", null);
 try {
  LOG.info((eraseAcls ? "Erase" : "Set") + " HBase ACLs for " +
       zkw.getQuorum() + " " + zkw.getZNodePaths().baseZNode);
  resetAcls(zkw, zkw.getZNodePaths().baseZNode, eraseAcls);
 } finally {
  zkw.close();
 }
}

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

public VerifyingRSGroupAdminClient(RSGroupAdmin RSGroupAdmin, Configuration conf)
  throws IOException {
 wrapped = RSGroupAdmin;
 table = ConnectionFactory.createConnection(conf)
     .getTable(RSGroupInfoManager.RSGROUP_TABLE_NAME);
 zkw = new ZKWatcher(conf, this.getClass().getSimpleName(), null);
}

代码示例来源: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

@Test
public void testUnsecure() throws ZooKeeperConnectionException, IOException {
 Configuration conf = HBaseConfiguration.create();
 conf.set(Superusers.SUPERUSER_CONF_KEY, "user1");
 String node = "/hbase/testUnsecure";
 ZKWatcher watcher = new ZKWatcher(conf, node, null, false);
 List<ACL> aclList = ZKUtil.createACL(watcher, node, false);
 assertEquals(1, aclList.size());
 assertTrue(aclList.contains(Ids.OPEN_ACL_UNSAFE.iterator().next()));
}

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

/**
 * @param htu Testing utility to use
 * @param zkw If true, create a zkw.
 * @throws ZooKeeperConnectionException
 * @throws IOException
 */
public MockServer(final HBaseTestingUtility htu, final boolean zkw)
throws ZooKeeperConnectionException, IOException {
 this.htu = htu;
 this.zk = zkw?
  new ZKWatcher(htu.getConfiguration(), NAME.toString(), this, true):
  null;
}

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

@Test
public void testSecuritySingleSuperuser() throws ZooKeeperConnectionException, IOException {
 Configuration conf = HBaseConfiguration.create();
 conf.set(Superusers.SUPERUSER_CONF_KEY, "user1");
 String node = "/hbase/testSecuritySingleSuperuser";
 ZKWatcher watcher = new ZKWatcher(conf, node, null, false);
 List<ACL> aclList = ZKUtil.createACL(watcher, node, true);
 assertEquals(2, aclList.size()); // 1+1, since ACL will be set for the creator by default
 assertTrue(aclList.contains(new ACL(Perms.ALL, new Id("sasl", "user1"))));
 assertTrue(aclList.contains(Ids.CREATOR_ALL_ACL.iterator().next()));
}

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

/**
 * Closes the current ZKW (if not null) and creates a new one
 * @throws IOException If anything goes wrong connecting
 */
synchronized void reloadZkWatcher() throws IOException {
 if (zkw != null) zkw.close();
 zkw = new ZKWatcher(ctx.getConfiguration(),
   "connection to cluster: " + ctx.getPeerId(), this);
 getZkw().registerListener(new PeerRegionServerListener(this));
}

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

@BeforeClass
public static void beforeClass() throws Exception {
 // setup configuration
 Configuration conf = UTIL.getConfiguration();
 SecureTestUtil.enableSecurity(conf);
 // start minicluster
 UTIL.startMiniCluster();
 AUTH_A = AuthManager.getOrCreate(new ZKWatcher(conf,
  "TestZKPermissionsWatcher_1", ABORTABLE), conf);
 AUTH_B = AuthManager.getOrCreate(new ZKWatcher(conf,
  "TestZKPermissionsWatcher_2", ABORTABLE), conf);
}

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

@BeforeClass
public static void setUp() throws Exception {
 UTIL.startMiniZKCluster().getClientPort();
 ZKW = new ZKWatcher(new Configuration(UTIL.getConfiguration()), TestZKUtil.class.getName(),
   new WarnOnlyAbortable());
}

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

private static String initPeerClusterState(String baseZKNode)
  throws IOException, KeeperException {
 // Add a dummy region server and set up the cluster id
 Configuration testConf = new Configuration(conf);
 testConf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, baseZKNode);
 ZKWatcher zkw1 = new ZKWatcher(testConf, "test1", null);
 String fakeRs = ZNodePaths.joinZNode(zkw1.getZNodePaths().rsZNode,
     "hostname1.example.org:1234");
 ZKUtil.createWithParents(zkw1, fakeRs);
 ZKClusterId.setClusterId(zkw1, new ClusterId());
 return ZKConfig.getZooKeeperClusterKey(testConf);
}

相关文章