Search in sources :

Example 11 with CommandLineJob

use of alluxio.job.CommandLineJob 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 12 with CommandLineJob

use of alluxio.job.CommandLineJob in project alluxio by Alluxio.

the class LineageMasterIntegrationTest method before.

@Before
public void before() throws Exception {
    AuthenticatedClientUser.set("test");
    mJob = new CommandLineJob("test", new JobConf("output"));
}
Also used : CommandLineJob(alluxio.job.CommandLineJob) JobConf(alluxio.job.JobConf) Before(org.junit.Before)

Example 13 with CommandLineJob

use of alluxio.job.CommandLineJob in project alluxio by Alluxio.

the class AlluxioLineageTest method createLineage.

@Test
public void createLineage() throws Exception {
    List<AlluxioURI> inputFiles = Lists.newArrayList(new AlluxioURI("input"));
    List<AlluxioURI> outputFiles = Lists.newArrayList(new AlluxioURI("output"));
    CommandLineJob job = new CommandLineJob("cmd", new JobConf("out"));
    mAlluxioLineage.createLineage(inputFiles, outputFiles, job);
    Mockito.verify(mLineageMasterClient).createLineage(Lists.newArrayList("input"), Lists.newArrayList("output"), job);
    // verify client is released
    Mockito.verify(mLineageContext).releaseMasterClient(mLineageMasterClient);
}
Also used : CommandLineJob(alluxio.job.CommandLineJob) JobConf(alluxio.job.JobConf) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

CommandLineJob (alluxio.job.CommandLineJob)13 JobConf (alluxio.job.JobConf)12 AlluxioURI (alluxio.AlluxioURI)6 ArrayList (java.util.ArrayList)5 Before (org.junit.Before)5 Test (org.junit.Test)5 FileSystemMaster (alluxio.master.file.FileSystemMaster)3 Config (alluxio.LocalAlluxioClusterResource.Config)2 FileSystem (alluxio.client.file.FileSystem)2 AlluxioLineage (alluxio.client.lineage.AlluxioLineage)2 LineageFileSystem (alluxio.client.lineage.LineageFileSystem)2 FileSystemMasterView (alluxio.master.file.meta.FileSystemMasterView)2 LineageIdGenerator (alluxio.master.lineage.meta.LineageIdGenerator)2 LineageStore (alluxio.master.lineage.meta.LineageStore)2 RestApiTest (alluxio.rest.RestApiTest)2 TestCase (alluxio.rest.TestCase)2 FileOutStream (alluxio.client.file.FileOutStream)1 LineageMasterClient (alluxio.client.lineage.LineageMasterClient)1 DeleteLineageOptions (alluxio.client.lineage.options.DeleteLineageOptions)1 Job (alluxio.job.Job)1