FileDocCategorySizeDatePackage
ConnectionManagerMonitorTask.javaAPI DocGlassfish v2 API7789Fri May 04 22:25:18 BST 2007com.sun.enterprise.cli.commands.monitor

ConnectionManagerMonitorTask

public class ConnectionManagerMonitorTask extends MonitorTask

Fields Summary
private final String
displayFormat
Constructors Summary
public ConnectionManagerMonitorTask(ServerRootMonitor srm, String filter, Timer timer, boolean verbose, File fileName)


          
                                                
         
    
        super(srm, filter, timer, verbose, fileName);
        
        final Map<String,ConnectionManagerMonitor> connectionManagerMap  = srm.getConnectionManagerMonitorMap();
        
        if (connectionManagerMap == null)
            throw new MonitorTaskException(localStrings.getString("commands.monitor.unable_to_monitor_connection_manager"));
        
        final String[] keys = MapUtil.getKeyStrings(connectionManagerMap);
        if (this.filter == null)
        {
            checkForNumberOfElements(keys);
            this.filter = keys[0];
        }
        else {
            if (!connectionManagerMap.containsKey(this.filter)) {
                throw new MonitorTaskException(localStrings.getString("commands.monitor.does_not_exist", new Object[] {this.filter}));
            }
        }
        final String connManagerMonitoring = localStrings.getString("commands.monitor.connection_manager_monitoring_title", new Object[] {this.filter});
        final String title = String.format("%1$5s", connManagerMonitoring);
        CLILogger.getInstance().printMessage(title);
        displayHeader();        
    
Methods Summary
private voiddisplayData(ConnectionManagerStats cms)

        final String data = String.format(displayFormat,
                                          cms.getConnectionsIdle().getCount(),
                                          cms.getConnectionsInUse().getCount(),
                                          cms.getTotalConnections().getLowerBound(),
                                          cms.getTotalConnections().getUpperBound(),
                                          cms.getTotalConnections().getLowWaterMark(),
                                          cms.getTotalConnections().getHighWaterMark(),
                                          cms.getTotalConnections().getCurrent());
        CLILogger.getInstance().printMessage(data);

        if (fileName != null)
        {
            final String fileData = String.format("%1$s,%2$s,%3$s,%4$s,%5$s,%6$s,%7$s",
                                          cms.getConnectionsIdle().getCount(),
                                          cms.getConnectionsInUse().getCount(),
                                          cms.getTotalConnections().getLowerBound(),
                                          cms.getTotalConnections().getUpperBound(),
                                          cms.getTotalConnections().getLowWaterMark(),
                                          cms.getTotalConnections().getHighWaterMark(),                                          
                                          cms.getTotalConnections().getCurrent());
            writeToFile(fileData);
        }
    
public voiddisplayDetails()

        final String details = localStrings.getString("commands.monitor.connection_manager_details");
        CLILogger.getInstance().printMessage(details);
    
private voiddisplayHeader()

        final String totalConn = localStrings.getString("commands.monitor.total_connections");
        final String ci = localStrings.getString("commands.monitor.ci");
        final String ciu = localStrings.getString("commands.monitor.ciu");
        final String low = localStrings.getString("commands.monitor.low");
        final String hi = localStrings.getString("commands.monitor.hi");
        final String cur = localStrings.getString("commands.monitor.cur");
        final String min = localStrings.getString("commands.monitor.min");
        final String max = localStrings.getString("commands.monitor.max");
        
        final String header = String.format("%1$35s", totalConn);
        final String subheader = String.format(displayFormat, ci, ciu, low, hi, cur, min, max);
        
        CLILogger.getInstance().printMessage(header);
        CLILogger.getInstance().printMessage(subheader);
        if (fileName != null)
        {
            writeToFile(localStrings.getString("commands.monitor.connection_manager_write_to_file"));
        }
    
public voidrun()

        if (srm == null)
        {
            super.cancelMonitorTask();
            return;
        }
        
        final Map<String,ConnectionManagerMonitor> connectionManagerMap  = srm.getConnectionManagerMonitorMap();
        if (connectionManagerMap == null || connectionManagerMap.size()<0)
        {
            super.cancelMonitorTask();
            return;
        }
        
            
        final ConnectionManagerMonitor connectionManagerMonitor = connectionManagerMap.get(filter);
        if (connectionManagerMonitor == null)
        {
            cancelMonitorTask();
            return;
        }
            
        final ConnectionManagerStats connectionManagerStats = connectionManagerMonitor.getConnectionManagerStats();

        if (verbose && counter == NUM_ROWS)
        {
            displayHeader();
            counter = 0;  //reset to 0
        }
        displayData(connectionManagerStats);
        if (verbose) counter++;