[
https://issues.apache.org/jira/browse/OODT-918?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14998625#comment-14998625
]
ASF GitHub Bot commented on OODT-918:
-------------------------------------
Github user chrismattmann commented on a diff in the pull request:
https://github.com/apache/oodt/pull/35#discussion_r44409273
--- Diff:
workflow/src/main/java/org/apache/oodt/cas/workflow/examples/PrerequisiteCondition.java
---
@@ -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.examples;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.Iterator;
+
+//OODT imports
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.resource.structs.Job;
+import org.apache.oodt.cas.resource.structs.exceptions.JobQueueException;
+import org.apache.oodt.cas.resource.system.XmlRpcResourceManagerClient;
+import org.apache.oodt.cas.workflow.structs.WorkflowConditionConfiguration;
+import org.apache.oodt.cas.workflow.structs.WorkflowConditionInstance;
+
+/**
+ * @author singhk
+ * @version $Revision$
+ *
+ * <p>A Simple condition that evaluates to false as many times as the
prerequisite job in Resource Manager
+ * isn't completed. After that, the condition returns
+ * true.</p>
+ *
+ */
+public class PrerequisiteCondition implements WorkflowConditionInstance {
+
+ public PrerequisiteCondition() {
+ super();
+ }
+
+ /**
+ * Check if there is any job queued in Resource Manager with name
equivalent to <code>jobName</code>
+ * @param client
+ * @param jobName
+ * @return true if job is present, otherwise false
+ */
+ @SuppressWarnings("unchecked")
+ private boolean isJobPresentInQueue(XmlRpcResourceManagerClient client,
String jobName){
+ Iterator<Job> iter;
+ try {
+ iter = (Iterator<Job>)client.getQueuedJobs().iterator();
+ while(iter.hasNext()){
+ Job job = iter.next();
+ if(job.getName().equals(jobName))
+ return true;
+ }
+ } catch (JobQueueException e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.apache.oodt.cas.workflow.structs.WorkflowConditionInstance#evaluate(org.apache.oodt.cas.metadata.Metadata)
+ */
+ public boolean evaluate(Metadata metadata,
WorkflowConditionConfiguration config) {
+
+ String[] jobs = (config.getProperty("JOBS")).split(",");
+ String resourceManagerUrl = config.getProperty("RESMGR_URL");
+ boolean flag = true;
+
+ System.out.println(new Date() + " PrerequisiteCondition: Jobs:
"+ Arrays.toString(jobs));
+ System.out.println(new Date() + " PrerequisiteCondition:
Resource Manager: "+ resourceManagerUrl);
--- End diff --
LOG.info()
> Prerequisite workflow condition to check ordering of Resource Manager jobs
> --------------------------------------------------------------------------
>
> Key: OODT-918
> URL: https://issues.apache.org/jira/browse/OODT-918
> Project: OODT
> Issue Type: Improvement
> Components: resource manager, workflow manager
> Affects Versions: 0.10, 0.11
> Reporter: Karanjeet Singh
> Labels: condition, prerequisite, resource, resourcemanager,
> workflow
> Fix For: 0.10, 0.11
>
> Original Estimate: 336h
> Remaining Estimate: 336h
>
> This condition is more applicable where we have a sequence of jobs submitted
> to Resource Manager and we have to abide with some ordering. Such a case if
> DRAT where we are submitting jobs to Resource Manager and we want the reducer
> (RatAggregator) to run after the mapper jobs (RatCodeAudit and Mime
> Partitioner).
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)