this.pipesThreads=pt;
}
public void run() {
Environment en = Environment.getInstance();
Pipe pipe=null;
try {
// Is queue empty?
while (!this.peq.isQueueEmpty()) {
// Get first PipeExecutionRequest in queue
PipeExecutionRequest per = peq.getFirst();
en.log("Getting pipe from request queue");
pipe=per.getPipe();
en.log("Got pipe: "+pipe.getName());
// Set PipeExecutionRequest start timestamp
per.setStartedDate(new Date());
en.log("Set execution start time and updating pipe: "+pipe.getName());
// Update PipeExecutionRequst
peq.updatePERequest(per);
en.log("Starting execution of pipe: "+pipe.getName());
// Start pipe transfer with request creation date
pipe.transfer(this.ti, per.getCreatedDate());
en.log("Finished execution of pipe: "+pipe.getName());
// Update pipe after execution
peq.updatePipe();
en.log("Updated pipe "+pipe.getName());
// Remove completed PipeExecutionRequest from queue
peq.deleteRequest(per.getId());
en.log("Removed pipe "+ pipe.getName()+" from execution queue");
}
}
catch(Exception e){
en.log(e.getMessage(), e);
}
finally {
// Remove persister from persisters, otherwise repeated execution of pipe may fail
SyncroHttpStart.persisters.remove(pers.getDatabaseName()+pipe.getName());
// Remove pipe and thread from webapp context (because queue is empty now)
LinkedList<PipeWrapper> pipesThreadsToRemove = new LinkedList<PipeWrapper>();
Iterator pipeWrapperIt = pipesThreads.keySet().iterator();
while (pipeWrapperIt.hasNext()){
PipeWrapper pw = (PipeWrapper)pipeWrapperIt.next();
Pipe p = pw.getPipe();
if(p.equals(pipe) && pw.getDatabase().equals(pers.getDatabaseName())){
pipesThreadsToRemove.add(pw);
}
}
Iterator ptRemoveIt = pipesThreadsToRemove.iterator();
while (ptRemoveIt.hasNext()){