airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject airavata git commit: fixing priority order logic and NPE in monitor - AIRAVATA-1820
Date Wed, 02 Sep 2015 20:17:41 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 55aa6dfa0 -> 6938f907f


fixing priority order logic and NPE in monitor - AIRAVATA-1820


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/6938f907
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/6938f907
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/6938f907

Branch: refs/heads/master
Commit: 6938f907f6d994a84f0ed6cd02291ed828211ca9
Parents: 55aa6df
Author: Chathuri Wimalasena <chathuri@apache.org>
Authored: Wed Sep 2 16:17:32 2015 -0400
Committer: Chathuri Wimalasena <chathuri@apache.org>
Committed: Wed Sep 2 16:17:32 2015 -0400

----------------------------------------------------------------------
 .../client/samples/CreateLaunchExperiment.java  | 20 ++++++------
 .../apache/airavata/gfac/core/GFacUtils.java    | 32 +++++++++++++++++---
 .../gfac/monitor/email/EmailBasedMonitor.java   | 22 ++++++++------
 3 files changed, 50 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/6938f907/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
index a510504..2d045bd 100644
--- a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
+++ b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
@@ -48,7 +48,7 @@ import java.util.*;
 public class CreateLaunchExperiment {
 
     //FIXME: Read from a config file
-    public static final String THRIFT_SERVER_HOST = "localhost";
+    public static final String THRIFT_SERVER_HOST = "gw56.iu.xsede.org";
     public static final int THRIFT_SERVER_PORT = 8930;
 //	public static final String THRIFT_SERVER_HOST = "gw111.iu.xsede.org";
 //	public static final int THRIFT_SERVER_PORT = 9930;
@@ -58,7 +58,7 @@ public class CreateLaunchExperiment {
     public static final String DEFAULT_GATEWAY = "default";
     private static Airavata.Client airavataClient;
 
-    private static String echoAppId = "Echo_b730bf47-6a22-44ac-91f3-91bd463bd627";
+    private static String echoAppId = "Python_Echo_069ea651-4937-4b89-9684-fb0682ac52f5";
     private static String mpiAppId = "HelloMPI_71b6f45e-40c2-46e9-a417-160b2640fcb9";
     private static String wrfAppId = "WRF_7ad5da38-c08b-417c-a9ea-da9298839762";
     private static String amberAppId = "Amber_74ad818e-7633-476a-b861-952de9b0a529";
@@ -967,19 +967,19 @@ public class CreateLaunchExperiment {
     public static String createEchoExperimentForStampede(Airavata.Client client) throws TException
{
         try {
             List<InputDataObjectType> exInputs = client.getApplicationInputs(new AuthzToken(""),
echoAppId);
-            for (InputDataObjectType inputDataObjectType : exInputs) {
-                if (inputDataObjectType.getName().equalsIgnoreCase("Input_to_Echo")) {
-                    inputDataObjectType.setValue("Hello World");
-                }
-            }
-            List<OutputDataObjectType> exOut = client.getApplicationOutputs(new AuthzToken(""),
echoAppId);
+//            for (InputDataObjectType inputDataObjectType : exInputs) {
+//                if (inputDataObjectType.getName().equalsIgnoreCase("Input_to_Echo")) {
+//                    inputDataObjectType.setValue("Hello World");
+//                }
+//            }
+//            List<OutputDataObjectType> exOut = client.getApplicationOutputs(new AuthzToken(""),
echoAppId);
 
             Project project = ProjectModelUtil.createProject("default", "admin", "test project");
 	        String projectId = client.createProject(new AuthzToken(""), DEFAULT_GATEWAY, project);
 
             ExperimentModel simpleExperiment =
                     ExperimentModelUtil.createSimpleExperiment(DEFAULT_GATEWAY,projectId,
"admin", "echoExperiment", "SimpleEcho3", echoAppId, exInputs);
-            simpleExperiment.setExperimentOutputs(exOut);
+//            simpleExperiment.setExperimentOutputs(exOut);
 
             Map<String, String> computeResources = airavataClient.getAvailableAppInterfaceComputeResources(new
AuthzToken(""), echoAppId);
             if (computeResources != null && computeResources.size() != 0) {
@@ -1441,7 +1441,7 @@ public class CreateLaunchExperiment {
     public static void launchExperiment(Airavata.Client client, String expId)
             throws TException {
         try {
-            String tokenId = "-0bbb-403b-a88a-42b6dbe198e9";
+            String tokenId = "47507a08-1579-4883-be03-3c8e3b7da061";
             client.launchExperiment(new AuthzToken(""), expId, tokenId);
         } catch (ExperimentNotFoundException e) {
             logger.error("Error occured while launching the experiment...", e.getMessage());

http://git-wip-us.apache.org/repos/asf/airavata/blob/6938f907/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/GFacUtils.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/GFacUtils.java
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/GFacUtils.java
index cbc0c0b..5880fcc 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/GFacUtils.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/GFacUtils.java
@@ -29,8 +29,6 @@ import org.apache.airavata.credential.store.store.CredentialReader;
 import org.apache.airavata.credential.store.store.impl.CredentialReaderImpl;
 import org.apache.airavata.gfac.core.context.ProcessContext;
 import org.apache.airavata.gfac.core.context.TaskContext;
-import org.apache.airavata.gfac.core.watcher.CancelRequestWatcher;
-import org.apache.airavata.gfac.core.watcher.RedeliveryRequestWatcher;
 import org.apache.airavata.messaging.core.MessageContext;
 import org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription;
 import org.apache.airavata.model.appcatalog.appdeployment.ApplicationParallelismType;
@@ -1008,10 +1006,36 @@ public class GFacUtils {
     public static JobSubmissionInterface getPreferredJobSubmissionInterface(ProcessContext
context) throws AppCatalogException {
         try {
             String resourceHostId = context.getComputeResourceDescription().getComputeResourceId();
+            ComputeResourcePreference resourcePreference = context.getComputeResourcePreference();
+            JobSubmissionProtocol preferredJobSubmissionProtocol = resourcePreference.getPreferredJobSubmissionProtocol();
             ComputeResourceDescription resourceDescription = context.getAppCatalog().getComputeResource().getComputeResource(resourceHostId);
             List<JobSubmissionInterface> jobSubmissionInterfaces = resourceDescription.getJobSubmissionInterfaces();
+            Map<JobSubmissionProtocol, List<JobSubmissionInterface>> orderedInterfaces
= new HashMap<>();
+            List<JobSubmissionInterface> interfaces = new ArrayList<>();
             if (jobSubmissionInterfaces != null && !jobSubmissionInterfaces.isEmpty())
{
-                Collections.sort(jobSubmissionInterfaces, new Comparator<JobSubmissionInterface>()
{
+                for (JobSubmissionInterface submissionInterface : jobSubmissionInterfaces){
+
+                    if (preferredJobSubmissionProtocol != null){
+                        if (preferredJobSubmissionProtocol.toString().equals(submissionInterface.getJobSubmissionProtocol().toString())){
+                            if (orderedInterfaces.containsKey(submissionInterface.getJobSubmissionProtocol())){
+                                List<JobSubmissionInterface> interfaceList = orderedInterfaces.get(submissionInterface.getJobSubmissionProtocol());
+                                interfaceList.add(submissionInterface);
+                            }else {
+                                interfaces.add(submissionInterface);
+                                orderedInterfaces.put(submissionInterface.getJobSubmissionProtocol(),
interfaces);
+                            }
+                        }
+                    }else {
+                        Collections.sort(jobSubmissionInterfaces, new Comparator<JobSubmissionInterface>()
{
+                            @Override
+                            public int compare(JobSubmissionInterface jobSubmissionInterface,
JobSubmissionInterface jobSubmissionInterface2) {
+                                return jobSubmissionInterface.getPriorityOrder() - jobSubmissionInterface2.getPriorityOrder();
+                            }
+                        });
+                    }
+                }
+                interfaces = orderedInterfaces.get(preferredJobSubmissionProtocol);
+                Collections.sort(interfaces, new Comparator<JobSubmissionInterface>()
{
                     @Override
                     public int compare(JobSubmissionInterface jobSubmissionInterface, JobSubmissionInterface
jobSubmissionInterface2) {
                         return jobSubmissionInterface.getPriorityOrder() - jobSubmissionInterface2.getPriorityOrder();
@@ -1020,7 +1044,7 @@ public class GFacUtils {
             } else {
                 throw new AppCatalogException("Compute resource should have at least one
job submission interface defined...");
             }
-            return jobSubmissionInterfaces.get(0);
+            return interfaces.get(0);
         } catch (AppCatalogException e) {
             throw new AppCatalogException("Error occurred while retrieving data from app
catalog", e);
         }

http://git-wip-us.apache.org/repos/asf/airavata/blob/6938f907/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/EmailBasedMonitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/EmailBasedMonitor.java
b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/EmailBasedMonitor.java
index bd0b541..616373d 100644
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/EmailBasedMonitor.java
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/EmailBasedMonitor.java
@@ -103,16 +103,18 @@ public class EmailBasedMonitor implements JobMonitor, Runnable{
 			ResourceJobManagerType type = resourceConfigEntry.getKey();
 			ResourceConfig config = resourceConfigEntry.getValue();
 			List<String> resourceEmailAddresses = config.getResourceEmailAddresses();
-			for (String resourceEmailAddress : resourceEmailAddresses) {
-				addressMap.put(resourceEmailAddress, type);
-			}
-			try {
-				Class<? extends EmailParser> emailParserClass = Class.forName(config.getEmailParser()).asSubclass(EmailParser.class);
-				EmailParser emailParser = emailParserClass.getConstructor().newInstance();
-				emailParserMap.put(type, emailParser);
-			} catch (Exception e) {
-				throw new AiravataException("Error while instantiation email parsers", e);
-			}
+            if (resourceEmailAddresses != null && !resourceEmailAddresses.isEmpty()){
+                for (String resourceEmailAddress : resourceEmailAddresses) {
+                    addressMap.put(resourceEmailAddress, type);
+                }
+                try {
+                    Class<? extends EmailParser> emailParserClass = Class.forName(config.getEmailParser()).asSubclass(EmailParser.class);
+                    EmailParser emailParser = emailParserClass.getConstructor().newInstance();
+                    emailParserMap.put(type, emailParser);
+                } catch (Exception e) {
+                    throw new AiravataException("Error while instantiation email parsers",
e);
+                }
+            }
 		}
 
 	}


Mime
View raw message