org.apache.hadoop.fs.FileUtil.fullyDelete() - java examples

Here are the examples of the java api org.apache.hadoop.fs.FileUtil.fullyDelete() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

155 Examples 7

19 View Complete Implementation : UpgradeUtilities.java
Copyright Apache License 2.0
Author : apache
/**
 * Create empty directories.  If a specified directory already exists
 * then it is first removed.
 */
public static void createEmptyDirs(String[] dirs) throws IOException {
    for (String d : dirs) {
        File dir = new File(d);
        if (dir.exists()) {
            FileUtil.fullyDelete(dir);
        }
        dir.mkdirs();
    }
}

19 View Complete Implementation : TestNMWebServices.java
Copyright Apache License 2.0
Author : apache
@AfterClreplaced
static public void stop() {
    FileUtil.fullyDelete(testRootDir);
    FileUtil.fullyDelete(testLogDir);
    FileUtil.fullyDelete(testRemoteLogDir);
}

19 View Complete Implementation : TestNMWebServicesAuxServices.java
Copyright Apache License 2.0
Author : apache
@AfterClreplaced
static public void cleanup() {
    FileUtil.fullyDelete(testRootDir);
    FileUtil.fullyDelete(testLogDir);
}

19 View Complete Implementation : TestNMWebServicesApps.java
Copyright Apache License 2.0
Author : apache
@AfterClreplaced
static public void cleanup() {
    FileUtil.fullyDelete(testRootDir);
    FileUtil.fullyDelete(testLogDir);
}

19 View Complete Implementation : TestProcfsBasedProcessTree.java
Copyright Apache License 2.0
Author : apache
/**
 * Verifies ProcfsBasedProcessTree.checkPidPgrpidForMatch() in case of
 * 'constructProcessInfo() returning null' by not writing stat file for the
 * mock process
 *
 * @throws IOException
 *           if there was a problem setting up the fake procfs directories or
 *           files.
 */
@Test(timeout = 30000)
public void testDestroyProcessTree() throws IOException {
    // test process
    String pid = "100";
    // create the fake procfs root directory.
    File procfsRootDir = new File(TEST_ROOT_DIR, "proc");
    try {
        setupProcfsRootDir(procfsRootDir);
        // crank up the process tree clreplaced.
        createProcessTree(pid, procfsRootDir.getAbsolutePath(), SystemClock.getInstance());
        // Let us not create stat file for pid 100.
        replacedert.replacedertTrue(ProcfsBasedProcessTree.checkPidPgrpidForMatch(pid, procfsRootDir.getAbsolutePath()));
    } finally {
        FileUtil.fullyDelete(procfsRootDir);
    }
}

19 View Complete Implementation : BlockPoolSliceStorage.java
Copyright Apache License 2.0
Author : apache
/**
 * Restore all files from the trash directory to their corresponding
 * locations under current/
 */
private int restoreBlockFilesFromTrash(File trashRoot) throws IOException {
    int filesRestored = 0;
    File[] children = trashRoot.exists() ? trashRoot.listFiles() : null;
    if (children == null) {
        return 0;
    }
    File restoreDirectory = null;
    for (File child : children) {
        if (child.isDirectory()) {
            // Recurse to process subdirectories.
            filesRestored += restoreBlockFilesFromTrash(child);
            continue;
        }
        if (restoreDirectory == null) {
            restoreDirectory = new File(getRestoreDirectory(child));
            if (!restoreDirectory.exists() && !restoreDirectory.mkdirs()) {
                throw new IOException("Failed to create directory " + restoreDirectory);
            }
        }
        final File newChild = new File(restoreDirectory, child.getName());
        if (newChild.exists() && newChild.length() >= child.length()) {
            // Failsafe - we should not hit this case but let's make sure
            // we never overwrite a newer version of a block file with an
            // older version.
            LOG.info("Not overwriting {} with smaller file from " + "trash directory. This message can be safely ignored.", newChild);
        } else if (!child.renameTo(newChild)) {
            throw new IOException("Failed to rename " + child + " to " + newChild);
        } else {
            ++filesRestored;
        }
    }
    FileUtil.fullyDelete(trashRoot);
    return filesRestored;
}

19 View Complete Implementation : TestTimelineAuthFilterForV2.java
Copyright Apache License 2.0
Author : apache
@AfterClreplaced
public static void tearDown() throws Exception {
    if (testMiniKDC != null) {
        testMiniKDC.stop();
    }
    FileUtil.fullyDelete(TEST_ROOT_DIR);
}

19 View Complete Implementation : TestNMWebServicesContainers.java
Copyright Apache License 2.0
Author : apache
@AfterClreplaced
static public void cleanup() {
    FileUtil.fullyDelete(testRootDir);
    FileUtil.fullyDelete(testLogDir);
}

19 View Complete Implementation : TestNativeIO.java
Copyright Apache License 2.0
Author : apache
@Before
public void setupTestDir() {
    FileUtil.fullyDelete(TEST_DIR);
    TEST_DIR.mkdirs();
}

19 View Complete Implementation : TestSSLFactory.java
Copyright Apache License 2.0
Author : apache
@BeforeClreplaced
public static void setUp() throws Exception {
    File base = new File(BASEDIR);
    FileUtil.fullyDelete(base);
    base.mkdirs();
}

19 View Complete Implementation : TestProcfsBasedProcessTree.java
Copyright Apache License 2.0
Author : apache
/**
 * Create a directory to mimic the procfs file system's root.
 *
 * @param procfsRootDir
 *          root directory to create.
 * @throws IOException
 *           if could not delete the procfs root directory
 */
public static void setupProcfsRootDir(File procfsRootDir) throws IOException {
    // cleanup any existing process root dir.
    if (procfsRootDir.exists()) {
        replacedert.replacedertTrue(FileUtil.fullyDelete(procfsRootDir));
    }
    // create afresh
    replacedert.replacedertTrue(procfsRootDir.mkdirs());
}

18 View Complete Implementation : TestLeveldbRMStateStore.java
Copyright Apache License 2.0
Author : apache
@After
public void cleanup() throws IOException {
    if (stateStore != null) {
        stateStore.close();
    }
    FileUtil.fullyDelete(TEST_DIR);
}

18 View Complete Implementation : TestTrafficController.java
Copyright Apache License 2.0
Author : apache
@After
public void teardown() {
    FileUtil.fullyDelete(new File(tmpPath));
}

18 View Complete Implementation : TestTaskLog.java
Copyright Apache License 2.0
Author : apache
@AfterClreplaced
public static void cleanup() {
    FileUtil.fullyDelete(new File(testDir));
}

18 View Complete Implementation : TestQueue.java
Copyright Apache License 2.0
Author : apache
@After
public void cleanup() {
    FileUtil.fullyDelete(testDir);
}

18 View Complete Implementation : TestAggregatedLogsBlock.java
Copyright Apache License 2.0
Author : apache
/**
 * Bad user. User 'owner' is trying to read logs without access
 */
@Test
public void testAccessDenied() throws Exception {
    FileUtil.fullyDelete(new File("target/logs"));
    Configuration configuration = getConfiguration();
    writeLogs("target/logs/logs/application_0_0001/container_0_0001_01_000001");
    writeLog(configuration, "owner");
    ByteArrayOutputStream data = new ByteArrayOutputStream();
    PrintWriter printWriter = new PrintWriter(data);
    HtmlBlock html = new HtmlBlockForTest();
    HtmlBlock.Block block = new BlockForTest(html, printWriter, 10, false);
    TFileAggregatedLogsBlockForTest aggregatedBlock = getTFileAggregatedLogsBlockForTest(configuration, "owner", "container_0_0001_01_000001", "localhost:1234");
    aggregatedBlock.render(block);
    block.getWriter().flush();
    String out = data.toString();
    replacedertTrue(out.contains("User [owner] is not authorized to view the logs for enreplacedy"));
}

18 View Complete Implementation : TestTrafficControlBandwidthHandlerImpl.java
Copyright Apache License 2.0
Author : apache
@After
public void teardown() {
    FileUtil.fullyDelete(new File(tmpPath));
}

18 View Complete Implementation : TestJournal.java
Copyright Apache License 2.0
Author : apache
@Before
public void setup() throws Exception {
    FileUtil.fullyDelete(TEST_LOG_DIR);
    conf = new Configuration();
    // Enable fetching edits via RPC
    conf.setBoolean(DFSConfigKeys.DFS_HA_TAILEDITS_INPROGRESS_KEY, true);
    journal = new Journal(conf, TEST_LOG_DIR, JID, StartupOption.REGULAR, mockErrorReporter);
    journal.format(FAKE_NSINFO, false);
}

18 View Complete Implementation : TestMapTask.java
Copyright Apache License 2.0
Author : apache
@After
public void cleanup() throws Exception {
    FileUtil.fullyDelete(TEST_ROOT_DIR);
}

18 View Complete Implementation : RollingFileSystemSinkTestBase.java
Copyright Apache License 2.0
Author : apache
/**
 * Set the date format's timezone to GMT.
 */
@BeforeClreplaced
public static void setup() {
    DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT"));
    FileUtil.fullyDelete(ROOT_TEST_DIR);
}

18 View Complete Implementation : TestHistoryServerLeveldbStateStoreService.java
Copyright Apache License 2.0
Author : apache
@After
public void cleanup() {
    FileUtil.fullyDelete(testDir);
}

18 View Complete Implementation : TestDirectoryCollection.java
Copyright Apache License 2.0
Author : apache
@After
public void teardown() {
    FileUtil.fullyDelete(testDir);
}

18 View Complete Implementation : TestFileOutputCommitter.java
Copyright Apache License 2.0
Author : apache
private void testMapOnlyNoOutputInternal(int version) throws Exception {
    JobConf conf = new JobConf();
    // This is not set on purpose. FileOutputFormat.setOutputPath(conf, outDir);
    conf.set(JobContext.TASK_ATTEMPT_ID, attempt);
    conf.setInt(org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter.FILEOUTPUTCOMMITTER_ALGORITHM_VERSION, version);
    JobContext jContext = new JobContextImpl(conf, taskID.getJobID());
    TaskAttemptContext tContext = new TaskAttemptContextImpl(conf, taskID);
    FileOutputCommitter committer = new FileOutputCommitter();
    // setup
    committer.setupJob(jContext);
    committer.setupTask(tContext);
    if (committer.needsTaskCommit(tContext)) {
        // do commit
        committer.commitTask(tContext);
    }
    committer.commitJob(jContext);
    // validate output
    FileUtil.fullyDelete(new File(outDir.toString()));
}

18 View Complete Implementation : TestStreamingKeyValue.java
Copyright Apache License 2.0
Author : apache
public void runStreamJob(final String outputExpect, boolean ignoreKey) throws Exception {
    String outFileName = "part-00000";
    File outFile = null;
    try {
        try {
            FileUtil.fullyDelete(OUTPUT_DIR.getAbsoluteFile());
        } catch (Exception e) {
        }
        createInput();
        boolean mayExit = false;
        // During tests, the default Configuration will use a local mapred
        // So don't specify -config or -cluster
        job = new StreamJob(genArgs(ignoreKey), mayExit);
        job.go();
        outFile = new File(OUTPUT_DIR, outFileName).getAbsoluteFile();
        String output = StreamUtil.slurp(outFile);
        System.err.println("outEx1=" + outputExpect);
        System.err.println("  out1=" + output);
        replacedertEquals(outputExpect, output);
    } finally {
        INPUT_FILE.delete();
        FileUtil.fullyDelete(OUTPUT_DIR.getAbsoluteFile());
    }
}

18 View Complete Implementation : TestAggregatedLogsBlock.java
Copyright Apache License 2.0
Author : apache
/**
 * Log files was deleted.
 * @throws Exception
 */
@Test
public void testNoLogs() throws Exception {
    FileUtil.fullyDelete(new File("target/logs"));
    Configuration configuration = getConfiguration();
    File f = new File("target/logs/logs/application_0_0001/container_0_0001_01_000001");
    if (!f.exists()) {
        replacedertTrue(f.mkdirs());
    }
    writeLog(configuration, "admin");
    ByteArrayOutputStream data = new ByteArrayOutputStream();
    PrintWriter printWriter = new PrintWriter(data);
    HtmlBlock html = new HtmlBlockForTest();
    HtmlBlock.Block block = new BlockForTest(html, printWriter, 10, false);
    TFileAggregatedLogsBlockForTest aggregatedBlock = getTFileAggregatedLogsBlockForTest(configuration, "admin", "container_0_0001_01_000001", "localhost:1234");
    aggregatedBlock.render(block);
    block.getWriter().flush();
    String out = data.toString();
    replacedertTrue(out.contains("No logs available for container container_0_0001_01_000001"));
}

18 View Complete Implementation : TestMapReduce.java
Copyright Apache License 2.0
Author : apache
@After
public void cleanup() {
    FileUtil.fullyDelete(TEST_DIR);
}

18 View Complete Implementation : TestComparators.java
Copyright Apache License 2.0
Author : apache
@After
public void cleanup() {
    FileUtil.fullyDelete(TEST_DIR);
}

18 View Complete Implementation : TestViewfsFileStatus.java
Copyright Apache License 2.0
Author : apache
@AfterClreplaced
public static void cleanup() throws IOException {
    FileUtil.fullyDelete(TEST_DIR);
}

18 View Complete Implementation : RollingFileSystemSinkTestBase.java
Copyright Apache License 2.0
Author : apache
/**
 * Delete the test directory for this test.
 * @throws IOException thrown if the delete fails
 */
@AfterClreplaced
public static void deleteBaseDir() throws IOException {
    FileUtil.fullyDelete(ROOT_TEST_DIR);
}

18 View Complete Implementation : TestMapReduce.java
Copyright Apache License 2.0
Author : apache
/**
 * Launches all the tasks in order.
 */
public static void main(String[] argv) throws Exception {
    if (argv.length < 2) {
        System.err.println("Usage: TestMapReduce <range> <counts>");
        System.err.println();
        System.err.println("Note: a good test will have a <counts> value" + " that is substantially larger than the <range>");
        return;
    }
    int i = 0;
    range = Integer.parseInt(argv[i++]);
    counts = Integer.parseInt(argv[i++]);
    try {
        launch();
    } finally {
        FileUtil.fullyDelete(TEST_DIR);
    }
}

18 View Complete Implementation : TestDiskFailures.java
Copyright Apache License 2.0
Author : apache
@AfterClreplaced
public static void teardown() {
    if (yarnCluster != null) {
        yarnCluster.stop();
        yarnCluster = null;
    }
    FileUtil.fullyDelete(localFSDirBase);
}

18 View Complete Implementation : TestNMWebServer.java
Copyright Apache License 2.0
Author : apache
@After
public void tearDown() {
    FileUtil.fullyDelete(testRootDir);
    FileUtil.fullyDelete(testLogDir);
}

18 View Complete Implementation : TestLocalDirsHandlerService.java
Copyright Apache License 2.0
Author : apache
@After
public void teardown() {
    FileUtil.fullyDelete(testDir);
}

18 View Complete Implementation : TestAggregatedLogsBlock.java
Copyright Apache License 2.0
Author : apache
/**
 * Reading from logs should succeed and they should be shown in the
 * AggregatedLogsBlock html.
 *
 * @throws Exception
 */
@Test
public void testAggregatedLogsBlock() throws Exception {
    FileUtil.fullyDelete(new File("target/logs"));
    Configuration configuration = getConfiguration();
    writeLogs("target/logs/logs/application_0_0001/container_0_0001_01_000001");
    writeLog(configuration, "admin");
    ByteArrayOutputStream data = new ByteArrayOutputStream();
    PrintWriter printWriter = new PrintWriter(data);
    HtmlBlock html = new HtmlBlockForTest();
    HtmlBlock.Block block = new BlockForTest(html, printWriter, 10, false);
    TFileAggregatedLogsBlockForTest aggregatedBlock = getTFileAggregatedLogsBlockForTest(configuration, "admin", "container_0_0001_01_000001", "localhost:1234");
    aggregatedBlock.render(block);
    block.getWriter().flush();
    String out = data.toString();
    replacedertTrue(out.contains("test log1"));
    replacedertTrue(out.contains("test log2"));
    replacedertTrue(out.contains("test log3"));
}

18 View Complete Implementation : TestMRCJCFileOutputCommitter.java
Copyright Apache License 2.0
Author : apache
@After
public void teardown() {
    FileUtil.fullyDelete(new File(outDir.toString()));
}

18 View Complete Implementation : TestMapOutputType.java
Copyright Apache License 2.0
Author : apache
@After
public void cleanup() {
    FileUtil.fullyDelete(TEST_DIR);
}

18 View Complete Implementation : TestNetworkPacketTaggingHandlerImpl.java
Copyright Apache License 2.0
Author : apache
@After
public void teardown() {
    FileUtil.fullyDelete(new File(tmpPath));
}

18 View Complete Implementation : TestStandbyCheckpoints.java
Copyright Apache License 2.0
Author : apache
/**
 * Test that checkpointing is still successful even if an issue
 * was encountered while writing the legacy OIV image.
 */
@Test(timeout = 300000)
public void testCheckpointSucceedsWithLegacyOIVException() throws Exception {
    // Delete the OIV image dir to cause an IOException while saving
    FileUtil.fullyDelete(tmpOivImgDir);
    doEdits(0, 10);
    HATestUtil.waitForStandbyToCatchUp(nns[0], nns[1]);
    // Once the standby catches up, it should notice that it needs to
    // do a checkpoint and save one to its local directories.
    HATestUtil.waitForCheckpoint(cluster, 1, ImmutableList.of(12));
    // It should also upload it back to the active.
    HATestUtil.waitForCheckpoint(cluster, 0, ImmutableList.of(12));
}

18 View Complete Implementation : TestJobClient.java
Copyright Apache License 2.0
Author : apache
@After
public void tearDown() {
    FileUtil.fullyDelete(new File(TEST_DIR));
}

18 View Complete Implementation : TestMRAsyncDiskService.java
Copyright Apache License 2.0
Author : apache
@Before
public void setUp() {
    FileUtil.fullyDelete(new File(TEST_ROOT_DIR));
}

18 View Complete Implementation : TestWinUtils.java
Copyright Apache License 2.0
Author : apache
private void testChmodInternalR(String mode, String expectedPerm, String expectedPermx) throws IOException {
    requireWinutils();
    // Setup test folder hierarchy
    File a = new File(TEST_DIR, "a");
    replacedertTrue(a.mkdir());
    chmod("700", a);
    File aa = new File(a, "a");
    replacedertTrue(aa.createNewFile());
    chmod("600", aa);
    File ab = new File(a, "b");
    replacedertTrue(ab.mkdir());
    chmod("700", ab);
    File aba = new File(ab, "a");
    replacedertTrue(aba.mkdir());
    chmod("700", aba);
    File abb = new File(ab, "b");
    replacedertTrue(abb.createNewFile());
    chmod("600", abb);
    File abx = new File(ab, "x");
    replacedertTrue(abx.createNewFile());
    chmod("u+x", abx);
    // Run chmod recursive
    chmodR(mode, a);
    // Verify outcome
    replacedertPermissions(a, "d" + expectedPermx);
    replacedertPermissions(aa, "-" + expectedPerm);
    replacedertPermissions(ab, "d" + expectedPermx);
    replacedertPermissions(aba, "d" + expectedPermx);
    replacedertPermissions(abb, "-" + expectedPerm);
    replacedertPermissions(abx, "-" + expectedPermx);
    replacedertTrue(FileUtil.fullyDelete(a));
}

18 View Complete Implementation : TestHistoryServerFileSystemStateStoreService.java
Copyright Apache License 2.0
Author : apache
@After
public void cleanup() {
    FileUtil.fullyDelete(testDir);
}

18 View Complete Implementation : TestObserverNode.java
Copyright Apache License 2.0
Author : apache
@Test
public void testBootstrap() throws Exception {
    for (URI u : dfsCluster.getNameDirs(2)) {
        File dir = new File(u.getPath());
        replacedertTrue(FileUtil.fullyDelete(dir));
    }
    int rc = BootstrapStandby.run(new String[] { "-nonInteractive" }, dfsCluster.getConfiguration(2));
    replacedertEquals(0, rc);
}

18 View Complete Implementation : TestWinUtils.java
Copyright Apache License 2.0
Author : apache
@After
public void tearDown() throws IOException {
    FileUtil.fullyDelete(TEST_DIR);
}

18 View Complete Implementation : TestInitializeSharedEdits.java
Copyright Apache License 2.0
Author : apache
private void shutdownClusterAndRemoveSharedEditsDir() throws IOException {
    cluster.shutdownNameNode(0);
    cluster.shutdownNameNode(1);
    File sharedEditsDir = new File(cluster.getSharedEditsDir(0, 1));
    replacedertTrue(FileUtil.fullyDelete(sharedEditsDir));
}

18 View Complete Implementation : TestStandbyCheckpoints.java
Copyright Apache License 2.0
Author : apache
@After
public void shutdownCluster() throws IOException {
    if (cluster != null) {
        cluster.shutdown();
        cluster = null;
    }
    if (tmpOivImgDir != null) {
        FileUtil.fullyDelete(tmpOivImgDir);
    }
}

18 View Complete Implementation : TestTimelineAuthenticationFilterForV1.java
Copyright Apache License 2.0
Author : apache
@AfterClreplaced
public static void tearDown() throws Exception {
    if (testMiniKDC != null) {
        testMiniKDC.stop();
    }
    if (testTimelineServer != null) {
        testTimelineServer.stop();
    }
    if (withSsl) {
        KeyStoreTestUtil.cleanupSSLConfig(keystoresDir, sslConfDir);
        File base = new File(BASEDIR);
        FileUtil.fullyDelete(base);
    }
}

18 View Complete Implementation : TestFileOutputCommitter.java
Copyright Apache License 2.0
Author : apache
private void testCommitterInternal(int version) throws Exception {
    JobConf conf = new JobConf();
    FileOutputFormat.setOutputPath(conf, outDir);
    conf.set(JobContext.TASK_ATTEMPT_ID, attempt);
    conf.setInt(org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter.FILEOUTPUTCOMMITTER_ALGORITHM_VERSION, version);
    JobContext jContext = new JobContextImpl(conf, taskID.getJobID());
    TaskAttemptContext tContext = new TaskAttemptContextImpl(conf, taskID);
    FileOutputCommitter committer = new FileOutputCommitter();
    // setup
    committer.setupJob(jContext);
    committer.setupTask(tContext);
    // write output
    TextOutputFormat theOutputFormat = new TextOutputFormat();
    RecordWriter theRecordWriter = theOutputFormat.getRecordWriter(null, conf, partFile, null);
    writeOutput(theRecordWriter, tContext);
    // do commit
    if (committer.needsTaskCommit(tContext)) {
        committer.commitTask(tContext);
    }
    committer.commitJob(jContext);
    // validate output
    validateContent(outDir);
    FileUtil.fullyDelete(new File(outDir.toString()));
}

18 View Complete Implementation : TestDataStorage.java
Copyright Apache License 2.0
Author : apache
@After
public void tearDown() throws IOException {
    storage.unlockAll();
    FileUtil.fullyDelete(TEST_DIR);
}

18 View Complete Implementation : TestMapRed.java
Copyright Apache License 2.0
Author : apache
@After
public void cleanup() {
    FileUtil.fullyDelete(TEST_DIR);
}