/** * Calculates Sum of requestCount, errorCount and processingTime for all servlets for the given * application. It also works out minimum value of minTime and maximum value for maxTime for all * servlets. * * @param context the context whose stats will be collected * @param app the application in which to store the collected stats */ public static void collectApplicationServletStats(Context context, Application app) { int svltCount = 0; int reqCount = 0; int errCount = 0; long procTime = 0; long minTime = Long.MAX_VALUE; long maxTime = 0; for (Container container : context.findChildren()) { if (container instanceof StandardWrapper) { StandardWrapper sw = (StandardWrapper) container; svltCount++; reqCount += sw.getRequestCount(); errCount += sw.getErrorCount(); procTime += sw.getProcessingTime(); if (sw.getRequestCount() > 0) { minTime = Math.min(minTime, sw.getMinTime()); } maxTime = Math.max(maxTime, sw.getMaxTime()); } } app.setServletCount(svltCount); app.setRequestCount(reqCount); app.setErrorCount(errCount); app.setProcessingTime(procTime); app.setMinTime(minTime == Long.MAX_VALUE ? 0 : minTime); app.setMaxTime(maxTime); }
private static ServletInfo getServletInfo(Wrapper wrapper, String contextName) { ServletInfo si = new ServletInfo(); si.setApplicationName(contextName.length() > 0 ? contextName : "/"); si.setServletName(wrapper.getName()); si.setServletClass(wrapper.getServletClass()); si.setAvailable(!wrapper.isUnavailable()); si.setLoadOnStartup(wrapper.getLoadOnStartup()); si.setRunAs(wrapper.getRunAs()); si.getMappings().addAll(Arrays.asList(wrapper.findMappings())); if (wrapper instanceof StandardWrapper) { StandardWrapper sw = (StandardWrapper) wrapper; si.setAllocationCount(sw.getCountAllocated()); si.setErrorCount(sw.getErrorCount()); si.setLoadTime(sw.getLoadTime()); si.setMaxInstances(sw.getMaxInstances()); si.setMaxTime(sw.getMaxTime()); si.setMinTime(sw.getMinTime() == Long.MAX_VALUE ? 0 : sw.getMinTime()); si.setProcessingTime(sw.getProcessingTime()); si.setRequestCount(sw.getRequestCount()); si.setSingleThreaded(sw.isSingleThreadModel()); } return si; }