/** * @param viskoService * @param inputDataURL * @param serviceIndex * @return * @throws ExecutionException */ private String executeService( edu.utep.trustlab.visko.ontology.viskoService.Service viskoService, String inputDataURL, int serviceIndex) throws ExecutionException { OWLKnowledgeBase kb = OWLFactory.createKB(); Service service = viskoService.getOWLSService().getIndividual(); Process process = service.getProcess(); ValueMap<Input, OWLValue> inputs = OWLSParameterBinder.buildInputValueMap( process, inputDataURL, job.getPipeline().getParameterBindings(), kb); String outputDataURL = null; if (inputs != null) { ValueMap<Output, OWLValue> outputs; if (job.isSimulated()) outputDataURL = ServiceSimulator.exec(); else { outputs = exec.execute(process, inputs, kb); OWLDataValue out = (OWLDataValue) outputs.getValue(process.getOutput()); outputDataURL = out.toString(); } if (job.getProvenanceLogging()) { pmlLogger.recordServiceInvocation(viskoService, inputDataURL, outputDataURL, inputs); provLogger.recordServiceInvocation(viskoService, inputDataURL, outputDataURL, inputs); } } return outputDataURL; }
/** * Because the PipelineExecutor is synchronous, calling this method signals that the previous * PipelineExecutorJob has completed and 'pipelineJob' is the next one to perform. * * @param pipelineJob a new Job to execute (replacing the already-finished old Job). */ public void setJob(PipelineExecutorJob pipelineJob) { job = pipelineJob; job.getJobStatus().setTotalServiceCount(job.getPipeline().size()); if (job.getProvenanceLogging()) { pmlLogger = new PML2PipelineExecutionProvenanceLogger(); provLogger = new PROVPipelineExecutionProvenanceLogger(); String viskoQuery = job.getPipeline().getParentPipelineSet().getQuery().toString(); pmlLogger.recordVisKoQuery(viskoQuery); provLogger.recordVisKoQuery(viskoQuery); } exec = OWLSFactory.createExecutionEngine(); isScheduledForTermination = false; }
public void process() { // TODO: How many methods can you have with these synonyms: process, run, // executePipeline? (apparently, 3) if (job.getJobStatus().getPipelineState() == PipelineExecutorJobStatus.PipelineState.NEW) { t = new Thread(this); t.setDaemon(true); t.start(); } }
@Override public void run() { try { if (!job.getPipeline().hasInputData()) { job.getJobStatus().setPipelineState(PipelineExecutorJobStatus.PipelineState.NODATA); } else if (job.getPipeline().isEmpty()) { job.getJobStatus().setPipelineState(PipelineExecutorJobStatus.PipelineState.EMPTYPIPELINE); } else { executePipeline(); job.getJobStatus().setPipelineState(PipelineExecutorJobStatus.PipelineState.COMPLETE); } } catch (Exception e) { e.printStackTrace(); job.getJobStatus().setPipelineState(PipelineExecutorJobStatus.PipelineState.ERROR); } }
private void executePipeline() throws ExecutionException { if (job.getProvenanceLogging()) { provLogger.recordPipelineStart(); pmlLogger.recordPipelineStart(); } job.getJobStatus().setPipelineState(PipelineExecutorJobStatus.PipelineState.RUNNING); String resultURL = job.getPipeline().getArtifactURL(); System.out.println(job.getJobStatus()); for (int i = 0; i < job.getPipeline().size(); i++) { edu.utep.trustlab.visko.ontology.viskoService.Service viskoService = job.getPipeline().getService(i); // Capture initial dataset if (job.getProvenanceLogging() && i == 0) { pmlLogger.recordInitialDataset(resultURL, job.getPipeline().getService(i)); provLogger.recordInitialDataset(resultURL, job.getPipeline().getService(i)); } job.getJobStatus().setCurrentService(viskoService.getOWLSService().getURI(), i); System.out.println(job.getJobStatus()); resultURL = executeService(viskoService, resultURL, i); if (isScheduledForTermination) { System.out.println("This thread's execution was interrupted and will quit!"); job.getJobStatus().setPipelineState(PipelineExecutorJobStatus.PipelineState.INTERRUPTED); break; } } job.setFinalResultURL(resultURL); if (job.getProvenanceLogging()) { provLogger.recordPipelineEnd(job); pmlLogger.recordPipelineEnd(job); // Set URIs on Job job.setPMLQueryURI(pmlLogger.finish()); job.setProvQueryURI(provLogger.finish()); } }