Examples of WorkflowTask


Examples of org.apache.oodt.cas.workflow.structs.WorkflowTask

            rs = statement.executeQuery(getTasksSql);
            tasks = new Vector();

            while (rs.next()) {
                // get an instance of the class name
                WorkflowTask task = DbStructFactory.getWorkflowTask(rs, true);

                if (task != null) {
                    task.setConditions(getConditionsByTaskId(task.getTaskId()));
                    task.setTaskConfig(getConfigurationByTaskId(task
                            .getTaskId()));
                    tasks.add(task);
                }
            }
View Full Code Here

Examples of org.apache.oodt.cas.workflow.structs.WorkflowTask

            throws RepositoryException {
        Connection conn = null;
        Statement statement = null;
        ResultSet rs = null;

        WorkflowTask task = null;

        try {
            conn = dataSource.getConnection();
            statement = conn.createStatement();

            String getTaskSql = "SELECT * FROM workflow_tasks WHERE workflow_task_id = "
                    + taskId;

            LOG
                    .log(Level.FINE, "getWorkflowTaskById: Executing: "
                            + getTaskSql);
            rs = statement.executeQuery(getTaskSql);

            while (rs.next()) {
                // get an instance of the class name
                task = DbStructFactory.getWorkflowTask(rs, false);
                task.setConditions(getConditionsByTaskId(task.getTaskId()));
                task.setTaskConfig(getConfigurationByTaskId(task.getTaskId()));
            }

        } catch (Exception e) {
            e.printStackTrace();
            LOG.log(Level.WARNING, "Exception getting task by id. Message: "
View Full Code Here

Examples of org.apache.oodt.cas.workflow.structs.WorkflowTask

                                + getTaskNameById(workflowInst
                                        .getCurrentTaskId()));
                continue;
            }

            WorkflowTask task = (WorkflowTask) taskIterator.next();
            workflowInst.setCurrentTaskId(task.getTaskId());

            // now persist it
            persistWorkflowInstance();

            // check to see if req met fields are present
            // if they aren't, set the status to METERROR, and then fail
            if (!checkTaskRequiredMetadata(task, this.workflowInst
                    .getSharedContext())) {
                this.workflowInst.setStatus(METADATA_MISSING);
                persistWorkflowInstance();
                // now break out of this run loop
                return;
            }

            // this is where the pre-conditions come in
            // only execute the below code when it's passed all of its
            // pre-conditions
            if (task.getConditions() != null) {
                while (!satisfied(task.getConditions(), task.getTaskId()) && !isStopped()) {

                    // if we're not paused, go ahead and pause us now
                    if (!isPaused()) {
                        pause();
                    }

                    LOG.log(Level.FINEST, "Pre-conditions for task: "
                            + task.getTaskName() + " unsatisfied: waiting: "
                            + waitForConditionSatisfy
                            + " seconds before checking again.");
                    try {
                        Thread.currentThread().sleep(
                                waitForConditionSatisfy * 1000);
                    } catch (InterruptedException ignore) {
                    }

                    // check to see if we've been resumed, if so, break
                    // the loop and start
                    if (!isPaused()) {
                        break;
                    }
                }
               
                // check to see if we've been killed
                if (isStopped()){
                    break;
                }
               

                // un pause us (if needed)
                if (isPaused()) {
                    resume();
                }
            }

            // task execution
            LOG.log(Level.FINEST,
                    "IterativeWorkflowProcessorThread: Executing task: "
                            + task.getTaskName());

            WorkflowTaskInstance taskInstance = GenericWorkflowObjectFactory
                    .getTaskObjectFromClassName(task.getTaskInstanceClassName());
            // add the TaskId and the JobId and ProcessingNode
            // TODO: unfake the JobId
            workflowInst.getSharedContext().replaceMetadata(TASK_ID,
                    task.getTaskId());
            workflowInst.getSharedContext().replaceMetadata(WORKFLOW_INST_ID,
                    workflowInst.getId());
            workflowInst.getSharedContext().replaceMetadata(JOB_ID,
                    workflowInst.getId());
            workflowInst.getSharedContext().replaceMetadata(PROCESSING_NODE,
                    getHostname());
            workflowInst.getSharedContext().replaceMetadata(
                    WORKFLOW_MANAGER_URL, this.wmgrParentUrl.toString());

            if (rClient != null) {
                // build up the Job
                // and the Job Input
                Job taskJob = new Job();
                taskJob.setName(task.getTaskId());
                taskJob
                        .setJobInstanceClassName("org.apache.oodt.cas.workflow.structs.TaskJob");
                taskJob
                        .setJobInputClassName("org.apache.oodt.cas.workflow.structs.TaskJobInput");
                taskJob.setLoadValue(new Integer(2));
                taskJob.setQueueName(task.getTaskConfig().getProperty(
                        QUEUE_NAME) != null ? task.getTaskConfig()
                        .getProperty(QUEUE_NAME) : DEFAULT_QUEUE_NAME);

                TaskJobInput in = new TaskJobInput();
                in.setDynMetadata(workflowInst.getSharedContext());
                in.setTaskConfig(task.getTaskConfig());
                in.setWorkflowTaskInstanceClassName(task
                        .getTaskInstanceClassName());

                workflowInst.setStatus(RESMGR_SUBMIT);
                persistWorkflowInstance();

                try {
                    // this is * NOT * a blocking operation so when it returns
                    // the job may not actually have finished executing
                    // so we go into a waiting/sleep behavior using the passed
                    // back job id to wait until the job has actually finished
                    // executing

                    this.currentJobId = rClient.submitJob(taskJob, in);

                    while (!safeCheckJobComplete(this.currentJobId) && !isStopped()) {
                        // sleep for 5 seconds then come back
                        // and check again
                        try {
                            Thread.currentThread()
                                    .sleep(pollingWaitTime * 1000);
                        } catch (InterruptedException ignore) {
                        }
                    }

                    // okay job is done: TODO: fix this hack
                    // the task update time was set remotely
                    // by remote task, so let's read it now
                    // from the instRepo (which will have the updated
                    // time)

                    if (isStopped()) {
                        // this means that this workflow was killed, so
                        // gracefully exit
                        break;
                    }

                    WorkflowInstance updatedInst = null;
                    try {
                        updatedInst = instanceRepository
                                .getWorkflowInstanceById(workflowInst.getId());
                        workflowInst = updatedInst;
                    } catch (InstanceRepositoryException e) {
                        e.printStackTrace();
                        LOG.log(Level.WARNING, "Unable to get "
                                + "updated workflow " + "instance record "
                                + "when executing remote job: Message: "
                                + e.getMessage());
                    }

                } catch (JobExecutionException e) {
                    LOG.log(Level.WARNING,
                            "Job execution exception using resource manager to execute job: Message: "
                                    + e.getMessage());
                }
            } else {
                // we started, so mark it
                workflowInst.setStatus(STARTED);
                // go ahead and persist the workflow instance, after we
                // save the current task start date time
                String currentTaskIsoStartDateTimeStr = DateConvert
                        .isoFormat(new Date());
                workflowInst
                        .setCurrentTaskStartDateTimeIsoStr(currentTaskIsoStartDateTimeStr);
                workflowInst.setCurrentTaskEndDateTimeIsoStr(null); /*
                                                                     * clear
                                                                     * this out
                                                                     * until
                                                                     * it's
                                                                     * ready
                                                                     */
                persistWorkflowInstance();
                executeTaskLocally(taskInstance, workflowInst
                        .getSharedContext(), task.getTaskConfig(), task
                        .getTaskName());
                String currentTaskIsoEndDateTimeStr = DateConvert
                        .isoFormat(new Date());
                workflowInst
                        .setCurrentTaskEndDateTimeIsoStr(currentTaskIsoEndDateTimeStr);
                persistWorkflowInstance();
            }

            LOG.log(Level.FINEST,
                    "IterativeWorkflowProcessorThread: Completed task: "
                            + task.getTaskName());

        }

        LOG.log(Level.FINEST,
                "IterativeWorkflowProcessorThread: Completed workflow: "
View Full Code Here

Examples of org.apache.oodt.cas.workflow.structs.WorkflowTask

    }

    private String getTaskNameById(String taskId) {
        for (Iterator i = workflowInst.getWorkflow().getTasks().iterator(); i
                .hasNext();) {
            WorkflowTask task = (WorkflowTask) i.next();
            if (task.getTaskId().equals(taskId)) {
                return task.getTaskName();
            }
        }

        return null;
    }
View Full Code Here

Examples of org.apache.oodt.cas.workflow.structs.WorkflowTask

        if (tasks == null) {
            return wTasks;
        }

        for (Iterator i = tasks.iterator(); i.hasNext();) {
            WorkflowTask t = (WorkflowTask) i.next();
            Hashtable task = getXmlRpcWorkflowTask(t);
            wTasks.add(task);
        }

        return wTasks;
View Full Code Here

Examples of org.apache.oodt.cas.workflow.structs.WorkflowTask

     *            The XML-RPC Hashtable version of the WorkflowTask.
     * @return a {@link WorkflowTask} from an XML-RPC {@link Hashtable} sent
     *         over the wire.
     */
    public static WorkflowTask getWorkflowTaskFromXmlRpc(Hashtable task) {
        WorkflowTask t = new WorkflowTask();
        t.setTaskInstanceClassName((String) task.get("class"));
        t.setTaskId((String) task.get("id"));
        t.setTaskName((String) task.get("name"));
        t.setOrder(Integer.valueOf((String) task.get("order")).intValue());
        t.setTaskConfig(getWorkflowTaskConfigurationFromXmlRpc((Hashtable) task
                .get("configuration")));
        t.setConditions(getWorkflowConditionsFromXmlRpc((Vector) task
                .get("conditions")));
        t
                .setRequiredMetFields(getWorkflowTaskReqMetFieldsFromXmlRpc((Vector) task
                        .get("requiredMetFields")));

        return t;
    }
View Full Code Here

Examples of org.apache.oodt.cas.workflow.structs.WorkflowTask

    public static List getWorkflowTasksFromXmlRpc(Vector tsks) {
        List tasks = new Vector();

        for (Iterator i = tsks.iterator(); i.hasNext();) {
            Hashtable taskHashtable = (Hashtable) i.next();
            WorkflowTask task = getWorkflowTaskFromXmlRpc(taskHashtable);
            tasks.add(task);

        }
        return tasks;
    }
View Full Code Here

Examples of org.apache.oodt.cas.workflow.structs.WorkflowTask

    if(taskList != null){
     
      List newTaskList = new Vector(taskList.size());
     
      for(Iterator i = taskList.iterator(); i.hasNext(); ){
        WorkflowTask t = (WorkflowTask)i.next();
        WorkflowTask newTask = copyTask(t);
        newTaskList.add(newTask);
      }
     
      return newTaskList;
    }
View Full Code Here

Examples of org.apache.oodt.cas.workflow.structs.WorkflowTask

    }
    else return null;
  }
 
  public static WorkflowTask copyTask(WorkflowTask t){
    WorkflowTask newTask = new WorkflowTask();
    newTask.setTaskConfig(t.getTaskConfig());
    newTask.setTaskId(t.getTaskId());
    newTask.setTaskName(t.getTaskName());
    newTask.setTaskInstanceClassName(t.getTaskInstanceClassName());
    newTask.setOrder(t.getOrder());
    newTask.setConditions(copyConditions(t.getConditions()));
    return newTask;
  }
View Full Code Here

Examples of org.apache.oodt.cas.workflow.structs.WorkflowTask

                                + getTaskNameById(workflowInst
                                        .getCurrentTaskId()));
                continue;
            }

            WorkflowTask task = getTaskById(workflowInst.getWorkflow(),workflowInst.getCurrentTaskId());
            //WorkflowTask task = (WorkflowTask) taskIterator.next();
            //workflowInst.setCurrentTaskId(task.getTaskId());
           
           
           
           
            // now persist it
            //persistWorkflowInstance();

            // check to see if req met fields are present
            // if they aren't, set the status to METERROR, and then fail
            //if (!checkTaskRequiredMetadata(task, this.workflowInst
            //        .getSharedContext())) {
            //    this.workflowInst.setStatus(METADATA_MISSING);
            //    persistWorkflowInstance();
                // now break out of this run loop
            //    return;
            //}

            // this is where the pre-conditions come in
            // only execute the below code when it's passed all of its
            // pre-conditions
            /*if (task.getConditions() != null) {
                while (!satisfied(task.getConditions(), task.getTaskId()) && !isStopped()) {

                    // if we're not paused, go ahead and pause us now
                    if (!isPaused()) {
                        pause();
                    }

                    LOG.log(Level.FINEST, "Pre-conditions for task: "
                            + task.getTaskName() + " unsatisfied: waiting: "
                            + waitForConditionSatisfy
                            + " seconds before checking again.");
                    try {
                        Thread.currentThread().sleep(
                                waitForConditionSatisfy * 1000);
                    } catch (InterruptedException ignore) {
                    }

                    // check to see if we've been resumed, if so, break
                    // the loop and start
                    if (!isPaused()) {
                        break;
                    }
                }
               
                // check to see if we've been killed
                if (isStopped()){
                    break;
                }
               

                // un pause us (if needed)
                if (isPaused()) {
                    resume();
                }
            }*/

            // task execution
            LOG.log(Level.FINEST,
                    "IterativeWorkflowProcessorThread: Executing task: "
                            + task.getTaskName());

            WorkflowTaskInstance taskInstance = GenericWorkflowObjectFactory
                    .getTaskObjectFromClassName(task.getTaskInstanceClassName());
            // add the TaskId and the JobId and ProcessingNode
            // TODO: unfake the JobId
            workflowInst.getSharedContext().replaceMetadata(TASK_ID,
                    task.getTaskId());
            workflowInst.getSharedContext().replaceMetadata(WORKFLOW_INST_ID,
                    workflowInst.getId());
            workflowInst.getSharedContext().replaceMetadata(JOB_ID,
                    workflowInst.getId());
            workflowInst.getSharedContext().replaceMetadata(PROCESSING_NODE,
                    getHostname());
            workflowInst.getSharedContext().replaceMetadata(
                    WORKFLOW_MANAGER_URL, this.wmgrParentUrl.toString());

            if (rClient != null) {
                // build up the Job
                // and the Job Input
                Job taskJob = new Job();
                taskJob.setName(task.getTaskId());
                taskJob
                        .setJobInstanceClassName("org.apache.oodt.cas.workflow.structs.TaskJob");
                taskJob
                        .setJobInputClassName("org.apache.oodt.cas.workflow.structs.TaskJobInput");
                taskJob.setLoadValue(new Integer(2));
                taskJob.setQueueName(task.getTaskConfig().getProperty(
                        QUEUE_NAME) != null ? task.getTaskConfig()
                        .getProperty(QUEUE_NAME) : DEFAULT_QUEUE_NAME);

                TaskJobInput in = new TaskJobInput();
                in.setDynMetadata(workflowInst.getSharedContext());
                in.setTaskConfig(task.getTaskConfig());
                in.setWorkflowTaskInstanceClassName(task
                        .getTaskInstanceClassName());

                workflowInst.setStatus(RESMGR_SUBMIT);
                persistWorkflowInstance();

                try {
                    // this is * NOT * a blocking operation so when it returns
                    // the job may not actually have finished executing
                    // so we go into a waiting/sleep behavior using the passed
                    // back job id to wait until the job has actually finished
                    // executing

                    this.currentJobId = rClient.submitJob(taskJob, in);

                    while (!safeCheckJobComplete(this.currentJobId) && !isStopped()) {
                        // sleep for 5 seconds then come back
                        // and check again
                        try {
                            Thread.currentThread()
                                    .sleep(pollingWaitTime * 1000);
                        } catch (InterruptedException ignore) {
                        }
                    }

                    // okay job is done: TODO: fix this hack
                    // the task update time was set remotely
                    // by remote task, so let's read it now
                    // from the instRepo (which will have the updated
                    // time)

                    if (isStopped()) {
                        // this means that this workflow was killed, so
                        // gracefully exit
                        break;
                    }

                    WorkflowInstance updatedInst = null;
                    try {
                        updatedInst = instanceRepository
                                .getWorkflowInstanceById(workflowInst.getId());
                        workflowInst = updatedInst;
                    } catch (InstanceRepositoryException e) {
                        e.printStackTrace();
                        LOG.log(Level.WARNING, "Unable to get "
                                + "updated workflow " + "instance record "
                                + "when executing remote job: Message: "
                                + e.getMessage());
                    }

                } catch (JobExecutionException e) {
                    LOG.log(Level.WARNING,
                            "Job execution exception using resource manager to execute job: Message: "
                                    + e.getMessage());
                }
            } else {
                // we started, so mark it
                workflowInst.setStatus(STARTED);
                // go ahead and persist the workflow instance, after we
                // save the current task start date time
                String currentTaskIsoStartDateTimeStr = DateConvert
                        .isoFormat(new Date());
                workflowInst
                        .setCurrentTaskStartDateTimeIsoStr(currentTaskIsoStartDateTimeStr);
                workflowInst.setCurrentTaskEndDateTimeIsoStr(null); /*
                                                                     * clear
                                                                     * this out
                                                                     * until
                                                                     * it's
                                                                     * ready
                                                                     */
                persistWorkflowInstance();
                executeTaskLocally(taskInstance, workflowInst
                        .getSharedContext(), task.getTaskConfig(), task
                        .getTaskName());
                String currentTaskIsoEndDateTimeStr = DateConvert
                        .isoFormat(new Date());
                workflowInst
                        .setCurrentTaskEndDateTimeIsoStr(currentTaskIsoEndDateTimeStr);
                persistWorkflowInstance();
            }

            LOG.log(Level.FINEST,
                    "IterativeWorkflowProcessorThread: Completed task: "
                            + task.getTaskName());

        }

        LOG.log(Level.FINEST,
                "IterativeWorkflowProcessorThread: Completed workflow: "
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.