Updated Branches: refs/heads/master 07e04592b -> e7f3ade75
Setting load average and memory consumptions in network partition context at the event Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/e7f3ade7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/e7f3ade7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/e7f3ade7 Branch: refs/heads/master Commit: e7f3ade75afeaef02da2fab6b604ab777f7dcf7b Parents: 07e0459 Author: Lahiru Sandaruwan <[email protected]> Authored: Thu Jan 2 19:18:33 2014 +0530 Committer: Lahiru Sandaruwan <[email protected]> Committed: Thu Jan 2 19:18:33 2014 +0530 ---------------------------------------------------------------------- .../health/HealthEventMessageDelegator.java | 168 ++++++++++++++++++- 1 file changed, 162 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/e7f3ade7/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/HealthEventMessageDelegator.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/HealthEventMessageDelegator.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/HealthEventMessageDelegator.java index d32ffb4..d1bcb1c 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/HealthEventMessageDelegator.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/HealthEventMessageDelegator.java @@ -242,17 +242,173 @@ public class HealthEventMessageDelegator implements Runnable { } } else if(Constants.AVERAGE_LOAD_AVERAGE.equals(eventName)) { - //do nothing for network partition wise events yet + + String clusterId = event.getProperties().get("cluster_id"); + String networkPartitionId = event.getProperties().get("network_partition_id"); + String value = event.getProperties().get("value"); + Float floatValue = Float.parseFloat(value); + + if (log.isDebugEnabled()) { + log.debug(String.format("%s event: [cluster] %s [network-partition] %s [value] %s", eventName, + clusterId, networkPartitionId, value)); + } + AbstractMonitor monitor = AutoscalerContext.getInstance().getMonitor(clusterId); + if(null != monitor){ + NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId); + if(null != networkPartitionContext){ + networkPartitionContext.setAverageLoadAverage(floatValue); + } else { + if(log.isErrorEnabled()) { + log.error(String.format("Network partition context is not available for :" + + " [network partition] %s", networkPartitionId)); + } + } + } else { + + if(log.isErrorEnabled()) { + log.error(String.format("Cluster monitor is not available for : [cluster] %s", clusterId)); + } + } } else if(Constants.SECOND_DERIVATIVE_OF_LOAD_AVERAGE.equals(eventName)) { - //do nothing for network partition wise events yet + + String clusterId = event.getProperties().get("cluster_id"); + String networkPartitionId = event.getProperties().get("network_partition_id"); + String value = event.getProperties().get("value"); + Float floatValue = Float.parseFloat(value); + + if (log.isDebugEnabled()) { + log.debug(String.format("%s event: [cluster] %s [network-partition] %s [value] %s", eventName, + clusterId, networkPartitionId, value)); + } + AbstractMonitor monitor = AutoscalerContext.getInstance().getMonitor(clusterId); + if(null != monitor){ + NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId); + if(null != networkPartitionContext){ + networkPartitionContext.setLoadAverageSecondDerivative(floatValue); + } else { + if(log.isErrorEnabled()) { + log.error(String.format("Network partition context is not available for :" + + " [network partition] %s", networkPartitionId)); + } + } + } else { + + if(log.isErrorEnabled()) { + log.error(String.format("Cluster monitor is not available for : [cluster] %s", clusterId)); + } + } } else if(Constants.GRADIENT_LOAD_AVERAGE.equals(eventName)) { - //do nothing for network partition wise events yet + + String clusterId = event.getProperties().get("cluster_id"); + String networkPartitionId = event.getProperties().get("network_partition_id"); + String value = event.getProperties().get("value"); + Float floatValue = Float.parseFloat(value); + + if (log.isDebugEnabled()) { + log.debug(String.format("%s event: [cluster] %s [network-partition] %s [value] %s", eventName, + clusterId, networkPartitionId, value)); + } + AbstractMonitor monitor = AutoscalerContext.getInstance().getMonitor(clusterId); + if(null != monitor){ + NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId); + if(null != networkPartitionContext){ + networkPartitionContext.setLoadAverageGradient(floatValue); + } else { + if(log.isErrorEnabled()) { + log.error(String.format("Network partition context is not available for :" + + " [network partition] %s", networkPartitionId)); + } + } + } else { + + if(log.isErrorEnabled()) { + log.error(String.format("Cluster monitor is not available for : [cluster] %s", clusterId)); + } + } } else if(Constants.AVERAGE_MEMORY_CONSUMPTION.equals(eventName)) { - //do nothing for network partition wise events yet + + String clusterId = event.getProperties().get("cluster_id"); + String networkPartitionId = event.getProperties().get("network_partition_id"); + String value = event.getProperties().get("value"); + Float floatValue = Float.parseFloat(value); + + if (log.isDebugEnabled()) { + log.debug(String.format("%s event: [cluster] %s [network-partition] %s [value] %s", eventName, + clusterId, networkPartitionId, value)); + } + AbstractMonitor monitor = AutoscalerContext.getInstance().getMonitor(clusterId); + if(null != monitor){ + NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId); + if(null != networkPartitionContext){ + networkPartitionContext.setAverageMemoryConsumption(floatValue); + } else { + if(log.isErrorEnabled()) { + log.error(String.format("Network partition context is not available for :" + + " [network partition] %s", networkPartitionId)); + } + } + } else { + + if(log.isErrorEnabled()) { + log.error(String.format("Cluster monitor is not available for : [cluster] %s", clusterId)); + } + } } else if(Constants.SECOND_DERIVATIVE_OF_MEMORY_CONSUMPTION.equals(eventName)) { - //do nothing for network partition wise events yet + + String clusterId = event.getProperties().get("cluster_id"); + String networkPartitionId = event.getProperties().get("network_partition_id"); + String value = event.getProperties().get("value"); + Float floatValue = Float.parseFloat(value); + + if (log.isDebugEnabled()) { + log.debug(String.format("%s event: [cluster] %s [network-partition] %s [value] %s", eventName, + clusterId, networkPartitionId, value)); + } + AbstractMonitor monitor = AutoscalerContext.getInstance().getMonitor(clusterId); + if(null != monitor){ + NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId); + if(null != networkPartitionContext){ + networkPartitionContext.setMemoryConsumptionSecondDerivative(floatValue); + } else { + if(log.isErrorEnabled()) { + log.error(String.format("Network partition context is not available for :" + + " [network partition] %s", networkPartitionId)); + } + } + } else { + + if(log.isErrorEnabled()) { + log.error(String.format("Cluster monitor is not available for : [cluster] %s", clusterId)); + } + } } else if(Constants.GRADIENT_MEMORY_CONSUMPTION.equals(eventName)) { - //do nothing for network partition wise events yet + + String clusterId = event.getProperties().get("cluster_id"); + String networkPartitionId = event.getProperties().get("network_partition_id"); + String value = event.getProperties().get("value"); + Float floatValue = Float.parseFloat(value); + + if (log.isDebugEnabled()) { + log.debug(String.format("%s event: [cluster] %s [network-partition] %s [value] %s", eventName, + clusterId, networkPartitionId, value)); + } + AbstractMonitor monitor = AutoscalerContext.getInstance().getMonitor(clusterId); + if(null != monitor){ + NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId); + if(null != networkPartitionContext){ + networkPartitionContext.setMemoryConsumptionGradient(floatValue); + } else { + if(log.isErrorEnabled()) { + log.error(String.format("Network partition context is not available for :" + + " [network partition] %s", networkPartitionId)); + } + } + } else { + + if(log.isErrorEnabled()) { + log.error(String.format("Cluster monitor is not available for : [cluster] %s", clusterId)); + } + } } } catch (Exception e) { log.error("Failed to retrieve the health stat event message.", e);
