use of java.net.URI in project hadoop by apache.
the class TestChRootedFileSystem method testSetStoragePolicy.
@Test(timeout = 30000)
public void testSetStoragePolicy() throws Exception {
Path storagePolicyPath = new Path("/storagePolicy");
Path chRootedStoragePolicyPath = new Path("/a/b/storagePolicy");
Configuration conf = new Configuration();
conf.setClass("fs.mockfs.impl", MockFileSystem.class, FileSystem.class);
URI chrootUri = URI.create("mockfs://foo/a/b");
ChRootedFileSystem chrootFs = new ChRootedFileSystem(chrootUri, conf);
FileSystem mockFs = ((FilterFileSystem) chrootFs.getRawFileSystem()).getRawFileSystem();
chrootFs.setStoragePolicy(storagePolicyPath, "HOT");
verify(mockFs).setStoragePolicy(chRootedStoragePolicyPath, "HOT");
}
use of java.net.URI in project hadoop by apache.
the class TestChRootedFileSystem method testURIEmptyPath.
@Test
public void testURIEmptyPath() throws IOException {
Configuration conf = new Configuration();
conf.setClass("fs.mockfs.impl", MockFileSystem.class, FileSystem.class);
URI chrootUri = URI.create("mockfs://foo");
new ChRootedFileSystem(chrootUri, conf);
}
use of java.net.URI in project hadoop by apache.
the class TestChRootedFileSystem method testGetStoragePolicy.
@Test(timeout = 30000)
public void testGetStoragePolicy() throws Exception {
Path storagePolicyPath = new Path("/storagePolicy");
Path chRootedStoragePolicyPath = new Path("/a/b/storagePolicy");
Configuration conf = new Configuration();
conf.setClass("fs.mockfs.impl", MockFileSystem.class, FileSystem.class);
URI chrootUri = URI.create("mockfs://foo/a/b");
ChRootedFileSystem chrootFs = new ChRootedFileSystem(chrootUri, conf);
FileSystem mockFs = ((FilterFileSystem) chrootFs.getRawFileSystem()).getRawFileSystem();
chrootFs.getStoragePolicy(storagePolicyPath);
verify(mockFs).getStoragePolicy(chRootedStoragePolicyPath);
}
use of java.net.URI in project hadoop by apache.
the class TestChRootedFileSystem method testUnsetStoragePolicy.
@Test(timeout = 30000)
public void testUnsetStoragePolicy() throws Exception {
Path storagePolicyPath = new Path("/storagePolicy");
Path chRootedStoragePolicyPath = new Path("/a/b/storagePolicy");
Configuration conf = new Configuration();
conf.setClass("fs.mockfs.impl", MockFileSystem.class, FileSystem.class);
URI chrootUri = URI.create("mockfs://foo/a/b");
ChRootedFileSystem chrootFs = new ChRootedFileSystem(chrootUri, conf);
FileSystem mockFs = ((FilterFileSystem) chrootFs.getRawFileSystem()).getRawFileSystem();
chrootFs.unsetStoragePolicy(storagePolicyPath);
verify(mockFs).unsetStoragePolicy(chRootedStoragePolicyPath);
}
use of java.net.URI in project hadoop by apache.
the class RollingFileSystemSinkTestBase method readLogFile.
/**
* Read the log files at the target path and return the contents as a single
* string. This method will assert that the correct number of files is found.
*
* @param path the target path
* @param then when the test method began. Used to find the log directory in
* the case that the test run crosses the top of the hour.
* @param count the number of log files to expect
* @return
* @throws IOException
* @throws URISyntaxException
*/
protected String readLogFile(String path, String then, int count) throws IOException, URISyntaxException {
final String now = DATE_FORMAT.format(new Date()) + "00";
final String logFile = getLogFilename();
FileSystem fs = FileSystem.get(new URI(path), new Configuration());
StringBuilder metrics = new StringBuilder();
boolean found = false;
for (FileStatus status : fs.listStatus(new Path(path))) {
Path logDir = status.getPath();
// the test started and the current time. Anything else can be ignored.
if (now.equals(logDir.getName()) || then.equals(logDir.getName())) {
readLogData(fs, findMostRecentLogFile(fs, new Path(logDir, logFile)), metrics);
assertFileCount(fs, logDir, count);
found = true;
}
}
assertTrue("No valid log directories found", found);
return metrics.toString();
}
Aggregations