if (log.isDebugEnabled()) {
log.debug(String.format("Avg load avg event: [cluster] %s [network-partition] %s [value] %s",
clusterId, networkPartitionId, floatValue));
}
AutoscalerContext asCtx = AutoscalerContext.getInstance();
AbstractMonitor monitor;
if(asCtx.monitorExist(clusterId)){
monitor = asCtx.getMonitor(clusterId);
}else if(asCtx.lbMonitorExist(clusterId)){
monitor = asCtx.getLBMonitor(clusterId);
}else{
if(log.isDebugEnabled()){
log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId));
}
return;
}
if(null != monitor){
NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId);
if(null != networkPartitionContext){
networkPartitionContext.setAverageLoadAverage(floatValue);
} else {
if(log.isDebugEnabled()) {
log.debug(String.format("Network partition context is not available for :" +
" [network partition] %s", networkPartitionId));
}
}
}
}
});
healthStatEventReceiver.addEventListener(new AverageMemoryConsumptionEventListener() {
@Override
protected void onEvent(org.apache.stratos.messaging.event.Event event) {
AverageMemoryConsumptionEvent e = (AverageMemoryConsumptionEvent) event;
String clusterId = e.getClusterId();
String networkPartitionId = e.getNetworkPartitionId();
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));
}
AutoscalerContext asCtx = AutoscalerContext.getInstance();
AbstractMonitor monitor;
if(asCtx.monitorExist(clusterId)){
monitor = asCtx.getMonitor(clusterId);
}else if(asCtx.lbMonitorExist(clusterId)){
monitor = asCtx.getLBMonitor(clusterId);
}else{
if(log.isDebugEnabled()){
log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId));
}
return;
}
if(null != monitor){
NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId);
if(null != networkPartitionContext){
networkPartitionContext.setAverageMemoryConsumption(floatValue);
} else {
if(log.isDebugEnabled()) {
log.debug(String.format("Network partition context is not available for :" +
" [network partition] %s", networkPartitionId));
}
}
}
}
});
healthStatEventReceiver.addEventListener(new AverageRequestsInFlightEventListener() {
@Override
protected void onEvent(org.apache.stratos.messaging.event.Event event) {
AverageRequestsInFlightEvent e = (AverageRequestsInFlightEvent) event;
String clusterId = e.getClusterId();
String networkPartitionId = e.getNetworkPartitionId();
Float floatValue = e.getValue();
if (log.isDebugEnabled()) {
log.debug(String.format("Average Rif event: [cluster] %s [network-partition] %s [value] %s",
clusterId, networkPartitionId, floatValue));
}
AutoscalerContext asCtx = AutoscalerContext.getInstance();
AbstractMonitor monitor;
if(asCtx.monitorExist(clusterId)){
monitor = asCtx.getMonitor(clusterId);
}else if(asCtx.lbMonitorExist(clusterId)){
monitor = asCtx.getLBMonitor(clusterId);
}else{
if(log.isDebugEnabled()){
log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId));
}
return;
}
if(null != monitor){
NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId);
if(null != networkPartitionContext){
networkPartitionContext.setAverageRequestsInFlight(floatValue);
} else {
if(log.isDebugEnabled()) {
log.debug(String.format("Network partition context is not available for :" +
" [network partition] %s", networkPartitionId));
}
}
}
}
});
healthStatEventReceiver.addEventListener(new GradientOfLoadAverageEventListener() {
@Override
protected void onEvent(org.apache.stratos.messaging.event.Event event) {
GradientOfLoadAverageEvent e = (GradientOfLoadAverageEvent) event;
String clusterId = e.getClusterId();
String networkPartitionId = e.getNetworkPartitionId();
Float floatValue = e.getValue();
if (log.isDebugEnabled()) {
log.debug(String.format("Grad of load avg event: [cluster] %s [network-partition] %s [value] %s",
clusterId, networkPartitionId, floatValue));
}
AutoscalerContext asCtx = AutoscalerContext.getInstance();
AbstractMonitor monitor;
if(asCtx.monitorExist(clusterId)){
monitor = asCtx.getMonitor(clusterId);
}else if(asCtx.lbMonitorExist(clusterId)){
monitor = asCtx.getLBMonitor(clusterId);
}else{
if(log.isDebugEnabled()){
log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId));
}
return;
}
if(null != monitor){
NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId);
if(null != networkPartitionContext){
networkPartitionContext.setLoadAverageGradient(floatValue);
} else {
if(log.isDebugEnabled()) {
log.debug(String.format("Network partition context is not available for :" +
" [network partition] %s", networkPartitionId));
}
}
}
}
});
healthStatEventReceiver.addEventListener(new GradientOfMemoryConsumptionEventListener() {
@Override
protected void onEvent(org.apache.stratos.messaging.event.Event event) {
GradientOfMemoryConsumptionEvent e = (GradientOfMemoryConsumptionEvent) event;
String clusterId = e.getClusterId();
String networkPartitionId = e.getNetworkPartitionId();
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));
}
AutoscalerContext asCtx = AutoscalerContext.getInstance();
AbstractMonitor monitor;
if(asCtx.monitorExist(clusterId)){
monitor = asCtx.getMonitor(clusterId);
}else if(asCtx.lbMonitorExist(clusterId)){
monitor = asCtx.getLBMonitor(clusterId);
}else{
if(log.isDebugEnabled()){
log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId));
}
return;
};
if(null != monitor){
NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId);
if(null != networkPartitionContext){
networkPartitionContext.setMemoryConsumptionGradient(floatValue);
} else {
if(log.isDebugEnabled()) {
log.debug(String.format("Network partition context is not available for :" +
" [network partition] %s", networkPartitionId));
}
}
}
}
});
healthStatEventReceiver.addEventListener(new GradientOfRequestsInFlightEventListener() {
@Override
protected void onEvent(org.apache.stratos.messaging.event.Event event) {
GradientOfRequestsInFlightEvent e = (GradientOfRequestsInFlightEvent) event;
String clusterId = e.getClusterId();
String networkPartitionId = e.getNetworkPartitionId();
Float floatValue = e.getValue();
if (log.isDebugEnabled()) {
log.debug(String.format("Gradient of Rif event: [cluster] %s [network-partition] %s [value] %s",
clusterId, networkPartitionId, floatValue));
}
AutoscalerContext asCtx = AutoscalerContext.getInstance();
AbstractMonitor monitor;
if(asCtx.monitorExist(clusterId)){
monitor = asCtx.getMonitor(clusterId);
}else if(asCtx.lbMonitorExist(clusterId)){
monitor = asCtx.getLBMonitor(clusterId);
}else{
if(log.isDebugEnabled()){
log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId));
}
return;
}
if(null != monitor){
NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId);
if(null != networkPartitionContext){
networkPartitionContext.setRequestsInFlightGradient(floatValue);
} else {
if(log.isDebugEnabled()) {
log.debug(String.format("Network partition context is not available for :" +
" [network partition] %s", networkPartitionId));
}
}
}
}
});
healthStatEventReceiver.addEventListener(new MemberAverageLoadAverageEventListener() {
@Override
protected void onEvent(org.apache.stratos.messaging.event.Event event) {
MemberAverageLoadAverageEvent e = (MemberAverageLoadAverageEvent) event;
LoadAverage loadAverage = findLoadAverage(e.getMemberId());
if(loadAverage != null) {
Float floatValue = e.getValue();
loadAverage.setAverage(floatValue);
if (log.isDebugEnabled()) {
log.debug(String.format("Member avg of load avg event: [member] %s [value] %s", e.getMemberId()
, floatValue));
}
}
}
});
healthStatEventReceiver.addEventListener(new MemberAverageMemoryConsumptionEventListener() {
@Override
protected void onEvent(org.apache.stratos.messaging.event.Event event) {
MemberAverageMemoryConsumptionEvent e = (MemberAverageMemoryConsumptionEvent) event;
MemoryConsumption memoryConsumption = findMemoryConsumption(e.getMemberId());
if(memoryConsumption != null) {
Float floatValue = e.getValue();
memoryConsumption.setAverage(floatValue);
if (log.isDebugEnabled()) {
log.debug(String.format("Member avg Memory Consumption event: [member] %s [value] %s", e.getMemberId(),
floatValue));
}
}
}
});
healthStatEventReceiver.addEventListener(new MemberFaultEventListener() {
@Override
protected void onEvent(org.apache.stratos.messaging.event.Event event) {
MemberFaultEvent e = (MemberFaultEvent) event;
String clusterId = e.getClusterId();
String memberId = e.getMemberId();
if (memberId == null || memberId.isEmpty()) {
if(log.isErrorEnabled()) {
log.error("Member id not found in received message");
}
} else {
if (log.isDebugEnabled()) {
log.debug(String.format("Member fault event: [member] %s ", e.getMemberId()));
}
handleMemberFaultEvent(clusterId, memberId);
}
}
});
healthStatEventReceiver.addEventListener(new MemberGradientOfLoadAverageEventListener() {
@Override
protected void onEvent(org.apache.stratos.messaging.event.Event event) {
MemberGradientOfLoadAverageEvent e = (MemberGradientOfLoadAverageEvent) event;
LoadAverage loadAverage = findLoadAverage(e.getMemberId());
if(loadAverage != null) {
Float floatValue = e.getValue();
loadAverage.setGradient(floatValue);
if (log.isDebugEnabled()) {
log.debug(String.format("Member grad of load avg event: [member] %s [value] %s", e.getMemberId(),
floatValue));
}
}
}
});
healthStatEventReceiver.addEventListener(new MemberGradientOfMemoryConsumptionEventListener() {
@Override
protected void onEvent(org.apache.stratos.messaging.event.Event event) {
MemberGradientOfMemoryConsumptionEvent e = (MemberGradientOfMemoryConsumptionEvent) event;
MemoryConsumption memoryConsumption = findMemoryConsumption(e.getMemberId());
if(memoryConsumption != null) {
Float floatValue = e.getValue();
memoryConsumption.setGradient(floatValue);
if (log.isDebugEnabled()) {
log.debug(String.format("Member grad of Memory Consumption event: [member] %s [value] %s", e.getMemberId(),
floatValue));
}
}
}
});
healthStatEventReceiver.addEventListener(new MemberSecondDerivativeOfLoadAverageEventListener() {
@Override
protected void onEvent(org.apache.stratos.messaging.event.Event event) {
MemberSecondDerivativeOfLoadAverageEvent e = (MemberSecondDerivativeOfLoadAverageEvent) event;
LoadAverage loadAverage = findLoadAverage(e.getMemberId());
if(loadAverage != null) {
Float floatValue = e.getValue();
loadAverage.setSecondDerivative(floatValue);
if (log.isDebugEnabled()) {
log.debug(String.format("Member Second Derivation of load avg event: [member] %s [value] %s", e.getMemberId()
, floatValue));
}
}
}
});
healthStatEventReceiver.addEventListener(new MemberSecondDerivativeOfMemoryConsumptionEventListener() {
@Override
protected void onEvent(org.apache.stratos.messaging.event.Event event) {
}
});
healthStatEventReceiver.addEventListener(new SecondDerivativeOfLoadAverageEventListener() {
@Override
protected void onEvent(org.apache.stratos.messaging.event.Event event) {
SecondDerivativeOfLoadAverageEvent e = (SecondDerivativeOfLoadAverageEvent) event;
String clusterId = e.getClusterId();
String networkPartitionId = e.getNetworkPartitionId();
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));
}
AutoscalerContext asCtx = AutoscalerContext.getInstance();
AbstractMonitor monitor;
if(asCtx.monitorExist(clusterId)){
monitor = asCtx.getMonitor(clusterId);
}else if(asCtx.lbMonitorExist(clusterId)){
monitor = asCtx.getLBMonitor(clusterId);
}else{
if(log.isDebugEnabled()){
log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId));
}
return;
}
if(null != monitor){
NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId);
if(null != networkPartitionContext){
networkPartitionContext.setLoadAverageSecondDerivative(floatValue);
} else {
if(log.isDebugEnabled()) {
log.debug(String.format("Network partition context is not available for :" +
" [network partition] %s", networkPartitionId));
}
}
}
}
});
healthStatEventReceiver.addEventListener(new SecondDerivativeOfMemoryConsumptionEventListener() {
@Override
protected void onEvent(org.apache.stratos.messaging.event.Event event) {
SecondDerivativeOfMemoryConsumptionEvent e = (SecondDerivativeOfMemoryConsumptionEvent) event;
String clusterId = e.getClusterId();
String networkPartitionId = e.getNetworkPartitionId();
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));
}
AutoscalerContext asCtx = AutoscalerContext.getInstance();
AbstractMonitor monitor;
if(asCtx.monitorExist(clusterId)){
monitor = asCtx.getMonitor(clusterId);
}else if(asCtx.lbMonitorExist(clusterId)){
monitor = asCtx.getLBMonitor(clusterId);
}else{
if(log.isDebugEnabled()){
log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId));
}
return;
}
if(null != monitor){
NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId);
if(null != networkPartitionContext){
networkPartitionContext.setMemoryConsumptionSecondDerivative(floatValue);
} else {
if(log.isDebugEnabled()) {
log.debug(String.format("Network partition context is not available for :" +
" [network partition] %s", networkPartitionId));
}
}
}
}
});
healthStatEventReceiver.addEventListener(new SecondDerivativeOfRequestsInFlightEventListener() {
@Override
protected void onEvent(org.apache.stratos.messaging.event.Event event) {
SecondDerivativeOfRequestsInFlightEvent e = (SecondDerivativeOfRequestsInFlightEvent) event;
String clusterId = e.getClusterId();
String networkPartitionId = e.getNetworkPartitionId();
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));
}
AutoscalerContext asCtx = AutoscalerContext.getInstance();
AbstractMonitor monitor;
if(asCtx.monitorExist(clusterId)){
monitor = asCtx.getMonitor(clusterId);
}else if(asCtx.lbMonitorExist(clusterId)){
monitor = asCtx.getLBMonitor(clusterId);
}else{
if(log.isDebugEnabled()){
log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId));
}
return;