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/09/09 21:58:55 UTC
svn commit: r1167344 - in /incubator/airavata/trunk/modules:
gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/reciever/
gfac-core/src/main/java/org/apache/airavata/core/gfac/context/invocation/
gfac-core/src/main/java/org/apache/airavat...
Author: patanachai
Date: Fri Sep 9 19:58:54 2011
New Revision: 1167344
URL: http://svn.apache.org/viewvc?rev=1167344&view=rev
Log:
Change Notification Interface
Added:
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/Notifiable.java
- copied, changed from r1167241, incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/NotificationService.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/Notifier.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/Subject.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/DefaultNotifier.java
Modified:
incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/reciever/GFacMessageReciever.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/invocation/ExecutionContext.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/invocation/ExecutionDescription.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/invocation/InvocationContext.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/invocation/impl/DefaultExecutionContext.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/message/MessageContext.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/NotificationService.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/DummyNotification.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/LoggingNotification.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/StandardOutNotification.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/WorkflowTrackingNotification.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/AbstractProvider.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/EC2Provider.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/GramProvider.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/LocalProvider.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/SSHProvider.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/utils/GramRSLGenerator.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/utils/JobSubmissionListener.java
incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/AbstractSimpleService.java
incubator/airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/PropertiesBasedServiceImplTest.java
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=1167344&r1=1167343&r2=1167344&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 Fri Sep 9 19:58:54 2011
@@ -154,7 +154,7 @@ public class GFacMessageReciever impleme
ct.setExecutionContext(new DefaultExecutionContext());
ct.setServiceName(serviceName);
ct.getExecutionContext().setRegistryService(getRegistry(context));
- ct.getExecutionContext().setNotificationService(notification);
+ ct.getExecutionContext().addNotifiable(notification);
/*
* read from registry and set the correct parameters
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/invocation/ExecutionContext.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/invocation/ExecutionContext.java?rev=1167344&r1=1167343&r2=1167344&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/invocation/ExecutionContext.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/invocation/ExecutionContext.java Fri Sep 9 19:58:54 2011
@@ -22,7 +22,8 @@
package org.apache.airavata.core.gfac.context.invocation;
import org.apache.airavata.commons.gfac.api.Registry;
-import org.apache.airavata.core.gfac.notification.NotificationService;
+import org.apache.airavata.core.gfac.notification.Notifiable;
+import org.apache.airavata.core.gfac.notification.Notifier;
/**
* The Execution Context is used for passing information around the whole
@@ -33,19 +34,19 @@ import org.apache.airavata.core.gfac.not
public interface ExecutionContext {
/**
- * Get NotificationService object to used for notification.
+ * Get Notifier object to used for notification.
*
* @return NotificationService to be used.
*/
- public NotificationService getNotificationService();
+ Notifier getNotifier();
/**
- * Set NotificationService object.
+ * add Notifiable object.
*
- * @param NotificationService
+ * @param Notifiable
* object to used
*/
- public <T extends NotificationService> void setNotificationService(T value);
+ void addNotifiable(Notifiable value);
/**
* Get Registry object. It is used to retrieve important information about
@@ -53,7 +54,7 @@ public interface ExecutionContext {
*
* @return Registry object
*/
- public Registry getRegistryService();
+ Registry getRegistryService();
/**
* Set Registry object.
@@ -61,5 +62,5 @@ public interface ExecutionContext {
* @param Registry
* object to used.
*/
- public <T extends Registry> void setRegistryService(T value);
+ void setRegistryService(Registry value);
}
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/invocation/ExecutionDescription.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/invocation/ExecutionDescription.java?rev=1167344&r1=1167343&r2=1167344&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/invocation/ExecutionDescription.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/invocation/ExecutionDescription.java Fri Sep 9 19:58:54 2011
@@ -38,40 +38,40 @@ public interface ExecutionDescription {
*
* @return HostDescription
*/
- public HostDescription getHost();
+ HostDescription getHost();
/**
* Set HostDescription
*
* @param host
*/
- public <T extends HostDescription> void setHost(T host);
+ <T extends HostDescription> void setHost(T host);
/**
* Get ApplicationDeploymentDescription
*
* @return ApplicationDeploymentDescription
*/
- public ApplicationDeploymentDescription getApp();
+ ApplicationDeploymentDescription getApp();
/**
* Set ApplicationDeploymentDescription
*
* @param app
*/
- public <T extends ApplicationDeploymentDescription> void setApp(T app);
+ <T extends ApplicationDeploymentDescription> void setApp(T app);
/**
* Get ServiceDescription
*
* @return service
*/
- public ServiceDescription getService();
+ ServiceDescription getService();
/**
* Set ServiceDescription
*
* @param service
*/
- public <T extends ServiceDescription> void setService(T service);
+ <T extends ServiceDescription> void setService(T service);
}
\ No newline at end of file
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/invocation/InvocationContext.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/invocation/InvocationContext.java?rev=1167344&r1=1167343&r2=1167344&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/invocation/InvocationContext.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/invocation/InvocationContext.java Fri Sep 9 19:58:54 2011
@@ -36,64 +36,63 @@ public interface InvocationContext {
*
* @return
*/
- public String getServiceName();
+ String getServiceName();
/**
* Get input. Use to handle specific MessageContext for input
*
* @return MessageContext contains input
*/
- public <T> MessageContext<T> getInput();
+ <T> MessageContext<T> getInput();
/**
* Set MessageContext as input
*
* @param value
*/
- public void setInput(MessageContext<?> value);
+ void setInput(MessageContext<?> value);
/**
* Get output. Use to handle specific MessageContext for output
*
* @return MessageContext contains output
*/
- public <T> MessageContext<T> getOutput();
+ <T> MessageContext<T> getOutput();
/**
* Set MessageContext as output
*
* @param value
*/
- public void setOutput(MessageContext<?> value);
+ void setOutput(MessageContext<?> value);
/**
* Get ExecutionDescription
*
* @return ExecutionDescription
*/
- public ExecutionDescription getExecutionDescription();
-
+ ExecutionDescription getExecutionDescription();
/**
* Set ExecutionDescription
*
* @param value
*/
- public void setExecutionDescription(ExecutionDescription value);
+ void setExecutionDescription(ExecutionDescription value);
/**
* Get ExecutionContext
*
* @return ExecutionContext
*/
- public ExecutionContext getExecutionContext();
+ ExecutionContext getExecutionContext();
/**
* Set ExecutionContext
*
* @param value
*/
- public void setExecutionContext(ExecutionContext value);
+ void setExecutionContext(ExecutionContext value);
/**
* Get MessageContext
@@ -101,7 +100,7 @@ public interface InvocationContext {
* @param name
* @return MessageContext
*/
- public <T> MessageContext<T> getMessageContext(String name);
+ <T> MessageContext<T> getMessageContext(String name);
/**
* Add MessageContext to the invocation with specific name.
@@ -109,7 +108,7 @@ public interface InvocationContext {
* @param name
* @param value
*/
- public void addMessageContext(String name, MessageContext<?> value);
+ void addMessageContext(String name, MessageContext<?> value);
/**
* Get SecurityContext
@@ -117,7 +116,7 @@ public interface InvocationContext {
* @param name
* @return
*/
- public SecurityContext getSecurityContext(String name);
+ SecurityContext getSecurityContext(String name);
/**
* Add SecurityContext to the invocation with specific name.
@@ -125,6 +124,6 @@ public interface InvocationContext {
* @param name
* @param value
*/
- public void addSecurityContext(String name, SecurityContext value);
+ void addSecurityContext(String name, SecurityContext value);
}
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/invocation/impl/DefaultExecutionContext.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/invocation/impl/DefaultExecutionContext.java?rev=1167344&r1=1167343&r2=1167344&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/invocation/impl/DefaultExecutionContext.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/invocation/impl/DefaultExecutionContext.java Fri Sep 9 19:58:54 2011
@@ -23,19 +23,21 @@ package org.apache.airavata.core.gfac.co
import org.apache.airavata.commons.gfac.api.Registry;
import org.apache.airavata.core.gfac.context.invocation.ExecutionContext;
-import org.apache.airavata.core.gfac.notification.NotificationService;
+import org.apache.airavata.core.gfac.notification.Notifiable;
+import org.apache.airavata.core.gfac.notification.Notifier;
+import org.apache.airavata.core.gfac.notification.impl.DefaultNotifier;
public class DefaultExecutionContext implements ExecutionContext {
- private NotificationService notificationService;
- private Registry registryService;
-
- public NotificationService getNotificationService() {
+ private Notifier notificationService = new DefaultNotifier();
+ private Registry registryService;
+
+ public Notifier getNotifier() {
return this.notificationService;
}
- public void setNotificationService(NotificationService service) {
- this.notificationService = service;
+ public void addNotifiable(Notifiable service) {
+ this.notificationService.addNotifiable(service);
}
public Registry getRegistryService() {
@@ -45,5 +47,4 @@ public class DefaultExecutionContext imp
public void setRegistryService(Registry registryService) {
this.registryService = registryService;
}
-
}
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/message/MessageContext.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/message/MessageContext.java?rev=1167344&r1=1167343&r2=1167344&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/message/MessageContext.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/context/message/MessageContext.java Fri Sep 9 19:58:54 2011
@@ -48,7 +48,7 @@ public interface MessageContext<T> {
* @param name
* @return value
*/
- public T getValue(String name);
+ T getValue(String name);
/**
* Return value associated with the key as a String object
@@ -56,7 +56,7 @@ public interface MessageContext<T> {
* @param name
* @return string represents value
*/
- public String getStringValue(String name);
+ String getStringValue(String name);
/**
* Add new object associated with the key
@@ -64,7 +64,7 @@ public interface MessageContext<T> {
* @param name
* @param value
*/
- public void add(String name, T value);
+ void add(String name, T value);
/**
* Update the current value associated with the key
@@ -72,5 +72,5 @@ public interface MessageContext<T> {
* @param name
* @param value
*/
- public void setValue(String name, T value);
+ void setValue(String name, T value);
}
Copied: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/Notifiable.java (from r1167241, incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/NotificationService.java)
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/Notifiable.java?p2=incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/Notifiable.java&p1=incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/NotificationService.java&r1=1167241&r2=1167344&rev=1167344&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/NotificationService.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/Notifiable.java Fri Sep 9 19:58:54 2011
@@ -21,37 +21,5 @@
package org.apache.airavata.core.gfac.notification;
-import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
-import org.apache.airavata.core.gfac.provider.Provider;
-import org.apache.airavata.core.gfac.scheduler.Scheduler;
-
-public interface NotificationService {
- /*
- *
- */
- void startSchedule(Object notifier, InvocationContext context, Scheduler scheduler);
- void finishSchedule(Object notifier, InvocationContext context, Scheduler scheduler, Provider provider);
-
- /*
- *
- */
- void input(Object notifier, InvocationContext context, String... data);
- void output(Object notifier, InvocationContext context, String... data);
-
- /*
- *
- */
- void startExecution(Object notifier, InvocationContext context);
- void applicationInfo(Object notifier, InvocationContext context, String... data);
- void finishExecution(Object notifier, InvocationContext context);
- void statusChanged(Object notifier, InvocationContext context, String... data);
- void executionFail(Object notifier, InvocationContext context, Exception e, String... data);
-
- /*
- * Interface for developer to use
- */
- void debug(Object notifier, InvocationContext context, String... data);
- void info(Object notifier, InvocationContext context, String... data);
- void warning(Object notifier, InvocationContext context, String... data);
- void exception(Object notifier, InvocationContext context, String... data);
+public interface Notifiable extends Subject {
}
Added: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/Notifier.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/Notifier.java?rev=1167344&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/Notifier.java (added)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/Notifier.java Fri Sep 9 19:58:54 2011
@@ -0,0 +1,27 @@
+/*
+ *
+ * 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.notification;
+
+public interface Notifier extends Subject {
+ void addNotifiable(Notifiable notif);
+ Notifiable[] getNotifiable();
+}
Added: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/Subject.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/Subject.java?rev=1167344&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/Subject.java (added)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/Subject.java Fri Sep 9 19:58:54 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.core.gfac.notification;
+
+import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
+
+public interface Subject {
+ /*
+ *
+ */
+ void startSchedule(Object notifier, InvocationContext context);
+ void finishSchedule(Object notifier, InvocationContext context);
+
+ /*
+ *
+ */
+ void input(Object notifier, InvocationContext context, String... data);
+ void output(Object notifier, InvocationContext context, String... data);
+
+ /*
+ *
+ */
+ void startExecution(Object notifier, InvocationContext context);
+ void applicationInfo(Object notifier, InvocationContext context, String... data);
+ void finishExecution(Object notifier, InvocationContext context);
+ void statusChanged(Object notifier, InvocationContext context, String... data);
+ void executionFail(Object notifier, InvocationContext context, Exception e, String... data);
+
+ /*
+ * Interface for developer to use
+ */
+ void debug(Object notifier, InvocationContext context, String... data);
+ void info(Object notifier, InvocationContext context, String... data);
+ void warning(Object notifier, InvocationContext context, String... data);
+ void exception(Object notifier, InvocationContext context, String... data);
+}
Added: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/DefaultNotifier.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/DefaultNotifier.java?rev=1167344&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/DefaultNotifier.java (added)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/DefaultNotifier.java Fri Sep 9 19:58:54 2011
@@ -0,0 +1,123 @@
+/*
+ *
+ * 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.notification.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
+import org.apache.airavata.core.gfac.notification.Notifiable;
+import org.apache.airavata.core.gfac.notification.Notifier;
+
+
+public class DefaultNotifier implements Notifier {
+
+ private List<Notifiable> notifiableObjects = new ArrayList<Notifiable>();
+
+ public void addNotifiable(Notifiable notif){
+ notifiableObjects.add(notif);
+ }
+
+ public Notifiable[] getNotifiable(){
+ return (Notifiable[]) notifiableObjects.toArray();
+ }
+
+ public void startSchedule(Object notifier, InvocationContext context) {
+ for (Notifiable notif : notifiableObjects) {
+ notif.startSchedule(notifier, context);
+ }
+ }
+
+ public void finishSchedule(Object notifier, InvocationContext context) {
+ for (Notifiable notif : notifiableObjects) {
+ notif.finishSchedule(notifier, context);
+ }
+ }
+
+ public void input(Object notifier, InvocationContext context, String... data) {
+ for (Notifiable notif : notifiableObjects) {
+ notif.info(notifier, context, data);
+ }
+ }
+
+ public void output(Object notifier, InvocationContext context, String... data) {
+ for (Notifiable notif : notifiableObjects) {
+ notif.output(notifier, context, data);
+ }
+ }
+
+ public void startExecution(Object notifier, InvocationContext context) {
+ for (Notifiable notif : notifiableObjects) {
+ notif.startExecution(notifier, context);
+ }
+ }
+
+ public void applicationInfo(Object notifier, InvocationContext context, String... data) {
+ for (Notifiable notif : notifiableObjects) {
+ notif.applicationInfo(notifier, context, data);
+ }
+ }
+
+ public void finishExecution(Object notifier, InvocationContext context) {
+ for (Notifiable notif : notifiableObjects) {
+ notif.finishExecution(notifier, context);
+ }
+ }
+
+ public void statusChanged(Object notifier, InvocationContext context, String... data) {
+ for (Notifiable notif : notifiableObjects) {
+ notif.statusChanged(notifier, context, data);
+ }
+ }
+
+ public void executionFail(Object notifier, InvocationContext context, Exception e, String... data) {
+ for (Notifiable notif : notifiableObjects) {
+ notif.executionFail(notifier, context, e, data);
+ }
+ }
+
+ public void debug(Object notifier, InvocationContext context, String... data) {
+ for (Notifiable notif : notifiableObjects) {
+ notif.debug(notifier, context, data);
+ }
+ }
+
+ public void info(Object notifier, InvocationContext context, String... data) {
+ for (Notifiable notif : notifiableObjects) {
+ notif.info(notifier, context, data);
+ }
+
+ }
+
+ public void warning(Object notifier, InvocationContext context, String... data) {
+ for (Notifiable notif : notifiableObjects) {
+ notif.warning(notifier, context, data);
+ }
+
+ }
+
+ public void exception(Object notifier, InvocationContext context, String... data) {
+ for (Notifiable notif : notifiableObjects) {
+ notif.exception(notifier, context, data);
+ }
+ }
+}
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/LoggingNotification.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/LoggingNotification.java?rev=1167344&r1=1167343&r2=1167344&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/LoggingNotification.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/LoggingNotification.java Fri Sep 9 19:58:54 2011
@@ -21,21 +21,19 @@
package org.apache.airavata.core.gfac.notification.impl;
import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
-import org.apache.airavata.core.gfac.notification.NotificationService;
-import org.apache.airavata.core.gfac.provider.Provider;
-import org.apache.airavata.core.gfac.scheduler.Scheduler;
+import org.apache.airavata.core.gfac.notification.Notifiable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class LoggingNotification implements NotificationService {
+public class LoggingNotification implements Notifiable {
protected final Logger log = LoggerFactory.getLogger(LoggingNotification.class);
- public void startSchedule(Object notifier, InvocationContext context, Scheduler scheduler) {
+ public void startSchedule(Object notifier, InvocationContext context) {
printOut(notifier, context, "Start scheduling");
}
- public void finishSchedule(Object notifier, InvocationContext context, Scheduler scheduler, Provider provider) {
+ public void finishSchedule(Object notifier, InvocationContext context) {
printOut(notifier, context, "Finish scheduling");
}
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/StandardOutNotification.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/StandardOutNotification.java?rev=1167344&r1=1167343&r2=1167344&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/StandardOutNotification.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/StandardOutNotification.java Fri Sep 9 19:58:54 2011
@@ -21,18 +21,16 @@
package org.apache.airavata.core.gfac.notification.impl;
import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
-import org.apache.airavata.core.gfac.notification.NotificationService;
-import org.apache.airavata.core.gfac.provider.Provider;
-import org.apache.airavata.core.gfac.scheduler.Scheduler;
+import org.apache.airavata.core.gfac.notification.Notifiable;
-public class StandardOutNotification implements NotificationService {
+public class StandardOutNotification implements Notifiable {
- public void startSchedule(Object notifier, InvocationContext context, Scheduler scheduler) {
- printOut(notifier, context, null);
+ public void startSchedule(Object notifier, InvocationContext context) {
+ printOut(notifier, context);
}
- public void finishSchedule(Object notifier, InvocationContext context, Scheduler scheduler, Provider provider) {
- printOut(notifier, context, null);
+ public void finishSchedule(Object notifier, InvocationContext context) {
+ printOut(notifier, context);
}
public void input(Object notifier, InvocationContext context, String... data) {
@@ -43,7 +41,7 @@ public class StandardOutNotification imp
}
public void startExecution(Object notifier, InvocationContext context) {
- printOut(notifier, context, null);
+ printOut(notifier, context);
}
public void applicationInfo(Object notifier, InvocationContext context, String... data) {
@@ -51,7 +49,7 @@ public class StandardOutNotification imp
}
public void finishExecution(Object notifier, InvocationContext context) {
- printOut(notifier, context, null);
+ printOut(notifier, context);
}
public void statusChanged(Object notifier, InvocationContext context, String... data) {
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/WorkflowTrackingNotification.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/WorkflowTrackingNotification.java?rev=1167344&r1=1167343&r2=1167344&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/WorkflowTrackingNotification.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/notification/impl/WorkflowTrackingNotification.java Fri Sep 9 19:58:54 2011
@@ -25,16 +25,14 @@ import java.net.URI;
import java.util.Properties;
import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
-import org.apache.airavata.core.gfac.notification.NotificationService;
-import org.apache.airavata.core.gfac.provider.Provider;
-import org.apache.airavata.core.gfac.scheduler.Scheduler;
+import org.apache.airavata.core.gfac.notification.Notifiable;
import org.apache.airavata.workflow.tracking.Notifier;
import org.apache.airavata.workflow.tracking.NotifierFactory;
import org.apache.airavata.workflow.tracking.common.DurationObj;
import org.apache.airavata.workflow.tracking.common.InvocationEntity;
import org.apache.airavata.workflow.tracking.common.WorkflowTrackingContext;
-public class WorkflowTrackingNotification implements NotificationService {
+public class WorkflowTrackingNotification implements Notifiable {
private Notifier notifier;
@@ -76,13 +74,13 @@ public class WorkflowTrackingNotificatio
receiverWorkflowTimeStep);
//send start workflow
- this.invocationContext = this.notifier.workflowInvoked(this.context, this.initiator, null);
+ this.invocationContext = this.notifier.workflowInvoked(this.context, this.initiator);
}
- public void startSchedule(Object notifier, InvocationContext context, Scheduler scheduler) {
+ public void startSchedule(Object notifier, InvocationContext context) {
}
- public void finishSchedule(Object notifier, InvocationContext context, Scheduler scheduler, Provider provider) {
+ public void finishSchedule(Object notifier, InvocationContext context) {
}
public void input(Object notifier, InvocationContext context, String... data) {
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/AbstractProvider.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/AbstractProvider.java?rev=1167344&r1=1167343&r2=1167344&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/AbstractProvider.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/AbstractProvider.java Fri Sep 9 19:58:54 2011
@@ -21,10 +21,54 @@
package org.apache.airavata.core.gfac.provider;
+import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
+import org.apache.airavata.core.gfac.exception.ProviderException;
+import org.apache.airavata.core.gfac.notification.Notifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * AbstractProvider wraps up steps of execution for Provider.
+ *
+ */
public abstract class AbstractProvider implements Provider {
- protected final Logger log = LoggerFactory.getLogger(this.getClass());
-
+ protected final Logger log = LoggerFactory.getLogger(this.getClass());
+
+ public void execute(InvocationContext invocationContext) throws ProviderException{
+
+ Notifier notifier = invocationContext.getExecutionContext().getNotifier();
+
+ /*
+ * Make a directory on the host
+ */
+ makeDirectory(invocationContext);
+
+ /*
+ * Setup necessary environment
+ */
+ setupEnvironment(invocationContext);
+
+ notifier.startExecution(this, invocationContext);
+
+ /*
+ * Execution application
+ */
+ executeApplication(invocationContext);
+
+ notifier.finishExecution(this, invocationContext);
+
+
+ /*
+ * Process output information
+ */
+ retrieveOutput(invocationContext);
+ }
+
+ public abstract void makeDirectory(InvocationContext invocationContext) throws ProviderException;
+
+ public abstract void setupEnvironment(InvocationContext invocationContext) throws ProviderException;
+
+ public abstract void executeApplication(InvocationContext invocationContext) throws ProviderException;
+
+ public abstract void retrieveOutput(InvocationContext invocationContext) throws ProviderException;
}
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/GramProvider.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/GramProvider.java?rev=1167344&r1=1167343&r2=1167344&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/GramProvider.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/GramProvider.java Fri Sep 9 19:58:54 2011
@@ -27,7 +27,6 @@ import java.net.URISyntaxException;
import javax.xml.namespace.QName;
-import org.apache.airavata.commons.gfac.type.app.GramApplicationDeployment;
import org.apache.airavata.commons.gfac.type.app.ShellApplicationDeployment;
import org.apache.airavata.commons.gfac.type.host.GlobusHost;
import org.apache.airavata.commons.gfac.type.parameter.AbstractParameter;
@@ -39,7 +38,6 @@ import org.apache.airavata.core.gfac.exc
import org.apache.airavata.core.gfac.exception.SecurityException;
import org.apache.airavata.core.gfac.exception.ToolsException;
import org.apache.airavata.core.gfac.external.GridFtp;
-import org.apache.airavata.core.gfac.notification.NotificationService;
import org.apache.airavata.core.gfac.provider.utils.GramRSLGenerator;
import org.apache.airavata.core.gfac.provider.utils.JobSubmissionListener;
import org.apache.airavata.core.gfac.utils.GfacUtils;
@@ -53,11 +51,24 @@ import org.ietf.jgss.GSSException;
public class GramProvider extends AbstractProvider {
public static final String MYPROXY_SECURITY_CONTEXT = "myproxy";
+ private GramJob job;
+ private String gateKeeper;
+ private JobSubmissionListener listener;
public void initialize(InvocationContext invocationContext) throws ProviderException {
- GlobusHost host = (GlobusHost)invocationContext.getExecutionDescription().getHost();
- ShellApplicationDeployment app = (ShellApplicationDeployment)invocationContext.getExecutionDescription().getApp();
-
+ }
+
+ public void dispose(InvocationContext invocationContext) throws GfacException {
+ }
+
+ public void abort(InvocationContext invocationContext) throws GfacException {
+ }
+
+ public void makeDirectory(InvocationContext invocationContext) throws ProviderException {
+ GlobusHost host = (GlobusHost) invocationContext.getExecutionDescription().getHost();
+ ShellApplicationDeployment app = (ShellApplicationDeployment) invocationContext.getExecutionDescription()
+ .getApp();
+
GridFtp ftp = new GridFtp();
try {
@@ -65,7 +76,7 @@ public class GramProvider extends Abstra
.getSecurityContext(MYPROXY_SECURITY_CONTEXT)).getGssCredentails();
String hostgridFTP = host.getGridFTPEndPoint();
- if (host.getGridFTPEndPoint() == null){
+ if (host.getGridFTPEndPoint() == null) {
hostgridFTP = host.getName();
}
@@ -83,107 +94,158 @@ public class GramProvider extends Abstra
ftp.makeDir(tmpdirURI, gssCred);
ftp.makeDir(workingDirURI, gssCred);
ftp.makeDir(inputURI, gssCred);
- ftp.makeDir(outputURI, gssCred);
-
- } catch (Exception e) {
- e.printStackTrace();
+ } catch (URISyntaxException e) {
+ throw new ProviderException("URI is malformatted:" + e.getMessage(), e);
+ } catch (SecurityException e) {
+ throw new ProviderException(e.getMessage(), e);
+ } catch (ToolsException e) {
+ throw new ProviderException(e.getMessage(), e);
}
}
- public void execute(InvocationContext invocationContext) throws ProviderException {
- GlobusHost host = (GlobusHost)invocationContext.getExecutionDescription().getHost();
- GramApplicationDeployment app = (GramApplicationDeployment)invocationContext.getExecutionDescription().getApp();
+ public void setupEnvironment(InvocationContext invocationContext) throws ProviderException {
+ GlobusHost host = (GlobusHost) invocationContext.getExecutionDescription().getHost();
log.info("Searching for Gate Keeper");
- String gatekeeper = host.getGlobusGateKeeperEndPoint();
- if (gatekeeper == null) {
- gatekeeper = host.getName();
+ gateKeeper = host.getGlobusGateKeeperEndPoint();
+ if (gateKeeper == null) {
+ gateKeeper = host.getName();
}
- log.info("Using Globus GateKeeper " + gatekeeper);
- GramJob job = null;
- boolean jobSucsseful = false;
+ log.info("Using Globus GateKeeper " + gateKeeper);
String rsl = "";
- int errCode = 0;
try {
- GSSCredential gssCred = ((GSISecurityContext) invocationContext
- .getSecurityContext(MYPROXY_SECURITY_CONTEXT)).getGssCredentails();
-
GramAttributes jobAttr = GramRSLGenerator.configureRemoteJob(invocationContext);
rsl = jobAttr.toRSL();
- job = new GramJob(rsl);
- job.setCredentials(gssCred);
log.info("RSL = " + rsl);
- NotificationService notifier = invocationContext.getExecutionContext().getNotificationService();
- notifier.startExecution(this, invocationContext);
- StringBuffer buf = new StringBuffer();
-
- JobSubmissionListener listener = new JobSubmissionListener(job, invocationContext);
+ job = new GramJob(rsl);
+ listener = new JobSubmissionListener(job, invocationContext);
job.addListener(listener);
- log.info("Request to contact:" + gatekeeper);
+
+ } catch (ToolsException te) {
+ throw new ProviderException(te.getMessage(), te);
+ }
+
+ }
+
+ public void executeApplication(InvocationContext invocationContext) throws ProviderException {
+ GlobusHost host = (GlobusHost) invocationContext.getExecutionDescription().getHost();
+ ShellApplicationDeployment app = (ShellApplicationDeployment) invocationContext.getExecutionDescription()
+ .getApp();
+ StringBuffer buf = new StringBuffer();
+ try {
+
/*
- * The first boolean is to specify the job is a batch job - use true for interactive and false for batch.
- * The second boolean is to specify to use the full proxy and not delegate a limited proxy.
+ * Set Security
*/
- job.request(gatekeeper, false, false);
+ GSSCredential gssCred = ((GSISecurityContext) invocationContext
+ .getSecurityContext(MYPROXY_SECURITY_CONTEXT)).getGssCredentails();
+ job.setCredentials(gssCred);
+
+ log.info("Request to contact:" + gateKeeper);
- log.info("JobID = " + job.getIDAsString());
+ buf.append("Finished launching job, Host = ").append(host.getName()).append(" RSL = ").append(job.getRSL())
+ .append(" working directory = ").append(app.getWorkingDir()).append(" tempDirectory = ")
+ .append(app.getTmpDir()).append(" Globus GateKeeper cantact = ").append(gateKeeper);
+ invocationContext.getExecutionContext().getNotifier().info(this, invocationContext, buf.toString());
- // Gram.request(contact, job, false, false);
-
- buf.append("Finished launching job, Host = ")
- .append(host.getName())
- .append(" RSL = ")
- .append(job.getRSL())
- .append(" working directory = ")
- .append(app.getWorkingDir())
- .append(" tempDirectory = ")
- .append(app.getTmpDir())
- .append(" Globus GateKeeper cantact = ")
- .append(gatekeeper);
- notifier.info(this, invocationContext, buf.toString());
+ /*
+ * The first boolean is to specify the job is a batch job - use true
+ * for interactive and false for batch. The second boolean is to
+ * specify to use the full proxy and not delegate a limited proxy.
+ */
+ job.request(gateKeeper, false, false);
String gramJobid = job.getIDAsString();
- notifier.info(this, invocationContext, "JobID=" + gramJobid);
+ log.info("JobID = " + gramJobid);
+ invocationContext.getExecutionContext().getNotifier().info(this, invocationContext, "JobID=" + gramJobid);
+
log.info(buf.toString());
-
- notifier.applicationInfo(this, invocationContext, gramJobid, gatekeeper, null, null,
- gssCred.getName().toString(), null, job.getRSL());
+ invocationContext
+ .getExecutionContext()
+ .getNotifier()
+ .applicationInfo(this, invocationContext, gramJobid, gateKeeper, null, null,
+ gssCred.getName().toString(), null, job.getRSL());
+
+ /*
+ * Block untill job is done
+ */
listener.waitFor();
+
+ /*
+ * Remove listener
+ */
job.removeListener(listener);
+ /*
+ * Fail job
+ */
int jobStatus = listener.getStatus();
if (jobStatus == GramJob.STATUS_FAILED) {
- errCode = listener.getError();
- String errorMsg = "Job " + job.getID() + " on host " + host.getName() + " Error Code = " + errCode;
- JobSubmissionFault error = new JobSubmissionFault(this, new Exception(errorMsg), "GFAC HOST", gatekeeper, rsl);
+ int errCode = listener.getError();
+ String errorMsg = "Job " + job.getID() + " on host " + host.getName() + " Error Code = " + errCode;
+ JobSubmissionFault error = new JobSubmissionFault(this, new Exception(errorMsg), "GFAC HOST",
+ gateKeeper, job.getRSL());
if (errCode == 8) {
- error.setReason(JobSubmissionFault.JOB_CANCEL);
+ error.setReason(JobSubmissionFault.JOB_CANCEL);
} else {
error.setReason(JobSubmissionFault.JOB_FAILED);
}
throw error;
}
- notifier.finishExecution(this, invocationContext);
+
+ } catch (GramException e) {
+ JobSubmissionFault error = new JobSubmissionFault(this, e, host.getName(), gateKeeper, job.getRSL());
+ if (listener.getError() == 8) {
+ error.setReason(JobSubmissionFault.JOB_CANCEL);
+ } else {
+ error.setReason(JobSubmissionFault.JOB_FAILED);
+ }
+ throw error;
+ } catch (GSSException e) {
+ throw new ProviderException(e.getMessage(), e);
+ } catch (InterruptedException e) {
+ throw new ProviderException("Thread", e);
+ } catch (SecurityException e) {
+ throw new ProviderException(e.getMessage(), e);
+ } finally {
+ if (job != null) {
+ try {
+ job.cancel();
+ } catch (Exception e) {
+ }
+ }
+ }
+
+ }
+
+ public void retrieveOutput(InvocationContext invocationContext) throws ProviderException {
+ GlobusHost host = (GlobusHost) invocationContext.getExecutionDescription().getHost();
+ ShellApplicationDeployment app = (ShellApplicationDeployment) invocationContext.getExecutionDescription()
+ .getApp();
+ GridFtp ftp = new GridFtp();
+
+ try {
+ GSSCredential gssCred = ((GSISecurityContext) invocationContext
+ .getSecurityContext(MYPROXY_SECURITY_CONTEXT)).getGssCredentails();
/*
* Stdout and Stderror
*/
- GridFtp ftp = new GridFtp();
String hostgridFTP = host.getGridFTPEndPoint();
- if (host.getGridFTPEndPoint() == null){
+ if (host.getGridFTPEndPoint() == null) {
hostgridFTP = host.getName();
}
URI stdoutURI = GfacUtils.createGsiftpURI(hostgridFTP, app.getStdOut());
URI stderrURI = GfacUtils.createGsiftpURI(hostgridFTP, app.getStdErr());
- System.out.println(stdoutURI);
- System.out.println(stderrURI);
+ log.info("STDOUT:" + stdoutURI.toString());
+ log.info("STDERR:" + stderrURI.toString());
File logDir = new File("./service_logs");
if (!logDir.exists()) {
@@ -200,43 +262,15 @@ public class GramProvider extends Abstra
String stderr = ftp.readRemoteFile(stderrURI, gssCred, localStdErrFile);
// set to context
- OutputUtils.fillOutputFromStdout(invocationContext.<AbstractParameter>getOutput(), stdout, stderr);
-
- jobSucsseful = true;
- } catch (GramException e) {
- JobSubmissionFault error = new JobSubmissionFault(this, e, host.getName(), gatekeeper, rsl);
- if (errCode == 8) {
- error.setReason(JobSubmissionFault.JOB_CANCEL);
- } else {
- error.setReason(JobSubmissionFault.JOB_FAILED);
- }
- throw error;
- } catch (GSSException e) {
- throw new ProviderException("GFAC HOST", e);
- } catch (InterruptedException e) {
- throw new ProviderException("Thread", e);
+ OutputUtils.fillOutputFromStdout(invocationContext.<AbstractParameter> getOutput(), stdout, stderr);
+
+ } catch (URISyntaxException e) {
+ throw new ProviderException("URI is malformatted:" + e.getMessage(), e);
} catch (SecurityException e) {
- throw new ProviderException(e.getMessage(), e);
+ throw new ProviderException(e.getMessage(), e);
} catch (ToolsException e) {
throw new ProviderException(e.getMessage(), e);
- } catch (URISyntaxException e) {
- throw new ProviderException("URI is in the wrong format:" + e.getMessage(), e);
- } finally {
- if (job != null && !jobSucsseful) {
- try {
- job.cancel();
- } catch (Exception e) {
- }
- }
}
-
- }
-
- public void dispose(InvocationContext invocationContext) throws GfacException {
-
- }
-
- public void abort(InvocationContext invocationContext) throws GfacException {
}
}
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/LocalProvider.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/LocalProvider.java?rev=1167344&r1=1167343&r2=1167344&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/LocalProvider.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/LocalProvider.java Fri Sep 9 19:58:54 2011
@@ -38,7 +38,6 @@ import org.apache.airavata.commons.gfac.
import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
import org.apache.airavata.core.gfac.exception.GfacException;
import org.apache.airavata.core.gfac.exception.ProviderException;
-import org.apache.airavata.core.gfac.notification.NotificationService;
import org.apache.airavata.core.gfac.utils.GFacConstants;
import org.apache.airavata.core.gfac.utils.GfacUtils;
import org.apache.airavata.core.gfac.utils.OutputUtils;
@@ -46,6 +45,8 @@ import org.apache.airavata.core.gfac.uti
public class LocalProvider extends AbstractProvider {
private static final String SPACE = " ";
+ private ProcessBuilder builder;
+ private List<String> cmdList;
private String buildCommand(List<String> cmdList) {
StringBuffer buff = new StringBuffer();
@@ -57,66 +58,71 @@ public class LocalProvider extends Abstr
}
public void initialize(InvocationContext invocationContext) throws ProviderException {
+ }
+
+ public void dispose(InvocationContext invocationContext) throws GfacException {
+ }
+
+ public void abort(InvocationContext invocationContext) throws GfacException {
+
+ }
+
+ public void makeDirectory(InvocationContext invocationContext) throws ProviderException {
ApplicationDeploymentDescription app = invocationContext.getExecutionDescription().getApp();
log.info("working diectroy = " + app.getWorkingDir());
log.info("temp directory = " + app.getTmpDir());
- //TODO: These should be abstracted out as methods like makeWorkingDirOnTarget(app),
- //TODO: since any provider developer will need to implement.
new File(app.getWorkingDir()).mkdir();
new File(app.getTmpDir()).mkdir();
new File(app.getInputDir()).mkdir();
new File(app.getOutputDir()).mkdir();
}
- //TODO: This method is too complex and thus fragile. It should be broken up into smaller private methods.
- public void execute(InvocationContext context) throws ProviderException {
- ShellApplicationDeployment app = (ShellApplicationDeployment)context.getExecutionDescription().getApp();
-
+ public void setupEnvironment(InvocationContext context) throws ProviderException {
+ ShellApplicationDeployment app = (ShellApplicationDeployment) context.getExecutionDescription().getApp();
+
// input parameter
ArrayList<String> tmp = new ArrayList<String>();
for (Iterator<String> iterator = context.getInput().getNames(); iterator.hasNext();) {
String key = iterator.next();
tmp.add(context.getInput().getStringValue(key));
}
-
- List<String> cmdList = new ArrayList<String>();
- try {
- /*
- * Builder Command
- */
- cmdList.add(app.getExecutable());
- cmdList.addAll(tmp);
+ cmdList = new ArrayList<String>();
- // create process builder from command
- ProcessBuilder builder = new ProcessBuilder(cmdList);
+ /*
+ * Builder Command
+ */
+ cmdList.add(app.getExecutable());
+ cmdList.addAll(tmp);
+
+ // create process builder from command
+ this.builder = new ProcessBuilder(cmdList);
+
+ // get the env of the host and the application
+ Map<String, String> nv = app.getEnv();
+ builder.environment().putAll(nv);
+
+ // extra env's
+ builder.environment().put(GFacConstants.INPUT_DATA_DIR_VAR_NAME, app.getInputDir());
+ builder.environment().put(GFacConstants.OUTPUT_DATA_DIR_VAR_NAME, app.getOutputDir());
+
+ // working directory
+ builder.directory(new File(app.getWorkingDir()));
+
+ // log info
+ log.info("Command = " + buildCommand(cmdList));
+ log.info("Working dir = " + builder.directory());
+ for (String key : builder.environment().keySet()) {
+ log.info("Env[" + key + "] = " + builder.environment().get(key));
+ }
+ }
- // get the env of the host and the application
- Map<String, String> nv = app.getEnv();
- builder.environment().putAll(nv);
-
- // extra env's
- builder.environment().put(GFacConstants.INPUT_DATA_DIR_VAR_NAME, app.getInputDir());
- builder.environment().put(GFacConstants.OUTPUT_DATA_DIR_VAR_NAME, app.getOutputDir());
-
- // working directory
- builder.directory(new File(app.getWorkingDir()));
-
- // log info
- log.info("Command = " + buildCommand(cmdList));
- log.info("Working dir = " + builder.directory());
- for (String key : builder.environment().keySet()) {
- log.info("Env[" + key + "] = " + builder.environment().get(key));
- }
+ public void executeApplication(InvocationContext context) throws ProviderException {
+ ShellApplicationDeployment app = (ShellApplicationDeployment) context.getExecutionDescription().getApp();
- //TODO: Since all execute() methods need to implement notification, this should
- //TODO: be made foolproof in some way (maybe as "listener" pattern, off the
- //TODO: top of my head) so that other provider developers implement it correctly.
- NotificationService notifier = context.getExecutionContext().getNotificationService();
- notifier.startExecution(this, context);
-
+ try {
// running cmd
Process process = builder.start();
@@ -198,16 +204,15 @@ public class LocalProvider extends Abstr
// wait for the process (application) to finish executing
int returnValue = process.waitFor();
-
- notifier.finishExecution(this, context);
// make sure other two threads are done
t1.join();
t2.join();
/*
- * check return value. usually not very helpful to draw conclusions based on return values so don't bother.
- * just provide warning in the log messages
+ * check return value. usually not very helpful to draw conclusions
+ * based on return values so don't bother. just provide warning in
+ * the log messages
*/
if (returnValue != 0) {
log.error("Process finished with non zero return value. Process may have failed");
@@ -216,42 +221,30 @@ public class LocalProvider extends Abstr
}
StringBuffer buf = new StringBuffer();
- buf.append("Executed ")
- .append(buildCommand(cmdList))
- .append(" on the localHost, working directory = ")
- .append(app.getWorkingDir())
- .append(" tempDirectory = ")
- .append(app.getTmpDir())
- .append(" With the status ")
- .append(String.valueOf(returnValue));
+ buf.append("Executed ").append(buildCommand(cmdList)).append(" on the localHost, working directory = ")
+ .append(app.getWorkingDir()).append(" tempDirectory = ").append(app.getTmpDir())
+ .append(" With the status ").append(String.valueOf(returnValue));
log.info(buf.toString());
- String stdOutStr = GfacUtils.readFileToString(app.getStdOut());
- String stdErrStr = GfacUtils.readFileToString(app.getStdErr());
-
- // set to context
- OutputUtils.fillOutputFromStdout(context.<AbstractParameter>getOutput(), stdOutStr, stdErrStr);
+ } catch (IOException io) {
- } catch (IOException e) {
- log.error("error", e);
- throw new ProviderException(e.getMessage(), e);
} catch (InterruptedException e) {
- log.error("error", e);
- throw new ProviderException(e.getMessage(), e);
- } catch (Exception e){
- log.error("error", e);
- throw new ProviderException(e.getMessage(), e);
}
-
}
- public void dispose(InvocationContext invocationContext) throws GfacException {
+ public void retrieveOutput(InvocationContext context) throws ProviderException {
- }
+ ShellApplicationDeployment app = (ShellApplicationDeployment) context.getExecutionDescription().getApp();
- public void abort(InvocationContext invocationContext) throws GfacException {
+ try {
+ String stdOutStr = GfacUtils.readFileToString(app.getStdOut());
+ String stdErrStr = GfacUtils.readFileToString(app.getStdErr());
- }
+ // set to context
+ OutputUtils.fillOutputFromStdout(context.<AbstractParameter> getOutput(), stdOutStr, stdErrStr);
+ } catch (IOException io) {
+ }
+ }
}
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/SSHProvider.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/SSHProvider.java?rev=1167344&r1=1167343&r2=1167344&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/SSHProvider.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/SSHProvider.java Fri Sep 9 19:58:54 2011
@@ -46,7 +46,6 @@ import org.apache.airavata.core.gfac.con
import org.apache.airavata.core.gfac.context.security.impl.SSHSecurityContextImpl;
import org.apache.airavata.core.gfac.exception.GfacException;
import org.apache.airavata.core.gfac.exception.ProviderException;
-import org.apache.airavata.core.gfac.notification.NotificationService;
import org.apache.airavata.core.gfac.utils.GFacConstants;
import org.apache.airavata.core.gfac.utils.GfacUtils;
import org.apache.airavata.core.gfac.utils.OutputUtils;
@@ -55,6 +54,7 @@ public class SSHProvider extends Abstrac
private static final String SPACE = " ";
private static final String SSH_SECURITY_CONTEXT = "ssh";
+ private String command;
private String buildCommand(List<String> cmdList) {
StringBuffer buff = new StringBuffer();
@@ -81,9 +81,22 @@ public class SSHProvider extends Abstrac
}
- // TODO: This method has a try/catch embedded in 'finally' method. Is there a way
- // TODO: to force cleanup on failed connections?
public void initialize(InvocationContext context) throws ProviderException {
+ }
+
+ public void execute(InvocationContext context) throws ProviderException {
+ }
+
+ public void dispose(InvocationContext invocationContext) throws GfacException {
+ }
+
+ public void abort(InvocationContext invocationContext) throws GfacException {
+ }
+
+ // TODO: This method has a try/catch embedded in 'finally' method. Is there
+ // a way
+ // TODO: to force cleanup on failed connections?
+ public void makeDirectory(InvocationContext context) throws ProviderException {
HostDescription host = context.getExecutionDescription().getHost();
ShellApplicationDeployment app = (ShellApplicationDeployment) context.getExecutionDescription().getApp();
@@ -130,9 +143,7 @@ public class SSHProvider extends Abstrac
}
}
- // TODO: This method has a try/catch embedded in 'finally' method. Is there a way
- // TODO: to force cleanup on failed connections?
- public void execute(InvocationContext context) throws ProviderException {
+ public void setupEnvironment(InvocationContext context) throws ProviderException {
HostDescription host = context.getExecutionDescription().getHost();
ShellApplicationDeployment app = (ShellApplicationDeployment) context.getExecutionDescription().getApp();
@@ -145,60 +156,58 @@ public class SSHProvider extends Abstrac
List<String> cmdList = new ArrayList<String>();
+ /*
+ * Builder Command
+ */
+ cmdList.add(app.getExecutable());
+ cmdList.addAll(tmp);
+
+ // create process builder from command
+ command = buildCommand(cmdList);
+
+ // redirect StdOut and StdErr
+ // TODO: Make 1> and 2> into static constants.
+ // TODO: This only works for the BASH shell. CSH and TCSH will be
+ // different.
+ command += SPACE + "1>" + SPACE + app.getStdOut();
+ command += SPACE + "2>" + SPACE + app.getStdErr();
+ }
+
+ public void executeApplication(InvocationContext context) throws ProviderException {
+ // TODO: initSSHSecurity can throw an IOException but you are
+ // treating everything as a GFAC exception.
+
+ HostDescription host = context.getExecutionDescription().getHost();
+ ShellApplicationDeployment app = (ShellApplicationDeployment) context.getExecutionDescription().getApp();
+
SSHClient ssh = new SSHClient();
try {
- /*
- * Builder Command
- */
- cmdList.add(app.getExecutable());
- cmdList.addAll(tmp);
-
- // create process builder from command
- String command = buildCommand(cmdList);
-
- // redirect StdOut and StdErr
- // TODO: Make 1> and 2> into static constants.
- // TODO: This only works for the BASH shell. CSH and TCSH will be different.
- command += SPACE + "1>" + SPACE + app.getStdOut();
- command += SPACE + "2>" + SPACE + app.getStdErr();
-
- // get the env of the host and the application
- Map<String, String> nv = app.getEnv();
-
- // extra env's
- nv.put(GFacConstants.INPUT_DATA_DIR_VAR_NAME, app.getInputDir());
- nv.put(GFacConstants.OUTPUT_DATA_DIR_VAR_NAME, app.getOutputDir());
-
- // log info
- log.info("Command = " + buildCommand(cmdList));
- for (Entry<String, String> entry : nv.entrySet()) {
- log.info("Env[" + entry.getKey() + "] = " + entry.getValue());
- }
-
- // notify start
- NotificationService notifier = context.getExecutionContext().getNotificationService();
- notifier.startExecution(this, context);
-
- // TODO: initSSHSecurity can throw an IOException but you are
- // treating everything as a GFAC exception.
initSSHSecurity(context, ssh);
ssh.connect(host.getName());
+
final Session session = ssh.startSession();
try {
/*
- * Build working Directory
+ * Going to working Directory
*/
- log.info("WorkingDir = " + app.getWorkingDir());
- session.exec("mkdir -p " + app.getWorkingDir());
session.exec("cd " + app.getWorkingDir());
+ // get the env of the host and the application
+ Map<String, String> nv = app.getEnv();
+
+ // extra env's
+ nv.put(GFacConstants.INPUT_DATA_DIR_VAR_NAME, app.getInputDir());
+ nv.put(GFacConstants.OUTPUT_DATA_DIR_VAR_NAME, app.getOutputDir());
+
/*
* Set environment
*/
+ log.info("Command = " + command);
for (Entry<String, String> entry : nv.entrySet()) {
+ log.info("Env[" + entry.getKey() + "] = " + entry.getValue());
session.setEnvVar(entry.getKey(), entry.getValue());
- }
+ }
/*
* Execute
@@ -207,9 +216,6 @@ public class SSHProvider extends Abstrac
log.info("stdout=" + GfacUtils.readFromStream(session.getInputStream()));
cmd.join(5, TimeUnit.SECONDS);
- // notify end
- notifier.finishExecution(this, context);
-
/*
* check return value. usually not very helpful to draw
* conclusions based on return values so don't bother. just
@@ -221,14 +227,47 @@ public class SSHProvider extends Abstrac
log.info("Process finished with return value of zero.");
}
- // TODO: The location of the logDir should be a configurable parameter.
- // TODO: This location is easy to lose. Also, why not use standard logging
- // TODO: tools for this? Or are these really temporary directories rather than logs?
+ } catch (ConnectionException e) {
+ throw e;
+ } finally {
+ try {
+ session.close();
+ } catch (Exception e) {
+ log.warn("Cannot Close SSH Session");
+ }
+ }
+ } catch (IOException e) {
+ throw new ProviderException(e.getMessage(), e);
+ } finally {
+ try {
+ ssh.disconnect();
+ } catch (Exception e) {
+ log.warn("Cannot Close SSH Connection");
+ }
+ }
+ }
+
+ public void retrieveOutput(InvocationContext context) throws ProviderException {
+ HostDescription host = context.getExecutionDescription().getHost();
+ ShellApplicationDeployment app = (ShellApplicationDeployment) context.getExecutionDescription().getApp();
+ SSHClient ssh = new SSHClient();
+ try {
+
+ initSSHSecurity(context, ssh);
+ ssh.connect(host.getName());
+
+ final Session session = ssh.startSession();
+ try {
+ // TODO: The location of the logDir should be a configurable
+ // parameter.
+ // TODO: This location is easy to lose. Also, why not use
+ // standard logging
+ // TODO: tools for this? Or are these really temporary
+ // directories rather than logs?
File logDir = new File("./service_logs");
if (!logDir.exists()) {
logDir.mkdir();
}
-
// Get the Stdouts and StdErrs
QName x = QName.valueOf(context.getServiceName());
String timeStampedServiceName = GfacUtils.createServiceDirName(x);
@@ -245,7 +284,7 @@ public class SSHProvider extends Abstrac
// set to context
OutputUtils.fillOutputFromStdout(context.<AbstractParameter> getOutput(), stdOutStr, stdErrStr);
- } catch (IOException e) {
+ } catch (ConnectionException e) {
throw e;
} finally {
try {
@@ -264,14 +303,4 @@ public class SSHProvider extends Abstrac
}
}
}
-
- public void dispose(InvocationContext invocationContext) throws GfacException {
- // TODO Auto-generated method stub
- }
-
- public void abort(InvocationContext invocationContext) throws GfacException {
- // TODO Auto-generated method stub
-
- }
-
}
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/utils/GramRSLGenerator.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/utils/GramRSLGenerator.java?rev=1167344&r1=1167343&r2=1167344&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/utils/GramRSLGenerator.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/utils/GramRSLGenerator.java Fri Sep 9 19:58:54 2011
@@ -23,6 +23,7 @@ package org.apache.airavata.core.gfac.pr
import java.util.Iterator;
import java.util.Map;
+import java.util.Map.Entry;
import org.apache.airavata.commons.gfac.type.app.GramApplicationDeployment;
import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
@@ -33,7 +34,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GramRSLGenerator {
- protected final static Logger log = LoggerFactory.getLogger(GramRSLGenerator.class);
+ protected static final Logger log = LoggerFactory.getLogger(GramRSLGenerator.class);
private enum JobType {
SINGLE, MPI, MULTIPLE, CONDOR
@@ -54,8 +55,8 @@ public class GramRSLGenerator {
* documents
*/
Map<String, String> nv = app.getEnv();
- for (String key : nv.keySet()) {
- jobAttr.addEnvVariable(key, nv.get(key));
+ for (Entry<String, String> entry : nv.entrySet()) {
+ jobAttr.addEnvVariable(entry.getKey(), entry.getValue());
}
jobAttr.addEnvVariable(GFacConstants.INPUT_DATA_DIR_VAR_NAME, app.getInputDir());
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/utils/JobSubmissionListener.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/utils/JobSubmissionListener.java?rev=1167344&r1=1167343&r2=1167344&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/utils/JobSubmissionListener.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/utils/JobSubmissionListener.java Fri Sep 9 19:58:54 2011
@@ -116,7 +116,7 @@ public class JobSubmissionListener imple
/*
* Notify status change
*/
- this.context.getExecutionContext().getNotificationService().statusChanged(this, this.context, jobStatusMessage);
+ this.context.getExecutionContext().getNotifier().statusChanged(this, this.context, jobStatusMessage);
/*
* Set new status if it is finished, notify all wait object
Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/AbstractSimpleService.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/AbstractSimpleService.java?rev=1167344&r1=1167343&r2=1167344&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/AbstractSimpleService.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/services/impl/AbstractSimpleService.java Fri Sep 9 19:58:54 2011
@@ -66,9 +66,9 @@ public abstract class AbstractSimpleServ
* Determine provider
*/
Scheduler scheduler = getScheduler(context);
- context.getExecutionContext().getNotificationService().startSchedule(this, context, scheduler);
+ context.getExecutionContext().getNotifier().startSchedule(this, context);
Provider provider = scheduler.schedule(context);
- context.getExecutionContext().getNotificationService().finishSchedule(this, context, scheduler, provider);
+ context.getExecutionContext().getNotifier().finishSchedule(this, context);
log.debug("After scheduling, try to run data chain");
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=1167344&r1=1167343&r2=1167344&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 Fri Sep 9 19:58:54 2011
@@ -110,7 +110,7 @@ public class PropertiesBasedServiceImplT
DefaultInvocationContext ct = new DefaultInvocationContext();
DefaultExecutionContext ec = new DefaultExecutionContext();
- ec.setNotificationService(new LoggingNotification());
+ ec.addNotifiable(new LoggingNotification());
ct.setExecutionContext(ec);
ct.setServiceName("SimpleEcho");