Package eu.planets_project.ifr.core.wee.api.workflow

Examples of eu.planets_project.ifr.core.wee.api.workflow.WorkflowInstance


     
      //1) get the WEEManager instance - required in the same JVM
        WeeManager weeManager = WeeManagerImpl.getWeeManagerInstance();
       
      //2) extract the Message's payload 
      WorkflowInstance wf = null;
      UUID uuid = null;
      try {
        TextMessage msg = null;
          if (m instanceof TextMessage) {
              msg = (TextMessage) m;
              log.debug("WorkflowExecutionEngine: received ObjectMessage at timestamp: " + msg.getJMSTimestamp());
          }
          // for ObjectMessages: uuid = UUID.fromString(msg.getStringProperty("UUID"));
          uuid = UUID.fromString(msg.getText());
          /*
           *  WorkflowInstance object cannot be Serialized due to the org.jboss.ws.core.jaxws.client.ClientProxy
           *  it contains that cannot be serialized. Therefore a callback to the weeManager for fetching this object
           *  is performed.
           *  Not possible:  wf = (WorkflowInstance)msg.getObject();
           */
          wf = ((WeeManagerImpl)weeManager).getWorkflowInstance(uuid);
          //for testing poolsize 1
          //Thread.currentThread().sleep(30000);

      } catch (Exception e) {
          log.error("WorkflowExecutionEngine: error receiving message workflow payload or UUID",e);
          if(uuid!=null){
            weeManager.notify(uuid,WorkflowExecutionStatus.FAILED);
          }
          return;
      }
               
       
        //set status for the workflow inISRUNNING
      weeManager.notify(uuid,WorkflowExecutionStatus.RUNNING);

        //3) executeWorkflow and get WF Result
      WorkflowResult ret = wf.initializeExecution();
      try {
        log.debug("WorkflowExecutionEngine: start executing wf ID: " + wf.getWorkflowID());
       
        //EXECUTES THE WF INSTANCE
      List<DigitalObject> payload = wf.getData();
      int count = 1;
      for(DigitalObject digo : payload){
        //process the payload item by item - workflowResult appends individual log items
        ret = wf.execute(digo);
        count+=1;
        int progress = (100/payload.size())*count;
        weeManager.notify(uuid, ret, WorkflowExecutionStatus.RUNNING, progress);
      }
      ret = wf.finalizeExecution();
     
     
      log.debug("WorkflowExecutionEngine: completed executing wf ID: " + wf.getWorkflowID());
    } catch (Exception e) {
      log.error("WorkflowExecutionEngine: error running Workflow.execute()",e);
      //set WeeManagerstatus 'failed'
      weeManager.notify(uuid, WorkflowExecutionStatus.FAILED);
      return;
View Full Code Here


  /* (non-Javadoc)
   * @see eu.planets_project.ifr.core.wee.api.WeeManager#getPositionInQueue(java.util.UUID)
   */
  public int getPositionInQueue(UUID ticket) throws PlanetsException{
    if(this.mapUUIDtoWF.containsKey(ticket)){
      WorkflowInstance wf = mapUUIDtoWF.get(ticket);
      return this.localJobqueue.indexOf(wf);
    }
    log.debug("WEEManager: requesting position for unknown ticket #"+ticket);
    throw new PlanetsException("WEEManager: requesting position for unknown ticket #"+ticket);
  }
View Full Code Here

    }
    log.debug("WEEManager: notify called from execution engine on status: "+status+" ticket #"+ticket);
  }
 
  private void removeWorkflowFromLocalQueue(UUID ticket){
    WorkflowInstance executedWF = this.mapUUIDtoWF.get(ticket);
    //checkMessagesSkipped(executedWF);
    log.debug("WEEManager: removing ticket#: "+ticket+" from local job queue");
    this.localJobqueue.remove(executedWF);
  }
View Full Code Here

   
    wfConfUtil.checkValidXMLConfig(xmlWorkflowConfig);
    //read the xml config data and create java representation of it
    WorkflowConf wfConf = WorkflowConfigUtil.unmarshalWorkflowConfig(xmlWorkflowConfig);
    //use workflowFactory to create a new WorkflowInstance with the provided data
    WorkflowInstance wfInstance = WorkflowFactory.create(wfConf, digObjs);
    log.debug("created workflow instance ID: "+wfInstance.getWorkflowID() +" for template "+wfConf.getTemplate().getClazz());
    //submit the wfInstance for execution
    UUID ticket = weeManager.submitWorkflow(wfInstance);
    log.debug("submitted workflow instance ID: "+wfInstance.getWorkflowID() +" position in queue: "+weeManager.getPositionInQueue(ticket));
    //hand back the ticket
    return ticket;
  }
View Full Code Here

   
    //hand over the WorkflowContext
    wft.setWorkflowContext(getOrInitWFContext());
   
    //4) Build the WorkflowInstance
    WorkflowInstance wfi = new WorkflowInstanceImpl(wft);
    //provide the template with a reference to the wfi's UUID e.g. relevant for logging, storing, ...
    wft.setWorkflowInstanceID(wfi.getWorkflowID());
   
    return wfi;
  }
View Full Code Here

TOP

Related Classes of eu.planets_project.ifr.core.wee.api.workflow.WorkflowInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.