stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nirmal070...@apache.org
Subject [2/2] git commit: Implementing https://issues.apache.org/jira/browse/STRATOS-892
Date Tue, 14 Oct 2014 04:35:34 GMT
Implementing https://issues.apache.org/jira/browse/STRATOS-892


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

Branch: refs/heads/master
Commit: da2c792059a40c2d0b873c347acbbf4db4d2b274
Parents: 8105f27
Author: Nirmal Fernando <nirmal070125@gmail.com>
Authored: Tue Oct 14 10:04:51 2014 +0530
Committer: Nirmal Fernando <nirmal070125@gmail.com>
Committed: Tue Oct 14 10:04:51 2014 +0530

----------------------------------------------------------------------
 .../autoscaler/api/AutoScalerServiceImpl.java   |    2 +-
 .../exception/InvalidArgumentException.java     |   46 +
 .../interfaces/AutoScalerServiceInterface.java  |    2 +-
 .../monitor/AbstractClusterMonitor.java         |    3 +-
 .../KubernetesServiceClusterMonitor.java        |   13 +-
 .../autoscaler/monitor/VMLbClusterMonitor.java  |    3 +-
 .../monitor/VMServiceClusterMonitor.java        |    3 +-
 .../manager/client/AutoscalerServiceClient.java |    2 +-
 .../rest/endpoint/services/ServiceUtils.java    |    9 +-
 .../src/main/resources/AutoScalerService.wsdl   | 1222 +++++++++---------
 10 files changed, 695 insertions(+), 610 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/da2c7920/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 69532b1..4b6b897 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
@@ -327,7 +327,7 @@ public class AutoScalerServiceImpl implements AutoScalerServiceInterface
{
 
     }
 
-    public void updateClusterMonitor(String clusterId, Properties properties) {
+    public void updateClusterMonitor(String clusterId, Properties properties) throws InvalidArgumentException
{
         if (log.isDebugEnabled()) {
             log.debug(String.format("Updating Cluster monitor [Cluster id] %s ", clusterId));
         }

http://git-wip-us.apache.org/repos/asf/stratos/blob/da2c7920/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidArgumentException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidArgumentException.java
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidArgumentException.java
new file mode 100644
index 0000000..79492a7
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidArgumentException.java
@@ -0,0 +1,46 @@
+/*
+ * 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.stratos.autoscaler.exception;
+
+public class InvalidArgumentException extends Exception {
+
+    private static final long serialVersionUID = -43882156675116287L;
+    private String message;
+	
+	public InvalidArgumentException(String message) {
+		super(message);
+		this.message = message;
+	}
+	
+	public InvalidArgumentException(String message,Throwable e) {
+		super(message,e);
+		this.message = message;
+	}
+	
+	public InvalidArgumentException(Throwable e) {
+		super(e);
+	}
+	
+	@Override
+	public String getMessage() {
+		return message;
+	}
+	
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/da2c7920/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java
index fe2801d..2f88581 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java
@@ -184,5 +184,5 @@ public interface AutoScalerServiceInterface {
      * @param clusterId id of the cluster.
      * @param properties updated properties.
      */
-    void updateClusterMonitor(String clusterId, Properties properties);
+    void updateClusterMonitor(String clusterId, Properties properties) throws InvalidArgumentException;
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/da2c7920/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
index 774fd2e..972ddad 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
@@ -22,6 +22,7 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.stratos.autoscaler.exception.InvalidArgumentException;
 import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;
 import org.apache.stratos.cloud.controller.stub.pojo.Properties;
 import org.apache.stratos.messaging.domain.topology.ClusterStatus;
@@ -159,7 +160,7 @@ public abstract class AbstractClusterMonitor implements Runnable {
 
     public abstract void handleClusterRemovedEvent(ClusterRemovedEvent clusterRemovedEvent);
     
-    public abstract void handleDynamicUpdates(Properties properties);
+    public abstract void handleDynamicUpdates(Properties properties) throws InvalidArgumentException;
 
     public String getClusterId() {
         return clusterId;

http://git-wip-us.apache.org/repos/asf/stratos/blob/da2c7920/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/KubernetesServiceClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/KubernetesServiceClusterMonitor.java
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/KubernetesServiceClusterMonitor.java
index 3d47296..8abcf33 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/KubernetesServiceClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/KubernetesServiceClusterMonitor.java
@@ -27,6 +27,7 @@ import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.KubernetesClusterContext;
+import org.apache.stratos.autoscaler.exception.InvalidArgumentException;
 import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
 import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;
 import org.apache.stratos.autoscaler.util.AutoScalerConstants;
@@ -168,7 +169,7 @@ public final class KubernetesServiceClusterMonitor extends KubernetesClusterMoni
     }
 
     @Override
-    public void handleDynamicUpdates(Properties properties) {
+    public void handleDynamicUpdates(Properties properties) throws InvalidArgumentException
{
         
         if (properties != null) {
             Property[] propertyArray = properties.getProperties();
@@ -182,7 +183,15 @@ public final class KubernetesServiceClusterMonitor extends KubernetesClusterMoni
                 String value = property.getValue();
                 
                 if (StratosConstants.KUBERNETES_MIN_REPLICAS.equals(key)) {
-                    getKubernetesClusterCtxt().setMinReplicas(Integer.parseInt(value));
+                    int min = Integer.parseInt(value);
+                    int max = getKubernetesClusterCtxt().getMaxReplicas();
+                    if (min > max) {
+                        String msg = String.format("%s should be less than %s . But %s is
not less than %s.", 
+                                StratosConstants.KUBERNETES_MIN_REPLICAS, StratosConstants.KUBERNETES_MAX_REPLICAS,
min, max);
+                        log.error(msg);
+                        throw new InvalidArgumentException(msg);
+                    }
+                    getKubernetesClusterCtxt().setMinReplicas(min);
                     break;
                 }
             }

http://git-wip-us.apache.org/repos/asf/stratos/blob/da2c7920/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMLbClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMLbClusterMonitor.java
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMLbClusterMonitor.java
index 112f7ba..af8cf47 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMLbClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMLbClusterMonitor.java
@@ -28,6 +28,7 @@ import org.apache.stratos.autoscaler.NetworkPartitionContext;
 import org.apache.stratos.autoscaler.NetworkPartitionLbHolder;
 import org.apache.stratos.autoscaler.PartitionContext;
 import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
+import org.apache.stratos.autoscaler.exception.InvalidArgumentException;
 import org.apache.stratos.autoscaler.partition.PartitionManager;
 import org.apache.stratos.autoscaler.policy.PolicyManager;
 import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
@@ -167,7 +168,7 @@ public class VMLbClusterMonitor extends VMClusterMonitor {
     }
 
     @Override
-    public void handleDynamicUpdates(Properties properties) {
+    public void handleDynamicUpdates(Properties properties) throws InvalidArgumentException
{
         // TODO 
         
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/da2c7920/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMServiceClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMServiceClusterMonitor.java
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMServiceClusterMonitor.java
index e102ee9..6492490 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMServiceClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMServiceClusterMonitor.java
@@ -28,6 +28,7 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.NetworkPartitionContext;
 import org.apache.stratos.autoscaler.PartitionContext;
 import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
+import org.apache.stratos.autoscaler.exception.InvalidArgumentException;
 import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
 import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;
 import org.apache.stratos.autoscaler.util.AutoScalerConstants;
@@ -227,7 +228,7 @@ public class VMServiceClusterMonitor extends VMClusterMonitor {
     }
 
     @Override
-    public void handleDynamicUpdates(Properties properties) {
+    public void handleDynamicUpdates(Properties properties) throws InvalidArgumentException
{
         // TODO 
         
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/da2c7920/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
index 8445095..cd35075 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
@@ -265,7 +265,7 @@ public class AutoscalerServiceClient {
         return stub.updateKubernetesHost(kubernetesHost);
     }
     
-    public void updateClusterMonitor(String clusterId, Properties properties) throws RemoteException
{
+    public void updateClusterMonitor(String clusterId, Properties properties) throws RemoteException,
AutoScalerServiceInvalidArgumentExceptionException {
         stub.updateClusterMonitor(clusterId, properties);
     }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/da2c7920/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
index 461a5f7..14c5331 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
@@ -1491,8 +1491,13 @@ public class ServiceUtils {
                 if (property != null) {
                     autoscalerServiceClient.updateClusterMonitor(cluster.getClusterId(),
PojoConverter.getProperties(property));
                 }
-            } catch(Exception e) {
-                log.error(e.getMessage(), e);
+            } catch(AutoScalerServiceInvalidArgumentExceptionException e) {
+                String message = e.getFaultMessage().getInvalidArgumentException().getMessage();
+                log.error(message, e);
+                throw new RestAPIException(message, e);
+            } catch (RemoteException e) {
+                String msg = "Error while connecting to Autoscaler Service. "+e.getMessage();
+                log.error(msg, e);
                 throw new RestAPIException(e.getMessage(), e);
             }
         }


Mime
View raw message