Java Code Examples for org.apache.hadoop.fs.FileUtil#fullyDeleteContents()

The following examples show how to use org.apache.hadoop.fs.FileUtil#fullyDeleteContents() . 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: FSImageTestUtil.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Return a standalone instance of FSEditLog that will log into the given
 * log directory. The returned instance is not yet opened.
 */
public static FSEditLog createStandaloneEditLog(File logDir)
    throws IOException {
  assertTrue(logDir.mkdirs() || logDir.exists());
  if (!FileUtil.fullyDeleteContents(logDir)) {
    throw new IOException("Unable to delete contents of " + logDir);
  }
  NNStorage storage = Mockito.mock(NNStorage.class);
  StorageDirectory sd 
    = FSImageTestUtil.mockStorageDirectory(logDir, NameNodeDirType.EDITS);
  List<StorageDirectory> sds = Lists.newArrayList(sd);
  Mockito.doReturn(sds).when(storage).dirIterable(NameNodeDirType.EDITS);
  Mockito.doReturn(sd).when(storage)
    .getStorageDirectory(Matchers.<URI>anyObject());

  FSEditLog editLog = new FSEditLog(new Configuration(), 
                       storage,
                       ImmutableList.of(logDir.toURI()));
  editLog.initJournalsForWrite();
  return editLog;
}
 
Example 2
Source File: FSImageTestUtil.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Return a standalone instance of FSEditLog that will log into the given
 * log directory. The returned instance is not yet opened.
 */
public static FSEditLog createStandaloneEditLog(File logDir)
    throws IOException {
  assertTrue(logDir.mkdirs() || logDir.exists());
  if (!FileUtil.fullyDeleteContents(logDir)) {
    throw new IOException("Unable to delete contents of " + logDir);
  }
  NNStorage storage = Mockito.mock(NNStorage.class);
  StorageDirectory sd 
    = FSImageTestUtil.mockStorageDirectory(logDir, NameNodeDirType.EDITS);
  List<StorageDirectory> sds = Lists.newArrayList(sd);
  Mockito.doReturn(sds).when(storage).dirIterable(NameNodeDirType.EDITS);
  Mockito.doReturn(sd).when(storage)
    .getStorageDirectory(Matchers.<URI>anyObject());

  FSEditLog editLog = new FSEditLog(new Configuration(), 
                       storage,
                       ImmutableList.of(logDir.toURI()));
  editLog.initJournalsForWrite();
  return editLog;
}
 
Example 3
Source File: TestFSNamesystem.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@After
public void cleanUp() {
  FileUtil.fullyDeleteContents(new File(MiniDFSCluster.getBaseDirectory()));
}
 
Example 4
Source File: TestNNThroughputBenchmark.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@After
public void cleanUp() {
  FileUtil.fullyDeleteContents(new File(MiniDFSCluster.getBaseDirectory()));
}
 
Example 5
Source File: TestCheckpoint.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
  FileUtil.fullyDeleteContents(new File(MiniDFSCluster.getBaseDirectory()));
  faultInjector = Mockito.mock(CheckpointFaultInjector.class);
  CheckpointFaultInjector.instance = faultInjector;
}
 
Example 6
Source File: TestCheckpointsWithSnapshots.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
  FileUtil.fullyDeleteContents(new File(MiniDFSCluster.getBaseDirectory()));
}
 
Example 7
Source File: TestValidateConfigurationSettings.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@After
public void cleanUp() {
  FileUtil.fullyDeleteContents(new File(MiniDFSCluster.getBaseDirectory()));
}
 
Example 8
Source File: TestAtomicFileOutputStream.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Before
public void cleanupTestDir() throws IOException {
  assertTrue(TEST_DIR.exists() || TEST_DIR.mkdirs());
  FileUtil.fullyDeleteContents(TEST_DIR);
}
 
Example 9
Source File: TestFSNamesystem.java    From big-c with Apache License 2.0 4 votes vote down vote up
@After
public void cleanUp() {
  FileUtil.fullyDeleteContents(new File(MiniDFSCluster.getBaseDirectory()));
}
 
Example 10
Source File: TestNNThroughputBenchmark.java    From big-c with Apache License 2.0 4 votes vote down vote up
@After
public void cleanUp() {
  FileUtil.fullyDeleteContents(new File(MiniDFSCluster.getBaseDirectory()));
}
 
Example 11
Source File: TestCheckpoint.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
  FileUtil.fullyDeleteContents(new File(MiniDFSCluster.getBaseDirectory()));
  faultInjector = Mockito.mock(CheckpointFaultInjector.class);
  CheckpointFaultInjector.instance = faultInjector;
}
 
Example 12
Source File: TestCheckpointsWithSnapshots.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
  FileUtil.fullyDeleteContents(new File(MiniDFSCluster.getBaseDirectory()));
}
 
Example 13
Source File: TestValidateConfigurationSettings.java    From big-c with Apache License 2.0 4 votes vote down vote up
@After
public void cleanUp() {
  FileUtil.fullyDeleteContents(new File(MiniDFSCluster.getBaseDirectory()));
}
 
Example 14
Source File: TestAtomicFileOutputStream.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Before
public void cleanupTestDir() throws IOException {
  assertTrue(TEST_DIR.exists() || TEST_DIR.mkdirs());
  FileUtil.fullyDeleteContents(TEST_DIR);
}