Repository: stratos Updated Branches: refs/heads/container-autoscaling 7d616494a -> fb68de94a
executor service instead of thread sleep Signed-off-by: sajhak <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/fb68de94 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/fb68de94 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/fb68de94 Branch: refs/heads/container-autoscaling Commit: fb68de94a1df0a7c679d5881f680dba5671340eb Parents: 244030b Author: R-Rajkumar <[email protected]> Authored: Mon Oct 6 11:25:54 2014 +0530 Committer: sajhak <[email protected]> Committed: Mon Oct 6 23:11:29 2014 +0530 ---------------------------------------------------------------------- .../monitor/AbstractClusterMonitor.java | 10 +++---- .../KubernetesServiceClusterMonitor.java | 28 ++++++++++---------- .../autoscaler/monitor/VMLbClusterMonitor.java | 26 +++++++++--------- .../monitor/VMServiceClusterMonitor.java | 26 +++++++++--------- 4 files changed, 45 insertions(+), 45 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/fb68de94/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 e44bd72..3238d46 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 @@ -66,7 +66,7 @@ public abstract class AbstractClusterMonitor implements Runnable { private boolean isDestroyed; private AutoscalerRuleEvaluator autoscalerRuleEvaluator; - + private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); protected AbstractClusterMonitor(String clusterId, String serviceId, @@ -81,13 +81,13 @@ public abstract class AbstractClusterMonitor implements Runnable { } protected abstract void readConfigurations(); - + public void startScheduler() { - scheduler.scheduleAtFixedRate(this, 0, getMonitorIntervalMilliseconds(), TimeUnit.MILLISECONDS); + scheduler.scheduleAtFixedRate(this, 0, getMonitorIntervalMilliseconds(), TimeUnit.MILLISECONDS); } - + protected void stopScheduler() { - scheduler.shutdownNow(); + scheduler.shutdownNow(); } protected abstract void monitor(); http://git-wip-us.apache.org/repos/asf/stratos/blob/fb68de94/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 93580d9..6e14ce0 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 @@ -59,22 +59,22 @@ public final class KubernetesServiceClusterMonitor extends KubernetesClusterMoni @Override public void run() { - if (log.isDebugEnabled()) { - log.debug("KubernetesServiceClusterMonitor is running.. " + this.toString()); - } - try { - if (!ClusterStatus.In_Maintenance.equals(getStatus())) { - monitor(); - } else { - if (log.isDebugEnabled()) { - log.debug("KubernetesServiceClusterMonitor is suspended as the cluster is in " - + ClusterStatus.In_Maintenance + " mode......"); - } + if (log.isDebugEnabled()) { + log.debug("KubernetesServiceClusterMonitor is running.. " + this.toString()); + } + try { + if (!ClusterStatus.In_Maintenance.equals(getStatus())) { + monitor(); + } else { + if (log.isDebugEnabled()) { + log.debug("KubernetesServiceClusterMonitor is suspended as the cluster is in " + + ClusterStatus.In_Maintenance + " mode......"); } - } catch (Exception e) { - log.error("KubernetesServiceClusterMonitor : Monitor failed." + this.toString(), - e); } + } catch (Exception e) { + log.error("KubernetesServiceClusterMonitor : Monitor failed." + this.toString(), + e); + } } @Override http://git-wip-us.apache.org/repos/asf/stratos/blob/fb68de94/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 f950f9d..1c27380 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 @@ -57,21 +57,21 @@ public class VMLbClusterMonitor extends VMClusterMonitor { @Override public void run() { - if (log.isDebugEnabled()) { - log.debug("VMLbClusterMonitor is running.. " + this.toString()); - } - try { - if (!ClusterStatus.In_Maintenance.equals(getStatus())) { - monitor(); - } else { - if (log.isDebugEnabled()) { - log.debug("VMLbClusterMonitor is suspended as the cluster is in " + - ClusterStatus.In_Maintenance + " mode......"); - } + if (log.isDebugEnabled()) { + log.debug("VMLbClusterMonitor is running.. " + this.toString()); + } + try { + if (!ClusterStatus.In_Maintenance.equals(getStatus())) { + monitor(); + } else { + if (log.isDebugEnabled()) { + log.debug("VMLbClusterMonitor is suspended as the cluster is in " + + ClusterStatus.In_Maintenance + " mode......"); } - } catch (Exception e) { - log.error("VMLbClusterMonitor : Monitor failed. " + this.toString(), e); } + } catch (Exception e) { + log.error("VMLbClusterMonitor : Monitor failed. " + this.toString(), e); + } } @Override http://git-wip-us.apache.org/repos/asf/stratos/blob/fb68de94/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 d8c9e69..6f9fb26 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 @@ -67,21 +67,21 @@ public class VMServiceClusterMonitor extends VMClusterMonitor { } catch (InterruptedException ignore) { } - if (log.isDebugEnabled()) { - log.debug("VMServiceClusterMonitor is running.. " + this.toString()); - } - try { - if (!ClusterStatus.In_Maintenance.equals(getStatus())) { - monitor(); - } else { - if (log.isDebugEnabled()) { - log.debug("VMServiceClusterMonitor is suspended as the cluster is in " + - ClusterStatus.In_Maintenance + " mode......"); - } + if (log.isDebugEnabled()) { + log.debug("VMServiceClusterMonitor is running.. " + this.toString()); + } + try { + if (!ClusterStatus.In_Maintenance.equals(getStatus())) { + monitor(); + } else { + if (log.isDebugEnabled()) { + log.debug("VMServiceClusterMonitor is suspended as the cluster is in " + + ClusterStatus.In_Maintenance + " mode......"); } - } catch (Exception e) { - log.error("VMServiceClusterMonitor : Monitor failed." + this.toString(), e); } + } catch (Exception e) { + log.error("VMServiceClusterMonitor : Monitor failed." + this.toString(), e); + } } @Override
