Example usage for org.apache.hadoop.hdfs DistributedFileSystem setSafeMode

List of usage examples for org.apache.hadoop.hdfs DistributedFileSystem setSafeMode

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs DistributedFileSystem setSafeMode.

Prototype

public boolean setSafeMode(HdfsConstants.SafeModeAction action) throws IOException 

Source Link

Document

Enter, leave or get safe mode.

Usage

From source file:org.apache.accumulo.server.fs.VolumeManagerImpl.java

License:Apache License

@Override
public boolean isReady() throws IOException {
    for (Volume volume : getFileSystems().values()) {
        final FileSystem fs = volume.getFileSystem();

        if (!(fs instanceof DistributedFileSystem))
            continue;

        final DistributedFileSystem dfs = (DistributedFileSystem) fs;

        // Returns true when safemode is on
        if (dfs.setSafeMode(SafeModeAction.SAFEMODE_GET)) {
            return false;
        }//w  w  w  .j a v a2  s.co  m
    }
    return true;
}

From source file:org.apache.ambari.servicemonitor.clients.DFSSafeMode.java

License:Apache License

@Override
protected Operation executeOneOperation() throws IOException {
    Operation operation = new Operation("DFS safemode to " + safeMode);

    started(operation);/*w  ww . java2  s .c o  m*/
    try {
        FileSystem result;
        result = cachedFS.getOrCreate();
        DistributedFileSystem hdfs = (DistributedFileSystem) result;
        if (toggle) {
            boolean currentSM = hdfs.setSafeMode(FSConstants.SafeModeAction.SAFEMODE_GET);
            safeMode = !currentSM;
        }
        hdfs.setSafeMode(safeMode ? FSConstants.SafeModeAction.SAFEMODE_ENTER
                : FSConstants.SafeModeAction.SAFEMODE_LEAVE);
        operation.success();
    } catch (ExitClientRunException e) {
        //propagate this up
        throw e;
    } catch (IOException e) {
        //all other outcomes are failures
        operation.failure(e);
    }
    return operation;
}

From source file:org.apache.ambari.servicemonitor.probes.DfsSafeModeProbe.java

License:Apache License

@Override
public ProbeStatus ping(boolean livePing) {
    ProbeStatus status = new ProbeStatus();
    try {//  ww  w  . j  ava2s  .c o  m
        DistributedFileSystem hdfs = DFSUtils.createUncachedDFS(conf);
        inSafeMode = hdfs.setSafeMode(FSConstants.SafeModeAction.SAFEMODE_GET);
        boolean live = !inSafeMode;
        if (inSafeMode) {
            if (ignoreSafeModeManuallyTriggered) {
                live = safeModeExitedOnce;
            }
        } else {
            //it's easier to always set this on a live NN than it is to track whether there's just
            //been a state transition.
            safeModeExitedOnce = true;
        }
        status.succeed(this);
        status.setSuccess(live);
        status.setMessage(hdfs.getUri() + " up - safe mode state " + inSafeMode);
    } catch (IOException e) {
        status.fail(this, e);
    }
    return status;
}

From source file:org.apache.whirr.examples.HadoopClusterExample.java

License:Apache License

private void waitToExitSafeMode(JobClient client) throws IOException {
    LOG.info("Waiting to exit safe mode...");
    FileSystem fs = client.getFs();
    DistributedFileSystem dfs = (DistributedFileSystem) fs;
    boolean inSafeMode = true;
    while (inSafeMode) {
        inSafeMode = dfs.setSafeMode(FSConstants.SafeModeAction.SAFEMODE_GET);
        try {/*  w  ww .ja v  a  2 s. co  m*/
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            break;
        }
    }
    LOG.info("Exited safe mode");
}

From source file:org.apache.whirr.service.hadoop.integration.HadoopServiceController.java

License:Apache License

private static void waitToExitSafeMode(JobClient client) throws IOException {
    LOG.info("Waiting to exit safe mode...");
    FileSystem fs = client.getFs();
    DistributedFileSystem dfs = (DistributedFileSystem) fs;
    boolean inSafeMode = true;
    while (inSafeMode) {
        inSafeMode = dfs.setSafeMode(FSConstants.SafeModeAction.SAFEMODE_GET);
        try {/*from www. j  av  a 2  s .  c o m*/
            System.out.print(".");
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            break;
        }
    }
    LOG.info("Exited safe mode");
}