Java Code Examples for org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper#getChildren()
The following examples show how to use
org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper#getChildren() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IntegrationTestZKAndFSPermissions.java From hbase with Apache License 2.0 | 6 votes |
private void checkZnodePermsRecursive(ZKWatcher watcher, RecoverableZooKeeper zk, String znode) throws KeeperException, InterruptedException { boolean expectedWorldReadable = watcher.getZNodePaths().isClientReadable(znode); assertZnodePerms(zk, znode, expectedWorldReadable); try { List<String> children = zk.getChildren(znode, false); for (String child : children) { checkZnodePermsRecursive(watcher, zk, ZNodePaths.joinZNode(znode, child)); } } catch (KeeperException ke) { // if we are not authenticated for listChildren, it is fine. if (ke.code() != Code.NOAUTH && ke.code() != Code.NONODE) { throw ke; } } }
Example 2
Source File: ZkUtils.java From spliceengine with GNU Affero General Public License v3.0 | 6 votes |
/** * Deletes just the splice-specific paths in zookeeper. Does not delete hbase paths. */ public static void cleanZookeeper() throws InterruptedException, KeeperException{ RecoverableZooKeeper rzk=getRecoverableZooKeeper(); String rootPath=HConfiguration.getConfiguration().getSpliceRootPath(); for(String path : HConfiguration.zookeeperPaths){ path=rootPath+path; if(rzk.exists(path,false)!=null){ for(String child : rzk.getChildren(path,false)){ for(String grandChild : rzk.getChildren(path+"/"+child,false)){ rzk.delete(path+"/"+child+"/"+grandChild,-1); } rzk.delete(path+"/"+child,-1); } rzk.delete(path,-1); } } }
Example 3
Source File: ReplicationUtils.java From spliceengine with GNU Affero General Public License v3.0 | 6 votes |
public static void disableMaster(String masterClusterKey) throws InterruptedException, KeeperException, IOException { // Delete all peers from master cluster Configuration conf = ReplicationUtils.createConfiguration(masterClusterKey); ZKWatcher masterZkw = new ZKWatcher(conf, "replication monitor", null, false); RecoverableZooKeeper masterRzk = masterZkw.getRecoverableZooKeeper(); String[] s = masterClusterKey.split(":"); String hbaseRootDir = s[2]; String peerPath = hbaseRootDir+"/replication/peers"; List<String> peers = masterRzk.getChildren(peerPath, false); for (String peer : peers) { String p = peerPath + "/" + peer; List<String> children = masterRzk.getChildren(p, false); String peerStatePath = p + "/" + children.get(0); masterRzk.setData(peerStatePath, toByteArray(ReplicationProtos.ReplicationState.State.DISABLED), -1); System.out.println("Disabled peer " + peer); } }
Example 4
Source File: ZkUtils.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
public static List<String> getChildren(String path,boolean watch, RecoverableZooKeeper rzk) throws IOException{ try{ return rzk.getChildren(path,watch); }catch(InterruptedException | KeeperException e){ throw new IOException(e); } }
Example 5
Source File: BackupUtils.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
public static boolean shouldCaptureIncrementalChanges(FileSystem fs,Path rootDir) throws StandardException{ boolean shouldRegister = false; try { boolean enabled = incrementalBackupEnabled(); if (enabled) { RecoverableZooKeeper zooKeeper = ZkUtils.getRecoverableZooKeeper(); String spliceBackupPath = BackupUtils.getBackupPath(); if (zooKeeper.exists(spliceBackupPath, false)==null){ return false; } boolean isRestoreMode = SIDriver.driver().lifecycleManager().isRestoreMode(); if (!isRestoreMode) { if (BackupUtils.existsDatabaseBackup(fs, rootDir)) { if (LOG.isDebugEnabled()) { SpliceLogUtils.debug(LOG, "There exists a successful full or incremental backup in the system"); } shouldRegister = true; } else { List<String> backupJobs = zooKeeper.getChildren(spliceBackupPath, false); for (String backupId : backupJobs) { String path = spliceBackupPath + "/" + backupId; byte[] data = zooKeeper.getData(path, false, null); BackupJobStatus status = BackupJobStatus.parseFrom(data); if (status.getScope() == BackupJobStatus.BackupScope.DATABASE) { if (LOG.isDebugEnabled()) { SpliceLogUtils.debug(LOG, "A database backup is running"); } shouldRegister = true; } } } } } return shouldRegister; } catch (Exception e) { e.printStackTrace(); throw StandardException.plainWrapException(e); } }
Example 6
Source File: ReplicationMonitorChore.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
private String getMasterCluster() throws InterruptedException, KeeperException{ RecoverableZooKeeper rzk = zkWatcher.getRecoverableZooKeeper(); String path = replicationMonitorPath + "/master"; if (rzk.exists(path, false) != null) { List<String> children = rzk.getChildren(path, false); return children.size() > 0 ? children.get(0) : null; } return null; }
Example 7
Source File: ReplicationMonitorChore.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
private boolean isMasterReachable() { String masterClusterKey = getClusterKey(masterCluster); Configuration conf = ReplicationUtils.createConfiguration(masterClusterKey); try (ZKWatcher masterZkw = new ZKWatcher(conf, "replication monitor", null, false)) { String[] s = masterClusterKey.split(":"); RecoverableZooKeeper rzk = masterZkw.getRecoverableZooKeeper(); List<String> children = rzk.getChildren(s[2], false); return true; } catch (Exception e) { return false; } }
Example 8
Source File: ReplicationUtils.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
public static List<String> getRegionServers(Configuration conf) throws IOException, InterruptedException, KeeperException{ try(ZKWatcher zkWatcher = new ZKWatcher(conf, "replication monitor", null, false)) { RecoverableZooKeeper zk = zkWatcher.getRecoverableZooKeeper(); List<String> servers = zk.getChildren("/splice/servers", false); return servers; } }
Example 9
Source File: ReplicationMonitorChore.java From spliceengine with GNU Affero General Public License v3.0 | 4 votes |
private List<String> getReplicationPeers() throws KeeperException, InterruptedException { RecoverableZooKeeper rzk = zkWatcher.getRecoverableZooKeeper(); String path = replicationMonitorPath + "/peers"; return rzk.exists(path, false) != null ? rzk.getChildren(path, false) : Lists.newArrayList(); }