Esempio n. 1
0
  @Override
  public boolean rename(BasePath src, BasePath dst) throws Exception {
    File srcFile = new File(src.getAbsolutePath());
    File dstFile = new File(dst.getAbsolutePath());

    return srcFile.renameTo(dstFile);
  }
  @Test
  public void testPathCreation() throws Exception {
    // Clear it out first.
    final String targetDirname = "build/test/HadoopPlatformTest/testPathCreation";
    File targetDirFile = new File(targetDirname);
    FileUtils.deleteDirectory(targetDirFile);
    assertFalse(targetDirFile.exists());

    BasePlatform platform = new HadoopPlatform(HadoopPlatformTest.class);

    BasePath path = platform.makePath(targetDirname);
    assertEquals(targetDirname, path.getPath());
    assertEquals(targetDirFile.toURI().toString(), path.getAbsolutePath());
    assertEquals(targetDirFile.toURI().toString(), path.toString());

    assertFalse(path.exists());
    assertTrue(path.mkdirs());
    assertTrue(path.isDirectory());
    assertFalse(path.isFile());

    assertTrue(targetDirFile.exists());
    assertTrue(targetDirFile.isDirectory());

    // Check out sub-dir support.
    File subDirFile = new File(targetDirFile, "subdir");

    BasePath child = platform.makePath(path, "subdir");
    assertEquals(targetDirname + "/" + "subdir", child.getPath());
    assertEquals(subDirFile.toURI().toString(), child.getAbsolutePath());

    assertFalse(child.exists());
    assertTrue(child.mkdirs());
    assertTrue(child.isDirectory());
    assertFalse(child.isFile());

    assertTrue(subDirFile.exists());
    assertTrue(subDirFile.isDirectory());
  }
Esempio n. 3
0
 @Override
 public Tap makeTap(Scheme scheme, BasePath path, SinkMode mode) throws Exception {
   return new DirectoryTap(scheme, path.getAbsolutePath(), mode);
 }