You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ra...@apache.org on 2015/01/05 08:27:27 UTC
stratos git commit: fixing NPE while undeploying application
Repository: stratos
Updated Branches:
refs/heads/master c028eaa4c -> e8df5e522
fixing NPE while undeploying application
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/e8df5e52
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/e8df5e52
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/e8df5e52
Branch: refs/heads/master
Commit: e8df5e52229501f8f8722aec144f3d8b03f4aef2
Parents: c028eaa
Author: raj <ra...@apache.org>
Authored: Mon Jan 5 12:57:05 2015 +0530
Committer: raj <ra...@apache.org>
Committed: Mon Jan 5 12:57:05 2015 +0530
----------------------------------------------------------------------
.../stratos/autoscaler/api/AutoScalerServiceImpl.java | 12 ++++++++++++
.../stratos/rest/endpoint/api/StratosApiV41Utils.java | 12 ++++++++++++
2 files changed, 24 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/e8df5e52/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
index 1cfa180..75e53f5 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
@@ -291,6 +291,18 @@ public class AutoScalerServiceImpl implements AutoScalerServiceInterface {
log.info("Starting to undeploy application: [application-id] " + applicationId);
}
+ ApplicationContext application = AutoscalerContext.getInstance().getApplicationContext(applicationId);
+ if ( application == null){
+ String msg = String.format("Application not found : [application-id] %s", applicationId);
+ throw new RuntimeException(msg);
+ }
+
+ if (!application.getStatus().equals(ApplicationContext.STATUS_DEPLOYED)) {
+ String message = String.format("Application is not deployed: [application-id] %s", applicationId);
+ log.error(message);
+ throw new RuntimeException(message);
+ }
+
ApplicationBuilder.handleApplicationUndeployed(applicationId);
ApplicationContext applicationContext = AutoscalerContext.getInstance().getApplicationContext(applicationId);
http://git-wip-us.apache.org/repos/asf/stratos/blob/e8df5e52/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
index edf17b9..10c146b 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
@@ -959,6 +959,18 @@ public class StratosApiV41Utils {
AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
if (autoscalerServiceClient != null) {
try {
+ ApplicationContext application = autoscalerServiceClient.getApplication(applicationId);
+ if(application == null) {
+ String message = String.format("Application is not found: [application-id] %s", applicationId);
+ log.error(message);
+ throw new RestAPIException(message);
+ }
+ if (!application.getStatus().equals(APPLICATION_STATUS_DEPLOYED)) {
+ String message = String.format("Application is not deployed: [application-id] %s", applicationId);
+ log.error(message);
+ throw new RestAPIException(message);
+ }
+
autoscalerServiceClient.undeployApplication(applicationId);
} catch (RemoteException e) {
String message = "Could not undeploy application: [application-id] " + applicationId;