Search in sources :

Example 16 with StoppableImplementation

use of org.apache.hadoop.hbase.util.StoppableImplementation in project hbase by apache.

the class TestCleanerChore method testSavesFilesOnRequest.

@Test
public void testSavesFilesOnRequest() throws Exception {
    Stoppable stop = new StoppableImplementation();
    Configuration conf = UTIL.getConfiguration();
    Path testDir = UTIL.getDataTestDir();
    FileSystem fs = UTIL.getTestFileSystem();
    String confKey = "hbase.test.cleaner.delegates";
    conf.set(confKey, NeverDelete.class.getName());
    AllValidPaths chore = new AllValidPaths("test-file-cleaner", stop, conf, fs, testDir, confKey, POOL);
    // create the directory layout in the directory to clean
    Path parent = new Path(testDir, "parent");
    Path file = new Path(parent, "someFile");
    fs.mkdirs(parent);
    // touch a new file
    fs.create(file).close();
    assertTrue("Test file didn't get created.", fs.exists(file));
    // run the chore
    chore.chore();
    // verify all the files were preserved
    assertTrue("File shouldn't have been deleted", fs.exists(file));
    assertTrue("directory shouldn't have been deleted", fs.exists(parent));
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) StoppableImplementation(org.apache.hadoop.hbase.util.StoppableImplementation) FileSystem(org.apache.hadoop.fs.FileSystem) FilterFileSystem(org.apache.hadoop.fs.FilterFileSystem) Stoppable(org.apache.hadoop.hbase.Stoppable) Test(org.junit.Test)

Aggregations

StoppableImplementation (org.apache.hadoop.hbase.util.StoppableImplementation)16 Test (org.junit.Test)16 Stoppable (org.apache.hadoop.hbase.Stoppable)15 Configuration (org.apache.hadoop.conf.Configuration)14 FileSystem (org.apache.hadoop.fs.FileSystem)14 Path (org.apache.hadoop.fs.Path)14 FilterFileSystem (org.apache.hadoop.fs.FilterFileSystem)11 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 ChoreService (org.apache.hadoop.hbase.ChoreService)3 HFileCleaner (org.apache.hadoop.hbase.master.cleaner.HFileCleaner)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 FileStatus (org.apache.hadoop.fs.FileStatus)2 ColumnFamilyDescriptor (org.apache.hadoop.hbase.client.ColumnFamilyDescriptor)2 BaseHFileCleanerDelegate (org.apache.hadoop.hbase.master.cleaner.BaseHFileCleanerDelegate)2 CompactedHFilesDischarger (org.apache.hadoop.hbase.regionserver.CompactedHFilesDischarger)2 HRegion (org.apache.hadoop.hbase.regionserver.HRegion)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 HBaseTestingUtil (org.apache.hadoop.hbase.HBaseTestingUtil)1