Search in sources :

Example 26 with JobInfo

use of alluxio.job.wire.JobInfo in project alluxio by Alluxio.

the class PersistIntegrationTest method persistOnlyCompleteFiles.

@Test(timeout = 30000)
public void persistOnlyCompleteFiles() throws Exception {
    AlluxioURI path = new AlluxioURI("/" + CommonUtils.randomAlphaNumString(10));
    // Create file, but do not complete
    FileOutStream os = mFileSystem.createFile(path, CreateFilePOptions.newBuilder().setWriteType(WritePType.MUST_CACHE).setMode(TEST_MODE.toProto()).build());
    URIStatus status = mFileSystem.getStatus(path);
    // Generate a temporary path to be used by the persist job.
    String tempUfsPath = PathUtils.temporaryFileName(System.currentTimeMillis(), status.getUfsPath());
    JobMaster jobMaster = mLocalAlluxioJobCluster.getMaster().getJobMaster();
    // Run persist job on incomplete file (expected to fail)
    long failId = jobMaster.run(new PersistConfig(path.toString(), status.getMountId(), false, tempUfsPath));
    CommonUtils.waitFor("Wait for persist job to complete", () -> {
        try {
            JobInfo jobInfo = jobMaster.getStatus(failId);
            Assert.assertNotEquals("Persist should not succeed for incomplete file", COMPLETED, jobInfo.getStatus());
            if (jobInfo.getStatus() == FAILED) {
                // failed job is expected
                Assert.assertTrue("Failure expected to be about incomplete files", jobInfo.getErrorMessage().toLowerCase().contains("incomplete"));
                return true;
            }
            return false;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }, WaitForOptions.defaults().setTimeoutMs(10 * Constants.SECOND_MS).setInterval(100));
    // close the file to allow persist to happen
    os.close();
    // Run persist job on complete file (expected to succeed)
    long successId = jobMaster.run(new PersistConfig(path.toString(), status.getMountId(), false, tempUfsPath));
    CommonUtils.waitFor("Wait for persist job to complete", () -> {
        try {
            JobInfo jobInfo = jobMaster.getStatus(successId);
            Assert.assertNotEquals("Persist should not fail", FAILED, jobInfo.getStatus());
            return jobInfo.getStatus() == COMPLETED;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }, WaitForOptions.defaults().setTimeoutMs(10 * Constants.SECOND_MS).setInterval(100));
}
Also used : JobMaster(alluxio.master.job.JobMaster) JobInfo(alluxio.job.wire.JobInfo) FileOutStream(alluxio.client.file.FileOutStream) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) JobIntegrationTest(alluxio.job.JobIntegrationTest) Test(org.junit.Test)

Example 27 with JobInfo

use of alluxio.job.wire.JobInfo in project alluxio by Alluxio.

the class CompositeIntegrationTest method waitSequential.

@Test
public void waitSequential() throws Exception {
    CompositeConfig config = new CompositeConfig(Lists.newArrayList(new SleepJobConfig(1000000), new SleepJobConfig(1)), true);
    long jobId = mJobMaster.run(config);
    JobInfo status = mJobMaster.getStatus(jobId);
    assertEquals(Status.RUNNING, status.getStatus());
    assertEquals(1, status.getChildren().size());
}
Also used : JobInfo(alluxio.job.wire.JobInfo) SleepJobConfig(alluxio.job.SleepJobConfig) JobIntegrationTest(alluxio.job.JobIntegrationTest) Test(org.junit.Test)

Aggregations

JobInfo (alluxio.job.wire.JobInfo)27 Test (org.junit.Test)14 AlluxioURI (alluxio.AlluxioURI)6 SleepJobConfig (alluxio.job.SleepJobConfig)6 JobConfig (alluxio.job.JobConfig)5 JobIntegrationTest (alluxio.job.JobIntegrationTest)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 FileInfo (alluxio.wire.FileInfo)4 IOException (java.io.IOException)4 Random (java.util.Random)4 JobDoesNotExistException (alluxio.exception.JobDoesNotExistException)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 URIStatus (alluxio.client.file.URIStatus)2 JobServiceSummary (alluxio.job.wire.JobServiceSummary)2 JobWorkerHealth (alluxio.job.wire.JobWorkerHealth)2 Status (alluxio.job.wire.Status)2 CompositeConfig (alluxio.job.workflow.composite.CompositeConfig)2 JobMaster (alluxio.master.job.JobMaster)2 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)2 UnderFileSystem (alluxio.underfs.UnderFileSystem)2