use of com.baidu.hugegraph.entity.load.LoadTask in project incubator-hugegraph-toolchain by apache.
the class LoadTaskService method pause.
public LoadTask pause(int taskId) {
LoadTask task = this.runningTaskContainer.get(taskId);
Ex.check(task.getStatus() == LoadStatus.RUNNING, "Can only pause the RUNNING task");
// Mark status as paused, should set before context.stopLoading()
task.setStatus(LoadStatus.PAUSED);
// Let HugeGraphLoader stop
task.stop();
task.lock();
try {
this.update(task);
this.runningTaskContainer.remove(taskId);
} finally {
task.unlock();
}
return task;
}
use of com.baidu.hugegraph.entity.load.LoadTask in project incubator-hugegraph-toolchain by apache.
the class LoadTaskService method start.
public LoadTask start(GraphConnection connection, FileMapping fileMapping) {
this.sslService.configSSL(this.config, connection);
LoadTask task = this.buildLoadTask(connection, fileMapping);
this.save(task);
// Executed in other threads
this.taskExecutor.execute(task, () -> this.update(task));
// Save current load task
this.runningTaskContainer.put(task.getId(), task);
return task;
}
use of com.baidu.hugegraph.entity.load.LoadTask in project incubator-hugegraph-toolchain by apache.
the class JobManagerService method list.
public IPage<JobManager> list(int connId, int pageNo, int pageSize, String content) {
QueryWrapper<JobManager> query = Wrappers.query();
query.eq("conn_id", connId);
if (!content.isEmpty()) {
query.like("job_name", content);
}
query.orderByDesc("create_time");
Page<JobManager> page = new Page<>(pageNo, pageSize);
IPage<JobManager> list = this.mapper.selectPage(page, query);
list.getRecords().forEach(task -> {
if (task.getJobStatus() == JobStatus.LOADING) {
List<LoadTask> tasks = this.taskService.taskListByJob(task.getId());
JobStatus status = JobStatus.SUCCESS;
for (LoadTask loadTask : tasks) {
if (loadTask.getStatus().inRunning() || loadTask.getStatus() == LoadStatus.PAUSED || loadTask.getStatus() == LoadStatus.STOPPED) {
status = JobStatus.LOADING;
break;
}
if (loadTask.getStatus() == LoadStatus.FAILED) {
status = JobStatus.FAILED;
break;
}
}
if (status == JobStatus.SUCCESS || status == JobStatus.FAILED) {
task.setJobStatus(status);
this.update(task);
}
}
Date endDate = task.getJobStatus() == JobStatus.FAILED || task.getJobStatus() == JobStatus.SUCCESS ? task.getUpdateTime() : HubbleUtil.nowDate();
task.setJobDuration(endDate.getTime() - task.getCreateTime().getTime());
});
return list;
}
use of com.baidu.hugegraph.entity.load.LoadTask in project incubator-hugegraph-toolchain by apache.
the class JobManagerController method reason.
@GetMapping("{id}/reason")
public Response reason(@PathVariable("connId") int connId, @PathVariable("id") int id) {
JobManager job = this.service.get(id);
if (job == null) {
throw new ExternalException("job.manager.not-exist.id", id);
}
List<LoadTask> tasks = this.taskService.batchTasks(job.getId());
List<JobManagerReasonResult> reasonResults = new ArrayList<>();
tasks.forEach(task -> {
JobManagerReasonResult reasonResult = new JobManagerReasonResult();
int fileId = task.getFileId();
String reason = "";
if (task.getStatus() == LoadStatus.FAILED) {
FileMapping mapping = this.fmService.get(fileId);
reason = this.taskService.readLoadFailedReason(mapping);
}
reasonResult.setTaskId(task.getJobId());
reasonResult.setFileId(task.getFileId());
reasonResult.setFileName(task.getFileName());
reasonResult.setReason(reason);
reasonResults.add(reasonResult);
});
return Response.builder().status(Constant.STATUS_OK).data(reasonResults).build();
}
use of com.baidu.hugegraph.entity.load.LoadTask in project incubator-hugegraph-toolchain by apache.
the class LoadTaskService method stop.
public LoadTask stop(int taskId) {
LoadTask task = this.runningTaskContainer.get(taskId);
if (task == null) {
task = this.get(taskId);
}
LoadStatus status = task.getStatus();
Ex.check(status == LoadStatus.RUNNING || status == LoadStatus.PAUSED, "Can only stop the RUNNING or PAUSED task");
// Mark status as stopped
task.setStatus(LoadStatus.STOPPED);
if (status == LoadStatus.RUNNING) {
task.stop();
}
task.lock();
try {
this.update(task);
this.runningTaskContainer.remove(taskId);
} finally {
task.unlock();
}
return task;
}
Aggregations