use of com.baidu.hugegraph.entity.load.JobManager in project incubator-hugegraph-toolchain by apache.
the class LoadTaskController method create.
@PostMapping
public LoadTask create(@PathVariable("connId") int connId, @PathVariable("jobId") int jobId, @RequestBody LoadTask entity) {
JobManager jobEntity = this.jobService.get(jobId);
Ex.check(jobEntity != null, "job-manager.not-exist.id", jobId);
Ex.check(jobEntity.getJobStatus() == JobStatus.SETTING, "load.task.create.no-permission");
synchronized (this.service) {
Ex.check(this.service.count() < LIMIT, "load.task.reached-limit", LIMIT);
entity.setConnId(connId);
this.service.save(entity);
}
return entity;
}
use of com.baidu.hugegraph.entity.load.JobManager in project incubator-hugegraph-toolchain by apache.
the class LoadTaskController method resume.
@PostMapping("resume")
public LoadTask resume(@PathVariable("connId") int connId, @PathVariable("jobId") int jobId, @RequestParam("task_id") int taskId) {
GraphConnection connection = this.connService.get(connId);
if (connection == null) {
throw new ExternalException("graph-connection.not-exist.id", connId);
}
JobManager jobEntity = this.jobService.get(jobId);
Ex.check(jobEntity != null, "job-manager.not-exist.id", jobId);
Ex.check(jobEntity.getJobStatus() == JobStatus.LOADING, "load.task.pause.no-permission");
try {
return this.service.resume(taskId);
} finally {
jobEntity.setJobStatus(JobStatus.LOADING);
jobEntity.setUpdateTime(HubbleUtil.nowDate());
this.jobService.update(jobEntity);
}
}
use of com.baidu.hugegraph.entity.load.JobManager in project incubator-hugegraph-toolchain by apache.
the class LoadTaskController method retry.
@PostMapping("retry")
public LoadTask retry(@PathVariable("connId") int connId, @PathVariable("jobId") int jobId, @RequestParam("task_id") int taskId) {
GraphConnection connection = this.connService.get(connId);
if (connection == null) {
throw new ExternalException("graph-connection.not-exist.id", connId);
}
JobManager jobEntity = this.jobService.get(jobId);
Ex.check(jobEntity != null, "job-manager.not-exist.id", jobId);
Ex.check(jobEntity.getJobStatus() == JobStatus.LOADING, "load.task.pause.no-permission");
try {
return this.service.retry(taskId);
} finally {
jobEntity.setJobStatus(JobStatus.LOADING);
jobEntity.setUpdateTime(HubbleUtil.nowDate());
this.jobService.update(jobEntity);
}
}
use of com.baidu.hugegraph.entity.load.JobManager in project incubator-hugegraph-toolchain by apache.
the class FileUploadController method delete.
@DeleteMapping
public Boolean delete(@PathVariable("connId") int connId, @PathVariable("jobId") int jobId, @RequestParam("name") String fileName, @RequestParam("token") String token) {
JobManager jobEntity = this.jobService.get(jobId);
Ex.check(jobEntity != null, "job-manager.not-exist.id", jobId);
Ex.check(jobEntity.getJobStatus() == JobStatus.UPLOADING || jobEntity.getJobStatus() == JobStatus.MAPPING || jobEntity.getJobStatus() == JobStatus.SETTING, "deleted.file.no-permission");
FileMapping mapping = this.service.get(connId, jobId, fileName);
Ex.check(mapping != null, "load.file-mapping.not-exist.name", fileName);
ReadWriteLock lock = this.uploadingTokenLocks().get(token);
if (lock != null) {
lock.writeLock().lock();
}
try {
this.service.deleteDiskFile(mapping);
log.info("Prepare to remove file mapping {}", mapping.getId());
this.service.remove(mapping.getId());
long jobSize = jobEntity.getJobSize() - mapping.getTotalSize();
jobEntity.setJobSize(jobSize);
this.jobService.update(jobEntity);
if (lock != null) {
this.uploadingTokenLocks().remove(token);
}
return true;
} finally {
if (lock != null) {
lock.writeLock().unlock();
}
}
}
use of com.baidu.hugegraph.entity.load.JobManager in project incubator-hugegraph-toolchain by apache.
the class FileUploadController method nextStep.
@PutMapping("next-step")
public JobManager nextStep(@PathVariable("jobId") int jobId) {
JobManager jobEntity = this.jobService.get(jobId);
Ex.check(jobEntity != null, "job-manager.not-exist.id", jobId);
Ex.check(jobEntity.getJobStatus() == JobStatus.UPLOADING, "job.manager.status.unexpected", JobStatus.UPLOADING, jobEntity.getJobStatus());
jobEntity.setJobStatus(JobStatus.MAPPING);
this.jobService.update(jobEntity);
return jobEntity;
}
Aggregations