Search in sources :

Example 16 with FileSystem

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();
    }
}
Also used : FileSystem(alluxio.client.file.FileSystem)

Example 17 with FileSystem

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;
}
Also used : FileSystem(alluxio.client.file.FileSystem)

Example 18 with FileSystem

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));
}
Also used : FileOutStream(alluxio.client.file.FileOutStream) LineageMasterClient(alluxio.client.lineage.LineageMasterClient) CommandLineJob(alluxio.job.CommandLineJob) FileSystem(alluxio.client.file.FileSystem) LineageFileSystem(alluxio.client.lineage.LineageFileSystem) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) File(java.io.File) JobConf(alluxio.job.JobConf) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 19 with FileSystem

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());
}
Also used : FileSystem(alluxio.client.file.FileSystem) FileSystemMaster(alluxio.master.file.FileSystemMaster) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 20 with FileSystem

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();
}
Also used : FileSystem(alluxio.client.file.FileSystem) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Aggregations

FileSystem (alluxio.client.file.FileSystem)23 AlluxioURI (alluxio.AlluxioURI)16 Test (org.junit.Test)10 URIStatus (alluxio.client.file.URIStatus)7 FileInStream (alluxio.client.file.FileInStream)6 FileOutStream (alluxio.client.file.FileOutStream)4 OpenFileOptions (alluxio.client.file.options.OpenFileOptions)2 LineageFileSystem (alluxio.client.lineage.LineageFileSystem)2 CommandLineJob (alluxio.job.CommandLineJob)2 JobConf (alluxio.job.JobConf)2 ArrayList (java.util.ArrayList)2 CreateFileOptions (alluxio.client.file.options.CreateFileOptions)1 RoundRobinPolicy (alluxio.client.file.policy.RoundRobinPolicy)1 AlluxioLineage (alluxio.client.lineage.AlluxioLineage)1 LineageMasterClient (alluxio.client.lineage.LineageMasterClient)1 DeleteLineageOptions (alluxio.client.lineage.options.DeleteLineageOptions)1 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)1 FileSystemMaster (alluxio.master.file.FileSystemMaster)1 UnderFileSystem (alluxio.underfs.UnderFileSystem)1 FileBlockInfo (alluxio.wire.FileBlockInfo)1