1 23 24 29 30 package com.sun.enterprise.management.j2ee; 31 32 import java.util.Set ; 33 import java.util.Map ; 34 import java.util.HashMap ; 35 import java.util.Iterator ; 36 import java.util.Collections ; 37 38 import javax.management.ObjectName ; 39 40 import com.sun.appserv.management.base.Util; 41 import com.sun.appserv.management.util.misc.GSetUtil; 42 import com.sun.appserv.management.util.misc.ExceptionUtil; 43 44 import com.sun.appserv.management.j2ee.J2EECluster; 45 46 import com.sun.appserv.management.j2ee.J2EETypes; 47 48 import com.sun.appserv.management.j2ee.StateManageable; 49 50 51 import com.sun.enterprise.management.support.Delegate; 52 import com.sun.enterprise.management.support.oldconfig.OldClusterMBean; 53 import com.sun.enterprise.management.support.oldconfig.OldClustersMBean; 54 55 import com.sun.enterprise.admin.servermgmt.RuntimeStatusList; 56 import com.sun.enterprise.admin.servermgmt.RuntimeStatus; 57 58 61 public final class J2EEClusterImpl 62 extends J2EELogicalServerImplBase 63 { 64 public 65 J2EEClusterImpl( final Delegate delegate ) 66 { 67 super( J2EETypes.J2EE_CLUSTER, delegate ); 68 } 69 70 public String [] 71 getServerNames() 72 { 73 78 return getOldClusterMBean().listServerInstancesAsString( false ); 79 } 80 81 public Map <String ,ObjectName > 82 getServerObjectNameMap() 83 { 84 89 final Set <String > serverNamesInCluster = GSetUtil.newStringSet( getServerNames() ); 90 if ( serverNamesInCluster.size() == 0 ) 91 { 92 return Collections.emptyMap(); 93 } 94 final Set <ObjectName > allJ2EEServerObjectNames = 95 getQueryMgr().queryJ2EETypeObjectNameSet( J2EETypes.J2EE_SERVER ); 96 final Map <String ,ObjectName > objectNameMap = Util.createObjectNameMap( allJ2EEServerObjectNames ); 97 98 final Map <String ,ObjectName > serverObjectNameMap = 99 new HashMap <String ,ObjectName >( serverNamesInCluster.size() ); 100 101 for( final String nameKey : serverNamesInCluster ) 102 { 103 serverObjectNameMap.put( nameKey, objectNameMap.get( nameKey ) ); 104 } 105 return serverObjectNameMap; 106 } 107 108 public boolean 109 isstateManageable() 110 { 111 return true; 112 } 113 114 public void 115 start() 116 { 117 trace( "J2EEClusterImpl.start" ); 118 getOldClusterMBean().start(); 119 setstartTime( System.currentTimeMillis() ); 120 } 121 122 public void 123 startRecursive() 124 { 125 start(); 126 } 127 128 public void 129 stop() 130 { 131 trace( "J2EEClusterImpl.start" ); 132 getOldClusterMBean().stop(); 133 setstartTime( 0 ); 134 } 135 136 public int 137 getstate() 138 { 139 final RuntimeStatusList rsl = getRuntimeStatus(); 140 int state = rsl.anyRunning() ? 141 StateManageable.STATE_RUNNING : StateManageable.STATE_STOPPED; 142 return state; 143 } 144 private OldClusterMBean 145 getOldClusterMBean() 146 { 147 return( getOldConfigProxies().getOldClusterMBean( getSelfName() ) ); 148 } 149 150 private RuntimeStatusList 151 getRuntimeStatus() 152 { 153 158 final OldClustersMBean oldMBean = 159 getOldConfigProxies().getOldClustersMBean(); 160 return( ( RuntimeStatusList )oldMBean.getRuntimeStatus( getSelfName() ) ); 161 } 162 } 163 | Popular Tags |