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();
}
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;
}
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());
}
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();
}
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();
}
Aggregations