Search in sources :

Example 21 with JobInfo

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

the class StatCommand method formatOutput.

private String formatOutput(CommandLine cl, JobInfo info) {
    StringBuilder output = new StringBuilder();
    output.append("ID: ").append(info.getId()).append("\n");
    output.append("Name: ").append(info.getName()).append("\n");
    output.append("Description: ");
    if (cl.hasOption("v")) {
        output.append(info.getDescription());
    } else {
        output.append(StringUtils.abbreviate(info.getDescription(), 200));
    }
    output.append("\n");
    output.append("Status: ").append(info.getStatus()).append("\n");
    if (info.getErrorMessage() != null && !info.getErrorMessage().isEmpty()) {
        output.append("Error: ").append(info.getErrorMessage()).append("\n");
    }
    if (info.getResult() != null && !info.getResult().toString().isEmpty()) {
        output.append("Result: ").append(info.getResult().toString()).append("\n");
    }
    if (cl.hasOption("v")) {
        for (JobInfo childInfo : info.getChildren()) {
            output.append("Task ").append(childInfo.getId()).append("\n");
            if (childInfo instanceof TaskInfo) {
                TaskInfo taskInfo = (TaskInfo) childInfo;
                if (taskInfo.getWorkerHost() != null) {
                    output.append("\t").append("Worker: ").append(taskInfo.getWorkerHost()).append("\n");
                }
            }
            if (!childInfo.getDescription().isEmpty()) {
                output.append("\t").append("Description: ").append(StringUtils.abbreviate(childInfo.getDescription(), 200)).append("\n");
            }
            output.append("\t").append("Status: ").append(childInfo.getStatus()).append("\n");
            if (childInfo.getErrorMessage() != null && !childInfo.getErrorMessage().isEmpty()) {
                output.append("\t").append("Error: ").append(childInfo.getErrorMessage()).append("\n");
            }
            if (childInfo.getResult() != null) {
                output.append("\t").append("Result: ").append(childInfo.getResult()).append("\n");
            }
        }
    }
    return output.toString();
}
Also used : TaskInfo(alluxio.job.wire.TaskInfo) JobInfo(alluxio.job.wire.JobInfo)

Example 22 with JobInfo

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

the class StatCommand method run.

@Override
public int run(CommandLine cl) throws AlluxioException, IOException {
    long id = Long.parseLong(cl.getArgs()[0]);
    try (CloseableResource<JobMasterClient> client = JobContext.create(mFsContext.getClusterConf(), mFsContext.getClientContext().getUserState()).acquireMasterClientResource()) {
        JobInfo info = client.get().getJobStatusDetailed(id);
        System.out.print(formatOutput(cl, info));
    } catch (Exception e) {
        LOG.error("Failed to get status of the job", e);
        System.out.println("Failed to get status of the job " + id);
        return -1;
    }
    return 0;
}
Also used : JobMasterClient(alluxio.client.job.JobMasterClient) JobInfo(alluxio.job.wire.JobInfo) AlluxioException(alluxio.exception.AlluxioException) IOException(java.io.IOException) InvalidArgumentException(alluxio.exception.status.InvalidArgumentException)

Example 23 with JobInfo

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

the class MigrateIntegrationTest method migrateFile.

@Test
public void migrateFile() throws Exception {
    File ufsMountPoint1 = mFolder.newFolder();
    File ufsMountPoint2 = mFolder.newFolder();
    mFileSystem.mount(new AlluxioURI("/mount1"), new AlluxioURI(ufsMountPoint1.getAbsolutePath()));
    mFileSystem.mount(new AlluxioURI("/mount2"), new AlluxioURI(ufsMountPoint2.getAbsolutePath()));
    String source = "/mount1/source";
    String destination = "/mount2/destination";
    createFileWithTestBytes(source);
    long jobId = mJobMaster.run(new MigrateConfig(source, destination, WriteType.CACHE_THROUGH.toString(), true));
    JobInfo info = waitForJobToFinish(jobId);
    Assert.assertTrue(mFileSystem.exists(new AlluxioURI(source)));
    Assert.assertTrue(mFileSystem.exists(new AlluxioURI(destination)));
    checkFileContainsTestBytes(destination);
    // One worker task is needed when moving within the same mount point.
    Assert.assertEquals(1, info.getChildren().size());
}
Also used : JobInfo(alluxio.job.wire.JobInfo) File(java.io.File) AlluxioURI(alluxio.AlluxioURI) JobIntegrationTest(alluxio.job.JobIntegrationTest) Test(org.junit.Test)

Example 24 with JobInfo

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

the class JobTestUtils method waitForJobStatus.

/**
 * Waits for the job with the given job ID to be in the one of given states.
 *
 * @param jobMaster the job master running the job
 * @param jobId the ID of the job
 * @param statuses set of statuses to wait for
 * @return the status of the job waited for
 */
public static JobInfo waitForJobStatus(final JobMaster jobMaster, final long jobId, final Set<Status> statuses) throws InterruptedException, TimeoutException {
    final AtomicReference<JobInfo> singleton = new AtomicReference<>();
    final AtomicReference<String> jobStatus = new AtomicReference<>();
    try {
        CommonUtils.waitFor(String.format("job %d to be one of status %s", jobId, Arrays.toString(statuses.toArray())), () -> {
            JobInfo info;
            try {
                info = jobMaster.getStatus(jobId);
                jobStatus.set(info.toString());
                if (statuses.contains(info.getStatus())) {
                    singleton.set(info);
                }
                return statuses.contains(info.getStatus());
            } catch (JobDoesNotExistException e) {
                throw Throwables.propagate(e);
            }
        }, WaitForOptions.defaults().setTimeoutMs(30 * Constants.SECOND_MS));
    } catch (TimeoutException e) {
        throw new TimeoutException(String.format("%s, %s", e.getMessage(), jobStatus.toString()));
    }
    return singleton.get();
}
Also used : JobDoesNotExistException(alluxio.exception.JobDoesNotExistException) JobInfo(alluxio.job.wire.JobInfo) AtomicReference(java.util.concurrent.atomic.AtomicReference) TimeoutException(java.util.concurrent.TimeoutException)

Example 25 with JobInfo

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

the class JobTestUtils method waitForJobStatus.

/**
 * Waits for the job with the given job ID to be in the one of given states in provided timeout.
 *
 * @param jobMaster the job master running the job
 * @param jobId the ID of the job
 * @param statuses set of statuses to wait for
 * @param timeout the timeout for the wait period
 * @return the status of the job waited for
 */
public static JobInfo waitForJobStatus(final JobMaster jobMaster, final long jobId, final Set<Status> statuses, int timeout) throws InterruptedException, TimeoutException {
    final AtomicReference<JobInfo> singleton = new AtomicReference<>();
    CommonUtils.waitFor(String.format("job %d to be one of status %s", jobId, Arrays.toString(statuses.toArray())), () -> {
        JobInfo info;
        try {
            info = jobMaster.getStatus(jobId);
            if (statuses.contains(info.getStatus())) {
                singleton.set(info);
            }
            return statuses.contains(info.getStatus());
        } catch (JobDoesNotExistException e) {
            throw Throwables.propagate(e);
        }
    }, WaitForOptions.defaults().setTimeoutMs(timeout * Constants.SECOND_MS));
    return singleton.get();
}
Also used : JobDoesNotExistException(alluxio.exception.JobDoesNotExistException) JobInfo(alluxio.job.wire.JobInfo) AtomicReference(java.util.concurrent.atomic.AtomicReference)

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