org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper#exists ( )源码实例Demo

下面列出了org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper#exists ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: spliceengine   文件: ZkUtils.java
/**
 * 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);
        }
    }
}
 
源代码2 项目: spliceengine   文件: OlapServerSubmitter.java
private void reportDiagnostics(String diagnostics) {
    try {
        RecoverableZooKeeper rzk = ZkUtils.getRecoverableZooKeeper();
        String root = HConfiguration.getConfiguration().getSpliceRootPath();

        String diagnosticsPath = root + HBaseConfiguration.OLAP_SERVER_PATH + HBaseConfiguration.OLAP_SERVER_DIAGNOSTICS_PATH + "/" + queueName;

        if (rzk.exists(diagnosticsPath, false) != null) {
            rzk.setData(diagnosticsPath, Bytes.toBytes(diagnostics), -1);
        } else {
            rzk.create(diagnosticsPath, Bytes.toBytes(diagnostics), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        }
    } catch (Exception e) {
        LOG.error("Exception while trying to report diagnostics", e);
        // ignore this exception during error reporting
    }
}
 
源代码3 项目: spliceengine   文件: OlapServerMaster.java
private void reportDiagnostics(String diagnostics) {
    try {
        RecoverableZooKeeper rzk = ZkUtils.getRecoverableZooKeeper();
        String root = HConfiguration.getConfiguration().getSpliceRootPath();

        String diagnosticsRoot = root + HBaseConfiguration.OLAP_SERVER_PATH + HBaseConfiguration.OLAP_SERVER_DIAGNOSTICS_PATH;
        zkSafeCreate(diagnosticsRoot);
        String diagnosticsPath = diagnosticsRoot + "/spark-" + queueName;

        if (rzk.exists(diagnosticsPath, false) != null) {
            rzk.setData(diagnosticsPath, com.splicemachine.primitives.Bytes.toBytes(diagnostics), -1);
        } else {
            rzk.create(diagnosticsPath, com.splicemachine.primitives.Bytes.toBytes(diagnostics), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        }
    } catch (Exception e) {
        LOG.error("Exception while trying to report diagnostics", e);
        // ignore this exception during error reporting
    }
}
 
源代码4 项目: spliceengine   文件: ZkUtils.java
public static boolean validZookeeper() throws InterruptedException, KeeperException{
    RecoverableZooKeeper rzk=getRecoverableZooKeeper();

    String rootPath=HConfiguration.getConfiguration().getSpliceRootPath();
    for(String path : HConfiguration.zookeeperPaths){
        if(rzk.exists(rootPath+path,false)==null)
            return false;
    }
    return true;
}
 
源代码5 项目: spliceengine   文件: BackupUtils.java
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);
    }
}
 
源代码6 项目: spliceengine   文件: ReplicationMonitorChore.java
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;
}
 
源代码7 项目: spliceengine   文件: ReplicationMonitorChore.java
private boolean involvedInReplication() throws InterruptedException, KeeperException{
    RecoverableZooKeeper rzk = zkWatcher.getRecoverableZooKeeper();
    String masterPath = replicationMonitorPath + "/master/" + thisCluster;
    String peerPath = replicationMonitorPath + "/peers/" + thisCluster;
    return rzk.exists(masterPath, false) != null || rzk.exists(peerPath, false) != null;

}
 
源代码8 项目: spliceengine   文件: ZkUtils.java
public static boolean isSpliceLoaded() throws InterruptedException, KeeperException{
    RecoverableZooKeeper rzk=getRecoverableZooKeeper();
    String path=HConfiguration.getConfiguration().getSpliceRootPath()+HConfiguration.STARTUP_PATH;
    return rzk.exists(path,false)!=null;
}
 
源代码9 项目: spliceengine   文件: BackupUtils.java
public static boolean backupInProgress() throws Exception {
    String path = BackupUtils.getBackupPath();
    RecoverableZooKeeper zooKeeper = ZkUtils.getRecoverableZooKeeper();
    Stat stat = zooKeeper.exists(path, false);
    return (stat != null);
}
 
源代码10 项目: spliceengine   文件: BackupUtils.java
public static boolean backupCanceled() throws KeeperException, InterruptedException {
    RecoverableZooKeeper zooKeeper = ZkUtils.getRecoverableZooKeeper();
    String path = BackupUtils.getBackupPath();
    return zooKeeper.exists(path, false) == null;
}
 
源代码11 项目: spliceengine   文件: ReplicationMonitorChore.java
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();
}