Exemplo n.º 1
0
 private String debug() {
   _executor.purge(); // Remove cancelled tasks from the queue so we get a good queue size stat
   return " Pool: "
       + _name
       + " Active: "
       + _executor.getActiveCount()
       + '/'
       + _executor.getPoolSize()
       + " Completed: "
       + _executor.getCompletedTaskCount()
       + " Queued: "
       + _executor.getQueue().size();
 }
Exemplo n.º 2
0
  @Override
  public String getStatus() {
    StringWriter sw = new StringWriter();
    PrintWriter out = new PrintWriter(sw);
    if (executor == null) {
      out.println("Jobs execution pool:");
      out.println("~~~~~~~~~~~~~~~~~~~");
      out.println("(not yet started)");
      return sw.toString();
    }
    out.println("Jobs execution pool:");
    out.println("~~~~~~~~~~~~~~~~~~~");
    out.println("Pool size: " + executor.getPoolSize());
    out.println("Active count: " + executor.getActiveCount());
    out.println("Scheduled task count: " + executor.getTaskCount());
    out.println("Queue size: " + executor.getQueue().size());
    SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
    if (!scheduledJobs.isEmpty()) {
      out.println();
      out.println("Scheduled jobs (" + scheduledJobs.size() + "):");
      out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~");
      for (Job job : scheduledJobs) {
        out.print(job.getClass().getName());
        if (job.getClass().isAnnotationPresent(OnApplicationStart.class)) {
          OnApplicationStart appStartAnnotation =
              job.getClass().getAnnotation(OnApplicationStart.class);
          out.print(
              " run at application start" + (appStartAnnotation.async() ? " (async)" : "") + ".");
        }

        if (job.getClass().isAnnotationPresent(On.class)) {

          String cron = job.getClass().getAnnotation(On.class).value();
          if (cron != null && cron.startsWith("cron.")) {
            cron = Play.configuration.getProperty(cron);
          }
          out.print(" run with cron expression " + cron + ".");
        }
        if (job.getClass().isAnnotationPresent(Every.class)) {
          out.print(" run every " + job.getClass().getAnnotation(Every.class).value() + ".");
        }
        if (job.lastRun > 0) {
          out.print(" (last run at " + df.format(new Date(job.lastRun)));
          if (job.wasError) {
            out.print(" with error)");
          } else {
            out.print(")");
          }
        } else {
          out.print(" (has never run)");
        }
        out.println();
      }
    }
    if (!executor.getQueue().isEmpty()) {
      out.println();
      out.println("Waiting jobs:");
      out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~");
      for (Object o : executor.getQueue()) {
        ScheduledFuture task = (ScheduledFuture) o;
        out.println(
            Java.extractUnderlyingCallable((FutureTask) task)
                + " will run in "
                + task.getDelay(TimeUnit.SECONDS)
                + " seconds");
      }
    }
    return sw.toString();
  }
Exemplo n.º 3
0
 public String[] getStats() {
   return new String[] {
     "STP:",
     " + Effects:",
     " |- ActiveThreads:   " + _effectsScheduledThreadPool.getActiveCount(),
     " |- getCorePoolSize: " + _effectsScheduledThreadPool.getCorePoolSize(),
     " |- PoolSize:        " + _effectsScheduledThreadPool.getPoolSize(),
     " |- MaximumPoolSize: " + _effectsScheduledThreadPool.getMaximumPoolSize(),
     " |- CompletedTasks:  " + _effectsScheduledThreadPool.getCompletedTaskCount(),
     " |- ScheduledTasks:  "
         + (_effectsScheduledThreadPool.getTaskCount()
             - _effectsScheduledThreadPool.getCompletedTaskCount()),
     " | -------",
     " + General:",
     " |- ActiveThreads:   " + _generalScheduledThreadPool.getActiveCount(),
     " |- getCorePoolSize: " + _generalScheduledThreadPool.getCorePoolSize(),
     " |- PoolSize:        " + _generalScheduledThreadPool.getPoolSize(),
     " |- MaximumPoolSize: " + _generalScheduledThreadPool.getMaximumPoolSize(),
     " |- CompletedTasks:  " + _generalScheduledThreadPool.getCompletedTaskCount(),
     " |- ScheduledTasks:  "
         + (_generalScheduledThreadPool.getTaskCount()
             - _generalScheduledThreadPool.getCompletedTaskCount()),
     " | -------",
     " + AI:",
     " |- ActiveThreads:   " + _aiScheduledThreadPool.getActiveCount(),
     " |- getCorePoolSize: " + _aiScheduledThreadPool.getCorePoolSize(),
     " |- PoolSize:        " + _aiScheduledThreadPool.getPoolSize(),
     " |- MaximumPoolSize: " + _aiScheduledThreadPool.getMaximumPoolSize(),
     " |- CompletedTasks:  " + _aiScheduledThreadPool.getCompletedTaskCount(),
     " |- ScheduledTasks:  "
         + (_aiScheduledThreadPool.getTaskCount()
             - _aiScheduledThreadPool.getCompletedTaskCount()),
     "TP:",
     " + Packets:",
     " |- ActiveThreads:   " + _generalPacketsThreadPool.getActiveCount(),
     " |- getCorePoolSize: " + _generalPacketsThreadPool.getCorePoolSize(),
     " |- MaximumPoolSize: " + _generalPacketsThreadPool.getMaximumPoolSize(),
     " |- LargestPoolSize: " + _generalPacketsThreadPool.getLargestPoolSize(),
     " |- PoolSize:        " + _generalPacketsThreadPool.getPoolSize(),
     " |- CompletedTasks:  " + _generalPacketsThreadPool.getCompletedTaskCount(),
     " |- QueuedTasks:     " + _generalPacketsThreadPool.getQueue().size(),
     " | -------",
     " + I/O Packets:",
     " |- ActiveThreads:   " + _ioPacketsThreadPool.getActiveCount(),
     " |- getCorePoolSize: " + _ioPacketsThreadPool.getCorePoolSize(),
     " |- MaximumPoolSize: " + _ioPacketsThreadPool.getMaximumPoolSize(),
     " |- LargestPoolSize: " + _ioPacketsThreadPool.getLargestPoolSize(),
     " |- PoolSize:        " + _ioPacketsThreadPool.getPoolSize(),
     " |- CompletedTasks:  " + _ioPacketsThreadPool.getCompletedTaskCount(),
     " |- QueuedTasks:     " + _ioPacketsThreadPool.getQueue().size(),
     " | -------",
     " + General Tasks:",
     " |- ActiveThreads:   " + _generalThreadPool.getActiveCount(),
     " |- getCorePoolSize: " + _generalThreadPool.getCorePoolSize(),
     " |- MaximumPoolSize: " + _generalThreadPool.getMaximumPoolSize(),
     " |- LargestPoolSize: " + _generalThreadPool.getLargestPoolSize(),
     " |- PoolSize:        " + _generalThreadPool.getPoolSize(),
     " |- CompletedTasks:  " + _generalThreadPool.getCompletedTaskCount(),
     " |- QueuedTasks:     " + _generalThreadPool.getQueue().size(),
     " | -------",
     " + Javolution stats:",
     " |- FastList:        " + FastList.report(),
     " |- FastMap:        " + FastMap.report(),
     " |- FastSet:        " + FastSet.report(),
     " | -------"
   };
 }