use of org.apache.hadoop.fs.LocalFileSystem in project hadoop by apache.
the class TestTraceUtils method testTracingGlobber.
/**
* Test tracing the globber. This is a regression test for HDFS-9187.
*/
@Test
public void testTracingGlobber() throws Exception {
// Bypass the normal FileSystem object creation path by just creating an
// instance of a subclass.
FileSystem fs = new LocalFileSystem();
fs.initialize(new URI("file:///"), new Configuration());
fs.globStatus(new Path("/"));
fs.close();
}
use of org.apache.hadoop.fs.LocalFileSystem in project hadoop by apache.
the class TestDiskChecker method _mkdirs.
private void _mkdirs(boolean exists, FsPermission before, FsPermission after) throws Throwable {
File localDir = make(stub(File.class).returning(exists).from.exists());
when(localDir.mkdir()).thenReturn(true);
// use default stubs
Path dir = mock(Path.class);
LocalFileSystem fs = make(stub(LocalFileSystem.class).returning(localDir).from.pathToFile(dir));
FileStatus stat = make(stub(FileStatus.class).returning(after).from.getPermission());
when(fs.getFileStatus(dir)).thenReturn(stat);
try {
DiskChecker.mkdirsWithExistsAndPermissionCheck(fs, dir, before);
if (!exists)
verify(fs).setPermission(dir, before);
else {
verify(fs).getFileStatus(dir);
verify(stat).getPermission();
}
} catch (DiskErrorException e) {
if (before != after)
assertTrue(e.getMessage().startsWith("Incorrect permission"));
}
}
use of org.apache.hadoop.fs.LocalFileSystem in project hadoop by apache.
the class TestBloomMapFile method setUp.
@Before
public void setUp() throws Exception {
LocalFileSystem fs = FileSystem.getLocal(conf);
if (fs.exists(TEST_ROOT) && !fs.delete(TEST_ROOT, true)) {
fail("Can't clean up test root dir");
}
fs.mkdirs(TEST_ROOT);
}
use of org.apache.hadoop.fs.LocalFileSystem in project crunch by cloudera.
the class CompositePathIterableTest method testCreate_DirectoryPresentButNoFiles.
@Test
public void testCreate_DirectoryPresentButNoFiles() throws IOException {
String inputFilePath = Files.createTempDir().getAbsolutePath();
Configuration conf = new Configuration();
LocalFileSystem local = FileSystem.getLocal(conf);
Iterable<String> iterable = CompositePathIterable.create(local, new Path(inputFilePath), new TextFileReaderFactory<String>(Writables.strings(), conf));
assertTrue(Lists.newArrayList(iterable).isEmpty());
}
use of org.apache.hadoop.fs.LocalFileSystem in project hadoop by apache.
the class StorageLocation method makeBlockPoolDir.
/**
* Create physical directory for block pools on the data node.
*
* @param blockPoolID
* the block pool id
* @param conf
* Configuration instance to use.
* @throws IOException on errors
*/
public void makeBlockPoolDir(String blockPoolID, Configuration conf) throws IOException {
if (conf == null) {
conf = new HdfsConfiguration();
}
LocalFileSystem localFS = FileSystem.getLocal(conf);
FsPermission permission = new FsPermission(conf.get(DFSConfigKeys.DFS_DATANODE_DATA_DIR_PERMISSION_KEY, DFSConfigKeys.DFS_DATANODE_DATA_DIR_PERMISSION_DEFAULT));
File data = new File(getBpURI(blockPoolID, Storage.STORAGE_DIR_CURRENT));
try {
DiskChecker.checkDir(localFS, new Path(data.toURI()), permission);
} catch (IOException e) {
DataStorage.LOG.warn("Invalid directory in: " + data.getCanonicalPath() + ": " + e.getMessage());
}
}
Aggregations