Java 类hudson.model.queue.QueueTaskDispatcher 实例源码

项目:support-core-plugin    文件:BuildQueue.java   
@Override
public void addContents(@NonNull Container container) {
  container.add(new Content("buildqueue.md") {
      @Override
      public void writeTo(OutputStream os) throws IOException {
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(os, "utf-8")));
        try {
          List<Queue.Item> items = Jenkins.getInstance().getQueue().getApproximateItemsQuickly();
          out.println("Current build queue has " +  items.size() + " item(s).");
          out.println("---------------");

          for (Queue.Item item : items) {
            if (item instanceof Item) {
              out.println(" * Name of item: " + ((Item) item).getFullName());
            }
            else {
              out.println(" * Name of item: " + Functions.escape(item.task.getFullDisplayName()));
            }
            out.println("    - In queue for: " + item.getInQueueForString());
            out.println("    - Is blocked: " + item.isBlocked());
            out.println("    - Why in queue: " + item.getWhy());

            for (Cause cause : item.getCauses()) {
              out.println("    - Current queue trigger cause: " + cause.getShortDescription());
            }

            for (QueueTaskDispatcher taskDispatcher : QueueTaskDispatcher.all()) {
                out.println("  * Task Dispatcher: " + taskDispatcher);
                out.println("    - Can run: " + taskDispatcher.canRun(item));
            }
            out.println("----");
            out.println();
          }
          out.println("Is quieting down: " + Jenkins.getInstance().isQuietingDown());
        } finally {
          out.flush();
        }
      }
    }
  );
}