Refactored - licenses and comments added
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/df147953 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/df147953 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/df147953 Branch: refs/heads/master Commit: df1479535afd44cd04b89216852b2e74a71733e9 Parents: 85c0ea4 Author: R-Rajkumar <[email protected]> Authored: Wed Oct 1 13:45:46 2014 +0530 Committer: Akila Perera <[email protected]> Committed: Wed Oct 1 13:59:36 2014 +0530 ---------------------------------------------------------------------- .../stratos/autoscaler/AutoscalerContext.java | 2 +- .../autoscaler/KubernetesClusterContext.java | 73 ++++---- .../cloud/controller/CloudControllerClient.java | 6 + .../AutoscalerHealthStatEventReceiver.java | 174 +++++++++++-------- .../AutoscalerTopologyEventReceiver.java | 59 ++++--- .../monitor/AbstractClusterMonitor.java | 21 +++ .../monitor/ClusterMonitorFactory.java | 32 +++- .../monitor/ContainerClusterMonitor.java | 21 +++ .../monitor/DockerServiceClusterMonitor.java | 22 ++- 9 files changed, 284 insertions(+), 126 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/df147953/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java index 18003d8..581d633 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java @@ -28,7 +28,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; /** - * This class is there for accumulating cluster details which are not there in Topology + * It holds all cluster monitors which are active in stratos. */ public class AutoscalerContext { http://git-wip-us.apache.org/repos/asf/stratos/blob/df147953/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/KubernetesClusterContext.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/KubernetesClusterContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/KubernetesClusterContext.java index fa09e8a..16bc653 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/KubernetesClusterContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/KubernetesClusterContext.java @@ -1,3 +1,21 @@ +/* + * 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; import java.io.Serializable; @@ -19,6 +37,9 @@ import org.apache.stratos.autoscaler.policy.model.RequestsInFlight; import org.apache.stratos.autoscaler.util.ConfUtil; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; +/* + * It holds the runtime data of a kubernetes cluster + */ public class KubernetesClusterContext implements Serializable{ private static final long serialVersionUID = 808741789615481596L; @@ -54,13 +75,14 @@ public class KubernetesClusterContext implements Serializable{ private String clusterId; //boolean values to keep whether the requests in flight parameters are reset or not - private boolean rifReset = false, averageRifReset = false, gradientRifReset = false, secondDerivativeRifRest = false; + private boolean rifReset = false, averageRifReset = false, + gradientRifReset = false, secondDerivativeRifRest = false; //boolean values to keep whether the memory consumption parameters are reset or not private boolean memoryConsumptionReset = false, averageMemoryConsumptionReset = false, gradientMemoryConsumptionReset = false, secondDerivativeMemoryConsumptionRest = false; //boolean values to keep whether the load average parameters are reset or not - private boolean loadAverageReset = false, averageLoadAverageReset = false, gradientLoadAverageReset = false, - secondDerivativeLoadAverageRest = false; + private boolean loadAverageReset = false, averageLoadAverageReset = false, + gradientLoadAverageReset = false, secondDerivativeLoadAverageRest = false; public KubernetesClusterContext(String kubernetesClusterId, String clusterId){ this.kubernetesClusterId = kubernetesClusterId; @@ -316,9 +338,8 @@ public class KubernetesClusterContext implements Serializable{ if (secondDerivativeRifRest && gradientRifReset) { rifReset = true; if (log.isDebugEnabled()) { - log.debug(String - .format("Requests in flights stats are reset, ready to do scale check [kub cluster] %s", - this.kubernetesClusterId)); + log.debug(String.format("Requests in flights stats are reset, " + + "ready to do scale check [kub cluster] %s", this.kubernetesClusterId)); } } } @@ -334,9 +355,8 @@ public class KubernetesClusterContext implements Serializable{ if (averageRifReset && gradientRifReset) { rifReset = true; if (log.isDebugEnabled()) { - log.debug(String - .format("Requests in flights stats are reset, ready to do scale check [kub cluster] %s", - this.kubernetesClusterId)); + log.debug(String.format("Requests in flights stats are reset, ready to do scale check " + + "[kub cluster] %s", this.kubernetesClusterId)); } } } @@ -351,9 +371,8 @@ public class KubernetesClusterContext implements Serializable{ if (secondDerivativeRifRest && averageRifReset) { rifReset = true; if (log.isDebugEnabled()) { - log.debug(String - .format("Requests in flights stats are reset, ready to do scale check [kub cluster] %s", - this.kubernetesClusterId)); + log.debug(String.format("Requests in flights stats are reset, ready to do scale check " + + "[kub cluster] %s", this.kubernetesClusterId)); } } } @@ -380,9 +399,8 @@ public class KubernetesClusterContext implements Serializable{ && gradientMemoryConsumptionReset) { memoryConsumptionReset = true; if (log.isDebugEnabled()) { - log.debug(String - .format("Memory consumption stats are reset, ready to do scale check [kub cluster] %s", - this.kubernetesClusterId)); + log.debug(String.format("Memory consumption stats are reset, ready to do scale check " + + "[kub cluster] %s", this.kubernetesClusterId)); } } } @@ -399,9 +417,8 @@ public class KubernetesClusterContext implements Serializable{ if (averageMemoryConsumptionReset && gradientMemoryConsumptionReset) { memoryConsumptionReset = true; if (log.isDebugEnabled()) { - log.debug(String - .format("Memory consumption stats are reset, ready to do scale check [kub cluster] %s", - this.kubernetesClusterId)); + log.debug(String.format("Memory consumption stats are reset, ready to do scale check " + + "[kub cluster] %s", this.kubernetesClusterId)); } } } @@ -417,9 +434,8 @@ public class KubernetesClusterContext implements Serializable{ && averageMemoryConsumptionReset) { memoryConsumptionReset = true; if (log.isDebugEnabled()) { - log.debug(String - .format("Memory consumption stats are reset, ready to do scale check [kub cluster] %s", - this.kubernetesClusterId)); + log.debug(String.format("Memory consumption stats are reset, ready to do scale check " + + "[kub cluster] %s", this.kubernetesClusterId)); } } } @@ -446,9 +462,8 @@ public class KubernetesClusterContext implements Serializable{ if (secondDerivativeLoadAverageRest && gradientLoadAverageReset) { loadAverageReset = true; if (log.isDebugEnabled()) { - log.debug(String - .format("Load average stats are reset, ready to do scale check [kub cluster] %s", - this.kubernetesClusterId)); + log.debug(String.format("Load average stats are reset, ready to do scale check " + + "[kub cluster] %s", this.kubernetesClusterId)); } } } @@ -463,9 +478,8 @@ public class KubernetesClusterContext implements Serializable{ if (averageLoadAverageReset && gradientLoadAverageReset) { loadAverageReset = true; if (log.isDebugEnabled()) { - log.debug(String - .format("Load average stats are reset, ready to do scale check [kub cluster] %s", - this.kubernetesClusterId)); + log.debug(String.format("Load average stats are reset, ready to do scale check " + + "[kub cluster] %s", this.kubernetesClusterId)); } } } @@ -480,9 +494,8 @@ public class KubernetesClusterContext implements Serializable{ if (secondDerivativeLoadAverageRest && averageLoadAverageReset) { loadAverageReset = true; if (log.isDebugEnabled()) { - log.debug(String - .format("Load average stats are reset, ready to do scale check [kub cluster] %s", - this.kubernetesClusterId)); + log.debug(String.format("Load average stats are reset, ready to do scale check " + + "[kub cluster] %s", this.kubernetesClusterId)); } } } http://git-wip-us.apache.org/repos/asf/stratos/blob/df147953/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java index 2efca75..d554cec 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java @@ -233,6 +233,12 @@ public class CloudControllerClient { } } + /** + * @param kubernetesClusterId + * @param clusterId + * @return + * @throws SpawningException + */ public synchronized MemberContext createContainer(String kubernetesClusterId, String clusterId) throws SpawningException { try { http://git-wip-us.apache.org/repos/asf/stratos/blob/df147953/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java index ccb0f4e..e1d7cc5 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java @@ -105,7 +105,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { monitor = asCtx.getClusterMonitor(clusterId); } else { if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); } return; } @@ -114,7 +115,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { || monitor.getClusterType() == ClusterType.VMLbCluster) { if(null != monitor){ - NetworkPartitionContext networkPartitionContext = ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); + NetworkPartitionContext networkPartitionContext = + ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); if(null != networkPartitionContext){ networkPartitionContext.setAverageLoadAverage(floatValue); } else { @@ -125,7 +127,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { } } } else if(monitor.getClusterType() == ClusterType.DockerServiceCluster) { - KubernetesClusterContext kubernetesClusterContext = ((DockerServiceClusterMonitor) monitor).getKubernetesClusterCtxt(); + KubernetesClusterContext kubernetesClusterContext = + ((DockerServiceClusterMonitor) monitor).getKubernetesClusterCtxt(); if (null != kubernetesClusterContext) { kubernetesClusterContext.setAverageLoadAverage(floatValue); } else { @@ -149,8 +152,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { Float floatValue = e.getValue(); if (log.isDebugEnabled()) { - log.debug(String.format("Avg Memory Consumption event: [cluster] %s [network-partition] %s [value] %s", - clusterId, networkPartitionId, floatValue)); + log.debug(String.format("Avg Memory Consumption event: [cluster] %s [network-partition] %s " + + "[value] %s", clusterId, networkPartitionId, floatValue)); } AutoscalerContext asCtx = AutoscalerContext.getInstance(); AbstractClusterMonitor monitor; @@ -159,7 +162,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { monitor = asCtx.getClusterMonitor(clusterId); } else { if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); } return; } @@ -168,7 +172,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { || monitor.getClusterType() == ClusterType.VMLbCluster) { if(null != monitor){ - NetworkPartitionContext networkPartitionContext = ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); + NetworkPartitionContext networkPartitionContext = + ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); if(null != networkPartitionContext){ networkPartitionContext.setAverageMemoryConsumption(floatValue); } else { @@ -179,7 +184,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { } } } else if(monitor.getClusterType() == ClusterType.DockerServiceCluster) { - KubernetesClusterContext kubernetesClusterContext = ((DockerServiceClusterMonitor) monitor).getKubernetesClusterCtxt(); + KubernetesClusterContext kubernetesClusterContext = + ((DockerServiceClusterMonitor) monitor).getKubernetesClusterCtxt(); if (null != kubernetesClusterContext) { kubernetesClusterContext.setAverageMemoryConsumption(floatValue); } else { @@ -212,7 +218,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { monitor = asCtx.getClusterMonitor(clusterId); } else { if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); } return; } @@ -221,7 +228,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { || monitor.getClusterType() == ClusterType.VMLbCluster) { if(null != monitor){ - NetworkPartitionContext networkPartitionContext = ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); + NetworkPartitionContext networkPartitionContext = + ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); if(null != networkPartitionContext){ networkPartitionContext.setAverageRequestsInFlight(floatValue); } else { @@ -232,7 +240,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { } } } else if(monitor.getClusterType() == ClusterType.DockerServiceCluster) { - KubernetesClusterContext kubernetesClusterContext = ((DockerServiceClusterMonitor) monitor).getKubernetesClusterCtxt(); + KubernetesClusterContext kubernetesClusterContext = + ((DockerServiceClusterMonitor) monitor).getKubernetesClusterCtxt(); if (null != kubernetesClusterContext) { kubernetesClusterContext.setAverageRequestsInFlight(floatValue); } else { @@ -265,7 +274,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { monitor = asCtx.getClusterMonitor(clusterId); } else { if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); } return; } @@ -274,7 +284,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { || monitor.getClusterType() == ClusterType.VMLbCluster){ if(null != monitor){ - NetworkPartitionContext networkPartitionContext = ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); + NetworkPartitionContext networkPartitionContext = + ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); if(null != networkPartitionContext){ networkPartitionContext.setLoadAverageGradient(floatValue); } else { @@ -285,7 +296,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { } } } else if(monitor.getClusterType() == ClusterType.DockerServiceCluster) { - KubernetesClusterContext kubernetesClusterContext = ((DockerServiceClusterMonitor) monitor).getKubernetesClusterCtxt(); + KubernetesClusterContext kubernetesClusterContext = + ((DockerServiceClusterMonitor) monitor).getKubernetesClusterCtxt(); if (null != kubernetesClusterContext) { kubernetesClusterContext.setLoadAverageGradient(floatValue); } else { @@ -309,8 +321,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { Float floatValue = e.getValue(); if (log.isDebugEnabled()) { - log.debug(String.format("Grad of Memory Consumption event: [cluster] %s [network-partition] %s [value] %s", - clusterId, networkPartitionId, floatValue)); + log.debug(String.format("Grad of Memory Consumption event: [cluster] %s " + + "[network-partition] %s [value] %s", clusterId, networkPartitionId, floatValue)); } AutoscalerContext asCtx = AutoscalerContext.getInstance(); AbstractClusterMonitor monitor; @@ -319,7 +331,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { monitor = asCtx.getClusterMonitor(clusterId); } else { if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); } return; } @@ -328,7 +341,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { || monitor.getClusterType() == ClusterType.VMLbCluster){ if(null != monitor){ - NetworkPartitionContext networkPartitionContext = ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); + NetworkPartitionContext networkPartitionContext = + ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); if(null != networkPartitionContext){ networkPartitionContext.setMemoryConsumptionGradient(floatValue); } else { @@ -339,7 +353,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { } } } else if(monitor.getClusterType() == ClusterType.DockerServiceCluster) { - KubernetesClusterContext kubernetesClusterContext = ((DockerServiceClusterMonitor) monitor).getKubernetesClusterCtxt(); + KubernetesClusterContext kubernetesClusterContext = + ((DockerServiceClusterMonitor) monitor).getKubernetesClusterCtxt(); if (null != kubernetesClusterContext) { kubernetesClusterContext.setMemoryConsumptionGradient(floatValue); } else { @@ -372,7 +387,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { monitor = asCtx.getClusterMonitor(clusterId); } else { if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); } return; } @@ -381,7 +397,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { || monitor.getClusterType() == ClusterType.VMLbCluster){ if(null != monitor){ - NetworkPartitionContext networkPartitionContext = ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); + NetworkPartitionContext networkPartitionContext = + ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); if(null != networkPartitionContext){ networkPartitionContext.setRequestsInFlightGradient(floatValue); } else { @@ -392,7 +409,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { } } } else if(monitor.getClusterType() == ClusterType.DockerServiceCluster) { - KubernetesClusterContext kubernetesClusterContext = ((DockerServiceClusterMonitor) monitor).getKubernetesClusterCtxt(); + KubernetesClusterContext kubernetesClusterContext = + ((DockerServiceClusterMonitor) monitor).getKubernetesClusterCtxt(); if (null != kubernetesClusterContext) { kubernetesClusterContext.setRequestsInFlightGradient(floatValue); } else { @@ -416,8 +434,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { loadAverage.setAverage(floatValue); if (log.isDebugEnabled()) { - log.debug(String.format("Member avg of load avg event: [member] %s [value] %s", e.getMemberId() - , floatValue)); + log.debug(String.format("Member avg of load avg event: [member] %s [value] %s", + e.getMemberId(), floatValue)); } } @@ -435,8 +453,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { memoryConsumption.setAverage(floatValue); if (log.isDebugEnabled()) { - log.debug(String.format("Member avg Memory Consumption event: [member] %s [value] %s", e.getMemberId(), - floatValue)); + log.debug(String.format("Member avg Memory Consumption event: [member] %s [value] %s", + e.getMemberId(), floatValue)); } } @@ -475,8 +493,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { loadAverage.setGradient(floatValue); if (log.isDebugEnabled()) { - log.debug(String.format("Member grad of load avg event: [member] %s [value] %s", e.getMemberId(), - floatValue)); + log.debug(String.format("Member grad of load avg event: [member] %s " + + "[value] %s", e.getMemberId(), floatValue)); } } @@ -494,8 +512,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { memoryConsumption.setGradient(floatValue); if (log.isDebugEnabled()) { - log.debug(String.format("Member grad of Memory Consumption event: [member] %s [value] %s", e.getMemberId(), - floatValue)); + log.debug(String.format("Member grad of Memory Consumption event: [member] %s " + + "[value] %s", e.getMemberId(), floatValue)); } } @@ -513,8 +531,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { loadAverage.setSecondDerivative(floatValue); if (log.isDebugEnabled()) { - log.debug(String.format("Member Second Derivation of load avg event: [member] %s [value] %s", e.getMemberId() - , floatValue)); + log.debug(String.format("Member Second Derivation of load avg event: [member] %s " + + "[value] %s", e.getMemberId(), floatValue)); } } } @@ -537,8 +555,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { Float floatValue = e.getValue(); if (log.isDebugEnabled()) { - log.debug(String.format("Second Derivation of load avg event: [cluster] %s [network-partition] %s [value] %s", - clusterId, networkPartitionId, floatValue)); + log.debug(String.format("Second Derivation of load avg event: [cluster] %s " + + "[network-partition] %s [value] %s", clusterId, networkPartitionId, floatValue)); } AutoscalerContext asCtx = AutoscalerContext.getInstance(); AbstractClusterMonitor monitor; @@ -547,7 +565,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { monitor = asCtx.getClusterMonitor(clusterId); } else { if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); } return; } @@ -556,7 +575,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { || monitor.getClusterType() == ClusterType.VMLbCluster){ if(null != monitor){ - NetworkPartitionContext networkPartitionContext = ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); + NetworkPartitionContext networkPartitionContext = + ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); if(null != networkPartitionContext){ networkPartitionContext.setLoadAverageSecondDerivative(floatValue); } else { @@ -567,7 +587,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { } } } else if(monitor.getClusterType() == ClusterType.DockerServiceCluster) { - KubernetesClusterContext kubernetesClusterContext = ((DockerServiceClusterMonitor) monitor).getKubernetesClusterCtxt(); + KubernetesClusterContext kubernetesClusterContext = + ((DockerServiceClusterMonitor) monitor).getKubernetesClusterCtxt(); if (null != kubernetesClusterContext) { kubernetesClusterContext.setLoadAverageSecondDerivative(floatValue); } else { @@ -591,8 +612,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { Float floatValue = e.getValue(); if (log.isDebugEnabled()) { - log.debug(String.format("Second Derivation of Memory Consumption event: [cluster] %s [network-partition] %s [value] %s", - clusterId, networkPartitionId, floatValue)); + log.debug(String.format("Second Derivation of Memory Consumption event: [cluster] %s " + + "[network-partition] %s [value] %s", clusterId, networkPartitionId, floatValue)); } AutoscalerContext asCtx = AutoscalerContext.getInstance(); AbstractClusterMonitor monitor; @@ -601,7 +622,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { monitor = asCtx.getClusterMonitor(clusterId); } else { if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); } return; } @@ -610,7 +632,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { || monitor.getClusterType() == ClusterType.VMLbCluster){ if(null != monitor){ - NetworkPartitionContext networkPartitionContext = ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); + NetworkPartitionContext networkPartitionContext = + ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); if(null != networkPartitionContext){ networkPartitionContext.setMemoryConsumptionSecondDerivative(floatValue); } else { @@ -621,7 +644,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { } } } else if(monitor.getClusterType() == ClusterType.DockerServiceCluster) { - KubernetesClusterContext kubernetesClusterContext = ((DockerServiceClusterMonitor) monitor).getKubernetesClusterCtxt(); + KubernetesClusterContext kubernetesClusterContext = + ((DockerServiceClusterMonitor) monitor).getKubernetesClusterCtxt(); if (null != kubernetesClusterContext) { kubernetesClusterContext.setMemoryConsumptionSecondDerivative(floatValue); } else { @@ -643,8 +667,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { Float floatValue = e.getValue(); if (log.isDebugEnabled()) { - log.debug(String.format("Second derivative of Rif event: [cluster] %s [network-partition] %s [value] %s", - clusterId, networkPartitionId, floatValue)); + log.debug(String.format("Second derivative of Rif event: [cluster] %s " + + "[network-partition] %s [value] %s", clusterId, networkPartitionId, floatValue)); } AutoscalerContext asCtx = AutoscalerContext.getInstance(); AbstractClusterMonitor monitor; @@ -653,7 +677,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { monitor = asCtx.getClusterMonitor(clusterId); } else { if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); } return; } @@ -662,7 +687,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { || monitor.getClusterType() == ClusterType.VMLbCluster){ if(null != monitor){ - NetworkPartitionContext networkPartitionContext = ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); + NetworkPartitionContext networkPartitionContext = + ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); if(null != networkPartitionContext){ networkPartitionContext.setRequestsInFlightSecondDerivative(floatValue); } else { @@ -673,7 +699,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { } } } else if(monitor.getClusterType() == ClusterType.DockerServiceCluster) { - KubernetesClusterContext kubernetesClusterContext = ((DockerServiceClusterMonitor) monitor).getKubernetesClusterCtxt(); + KubernetesClusterContext kubernetesClusterContext = + ((DockerServiceClusterMonitor) monitor).getKubernetesClusterCtxt(); if (null != kubernetesClusterContext) { kubernetesClusterContext.setRequestsInFlightSecondDerivative(floatValue); } else { @@ -707,7 +734,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { monitor = asCtx.getClusterMonitor(clusterId); } else { if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); } return null; } @@ -716,7 +744,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { || monitor.getClusterType() == ClusterType.VMLbCluster){ String networkPartitionId = findNetworkPartitionId(memberId); - MemberStatsContext memberStatsContext = ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId) + MemberStatsContext memberStatsContext = + ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId) .getPartitionCtxt(member.getPartitionId()) .getMemberStatsContext(memberId); if(null == memberStatsContext){ @@ -727,8 +756,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { } else if(!member.isActive()){ if(log.isDebugEnabled()){ - log.debug(String.format("Member activated event has not received for the member %s. Therefore ignoring" + - " the health stat", memberId)); + log.debug(String.format("Member activated event has not received for the member %s. " + + "Therefore ignoring" + " the health stat", memberId)); } return null; } @@ -736,7 +765,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { LoadAverage loadAverage = memberStatsContext.getLoadAverage(); return loadAverage; } else if(monitor.getClusterType() == ClusterType.DockerServiceCluster) { - MemberStatsContext memberStatsContext = ((ContainerClusterMonitor) monitor).getKubernetesClusterCtxt().getMemberStatsContext(memberId); + MemberStatsContext memberStatsContext = + ((ContainerClusterMonitor) monitor).getKubernetesClusterCtxt().getMemberStatsContext(memberId); if(null == memberStatsContext){ if(log.isDebugEnabled()) { log.debug(String.format("Member context is not available for : [member] %s", memberId)); @@ -745,8 +775,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { } else if(!member.isActive()){ if(log.isDebugEnabled()){ - log.debug(String.format("Member activated event has not received for the member %s. Therefore ignoring" + - " the health stat", memberId)); + log.debug(String.format("Member activated event has not received for the member %s. " + + "Therefore ignoring" + " the health stat", memberId)); } return null; } @@ -776,7 +806,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { monitor = asCtx.getClusterMonitor(member.getClusterId()); } else { if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", member.getClusterId())); + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", member.getClusterId())); } return null; } @@ -785,9 +816,10 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { || monitor.getClusterType() == ClusterType.VMLbCluster){ String networkPartitionId = findNetworkPartitionId(memberId); - MemberStatsContext memberStatsContext = ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId) - .getPartitionCtxt(member.getPartitionId()) - .getMemberStatsContext(memberId); + NetworkPartitionContext networkPartitionCtxt = + ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); + PartitionContext partitionCtxt = networkPartitionCtxt.getPartitionCtxt(member.getPartitionId()); + MemberStatsContext memberStatsContext = partitionCtxt.getMemberStatsContext(memberId); if(null == memberStatsContext){ if(log.isDebugEnabled()) { log.debug(String.format("Member context is not available for : [member] %s", memberId)); @@ -795,8 +827,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { return null; }else if(!member.isActive()){ if(log.isDebugEnabled()){ - log.debug(String.format("Member activated event has not received for the member %s. Therefore ignoring" + - " the health stat", memberId)); + log.debug(String.format("Member activated event has not received for the member %s. " + + "Therefore ignoring" + " the health stat", memberId)); } return null; } @@ -804,7 +836,9 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { return memoryConsumption; } else if (monitor.getClusterType() == ClusterType.DockerServiceCluster) { - MemberStatsContext memberStatsContext = ((ContainerClusterMonitor) monitor).getKubernetesClusterCtxt().getMemberStatsContext(memberId); + KubernetesClusterContext kubernetesClusterCtxt = + ((ContainerClusterMonitor) monitor).getKubernetesClusterCtxt(); + MemberStatsContext memberStatsContext = kubernetesClusterCtxt.getMemberStatsContext(memberId); if(null == memberStatsContext){ if(log.isDebugEnabled()) { log.debug(String.format("Member context is not available for : [member] %s", memberId)); @@ -812,8 +846,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { return null; }else if(!member.isActive()){ if(log.isDebugEnabled()){ - log.debug(String.format("Member activated event has not received for the member %s. Therefore ignoring" + - " the health stat", memberId)); + log.debug(String.format("Member activated event has not received for the member %s. " + + "Therefore ignoring" + " the health stat", memberId)); } return null; } @@ -862,7 +896,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { monitor = asCtx.getClusterMonitor(clusterId); } else { if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); } return; } @@ -880,8 +915,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { } if(!member.isActive()){ if(log.isDebugEnabled()){ - log.debug(String.format("Member activated event has not received for the member %s. Therefore ignoring" + - " the member fault health stat", memberId)); + log.debug(String.format("Member activated event has not received for the member %s. " + + "Therefore ignoring" + " the member fault health stat", memberId)); } return; } @@ -897,7 +932,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { if(!partitionCtxt.activeMemberExist(memberId)){ if(log.isDebugEnabled()){ - log.debug(String.format("Could not find the active member in partition context, [member] %s ", memberId)); + log.debug(String.format("Could not find the active member in partition context, " + + "[member] %s ", memberId)); } return; } @@ -909,8 +945,8 @@ public class AutoscalerHealthStatEventReceiver implements Runnable { partitionCtxt.removeActiveMemberById(memberId); if (log.isInfoEnabled()) { - log.info(String.format("Faulty member is terminated and removed from the active members list: [member] %s [partition] %s [cluster] %s ", - memberId, partitionId, clusterId)); + log.info(String.format("Faulty member is terminated and removed from the active members list: " + + "[member] %s [partition] %s [cluster] %s ", memberId, partitionId, clusterId)); } } else if(monitor.getClusterType() == ClusterType.DockerServiceCluster) { // no need to do anything http://git-wip-us.apache.org/repos/asf/stratos/blob/df147953/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 4c896fe..891aeb0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -144,7 +144,8 @@ public class AutoscalerTopologyEventReceiver implements Runnable { monitor = asCtx.getClusterMonitor(clusterId); } else { if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); } return; } @@ -155,7 +156,8 @@ public class AutoscalerTopologyEventReceiver implements Runnable { || monitor.getClusterType() == ClusterType.VMLbCluster) { NetworkPartitionContext nwPartitionCtxt; - nwPartitionCtxt = ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(memberReadyToShutdownEvent.getNetworkPartitionId()); + String networkPartitionId = memberReadyToShutdownEvent.getNetworkPartitionId(); + nwPartitionCtxt = ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); // start a new member in the same Partition String partitionId = ((VMClusterMonitor) monitor).getPartitionOfMember(memberId); @@ -170,8 +172,8 @@ public class AutoscalerTopologyEventReceiver implements Runnable { partitionCtxt.removeActiveMemberById(memberId); if (log.isInfoEnabled()) { - log.info(String.format("Member is terminated and removed from the active members list: [member] %s [partition] %s [cluster] %s ", - memberId, partitionId, clusterId)); + log.info(String.format("Member is terminated and removed from the active members list: " + + "[member] %s [partition] %s [cluster] %s ", memberId, partitionId, clusterId)); } } else if(monitor.getClusterType() == ClusterType.DockerServiceCluster) { // no need to do anything @@ -309,7 +311,8 @@ public class AutoscalerTopologyEventReceiver implements Runnable { monitor = asCtx.getClusterMonitor(clusterId); } else { if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); } return; } @@ -317,29 +320,36 @@ public class AutoscalerTopologyEventReceiver implements Runnable { if(monitor.getClusterType() == ClusterType.VMServiceCluster || monitor.getClusterType() == ClusterType.VMLbCluster) { - NetworkPartitionContext networkPartitionContext = ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); + NetworkPartitionContext networkPartitionContext = + ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); PartitionContext partitionContext = networkPartitionContext.getPartitionCtxt(partitionId); partitionContext.removeMemberStatsContext(memberId); if (partitionContext.removeTerminationPendingMember(memberId)) { if (log.isDebugEnabled()) { - log.debug(String.format("Member is removed from termination pending members list: [member] %s", memberId)); + log.debug(String.format("Member is removed from termination pending members list: " + + "[member] %s", memberId)); } } else if (partitionContext.removePendingMember(memberId)) { if (log.isDebugEnabled()) { - log.debug(String.format("Member is removed from pending members list: [member] %s", memberId)); + log.debug(String.format("Member is removed from pending members list: " + + "[member] %s", memberId)); } } else if (partitionContext.removeActiveMemberById(memberId)) { - log.warn(String.format("Member is in the wrong list and it is removed from active members list", memberId)); + log.warn(String.format("Member is in the wrong list and it is removed from " + + "active members list", memberId)); } else if (partitionContext.removeObsoleteMember(memberId)){ - log.warn(String.format("Member's obsolated timeout has been expired and it is removed from obsolated members list", memberId)); + log.warn(String.format("Member's obsolated timeout has been expired and " + + "it is removed from obsolated members list", memberId)); } else { - log.warn(String.format("Member is not available in any of the list active, pending and termination pending", memberId)); + log.warn(String.format("Member is not available in any of the list active, " + + "pending and termination pending", memberId)); } if (log.isInfoEnabled()) { - log.info(String.format("Member stat context has been removed successfully: [member] %s", memberId)); + log.info(String.format("Member stat context has been removed successfully: " + + "[member] %s", memberId)); } } else if(monitor.getClusterType() == ClusterType.DockerServiceCluster) { // no need to do anything @@ -374,7 +384,8 @@ public class AutoscalerTopologyEventReceiver implements Runnable { monitor = asCtx.getClusterMonitor(clusterId); } else { if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); } return; } @@ -384,7 +395,8 @@ public class AutoscalerTopologyEventReceiver implements Runnable { partitionContext = ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId).getPartitionCtxt(partitionId); partitionContext.addMemberStatsContext(new MemberStatsContext(memberId)); if (log.isInfoEnabled()) { - log.info(String.format("Member stat context has been added successfully: [member] %s", memberId)); + log.info(String.format("Member stat context has been added successfully: " + + "[member] %s", memberId)); } partitionContext.movePendingMemberToActiveMembers(memberId); } else if(monitor.getClusterType() == ClusterType.DockerServiceCluster) { @@ -392,7 +404,8 @@ public class AutoscalerTopologyEventReceiver implements Runnable { kubernetesClusterContext = ((ContainerClusterMonitor) monitor).getKubernetesClusterCtxt(); kubernetesClusterContext.addMemberStatsContext(new MemberStatsContext(memberId)); if (log.isInfoEnabled()) { - log.info(String.format("Member stat context has been added successfully: [member] %s", memberId)); + log.info(String.format("Member stat context has been added successfully: " + + "[member] %s", memberId)); } kubernetesClusterContext.movePendingMemberToActiveMembers(memberId); } @@ -421,7 +434,8 @@ public class AutoscalerTopologyEventReceiver implements Runnable { monitor = asCtx.getClusterMonitor(clusterId); } else { if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); } return; } @@ -430,7 +444,8 @@ public class AutoscalerTopologyEventReceiver implements Runnable { || monitor.getClusterType() == ClusterType.VMLbCluster) { NetworkPartitionContext nwPartitionCtxt; - nwPartitionCtxt = ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(memberReadyToShutdownEvent.getNetworkPartitionId()); + String networkPartitionId = memberReadyToShutdownEvent.getNetworkPartitionId(); + nwPartitionCtxt = ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId); // start a new member in the same Partition String partitionId = ((VMClusterMonitor) monitor).getPartitionOfMember(memberId); @@ -445,8 +460,8 @@ public class AutoscalerTopologyEventReceiver implements Runnable { partitionCtxt.removeActiveMemberById(memberId); if (log.isInfoEnabled()) { - log.info(String.format("Member is terminated and removed from the active members list: [member] %s [partition] %s [cluster] %s ", - memberId, partitionId, clusterId)); + log.info(String.format("Member is terminated and removed from the active members list: " + + "[member] %s [partition] %s [cluster] %s ", memberId, partitionId, clusterId)); } } else if(monitor.getClusterType() == ClusterType.DockerServiceCluster) { // no need to do anything @@ -480,7 +495,8 @@ public class AutoscalerTopologyEventReceiver implements Runnable { monitor = AutoscalerContext.getInstance().getClusterMonitor(clusterId); } else { if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); } return; } @@ -492,7 +508,8 @@ public class AutoscalerTopologyEventReceiver implements Runnable { partitionContext = ((VMClusterMonitor) monitor).getNetworkPartitionCtxt(networkPartitionId).getPartitionCtxt(partitionId); partitionContext.addMemberStatsContext(new MemberStatsContext(memberId)); if (log.isDebugEnabled()) { - log.debug(String.format("Member has been moved as pending termination: [member] %s", memberId)); + log.debug(String.format("Member has been moved as pending termination: " + + "[member] %s", memberId)); } partitionContext.moveActiveMemberToTerminationPendingMembers(memberId); } else if(monitor.getClusterType() == ClusterType.DockerServiceCluster) { http://git-wip-us.apache.org/repos/asf/stratos/blob/df147953/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 00796f1..cb60027 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 @@ -1,3 +1,21 @@ +/* + * 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.monitor; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; @@ -6,6 +24,9 @@ import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.drools.runtime.StatefulKnowledgeSession; import org.drools.runtime.rule.FactHandle; +/* + * Every cluster monitor, which are monitoring a cluster, should extend this class. + */ public abstract class AbstractClusterMonitor implements Runnable{ private String clusterId; http://git-wip-us.apache.org/repos/asf/stratos/blob/df147953/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitorFactory.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitorFactory.java index 70198de..bd01dc6 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitorFactory.java @@ -1,3 +1,22 @@ +/* + * 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.monitor; import java.util.Map; @@ -29,10 +48,19 @@ import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.MemberStatus; import org.apache.stratos.messaging.util.Constants; +/* + * Factory class for creating cluster monitors. + */ public class ClusterMonitorFactory { private static final Log log = LogFactory.getLog(ClusterMonitorFactory.class); + /** + * @param cluster the cluster to be monitored + * @return the created cluster monitor + * @throws PolicyValidationException when deployment policy is not valid + * @throws PartitionValidationException when partition is not valid + */ public static AbstractClusterMonitor getMonitor(Cluster cluster) throws PolicyValidationException, PartitionValidationException { AbstractClusterMonitor clusterMonitor; @@ -342,10 +370,6 @@ public class ClusterMonitorFactory { } } -// // set hasPrimary property -// // hasPrimary is true if there are primary members available in that cluster -// dockerClusterMonitor.setHasPrimary(Boolean.parseBoolean(props.getProperty(Constants.IS_PRIMARY))); - log.info("KubernetesServiceClusterMonitor created: "+ dockerClusterMonitor.toString()); return dockerClusterMonitor; } http://git-wip-us.apache.org/repos/asf/stratos/blob/df147953/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ContainerClusterMonitor.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ContainerClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ContainerClusterMonitor.java index f9b9047..2621690 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ContainerClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ContainerClusterMonitor.java @@ -1,3 +1,21 @@ +/* + * 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.monitor; import org.apache.stratos.autoscaler.KubernetesClusterContext; @@ -5,6 +23,9 @@ import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.common.enums.ClusterType; +/* + * Every container cluster monitor should extend this class + */ public abstract class ContainerClusterMonitor extends AbstractClusterMonitor { private KubernetesClusterContext kubernetesClusterCtxt; http://git-wip-us.apache.org/repos/asf/stratos/blob/df147953/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/DockerServiceClusterMonitor.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/DockerServiceClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/DockerServiceClusterMonitor.java index 402e6b1..850a295 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/DockerServiceClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/DockerServiceClusterMonitor.java @@ -1,3 +1,21 @@ +/* + * 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.monitor; import java.util.Properties; @@ -17,6 +35,9 @@ import org.apache.stratos.common.enums.ClusterType; import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +/* + * It is monitoring a kubernetes service cluster periodically. + */ public final class DockerServiceClusterMonitor extends ContainerClusterMonitor{ private static final Log log = LogFactory.getLog(DockerServiceClusterMonitor.class); @@ -129,7 +150,6 @@ public final class DockerServiceClusterMonitor extends ContainerClusterMonitor{ @Override protected void readConfigurations () { - // same as VM cluster monitor interval XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration(); int monitorInterval = conf.getInt(AutoScalerConstants.AUTOSCALER_MONITOR_INTERVAL, 90000); setMonitorInterval(monitorInterval);
