Пример #1
0
  public StandardWrapper addServlet(String path, String name, String clazz)
      throws ServletException {
    StandardWrapper servlet = (StandardWrapper) rootContext.createWrapper();
    servlet.setName(name);
    servlet.setServletClass(clazz);
    servlet.setLoadOnStartup(1);

    rootContext.addChild(servlet);
    rootContext.addServletMapping(path, name);

    servlet.setParent(rootContext);
    //        servlet.load();

    return servlet;
  }
Пример #2
0
  /**
   * 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);
  }
Пример #3
0
 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;
 }