1 7 8 package com.sun.corba.se.impl.transport; 9 10 import java.util.ArrayList ; 11 import java.util.Collection ; 12 13 import com.sun.corba.se.pept.broker.Broker; 14 import com.sun.corba.se.pept.transport.Acceptor; 15 import com.sun.corba.se.pept.transport.Connection; 16 import com.sun.corba.se.pept.transport.InboundConnectionCache; 17 18 import com.sun.corba.se.spi.monitoring.LongMonitoredAttributeBase; 19 import com.sun.corba.se.spi.monitoring.MonitoringConstants; 20 import com.sun.corba.se.spi.monitoring.MonitoringFactories; 21 import com.sun.corba.se.spi.monitoring.MonitoredObject; 22 import com.sun.corba.se.spi.orb.ORB; 23 import com.sun.corba.se.spi.transport.CorbaConnectionCache; 24 import com.sun.corba.se.spi.transport.CorbaAcceptor; 25 26 import com.sun.corba.se.impl.orbutil.ORBUtility; 27 28 31 public class CorbaInboundConnectionCacheImpl 32 extends 33 CorbaConnectionCacheBase 34 implements 35 InboundConnectionCache 36 { 37 protected Collection connectionCache; 38 39 public CorbaInboundConnectionCacheImpl(ORB orb, Acceptor acceptor) 40 { 41 super(orb, acceptor.getConnectionCacheType(), 42 ((CorbaAcceptor)acceptor).getMonitoringName()); 43 this.connectionCache = new ArrayList (); 44 } 45 46 51 public Connection get(Acceptor acceptor) 52 { 53 throw wrapper.methodShouldNotBeCalled(); 54 } 55 56 public void put(Acceptor acceptor, Connection connection) 57 { 58 if (orb.transportDebugFlag) { 59 dprint(".put: " + acceptor + " " + connection); 60 } 61 synchronized (backingStore()) { 62 connectionCache.add(connection); 63 connection.setConnectionCache(this); 64 dprintStatistics(); 65 } 66 } 67 68 public void remove(Connection connection) 69 { 70 if (orb.transportDebugFlag) { 71 dprint(".remove: " + connection); 72 } 73 synchronized (backingStore()) { 74 connectionCache.remove(connection); 75 dprintStatistics(); 76 } 77 } 78 79 84 public Collection values() 85 { 86 return connectionCache; 87 } 88 89 protected Object backingStore() 90 { 91 return connectionCache; 92 } 93 94 protected void registerWithMonitoring() 95 { 96 MonitoredObject orbMO = 98 orb.getMonitoringManager().getRootMonitoredObject(); 99 100 102 MonitoredObject connectionMO = 104 orbMO.getChild(MonitoringConstants.CONNECTION_MONITORING_ROOT); 105 if (connectionMO == null) { 106 connectionMO = 107 MonitoringFactories.getMonitoredObjectFactory() 108 .createMonitoredObject( 109 MonitoringConstants.CONNECTION_MONITORING_ROOT, 110 MonitoringConstants.CONNECTION_MONITORING_ROOT_DESCRIPTION); 111 orbMO.addChild(connectionMO); 112 } 113 114 MonitoredObject inboundConnectionMO = 116 connectionMO.getChild( 117 MonitoringConstants.INBOUND_CONNECTION_MONITORING_ROOT); 118 if (inboundConnectionMO == null) { 119 inboundConnectionMO = 120 MonitoringFactories.getMonitoredObjectFactory() 121 .createMonitoredObject( 122 MonitoringConstants.INBOUND_CONNECTION_MONITORING_ROOT, 123 MonitoringConstants.INBOUND_CONNECTION_MONITORING_ROOT_DESCRIPTION); 124 connectionMO.addChild(inboundConnectionMO); 125 } 126 127 MonitoredObject thisMO = 129 inboundConnectionMO.getChild(getMonitoringName()); 130 if (thisMO == null) { 131 thisMO = 132 MonitoringFactories.getMonitoredObjectFactory() 133 .createMonitoredObject( 134 getMonitoringName(), 135 MonitoringConstants.CONNECTION_MONITORING_DESCRIPTION); 136 inboundConnectionMO.addChild(thisMO); 137 } 138 139 LongMonitoredAttributeBase attribute; 140 141 attribute = new 143 LongMonitoredAttributeBase( 144 MonitoringConstants.CONNECTION_TOTAL_NUMBER_OF_CONNECTIONS, 145 MonitoringConstants.CONNECTION_TOTAL_NUMBER_OF_CONNECTIONS_DESCRIPTION) 146 { 147 public Object getValue() { 148 return new Long (CorbaInboundConnectionCacheImpl.this.numberOfConnections()); 149 } 150 }; 151 thisMO.addAttribute(attribute); 152 153 attribute = new 155 LongMonitoredAttributeBase( 156 MonitoringConstants.CONNECTION_NUMBER_OF_IDLE_CONNECTIONS, 157 MonitoringConstants.CONNECTION_NUMBER_OF_IDLE_CONNECTIONS_DESCRIPTION) 158 { 159 public Object getValue() { 160 return new Long (CorbaInboundConnectionCacheImpl.this.numberOfIdleConnections()); 161 } 162 }; 163 thisMO.addAttribute(attribute); 164 165 attribute = new 167 LongMonitoredAttributeBase( 168 MonitoringConstants.CONNECTION_NUMBER_OF_BUSY_CONNECTIONS, 169 MonitoringConstants.CONNECTION_NUMBER_OF_BUSY_CONNECTIONS_DESCRIPTION) 170 { 171 public Object getValue() { 172 return new Long (CorbaInboundConnectionCacheImpl.this.numberOfBusyConnections()); 173 } 174 }; 175 thisMO.addAttribute(attribute); 176 } 177 178 protected void dprint(String msg) 179 { 180 ORBUtility.dprint("CorbaInboundConnectionCacheImpl", msg); 181 } 182 } 183 184 | Popular Tags |