use of alluxio.client.file.FileSystem in project alluxio by Alluxio.
the class AlluxioFuse method main.
/**
* Running this class will mount the file system according to
* the options passed to this function {@link #parseOptions(String[])}.
* The user-space fuse application will stay on the foreground and keep
* the file system mounted. The user can unmount the file system by
* gracefully killing (SIGINT) the process.
*
* @param args arguments to run the command line
*/
public static void main(String[] args) {
final AlluxioFuseOptions opts = parseOptions(args);
if (opts == null) {
System.exit(1);
}
final FileSystem tfs = FileSystem.Factory.get();
final AlluxioFuseFileSystem fs = new AlluxioFuseFileSystem(tfs, opts);
final List<String> fuseOpts = opts.getFuseOpts();
// Force direct_io in FUSE: writes and reads bypass the kernel page
// cache and go directly to alluxio. This avoids extra memory copies
// in the write path.
fuseOpts.add("-odirect_io");
try {
fs.mount(Paths.get(opts.getMountPoint()), true, opts.isDebug(), fuseOpts.toArray(new String[0]));
} finally {
fs.umount();
}
}
use of alluxio.client.file.FileSystem in project alluxio by Alluxio.
the class ClientPool method getClient.
/**
* Returns a {@link FileSystem} client. This client does not need to be
* closed directly, but can be closed by calling {@link #close()} on this object.
*
* @return a {@link FileSystem} client
* @throws IOException when the operation fails
*/
public FileSystem getClient() throws IOException {
final FileSystem fs = FileSystem.Factory.get();
mClients.add(fs);
return fs;
}
use of alluxio.client.file.FileSystem in project alluxio by Alluxio.
the class LineageMasterIntegrationTest method lineageRecovery.
/**
* Tests that a lineage job is executed when the output file for the lineage is reported as lost.
*
* The checkpoint interval is set high so that we are guaranteed to call reportLostFile
* before persistence is complete.
*/
@Test(timeout = 100000)
@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.MASTER_LINEAGE_CHECKPOINT_INTERVAL_MS, "100000" })
public void lineageRecovery() throws Exception {
final File logFile = mFolder.newFile();
// Delete the log file so that when it starts to exist we know that it was created by the
// lineage recompute job
logFile.delete();
FileSystem fs = FileSystem.Factory.get();
try (LineageMasterClient lineageClient = getLineageMasterClient()) {
lineageClient.createLineage(ImmutableList.<String>of(), ImmutableList.of("/testFile"), new CommandLineJob("echo hello world", new JobConf(logFile.getAbsolutePath())));
FileOutStream out = fs.createFile(new AlluxioURI("/testFile"));
out.write("foo".getBytes());
out.close();
lineageClient.reportLostFile("/testFile");
}
// Wait for the log file to be created by the recompute job
CommonUtils.waitFor("the log file to be written", new Function<Void, Boolean>() {
@Override
public Boolean apply(Void input) {
if (!logFile.exists()) {
return false;
}
try (BufferedReader reader = new BufferedReader(new FileReader(logFile))) {
String line = reader.readLine();
return line != null && line.equals("hello world");
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
}, WaitForOptions.defaults().setTimeout(100 * Constants.SECOND_MS));
}
use of alluxio.client.file.FileSystem in project alluxio by Alluxio.
the class ClusterInitializationTest method recoverClusterSuccess.
/**
* When a user starts a cluster with journal logs, which are generated by previous running
* cluster owned by the same user, it should succeed.
*/
@Test
@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.SECURITY_LOGIN_USERNAME, SUPER_USER })
public void recoverClusterSuccess() throws Exception {
FileSystem fs = mLocalAlluxioClusterResource.get().getClient();
fs.createFile(new AlluxioURI("/testFile")).close();
mLocalAlluxioClusterResource.get().stopFS();
LoginUserTestUtils.resetLoginUser(SUPER_USER);
// user alluxio can recover master from journal
FileSystemMaster fileSystemMaster = MasterTestUtils.createLeaderFileSystemMasterFromJournal();
AuthenticatedClientUser.set(SUPER_USER);
Assert.assertEquals(SUPER_USER, fileSystemMaster.getFileInfo(new AlluxioURI("/testFile")).getOwner());
}
use of alluxio.client.file.FileSystem in project alluxio by Alluxio.
the class ClusterInitializationTest method recoverClusterFail.
/**
* When a user starts a cluster with journal logs, which are generated by previous running
* cluster owned by a different user, it should fail and throw an exception.
*/
@Test
@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.SECURITY_LOGIN_USERNAME, SUPER_USER })
public void recoverClusterFail() throws Exception {
mThrown.expect(RuntimeException.class);
mThrown.expectMessage(ExceptionMessage.PERMISSION_DENIED.getMessage("Unauthorized user on root"));
FileSystem fs = mLocalAlluxioClusterResource.get().getClient();
fs.createFile(new AlluxioURI("/testFile")).close();
mLocalAlluxioClusterResource.get().stopFS();
LoginUserTestUtils.resetLoginUser(USER);
// user jack cannot recover master from journal, in which the root is owned by alluxio.
MasterTestUtils.createLeaderFileSystemMasterFromJournal();
}
Aggregations