You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by bf...@apache.org on 2010/12/23 03:44:31 UTC
svn commit: r1052143 [4/11] - in /oodt/branches/wengine-branch: ./ src/
src/main/ src/main/assembly/ src/main/bin/ src/main/java/
src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/oodt/
src/main/java/org/apache/oodt/cas/ src/main/ja...
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/model/repo/XmlWorkflowModelRepository.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/model/repo/XmlWorkflowModelRepository.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/model/repo/XmlWorkflowModelRepository.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/model/repo/XmlWorkflowModelRepository.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,313 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.model.repo;
+
+//OODT imports
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.metadata.util.PathUtils;
+import org.apache.oodt.cas.workflow.model.WorkflowGraph;
+import org.apache.oodt.cas.workflow.model.WorkflowModelFactory;
+import org.apache.oodt.cas.workflow.priority.Priority;
+import org.apache.oodt.cas.workflow.processor.ConditionProcessor;
+import org.apache.oodt.cas.workflow.processor.ParallelProcessor;
+import org.apache.oodt.cas.workflow.processor.SequentialProcessor;
+import org.apache.oodt.cas.workflow.processor.TaskProcessor;
+import org.apache.oodt.cas.workflow.processor.WorkflowProcessor;
+import org.apache.oodt.cas.workflow.util.WorkflowUtils;
+
+//JDK imports
+import java.io.File;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.Vector;
+
+//JAVAX imports
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathFactory;
+
+//DOM imports
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * Model Repository which stores models in xml files
+ * </p>.
+ */
+public class XmlWorkflowModelRepository implements WorkflowModelRepository {
+
+ private List<File> files;
+
+ public XmlWorkflowModelRepository(List<File> files) throws InstantiationException {
+ try {
+ this.files = files;
+ }catch (Exception e) {
+ e.printStackTrace();
+ throw new InstantiationException();
+ }
+ }
+
+ public Map<String, WorkflowGraph> loadGraphs(Set<String> supportedProcessorIds) throws Exception {
+ HashMap<String, WorkflowGraph> graphs = new HashMap<String, WorkflowGraph>();
+ HashMap<String, Metadata> globalConfGroups = new HashMap<String, Metadata>();
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ DocumentBuilder parser = factory.newDocumentBuilder();
+ List<Element> rootElements = new Vector<Element>();
+ for (File file : files)
+ rootElements.add(parser.parse(file).getDocumentElement());
+ for (Element root : rootElements) {
+ loadConfiguration(rootElements, root, new Metadata(), globalConfGroups);
+ NodeList rootChildren = root.getChildNodes();
+ for (int i = 0; i < rootChildren.getLength(); i++)
+ if (rootChildren.item(i).getNodeType() == Node.ELEMENT_NODE && !rootChildren.item(i).getNodeName().equals("configuration")) {
+ WorkflowGraph graph = this.loadGraph(rootElements, rootChildren.item(i), new Metadata(), globalConfGroups, graphs, Priority.getDefault(), supportedProcessorIds);
+ graphs.put(graph.getId(), graph);
+ }
+ }
+ insureUniqueIds(graphs);
+ return graphs;
+ }
+
+ private void insureUniqueIds(HashMap<String, WorkflowGraph> graphs) {
+ for (WorkflowGraph graph : graphs.values()) {
+ HashSet<String> names = new HashSet<String>();
+ Vector<WorkflowGraph> stack = new Vector<WorkflowGraph>();
+ stack.add(graph);
+ while(!stack.isEmpty()) {
+ WorkflowGraph currentGraph = stack.remove(0);
+ String currentId = currentGraph.getId();
+ for (int i = 1; names.contains(currentId); i++)
+ currentId = currentGraph.getId() + "-" + i;
+ names.add(currentId);
+ if (!currentId.equals(currentGraph.getId()))
+ this.changeModelId(currentGraph, currentId);
+ stack.addAll(currentGraph.getChildren());
+ }
+ }
+ }
+
+ private void changeModelId(WorkflowGraph graph, String newModelId) {
+ WorkflowModelFactory factory = new WorkflowModelFactory(graph.getModel());
+ factory.setModelId(newModelId);
+ graph.setModel(factory.createModel());
+ }
+
+ private WorkflowGraph loadGraph(List<Element> rootElements, Node workflowNode, Metadata staticMetadata, HashMap<String, Metadata> globalConfGroups, HashMap<String, WorkflowGraph> graphs, Priority priority, Set<String> supportedProcessorIds) throws Exception {
+ String modelIdRef = null;
+ String modelId = null;
+ String modelName = null;
+ String alias = null;
+ String executionType = null;
+ String minReqSuccessfulSubProcessors = null;
+ List<String> excused = new Vector<String>();
+ String clazz = null;
+ boolean entryPoint = false;
+
+ NamedNodeMap attributes = workflowNode.getAttributes();
+ for (int i = 0; attributes != null && i < attributes.getLength(); i++) {
+ Node node = workflowNode.getAttributes().item(i);
+ if (node.getNodeName().equals("id")) {
+ modelId = node.getNodeValue();
+ }else if (node.getNodeName().equals("name")) {
+ modelName = node.getNodeValue();
+ }else if (node.getNodeName().equals("class")) {
+ clazz = node.getNodeValue();
+ }else if (node.getNodeName().equals("id-ref")) {
+ modelIdRef = node.getNodeValue();
+ }else if (node.getNodeName().equals("excused")) {
+ excused.addAll(Arrays.asList(node.getNodeValue().split(",")));
+ }else if (node.getNodeName().equals("entryPoint")) {
+ entryPoint = Boolean.parseBoolean(node.getNodeValue());
+ }else if (node.getNodeName().equals("alias")) {
+ alias = node.getNodeValue();
+ }else if (node.getNodeName().equals("min")) {
+ minReqSuccessfulSubProcessors = node.getNodeValue();
+ }else if (node.getNodeName().equals("execution")) {
+ executionType = node.getNodeValue();
+ }else if (node.getNodeName().equals("priority")) {
+ priority = Priority.getPriority(Double.parseDouble(node.getNodeValue()));
+ }else if (node.getNodeName().startsWith("p:")) {
+ staticMetadata.replaceMetadata(node.getNodeName().substring(2), node.getNodeValue());
+ }
+ }
+
+ if (modelId == null && modelIdRef == null)
+ modelId = UUID.randomUUID().toString();
+
+ WorkflowGraph graph = null;
+ if (modelId != null) {
+
+ if (workflowNode.getNodeName().equals("workflow") || workflowNode.getNodeName().equals("conditions")) {
+ if (executionType == null)
+ throw new Exception("workflow model '" + workflowNode.getNodeName() + "' missing execution type");
+ }else {
+ executionType = workflowNode.getNodeName();
+ }
+
+ if (!supportedProcessorIds.contains(executionType))
+ throw new Exception("Unsupported execution type id '" + executionType + "'");
+
+ loadConfiguration(rootElements, workflowNode, staticMetadata, globalConfGroups);
+
+ WorkflowModelFactory modelFactory = new WorkflowModelFactory();
+ modelFactory.setModelId(modelId);
+ modelFactory.setModelName(modelName);
+ modelFactory.setExecutionType(executionType);
+ modelFactory.setPriority(priority);
+ if (minReqSuccessfulSubProcessors != null)
+ modelFactory.setMinReqSuccessfulSubProcessors(Integer.parseInt(minReqSuccessfulSubProcessors));
+ modelFactory.setStaticMetadata(staticMetadata);
+ modelFactory.setExcusedSubProcessorIds(excused);
+ modelFactory.setInstanceClass(clazz);
+
+ graph = new WorkflowGraph(modelFactory.createModel());
+
+ boolean loadedPreConditions = false;
+ NodeList children = workflowNode.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node curChild = children.item(i);
+ if (curChild.getNodeType() == Node.ELEMENT_NODE) {
+ if (curChild.getNodeName().equals("conditions")) {
+ boolean isPreCondition = !loadedPreConditions;
+ String type = ((Element) curChild).getAttribute("type");
+ if (type.length() > 0)
+ isPreCondition = type.toLowerCase().equals("pre");
+ if (isPreCondition)
+ graph.setPreConditions(this.loadGraph(rootElements, curChild, new Metadata(staticMetadata), globalConfGroups, graphs, priority, supportedProcessorIds));
+ else
+ graph.setPostConditions(this.loadGraph(rootElements, curChild, new Metadata(staticMetadata), globalConfGroups, graphs, priority, supportedProcessorIds));
+ loadedPreConditions = true;
+ }else if (!curChild.getNodeName().equals("configuration")){
+ graph.addChild(this.loadGraph(rootElements, curChild, new Metadata(staticMetadata), globalConfGroups, graphs, priority, supportedProcessorIds));
+ }
+ }
+ }
+
+ }else if (modelIdRef != null) {
+ loadConfiguration(rootElements, workflowNode, staticMetadata, globalConfGroups);
+ graph = this.findGraph(rootElements, modelIdRef, new Metadata(staticMetadata), globalConfGroups, graphs, priority, supportedProcessorIds);
+ if (graph == null)
+ throw new Exception("Workflow '" + modelIdRef + "' has not been defined in this context");
+ if (alias != null)
+ this.changeModelId(graph, alias);
+ }
+
+ if (entryPoint) {
+ if (graphs.containsKey(graph.getId()))
+ throw new Exception("Entry points must have globally unique ModelIds: '" + graph.getId() + "' is used more than once");
+ graphs.put(graph.getId(), graph);
+ }
+
+ return graph;
+ }
+
+ protected WorkflowGraph findGraph(List<Element> rootElements, String modelIdRef, Metadata staticMetadata, HashMap<String, Metadata> globalConfGroups, HashMap<String, WorkflowGraph> graphs, Priority priority, Set<String> supportedProcessorIds) throws Exception {
+ XPath xpath = XPathFactory.newInstance().newXPath();
+ XPathExpression expr = xpath.compile("//*[@id = '" + modelIdRef + "']");
+ for (Element rootElement : rootElements) {
+ Node node = (Node) expr.evaluate(rootElement, XPathConstants.NODE);
+ if (node != null)
+ return this.loadGraph(rootElements, node, staticMetadata, globalConfGroups, graphs, priority, supportedProcessorIds);
+ }
+ return null;
+ }
+
+ private void loadConfiguration(List<Element> rootElements, Node workflowNode, Metadata staticMetadata, HashMap<String, Metadata> globalConfGroups) throws Exception {
+ NodeList children = workflowNode.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node curChild = children.item(i);
+ if (curChild.getNodeName().equals("configuration")) {
+ Metadata curMetadata = new Metadata();
+ if (!((Element) curChild).getAttribute("extends").equals(""))
+ for (String extension : ((Element) curChild).getAttribute("extends").split(","))
+ curMetadata.replaceMetadata(globalConfGroups.containsKey(extension) ? globalConfGroups.get(extension) : this.tempLoadConfGroup(rootElements, extension, globalConfGroups));
+ curMetadata.replaceMetadata(this.loadConfiguration(rootElements, curChild, globalConfGroups));
+ if (curChild.hasAttributes() && !((Element) curChild).getAttribute("name").equals(""))
+ globalConfGroups.put(((Element) curChild).getAttribute("name"), curMetadata);
+ staticMetadata.replaceMetadata(curMetadata);
+ }
+ }
+ }
+
+ private Metadata loadConfiguration(List<Element> rootElements, Node configNode, HashMap<String, Metadata> globalConfGroups) throws Exception {
+ Metadata curMetadata = new Metadata();
+ NodeList curGrandChildren = configNode.getChildNodes();
+ for (int k = 0; k < curGrandChildren.getLength(); k++) {
+ if (curGrandChildren.item(k).getNodeName().equals("property")) {
+ Element property = (Element) curGrandChildren.item(k);
+ String delim = property.getAttribute("delim");
+ String envReplace = property.getAttribute("envReplace");
+ String name = property.getAttribute("name");
+ String value = property.getAttribute("value");
+ if (Boolean.parseBoolean(envReplace))
+ value = PathUtils.doDynamicReplacement(value);
+ List<String> values = new Vector<String>();
+ if (delim.length() > 0)
+ values.addAll(Arrays.asList(value.split("\\" + delim)));
+ else
+ values.add(value);
+ curMetadata.replaceMetadata(name, values);
+ }
+ }
+ return curMetadata;
+ }
+
+ private Metadata tempLoadConfGroup(List<Element> rootElements, String group, HashMap<String, Metadata> globalConfGroups) throws Exception {
+ for (final Element rootElement : rootElements) {
+ NodeList nodes = rootElement.getElementsByTagName("configuration");
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node node = nodes.item(i);
+ String name = ((Element) node).getAttribute("name");
+ if (name.equals(group))
+ return this.loadConfiguration(rootElements, node, globalConfGroups);
+ }
+ }
+ throw new Exception("Configuration group '" + group + "' not defined!");
+ }
+
+ public static void main(String[] args) throws Exception {
+ XmlWorkflowModelRepositoryFactory factory = new XmlWorkflowModelRepositoryFactory();
+ factory.setModelFiles(Arrays.asList("src/main/resources/policy/workflows/GranuleMaps.xml", "src/main/resources/policy/workflows/properties.xml"));
+ HashMap<String, Class<? extends WorkflowProcessor>> modelToProcessorMap = new HashMap<String, Class<? extends WorkflowProcessor>>();
+ modelToProcessorMap.put("sequential", SequentialProcessor.class);
+ modelToProcessorMap.put("parallel", ParallelProcessor.class);
+ modelToProcessorMap.put("task", TaskProcessor.class);
+ modelToProcessorMap.put("condition", ConditionProcessor.class);
+ Map<String, WorkflowGraph> graphs = factory.createModelRepository().loadGraphs(modelToProcessorMap.keySet());
+ System.out.println(graphs.keySet());
+ WorkflowGraph graph = graphs.get("urn:npp:GranuleMaps");
+ System.out.println(WorkflowUtils.toString(graph));
+ System.out.println(graph.getModel().getStaticMetadata().getMetadata("BlockTimeElapse"));
+ }
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/model/repo/XmlWorkflowModelRepositoryFactory.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/model/repo/XmlWorkflowModelRepositoryFactory.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/model/repo/XmlWorkflowModelRepositoryFactory.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/model/repo/XmlWorkflowModelRepositoryFactory.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.model.repo;
+
+//JDK imports
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Vector;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * Factory for creating xml model repositories
+ * </p>.
+ */
+public class XmlWorkflowModelRepositoryFactory implements WorkflowModelRepositoryFactory {
+
+ private List<String> modelFiles;
+
+ public WorkflowModelRepository createModelRepository() {
+ if (modelFiles == null)
+ return null;
+ try {
+ List<File> files = new Vector<File>();
+ for (String modelFile : this.modelFiles) {
+ File modelFileHandle = new File(modelFile);
+ if (modelFileHandle.isDirectory()) {
+ for (File file : Arrays.asList(modelFileHandle.listFiles()))
+ if (!file.isDirectory())
+ files.add(file);
+ }else {
+ files.add(modelFileHandle);
+ }
+ }
+ return new XmlWorkflowModelRepository(files);
+ }catch (Exception e) {
+ return null;
+ }
+ }
+
+ public void setModelFiles(List<String> modelFiles) {
+ this.modelFiles = modelFiles;
+ }
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/page/PageFilter.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/page/PageFilter.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/page/PageFilter.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/page/PageFilter.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.page;
+
+//OODT imports
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.workflow.processor.ProcessorStub;
+
+/**
+ *
+ * @author bfoster
+ *
+ */
+public interface PageFilter {
+
+ public boolean accept(ProcessorStub stub, Metadata cachedMetadata);
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/page/QueryPage.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/page/QueryPage.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/page/QueryPage.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/page/QueryPage.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.page;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.page.Page;
+import org.apache.oodt.cas.catalog.page.ProcessedPageInfo;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A page of Instance Metadata
+ * </p>.
+ */
+public class QueryPage extends Page {
+
+ public QueryPage(Page page) {
+ super(new ProcessedPageInfo(page.getPageSize(), page.getPageNum(),
+ page.getNumOfHits()), page.getQueryExpression(),
+ page.getRestrictToCatalogIds(), page.getReceipts());
+ }
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/page/QueuePage.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/page/QueuePage.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/page/QueuePage.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/page/QueuePage.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.page;
+
+//JDK imports
+import java.util.List;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.page.ProcessedPageInfo;
+import org.apache.oodt.cas.workflow.processor.ProcessorStub;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A page of queued ProcessorStubs
+ * </p>.
+ */
+public class QueuePage {
+
+ private ProcessedPageInfo pageInfo;
+ private List<ProcessorStub> stubs;
+ private Object filter;
+
+ public QueuePage(ProcessedPageInfo pageInfo, List<ProcessorStub> stubs, Object filter) {
+ this.pageInfo = pageInfo;
+ this.stubs = stubs;
+ this.filter = filter;
+ }
+
+ public ProcessedPageInfo getPageInfo() {
+ return pageInfo;
+ }
+
+ public List<ProcessorStub> getStubs() {
+ return stubs;
+ }
+
+ public Object getFilter() {
+ return this.filter;
+ }
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/page/RunnablesPage.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/page/RunnablesPage.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/page/RunnablesPage.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/page/RunnablesPage.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.page;
+
+//JDK imports
+import java.util.List;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.page.ProcessedPageInfo;
+import org.apache.oodt.cas.workflow.processor.ProcessorStub;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A page of ProcessorStubs from runnables queue
+ * </p>.
+ */
+public class RunnablesPage {
+
+ private ProcessedPageInfo pageInfo;
+ private List<ProcessorStub> stubs;
+
+ public RunnablesPage(ProcessedPageInfo pageInfo, List<ProcessorStub> stubs) {
+ this.pageInfo = pageInfo;
+ this.stubs = stubs;
+ }
+
+ public ProcessedPageInfo getPageInfo() {
+ return pageInfo;
+ }
+
+ public List<ProcessorStub> getStubs() {
+ return stubs;
+ }
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/precondition/EnsureServerFullyLoaded.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/precondition/EnsureServerFullyLoaded.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/precondition/EnsureServerFullyLoaded.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/precondition/EnsureServerFullyLoaded.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.precondition;
+
+//JDK imports
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+//OODT imports
+import org.apache.oodt.cas.workflow.engine.WorkflowEngine;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * Event/Action Precondtion (NOT WORKFLOW PRECONDITIONS) which ensures all WorkflowProcessors are cached
+ * </p>.
+ */
+public class EnsureServerFullyLoaded extends WorkflowPreCondition {
+
+ private static final Logger LOG = Logger.getLogger(EnsureServerFullyLoaded.class.getName());
+
+ public boolean passes(WorkflowEngine engine) {
+ try {
+ return engine.getNumOfWorkflows() == engine.getNumOfLoadedProcessors();
+ }catch (Exception e) {
+ LOG.log(Level.SEVERE, "Failed to check precondition '" + this.getId() + "' : " + e.getMessage(), e);
+ return false;
+ }
+ }
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/precondition/PreConditionedComponent.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/precondition/PreConditionedComponent.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/precondition/PreConditionedComponent.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/precondition/PreConditionedComponent.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.precondition;
+
+//JDK imports
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+//OODT imports
+import org.apache.oodt.cas.workflow.engine.WorkflowEngine;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A Component which utilies NON-WORKFLOW preconditions -- applies to Events/Actions
+ * </p>.
+ */
+public class PreConditionedComponent {
+
+ private final static Logger LOG = Logger.getLogger(PreConditionedComponent.class.getName());
+
+ protected List<WorkflowPreCondition> preConditions;
+
+ public void setPreConditions(List<WorkflowPreCondition> preConditions) {
+ this.preConditions = preConditions;
+ }
+
+ public List<WorkflowPreCondition> getPreConditions() {
+ return this.preConditions;
+ }
+
+ public boolean passesPreConditions(WorkflowEngine engine) throws Exception {
+ if (this.preConditions != null) {
+ for (WorkflowPreCondition preCondition : this.preConditions) {
+ if (!preCondition.passes(engine)) {
+ LOG.log(Level.SEVERE, "Failed to pass action precondition '" + preCondition.getId() + "'");
+ return false;
+ }else {
+ LOG.log(Level.INFO, "Successfully passed action precondition '" + preCondition.getId() + "'");
+ }
+ }
+ }
+ return true;
+ }
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/precondition/WorkflowPreCondition.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/precondition/WorkflowPreCondition.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/precondition/WorkflowPreCondition.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/precondition/WorkflowPreCondition.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.precondition;
+
+//OODT imports
+import org.apache.oodt.cas.workflow.engine.WorkflowEngine;
+import org.apache.oodt.commons.spring.SpringSetIdInjectionType;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * NON-WORKFLOW preconditions -- applies to Events/Actions
+ * </p>.
+ */
+public abstract class WorkflowPreCondition implements SpringSetIdInjectionType {
+
+ protected String id;
+ protected String description;
+
+ public String getId() {
+ return this.id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public abstract boolean passes(WorkflowEngine engine);
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/FILOPriorityManager.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/FILOPriorityManager.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/FILOPriorityManager.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/FILOPriorityManager.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.priority;
+
+//JDK imports
+import java.util.Collections;
+import java.util.List;
+
+//OODT imports
+import org.apache.oodt.cas.workflow.processor.ProcessorStub;
+import org.apache.oodt.cas.workflow.server.action.GetSortedPage;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * First in last out priorty manager
+ * </p>.
+ */
+public class FILOPriorityManager implements PriorityManager {
+
+ public void sort(List<ProcessorStub> canadates) {
+ Collections.sort(canadates, GetSortedPage.COMPARATOR.CreationDate.getComparator());
+ }
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/FILOPriorityManagerFactory.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/FILOPriorityManagerFactory.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/FILOPriorityManagerFactory.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/FILOPriorityManagerFactory.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.priority;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * Factory for creating FILO Priority Manager
+ * </p>.
+ */
+public class FILOPriorityManagerFactory implements PriorityManagerFactory {
+
+ public FILOPriorityManager createPriorityManager() {
+ return new FILOPriorityManager();
+ }
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/HighestPriorityFIFOManager.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/HighestPriorityFIFOManager.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/HighestPriorityFIFOManager.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/HighestPriorityFIFOManager.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.priority;
+
+//JDK imports
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+//OODT imports
+import org.apache.oodt.cas.workflow.processor.ProcessorStub;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * Highest priority first priority manager with FIFO boost
+ * </p>.
+ */
+public class HighestPriorityFIFOManager implements PriorityManager {
+
+ private int secondsBetweenBoosts;
+ private double boostAmount;
+ private double boostCap;
+
+ public HighestPriorityFIFOManager(int secondsBetweenBoosts, double boostAmount, double boostCap) {
+ this.secondsBetweenBoosts = secondsBetweenBoosts;
+ this.boostAmount = boostAmount;
+ this.boostCap = boostCap;
+ }
+
+ public void sort(List<ProcessorStub> canadates) {
+
+ Collections.sort(canadates, new Comparator<ProcessorStub>() {
+ public int compare(ProcessorStub o1, ProcessorStub o2) {
+ return calculatePriority(o2).compareTo(calculatePriority(o1));
+ }
+ });
+ }
+
+ private Double calculatePriority(ProcessorStub processorStub) {
+ double aliveTime = (double) (System.currentTimeMillis() - processorStub.getProcessorInfo().getCreationDate().getTime());
+ double boostPercentage = aliveTime / 1000.0 / (double) this.secondsBetweenBoosts;
+ return Math.max(processorStub.getPriority().getValue(), Math.min(this.boostCap, Double.valueOf(processorStub.getPriority().getValue() + (boostPercentage * this.boostAmount))));
+ }
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/HighestPriorityFIFOManagerFactory.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/HighestPriorityFIFOManagerFactory.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/HighestPriorityFIFOManagerFactory.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/HighestPriorityFIFOManagerFactory.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.priority;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * Factory for creating highest priority first priority manager with FIFO boost
+ * </p>.
+ */
+public class HighestPriorityFIFOManagerFactory implements
+ PriorityManagerFactory {
+
+ private int secondsBetweenBoosts;
+ private double boostAmount;
+ private double boostCap;
+
+ public HighestPriorityFIFOManager createPriorityManager() {
+ return new HighestPriorityFIFOManager(secondsBetweenBoosts, boostAmount, boostCap);
+ }
+
+ public void setSecondsBetweenBoosts(int secondsBetweenBoosts) {
+ this.secondsBetweenBoosts = secondsBetweenBoosts;
+ }
+
+ public void setBoostAmount(double boostAmount) {
+ this.boostAmount = boostAmount;
+ }
+
+ public void setBoostCap(double boostCap) {
+ this.boostCap = boostCap;
+ }
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/HighestPriorityFirstManager.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/HighestPriorityFirstManager.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/HighestPriorityFirstManager.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/HighestPriorityFirstManager.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.priority;
+
+//JDK imports
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+//OODT imports
+import org.apache.oodt.cas.workflow.processor.ProcessorStub;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * Highest priority first priority manager
+ * </p>.
+ */
+public class HighestPriorityFirstManager implements PriorityManager {
+
+ public void sort(List<ProcessorStub> canadates) {
+ Collections.sort(canadates, new Comparator<ProcessorStub>() {
+ public int compare(ProcessorStub o1, ProcessorStub o2) {
+ return o2.getPriority().compareTo(o1.getPriority());
+ }
+ });
+ }
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/HighestPriorityFirstManagerFactory.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/HighestPriorityFirstManagerFactory.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/HighestPriorityFirstManagerFactory.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/HighestPriorityFirstManagerFactory.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.priority;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * Factory for creating highest priority first priority manager
+ * </p>.
+ */
+public class HighestPriorityFirstManagerFactory implements
+ PriorityManagerFactory {
+
+ public HighestPriorityFirstManager createPriorityManager() {
+ return new HighestPriorityFirstManager();
+ }
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/Priority.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/Priority.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/Priority.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/Priority.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.priority;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * Priority of a WorkflowProcessor
+ * </p>.
+ */
+public abstract class Priority implements Comparable<Priority> {
+
+ /**
+ * Big the better (that is higher the number higher the priority)
+ * @return
+ */
+ public abstract double getValue();
+ public abstract String getName();
+
+ public static final Priority LOW = new Priority() {
+ public double getValue() { return 0;}
+ public String getName() { return "LOW";}
+ };
+ public static final Priority MEDIUM_LOW = new Priority() {
+ public double getValue() { return 2.5;}
+ public String getName() { return "MEDIUM_LOW";}
+ };
+ public static final Priority MEDIUM = new Priority() {
+ public double getValue() { return 5;}
+ public String getName() { return "MEDIUM";}
+ };
+ public static final Priority MEDIUM_HIGH = new Priority() {
+ public double getValue() { return 7.5;}
+ public String getName() { return "MEDIUM_HIGH";}
+ };
+ public static final Priority HIGH = new Priority() {
+ public double getValue() { return 10;}
+ public String getName() { return "HIGH";}
+ };
+
+ public static Priority getDefault() {
+ return MEDIUM;
+ }
+
+ public static Priority getPriority(final double priority) {
+ if (priority == LOW.getValue())
+ return LOW;
+ else if (priority == MEDIUM_LOW.getValue())
+ return MEDIUM_LOW;
+ else if (priority == MEDIUM.getValue())
+ return MEDIUM;
+ else if (priority == MEDIUM_HIGH.getValue())
+ return MEDIUM_HIGH;
+ else if (priority == HIGH.getValue())
+ return HIGH;
+ else
+ return new Priority() {
+ public double getValue() { return priority; }
+ public String getName() { return "CUSTOM";}
+ };
+ }
+
+ public int hashCode() {
+ return new Double(this.getValue()).hashCode();
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof Priority)
+ return new Double(this.getValue()).equals(((Priority) obj).getValue());
+ else
+ return false;
+ }
+
+ public int compareTo(Priority priority) {
+ return new Double(this.getValue()).compareTo(priority.getValue());
+ }
+
+ public String toString() {
+ return this.getName() + " : " + Double.toString(this.getValue());
+ }
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/PriorityManager.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/PriorityManager.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/PriorityManager.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/PriorityManager.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.priority;
+
+//JDK imports
+import java.util.List;
+
+//OODT imports
+import org.apache.oodt.cas.workflow.processor.ProcessorStub;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * Controls the order which Ready jobs are submitted to Runner
+ * </p>.
+ */
+public interface PriorityManager {
+
+ public void sort(List<ProcessorStub> canadates);
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/PriorityManagerFactory.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/PriorityManagerFactory.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/PriorityManagerFactory.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/priority/PriorityManagerFactory.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.priority;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * Factory for creating priority manager
+ * </p>.
+ */
+public interface PriorityManagerFactory {
+
+ public PriorityManager createPriorityManager();
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/ConditionProcessor.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/ConditionProcessor.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/ConditionProcessor.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/ConditionProcessor.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.processor;
+
+//OODT import
+import org.apache.oodt.cas.workflow.priority.Priority;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * WorkflowProcessor which handles Workflow Pre/Post Conditions
+ * </p>.
+ */
+public class ConditionProcessor extends TaskProcessor {
+
+ public ConditionProcessor() {
+ super();
+ this.setIsConditionProcessor(true);
+ }
+
+ public void setPriority(Priority priority) {
+ super.setPriority(Priority.getPriority(priority.getValue() - 0.1));
+ }
+
+ @Override
+ public void setPreConditions(WorkflowProcessor preConditions) {
+ //not allowed
+ }
+
+ @Override
+ public void setPostConditions(WorkflowProcessor postConditions) {
+ //not allowed
+ }
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/ParallelProcessor.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/ParallelProcessor.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/ParallelProcessor.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/ParallelProcessor.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.processor;
+
+//JDK imports
+import java.util.List;
+
+//OODT imports
+import org.apache.oodt.cas.workflow.util.WorkflowUtils;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * WorkflowProcessor which handles running sub-workflow processors in parallel
+ * </p>.
+ */
+public class ParallelProcessor extends WorkflowProcessor {
+
+ public List<WorkflowProcessor> getRunnableSubProcessors() {
+ return this.getSubProcessors();
+ }
+
+ public void handleSubProcessorMetadata(WorkflowProcessor workflowProcessor) {
+ this.setDynamicMetadata(WorkflowUtils.mergeMetadata(this.getDynamicMetadata(), workflowProcessor.getDynamicMetadata()));
+ }
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/ProcessorInfo.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/ProcessorInfo.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/ProcessorInfo.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/ProcessorInfo.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.processor;
+
+//JDK imports
+import java.util.Date;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * Store WorkflowProcessor critial dates
+ * </p>.
+ */
+public class ProcessorInfo {
+
+ private Date creationDate;
+ private Date readyDate;
+ private Date executionDate;
+ private Date completionDate;
+
+ ProcessorInfo() {
+ this.creationDate = new Date();
+ }
+
+ public Date getCreationDate() {
+ return creationDate;
+ }
+
+ public Date getReadyDate() {
+ return readyDate;
+ }
+
+ void markReadyDate() {
+ if (this.readyDate == null)
+ this.readyDate = new Date();
+ }
+
+ public Date getExecutionDate() {
+ return executionDate;
+ }
+
+ void markExecutionDate() {
+ if (this.executionDate == null)
+ this.executionDate = new Date();
+ }
+
+ public Date getCompletionDate() {
+ return completionDate;
+ }
+
+ void markCompletionDate() {
+ if (this.completionDate == null)
+ this.completionDate = new Date();
+ }
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/ProcessorSkeleton.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/ProcessorSkeleton.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/ProcessorSkeleton.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/ProcessorSkeleton.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.processor;
+
+//OODT imports
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.workflow.listener.WorkflowProcessorListener;
+import org.apache.oodt.cas.workflow.priority.Priority;
+import org.apache.oodt.cas.workflow.state.WorkflowState;
+
+//JDK imports
+import java.util.List;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * Stripped down WorkflowProcessor mapping -- used to give state of WorkflowProcessor to
+ * client components without actually giving access to the WorkflowProcessor itself
+ * </p>.
+ */
+public class ProcessorSkeleton {
+
+ private String instanceId;
+ private String modelId;
+ private String modelName;
+ private String executionType;
+ private ProcessorInfo processorInfo;
+ private int timesBlocked;
+
+ private ProcessorSkeleton preConditions;
+ private ProcessorSkeleton postConditions;
+ private List<ProcessorSkeleton> subProcessors;
+ private List<String> excusedSubProcessorIds;
+ private WorkflowState state;
+ private List<WorkflowProcessorListener> listeners;
+ private Priority priority;
+ private Metadata staticMetadata;
+ private Metadata dynamicMetadata;
+
+ public ProcessorSkeleton(ProcessorStub stub, Metadata staticMetadata, Metadata dynamicMetadata, List<String> excusedSubProcessorIds, List<WorkflowProcessorListener> listeners) {
+ this.instanceId = stub.getInstanceId();
+ this.modelId = stub.getModelId();
+ this.modelName = stub.getModelName();
+ this.executionType = stub.getExecutionType();
+ this.processorInfo = stub.getProcessorInfo();
+ this.timesBlocked = stub.getTimesBlocked();
+ this.priority = stub.getPriority();
+ this.state = stub.getState();
+ this.staticMetadata = staticMetadata;
+ this.dynamicMetadata = dynamicMetadata;
+ this.excusedSubProcessorIds = excusedSubProcessorIds;
+ this.listeners = listeners;
+ }
+
+ public String getInstanceId() {
+ return this.instanceId;
+ }
+
+ public String getModelId() {
+ return this.modelId;
+ }
+
+ public String getModelName() {
+ return this.modelName;
+ }
+
+ public String getExecutionType() {
+ return this.executionType;
+ }
+
+ public ProcessorInfo getProcessorInfo() {
+ return this.processorInfo;
+ }
+
+ /* MODIFIABLE PROCESSOR PROPERTIES */
+
+ public ProcessorSkeleton getPreConditions() {
+ return preConditions;
+ }
+
+ public void setPreConditions(ProcessorSkeleton preConditions) {
+ this.preConditions = preConditions;
+ }
+
+ public ProcessorSkeleton getPostConditions() {
+ return postConditions;
+ }
+
+ public void setPostConditions(ProcessorSkeleton postConditions) {
+ this.postConditions = postConditions;
+ }
+
+ public List<ProcessorSkeleton> getSubProcessors() {
+ return subProcessors;
+ }
+
+ public void setSubProcessors(List<ProcessorSkeleton> subProcessors) {
+ this.subProcessors = subProcessors;
+ }
+
+ public List<String> getExcusedSubProcessorIds() {
+ return excusedSubProcessorIds;
+ }
+
+ public void setExcusedSubProcessorIds(List<String> excusedSubProcessorIds) {
+ this.excusedSubProcessorIds = excusedSubProcessorIds;
+ }
+
+ public WorkflowState getState() {
+ return state;
+ }
+
+ public void setState(WorkflowState state) {
+ this.state = state;
+ }
+
+ public List<WorkflowProcessorListener> getListeners() {
+ return listeners;
+ }
+
+ public void setListeners(List<WorkflowProcessorListener> listeners) {
+ this.listeners = listeners;
+ }
+
+ public Priority getPriority() {
+ return priority;
+ }
+
+ public void setPriority(Priority priority) {
+ this.priority = priority;
+ }
+
+ public Metadata getStaticMetadata() {
+ return staticMetadata;
+ }
+
+ public void setStaticMetadata(Metadata staticMetadata) {
+ this.staticMetadata = staticMetadata;
+ }
+
+ public Metadata getDynamicMetadata() {
+ return dynamicMetadata;
+ }
+
+ public void setDynamicMetadata(Metadata dynamicMetadata) {
+ this.dynamicMetadata = dynamicMetadata;
+ }
+
+ public int getTimesBlocked() {
+ return this.timesBlocked;
+ }
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/ProcessorStub.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/ProcessorStub.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/ProcessorStub.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/ProcessorStub.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.processor;
+
+//OODT imports
+import org.apache.oodt.cas.workflow.priority.Priority;
+import org.apache.oodt.cas.workflow.state.WorkflowState;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A cache of only the necessary variables of a workflow processor
+ * </p>.
+ */
+public class ProcessorStub {
+
+ private String instanceId;
+ private String modelId;
+ private String modelName;
+ private String executionType;
+ private Priority priority;
+ private WorkflowState state;
+ private ProcessorInfo processorInfo;
+ private int timesBlocked;
+
+ public ProcessorStub(String instanceId, String modelId, String modelName, String executionType, Priority priority, WorkflowState state, ProcessorInfo processorInfo, int timesBlocked) {
+ this.instanceId = instanceId;
+ this.modelId = modelId;
+ this.modelName = modelName;
+ this.executionType = executionType;
+ this.priority = priority;
+ this.state = state;
+ this.processorInfo = processorInfo;
+ this.timesBlocked = timesBlocked;
+ }
+
+ public String getInstanceId() {
+ return this.instanceId;
+ }
+
+ public String getModelId() {
+ return this.modelId;
+ }
+
+ public String getModelName() {
+ return this.modelName;
+ }
+
+ public String getExecutionType() {
+ return this.executionType;
+ }
+
+ public Priority getPriority() {
+ return this.priority;
+ }
+
+ public WorkflowState getState() {
+ return this.state;
+ }
+
+ public ProcessorInfo getProcessorInfo() {
+ return this.processorInfo;
+ }
+
+ public int getTimesBlocked() {
+ return this.timesBlocked;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof ProcessorStub)
+ return this.getInstanceId().equals(((ProcessorStub) obj).getInstanceId()) && this.getModelId().equals(((ProcessorStub) obj).getModelId());
+ else
+ return false;
+ }
+
+ public int hashCode() {
+ return (this.getInstanceId() + ":" + this.getModelId()).hashCode();
+ }
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/SequentialProcessor.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/SequentialProcessor.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/SequentialProcessor.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/SequentialProcessor.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.processor;
+
+//JDK imports
+import java.util.Collections;
+import java.util.List;
+import java.util.Vector;
+
+//OODT imports
+import org.apache.oodt.cas.workflow.state.WorkflowState;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * WorkflowProcessor which handles running sub-processors in sequence
+ * </p>.
+ */
+public class SequentialProcessor extends WorkflowProcessor {
+
+ @Override
+ public List<WorkflowProcessor> getRunnableSubProcessors() {
+ WorkflowProcessor nextWP = this.getNext();
+ if (nextWP != null)
+ return Collections.singletonList(nextWP);
+ else
+ return new Vector<WorkflowProcessor>();
+ }
+
+ @Override
+ public void handleSubProcessorMetadata(WorkflowProcessor workflowProcessor) {
+ this.setDynamicMetadata(workflowProcessor.getDynamicMetadata());
+ WorkflowProcessor nextWP = this.getNext();
+ if (nextWP != null)
+ nextWP.setDynamicMetadataRecur(workflowProcessor.getDynamicMetadata());
+ }
+
+ private WorkflowProcessor getNext() {
+ for (WorkflowProcessor wp : this.getSubProcessors())
+ if (!wp.getState().getCategory().equals(WorkflowState.Category.DONE))
+ return wp;
+ return null;
+ }
+
+}
Added: oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/TaskProcessor.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/TaskProcessor.java?rev=1052143&view=auto
==============================================================================
--- oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/TaskProcessor.java (added)
+++ oodt/branches/wengine-branch/src/main/java/org/apache/oodt/cas/workflow/processor/TaskProcessor.java Thu Dec 23 02:44:23 2010
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.processor;
+
+//JDK imports
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.List;
+import java.util.Vector;
+
+//OODT imports
+import org.apache.oodt.cas.workflow.instance.TaskInstance;
+import org.apache.oodt.cas.workflow.priority.Priority;
+import org.apache.oodt.cas.workflow.state.WorkflowState;
+import org.apache.oodt.cas.workflow.state.transition.PreConditionSuccessState;
+import org.apache.oodt.cas.workflow.state.waiting.BlockedState;
+import org.apache.oodt.cas.workflow.state.waiting.QueuedState;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * WorkflowProcessor which handles running task workflows
+ * </p>.
+ */
+public class TaskProcessor extends WorkflowProcessor {
+
+ private Class<? extends TaskInstance> instanceClass;
+ private String jobId;
+
+ public TaskProcessor() {
+ super();
+ }
+
+ public Class<? extends TaskInstance> getInstanceClass() {
+ return this.instanceClass;
+ }
+
+ public void setJobId(String jobId) {
+ this.jobId = jobId;
+ }
+
+ public String getJobId() {
+ return this.jobId;
+ }
+
+ public void setInstanceClass(Class<? extends TaskInstance> instanceClass) {
+ this.instanceClass = instanceClass;
+ }
+
+ @Override
+ public void setPriority(Priority priority) {
+ super.setPriority(Priority.getPriority(priority.getValue() + 0.1));
+ }
+
+ @Override
+ public List<TaskProcessor> getRunnableWorkflowProcessors() {
+ List<TaskProcessor> tps = super.getRunnableWorkflowProcessors();
+ if (tps.size() == 0) {
+ if (this.getState() instanceof BlockedState) {
+ String requiredBlockTimeElapseString = this.getStaticMetadata().getMetadata("BlockTimeElapse");
+ int requiredBlockTimeElapse = 2;
+ if (requiredBlockTimeElapseString != null) {
+ try {
+ requiredBlockTimeElapse = Integer.parseInt(requiredBlockTimeElapseString);
+ }catch (Exception e) {}
+ }
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(this.getState().getStartTime());
+ long elapsedTime = ((System.currentTimeMillis() - calendar.getTimeInMillis()) / 1000) / 60;
+ if (elapsedTime >= requiredBlockTimeElapse)
+ tps.add(this);
+ }else if (this.getState() instanceof QueuedState && this.passedPreConditions() || this.getState() instanceof PreConditionSuccessState) {
+ tps.add(this);
+ }
+ }
+ return tps;
+ }
+
+ protected boolean hasSubProcessors() {
+ return true;
+ }
+
+ @Override
+ public List<WorkflowProcessor> getRunnableSubProcessors() {
+ return new Vector<WorkflowProcessor>();
+ }
+
+ @Override
+ public void setSubProcessors(List<WorkflowProcessor> subProcessors) {
+ //not allowed
+ }
+
+ @Override
+ public void handleSubProcessorMetadata(WorkflowProcessor workflowProcessor) {
+ //do nothing
+ }
+
+}