Methods Summary |
---|
public void | changeLevel(com.sun.enterprise.admin.monitor.registry.MonitoringLevel from, com.sun.enterprise.admin.monitor.registry.MonitoringLevel to, javax.management.j2ee.statistics.Stats handback)This is the callback method called when the monitoring level
changes from HIGH/LOW <-> OFF
Here since the MonitoringLevel is a "type-safe enum", we
can directly check equality using ==
|
public void | changeLevel(com.sun.enterprise.admin.monitor.registry.MonitoringLevel from, com.sun.enterprise.admin.monitor.registry.MonitoringLevel to, com.sun.enterprise.admin.monitor.registry.MonitoredObjectType type)
//If we were called, the type has to be JDBC_CONN_POOL so
//we can safely ignore the type
if ( from == to ) {
//Its a no-op, so return
return;
}
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
ServerContext ctxt = ApplicationServer.getServerContext();
if (ctxt != null) {
registry_ = ctxt.getMonitoringRegistry();
}
return null;
}
});
if (from == OFF || from == LOW) {
if (to == HIGH) {
logFine("Changing level from " + from +" to HIGH");
transitionToHigh();
}
}
if (from == HIGH || from == LOW ) {
if ( to == OFF ) {
logFine("Switching level from " + from + " to OFF");
switchOffMonitoring();
}
}
if (from == OFF || from == HIGH ) {
if ( to == LOW ) {
logFine("Changing level from " + from + " to LOW");
transitionToLow();
}
}
|
private com.sun.enterprise.resource.MonitorableResourcePool[] | getPoolList()
ResourcesUtil resUtil = ResourcesUtil.createInstance();
JdbcConnectionPool[] jp = resUtil.getJdbcConnectionPools();
if (jp == null) {
return null;
}
MonitorableResourcePool[] pools = new MonitorableResourcePool[ jp.length ];
ConcurrentHashMap poolTable = getPoolManager().getPoolTable();
for( int i = 0 ; i < jp.length; i++ ) {
ResourcePool p = (ResourcePool) poolTable.get( jp[i].getName() );
if (p != null && (p instanceof MonitorableResourcePool ) ) {
pools[i] = (MonitorableResourcePool)p;
}
}
return pools;
|
private com.sun.enterprise.PoolManager | getPoolManager()
return Switch.getSwitch().getPoolManager();
|
private void | logFine(java.lang.String msg)
if (_logger.isLoggable( Level.FINE ) && msg != null ) {
_logger.fine( msg );
}
|
public void | setLevel(com.sun.enterprise.admin.monitor.registry.MonitoringLevel level)This is the callback for change in monitoring levels.
This shall go off once the admin team removes this method
|
private void | switchOffMonitoring()
//deregister
AccessController.doPrivileged( new PrivilegedAction() {
public Object run() {
MonitorableResourcePool[] pools = getPoolList();
if (pools == null) {
return null;
}
for (MonitorableResourcePool pool : pools) {
if (pool != null) {
try {
registry_.unregisterJDBCConnectionPoolStats(
pool.getPoolName());
getPoolManager().disableMonitoring(
pool.getPoolName());
} catch (Exception mre) {
_logger.log(Level.WARNING, "poolmon.cannot_unreg: "
+ pool.getPoolName(), mre.getMessage());
}
}
}
return null;
}
});
|
private void | transitionToHigh()
transitionToSpecifiedLevel(MonitoringLevel.HIGH);
|
private void | transitionToLow()
transitionToSpecifiedLevel(MonitoringLevel.LOW);
|
private void | transitionToSpecifiedLevel(com.sun.enterprise.admin.monitor.registry.MonitoringLevel monitoringLevel)
AccessController.doPrivileged( new PrivilegedAction() {
public Object run() {
//we should create a new pool object everytime since
//the stats have to be collected afresh
MonitorableResourcePool[] pools = getPoolList();
if (pools == null) {
return null;
}
for (MonitorableResourcePool pool : pools) {
if (pool != null) {
try {
JDBCConnectionPoolStatsImpl stats = new
JDBCConnectionPoolStatsImpl(pool);
if(monitoringLevel == MonitoringLevel.HIGH )
getPoolManager().setMonitoringEnabledHigh(pool.getPoolName());
else if(monitoringLevel == MonitoringLevel.LOW )
getPoolManager().setMonitoringEnabledLow(pool.getPoolName());
registry_.registerJDBCConnectionPoolStats(
stats, pool.getPoolName(), null);
} catch (Exception mre) {
try {
_logger.log(Level.INFO, "poolmon.cannot_reg: " +
pool.getPoolName(), mre.getMessage());
getPoolManager().disableMonitoring(
pool.getPoolName());
} catch (Exception ex) {
//FIXME: ignore?
}
}
}
}
return null;
}
});
|