1 23 24 package com.sun.enterprise.connectors.work.monitor; 25 26 import com.sun.enterprise.admin.monitor.stats.ConnectorWorkMgmtStats; 27 import com.sun.enterprise.admin.monitor.stats.CountStatisticImpl; 28 import com.sun.enterprise.admin.monitor.stats.GenericStatsImpl; 29 import com.sun.enterprise.admin.monitor.stats.MutableCountStatistic; 30 import com.sun.enterprise.admin.monitor.stats.MutableCountStatisticImpl; 31 import com.sun.enterprise.admin.monitor.stats.RangeStatisticImpl; 32 import com.sun.enterprise.connectors.ActiveInboundResourceAdapter; 33 import com.sun.enterprise.resource.monitor.AbstractStatsImpl; 34 35 import com.sun.logging.LogDomains; 36 37 import java.util.logging.Level ; 38 import java.util.logging.Logger ; 39 40 import javax.management.j2ee.statistics.CountStatistic ; 41 import javax.management.j2ee.statistics.RangeStatistic ; 42 43 50 public class ConnectorWorkMgmtStatsImpl extends AbstractStatsImpl 51 implements ConnectorWorkMgmtStats { 52 53 private static Logger _logger = 54 LogDomains.getLogger( LogDomains.RSR_LOGGER ); 55 private GenericStatsImpl gsImpl; 56 57 private RangeStatistic activeWorkCount; 58 private RangeStatistic waitQueueLength; 59 private RangeStatistic workRequestWaitTime; 60 private MutableCountStatistic submittedWorkCount; 61 private MutableCountStatistic rejectedWorkCount; 62 private MutableCountStatistic completedWorkCount; 63 private MonitorableWorkManager workManager; 64 65 public ConnectorWorkMgmtStatsImpl( ActiveInboundResourceAdapter inboundRA ) { 66 this.workManager = (MonitorableWorkManager)inboundRA. 67 getBootStrapContext().getWorkManager(); 68 initializeStatistics(); 69 try { 70 gsImpl = new GenericStatsImpl( 71 this.getClass().getInterfaces()[0].getName(), this ); 72 } catch( ClassNotFoundException cnfe ) { 73 _logger.log( Level.INFO, "workmgmtmon.cnfe", "GenericStatsImpl" ); 75 } 76 } 77 78 79 private void initializeStatistics() { 80 long time = System.currentTimeMillis(); 81 CountStatistic cs = null; 82 83 cs = new CountStatisticImpl(0, 84 "SubmittedWorkCount", "", 85 "Number of work objects submitted by a connector module for execution" 86 + "WorkQueue before executing",time, time); 87 submittedWorkCount = new MutableCountStatisticImpl( cs ); 88 89 cs = new CountStatisticImpl(0, 90 "RejectedWorkCount", "", 91 "Number of work objects rejected by the application server",time, time); 92 rejectedWorkCount = new MutableCountStatisticImpl( cs ); 93 94 cs = new CountStatisticImpl(0, 95 "CompletedWorkCount", "", 96 "Number of work objects completed execution",time, time); 97 completedWorkCount = new MutableCountStatisticImpl( cs ); 98 99 activeWorkCount = new RangeStatisticImpl(0, 0, 104 1, "ActiveWorkCount", "", 105 "Number of active work objects", 106 time, time); 107 108 waitQueueLength = new RangeStatisticImpl(0, 0, 109 1, "WaitQueueLength", "", 110 "Number of work objects waiting in the queue for execution", 111 time, time); 112 113 workRequestWaitTime = new RangeStatisticImpl(0, 0, 114 1, "workRequestWaitTime", "", 115 "Number of work objects waiting in the queue for execution", 116 time, time); 117 } 118 119 public RangeStatistic getActiveWorkCount() { 120 activeWorkCount = getUpdatedRangeStatistic(activeWorkCount, 121 workManager.getCurrentActiveWorkCount(), 122 workManager.getMaxActiveWorkCount(), 123 workManager.getMinActiveWorkCount()); 124 return activeWorkCount; 125 } 126 127 public RangeStatistic getWaitQueueLength() { 128 waitQueueLength = getUpdatedRangeStatistic(waitQueueLength, 0, 129 workManager.getMaxWaitQueueLength(), 130 workManager.getMinWaitQueueLength()); 131 return waitQueueLength; 132 } 133 134 public RangeStatistic getWorkRequestWaitTime() { 135 workRequestWaitTime = getUpdatedRangeStatistic(workRequestWaitTime, 0, 136 workManager.getMaxWorkRequestWaitTime(), 137 workManager.getMinWorkRequestWaitTime()); 138 return workRequestWaitTime; 139 } 140 141 public CountStatistic getSubmittedWorkCount() { 142 submittedWorkCount.setCount( workManager.getSubmittedWorkCount()); 143 return (CountStatistic) submittedWorkCount.unmodifiableView(); 144 } 145 146 public CountStatistic getRejectedWorkCount() { 147 rejectedWorkCount.setCount( workManager.getRejectedWorkCount()); 148 return (CountStatistic) rejectedWorkCount.unmodifiableView(); 149 } 150 151 public CountStatistic getCompletedWorkCount() { 152 completedWorkCount.setCount( workManager.getCompletedWorkCount()); 153 return (CountStatistic) completedWorkCount.unmodifiableView(); 154 } 155 } 156 | Popular Tags |