use of org.apache.metron.rest.model.pcap.PcapStatus in project metron by apache.
the class PcapServiceImpl method submit.
@Override
public PcapStatus submit(String username, PcapRequest pcapRequest) throws RestException {
List<PcapStatus> runningJobs = getJobStatus(username, JobStatus.State.RUNNING);
Integer userJobLimit = environment.getProperty(MetronRestConstants.USER_JOB_LIMIT_SPRING_PROPERTY, Integer.class, 1);
if (runningJobs != null && runningJobs.size() >= userJobLimit) {
String jobIds = runningJobs.stream().map(PcapStatus::getJobId).collect(Collectors.joining(", "));
String message = String.format("Cannot submit job because a job is already running. " + "Please contact the administrator to cancel job(s) with id(s) %s", jobIds);
throw new RestException(message);
}
try {
setPcapOptions(username, pcapRequest);
pcapRequest.setFields();
pcapJobSupplier.setPcapRequest(pcapRequest);
JobStatus jobStatus = jobManager.submit(pcapJobSupplier, username);
return jobStatusToPcapStatus(jobStatus);
} catch (IOException | JobException e) {
throw new RestException(e);
}
}
use of org.apache.metron.rest.model.pcap.PcapStatus in project metron by apache.
the class PcapServiceImpl method jobStatusToPcapStatus.
protected PcapStatus jobStatusToPcapStatus(JobStatus jobStatus) {
PcapStatus pcapStatus = new PcapStatus();
pcapStatus.setJobId(jobStatus.getJobId());
pcapStatus.setJobStatus(jobStatus.getState().toString());
pcapStatus.setDescription(jobStatus.getDescription());
pcapStatus.setPercentComplete(jobStatus.getPercentComplete());
return pcapStatus;
}
Aggregations