1 23 24 package com.sun.enterprise.iiop; 25 26 import java.util.Iterator ; 27 28 import javax.management.j2ee.statistics.CountStatistic ; 29 import javax.management.j2ee.statistics.BoundedRangeStatistic ; 30 import javax.management.j2ee.statistics.RangeStatistic ; 31 32 import com.sun.enterprise.admin.monitor.stats.BoundedRangeStatisticImpl; 33 import com.sun.enterprise.admin.monitor.stats.CountStatisticImpl; 34 import com.sun.enterprise.admin.monitor.stats.OrbConnectionManagerStats; 35 import com.sun.enterprise.admin.monitor.stats.MutableCountStatisticImpl; 36 import com.sun.enterprise.admin.monitor.stats.MutableBoundedRangeStatisticImpl; 37 import com.sun.enterprise.admin.monitor.stats.StatisticImpl; 38 39 import com.sun.corba.ee.spi.monitoring.MonitoringConstants; 40 import com.sun.corba.ee.spi.monitoring.MonitoringManager; 41 import com.sun.corba.ee.spi.monitoring.MonitoredObject; 42 43 50 51 public class OrbConnectionManagerStatsImpl 52 extends ORBCommonStatsImpl 53 implements OrbConnectionManagerStats 54 { 55 56 private MonitoredObject connection; 57 private String connectionName; 58 59 private static String stringTotalConnections = 60 MonitoringConstants.CONNECTION_TOTAL_NUMBER_OF_CONNECTIONS; 61 private static String stringIdleConnections = 62 MonitoringConstants.CONNECTION_NUMBER_OF_IDLE_CONNECTIONS; 63 private static String stringBusyConnections = 64 MonitoringConstants.CONNECTION_NUMBER_OF_BUSY_CONNECTIONS; 65 66 private MutableBoundedRangeStatisticImpl totalConnections; 67 private MutableCountStatisticImpl idleConnections; 68 private MutableCountStatisticImpl busyConnections; 69 70 71 public OrbConnectionManagerStatsImpl( MonitoredObject connectionNode ) { 72 this.connection = connectionNode; 73 this.connectionName = connection.getName(); 74 75 initializeStats(); 76 } 77 78 private void initializeStats() { 79 super.initialize( 80 "com.sun.enterprise.admin.monitor.stats.OrbConnectionManagerStats"); 81 82 final long time = System.currentTimeMillis(); 83 84 totalConnections = 85 new MutableBoundedRangeStatisticImpl( 86 new BoundedRangeStatisticImpl( 0, 0, 0, 87 java.lang.Long.MAX_VALUE, 0, 88 "TotalConnections", "count", 89 connection.getAttribute( stringTotalConnections ). 90 getAttributeInfo( ).getDescription(), 91 time, time )); 92 93 idleConnections = 94 new MutableCountStatisticImpl( 95 new CountStatisticImpl( 96 "ConnectionsIdle", "count", 97 connection.getAttribute( stringIdleConnections ). 98 getAttributeInfo( ).getDescription() )); 99 100 busyConnections = 101 new MutableCountStatisticImpl( 102 new CountStatisticImpl( 103 "ConnectionsInUse", "count", 104 connection.getAttribute( stringBusyConnections ). 105 getAttributeInfo( ).getDescription() )); 106 } 107 108 public BoundedRangeStatistic getTotalConnections() { 109 110 long totalNumberOfConnections = ((Long ) connection.getAttribute( 111 stringTotalConnections ).getValue()).longValue(); 112 113 totalConnections.setCount( totalNumberOfConnections ); 114 115 return (BoundedRangeStatistic ) totalConnections.modifiableView(); 116 } 117 118 119 public CountStatistic getConnectionsIdle() { 120 121 long numberIdleConnections = ((Long ) connection.getAttribute( 122 stringIdleConnections ).getValue()).longValue(); 123 124 125 idleConnections.setCount( numberIdleConnections ); 126 127 return (CountStatistic ) idleConnections.modifiableView(); 128 } 129 130 131 public CountStatistic getConnectionsInUse() { 132 133 long numberBusyConnections = ((Long ) connection.getAttribute( 134 stringBusyConnections ).getValue()).longValue(); 135 136 busyConnections.setCount( numberBusyConnections ); 137 138 return (CountStatistic ) busyConnections.modifiableView(); 139 } 140 141 142 } | Popular Tags |