org.apache.hadoop.fs.FileUtil.fullyDelete()

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.

235 Examples 7

19 Source : TestNMWebServicesContainers.java
with Apache License 2.0
from NJUJYB

@AfterClreplaced
static public void cleanup() {
    FileUtil.fullyDelete(testRootDir);
    FileUtil.fullyDelete(testLogDir);
}

19 Source : TestNMWebServices.java
with Apache License 2.0
from NJUJYB

@AfterClreplaced
static public void stop() {
    FileUtil.fullyDelete(testRootDir);
    FileUtil.fullyDelete(testLogDir);
}

19 Source : TestProcfsBasedProcessTree.java
with Apache License 2.0
from NJUJYB

/**
 * 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());
}

19 Source : TestProcfsBasedProcessTree.java
with Apache License 2.0
from NJUJYB

/**
 * 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());
        // Let us not create stat file for pid 100.
        replacedert.replacedertTrue(ProcfsBasedProcessTree.checkPidPgrpidForMatch(pid, procfsRootDir.getAbsolutePath()));
    } finally {
        FileUtil.fullyDelete(procfsRootDir);
    }
}

19 Source : TestHftpFileSystem.java
with Apache License 2.0
from NJUJYB

@BeforeClreplaced
public static void setUp() throws Exception {
    config = new Configuration();
    cluster = new MiniDFSCluster.Builder(config).numDataNodes(2).build();
    blockPoolId = cluster.getNamesystem().getBlockPoolId();
    hftpUri = "hftp://" + config.get(DFSConfigKeys.DFS_NAMENODE_HTTP_ADDRESS_KEY);
    File base = new File(BASEDIR);
    FileUtil.fullyDelete(base);
    base.mkdirs();
    keystoresDir = new File(BASEDIR).getAbsolutePath();
    sslConfDir = KeyStoreTestUtil.getClreplacedpathDir(TestHftpFileSystem.clreplaced);
    KeyStoreTestUtil.setupSSLConfig(keystoresDir, sslConfDir, config, false);
}

19 Source : UpgradeUtilities.java
with Apache License 2.0
from NJUJYB

/**
 * 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 Source : TestJournal.java
with Apache License 2.0
from NJUJYB

@Before
public void setup() throws Exception {
    FileUtil.fullyDelete(TEST_LOG_DIR);
    conf = new Configuration();
    journal = new Journal(conf, TEST_LOG_DIR, JID, StartupOption.REGULAR, mockErrorReporter);
    journal.format(FAKE_NSINFO);
}

19 Source : FsVolumeImpl.java
with Apache License 2.0
from NJUJYB

void deleteBPDirectories(String bpid, boolean force) throws IOException {
    File volumeCurrentDir = this.getCurrentDir();
    File bpDir = new File(volumeCurrentDir, bpid);
    if (!bpDir.isDirectory()) {
        // nothing to be deleted
        return;
    }
    File tmpDir = new File(bpDir, DataStorage.STORAGE_DIR_TMP);
    File bpCurrentDir = new File(bpDir, DataStorage.STORAGE_DIR_CURRENT);
    File finalizedDir = new File(bpCurrentDir, DataStorage.STORAGE_DIR_FINALIZED);
    File lazypersistDir = new File(bpCurrentDir, DataStorage.STORAGE_DIR_LAZY_PERSIST);
    File rbwDir = new File(bpCurrentDir, DataStorage.STORAGE_DIR_RBW);
    if (force) {
        FileUtil.fullyDelete(bpDir);
    } else {
        if (!rbwDir.delete()) {
            throw new IOException("Failed to delete " + rbwDir);
        }
        if (!DatanodeUtil.dirNoFilesRecursive(finalizedDir) || !FileUtil.fullyDelete(finalizedDir)) {
            throw new IOException("Failed to delete " + finalizedDir);
        }
        if (lazypersistDir.exists() && ((!DatanodeUtil.dirNoFilesRecursive(lazypersistDir) || !FileUtil.fullyDelete(lazypersistDir)))) {
            throw new IOException("Failed to delete " + lazypersistDir);
        }
        FileUtil.fullyDelete(tmpDir);
        for (File f : FileUtil.listFiles(bpCurrentDir)) {
            if (!f.delete()) {
                throw new IOException("Failed to delete " + f);
            }
        }
        if (!bpCurrentDir.delete()) {
            throw new IOException("Failed to delete " + bpCurrentDir);
        }
        for (File f : FileUtil.listFiles(bpDir)) {
            if (!f.delete()) {
                throw new IOException("Failed to delete " + f);
            }
        }
        if (!bpDir.delete()) {
            throw new IOException("Failed to delete " + bpDir);
        }
    }
}

19 Source : BlockPoolSlice.java
with Apache License 2.0
from NJUJYB

/**
 * Move replicas in the lazy persist directory to their corresponding locations
 * in the finalized directory.
 * @return number of replicas recovered.
 */
private int moveLazyPersistReplicasToFinalized(File source) throws IOException {
    File[] files = FileUtil.listFiles(source);
    int numRecovered = 0;
    for (File file : files) {
        if (file.isDirectory()) {
            numRecovered += moveLazyPersistReplicasToFinalized(file);
        }
        if (Block.isMetaFilename(file.getName())) {
            File metaFile = file;
            File blockFile = Block.metaToBlockFile(metaFile);
            long blockId = Block.filename2id(blockFile.getName());
            File targetDir = DatanodeUtil.idToBlockDir(finalizedDir, blockId);
            if (blockFile.exists()) {
                if (!targetDir.exists() && !targetDir.mkdirs()) {
                    LOG.warn("Failed to mkdirs " + targetDir);
                    continue;
                }
                final File targetMetaFile = new File(targetDir, metaFile.getName());
                try {
                    NativeIO.renameTo(metaFile, targetMetaFile);
                } catch (IOException e) {
                    LOG.warn("Failed to move meta file from " + metaFile + " to " + targetMetaFile, e);
                    continue;
                }
                final File targetBlockFile = new File(targetDir, blockFile.getName());
                try {
                    NativeIO.renameTo(blockFile, targetBlockFile);
                } catch (IOException e) {
                    LOG.warn("Failed to move block file from " + blockFile + " to " + targetBlockFile, e);
                    continue;
                }
                if (targetBlockFile.exists() && targetMetaFile.exists()) {
                    ++numRecovered;
                } else {
                    // Failure should be rare.
                    LOG.warn("Failed to move " + blockFile + " to " + targetDir);
                }
            }
        }
    }
    FileUtil.fullyDelete(source);
    return numRecovered;
}

19 Source : BlockPoolSliceStorage.java
with Apache License 2.0
from NJUJYB

/**
 * Delete all files and directories in the trash directories.
 */
public void restoreTrash() {
    for (StorageDirectory sd : storageDirs) {
        File trashRoot = getTrashRootDir(sd);
        try {
            Preconditions.checkState(!(trashRoot.exists() && sd.getPreviousDir().exists()));
            restoreBlockFilesFromTrash(trashRoot);
            FileUtil.fullyDelete(getTrashRootDir(sd));
        } catch (IOException ioe) {
            LOG.warn("Restoring trash failed for storage directory " + sd);
        }
    }
}

19 Source : BlockPoolSliceStorage.java
with Apache License 2.0
from NJUJYB

/**
 * 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 " + newChild + " with smaller file from " + "trash directory. This message can be safely ignored.");
        } else if (!child.renameTo(newChild)) {
            throw new IOException("Failed to rename " + child + " to " + newChild);
        } else {
            ++filesRestored;
        }
    }
    FileUtil.fullyDelete(trashRoot);
    return filesRestored;
}

19 Source : TestNativeIO.java
with Apache License 2.0
from NJUJYB

@Before
public void setupTestDir() {
    FileUtil.fullyDelete(TEST_DIR);
    TEST_DIR.mkdirs();
}

19 Source : TestProcfsBasedProcessTree.java
with Apache License 2.0
from naver

/**
 * 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(), new SystemClock());
        // Let us not create stat file for pid 100.
        replacedert.replacedertTrue(ProcfsBasedProcessTree.checkPidPgrpidForMatch(pid, procfsRootDir.getAbsolutePath()));
    } finally {
        FileUtil.fullyDelete(procfsRootDir);
    }
}

19 Source : ContinuousFileProcessingCheckpointITCase.java
with Apache License 2.0
from ljygz

@BeforeClreplaced
public static void createHDFS() {
    try {
        baseDir = new File("./target/localfs/fs_tests").getAbsoluteFile();
        FileUtil.fullyDelete(baseDir);
        org.apache.hadoop.conf.Configuration hdConf = new org.apache.hadoop.conf.Configuration();
        localFsURI = "file:///" + baseDir + "/";
        localFs = new org.apache.hadoop.fs.Path(localFsURI).getFileSystem(hdConf);
    } catch (Throwable e) {
        e.printStackTrace();
        replacedert.fail("Test failed " + e.getMessage());
    }
}

19 Source : TestOzoneTokenIdentifier.java
with Apache License 2.0
from apache

@BeforeClreplaced
public static void setUp() throws Exception {
    base = new File(BASEDIR);
    FileUtil.fullyDelete(base);
    base.mkdirs();
}

19 Source : TestEndPoint.java
with Apache License 2.0
from apache

@AfterClreplaced
public static void tearDown() throws Exception {
    if (scmServer != null) {
        scmServer.stop();
    }
    FileUtil.fullyDelete(testDir);
}

19 Source : TestContainerDataYaml.java
with Apache License 2.0
from apache

private void cleanup() {
    FileUtil.fullyDelete(new File(testRoot));
}

19 Source : TestHoodieLogFormatAppendFailure.java
with Apache License 2.0
from apache

@AfterAll
public static void tearDownClreplaced() {
    cluster.shutdown(true);
    // Force clean up the directory under which the cluster was created
    FileUtil.fullyDelete(baseDir);
}

18 Source : ITestLocalCloudup.java
with Apache License 2.0
from steveloughran

@Before
public void setup() throws Exception {
    methodDir = new File(testDirectory, methodName.getMethodName());
    mkdirs(methodDir);
    sourceDir = new File(methodDir, "src");
    destDir = new File(methodDir, "dest");
    FileUtil.fullyDelete(sourceDir);
    FileUtil.fullyDelete(destDir);
}

18 Source : ITestLocalCloudup.java
with Apache License 2.0
from steveloughran

@After
public void teardown() throws Exception {
    if (methodDir != null) {
        FileUtil.fullyDelete(methodDir);
    }
}

18 Source : ITestS3ACloudup.java
with Apache License 2.0
from steveloughran

@After
public void teardown() throws Exception {
    if (methodDir != null) {
        FileUtil.fullyDelete(methodDir);
    }
    cleanup("TEARDOWN", getFileSystem(), testPath);
}

18 Source : ITestS3ACloudup.java
with Apache License 2.0
from steveloughran

@Before
public void setup() throws Exception {
    super.setup();
    root = new Path(getFileSystem().getUri());
    testPath = new Path(root, "/ITestS3ACloudup");
    methodDir = new File(testDirectory, methodName.getMethodName());
    StoreTestUtils.mkdirs(methodDir);
    sourceDir = new File(methodDir, "src");
    FileUtil.fullyDelete(sourceDir);
}

18 Source : TestDiskFailures.java
with Apache License 2.0
from NJUJYB

@AfterClreplaced
public static void teardown() {
    if (yarnCluster != null) {
        yarnCluster.stop();
        yarnCluster = null;
    }
    FileUtil.fullyDelete(localFSDirBase);
}

18 Source : TestNMWebServer.java
with Apache License 2.0
from NJUJYB

@After
public void tearDown() {
    FileUtil.fullyDelete(testRootDir);
    FileUtil.fullyDelete(testLogDir);
}

18 Source : TestLocalDirsHandlerService.java
with Apache License 2.0
from NJUJYB

@AfterClreplaced
public static void teardown() {
    FileUtil.fullyDelete(testDir);
}

18 Source : TestDirectoryCollection.java
with Apache License 2.0
from NJUJYB

@After
public void teardown() {
    FileUtil.fullyDelete(testDir);
}

18 Source : TestNMLeveldbStateStoreService.java
with Apache License 2.0
from NJUJYB

@After
public void cleanup() throws IOException {
    if (stateStore != null) {
        stateStore.close();
    }
    FileUtil.fullyDelete(TMP_DIR);
}

18 Source : TestContainersMonitor.java
with Apache License 2.0
from NJUJYB

/**
 * Test to verify the check for whether a process tree is over limit or not.
 *
 * @throws IOException
 *           if there was a problem setting up the fake procfs directories or
 *           files.
 */
@Test
public void testProcessTreeLimits() throws IOException {
    // set up a dummy proc file system
    File procfsRootDir = new File(localDir, "proc");
    String[] pids = { "100", "200", "300", "400", "500", "600", "700" };
    try {
        TestProcfsBasedProcessTree.setupProcfsRootDir(procfsRootDir);
        // create pid dirs.
        TestProcfsBasedProcessTree.setupPidDirs(procfsRootDir, pids);
        // create process infos.
        TestProcfsBasedProcessTree.ProcessStatInfo[] procs = new TestProcfsBasedProcessTree.ProcessStatInfo[7];
        // replacedume pids 100, 500 are in 1 tree
        // 200,300,400 are in another
        // 600,700 are in a third
        procs[0] = new TestProcfsBasedProcessTree.ProcessStatInfo(new String[] { "100", "proc1", "1", "100", "100", "100000" });
        procs[1] = new TestProcfsBasedProcessTree.ProcessStatInfo(new String[] { "200", "proc2", "1", "200", "200", "200000" });
        procs[2] = new TestProcfsBasedProcessTree.ProcessStatInfo(new String[] { "300", "proc3", "200", "200", "200", "300000" });
        procs[3] = new TestProcfsBasedProcessTree.ProcessStatInfo(new String[] { "400", "proc4", "200", "200", "200", "400000" });
        procs[4] = new TestProcfsBasedProcessTree.ProcessStatInfo(new String[] { "500", "proc5", "100", "100", "100", "1500000" });
        procs[5] = new TestProcfsBasedProcessTree.ProcessStatInfo(new String[] { "600", "proc6", "1", "600", "600", "100000" });
        procs[6] = new TestProcfsBasedProcessTree.ProcessStatInfo(new String[] { "700", "proc7", "600", "600", "600", "100000" });
        // write stat files.
        TestProcfsBasedProcessTree.writeStatFiles(procfsRootDir, pids, procs, null);
        // vmem limit
        long limit = 700000;
        ContainersMonitorImpl test = new ContainersMonitorImpl(null, null, null);
        // create process trees
        // tree rooted at 100 is over limit immediately, as it is
        // twice over the mem limit.
        ProcfsBasedProcessTree pTree = new ProcfsBasedProcessTree("100", procfsRootDir.getAbsolutePath());
        pTree.updateProcessTree();
        replacedertTrue("tree rooted at 100 should be over limit " + "after first iteration.", test.isProcessTreeOverLimit(pTree, "dummyId", limit));
        // the tree rooted at 200 is initially below limit.
        pTree = new ProcfsBasedProcessTree("200", procfsRootDir.getAbsolutePath());
        pTree.updateProcessTree();
        replacedertFalse("tree rooted at 200 shouldn't be over limit " + "after one iteration.", test.isProcessTreeOverLimit(pTree, "dummyId", limit));
        // second iteration - now the tree has been over limit twice,
        // hence it should be declared over limit.
        pTree.updateProcessTree();
        replacedertTrue("tree rooted at 200 should be over limit after 2 iterations", test.isProcessTreeOverLimit(pTree, "dummyId", limit));
        // the tree rooted at 600 is never over limit.
        pTree = new ProcfsBasedProcessTree("600", procfsRootDir.getAbsolutePath());
        pTree.updateProcessTree();
        replacedertFalse("tree rooted at 600 should never be over limit.", test.isProcessTreeOverLimit(pTree, "dummyId", limit));
        // another iteration does not make any difference.
        pTree.updateProcessTree();
        replacedertFalse("tree rooted at 600 should never be over limit.", test.isProcessTreeOverLimit(pTree, "dummyId", limit));
    } finally {
        FileUtil.fullyDelete(procfsRootDir);
    }
}

18 Source : TestTimelineAuthenticationFilter.java
with Apache License 2.0
from NJUJYB

@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 Source : TestProcfsBasedProcessTree.java
with Apache License 2.0
from NJUJYB

/**
 * Test the correctness of process-tree dump.
 *
 * @throws IOException
 */
@Test(timeout = 30000)
public void testProcessTreeDump() throws IOException {
    String[] pids = { "100", "200", "300", "400", "500", "600" };
    File procfsRootDir = new File(TEST_ROOT_DIR, "proc");
    try {
        setupProcfsRootDir(procfsRootDir);
        setupPidDirs(procfsRootDir, pids);
        int numProcesses = pids.length;
        // Processes 200, 300, 400 and 500 are descendants of 100. 600 is not.
        ProcessStatInfo[] procInfos = new ProcessStatInfo[numProcesses];
        procInfos[0] = new ProcessStatInfo(new String[] { "100", "proc1", "1", "100", "100", "100000", "100", "1000", "200" });
        procInfos[1] = new ProcessStatInfo(new String[] { "200", "proc2", "100", "100", "100", "200000", "200", "2000", "400" });
        procInfos[2] = new ProcessStatInfo(new String[] { "300", "proc3", "200", "100", "100", "300000", "300", "3000", "600" });
        procInfos[3] = new ProcessStatInfo(new String[] { "400", "proc4", "200", "100", "100", "400000", "400", "4000", "800" });
        procInfos[4] = new ProcessStatInfo(new String[] { "500", "proc5", "400", "100", "100", "400000", "400", "4000", "800" });
        procInfos[5] = new ProcessStatInfo(new String[] { "600", "proc6", "1", "1", "1", "400000", "400", "4000", "800" });
        ProcessTreeSmapMemInfo[] memInfos = new ProcessTreeSmapMemInfo[6];
        memInfos[0] = new ProcessTreeSmapMemInfo("100");
        memInfos[1] = new ProcessTreeSmapMemInfo("200");
        memInfos[2] = new ProcessTreeSmapMemInfo("300");
        memInfos[3] = new ProcessTreeSmapMemInfo("400");
        memInfos[4] = new ProcessTreeSmapMemInfo("500");
        memInfos[5] = new ProcessTreeSmapMemInfo("600");
        String[] cmdLines = new String[numProcesses];
        cmdLines[0] = "proc1 arg1 arg2";
        cmdLines[1] = "proc2 arg3 arg4";
        cmdLines[2] = "proc3 arg5 arg6";
        cmdLines[3] = "proc4 arg7 arg8";
        cmdLines[4] = "proc5 arg9 arg10";
        cmdLines[5] = "proc6 arg11 arg12";
        createMemoryMappingInfo(memInfos);
        writeStatFiles(procfsRootDir, pids, procInfos, memInfos);
        writeCmdLineFiles(procfsRootDir, pids, cmdLines);
        ProcfsBasedProcessTree processTree = createProcessTree("100", procfsRootDir.getAbsolutePath());
        // build the process tree.
        processTree.updateProcessTree();
        // Get the process-tree dump
        String processTreeDump = processTree.getProcessTreeDump();
        LOG.info("Process-tree dump follows: \n" + processTreeDump);
        replacedert.replacedertTrue("Process-tree dump doesn't start with a proper header", processTreeDump.startsWith("\t|- PID PPID PGRPID SESSID CMD_NAME " + "USER_MODE_TIME(MILLIS) SYSTEM_TIME(MILLIS) VMEM_USAGE(BYTES) " + "RSSMEM_USAGE(PAGES) FULL_CMD_LINE\n"));
        for (int i = 0; i < 5; i++) {
            ProcessStatInfo p = procInfos[i];
            replacedert.replacedertTrue("Process-tree dump doesn't contain the cmdLineDump of process " + p.pid, processTreeDump.contains("\t|- " + p.pid + " " + p.ppid + " " + p.pgrpId + " " + p.session + " (" + p.name + ") " + p.utime + " " + p.stime + " " + p.vmem + " " + p.rssmemPage + " " + cmdLines[i]));
        }
        // 600 should not be in the dump
        ProcessStatInfo p = procInfos[5];
        replacedert.replacedertFalse("Process-tree dump shouldn't contain the cmdLineDump of process " + p.pid, processTreeDump.contains("\t|- " + p.pid + " " + p.ppid + " " + p.pgrpId + " " + p.session + " (" + p.name + ") " + p.utime + " " + p.stime + " " + p.vmem + " " + cmdLines[5]));
    } finally {
        FileUtil.fullyDelete(procfsRootDir);
    }
}

18 Source : TestTypedBytesStreaming.java
with Apache License 2.0
from NJUJYB

@Before
@After
public void cleanupOutput() throws Exception {
    FileUtil.fullyDelete(OUTPUT_DIR.getAbsoluteFile());
    INPUT_FILE.delete();
    createInput();
}

18 Source : TestStreamingKeyValue.java
with Apache License 2.0
from NJUJYB

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 Source : TestMRAsyncDiskService.java
with Apache License 2.0
from NJUJYB

@Override
protected void setUp() {
    FileUtil.fullyDelete(new File(TEST_ROOT_DIR));
}

18 Source : TestMapReduce.java
with Apache License 2.0
from NJUJYB

/**
 * 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 Source : TestMapReduce.java
with Apache License 2.0
from NJUJYB

@After
public void cleanup() {
    FileUtil.fullyDelete(TEST_DIR);
}

18 Source : TestEncryptedShuffle.java
with Apache License 2.0
from NJUJYB

@BeforeClreplaced
public static void setUp() throws Exception {
    File base = new File(BASEDIR);
    FileUtil.fullyDelete(base);
    base.mkdirs();
}

18 Source : TestYARNRunner.java
with Apache License 2.0
from NJUJYB

@After
public void cleanup() {
    FileUtil.fullyDelete(testWorkDir);
}

18 Source : TestTaskCommit.java
with Apache License 2.0
from NJUJYB

@Override
public void tearDown() throws Exception {
    super.tearDown();
    FileUtil.fullyDelete(new File(rootDir.toString()));
}

18 Source : TestHsWebServicesJobConf.java
with Apache License 2.0
from NJUJYB

@AfterClreplaced
static public void stop() {
    FileUtil.fullyDelete(testConfDir);
}

18 Source : TestHistoryServerFileSystemStateStoreService.java
with Apache License 2.0
from NJUJYB

@After
public void cleanup() {
    FileUtil.fullyDelete(testDir);
}

18 Source : TestFileOutputCommitter.java
with Apache License 2.0
from NJUJYB

public void testCommitter() throws Exception {
    JobConf conf = new JobConf();
    FileOutputFormat.setOutputPath(conf, outDir);
    conf.set(JobContext.TASK_ATTEMPT_ID, attempt);
    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 Source : TestFileOutputCommitter.java
with Apache License 2.0
from NJUJYB

public void testMapOnlyNoOutput() throws Exception {
    JobConf conf = new JobConf();
    // This is not set on purpose. FileOutputFormat.setOutputPath(conf, outDir);
    conf.set(JobContext.TASK_ATTEMPT_ID, attempt);
    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 Source : TestJobClient.java
with Apache License 2.0
from NJUJYB

@After
public void tearDown() {
    FileUtil.fullyDelete(new File(TEST_DIR));
}

18 Source : TestHftpFileSystem.java
with Apache License 2.0
from NJUJYB

@AfterClreplaced
public static void tearDown() throws Exception {
    if (cluster != null) {
        cluster.shutdown();
    }
    FileUtil.fullyDelete(new File(BASEDIR));
    KeyStoreTestUtil.cleanupSSLConfig(keystoresDir, sslConfDir);
}

18 Source : TestInitializeSharedEdits.java
with Apache License 2.0
from NJUJYB

private void shutdownClusterAndRemoveSharedEditsDir() throws IOException {
    cluster.shutdownNameNode(0);
    cluster.shutdownNameNode(1);
    File sharedEditsDir = new File(cluster.getSharedEditsDir(0, 1));
    replacedertTrue(FileUtil.fullyDelete(sharedEditsDir));
}

18 Source : TestDataStorage.java
with Apache License 2.0
from NJUJYB

@After
public void tearDown() throws IOException {
    storage.unlockAll();
    FileUtil.fullyDelete(TEST_DIR);
}

18 Source : TestBlockRecovery.java
with Apache License 2.0
from NJUJYB

/**
 * Cleans the resources and closes the instance of datanode
 * @throws IOException if an error occurred
 */
@After
public void tearDown() throws IOException {
    if (dn != null) {
        try {
            dn.shutdown();
        } catch (Exception e) {
            LOG.error("Cannot close: ", e);
        } finally {
            File dir = new File(DATA_DIR);
            if (dir.exists())
                replacedert.replacedertTrue("Cannot delete data-node dirs", FileUtil.fullyDelete(dir));
        }
    }
}

18 Source : TestSecureNNWithQJM.java
with Apache License 2.0
from NJUJYB

@AfterClreplaced
public static void destroy() {
    if (kdc != null) {
        kdc.stop();
    }
    FileUtil.fullyDelete(baseDir);
}

18 Source : TestWinUtils.java
with Apache License 2.0
from NJUJYB

private void testChmodInternalR(String mode, String expectedPerm, String expectedPermx) throws IOException {
    // 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 Source : TestWinUtils.java
with Apache License 2.0
from NJUJYB

@After
public void tearDown() throws IOException {
    FileUtil.fullyDelete(TEST_DIR);
}

See More Examples