use of uk.gov.gchq.gaffer.operation.Operation in project Gaffer by gchq.
the class Store method executeJob.
/**
* Executes a given operation chain job and returns the job detail.
*
* @param operationChain the operation chain to execute.
* @param user the user executing the job
* @return the job detail
* @throws OperationException thrown if jobs are not configured.
*/
public JobDetail executeJob(final OperationChain<?> operationChain, final User user) throws OperationException {
if (null == jobTracker) {
throw new OperationException("Running jobs has not configured.");
}
final Context context = createContext(user);
if (isSupported(ExportToGafferResultCache.class)) {
boolean hasExport = false;
for (final Operation operation : operationChain.getOperations()) {
if (operation instanceof ExportToGafferResultCache) {
hasExport = true;
break;
}
}
if (!hasExport) {
operationChain.getOperations().add(new ExportToGafferResultCache());
}
}
final JobDetail initialJobDetail = addOrUpdateJobDetail(operationChain, context, null, JobStatus.RUNNING);
new Thread(() -> {
try {
_execute(operationChain, context);
addOrUpdateJobDetail(operationChain, context, null, JobStatus.FINISHED);
} catch (final Throwable t) {
LOGGER.warn("Operation chain job failed to execute", t);
addOrUpdateJobDetail(operationChain, context, t.getMessage(), JobStatus.FAILED);
}
}).start();
return initialJobDetail;
}
use of uk.gov.gchq.gaffer.operation.Operation in project Gaffer by gchq.
the class Store method handleOperationChain.
protected <OUTPUT> OUTPUT handleOperationChain(final OperationChain<OUTPUT> operationChain, final Context context) throws OperationException {
Object result = null;
for (final Operation op : operationChain.getOperations()) {
updateOperationInput(op, result);
result = handleOperation(op, context);
}
return (OUTPUT) result;
}
Aggregations