You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ra...@apache.org on 2011/08/11 22:33:39 UTC
svn commit: r1156811 - in /incubator/airavata/trunk/modules:
commons/gfac-schema/src/main/java/org/apache/airavata/core/gfac/api/
commons/gfac-schema/src/main/java/org/apache/airavata/core/gfac/api/impl/
commons/gfac-schema/src/main/java/org/apache/air...
Author: raminder
Date: Thu Aug 11 20:33:38 2011
New Revision: 1156811
URL: http://svn.apache.org/viewvc?rev=1156811&view=rev
Log:
applied patch for AIRAVATA-74 by Patnachai
Modified:
incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/core/gfac/api/Registry.java
incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/core/gfac/api/impl/JCRRegistry.java
incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/core/gfac/type/util/SchemaUtil.java
incubator/airavata/trunk/modules/gfac-core/pom.xml
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/ExecutionContext.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/impl/ExecutionContextImpl.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/data/RegistryDataService.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/impl/SchedulerImpl.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImpl.java
incubator/airavata/trunk/modules/gfac-core/src/main/resources/service.properties
incubator/airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImplTest.java
incubator/airavata/trunk/modules/gfac-core/src/test/resources/service.properties
Modified: incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/core/gfac/api/Registry.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/core/gfac/api/Registry.java?rev=1156811&r1=1156810&r2=1156811&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/core/gfac/api/Registry.java (original)
+++ incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/core/gfac/api/Registry.java Thu Aug 11 20:33:38 2011
@@ -34,7 +34,7 @@ public interface Registry {
* @param serviceName
* @return List of HostDescription having the service
*/
- public List<HostDescription> getServiceLocation(String serviceName);
+ public List<HostDescription> getServiceLocation(String serviceName);
/**
* Retrieve a service description i.e. name, description, parameters
@@ -88,122 +88,15 @@ public interface Registry {
* @return identifier
*/
public String saveDeploymentDescription(String service, String host, ApplicationDeploymentDescription app);
-
- /**
- * Search host description with name
- *
- * @param name
- * @return the host descriptions with matched name
- */
- public List<HostDescription> searchHostDescription(String name);
-
- /**
- * Search service description with name
- *
- * @param name
- * @return the service descriptions with matched name
- */
- public List<ServiceDescription> searchServiceDescription(String name);
-
- /**
- * Search deployment description from a service and/or a hostname
- *
- * @param serviceName
- * @param hostName
- * @return the deployment descriptions with matched names
- */
- public List<ApplicationDeploymentDescription> searchDeploymentDescription(String serviceName, String hostName);
-}
-/*
- *
- * 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.api;
-
-import java.util.List;
-
-import org.apache.airavata.core.gfac.type.ApplicationDeploymentDescription;
-import org.apache.airavata.core.gfac.type.HostDescription;
-import org.apache.airavata.core.gfac.type.ServiceDescription;
-
-public interface Registry {
- /**
- * Find locations where the service is deployed
- *
- * @param serviceName
- * @return List of HostDescription having the service
- */
- public List<HostDescription> getServiceLocation(String serviceName);
-
- /**
- * Retrieve a service description i.e. name, description, parameters
- *
- * @param serviceName
- * @return a service description or null if a description is not found
- */
- public ServiceDescription getServiceDescription(String serviceName);
/**
- * Retrieve a deployment description for a service from the specific host
+ * Deploy a service on a host
*
* @param serviceName
* @param hostName
- * @return a deployment description or null if a description is not found
- */
- public ApplicationDeploymentDescription getDeploymentDescription(String serviceName, String hostName);
-
- /**
- * Retrieve a host description
- *
- * @param name
- * @return a host description or null if a description is not found
+ * @return true if service can be deploy on the hsot, otherwise false
*/
- public HostDescription getHostDescription(String name);
-
- /**
- * Save a host description with the specific name.
- *
- * @param name
- * @param host
- * @return identifier
- */
- public String saveHostDescription(String name, HostDescription host);
-
- /**
- * Save a service description with the specific name.
- *
- * @param service
- * @param host
- * @return identifier
- */
- public String saveServiceDescription(String name, ServiceDescription service);
-
- /**
- * Save a deployment description according to the service and host
- *
- * @param service
- * @param host
- * @param app
- * @return identifier
- */
- public String saveDeploymentDescription(String service, String host, ApplicationDeploymentDescription app);
+ public boolean deployServiceOnHost(String serviceName, String hostName);
/**
* Search host description with name
Modified: incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/core/gfac/api/impl/JCRRegistry.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/core/gfac/api/impl/JCRRegistry.java?rev=1156811&r1=1156810&r2=1156811&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/core/gfac/api/impl/JCRRegistry.java (original)
+++ incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/core/gfac/api/impl/JCRRegistry.java Thu Aug 11 20:33:38 2011
@@ -36,6 +36,7 @@ import javax.jcr.RepositoryException;
import javax.jcr.RepositoryFactory;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
+import javax.jcr.Value;
import org.apache.airavata.core.gfac.api.Registry;
import org.apache.airavata.core.gfac.type.ApplicationDeploymentDescription;
@@ -50,15 +51,12 @@ public class JCRRegistry implements Regi
private static final String SERVICE_NODE_NAME = "SERVICE_HOST";
private static final String DEPLOY_NODE_NAME = "APP_HOST";
private static final String HOST_NODE_NAME = "GFAC_HOST";
- private static final String XML_PROPERTY_NAME = "XML";
+ private static final String XML_PROPERTY_NAME = "XML";
+ private static final String LINK_NAME = "LINK";
private Repository repository;
private Credentials credentials;
- private Node serviceNode;
- private Node appNode;
- private Node hostNode;
-
private static Log log = LogFactory.getLog(JCRRegistry.class);
public JCRRegistry(String className, String user, String pass,
@@ -74,8 +72,6 @@ public class JCRRegistry implements Regi
.newInstance();
repository = repositoryFactory.getRepository(map);
- if (repository == null)
- System.exit(1);
credentials = new SimpleCredentials(user,
new String(pass).toCharArray());
@@ -93,25 +89,15 @@ public class JCRRegistry implements Regi
}
private Node getServiceNode(Session session) throws RepositoryException {
- if (this.serviceNode == null) {
- this.serviceNode = getOrAddNode(session.getRootNode(),
- SERVICE_NODE_NAME);
- }
- return this.serviceNode;
+ return getOrAddNode(session.getRootNode(), SERVICE_NODE_NAME);
}
private Node getDeploymentNode(Session session) throws RepositoryException {
- if (this.appNode == null) {
- this.appNode = getOrAddNode(session.getRootNode(), DEPLOY_NODE_NAME);
- }
- return this.appNode;
+ return getOrAddNode(session.getRootNode(), DEPLOY_NODE_NAME);
}
private Node getHostNode(Session session) throws RepositoryException {
- if (this.hostNode == null) {
- this.hostNode = getOrAddNode(session.getRootNode(), HOST_NODE_NAME);
- }
- return this.hostNode;
+ return getOrAddNode(session.getRootNode(), HOST_NODE_NAME);
}
private Node getOrAddNode(Node node, String name)
@@ -119,7 +105,7 @@ public class JCRRegistry implements Regi
Node node1 = null;
try {
node1 = node.getNode(name);
- }catch(PathNotFoundException pnfe){
+ } catch (PathNotFoundException pnfe) {
node1 = node.addNode(name);
} catch (RepositoryException e) {
String msg = "failed to resolve the path of the given node ";
@@ -135,19 +121,23 @@ public class JCRRegistry implements Regi
try {
session = getSession();
Node node = getServiceNode(session);
- NodeIterator nodes = node.getNodes();
- for (; nodes.hasNext();) {
- Node host = nodes.nextNode();
- Property prop = host.getProperty(XML_PROPERTY_NAME);
- result.add((HostDescription) SchemaUtil.parseFromXML(prop
- .getString()));
+ Node serviceNode = node.getNode(serviceName);
+ if (serviceNode.hasProperty(LINK_NAME)) {
+ Property prop = serviceNode.getProperty(LINK_NAME);
+ Value[] vals = prop.getValues();
+ for (Value val : vals) {
+ Node host = session.getNodeByIdentifier(val.getString());
+ Property hostProp = host.getProperty(XML_PROPERTY_NAME);
+ result.add((HostDescription) SchemaUtil
+ .parseFromXML(hostProp.getString()));
+ }
}
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
// TODO propagate
} finally {
- if (session != null) {
+ if (session != null && session.isLive()) {
session.logout();
}
}
@@ -169,7 +159,7 @@ public class JCRRegistry implements Regi
e.printStackTrace();
// TODO propagate
} finally {
- if (session != null) {
+ if (session != null && session.isLive()) {
session.logout();
}
}
@@ -197,7 +187,7 @@ public class JCRRegistry implements Regi
e.printStackTrace();
// TODO propagate
} finally {
- if (session != null) {
+ if (session != null && session.isLive()) {
session.logout();
}
}
@@ -219,7 +209,7 @@ public class JCRRegistry implements Regi
e.printStackTrace();
// TODO propagate
} finally {
- if (session != null) {
+ if (session != null && session.isLive()) {
session.logout();
}
}
@@ -233,8 +223,7 @@ public class JCRRegistry implements Regi
session = getSession();
Node hostNode = getHostNode(session);
Node node = getOrAddNode(hostNode, name);
- Property prop = node.setProperty(XML_PROPERTY_NAME,
- SchemaUtil.toXML(host));
+ node.setProperty(XML_PROPERTY_NAME, SchemaUtil.toXML(host));
session.save();
result = node.getIdentifier();
@@ -242,6 +231,10 @@ public class JCRRegistry implements Regi
System.out.println(e);
e.printStackTrace();
// TODO propagate
+ } finally {
+ if (session != null && session.isLive()) {
+ session.logout();
+ }
}
return result;
}
@@ -253,8 +246,7 @@ public class JCRRegistry implements Regi
session = getSession();
Node serviceNode = getServiceNode(session);
Node node = getOrAddNode(serviceNode, name);
- Property prop = node.setProperty(XML_PROPERTY_NAME,
- SchemaUtil.toXML(service));
+ node.setProperty(XML_PROPERTY_NAME, SchemaUtil.toXML(service));
session.save();
result = node.getIdentifier();
@@ -262,6 +254,10 @@ public class JCRRegistry implements Regi
System.out.println(e);
e.printStackTrace();
// TODO propagate
+ } finally {
+ if (session != null && session.isLive()) {
+ session.logout();
+ }
}
return result;
}
@@ -276,8 +272,7 @@ public class JCRRegistry implements Regi
Node serviceNode = getOrAddNode(deployNode, service);
Node hostNode = getOrAddNode(serviceNode, host);
Node appName = getOrAddNode(hostNode, app.getName());
- Property prop = appName.setProperty(XML_PROPERTY_NAME,
- SchemaUtil.toXML(app));
+ appName.setProperty(XML_PROPERTY_NAME, SchemaUtil.toXML(app));
session.save();
result = appName.getIdentifier();
@@ -285,314 +280,55 @@ public class JCRRegistry implements Regi
System.out.println(e);
e.printStackTrace();
// TODO propagate
- }
- return result;
- }
-
- public List<HostDescription> searchHostDescription(String name) {
- // TODO implementation
- return null;
- }
-
- public List<ServiceDescription> searchServiceDescription(String name) {
- // TODO implementation
- return null;
- }
-
- public List<ApplicationDeploymentDescription> searchDeploymentDescription(String serviceName, String hostName) {
- // TODO implementation
- return null;
- }
-}
-/*
- *
- * 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.api.impl;
-
-import java.lang.reflect.Constructor;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
-
-import org.apache.airavata.core.gfac.api.Registry;
-import org.apache.airavata.core.gfac.type.ApplicationDeploymentDescription;
-import org.apache.airavata.core.gfac.type.HostDescription;
-import org.apache.airavata.core.gfac.type.ServiceDescription;
-import org.apache.airavata.core.gfac.type.util.SchemaUtil;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class JCRRegistry implements Registry {
-
- private static final String SERVICE_NODE_NAME = "SERVICE_HOST";
- private static final String DEPLOY_NODE_NAME = "APP_HOST";
- private static final String HOST_NODE_NAME = "GFAC_HOST";
- private static final String XML_PROPERTY_NAME = "XML";
-
- private Repository repository;
- private Credentials credentials;
-
- private Node serviceNode;
- private Node appNode;
- private Node hostNode;
-
- private static Log log = LogFactory.getLog(JCRRegistry.class);
-
- public JCRRegistry(String className, String user, String pass,
- Map<String, String> map) {
- try {
- /*
- * Load the configuration from properties file at this level and
- * create the object
- */
- Class registryRepositoryFactory = Class.forName(className);
- Constructor c = registryRepositoryFactory.getConstructor();
- RepositoryFactory repositoryFactory = (RepositoryFactory) c
- .newInstance();
-
- repository = repositoryFactory.getRepository(map);
- if (repository == null)
- System.exit(1);
- credentials = new SimpleCredentials(user,
- new String(pass).toCharArray());
-
- } catch (ClassNotFoundException e) {
- log.error("Error class path settting", e);
- } catch (RepositoryException e) {
- log.error("Error connecting Remote Registry instance", e);
- } catch (Exception e) {
- log.error("Error init", e);
- }
- }
-
- private Session getSession() throws RepositoryException {
- return repository.login(credentials);
- }
-
- private Node getServiceNode(Session session) throws RepositoryException {
- if (this.serviceNode == null) {
- this.serviceNode = getOrAddNode(session.getRootNode(),
- SERVICE_NODE_NAME);
- }
- return this.serviceNode;
- }
-
- private Node getDeploymentNode(Session session) throws RepositoryException {
- if (this.appNode == null) {
- this.appNode = getOrAddNode(session.getRootNode(), DEPLOY_NODE_NAME);
- }
- return this.appNode;
- }
-
- private Node getHostNode(Session session) throws RepositoryException {
- if (this.hostNode == null) {
- this.hostNode = getOrAddNode(session.getRootNode(), HOST_NODE_NAME);
- }
- return this.hostNode;
- }
-
- private Node getOrAddNode(Node node, String name)
- throws RepositoryException {
- Node node1 = null;
- try {
- node1 = node.getNode(name);
- }catch(PathNotFoundException pnfe){
- node1 = node.addNode(name);
- } catch (RepositoryException e) {
- String msg = "failed to resolve the path of the given node ";
- log.debug(msg);
- throw new RepositoryException(msg, e);
- }
- return node1;
- }
-
- public List<HostDescription> getServiceLocation(String serviceName) {
- Session session = null;
- ArrayList<HostDescription> result = new ArrayList<HostDescription>();
- try {
- session = getSession();
- Node node = getServiceNode(session);
- NodeIterator nodes = node.getNodes();
- for (; nodes.hasNext();) {
- Node host = nodes.nextNode();
- Property prop = host.getProperty(XML_PROPERTY_NAME);
- result.add((HostDescription) SchemaUtil.parseFromXML(prop
- .getString()));
- }
- } catch (Exception e) {
- System.out.println(e);
- e.printStackTrace();
- // TODO propagate
} finally {
- if (session != null) {
+ if (session != null && session.isLive()) {
session.logout();
}
}
return result;
}
- public ServiceDescription getServiceDescription(String serviceName) {
+ public boolean deployServiceOnHost(String serviceName, String hostName) {
Session session = null;
- ServiceDescription result = null;
try {
session = getSession();
- Node serviceNode = getServiceNode(session);
- Node node = serviceNode.getNode(serviceName);
- Property prop = node.getProperty(XML_PROPERTY_NAME);
- result = (ServiceDescription) SchemaUtil.parseFromXML(prop
- .getString());
- } catch (Exception e) {
- System.out.println(e);
- e.printStackTrace();
- // TODO propagate
- } finally {
- if (session != null) {
- session.logout();
- }
- }
- return result;
- }
+ Node serviceRoot = getServiceNode(session);
+ Node hostRoot = getHostNode(session);
- public ApplicationDeploymentDescription getDeploymentDescription(
- String serviceName, String host) {
- Session session = null;
- ApplicationDeploymentDescription result = null;
- try {
- session = getSession();
- Node deploymentNode = getDeploymentNode(session);
- Node serviceNode = deploymentNode.getNode(serviceName);
- Node hostNode = serviceNode.getNode(host);
- NodeIterator nodes = hostNode.getNodes();
- for (; nodes.hasNext();) {
- Node app = nodes.nextNode();
- Property prop = app.getProperty(XML_PROPERTY_NAME);
- result = (ApplicationDeploymentDescription) SchemaUtil
- .parseFromXML(prop.getString());
+ Node serviceNode = serviceRoot.getNode(serviceName);
+ Node hostNode = hostRoot.getNode(hostName);
+
+ if (!serviceNode.hasProperty(LINK_NAME)) {
+ serviceNode.setProperty(LINK_NAME,
+ new String[] { hostNode.getIdentifier() });
+ } else {
+ Property prop = serviceNode.getProperty(LINK_NAME);
+ Value[] vals = prop.getValues();
+ ArrayList<String> s = new ArrayList<String>();
+ for (Value val : vals) {
+ s.add(val.getString());
+ }
+
+ if (s.contains(hostNode.getIdentifier())) {
+ return false;
+ }
+
+ s.add(hostNode.getIdentifier());
+ serviceNode.setProperty(LINK_NAME, s.toArray(new String[0]));
}
+
+ session.save();
+ return true;
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
// TODO propagate
} finally {
- if (session != null) {
- session.logout();
- }
- }
- return result;
- }
-
- public HostDescription getHostDescription(String name) {
- Session session = null;
- HostDescription result = null;
- try {
- session = getSession();
- Node hostNode = getHostNode(session);
- Node node = hostNode.getNode(name);
- Property prop = node.getProperty(XML_PROPERTY_NAME);
- result = (HostDescription) SchemaUtil
- .parseFromXML(prop.getString());
- } catch (Exception e) {
- System.out.println(e);
- e.printStackTrace();
- // TODO propagate
- } finally {
- if (session != null) {
+ if (session != null && session.isLive()) {
session.logout();
}
}
- return result;
- }
-
- public String saveHostDescription(String name, HostDescription host) {
- Session session = null;
- String result = null;
- try {
- session = getSession();
- Node hostNode = getHostNode(session);
- Node node = getOrAddNode(hostNode, name);
- Property prop = node.setProperty(XML_PROPERTY_NAME,
- SchemaUtil.toXML(host));
- session.save();
-
- result = node.getIdentifier();
- } catch (Exception e) {
- System.out.println(e);
- e.printStackTrace();
- // TODO propagate
- }
- return result;
- }
-
- public String saveServiceDescription(String name, ServiceDescription service) {
- Session session = null;
- String result = null;
- try {
- session = getSession();
- Node serviceNode = getServiceNode(session);
- Node node = getOrAddNode(serviceNode, name);
- Property prop = node.setProperty(XML_PROPERTY_NAME,
- SchemaUtil.toXML(service));
- session.save();
-
- result = node.getIdentifier();
- } catch (Exception e) {
- System.out.println(e);
- e.printStackTrace();
- // TODO propagate
- }
- return result;
- }
-
- public String saveDeploymentDescription(String service, String host,
- ApplicationDeploymentDescription app) {
- Session session = null;
- String result = null;
- try {
- session = getSession();
- Node deployNode = getDeploymentNode(session);
- Node serviceNode = getOrAddNode(deployNode, service);
- Node hostNode = getOrAddNode(serviceNode, host);
- Node appName = getOrAddNode(hostNode, app.getName());
- Property prop = appName.setProperty(XML_PROPERTY_NAME,
- SchemaUtil.toXML(app));
- session.save();
-
- result = appName.getIdentifier();
- } catch (Exception e) {
- System.out.println(e);
- e.printStackTrace();
- // TODO propagate
- }
- return result;
+ return false;
}
public List<HostDescription> searchHostDescription(String name) {
@@ -605,7 +341,8 @@ public class JCRRegistry implements Regi
return null;
}
- public List<ApplicationDeploymentDescription> searchDeploymentDescription(String serviceName, String hostName) {
+ public List<ApplicationDeploymentDescription> searchDeploymentDescription(
+ String serviceName, String hostName) {
// TODO implementation
return null;
}
Modified: incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/core/gfac/type/util/SchemaUtil.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/core/gfac/type/util/SchemaUtil.java?rev=1156811&r1=1156810&r2=1156811&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/core/gfac/type/util/SchemaUtil.java (original)
+++ incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/core/gfac/type/util/SchemaUtil.java Thu Aug 11 20:33:38 2011
@@ -45,50 +45,3 @@ public class SchemaUtil {
return x.toString();
}
}
-/*
- *
- * 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.type.util;
-
-import java.beans.XMLDecoder;
-import java.beans.XMLEncoder;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-
-import org.apache.airavata.core.gfac.type.Type;
-
-public class SchemaUtil {
- public static Type parseFromXML(String xml) {
- ByteArrayInputStream bs = new ByteArrayInputStream(xml.getBytes());
- XMLDecoder d = new XMLDecoder(bs);
- Object result = d.readObject();
- d.close();
- return (Type) result;
- }
-
- public static String toXML(Type type) {
- ByteArrayOutputStream x = new ByteArrayOutputStream();
- XMLEncoder e = new XMLEncoder(x);
- e.writeObject(type);
- e.close();
- return x.toString();
- }
-}
Modified: incubator/airavata/trunk/modules/gfac-core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/pom.xml?rev=1156811&r1=1156810&r2=1156811&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/pom.xml (original)
+++ incubator/airavata/trunk/modules/gfac-core/pom.xml Thu Aug 11 20:33:38 2011
@@ -33,8 +33,8 @@
</snapshots>
</repository>
</repositories>
-
- <dependencies>
+
+ <dependencies>
<dependency>
<groupId>cog-jglobus</groupId>
<artifactId>cog-jglobus</artifactId>
@@ -61,8 +61,14 @@
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
+
<!-- Logging -->
<dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${org.slf4j.version}</version>
@@ -85,11 +91,7 @@
<version>${log4j.version}</version>
<scope>runtime</scope>
</dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.0.4</version>
- </dependency>
+
<!-- GFAC schemas -->
<dependency>
<groupId>gfac</groupId>
@@ -101,7 +103,7 @@
<artifactId>airavata-gfac-schema-utils</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
-
+
<!-- Workflow Tracking -->
<dependency>
<groupId>workflow-tracking</groupId>
@@ -120,7 +122,7 @@
<artifactId>workflow-context-header</artifactId>
<version>1.0</version>
</dependency>
-
+
<!-- Xregistry jars -->
<dependency>
<groupId>xregistry</groupId>
@@ -153,6 +155,18 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-core</artifactId>
+ <version>2.2.7</version>
+ <scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-jcr-rmi</artifactId>
+ <version>2.2.7</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/ExecutionContext.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/ExecutionContext.java?rev=1156811&r1=1156810&r2=1156811&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/ExecutionContext.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/ExecutionContext.java Thu Aug 11 20:33:38 2011
@@ -21,9 +21,9 @@
package org.apache.airavata.core.gfac.context;
+import org.apache.airavata.core.gfac.api.Registry;
import org.apache.airavata.core.gfac.model.ExecutionModel;
import org.apache.airavata.core.gfac.notification.NotificationService;
-import org.apache.airavata.core.gfac.registry.RegistryService;
import org.ogce.namespaces.x2010.x08.x30.workflowContextHeader.WorkflowContextHeaderDocument.WorkflowContextHeader;
public interface ExecutionContext {
@@ -48,7 +48,7 @@ public interface ExecutionContext {
void setServiceContext(ServiceContext context);
- RegistryService getRegistryService();
+ Registry getRegistryService();
- void setRegistryService(RegistryService registryService);
+ void setRegistryService(Registry registryService);
}
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/impl/ExecutionContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/impl/ExecutionContextImpl.java?rev=1156811&r1=1156810&r2=1156811&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/impl/ExecutionContextImpl.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/impl/ExecutionContextImpl.java Thu Aug 11 20:33:38 2011
@@ -21,12 +21,12 @@
package org.apache.airavata.core.gfac.context.impl;
+import org.apache.airavata.core.gfac.api.Registry;
import org.apache.airavata.core.gfac.context.ExecutionContext;
import org.apache.airavata.core.gfac.context.SecurityContext;
import org.apache.airavata.core.gfac.context.ServiceContext;
import org.apache.airavata.core.gfac.model.ExecutionModel;
import org.apache.airavata.core.gfac.notification.NotificationService;
-import org.apache.airavata.core.gfac.registry.RegistryService;
import org.ogce.namespaces.x2010.x08.x30.workflowContextHeader.WorkflowContextHeaderDocument.WorkflowContextHeader;
public class ExecutionContextImpl implements ExecutionContext {
@@ -34,7 +34,7 @@ public class ExecutionContextImpl implem
private ExecutionModel executionModel;
private WorkflowContextHeader workflowContextHeader;
private NotificationService notificationService;
- private RegistryService registryService;
+ private Registry registryService;
private SecurityContext securityContext;
public ExecutionModel getExecutionModel() {
@@ -81,11 +81,11 @@ public class ExecutionContextImpl implem
}
- public RegistryService getRegistryService() {
+ public Registry getRegistryService() {
return this.registryService;
}
- public void setRegistryService(RegistryService registryService) {
+ public void setRegistryService(Registry registryService) {
this.registryService = registryService;
}
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/data/RegistryDataService.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/data/RegistryDataService.java?rev=1156811&r1=1156810&r2=1156811&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/data/RegistryDataService.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/extension/data/RegistryDataService.java Thu Aug 11 20:33:38 2011
@@ -22,174 +22,84 @@
package org.apache.airavata.core.gfac.extension.data;
import java.io.File;
-import java.util.ArrayList;
import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
import java.util.UUID;
-import javax.xml.namespace.QName;
-
import org.apache.airavata.core.gfac.context.InvocationContext;
-import org.apache.airavata.core.gfac.context.impl.ParameterContextImpl;
import org.apache.airavata.core.gfac.exception.GfacException;
import org.apache.airavata.core.gfac.exception.GfacException.FaultCode;
import org.apache.airavata.core.gfac.extension.DataServiceChain;
-import org.apache.airavata.core.gfac.model.ExecutionModel;
-import org.apache.airavata.core.gfac.registry.RegistryService;
-import org.apache.airavata.core.gfac.type.parameter.StringParameter;
-import org.apache.airavata.core.gfac.utils.GfacUtils;
-import org.apache.xmlbeans.XmlException;
-import org.ogce.schemas.gfac.documents.ApplicationDescriptionDocument;
-import org.ogce.schemas.gfac.documents.ApplicationDescriptionType;
-import org.ogce.schemas.gfac.documents.DeploymentDescriptionType;
-import org.ogce.schemas.gfac.documents.GlobusGatekeeperType;
-import org.ogce.schemas.gfac.documents.HostDescriptionDocument;
-import org.ogce.schemas.gfac.documents.HostDescriptionType;
-import org.ogce.schemas.gfac.documents.NameValuePairType;
-import org.ogce.schemas.gfac.documents.OutputParameterType;
-import org.ogce.schemas.gfac.documents.ServiceMapDocument;
-import org.ogce.schemas.gfac.documents.ServiceMapType;
+import org.apache.airavata.core.gfac.type.ApplicationDeploymentDescription;
+import org.apache.airavata.core.gfac.type.HostDescription;
+import org.apache.airavata.core.gfac.type.ServiceDescription;
+import org.apache.airavata.core.gfac.type.app.ShellApplicationDeployment;
public class RegistryDataService extends DataServiceChain {
- private static final String INPUT_MESSAGE_CONTEXT = "input";
- private static final String OUTPUT_MESSAGE_CONTEXT = "output";
-
- public boolean execute(InvocationContext context) throws GfacException {
+ public boolean execute(InvocationContext context) throws GfacException {
- /*
- * Load host and app description from registry
- */
- RegistryService registryService = context.getExecutionContext().getRegistryService();
- String serviceMapStr = registryService.getServiceMap(context.getServiceName());
- System.out.println(serviceMapStr);
- if (serviceMapStr != null) {
- try {
-
- ServiceMapType serviceMap = ServiceMapDocument.Factory.parse(serviceMapStr).getServiceMap();
- QName appName = GfacUtils.findApplcationName(serviceMap);
-
- // host name
- String hostName = findHostFromServiceMap(registryService, appName);
-
- // app
- String appDesc = registryService.getAppDesc(appName.toString(), hostName);
- ApplicationDescriptionType appDescType = ApplicationDescriptionDocument.Factory.parse(appDesc)
- .getApplicationDescription();
-
- // host desc
- String hostDesc = registryService.getHostDesc(hostName);
- HostDescriptionType hostDescType = HostDescriptionDocument.Factory.parse(hostDesc).getHostDescription();
-
- // application deployment
- DeploymentDescriptionType deploymentDesc = appDescType.getDeploymentDescription();
- String tmpDir = deploymentDesc.getTmpDir();
- if (tmpDir == null && hostDescType != null) {
- tmpDir = hostDescType.getHostConfiguration().getTmpDir();
- }
-
- if (tmpDir == null) {
- tmpDir = "/tmp";
- }
-
- String date = new Date().toString();
- date = date.replaceAll(" ", "_");
- date = date.replaceAll(":", "_");
-
- tmpDir = tmpDir + File.separator + appDescType.getApplicationName().getStringValue() + "_" + date + "_"
- + UUID.randomUUID();
-
- String workingDir = deploymentDesc.getWorkDir();
- if (workingDir == null || workingDir.trim().length() == 0) {
- workingDir = tmpDir;
- }
-
- String stdOut = tmpDir + File.separator + appDescType.getApplicationName().getStringValue() + ".stdout";
- String stderr = tmpDir + File.separator + appDescType.getApplicationName().getStringValue() + ".stderr";
- String executable = deploymentDesc.getExecutable();
- String host = deploymentDesc.getHostName();
-
- NameValuePairType[] env = deploymentDesc.getApplicationEnvArray();
- Map<String, String> envMap = new HashMap<String, String>();
- if (env != null) {
- for (int i = 0; i < env.length; i++) {
- envMap.put(env[i].getName(), env[i].getValue());
- }
- }
-
- String inputDataDir = tmpDir + File.separator + "inputData";
- String outputDataDir = tmpDir + File.separator + "outputData";
-
- GlobusGatekeeperType[] gatekeepers = hostDescType.getHostConfiguration().getGlobusGatekeeperArray();
-
- ExecutionModel model = new ExecutionModel();
- model.setHost(host);
- model.setExecutable(executable);
- model.setTmpDir(tmpDir);
- model.setWorkingDir(workingDir);
- model.setStdOut(stdOut);
- model.setStderr(stderr);
- model.setInputDataDir(inputDataDir);
- model.setOutputDataDir(outputDataDir);
- model.setEnv(envMap);
- model.setAplicationDesc(appDescType);
- model.setHostDesc(hostDescType);
- model.setGatekeeper(gatekeepers[0]);
-
- // input parameter
- ArrayList<String> tmp = new ArrayList<String>();
- for (Iterator<String> iterator = context.getMessageContext(INPUT_MESSAGE_CONTEXT).getParameterNames(); iterator
- .hasNext();) {
- String key = iterator.next();
- tmp.add(context.getMessageContext(INPUT_MESSAGE_CONTEXT).getStringParameterValue(key));
- }
- model.setInputParameters(tmp);
-
- context.getExecutionContext().setExectionModel(model);
-
- // output parameter
- // TODO type mapping
- if (serviceMap.getPortTypeArray(0).getMethodArray(0).getOutputParameterArray() != null) {
- ParameterContextImpl outtmp = new ParameterContextImpl();
- for (OutputParameterType output : serviceMap.getPortTypeArray(0).getMethodArray(0)
- .getOutputParameterArray()) {
- outtmp.addParameter(output.getParameterName(), new StringParameter());
- }
- context.addMessageContext(OUTPUT_MESSAGE_CONTEXT, outtmp);
- }
-
- } catch (XmlException e) {
- throw new GfacException(e, FaultCode.InitalizationError);
- }
- } else {
- throw new GfacException("Service Map for " + context.getServiceName()
- + " does not found on resource Catalog " + registryService, FaultCode.InvalidRequest);
- }
-
- return false;
- }
-
- private String findHostFromServiceMap(RegistryService regService, QName appName) throws GfacException {
-
- System.out.println("Searching registry for some deployed application hosts\n");
- String[] hosts = regService.app2Hosts(appName.toString());
- if (hosts.length > 1) {
- String hostNames = "";
- for (int i = 0; i < hosts.length; i++) {
- hostNames = hostNames + hosts[i];
- }
- System.out.println("Application deployed on more than one machine. The full Host list is " + hostNames
- + "\n");
- }
- if (hosts.length >= 1) {
- System.out.println("Found Host = " + hosts[0]);
- return hosts[0];
- } else {
- System.out.println("Applcation " + appName.getLocalPart() + " not found in registry");
- return null;
- }
- }
+ ServiceDescription serviceDesc = context.getGfacContext().getService();
+ HostDescription hostDesc = context.getGfacContext().getHost();
+ ApplicationDeploymentDescription appDesc = context.getGfacContext()
+ .getApp();
+ if (serviceDesc != null && hostDesc != null && appDesc != null) {
+ /*
+ * if there is no setting in deployment description, use from host
+ */
+ if (appDesc.getTmpDir() == null) {
+ appDesc.setTmpDir("/tmp");
+ }
+
+ /*
+ * Working dir
+ */
+ if (appDesc.getWorkingDir() == null) {
+ String date = new Date().toString();
+ date = date.replaceAll(" ", "_");
+ date = date.replaceAll(":", "_");
+
+ String tmpDir = appDesc.getTmpDir() + File.separator
+ + appDesc.getName() + "_" + date + "_"
+ + UUID.randomUUID();
+
+ appDesc.setWorkingDir(tmpDir);
+ }
+
+ /*
+ * Input and Output Dir
+ */
+ if (appDesc.getInputDir() == null) {
+ appDesc.setInputDir(appDesc.getWorkingDir() + File.separator
+ + "inputData");
+ }
+ if (appDesc.getOutputDir() == null) {
+ appDesc.setInputDir(appDesc.getWorkingDir() + File.separator
+ + "outputData");
+ }
+
+ /*
+ * Stdout and Stderr for Shell
+ */
+ if(appDesc.getClass().isAssignableFrom(ShellApplicationDeployment.class)){
+ ShellApplicationDeployment shell = (ShellApplicationDeployment)appDesc;
+ if(shell.getStdOut() == null){
+ shell.setStdOut(appDesc.getWorkingDir() + File.separator
+ + appDesc.getName() + ".stdout");
+ }
+ if(shell.getStdErr() == null){
+ shell.setStdOut(appDesc.getWorkingDir() + File.separator
+ + appDesc.getName() + ".stderr");
+ }
+ }
+
+ } else {
+ throw new GfacException("Service Map for "
+ + context.getServiceName()
+ + " does not found on resource Catalog "
+ + context.getExecutionContext().getRegistryService(),
+ FaultCode.InvalidRequest);
+ }
+ return false;
+ }
}
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/impl/SchedulerImpl.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/impl/SchedulerImpl.java?rev=1156811&r1=1156810&r2=1156811&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/impl/SchedulerImpl.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/impl/SchedulerImpl.java Thu Aug 11 20:33:38 2011
@@ -21,86 +21,109 @@
package org.apache.airavata.core.gfac.scheduler.impl;
-import javax.xml.namespace.QName;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.airavata.core.gfac.api.Registry;
+import org.apache.airavata.core.gfac.context.GFACContext;
import org.apache.airavata.core.gfac.context.InvocationContext;
import org.apache.airavata.core.gfac.exception.GfacException;
import org.apache.airavata.core.gfac.exception.GfacException.FaultCode;
import org.apache.airavata.core.gfac.provider.GramProvider;
import org.apache.airavata.core.gfac.provider.LocalProvider;
import org.apache.airavata.core.gfac.provider.Provider;
-import org.apache.airavata.core.gfac.registry.RegistryService;
import org.apache.airavata.core.gfac.scheduler.Scheduler;
+import org.apache.airavata.core.gfac.type.ApplicationDeploymentDescription;
+import org.apache.airavata.core.gfac.type.HostDescription;
+import org.apache.airavata.core.gfac.type.ServiceDescription;
import org.apache.airavata.core.gfac.utils.GfacUtils;
-import org.apache.xmlbeans.XmlException;
-import org.ogce.schemas.gfac.documents.ServiceMapDocument;
-import org.ogce.schemas.gfac.documents.ServiceMapType;
public class SchedulerImpl implements Scheduler {
- public Provider schedule(InvocationContext context) throws GfacException {
+ public Provider schedule(InvocationContext context) throws GfacException {
- String hostName = null;
+ Registry registryService = context.getExecutionContext()
+ .getRegistryService();
- /*
- * Load host and app description from registry
- */
- RegistryService registryService = context.getExecutionContext().getRegistryService();
- String serviceMapStr = registryService.getServiceMap(context.getServiceName());
-
- if (serviceMapStr != null) {
- try {
-
- ServiceMapType serviceMap = ServiceMapDocument.Factory.parse(serviceMapStr).getServiceMap();
- QName appName = GfacUtils.findApplcationName(serviceMap);
-
- // host name
- hostName = findHostFromServiceMap(registryService, appName);
-
- } catch (XmlException e) {
- throw new GfacException(e, FaultCode.InitalizationError);
- }
- } else {
- throw new GfacException("Service Map for " + context.getServiceName()
- + " does not found on resource Catalog " + registryService, FaultCode.InvalidRequest);
- }
-
- /*
- * Determine provider
- */
- if (GfacUtils.isLocalHost(hostName)) {
- return new LocalProvider();
- } else {
- // set Security context for executionContext
- if (context.getSecurityContext(GramProvider.MYPROXY_SECURITY_CONTEXT) != null) {
- context.getExecutionContext().setSecurityContext(
- context.getSecurityContext(GramProvider.MYPROXY_SECURITY_CONTEXT));
- } else {
- throw new GfacException("Cannot get security context to run on Gram", FaultCode.InvalidRequest);
- }
-
- return new GramProvider();
- }
- }
-
- private String findHostFromServiceMap(RegistryService regService, QName appName) throws GfacException {
-
- System.out.println("Searching registry for some deployed application hosts\n");
- String[] hosts = regService.app2Hosts(appName.toString());
- if (hosts.length > 1) {
- String hostNames = "";
- for (int i = 0; i < hosts.length; i++) {
- hostNames = hostNames + hosts[i];
- }
- System.out.println("Application deployed on more than one machine. The full Host list is " + hostNames
- + "\n");
- }
- if (hosts.length >= 1) {
- System.out.println("Found Host = " + hosts[0]);
- return hosts[0];
- } else {
- System.out.println("Applcation " + appName.getLocalPart() + " not found in registry");
- return null;
- }
- }
+ /*
+ * Load Service
+ */
+ ServiceDescription serviceDesc = registryService
+ .getServiceDescription(context.getServiceName());
+
+ if (serviceDesc == null)
+ throw new GfacException("Service Desciption for "
+ + context.getServiceName()
+ + " does not found on resource Catalog " + registryService,
+ FaultCode.InvalidRequest);
+
+ /*
+ * Load host
+ */
+ HostDescription host = scheduleToHost(registryService,
+ context.getServiceName());
+
+ if (host == null)
+ throw new GfacException("Host Desciption for "
+ + context.getServiceName()
+ + " does not found on resource Catalog " + registryService,
+ FaultCode.InvalidRequest);
+
+ /*
+ * Load app
+ */
+ ApplicationDeploymentDescription app = registryService
+ .getDeploymentDescription(context.getServiceName(),
+ host.getName());
+
+ if (app == null)
+ throw new GfacException("App Desciption for "
+ + context.getServiceName()
+ + " does not found on resource Catalog " + registryService,
+ FaultCode.InvalidRequest);
+
+ /*
+ * Binding
+ */
+
+ if (context.getGfacContext() == null) {
+ context.setGfacContext(new GFACContext());
+ }
+ context.getGfacContext().setHost(host);
+ context.getGfacContext().setService(serviceDesc);
+ context.getGfacContext().setApp(app);
+
+ /*
+ * Determine provider
+ */
+ String hostName = host.getName();
+ if (GfacUtils.isLocalHost(hostName)) {
+ return new LocalProvider();
+ } else {
+ return new GramProvider();
+ }
+
+ }
+
+ private HostDescription scheduleToHost(Registry regService,
+ String serviceName) {
+
+ System.out
+ .println("Searching registry for some deployed application hosts\n");
+ List<HostDescription> hosts = regService
+ .getServiceLocation(serviceName);
+ if (hosts != null && hosts.size() > 0) {
+ HostDescription result = null;
+ for (Iterator iterator = hosts.iterator(); iterator.hasNext();) {
+ result = (HostDescription) iterator.next();
+
+ System.out.println("Found service on: " + result.getName());
+ }
+ return result;
+ } else {
+ System.out.println("Applcation " + serviceName
+ + " not found in registry");
+ return null;
+ }
+ }
}
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImpl.java?rev=1156811&r1=1156810&r2=1156811&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImpl.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImpl.java Thu Aug 11 20:33:38 2011
@@ -23,8 +23,13 @@ package org.apache.airavata.core.gfac.se
import java.lang.reflect.Array;
import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Properties;
+import java.util.Set;
+import org.apache.airavata.core.gfac.api.Registry;
+import org.apache.airavata.core.gfac.api.impl.JCRRegistry;
import org.apache.airavata.core.gfac.context.InvocationContext;
import org.apache.airavata.core.gfac.exception.GfacException;
import org.apache.airavata.core.gfac.exception.GfacException.FaultCode;
@@ -32,8 +37,6 @@ import org.apache.airavata.core.gfac.ext
import org.apache.airavata.core.gfac.extension.ExitableChain;
import org.apache.airavata.core.gfac.extension.PostExecuteChain;
import org.apache.airavata.core.gfac.extension.PreExecuteChain;
-import org.apache.airavata.core.gfac.registry.RegistryService;
-import org.apache.airavata.core.gfac.registry.impl.XregistryServiceWrapper;
import org.apache.airavata.core.gfac.scheduler.Scheduler;
/**
@@ -44,13 +47,15 @@ import org.apache.airavata.core.gfac.sch
public class PropertiesBasedServiceImpl extends AbstractSimpleService {
private static final String FILENAME = "service.properties";
- public static final String REGISTY_URL_NAME = "registryURL";
- public static final String SSL_TRUSTED_CERTS_FILE = "ssl.trustedCertsFile";
- public static final String SSL_HOSTCERTS_KEY_FILE = "ssl.hostcertsKeyFile";
public static final String SCHEDULER_CLASS = "scheduler.class";
public static final String DATA_CHAIN_CLASS = "datachain.classes";
public static final String PRE_CHAIN_CLASS = "prechain.classes";
public static final String POST_CHAIN_CLASS = "postchain.classes";
+
+ /*
+ * JCR properties
+ */
+ public static final String JCR_CLASS = "jcr.class";
private Properties properties;
private Scheduler scheduler;
@@ -58,7 +63,7 @@ public class PropertiesBasedServiceImpl
private PostExecuteChain[] postChain;
private DataServiceChain[] dataChain;
- private RegistryService registryService;
+ private Registry registryService;
/*
* (non-Javadoc)
@@ -75,14 +80,26 @@ public class PropertiesBasedServiceImpl
this.properties = new Properties();
this.properties.load(url.openStream());
+
+ //JCR
+ String jcrClass = loadFromProperty(JCR_CLASS, true);
+
+ /*
+ * Remove unnecessary key
+ */
+ Map<String, String> map = new HashMap<String, String>((Map) this.properties);
+ map.remove(JCR_CLASS);
+ map.remove(SCHEDULER_CLASS);
+ map.remove(DATA_CHAIN_CLASS);
+ map.remove(PRE_CHAIN_CLASS);
+ map.remove(POST_CHAIN_CLASS);
+ if(map.size() == 0)
+ map = null;
- String registryURL = loadFromProperty(REGISTY_URL_NAME, true);
- String trustcerts = loadFromProperty(SSL_TRUSTED_CERTS_FILE, true);
- String hostcerts = loadFromProperty(SSL_HOSTCERTS_KEY_FILE, true);
-
- this.registryService = new XregistryServiceWrapper(registryURL, trustcerts, hostcerts);
+ this.registryService = new JCRRegistry(jcrClass, "admin", "admin", map);
} catch (Exception e) {
+ e.printStackTrace();
throw new GfacException("Error initialize the generic service", e);
}
}
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=1156811&r1=1156810&r2=1156811&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 Thu Aug 11 20:33:38 2011
@@ -19,9 +19,10 @@
#
#
-ssl.hostcertsKeyFile=/home/ptangcha/ogce-workspace/sgfac/target/dist-bin/conf/ogce_services_key.pem
-ssl.trustedCertsFile=/home/ptangcha/ogce-workspace/sgfac/target/dist-bin/certificates
-registryURL=https://ogceportal.iu.teragrid.org:19443/xregistry
+jcr.class=org.apache.jackrabbit.core.RepositoryFactoryImpl
+#jcr.class=org.apache.jackrabbit.rmi.repository.RmiRepositoryFactory
+#org.apache.jackrabbit.repository.uri=http://localhost:8080/rmi
+
scheduler.class= org.apache.airavata.core.gfac.scheduler.impl.SchedulerImpl
datachain.classes=org.apache.airavata.core.gfac.extension.data.RegistryDataService
#prechain.classes=
Modified: incubator/airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImplTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImplTest.java?rev=1156811&r1=1156810&r2=1156811&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImplTest.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImplTest.java Thu Aug 11 20:33:38 2011
@@ -23,82 +23,132 @@ package org.apache.airavata.core.gfac.se
import static org.junit.Assert.fail;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.airavata.core.gfac.api.impl.JCRRegistry;
import org.apache.airavata.core.gfac.context.InvocationContext;
import org.apache.airavata.core.gfac.context.impl.ExecutionContextImpl;
-import org.apache.airavata.core.gfac.context.impl.GSISecurityContext;
import org.apache.airavata.core.gfac.context.impl.ParameterContextImpl;
import org.apache.airavata.core.gfac.notification.DummyNotification;
+import org.apache.airavata.core.gfac.type.DataType;
+import org.apache.airavata.core.gfac.type.HostDescription;
+import org.apache.airavata.core.gfac.type.Parameter;
+import org.apache.airavata.core.gfac.type.ServiceDescription;
+import org.apache.airavata.core.gfac.type.app.ShellApplicationDeployment;
+import org.apache.airavata.core.gfac.type.parameter.AbstractParameter;
import org.apache.airavata.core.gfac.type.parameter.StringParameter;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
public class PropertiesBasedServiceImplTest {
-
- @Test
- public void testInit() {
- try {
- InvocationContext ct = new InvocationContext();
- ct.setExecutionContext(new ExecutionContextImpl());
-
- PropertiesBasedServiceImpl service = new PropertiesBasedServiceImpl();
- service.init();
- } catch (Exception e) {
- e.printStackTrace();
- fail("ERROR");
- }
- }
-
- @Test
- public void testExecute() {
- try {
- InvocationContext ct = new InvocationContext();
- ct.setExecutionContext(new ExecutionContextImpl());
-
- ct.getExecutionContext().setNotificationService(new DummyNotification());
-
- GSISecurityContext gsiSecurityContext = new GSISecurityContext();
- gsiSecurityContext.setMyproxyServer("myproxy.teragrid.org");
- gsiSecurityContext.setMyproxyUserName("ogce");
- gsiSecurityContext.setMyproxyPasswd("Jdas7wph");
- gsiSecurityContext.setMyproxyLifetime(14400);
- ct.addSecurityContext("myproxy", gsiSecurityContext);
-
- ct.setServiceName("{http://www.extreme.indiana.edu/namespaces/2004/01/gFac}Echo_Service");
-
- // parameter
- ParameterContextImpl x = new ParameterContextImpl();
- StringParameter parameter = new StringParameter();
- parameter.parseStringVal("Hello");
- x.addParameter("echo", parameter);
- ct.addMessageContext("input", x);
-
- PropertiesBasedServiceImpl service = new PropertiesBasedServiceImpl();
- service.init();
- service.execute(ct);
-
- Assert.assertNotNull(ct.getMessageContext("output"));
- Assert.assertNotNull(ct.getMessageContext("output").getParameterValue("Echoed_Output"));
- Assert.assertEquals("\"Hello\"", ct.getMessageContext("output").getParameterValue("Echoed_Output")
- .toString());
-
- } catch (Exception e) {
- e.printStackTrace();
- fail("ERROR");
- }
- }
-
- @Test
- public void testDispose() {
- try {
- InvocationContext ct = new InvocationContext();
- ct.setExecutionContext(new ExecutionContextImpl());
-
- PropertiesBasedServiceImpl service = new PropertiesBasedServiceImpl();
- service.dispose();
- } catch (Exception e) {
- e.printStackTrace();
- fail("ERROR");
- }
- }
-
+ @Before
+ public void setUp() throws Exception {
+ /*
+ * Create database
+ */
+ JCRRegistry jcrRegistry = new JCRRegistry(
+ "org.apache.jackrabbit.core.RepositoryFactoryImpl", "admin",
+ "admin", null);
+
+ /*
+ * Host
+ */
+ HostDescription host = new HostDescription();
+ host.setName("localhost");
+
+ /*
+ * App
+ */
+ ShellApplicationDeployment app = new ShellApplicationDeployment();
+ app.setName("EchoLocal");
+ app.setExecutable("/bin/echo");
+ app.setTmpDir("/tmp");
+ app.setWorkingDir("/tmp");
+ app.setInputDir("/tmp/input");
+ app.setOutputDir("/tmp/output");
+ app.setStdOut("/tmp/echo.stdout");
+ app.setStdErr("/tmp/echo.stdout");
+ app.setEnv(new HashMap<String, String>());
+
+ /*
+ * Service
+ */
+ ServiceDescription serv = new ServiceDescription();
+ serv.setName("SimpleEcho");
+
+ Parameter input = new Parameter();
+ input.setName("echo_input");
+ input.setType(DataType.String);
+ List<Parameter> inputList = new ArrayList<Parameter>();
+ inputList.add(input);
+
+ Parameter output = new Parameter();
+ output.setName("echo_output");
+ output.setType(DataType.String);
+ List<Parameter> outputList = new ArrayList<Parameter>();
+ outputList.add(output);
+
+ serv.setInputParameters(inputList);
+ serv.setOutputParameters(outputList);
+
+ /*
+ * Save to registry
+ */
+ jcrRegistry.saveHostDescription(host.getName(), host);
+ jcrRegistry.saveDeploymentDescription(serv.getName(), host.getName(),
+ app);
+ jcrRegistry.saveServiceDescription(serv.getName(), serv);
+ jcrRegistry.deployServiceOnHost(serv.getName(), host.getName());
+ }
+
+ @Test
+ public void testExecute() {
+ try {
+
+ InvocationContext ct = new InvocationContext();
+ ct.setExecutionContext(new ExecutionContextImpl());
+
+ ct.getExecutionContext().setNotificationService(
+ new DummyNotification());
+
+ ct.setServiceName("SimpleEcho");
+
+ /*
+ * Input
+ */
+ ParameterContextImpl input = new ParameterContextImpl();
+ StringParameter echo_input = new StringParameter();
+ echo_input.parseStringVal("echo_output=hello");
+ input.addParameter("echo_input", echo_input);
+
+ /*
+ * Output
+ */
+ ParameterContextImpl output = new ParameterContextImpl();
+ StringParameter echo_output = new StringParameter();
+ output.addParameter("echo_output", echo_output);
+
+ // parameter
+ ct.addMessageContext("input", input);
+ ct.addMessageContext("output", output);
+
+ PropertiesBasedServiceImpl service = new PropertiesBasedServiceImpl();
+ service.init();
+ service.execute(ct);
+
+ Assert.assertNotNull(ct.getMessageContext("output"));
+ Assert.assertNotNull(ct.getMessageContext("output")
+ .getParameterValue("echo_output"));
+ Assert.assertEquals("hello",
+ ((AbstractParameter) ct.getMessageContext("output")
+ .getParameterValue("echo_output")).toStringVal());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("ERROR");
+ }
+ }
}
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=1156811&r1=1156810&r2=1156811&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 Thu Aug 11 20:33:38 2011
@@ -19,9 +19,11 @@
#
#
-ssl.hostcertsKeyFile=/home/ptangcha/ogce-workspace/sgfac/target/dist-bin/conf/ogce_services_key.pem
-ssl.trustedCertsFile=/home/ptangcha/ogce-workspace/sgfac/target/dist-bin/certificates
-registryURL=https://ogceportal.iu.teragrid.org:19443/xregistry
+
+jcr.class=org.apache.jackrabbit.core.RepositoryFactoryImpl
+#jcr.class=org.apache.jackrabbit.rmi.repository.RmiRepositoryFactory
+#org.apache.jackrabbit.repository.uri=http://localhost:8080/rmi
+
scheduler.class= org.apache.airavata.core.gfac.scheduler.impl.SchedulerImpl
datachain.classes=org.apache.airavata.core.gfac.extension.data.RegistryDataService
#prechain.classes=