airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sma...@apache.org
Subject svn commit: r1142475 [3/7] - in /incubator/airavata/ws-messaging/trunk/workflow-tracking: ./ .settings/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/airavata/ src/main/java/org/apache/airavata/comm...
Date Sun, 03 Jul 2011 18:33:03 GMT
Added: incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/AnnotationProps.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/AnnotationProps.java?rev=1142475&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/AnnotationProps.java (added)
+++ incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/AnnotationProps.java Sun Jul  3 18:32:59 2011
@@ -0,0 +1,310 @@
+/*
+ *
+ * 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.airavata.workflow.tracking.common;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+import org.apache.xmlbeans.XmlObject;
+
+/**
+ * Use set(list) or setXml(list) to set multi valued annotations. Use add() or addXml() to add to multi valued
+ * annotations. Use set(string) or setXml(xmlobj) to set single valued annotations.
+ * 
+ */
+public class AnnotationProps {
+
+    private Map<AnnotationConsts, Object> localMap;
+
+    private AnnotationProps() {
+        localMap = new HashMap<AnnotationConsts, Object>();
+    }
+
+    public static AnnotationProps newProps() {
+        return new AnnotationProps();
+    }
+
+    public static AnnotationProps newProps(AnnotationConsts key, String value) {
+        return newProps().set(key, value);
+    }
+
+    public static AnnotationProps newProps(AnnotationConsts key, XmlObject value) {
+        return newProps().setXml(key, value);
+    }
+
+    /**
+     * Use for single valued string annotation
+     * 
+     * @param key
+     *            an AnnotationConsts
+     * @param value
+     *            a String
+     * 
+     * @return an AnnotationProps
+     * 
+     */
+    public AnnotationProps set(AnnotationConsts key, String value) {
+        if (!key.isSimpleType())
+            throw new RuntimeException("Expect XML Object value for annotation, not String [" + key + ", " + value
+                    + "]");
+        if (key.isMultiValued())
+            throw new RuntimeException("Expect list XML Object value for annotation, not single [" + key + ", " + value
+                    + "]");
+
+        localMap.put(key, value);
+        return this;
+    }
+
+    /**
+     * Use for single valued XmlObj annotation
+     * 
+     * @param key
+     *            an AnnotationConsts
+     * @param value
+     *            a XmlObject
+     * 
+     * @return an AnnotationProps
+     * 
+     */
+    public AnnotationProps setXml(AnnotationConsts key, XmlObject value) {
+        if (key.isSimpleType())
+            throw new RuntimeException("Expect string value for annotation, not Xml Object [" + key + ", " + value
+                    + "]");
+        if (key.isMultiValued())
+            throw new RuntimeException("Expect list XML Object value for annotation, not single [" + key + ", " + value
+                    + "]");
+
+        localMap.put(key, value);
+        return this;
+    }
+
+    /**
+     * Use for multivalued string annotation
+     * 
+     * @param key
+     *            an AnnotationConsts
+     * @param value
+     *            a List
+     * 
+     * @return an AnnotationProps
+     * 
+     */
+    public AnnotationProps set(AnnotationConsts key, List<String> value) {
+        if (!key.isSimpleType())
+            throw new RuntimeException("Expect XML Object value for annotation, not String [" + key + ", " + value
+                    + "]");
+        if (!key.isMultiValued())
+            throw new RuntimeException("Expect single XML Object value for annotation, not List [" + key + ", " + value
+                    + "]");
+
+        localMap.put(key, value);
+        return this;
+    }
+
+    /**
+     * Use for multivalued XmlObj annotation
+     * 
+     * @param key
+     *            an AnnotationConsts
+     * @param value
+     *            a List
+     * 
+     * @return an AnnotationProps
+     * 
+     */
+    public AnnotationProps setXml(AnnotationConsts key, List<XmlObject> value) {
+        if (key.isSimpleType())
+            throw new RuntimeException("Expect string value for annotation, not Xml Object [" + key + ", " + value
+                    + "]");
+        if (!key.isMultiValued())
+            throw new RuntimeException("Expect single XML Object value for annotation, not List [" + key + ", " + value
+                    + "]");
+
+        localMap.put(key, value);
+        return this;
+    }
+
+    /**
+     * Use to add to existing multivalued string annotation
+     * 
+     * @param key
+     *            an AnnotationConsts
+     * @param value
+     *            a String
+     * 
+     * @return an AnnotationProps
+     * 
+     */
+    public AnnotationProps add(AnnotationConsts key, String value) {
+        if (!key.isSimpleType())
+            throw new RuntimeException("Expect XML Object value for annotation, not String [" + key + ", " + value
+                    + "]");
+        if (!key.isMultiValued())
+            throw new RuntimeException("Expect single XML Object value for annotation. use set, not add [" + key + ", "
+                    + value + "]");
+
+        List<String> val = (List<String>) localMap.get(key);
+        if (val == null) {
+            val = new ArrayList<String>();
+            localMap.put(key, val);
+        }
+        val.add(value);
+        return this;
+    }
+
+    /**
+     * Use to add to existing multivalued XmlObj annotation
+     * 
+     * @param key
+     *            an AnnotationConsts
+     * @param value
+     *            a XmlObject
+     * 
+     * @return an AnnotationProps
+     * 
+     */
+    public AnnotationProps addXml(AnnotationConsts key, XmlObject value) {
+        if (key.isSimpleType())
+            throw new RuntimeException("Expect string value for annotation, not Xml Object [" + key + ", " + value
+                    + "]");
+        if (!key.isMultiValued())
+            throw new RuntimeException("Expect single XML Object value for annotation, use set, not add [" + key + ", "
+                    + value + "]");
+
+        List<XmlObject> val = (List<XmlObject>) localMap.get(key);
+        if (val == null) {
+            val = new ArrayList<XmlObject>();
+            localMap.put(key, val);
+        }
+        val.add(value);
+        return this;
+    }
+
+    public String get(AnnotationConsts key) {
+        if (!key.isSimpleType())
+            throw new RuntimeException("Expect XML Object value for annotation, not String" + " for anno: " + key);
+        if (key.isMultiValued())
+            throw new RuntimeException("Expect list XML Object value for annotation, not single" + " for anno: " + key);
+
+        return (String) localMap.get(key);
+    }
+
+    public XmlObject getXml(AnnotationConsts key) {
+        if (key.isSimpleType())
+            throw new RuntimeException("Expect string value for annotation, not Xml Object" + " for anno: " + key);
+        if (!key.isMultiValued())
+            throw new RuntimeException("Expect list XML Object value for annotation, not single" + " for anno: " + key);
+
+        return (XmlObject) localMap.get(key);
+    }
+
+    public List<String> getAll(AnnotationConsts key) {
+        if (!key.isSimpleType())
+            throw new RuntimeException("Expect XML Object value for annotation, not String" + " for anno: " + key);
+        if (!key.isMultiValued())
+            throw new RuntimeException("Expect single XML Object value for annotation, not List" + " for anno: " + key);
+
+        return (List<String>) localMap.get(key);
+    }
+
+    public List<XmlObject> getAllXml(AnnotationConsts key) {
+        if (key.isSimpleType())
+            throw new RuntimeException("Expect string value for annotation, not Xml Object" + " for anno: " + key);
+        if (!key.isMultiValued())
+            throw new RuntimeException("Expect single XML Object value for annotation, not List" + " for anno: " + key);
+
+        return (List<XmlObject>) localMap.get(key);
+    }
+
+    public Set<AnnotationConsts> getKeys() {
+        return localMap.keySet();
+    }
+
+    public int size() {
+        return localMap.size();
+    }
+
+    @Override
+    public String toString() {
+        final StringBuffer anno = new StringBuffer();
+        for (AnnotationConsts key : localMap.keySet()) {
+            if (key.isSimpleType()) {
+                if (key.isMultiValued()) {
+                    // List<String>
+                    List<String> values = (List<String>) localMap.get(key);
+                    for (String val : values) {
+                        addStartTag(anno, key);
+                        anno.append(val);
+                        addEndTag(anno, key);
+                    }
+                } else {
+                    // String
+                    String val = (String) localMap.get(key);
+                    addStartTag(anno, key);
+                    anno.append(val);
+                    addEndTag(anno, key);
+                }
+            } else {
+                if (key.isMultiValued()) {
+                    // List<XmlObject>
+                    List<XmlObject> values = (List<XmlObject>) localMap.get(key);
+                    for (XmlObject val : values) {
+                        addStartTag(anno, key);
+                        anno.append(val.xmlText());
+                        addEndTag(anno, key);
+                    }
+                } else {
+                    // XmlObject
+                    XmlObject val = (XmlObject) localMap.get(key);
+                    addStartTag(anno, key);
+                    anno.append(val.xmlText());
+                    addEndTag(anno, key);
+                }
+            }
+        }
+        return anno.toString();
+    }
+
+    private void addStartTag(StringBuffer anno, AnnotationConsts key) {
+        QName qname = key.getQName();
+        anno.append('<');
+        anno.append(qname.getLocalPart());
+        if (qname.getNamespaceURI() != null) {
+            anno.append(" xmlns='");
+            anno.append(qname.getNamespaceURI());
+            anno.append('\'');
+        }
+        anno.append('>');
+    }
+
+    private void addEndTag(StringBuffer anno, AnnotationConsts key) {
+        anno.append("</");
+        anno.append(key.getQName().getLocalPart());
+        anno.append('>');
+    }
+
+}

Added: incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/ConstructorConsts.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/ConstructorConsts.java?rev=1142475&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/ConstructorConsts.java (added)
+++ incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/ConstructorConsts.java Sun Jul  3 18:32:59 2011
@@ -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.airavata.workflow.tracking.common;
+
+import org.apache.airavata.workflow.tracking.client.Callback;
+
+/**
+ * This contains the names of parameters passed to the notifier constructor. e.g. props =
+ * util.Props.newProps(CONSTS.WORKFLOW_ID, "wfId001"). set(CONSTS.NODE_ID, "nodeId001"). set(CONSTS.TIMESTEP,
+ * "time0001"). set(CONSTS.BROKER_URL, "rainier:12346")); Notifier notifier = NotifierFactory.createNotifier(props);
+ */
+public enum ConstructorConsts {
+
+    NOTIFIER_IMPL_CLASS(String.class), ENABLE_BATCH_PROVENANCE(String.class), PUBLISHER_IMPL_CLASS(String.class), ENABLE_ASYNC_PUBLISH(
+            String.class), TOPIC(String.class), CALLBACK_LISTENER(Callback.class), BROKER_EPR(String.class), ANNOTATIONS(
+            AnnotationProps.class), KARMA_URL(String.class), KARMA_IMPL(Object.class);
+
+    public Class getValueType() {
+        return valueType;
+    }
+
+    public boolean checkValueType(Class otherType) {
+        if (otherType == null)
+            return false;
+        if (valueType.isAssignableFrom(otherType))
+            return true;
+        else
+            return false;
+    }
+
+    private Class valueType;
+
+    private ConstructorConsts(Class type_) {
+        valueType = type_;
+    }
+}

Added: incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/ConstructorProps.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/ConstructorProps.java?rev=1142475&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/ConstructorProps.java (added)
+++ incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/ConstructorProps.java Sun Jul  3 18:32:59 2011
@@ -0,0 +1,68 @@
+/*
+ *
+ * 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.airavata.workflow.tracking.common;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * simple helper class to set properties as a chain. Extends Properties, so can be passed as constructor to notifier
+ * factory. can also load an external propetirs file that conforms to Java Properties file schema at
+ * http://java.sun.com/dtd/properties.dtd.
+ * 
+ * e.g. props = util.Props.newProps(CONSTS.WORKFLOW_ID, "wfId001"). set(CONSTS.NODE_ID, "nodeId001").
+ * set(CONSTS.TIMESTEP, "time0001"). set(CONSTS.BROKER_URL, "rainier:12346")); Notifier notifier =
+ * NotifierFactory.createNotifier(props);
+ */
+public class ConstructorProps {
+
+    private Map<ConstructorConsts, Object> localMap;
+
+    public ConstructorProps() {
+        localMap = new HashMap<ConstructorConsts, Object>();
+    }
+
+    public static ConstructorProps newProps() {
+        return new ConstructorProps();
+    }
+
+    public static ConstructorProps newProps(ConstructorConsts key, Object value) {
+        return newProps().set(key, value);
+    }
+
+    public ConstructorProps set(ConstructorConsts key, Object value) {
+        if (!key.checkValueType(value.getClass()))
+            throw new ClassCastException("passed value class type: " + value.getClass() + " != expected class type: "
+                    + key.getValueType() + " for key: " + key);
+        localMap.put(key, value);
+        return this;
+    }
+
+    public Object get(ConstructorConsts key) {
+        return localMap.get(key);
+    }
+
+    public Object get(ConstructorConsts key, Object defaultValue) {
+        Object value = localMap.get(key);
+        return value == null ? defaultValue : value;
+    }
+}

Added: incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/DataDurationObj.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/DataDurationObj.java?rev=1142475&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/DataDurationObj.java (added)
+++ incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/DataDurationObj.java Sun Jul  3 18:32:59 2011
@@ -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.airavata.workflow.tracking.common;
+
+import java.net.URI;
+
+/**
+ * Convinience class to record notification related information about a file/directory.
+ * 
+ */
+public interface DataDurationObj extends DurationObj {
+
+    public DataObj getDataObj();
+
+    public URI getRemoteLocation();
+}

Added: incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/DataObj.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/DataObj.java?rev=1142475&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/DataObj.java (added)
+++ incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/DataObj.java Sun Jul  3 18:32:59 2011
@@ -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.airavata.workflow.tracking.common;
+
+import java.net.URI;
+import java.util.List;
+
+/**
+ * Convinience class to record notification related information about a file/directory.
+ * 
+ * 
+ */
+public interface DataObj {
+
+    public URI getId();
+
+    public URI getLocalLocation();
+
+    public List<URI> getLocations();
+
+    public long getSizeInBytes();
+
+}

Added: incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/DurationObj.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/DurationObj.java?rev=1142475&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/DurationObj.java (added)
+++ incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/DurationObj.java Sun Jul  3 18:32:59 2011
@@ -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.airavata.workflow.tracking.common;
+
+/**
+ * Convinience class to record the state of computation related notifications.
+ */
+public interface DurationObj {
+
+    public long markStartTimeMillis();
+
+    public long getStartTimeMillis();
+
+    public long markEndTimeMillis();
+
+    public long getEndTimeMillis();
+
+    public long getDurationMillis();
+}

Added: incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/InvocationContext.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/InvocationContext.java?rev=1142475&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/InvocationContext.java (added)
+++ incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/InvocationContext.java Sun Jul  3 18:32:59 2011
@@ -0,0 +1,28 @@
+/*
+ *
+ * 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.airavata.workflow.tracking.common;
+
+public interface InvocationContext extends InvocationEntity {
+
+    public InvocationEntity getRemoteEntity();
+
+}

Added: incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/InvocationEntity.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/InvocationEntity.java?rev=1142475&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/InvocationEntity.java (added)
+++ incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/InvocationEntity.java Sun Jul  3 18:32:59 2011
@@ -0,0 +1,37 @@
+/*
+ *
+ * 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.airavata.workflow.tracking.common;
+
+import java.net.URI;
+
+public interface InvocationEntity {
+
+    public String getWorkflowNodeID();
+
+    public URI getServiceID();
+
+    public Integer getWorkflowTimestep();
+
+    public URI getWorkflowID();
+
+    public BaseIDType toBaseIDType();
+}

Added: incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/NotifierConfig.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/NotifierConfig.java?rev=1142475&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/NotifierConfig.java (added)
+++ incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/NotifierConfig.java Sun Jul  3 18:32:59 2011
@@ -0,0 +1,54 @@
+/*
+ *
+ * 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.airavata.workflow.tracking.common;
+
+import org.apache.axis2.addressing.EndpointReference;
+
+public class NotifierConfig {
+    private EndpointReference bokerEpr;
+    private String publisherImpl;
+    private boolean enableAsyncPublishing;
+
+    public EndpointReference getBokerEpr() {
+        return bokerEpr;
+    }
+
+    public void setBokerEpr(EndpointReference bokerEpr) {
+        this.bokerEpr = bokerEpr;
+    }
+
+    public String getPublisherImpl() {
+        return publisherImpl;
+    }
+
+    public void setPublisherImpl(String publisherImpl) {
+        this.publisherImpl = publisherImpl;
+    }
+
+    public boolean isEnableAsyncPublishing() {
+        return enableAsyncPublishing;
+    }
+
+    public void setEnableAsyncPublishing(boolean enableAsyncPublishing) {
+        this.enableAsyncPublishing = enableAsyncPublishing;
+    }
+}

Added: incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/NotifierCreationException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/NotifierCreationException.java?rev=1142475&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/NotifierCreationException.java (added)
+++ incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/NotifierCreationException.java Sun Jul  3 18:32:59 2011
@@ -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.airavata.workflow.tracking.common;
+
+public class NotifierCreationException extends NotifierException {
+    public NotifierCreationException(String msg) {
+        super(msg);
+    }
+
+    public NotifierCreationException(Throwable ex) {
+        super(ex);
+    }
+}

Added: incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/NotifierException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/NotifierException.java?rev=1142475&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/NotifierException.java (added)
+++ incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/NotifierException.java Sun Jul  3 18:32:59 2011
@@ -0,0 +1,36 @@
+/*
+ *
+ * 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.airavata.workflow.tracking.common;
+
+public class NotifierException extends RuntimeException {
+    public NotifierException(String msg) {
+        super(msg);
+    }
+
+    public NotifierException(Throwable ex) {
+        super(ex);
+    }
+
+    public NotifierException(String msg, Throwable ex) {
+        super(msg, ex);
+    }
+}

Added: incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/NotifierVersion.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/NotifierVersion.java?rev=1142475&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/NotifierVersion.java (added)
+++ incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/NotifierVersion.java Sun Jul  3 18:32:59 2011
@@ -0,0 +1,56 @@
+/*
+ *
+ * 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.airavata.workflow.tracking.common;
+
+/**
+ * One place to put and check required version number.
+ */
+public class NotifierVersion {
+
+    private final static String TYPES_VERSION = "2.6";
+    private final static String IMPL_VERSION = "2.8.0";
+
+    public static String getTypesVersion() {
+        return TYPES_VERSION;
+    }
+
+    public static String getImplVersion() {
+        return IMPL_VERSION;
+    }
+
+    /**
+     * Print version when exxecuted from command line.
+     */
+    public static void main(String[] args) {
+        String IMPL_OPT = "-impl";
+        String TYPE_OPT = "-types";
+        if (IMPL_OPT.equals(args[0])) {
+            System.out.println(IMPL_VERSION);
+        } else if (TYPE_OPT.equals(args[0])) {
+            System.out.println(TYPES_VERSION);
+        } else {
+            System.out.println(NotifierVersion.class.getName() + " Error: " + TYPE_OPT + " or " + IMPL_OPT
+                    + " is required");
+            System.exit(-1);
+        }
+    }
+}

Added: incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/WorkflowTrackingContext.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/WorkflowTrackingContext.java?rev=1142475&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/WorkflowTrackingContext.java (added)
+++ incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/common/WorkflowTrackingContext.java Sun Jul  3 18:32:59 2011
@@ -0,0 +1,82 @@
+/*
+ *
+ * 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.airavata.workflow.tracking.common;
+
+import java.util.Properties;
+
+import org.apache.axis2.addressing.EndpointReference;
+
+public class WorkflowTrackingContext {
+    private EndpointReference brokerEpr;
+    private String globalAnnotations;
+    private InvocationEntity myself;
+    private String publisherImpl;
+    private boolean enableAsyncPublishing;
+
+    public void setGlobalAnnotations(Properties globalAnnotations) {
+        StringBuffer buf = new StringBuffer();
+        if (globalAnnotations != null) {
+            for (Object key : globalAnnotations.keySet()) {
+                buf.append("<").append(key).append(">").append(globalAnnotations.get(key)).append("</").append(key)
+                        .append(">");
+            }
+        }
+        this.globalAnnotations = buf.toString();
+    }
+
+    public String getGlobalAnnotations() {
+        return globalAnnotations;
+    }
+
+    public InvocationEntity getMyself() {
+        return myself;
+    }
+
+    public void setMyself(InvocationEntity myself) {
+        this.myself = myself;
+    }
+
+    public EndpointReference getBrokerEpr() {
+        return brokerEpr;
+    }
+
+    public void setBrokerEpr(EndpointReference brokerEpr) {
+        this.brokerEpr = brokerEpr;
+    }
+
+    public String getPublisherImpl() {
+        return publisherImpl;
+    }
+
+    public void setPublisherImpl(String publisherImpl) {
+        this.publisherImpl = publisherImpl;
+    }
+
+    public boolean isEnableAsyncPublishing() {
+        return enableAsyncPublishing;
+    }
+
+    public void setEnableAsyncPublishing(boolean enableAsyncPublishing) {
+        this.enableAsyncPublishing = enableAsyncPublishing;
+    }
+
+}

Added: incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/impl/GenericNotifierImpl.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/impl/GenericNotifierImpl.java?rev=1142475&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/impl/GenericNotifierImpl.java (added)
+++ incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/impl/GenericNotifierImpl.java Sun Jul  3 18:32:59 2011
@@ -0,0 +1,107 @@
+/*
+ *
+ * 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.airavata.workflow.tracking.impl;
+
+import org.apache.airavata.workflow.tracking.AbstractNotifier;
+import org.apache.airavata.workflow.tracking.GenericNotifier;
+import org.apache.airavata.workflow.tracking.WorkflowTrackingException;
+import org.apache.airavata.workflow.tracking.common.InvocationContext;
+import org.apache.airavata.workflow.tracking.common.InvocationEntity;
+import org.apache.airavata.workflow.tracking.common.WorkflowTrackingContext;
+import org.apache.airavata.workflow.tracking.impl.state.InvocationContextImpl;
+import org.apache.log4j.Logger;
+
+/**
+ * DOES NOT SUPPORT MULTI_THREADING -- PUBLISHER QUEUE, DATA CONSUMED/PRODUCED BATCHING
+ * 
+ * The constructor of this class uses the following properties from CONSTS: BROKER_URL, TOPIC, WORKFLOW_ID, NODE_ID,
+ * TIMESTEP, SERVICE_ID, ASYNC_PUB_MODE
+ */
+public class GenericNotifierImpl extends AbstractNotifier implements GenericNotifier {
+
+    // private AnnotationProps globalAnnotations;
+
+    protected static final org.apache.log4j.Logger logger = Logger.getLogger(GenericNotifierImpl.class);
+
+    public GenericNotifierImpl() throws WorkflowTrackingException {
+        super();
+    }
+
+    public InvocationContext createInitialContext(WorkflowTrackingContext context) {
+        if (context.getMyself() == null) {
+            throw new RuntimeException("Local entity passed to createInitialContext was NULL");
+        }
+        return new InvocationContextImpl(context.getMyself(), null);
+    }
+
+    public InvocationContext createInvocationContext(WorkflowTrackingContext context, InvocationEntity remoteEntity) {
+
+        if (context.getMyself() == null) {
+            throw new RuntimeException("Local entity passed to createInitialContext was NULL");
+        }
+
+        if (remoteEntity == null) {
+            throw new RuntimeException("Remote entity passed to createInitialContext was NULL");
+        }
+
+        return new InvocationContextImpl(context.getMyself(), remoteEntity);
+    }
+
+    public void debug(WorkflowTrackingContext context, String... descriptionAndAnnotation) {
+        LogDebugDocument logMsg = LogDebugDocument.Factory.newInstance();
+        BaseNotificationType log = logMsg.addNewLogDebug();
+        // add timestamp and notification source; add description, and
+        // annotation if present
+        sendNotification(context, logMsg, descriptionAndAnnotation, null);
+    }
+
+    public void exception(WorkflowTrackingContext context, String... descriptionAndAnnotation) {
+        LogExceptionDocument logMsg = LogExceptionDocument.Factory.newInstance();
+        BaseNotificationType log = logMsg.addNewLogException();
+        sendNotification(context, logMsg, descriptionAndAnnotation, null);
+    }
+
+    public void info(WorkflowTrackingContext context, String... descriptionAndAnnotation) {
+        LogInfoDocument logMsg = LogInfoDocument.Factory.newInstance();
+        BaseNotificationType log = logMsg.addNewLogInfo();
+        // add timestamp and notification source; add description, and
+        // annotation if present
+        // publish activity
+        sendNotification(context, logMsg, descriptionAndAnnotation, null);
+    }
+
+    public void publishURL(WorkflowTrackingContext context, String title, String url,
+            String... descriptionAndAnnotation) {
+        PublishURLDocument pubMsg = PublishURLDocument.Factory.newInstance();
+        PublishURLDocument.PublishURL pub = pubMsg.addNewPublishURL();
+        pub.setTitle(title);
+        pub.setLocation(url);
+        sendNotification(context, pubMsg, descriptionAndAnnotation, null);
+    }
+
+    public void warning(WorkflowTrackingContext context, String... descriptionAndAnnotation) {
+        LogWarningDocument logMsg = LogWarningDocument.Factory.newInstance();
+        BaseNotificationType log = logMsg.addNewLogWarning();
+        sendNotification(context, logMsg, descriptionAndAnnotation, null);
+    }
+
+}

Added: incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/impl/NotifierImpl.java
URL: http://svn.apache.org/viewvc/incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/impl/NotifierImpl.java?rev=1142475&view=auto
==============================================================================
--- incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/impl/NotifierImpl.java (added)
+++ incubator/airavata/ws-messaging/trunk/workflow-tracking/src/main/java/org/apache/airavata/workflow/tracking/impl/NotifierImpl.java Sun Jul  3 18:32:59 2011
@@ -0,0 +1,495 @@
+/*
+ *
+ * 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.airavata.workflow.tracking.impl;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.airavata.commons.LeadCrosscutParametersUtil;
+import org.apache.airavata.workflow.tracking.Notifier;
+import org.apache.airavata.workflow.tracking.common.DataDurationObj;
+import org.apache.airavata.workflow.tracking.common.DataObj;
+import org.apache.airavata.workflow.tracking.common.DurationObj;
+import org.apache.airavata.workflow.tracking.common.WorkflowTrackingContext;
+import org.apache.airavata.workflow.tracking.impl.state.DataDurationImpl;
+import org.apache.airavata.workflow.tracking.impl.state.DataObjImpl;
+import org.apache.airavata.workflow.tracking.impl.state.DurationImpl;
+
+/**
+ * DOES NOT SUPPORT MULTI_THREADING -- PUBLISHER QUEUE, DATA CONSUMED/PRODUCED BATCHING * Utility to create and send
+ * Lead notification messages for an application (script/web service). Since it extends WorkflowNotifierImpl, it can
+ * also send workflow related notifications.
+ * 
+ * The constructor of this class uses the following properties from CONSTS: BROKER_URL, TOPIC, WORKFLOW_ID, NODE_ID,
+ * TIMESTEP, SERVICE_ID, SERVICE_WSDL, IN_XML_MESSAGE, NAME_RESOLVER_URL, FILE_ACCESS_PROTOCOL, DISABLE_NAME_RESOLVER,
+ * BATCH_PROVENANCE_MSGS, ASYNC_PUB_MODE
+ * 
+ */
+public class NotifierImpl extends ProvenanceNotifierImpl implements Notifier {
+
+    private static final String WFT_NS = "http://lead.extreme.indiana.edu/namespaces/2006/06/workflow_tracking";
+
+    private static final HashMap<String, String> NS_MAP = new HashMap<String, String>();
+    static {
+        NS_MAP.put("", WFT_NS);
+    }
+
+    // public NotifierImpl(ConstructorProps props) throws XMLStreamException, IOException {
+    // super( props);
+    // }
+
+    /**
+     * @param batchProvMessages
+     *            whether provenance messages should be batched and sent as one message
+     * @param publisher
+     *            a NotificationPublisher used to send the notifications
+     * 
+     */
+    public NotifierImpl() {
+    }
+
+    // //////////////////////////////////////////////////////////////////////////////////////////////
+    //
+    // AUDIT NOTIFIER
+    //
+    // //////////////////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * {@inheritDoc}
+     * 
+     */
+    public void resourceMapping(WorkflowTrackingContext context, String mappedResource, int retryStatusCount,
+            String... descriptionAndAnnotation) {
+
+        ResourceMappingDocument mapMsg = ResourceMappingDocument.Factory.newInstance();
+        ResourceMappingType map = mapMsg.addNewResourceMapping();
+        map.setMappedResource(mappedResource);
+        map.setRetryStatusCount(retryStatusCount);
+
+        sendNotification(context, mapMsg, descriptionAndAnnotation, "[Resource mapping done for" + mappedResource + "]");
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     */
+    public void jobStatus(WorkflowTrackingContext context, String status, int retryCount,
+            String... descriptionAndAnnotation) {
+
+        JobStatusDocument jobMsg = JobStatusDocument.Factory.newInstance();
+        JobStatusType job = jobMsg.addNewJobStatus();
+        job.setJobStatus(status);
+        job.setRetryCount(retryCount);
+
+        sendNotification(context, jobMsg, descriptionAndAnnotation, "[Job status is " + status + "]");
+    }
+
+    // //////////////////////////////////////////////////////////////////////////////////////////////
+    //
+    // AUDIT NOTIFIER
+    //
+    // //////////////////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * {@inheritDoc}
+     * 
+     */
+    public void appAudit(WorkflowTrackingContext context, String name, URI jobHandle, String host, String queueName,
+            String jobId, String dName, String projectId, String rsl, String... descriptionAndAnnotation) {
+        final ApplicationAuditDocument appAuditMsg = ApplicationAuditDocument.Factory.newInstance();
+        final ApplicationAuditType appAudit = appAuditMsg.addNewApplicationAudit();
+        appAudit.setJobHandle(jobHandle.toString());
+        appAudit.setName(name);
+        appAudit.setHost(host);
+        appAudit.setQueueName(queueName); // queueName is an optional element
+        appAudit.setJobId(jobId); // jobId is an optional element
+        appAudit.setDistinguishedName(dName);
+        appAudit.setProjectId(projectId); // projectId is an optional element
+        appAudit.setRsl(rsl);
+
+        sendNotification(context, appAuditMsg, descriptionAndAnnotation, "[Audit msg for '" + name + "' at host "
+                + host + " for DN " + dName + "]" // default
+        );
+    }
+
+    // //////////////////////////////////////////////////////////////////////////////////////////////
+    //
+    // PERFORMANCE NOTIFIER
+    //
+    // //////////////////////////////////////////////////////////////////////////////////////////////
+    /**
+     * {@inheritDoc}
+     * 
+     */
+    public DurationObj computationStarted() {
+
+        return new DurationImpl();
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     */
+    public DurationObj computationFinished(WorkflowTrackingContext context, DurationObj compObj,
+            String... descriptionAndAnnotation) {
+
+        if (context == null)
+            throw new RuntimeException("Local entity passed was NULL.");
+        if (compObj == null)
+            throw new RuntimeException("Comp duration object passed was NULL.");
+
+        // mark computation end
+        compObj.markEndTimeMillis();
+
+        // create activity
+        ComputationDurationDocument activity = ComputationDurationDocument.Factory.newInstance();
+        ComputationDurationDocument.ComputationDuration activityType = activity.addNewComputationDuration();
+
+        activityType.setDurationInMillis(compObj.getDurationMillis());
+
+        sendNotification(context, activity, descriptionAndAnnotation,
+                "[Computation Time taken = " + compObj.getDurationMillis() + " ms]");
+
+        return compObj;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     */
+    public DurationObj computationDuration(WorkflowTrackingContext context, long durationMillis,
+            String... descriptionAndAnnotation) {
+
+        DurationObj compObj = new DurationImpl(durationMillis);
+        return computationFinished(context, compObj, descriptionAndAnnotation);
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     */
+    public DataDurationObj dataSendStarted(DataObj dataObj, URI remoteLocation) {
+
+        return new DataDurationImpl(dataObj, remoteLocation);
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     */
+    public DataDurationObj dataSendFinished(WorkflowTrackingContext context, DataDurationObj dataDurationObj,
+            String... descriptionAndAnnotation) {
+
+        if (context == null)
+            throw new RuntimeException("Local entity passed was NULL.");
+        if (dataDurationObj == null)
+            throw new RuntimeException("Data duration object passed was NULL.");
+
+        DataObj dataObj = null;
+        if ((dataObj = dataDurationObj.getDataObj()) == null)
+            throw new RuntimeException("Data duration object's DataObje was NULL.");
+        if (dataObj.getId() == null)
+            throw new RuntimeException("Data object's ID was NULL.");
+        if (dataObj.getLocalLocation() == null)
+            throw new RuntimeException("Local file URL passed in DataDurationObj.getDataObj was NULL.");
+        if (dataDurationObj.getRemoteLocation() == null)
+            throw new RuntimeException("Remote file URL passed in DataDurationObj was NULL.");
+
+        // mark computation end
+        dataDurationObj.markEndTimeMillis();
+
+        // create activity
+        DataSendDurationDocument activity = DataSendDurationDocument.Factory.newInstance();
+        DataTransferDurationType activityType = activity.addNewDataSendDuration();
+
+        activityType.setId(dataObj.getId().toString());
+        activityType.setDurationInMillis(dataDurationObj.getDurationMillis());
+        activityType.setSizeInBytes(dataObj.getSizeInBytes());
+
+        activityType.setSource(dataObj.getLocalLocation().toString());
+
+        activityType.setTarget(dataDurationObj.getRemoteLocation().toString());
+
+        sendNotification(context, activity, descriptionAndAnnotation, "[Data at " + dataObj.getLocalLocation()
+                + " was sent to " + dataDurationObj.getRemoteLocation() + "]");
+
+        return dataDurationObj;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     */
+    public DataDurationObj dataSendDuration(WorkflowTrackingContext context, URI dataID, URI localLocation,
+            URI remoteLocation, int sizeInBytes, long durationMillis, String... descriptionAndAnnotation) {
+
+        List<URI> locations = new ArrayList<URI>(2);
+        locations.add(localLocation);
+        locations.add(remoteLocation);
+
+        DataObj dataObj = new DataObjImpl(dataID, locations, sizeInBytes);
+        DataDurationObj dataDurationObj = new DataDurationImpl(dataObj, remoteLocation, durationMillis);
+
+        return dataSendFinished(context, dataDurationObj, descriptionAndAnnotation);
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     */
+    public DataDurationObj dataReceiveStarted(URI dataID, URI remoteLocation, URI localLocation) {
+
+        List<URI> locations = new ArrayList<URI>(2);
+        locations.add(localLocation);
+        locations.add(remoteLocation);
+
+        DataObj dataObj = new DataObjImpl(dataID, locations);
+        DataDurationObj dataDurationObj = new DataDurationImpl(dataObj, remoteLocation);
+
+        return dataDurationObj;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     */
+    public DataDurationObj dataReceiveFinished(WorkflowTrackingContext context, DataDurationObj dataDurationObj,
+            String... descriptionAndAnnotation) {
+
+        if (context == null)
+            throw new RuntimeException("Local entity passed was NULL.");
+        if (dataDurationObj == null)
+            throw new RuntimeException("Data duration object passed was NULL.");
+
+        DataObj dataObj = null;
+        if ((dataObj = dataDurationObj.getDataObj()) == null)
+            throw new RuntimeException("Data duration object's DataObj was NULL.");
+        if (dataObj.getId() == null)
+            throw new RuntimeException("Data object's ID was NULL.");
+        if (dataObj.getLocalLocation() == null)
+            throw new RuntimeException("Local file URL passed in DataDurationObj.getDataObj was NULL.");
+        if (dataDurationObj.getRemoteLocation() == null)
+            throw new RuntimeException("Remote file URL passed in DataDurationObj was NULL.");
+
+        // mark computation end
+        dataDurationObj.markEndTimeMillis();
+
+        // create activity
+        DataReceiveDurationDocument activity = DataReceiveDurationDocument.Factory.newInstance();
+        DataTransferDurationType activityType = activity.addNewDataReceiveDuration();
+
+        activityType.setId(dataObj.getId().toString());
+        activityType.setDurationInMillis(dataDurationObj.getDurationMillis());
+        activityType.setSizeInBytes(dataObj.getSizeInBytes());
+
+        activityType.setSource(dataObj.getLocalLocation().toString());
+
+        activityType.setTarget(dataDurationObj.getRemoteLocation().toString());
+
+        sendNotification(context, activity, descriptionAndAnnotation,
+                "[Data from " + dataDurationObj.getRemoteLocation() + " was received at " + dataObj.getLocalLocation()
+                        + "]");
+
+        return dataDurationObj;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     */
+    public DataDurationObj dataReceiveDuration(WorkflowTrackingContext context, URI dataID, URI remoteLocation,
+            URI localLocation, int sizeInBytes, long durationMillis, String... descriptionAndAnnotation) {
+
+        List<URI> locations = new ArrayList<URI>(2);
+        locations.add(localLocation);
+        locations.add(remoteLocation);
+
+        DataObj dataObj = new DataObjImpl(dataID, locations, sizeInBytes);
+        DataDurationObj dataDurationObj = new DataDurationImpl(dataObj, remoteLocation, durationMillis);
+
+        return dataReceiveFinished(context, dataDurationObj, descriptionAndAnnotation);
+    }
+
+    public void queryStarted(WorkflowTrackingContext context, String radarName, String... descriptionAndAnnotation) {
+
+        QueryStartedDocument queryStartedDoc = QueryStartedDocument.Factory.newInstance();
+        CalderNotificationType calderNotificationType = queryStartedDoc.addNewQueryStarted();
+        calderNotificationType.setRadarName(radarName);
+
+        sendNotification(context, queryStartedDoc, descriptionAndAnnotation, "[Query started for " + radarName + "]");
+    }
+
+    public void queryFailedToStart(WorkflowTrackingContext context, String radarName,
+            String... descriptionAndAnnotation) {
+        QueryFailedToStartDocument queryFailedToStartDoc = QueryFailedToStartDocument.Factory.newInstance();
+        CalderNotificationType calderNotificationType = queryFailedToStartDoc.addNewQueryFailedToStart();
+        calderNotificationType.setRadarName(radarName);
+
+        sendNotification(context, queryFailedToStartDoc, descriptionAndAnnotation, "[Query failed to start for "
+                + radarName + "]");
+
+    }
+
+    public void queryActive(WorkflowTrackingContext context, String radarName, String... descriptionAndAnnotation) {
+        QueryActiveDocument queryActiveDoc = QueryActiveDocument.Factory.newInstance();
+        CalderNotificationType calderNotificationType = queryActiveDoc.addNewQueryActive();
+        calderNotificationType.setRadarName(radarName);
+
+        sendNotification(context, queryActiveDoc, descriptionAndAnnotation, "[Query active for " + radarName + "]");
+
+    }
+
+    public void queryExpired(WorkflowTrackingContext context, String radarName, String... descriptionAndAnnotation) {
+        QueryExpiredDocument queryExpiredDoc = QueryExpiredDocument.Factory.newInstance();
+        CalderNotificationType calderNotificationType = queryExpiredDoc.addNewQueryExpired();
+        calderNotificationType.setRadarName(radarName);
+
+        sendNotification(context, queryExpiredDoc, descriptionAndAnnotation, "[Query Expired for " + radarName + "]");
+
+    }
+
+    public void triggerFound(WorkflowTrackingContext context, String radarName, String... descriptionAndAnnotation) {
+        TriggerFoundDocument triggerFoundDoc = TriggerFoundDocument.Factory.newInstance();
+        CalderNotificationType calderNotificationType = triggerFoundDoc.addNewTriggerFound();
+        calderNotificationType.setRadarName(radarName);
+
+        sendNotification(context, triggerFoundDoc, descriptionAndAnnotation, "[Trigger found for " + radarName + "]");
+
+    }
+
+    public void queryPublishResult(WorkflowTrackingContext context,
+            LeadCrosscutParametersUtil leadCrosscutParametersUtil) {
+        QueryPublishResultDocument queryPublishResultDoc = QueryPublishResultDocument.Factory.newInstance();
+        CalderClusterNotificationType calderClusterNotificationType = queryPublishResultDoc.addNewQueryPublishResult();
+        calderClusterNotificationType.setCtrlat(leadCrosscutParametersUtil.getCenterLatitude());
+        calderClusterNotificationType.setCtrlon(leadCrosscutParametersUtil.getCenterLongitude());
+        calderClusterNotificationType.setNorthbc(leadCrosscutParametersUtil.getNorthBc());
+        calderClusterNotificationType.setSouthbc(leadCrosscutParametersUtil.getSouthBc());
+        calderClusterNotificationType.setEastbc(leadCrosscutParametersUtil.getEastBc());
+        calderClusterNotificationType.setWestbc(leadCrosscutParametersUtil.getWestBc());
+
+        sendNotification(context, queryPublishResultDoc, null,
+                "[Clustering result for query found at " + leadCrosscutParametersUtil.getCenterLatitude() + " "
+                        + leadCrosscutParametersUtil.getCenterLongitude() + "]");
+
+    }
+
+    public void queryNoDetection(WorkflowTrackingContext context, String... descriptionAndAnnotation) {
+        QueryNoDetectionDocument queryNoDetectionDoc = QueryNoDetectionDocument.Factory.newInstance();
+        CalderNotificationType calderNotificationType = queryNoDetectionDoc.addNewQueryNoDetection();
+        calderNotificationType.setRadarName("");
+        sendNotification(context, queryNoDetectionDoc, descriptionAndAnnotation,
+                "[No mining results detected for query]");
+    }
+
+    // /**
+    // * Create a notifier object with the default values set. Creating this is
+    // convinient
+    // * if the same service/application needs to generate multiple messages,
+    // since the various
+    // * IDs passed in the constructor will be filled into the message
+    // automatically. If you're
+    // * sending just a single message from a service/app, you can use the
+    // static methods that are
+    // * available.
+    // *
+    // * @param brokerLoc_ the location of the broker service in the form
+    // "host:port"
+    // * @param topic_ the topic to which messages should be sent
+    // * @param workflowID_ the workflow instance ID to which this
+    // service/application belongs
+    // * @param nodeID_ the node ID within the workflow which this
+    // service/application represents
+    // * @param wfTimeStep_ the unique timestep within the workflow instance at
+    // which this
+    // * service/application invocation is taking place
+    // * @param serviceID_
+    // * @param serviceWsdl_ the concrete WSDL of the service (or service
+    // wrapper of an
+    // * application) which is sending the notification. This is used
+    // * to retrieve the unique service QName that can identify this
+    // * service instance, and to get the schema for the response message
+    // * @param incomingMessageXml_ the icoming message that started this
+    // service that should contain
+    // * end point reference (ReplyTo EPR is minimum) where the results of
+    // * this service/application should be sent to.
+    // * @param nameResolverWsdl_ WSDL location of name resolver
+    // * @param fileProtocol_ the protocol used to access local files created by
+    // this application. e.g. gridftp://, http://, ftp://, etc. Defaults to
+    // file://.
+    // * @param enableNameResolver whether name resolution is enabled
+    // * @param batchProvMessages whether provenance messages should be batched
+    // and sent as one message
+    // */
+    // private void init(String brokerLoc_, String topic_,
+    // String workflowID_, String nodeID_, String wfTimeStep_,
+    // String serviceID_, String serviceWsdl_,
+    // String incomingMessageXml_,
+    // String nameResolverWsdl_,
+    // String fileProtocol_,
+    // boolean enableNameResolver,
+    // boolean enableBatchProvenance) {
+    //
+
+    /**
+     * Method main. Simple self test by generating some notifications
+     * 
+     * @param args
+     *            a String[]
+     * 
+     */
+    // public static void main(String args[]) throws Exception {
+    //
+    // System.err.println("Started " + NotifierImpl.class);
+    //
+    // for (int i=0; i < 10; i++) {
+    // ProvenanceNotifier n =
+    // new NotifierImpl(Props.newProps(BROKER_URL,
+    // "rainier.extreme.indiana.edu:12346"). // brokerLoc
+    // set(TOPIC, "lead_wft_test_topic"). // topic
+    // set(WORKFLOW_ID, "wfId93643").
+    // set(NODE_ID, "nodeId26").
+    // set(TIMESTEP, "12"). // id'ss
+    // set(SERVICE_ID, "http://service.qname/").
+    // set(NAME_RESOLVER_URL,
+    // "http://rainier.extreme.indiana.edu:33330/name_resolver?wsdl").
+    // set(ENABLE_NAME_RESOLVER, "true")
+    // );
+    //
+    // n.serviceInvoked("SampleApplication");
+    // //n.debug("debug message from the applcation..");
+    // //n.publishURL("LEAD home", "http://lead.ou.edu");
+    // n.dataConsumed("urn:lead-ou-edu:iub:f81d4fae-7dec-11d0-a765-00a0c91e6bf6",
+    // "/foo/bar/input.data");
+    // n.fileProduced("/foo/bar/output.data");
+    // n.dataConsumed("urn:lead-ou-edu:iub:f81d4fae-7dec-11d0-a765-00a0c91e6bf7",
+    // "/acme/input.2");
+    // n.fileProduced("/acme/output.2");
+    // n.sendingResult(null, null);
+    // }
+    // //n.workflowFinishedSuccess("rainier.extreme.indiana.edu:12346",
+    // "lead_wft_test_topic", "wfId93643");
+    // System.err.println("finsished " + NotifierImpl.class);
+    // }
+}



Mime
View raw message