1 23 package com.sun.enterprise.management.support; 24 25 import java.util.Map ; 26 import java.util.HashMap ; 27 import java.util.List ; 28 import java.util.ArrayList ; 29 import java.util.Collection ; 30 import java.io.IOException ; 31 32 import javax.management.MBeanServer ; 33 import javax.management.ObjectName ; 34 import javax.management.JMException ; 35 import javax.management.InstanceNotFoundException ; 36 37 import com.sun.appserv.management.base.AMXDebug; 38 import com.sun.appserv.management.base.Container; 39 import com.sun.appserv.management.base.Util; 40 import com.sun.appserv.management.client.ProxyFactory; 41 import com.sun.enterprise.management.support.ObjectNames; 42 43 import com.sun.appserv.management.monitor.LoadBalancerMonitor; 44 import com.sun.appserv.management.monitor.LoadBalancerClusterMonitor; 45 import com.sun.appserv.management.monitor.LoadBalancerServerMonitor; 46 import com.sun.appserv.management.monitor.LoadBalancerApplicationMonitor; 47 import com.sun.appserv.management.monitor.LoadBalancerContextRootMonitor; 48 49 import static com.sun.appserv.management.base.XTypes.SERVER_REF_CONFIG; 50 import com.sun.appserv.management.config.DeployedItemRefConfig; 51 import com.sun.appserv.management.config.ServerRefConfig; 52 import com.sun.appserv.management.config.ClusterConfig; 53 import com.sun.appserv.management.config.ServerConfig; 54 import com.sun.appserv.management.config.ClusteredServerConfig; 55 import com.sun.appserv.management.config.StandaloneServerConfig; 56 import com.sun.appserv.management.config.LBConfig; 57 84 public class LoadBalancerServerRefRegistrationListener 85 extends LBBaseMBeanRegistrationListener { 86 87 public LoadBalancerServerRefRegistrationListener(MBeanServer mBeanServer) 88 throws InstanceNotFoundException , IOException { 89 super(mBeanServer); 90 } 91 92 protected void mbeanRegistered(final ObjectName objectName) { 93 try { 94 if (SERVER_REF_CONFIG.equals(Util.getJ2EEType(objectName))) { 95 96 ServerRefConfig serverRefConfig = 97 ProxyFactory.getInstance(getConn()).getProxy(objectName, ServerRefConfig.class); 98 String serverName = serverRefConfig.getRef(); 99 Container container = serverRefConfig.getContainer(); 100 101 Map <String , ServerConfig> serverConfigMap = new HashMap <String , ServerConfig>(); 102 103 if (container instanceof LBConfig) { 104 Map <String ,StandaloneServerConfig> sserverConfigMap = 106 getDomainConfig().getStandaloneServerConfigMap(); 107 108 for (String key : sserverConfigMap.keySet()) { 111 serverConfigMap.put( 112 key, (ServerConfig)sserverConfigMap.get(key)); 113 } 114 115 List <LoadBalancerMonitor> loadBalancerMonitorList = 116 fetchLBMonitoringRoots((LBConfig)container); 117 118 for (LoadBalancerMonitor lbm : loadBalancerMonitorList) { 119 LoadBalancerClusterMonitor lbcm = 120 registerLoadBalancerClusterMonitor( 121 lbm, serverName); 122 registerLoadBalancerServerMonitorTree( 123 lbcm, serverConfigMap, serverName); 124 } } 127 else if (container instanceof ClusterConfig) { 128 Map <String ,ClusteredServerConfig> cserverConfigMap = 130 getDomainConfig().getClusteredServerConfigMap(); 131 132 for (String key : cserverConfigMap.keySet()) { 135 serverConfigMap.put( 136 key, (ServerConfig)cserverConfigMap.get(key)); 137 } 138 139 Collection <LBConfig> affectedLBConfigArr = 140 fetchLBConfigs(((ClusterConfig)container).getName(), true); 141 142 for (LBConfig lbConfig : affectedLBConfigArr) { 143 List <LoadBalancerMonitor> monitoringRoots = 144 fetchLBMonitoringRoots(lbConfig); 145 List <LoadBalancerClusterMonitor> clusterMonitors = 146 fetchLoadBalancerClusterMonitors(monitoringRoots, 147 ((ClusterConfig)container).getName()); 148 149 for (LoadBalancerClusterMonitor lbcm : clusterMonitors) { 150 registerLoadBalancerServerMonitorTree( 151 lbcm, serverConfigMap, serverName); 152 } 153 } 154 } 155 } 156 } catch (Exception ex) { 157 logWarning( 158 "LoadBalancerServerRefRegistrationListener" + 159 " mbeanRegistered failed. Exception = ", ex); 160 } 161 } 162 } 163 | Popular Tags |