@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); } }
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; }
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; }
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); }
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; } }
@Override public ZKWatcher getZooKeeper() { try { return new ZKWatcher(getConfiguration(), "dummy server", this); } catch (IOException e) { e.printStackTrace(); } return null; }
@Override public ZKWatcher getZooKeeper() { try { return new ZKWatcher(getConfiguration(), "dummy server", this); } catch (IOException e) { e.printStackTrace(); } return null; }
@Override public ZKWatcher getZooKeeper() { try { return new ZKWatcher(getConfiguration(), "dummy server", this); } catch (IOException e) { e.printStackTrace(); } return null; }
/** * @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); }
@Override public ZKWatcher getZooKeeper() { try { return new ZKWatcher(getConfiguration(), "dummy server", this); } catch (IOException e) { e.printStackTrace(); } return null; }
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(); } }
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); }
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"); }
@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())); }
/** * @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; }
@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())); }
/** * 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)); }
@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); }
@BeforeClass public static void setUp() throws Exception { UTIL.startMiniZKCluster().getClientPort(); ZKW = new ZKWatcher(new Configuration(UTIL.getConfiguration()), TestZKUtil.class.getName(), new WarnOnlyAbortable()); }
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); }