You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by pa...@apache.org on 2011/10/10 23:26:43 UTC
svn commit: r1181247 - in /incubator/airavata/trunk/modules:
commons/registry-api/src/main/java/org/apache/airavata/registry/api/
commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/
gfac-axis2/src/main/java/org/apache/airavata/ser...
Author: patanachai
Date: Mon Oct 10 21:26:43 2011
New Revision: 1181247
URL: http://svn.apache.org/viewvc?rev=1181247&view=rev
Log:
AIRAVATA-134 add output register extension to GFac-Core
Added:
incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/DataRegistry.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/message/impl/WorkflowContextImpl.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/post/OutputRegister.java
Modified:
incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java
incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/reciever/GFacMessageReciever.java
incubator/airavata/trunk/modules/gfac-axis2/src/main/resources/repository.properties
incubator/airavata/trunk/modules/gfac-core/src/main/resources/service.properties
incubator/airavata/trunk/modules/gfac-core/src/test/resources/service.properties
Added: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/DataRegistry.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/DataRegistry.java?rev=1181247&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/DataRegistry.java (added)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/DataRegistry.java Mon Oct 10 21:26:43 2011
@@ -0,0 +1,47 @@
+/*
+ *
+ * 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.registry.api;
+
+import java.util.List;
+
+import org.apache.airavata.commons.gfac.type.parameter.AbstractParameter;
+
+public interface DataRegistry {
+
+ /**
+ * Save output from workflow execution.
+ *
+ * @param workflowId
+ * @param parameters
+ * @return
+ */
+ public String saveOutput(String workflowId, List<AbstractParameter> parameters);
+
+ /**
+ * Load output from workflow execution.
+ *
+ * @param workflowId
+ * @return List of parameters
+ */
+ public List<AbstractParameter> loadOutput(String workflowId);
+
+}
Modified: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java?rev=1181247&r1=1181246&r2=1181247&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java (original)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java Mon Oct 10 21:26:43 2011
@@ -46,15 +46,18 @@ import javax.jcr.Value;
import org.apache.airavata.commons.gfac.type.ApplicationDeploymentDescription;
import org.apache.airavata.commons.gfac.type.HostDescription;
import org.apache.airavata.commons.gfac.type.ServiceDescription;
+import org.apache.airavata.commons.gfac.type.parameter.AbstractParameter;
import org.apache.airavata.commons.gfac.type.util.SchemaUtil;
import org.apache.airavata.registry.api.Axis2Registry;
+import org.apache.airavata.registry.api.DataRegistry;
import org.apache.airavata.registry.api.user.UserManager;
import org.apache.airavata.registry.api.user.UserManagerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class JCRRegistry implements Axis2Registry {
+public class JCRRegistry implements Axis2Registry, DataRegistry {
+ private static final String OUTPUT_NODE_NAME = "OUTPUTS";
private static final String SERVICE_NODE_NAME = "SERVICE_HOST";
private static final String GFAC_INSTANCE_DATA = "GFAC_INSTANCE_DATA";
private static final String DEPLOY_NODE_NAME = "APP_HOST";
@@ -113,8 +116,6 @@ public class JCRRegistry implements Axis
return getOrAddNode(session.getRootNode(), SERVICE_NODE_NAME);
}
-
-
private Node getDeploymentNode(Session session) throws RepositoryException {
return getOrAddNode(session.getRootNode(), DEPLOY_NODE_NAME);
}
@@ -523,6 +524,55 @@ public class JCRRegistry implements Axis
public void setUserManager(UserManager userManager) {
this.userManager = userManager;
}
+
+ public String saveOutput(String workflowId, List<AbstractParameter> parameters) {
+ Session session = null;
+ String result = null;
+ try {
+ session = getSession();
+ Node outputNode = getOrAddNode(session.getRootNode(), OUTPUT_NODE_NAME);
+ Node node = getOrAddNode(outputNode, workflowId);
+ for (int i = 0; i < parameters.size(); i++) {
+ node.setProperty(String.valueOf(i), SchemaUtil.toXML(parameters.get(i)));
+ }
+
+ session.save();
-
+ result = node.getIdentifier();
+ } catch (Exception e) {
+ System.out.println(e);
+ e.printStackTrace();
+ // TODO propagate
+ } finally {
+ if (session != null && session.isLive()) {
+ session.logout();
+ }
+ }
+ return result;
+ }
+
+ public List<AbstractParameter> loadOutput(String workflowId){
+ Session session = null;
+ ArrayList<AbstractParameter> result = new ArrayList<AbstractParameter>();
+ try {
+ session = getSession();
+ Node outputNode = getOrAddNode(session.getRootNode(), OUTPUT_NODE_NAME);
+ Node node = outputNode.getNode(workflowId);
+
+ PropertyIterator it = node.getProperties();
+ while(it.hasNext()){
+ Property prop = (Property)it.next();
+ result.add((AbstractParameter) SchemaUtil.parseFromXML(prop.getString()));
+ }
+ } catch (Exception e) {
+ System.out.println(e);
+ e.printStackTrace();
+ // TODO propagate
+ } finally {
+ if (session != null && session.isLive()) {
+ session.logout();
+ }
+ }
+ return result;
+ }
}
Modified: incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/reciever/GFacMessageReciever.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/reciever/GFacMessageReciever.java?rev=1181247&r1=1181246&r2=1181247&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/reciever/GFacMessageReciever.java (original)
+++ incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/reciever/GFacMessageReciever.java Mon Oct 10 21:26:43 2011
@@ -39,6 +39,7 @@ import org.apache.airavata.commons.gfac.
import org.apache.airavata.core.gfac.context.invocation.impl.DefaultExecutionContext;
import org.apache.airavata.core.gfac.context.invocation.impl.DefaultInvocationContext;
import org.apache.airavata.core.gfac.context.message.impl.ParameterContextImpl;
+import org.apache.airavata.core.gfac.context.message.impl.WorkflowContextImpl;
import org.apache.airavata.core.gfac.factory.PropertyServiceFactory;
import org.apache.airavata.core.gfac.notification.impl.LoggingNotification;
import org.apache.airavata.core.gfac.notification.impl.WorkflowTrackingNotification;
@@ -152,6 +153,9 @@ public class GFacMessageReciever impleme
String topic = getTopic(messageContext);
OMElement outputElement = null;
try {
+ /*
+ * Add notifiable object
+ */
WorkflowTrackingNotification workflowNotification = new WorkflowTrackingNotification(brokerURL,topic);
LoggingNotification loggingNotification = new LoggingNotification();
DefaultInvocationContext invocationContext = new DefaultInvocationContext();
@@ -160,6 +164,13 @@ public class GFacMessageReciever impleme
invocationContext.getExecutionContext().setRegistryService(getRegistry(context));
invocationContext.getExecutionContext().addNotifiable(workflowNotification);
invocationContext.getExecutionContext().addNotifiable(loggingNotification);
+
+ /*
+ * Add workflow context
+ */
+ WorkflowContextImpl workflowContext = new WorkflowContextImpl();
+ workflowContext.setValue(WorkflowContextImpl.WORKFLOW_ID, URI.create(topic).toString());
+ invocationContext.addMessageContext(WorkflowContextImpl.WORKFLOW_CONTEXT_NAME, workflowContext);
/*
* read from registry and set the correct parameters
Modified: incubator/airavata/trunk/modules/gfac-axis2/src/main/resources/repository.properties
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-axis2/src/main/resources/repository.properties?rev=1181247&r1=1181246&r2=1181247&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-axis2/src/main/resources/repository.properties (original)
+++ incubator/airavata/trunk/modules/gfac-axis2/src/main/resources/repository.properties Mon Oct 10 21:26:43 2011
@@ -49,6 +49,7 @@ prechain.classes= org.apache.airavata.co
# Post execution Plugins classes. For example, GridFTP Output Staging
#
postchain.classes= org.apache.airavata.core.gfac.extension.post.GridFtpOutputStaging
+postchain.classes= org.apache.airavata.core.gfac.extension.post.OutputRegister
#
# SSH private key location. It will be used by SSHProvider
Added: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/message/impl/WorkflowContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/message/impl/WorkflowContextImpl.java?rev=1181247&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/message/impl/WorkflowContextImpl.java (added)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/message/impl/WorkflowContextImpl.java Mon Oct 10 21:26:43 2011
@@ -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.airavata.core.gfac.context.message.impl;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.airavata.core.gfac.context.message.MessageContext;
+
+/**
+ * This class contains actual parameters in service invocation.
+ */
+public class WorkflowContextImpl implements MessageContext<String> {
+
+ public static final String WORKFLOW_CONTEXT_NAME = "workflow_context";
+ public static final String WORKFLOW_ID = "workflowId";
+
+ private Map<String, String> value;
+
+ public WorkflowContextImpl() {
+ this.value = new HashMap<String, String>();
+ }
+
+ public Iterator<String> getNames() {
+ return this.value.keySet().iterator();
+ }
+
+ public String getValue(String name) {
+ return this.value.get(name);
+ }
+
+ public String getStringValue(String name) {
+ return this.value.get(name);
+ }
+
+ public void add(String name, String value) {
+ this.value.put(name, value);
+ }
+
+ public void setValue(String name, String value) {
+ this.value.put(name, value);
+ }
+
+}
Added: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/post/OutputRegister.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/post/OutputRegister.java?rev=1181247&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/post/OutputRegister.java (added)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/post/OutputRegister.java Mon Oct 10 21:26:43 2011
@@ -0,0 +1,77 @@
+/*
+ *
+ * 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.core.gfac.extension.post;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.airavata.commons.gfac.type.parameter.AbstractParameter;
+import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
+import org.apache.airavata.core.gfac.context.message.MessageContext;
+import org.apache.airavata.core.gfac.context.message.impl.WorkflowContextImpl;
+import org.apache.airavata.core.gfac.exception.ExtensionException;
+import org.apache.airavata.core.gfac.extension.PostExecuteChain;
+import org.apache.airavata.registry.api.DataRegistry;
+import org.apache.airavata.registry.api.Registry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Register output to Registry
+ */
+public class OutputRegister extends PostExecuteChain {
+
+ private static final Logger log = LoggerFactory.getLogger(OutputRegister.class);
+
+ public boolean execute(InvocationContext context) throws ExtensionException {
+ // output context
+ MessageContext<AbstractParameter> outputContext = context.getOutput();
+
+ // workflow context
+ MessageContext<String> workflowContext = context.getMessageContext(WorkflowContextImpl.WORKFLOW_CONTEXT_NAME);
+
+ // registry
+ Registry registry = context.getExecutionContext().getRegistryService();
+
+ if (outputContext != null && workflowContext != null) {
+
+ String workflowId = workflowContext.getValue(WorkflowContextImpl.WORKFLOW_ID);
+ List<AbstractParameter> outputs = new ArrayList<AbstractParameter>();
+
+ for (Iterator<String> iterator = outputContext.getNames(); iterator.hasNext();) {
+ String key = iterator.next();
+ outputs.add(outputContext.getValue(key));
+ }
+
+ if (registry != null && DataRegistry.class.isAssignableFrom(registry.getClass())) {
+ ((DataRegistry) registry).saveOutput(workflowId, outputs);
+ } else {
+ log.debug("Registry does not support for Data Catalog, CLass: " + registry.getClass());
+ }
+
+ } else {
+ log.debug("Context is null");
+ }
+ return false;
+ }
+}
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/resources/service.properties
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/resources/service.properties?rev=1181247&r1=1181246&r2=1181247&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/resources/service.properties (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/resources/service.properties Mon Oct 10 21:26:43 2011
@@ -49,6 +49,7 @@ prechain.classes= org.apache.airavata.co
# Post execution Plugins classes. For example, GridFTP Output Staging
#
postchain.classes= org.apache.airavata.core.gfac.extension.post.GridFtpOutputStaging
+postchain.classes= org.apache.airavata.core.gfac.extension.post.OutputRegister
#
# SSH private key location. It will be used by SSHProvider
Modified: incubator/airavata/trunk/modules/gfac-core/src/test/resources/service.properties
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/test/resources/service.properties?rev=1181247&r1=1181246&r2=1181247&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/test/resources/service.properties (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/test/resources/service.properties Mon Oct 10 21:26:43 2011
@@ -49,6 +49,7 @@ prechain.classes= org.apache.airavata.co
# Post execution Plugins classes. For example, GridFTP Output Staging
#
postchain.classes= org.apache.airavata.core.gfac.extension.post.GridFtpOutputStaging
+postchain.classes= org.apache.airavata.core.gfac.extension.post.OutputRegister
#
# SSH private key location. It will be used by SSHProvider