You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ch...@apache.org on 2014/05/20 18:00:03 UTC
git commit: fixing AIRAVATA-1242
Repository: airavata
Updated Branches:
refs/heads/master 23c118418 -> 054093f36
fixing AIRAVATA-1242
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/054093f3
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/054093f3
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/054093f3
Branch: refs/heads/master
Commit: 054093f369dff258f9c3782a2d1bf165908be881
Parents: 23c1184
Author: Chathuri Wimalasena <ka...@gmail.com>
Authored: Tue May 20 11:59:55 2014 -0400
Committer: Chathuri Wimalasena <ka...@gmail.com>
Committed: Tue May 20 11:59:55 2014 -0400
----------------------------------------------------------------------
.../server/handler/AiravataServerHandler.java | 144 ++++++++++++++++---
.../client/samples/CreateLaunchExperiment.java | 18 ++-
2 files changed, 138 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/054093f3/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
index 15b1009..f1cdaaa 100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
@@ -148,10 +148,10 @@ public class AiravataServerHandler implements Airavata.Iface {
}
return projects;
} catch (RegistryException e) {
- logger.error("Error while updating the project", e);
+ logger.error("Error while retrieving projects", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while updating the project. More info : " + e.getMessage());
+ exception.setMessage("Error while retrieving projects. More info : " + e.getMessage());
throw exception;
}
}
@@ -317,7 +317,37 @@ public class AiravataServerHandler implements Airavata.Iface {
if (!registry.isExist(RegistryModelType.EXPERIMENT, airavataExperimentId)){
throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system..");
}
- registry.update(RegistryModelType.EXPERIMENT, experiment, airavataExperimentId);
+ ExperimentStatus experimentStatus = getExperimentStatus(airavataExperimentId);
+ if (experimentStatus != null){
+ ExperimentState experimentState = experimentStatus.getExperimentState();
+ switch (experimentState){
+ case CREATED:
+ registry.update(RegistryModelType.EXPERIMENT, experiment, airavataExperimentId);
+ break;
+ case VALIDATED:
+ registry.update(RegistryModelType.EXPERIMENT, experiment, airavataExperimentId);
+ break;
+ case CANCELED:
+ registry.update(RegistryModelType.EXPERIMENT, experiment, airavataExperimentId);
+ break;
+ case FAILED:
+ registry.update(RegistryModelType.EXPERIMENT, experiment, airavataExperimentId);
+ break;
+ case UNKNOWN:
+ registry.update(RegistryModelType.EXPERIMENT, experiment, airavataExperimentId);
+ break;
+ default:
+ logger.error("Error while updating experiment. Update experiment is only valid for experiments " +
+ "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given " +
+ "experiment is in one of above statuses... ");
+ AiravataSystemException exception = new AiravataSystemException();
+ exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+ exception.setMessage("Error while updating experiment. Update experiment is only valid for experiments " +
+ "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given " +
+ "experiment is in one of above statuses... ");
+ throw exception;
+ }
+ }
} catch (Exception e) {
logger.error("Error while updating experiment", e);
AiravataSystemException exception = new AiravataSystemException();
@@ -334,12 +364,45 @@ public class AiravataServerHandler implements Airavata.Iface {
if (!registry.isExist(RegistryModelType.EXPERIMENT, airavataExperimentId)){
throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system..");
}
- registry.add(ChildDataType.EXPERIMENT_CONFIGURATION_DATA, userConfiguration, airavataExperimentId);
+ ExperimentStatus experimentStatus = getExperimentStatus(airavataExperimentId);
+ if (experimentStatus != null){
+ ExperimentState experimentState = experimentStatus.getExperimentState();
+ switch (experimentState){
+ case CREATED:
+ registry.add(ChildDataType.EXPERIMENT_CONFIGURATION_DATA, userConfiguration, airavataExperimentId);
+ break;
+ case VALIDATED:
+ registry.add(ChildDataType.EXPERIMENT_CONFIGURATION_DATA, userConfiguration, airavataExperimentId);
+ break;
+ case CANCELED:
+ registry.add(ChildDataType.EXPERIMENT_CONFIGURATION_DATA, userConfiguration, airavataExperimentId);
+ break;
+ case FAILED:
+ registry.add(ChildDataType.EXPERIMENT_CONFIGURATION_DATA, userConfiguration, airavataExperimentId);
+ break;
+ case UNKNOWN:
+ registry.add(ChildDataType.EXPERIMENT_CONFIGURATION_DATA, userConfiguration, airavataExperimentId);
+ break;
+ default:
+ logger.error("Error while updating experiment. Update experiment is only valid for experiments " +
+ "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given " +
+ "experiment is in one of above statuses... ");
+ AiravataSystemException exception = new AiravataSystemException();
+ exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+ exception.setMessage("Error while updating experiment. Update experiment is only valid for experiments " +
+ "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given " +
+ "experiment is in one of above statuses... ");
+ throw exception;
+ }
+ }
} catch (Exception e) {
logger.error("Error while updating user configuration", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while updating user configuration. More info : " + e.getMessage());
+ exception.setMessage("Error while updating user configuration. " +
+ "Update experiment is only valid for experiments " +
+ "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given " +
+ "experiment is in one of above statuses... " + e.getMessage());
throw exception;
}
}
@@ -351,12 +414,45 @@ public class AiravataServerHandler implements Airavata.Iface {
if (!registry.isExist(RegistryModelType.EXPERIMENT, airavataExperimentId)){
throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system..");
}
- registry.add(ChildDataType.COMPUTATIONAL_RESOURCE_SCHEDULING, resourceScheduling, airavataExperimentId);
+ ExperimentStatus experimentStatus = getExperimentStatus(airavataExperimentId);
+ if (experimentStatus != null){
+ ExperimentState experimentState = experimentStatus.getExperimentState();
+ switch (experimentState){
+ case CREATED:
+ registry.add(ChildDataType.COMPUTATIONAL_RESOURCE_SCHEDULING, resourceScheduling, airavataExperimentId);
+ break;
+ case VALIDATED:
+ registry.add(ChildDataType.COMPUTATIONAL_RESOURCE_SCHEDULING, resourceScheduling, airavataExperimentId);
+ break;
+ case CANCELED:
+ registry.add(ChildDataType.COMPUTATIONAL_RESOURCE_SCHEDULING, resourceScheduling, airavataExperimentId);
+ break;
+ case FAILED:
+ registry.add(ChildDataType.COMPUTATIONAL_RESOURCE_SCHEDULING, resourceScheduling, airavataExperimentId);
+ break;
+ case UNKNOWN:
+ registry.add(ChildDataType.COMPUTATIONAL_RESOURCE_SCHEDULING, resourceScheduling, airavataExperimentId);
+ break;
+ default:
+ logger.error("Error while updating scheduling info. Update experiment is only valid for experiments " +
+ "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given " +
+ "experiment is in one of above statuses... ");
+ AiravataSystemException exception = new AiravataSystemException();
+ exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+ exception.setMessage("Error while updating experiment. Update experiment is only valid for experiments " +
+ "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given " +
+ "experiment is in one of above statuses... ");
+ throw exception;
+ }
+ }
} catch (Exception e) {
logger.error("Error while updating scheduling info", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while updating scheduling info. More info : " + e.getMessage());
+ exception.setMessage("Error while updating scheduling info. " +
+ "Update experiment is only valid for experiments " +
+ "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given " +
+ "experiment is in one of above statuses... " + e.getMessage());
throw exception;
}
}
@@ -390,25 +486,31 @@ public class AiravataServerHandler implements Airavata.Iface {
* @throws org.apache.airavata.model.error.InvalidRequestException For any incorrect forming of the request itself.
* @throws org.apache.airavata.model.error.ExperimentNotFoundException If the specified experiment is not previously created, then an Experiment Not Found Exception is thrown.
* @throws org.apache.airavata.model.error.AiravataClientException The following list of exceptions are thrown which Airavata Client can take corrective actions to resolve:
- * <p/>
- * UNKNOWN_GATEWAY_ID - If a Gateway is not registered with Airavata as a one time administrative
- * step, then Airavata Registry will not have a provenance area setup. The client has to follow
- * gateway registration steps and retry this request.
- * <p/>
- * AUTHENTICATION_FAILURE - How Authentication will be implemented is yet to be determined.
- * For now this is a place holder.
- * <p/>
- * INVALID_AUTHORIZATION - This will throw an authorization exception. When a more robust security hand-shake
- * is implemented, the authorization will be more substantial.
- * @throws org.apache.airavata.model.error.AiravataSystemException This exception will be thrown for any Airavata Server side issues and if the problem cannot be corrected by the client
- * rather an Airavata Administrator will be notified to take corrective action.
+ *<p/>
+ *UNKNOWN_GATEWAY_ID - If a Gateway is not registered with Airavata as a one time administrative
+ *step, then Airavata Registry will not have a provenance area setup. The client has to follow
+ *gateway registration steps and retry this request.
+ *<p/>
+ *AUTHENTICATION_FAILURE - How Authentication will be implemented is yet to be determined.
+ *For now this is a place holder.
+ *<p/>
+ *INVALID_AUTHORIZATION - This will throw an authorization exception. When a more robust security hand-shake
+ *is implemented, the authorization will be more substantial.
+ * @throws org.apache.airavata.model.error.AiravataSystemException This exception will be thrown for any
+ * Airavata Server side issues and if the problem cannot be corrected by the client
+ * rather an Airavata Administrator will be notified to take corrective action.
*/
@Override
- public ExperimentStatus getExperimentStatus(String airavataExperimentId) throws InvalidRequestException, ExperimentNotFoundException, AiravataClientException, AiravataSystemException, TException {
+ public ExperimentStatus getExperimentStatus(String airavataExperimentId) throws InvalidRequestException,
+ ExperimentNotFoundException,
+ AiravataClientException,
+ AiravataSystemException,
+ TException {
try {
registry = RegistryFactory.getDefaultRegistry();
if (!registry.isExist(RegistryModelType.EXPERIMENT, airavataExperimentId)){
- throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system..");
+ throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId +
+ " does not exist in the system..");
}
return (ExperimentStatus)registry.get(RegistryModelType.EXPERIMENT_STATUS, airavataExperimentId);
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/airavata/blob/054093f3/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 c4f866a..927fa7f 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
@@ -69,16 +69,17 @@ public class CreateLaunchExperiment {
// final String expId = createExperimentForStampede(airavata);
final String expId = createExperimentForLocalHost(airavata);
System.out.println("Experiment ID : " + expId);
-
+ updateExperiment(airavata, expId);
launchExperiment(airavata, expId);
System.out.println("Launched successfully");
List<Experiment> experiments = getExperimentsForUser(airavata, "admin");
List<Project> projects = getAllUserProject(airavata, "admin");
for (Experiment exp : experiments){
System.out.println(" exp id : " + exp.getExperimentID());
- System.out.println(" exp status : " + exp.getExperimentStatus().getExperimentState().toString());
+ if (exp.getExperimentStatus() != null) {
+ System.out.println(" exp status : " + exp.getExperimentStatus().getExperimentState().toString());
+ }
}
-
for (Project pr : projects){
System.out.println(" project name : " + pr.getName());
}
@@ -227,6 +228,17 @@ public class CreateLaunchExperiment {
}
}
+ public static void updateExperiment(Airavata.Client client, String expId) throws TException {
+ try{
+ Experiment experiment = client.getExperiment(expId);
+ experiment.setDescription("updatedDescription");
+ client.updateExperiment(expId, experiment );
+ }catch (TException e) {
+ logger.error("Error occured while creating the experiment...", e.getMessage());
+ throw new TException(e);
+ }
+ }
+
public static String createExperimentForLocalHost(Airavata.Client client) throws TException {
try{