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

HttpListenerMonitorTask

public class HttpListenerMonitorTask extends MonitorTask

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


             
                                        
         
    
        super(srm, filter, timer, verbose, fileName);
        final HTTPServiceMonitor httpserviceMonitor = srm.getHTTPServiceMonitor();
        if (httpserviceMonitor == null)
            throw new MonitorTaskException(localStrings.getString("commands.monitor.unable_to_monitor_httplistener"));
        
        final Map<String,HTTPListenerMonitor> httpListenerMap = httpserviceMonitor.getHTTPListenerMonitorMap();
        if (httpListenerMap == null)
            throw new MonitorTaskException(localStrings.getString("commands.monitor.unable_to_monitor_httplistener"));
        
        final String[] keys = MapUtil.getKeyStrings(httpListenerMap);
        if (this.filter == null)
        {
            checkForNumberOfElements(keys);
            this.filter = keys[0];
        }
        else {
            if (!httpListenerMap.containsKey(this.filter)) {
                throw new MonitorTaskException(localStrings.getString("commands.monitor.does_not_exist", new Object[] {this.filter}));
            }
        }
        final String httpListenerTitle=localStrings.getString("commands.monitor.httplistener_monitoring_title", new Object[] {this.filter});
        final String title = String.format("%1$60s", httpListenerTitle);
        CLILogger.getInstance().printMessage(title);
        displayHeader();        
    
Methods Summary
private voiddisplayData(HTTPListenerStats hls)

        final String data = String.format(displayFormat,
                                          hls.getBytesReceived().getCount(),
                                          hls.getBytesSent().getCount(),
                                          hls.getCount200().getCount(),
                                          hls.getCount2xx().getCount(),
                                          hls.getCount302().getCount(),
                                          hls.getCount304().getCount(),
                                          hls.getCount3xx().getCount(),
                                          hls.getCount400().getCount(),
                                          hls.getCount401().getCount(),
                                          hls.getCount403().getCount(),
                                          hls.getCount404().getCount(),
                                          hls.getCount4xx().getCount(),
                                          hls.getCount503().getCount(),
                                          hls.getCount5xx().getCount(),
                                          hls.getCountOpenConnections().getCount(),
                                          hls.getCountOther().getCount(),
                                          hls.getCurrentThreadCount().getCount(),
                                          hls.getCurrentThreadsBusy().getCount(),
                                          hls.getErrorCount().getCount(),
                                          hls.getMaxOpenConnections().getCount(),
                                          hls.getMaxSpareThreads().getCount(),
                                          hls.getMaxThreads().getCount(),
                                          hls.getMaxTime().getCount(),
                                          hls.getMinSpareThreads().getCount(),
                                          hls.getProcessingTime().getCount(),
                                          hls.getRequestCount().getCount());
        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,%8$s,"+
                                              "%9$s,%10$s,%11$s,%12$s,%13$s,%14$s,%15$s,"+
                                              "%16$s,%17$s,%18$s,%19$s,%20$s,%21$s,%22$s,"+
                                              "%23$s,%24$s,%25$s,%26$s",
                                              hls.getBytesReceived().getCount(),
                                              hls.getBytesSent().getCount(),
                                              hls.getCount200().getCount(),
                                              hls.getCount2xx().getCount(),
                                              hls.getCount302().getCount(),
                                              hls.getCount304().getCount(),
                                              hls.getCount3xx().getCount(),
                                              hls.getCount400().getCount(),
                                              hls.getCount401().getCount(),
                                              hls.getCount403().getCount(),
                                              hls.getCount404().getCount(),
                                              hls.getCount4xx().getCount(),
                                              hls.getCount503().getCount(),
                                              hls.getCount5xx().getCount(),
                                              hls.getCountOpenConnections().getCount(),
                                              hls.getCountOther().getCount(),
                                              hls.getCurrentThreadCount().getCount(),
                                              hls.getCurrentThreadsBusy().getCount(),
                                              hls.getErrorCount().getCount(),
                                              hls.getMaxOpenConnections().getCount(),
                                              hls.getMaxSpareThreads().getCount(),
                                              hls.getMaxThreads().getCount(),
                                              hls.getMaxTime().getCount(),
                                              hls.getMinSpareThreads().getCount(),
                                              hls.getProcessingTime().getCount(),
                                              hls.getRequestCount().getCount());
            writeToFile(fileData);
        }
    
public voiddisplayDetails()

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

        final String br = localStrings.getString("commands.monitor.br");
        final String bs = localStrings.getString("commands.monitor.bs");
        final String c200 = localStrings.getString("commands.monitor.c200");
        final String c2xx = localStrings.getString("commands.monitor.c2xx");
        final String c302 = localStrings.getString("commands.monitor.c302");
        final String c304 = localStrings.getString("commands.monitor.c304");
        final String c3xx = localStrings.getString("commands.monitor.c3xx");
        final String c400 = localStrings.getString("commands.monitor.c400");
        final String c401 = localStrings.getString("commands.monitor.c401");
        final String c403 = localStrings.getString("commands.monitor.c403");
        final String c404 = localStrings.getString("commands.monitor.c404");
        final String c4xx = localStrings.getString("commands.monitor.c4xx");
        final String c503 = localStrings.getString("commands.monitor.c503");
        final String c5xx = localStrings.getString("commands.monitor.c5xx");
        final String coc = localStrings.getString("commands.monitor.coc");
        final String co = localStrings.getString("commands.monitor.co");
        final String ctc = localStrings.getString("commands.monitor.ctc");
        final String ctb = localStrings.getString("commands.monitor.ctb");
        final String ec = localStrings.getString("commands.monitor.ec");
        final String moc = localStrings.getString("commands.monitor.moc");
        final String mst = localStrings.getString("commands.monitor.mst");
        final String mt = localStrings.getString("commands.monitor.mt");
        final String mtm = localStrings.getString("commands.monitor.mtm");
        final String pt = localStrings.getString("commands.monitor.pt");
        final String rc = localStrings.getString("commands.monitor.rc");
        
        final String header = String.format(displayFormat,
                                            br,bs,c200,c2xx,c302,c304,c3xx,c400,c401,c403,
                                            c404,c4xx,c503,c5xx,coc,co,ctc,ctb,ec,moc,mst,
                                            mt,mtm,mst,pt,rc);
        CLILogger.getInstance().printMessage(header);
        
        if (fileName != null)
        {
            writeToFile(localStrings.getString("commands.monitor.httplistener_write_to_file"));
        }
    
public voidrun()

        if (srm == null) {
            super.cancelMonitorTask();
            return;
        }
        

        final HTTPServiceMonitor httpserviceMonitor = srm.getHTTPServiceMonitor();
        if (httpserviceMonitor == null) {
            cancelMonitorTask();
            return;
        }
        

        final Map<String,HTTPListenerMonitor> httpListenerMap = httpserviceMonitor.getHTTPListenerMonitorMap();
        if (httpListenerMap == null || httpListenerMap.size()<1) {
            cancelMonitorTask();
            return;
        }
        
        final HTTPListenerMonitor httpListenerMonitor = httpListenerMap.get(filter);
        if (httpListenerMonitor == null) {
            cancelMonitorTask();
            return;
        }
        
        final HTTPListenerStats httpListenerStats = httpListenerMonitor.getHTTPListenerStats();

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