Java Code Examples for org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper#exists()

The following examples show how to use org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper#exists() . 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: ZkUtils.java    From spliceengine with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 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 2
Source File: OlapServerSubmitter.java    From spliceengine with GNU Affero General Public License v3.0 6 votes vote down vote up
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
    }
}
 
Example 3
Source File: OlapServerMaster.java    From spliceengine with GNU Affero General Public License v3.0 6 votes vote down vote up
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
    }
}
 
Example 4
Source File: ZkUtils.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
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;
}
 
Example 5
Source File: BackupUtils.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
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 vote down vote up
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 vote down vote up
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;

}
 
Example 8
Source File: ZkUtils.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
public static boolean isSpliceLoaded() throws InterruptedException, KeeperException{
    RecoverableZooKeeper rzk=getRecoverableZooKeeper();
    String path=HConfiguration.getConfiguration().getSpliceRootPath()+HConfiguration.STARTUP_PATH;
    return rzk.exists(path,false)!=null;
}
 
Example 9
Source File: BackupUtils.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
public static boolean backupInProgress() throws Exception {
    String path = BackupUtils.getBackupPath();
    RecoverableZooKeeper zooKeeper = ZkUtils.getRecoverableZooKeeper();
    Stat stat = zooKeeper.exists(path, false);
    return (stat != null);
}
 
Example 10
Source File: BackupUtils.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
public static boolean backupCanceled() throws KeeperException, InterruptedException {
    RecoverableZooKeeper zooKeeper = ZkUtils.getRecoverableZooKeeper();
    String path = BackupUtils.getBackupPath();
    return zooKeeper.exists(path, false) == null;
}
 
Example 11
Source File: ReplicationMonitorChore.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
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();
}