@throws ExecutorManagerException
355246
private void handleStatePageLoad(final HttpServletRequest req, final HttpServletResponse resp,
      final Session session)
      throws ServletException {
    final Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/statsPage.vm");

    try {
      final Collection<Executor> executors = this.execManagerAdapter.getAllActiveExecutors();
      page.add("executorList", executors);

      if (executors.isEmpty()) {
        throw new ExecutorManagerException("Executor list is empty.");
      }

      final Map<String, Object> result =
          this.execManagerAdapter.callExecutorStats(executors.iterator().next().getId(),
              ConnectorParams.STATS_GET_ALLMETRICSNAME,
              (Pair<String, String>[]) null);
      if (result.containsKey(ConnectorParams.RESPONSE_ERROR)) {
        page.add("errorMsg", result.get(ConnectorParams.RESPONSE_ERROR)
            .toString());
      } else {
        page.add("metricList", result.get("data"));
      }
    } catch (final Exception e) {
      logger.error(e.getMessage(), e);
      page.add("errorMsg", "Failed to get a response from Azkaban exec server");
    }

    page.render();
  }
1312689
@Override
    public void run() throws Exception {
        QueueContainer queueContainer = getContainer();
        if (queueContainer.hasEnoughCapacity(txSize + 1)) {
            response = queueContainer.txnOfferReserve(transactionId);
        }
    }
1229597
private void tryRunNext() {
        while (runningSemaphore.tryAcquire()) {
            ExecutionTask execution = queue.poll();
            if (execution != null) {
                // Note: we've removed the execution from the queue so we're committed to running it
                // if we fail to do so for any reason, we need to call the exception handler to fail the execution
                try {
                    execution.submit();
                } catch (Throwable e) {
                    // Any exception here is unexpected
                    runningSemaphore.release();
                    execution.exceptionHandler.handle(e);
                }
            } else {
                runningSemaphore.release();
                break;
            }
        }
    }
189875
void execute(ExecutableBuilder builder,
            int timeout,
            TimeUnit unit) throws
            CommandLineException,
            InterruptedException, ExecutionException, TimeoutException {
        Future<Void> task = executorService.submit(() -> {
            builder.build().execute();
            return null;
        });
        try {
            if (timeout <= 0) { //Synchronous
                task.get();
            } else { // Guarded execution
                try {
                    task.get(timeout, unit);
                } catch (TimeoutException ex) {
                    // First make the context unusable
                    CommandContext c = builder.getCommandContext();
                    if (c instanceof TimeoutCommandContext) {
                        ((TimeoutCommandContext) c).timeout();
                    }
                    // Then cancel the task.
                    task.cancel(true);
                    throw ex;
                }
            }
        } catch (InterruptedException ex) {
            // Could have been interrupted by user (Ctrl-C)
            Thread.currentThread().interrupt();
            cancelTask(task, builder.getCommandContext(), null);
            // Interrupt running operation.
            CommandContext c = builder.getCommandContext();
            if (c instanceof TimeoutCommandContext) {
                ((TimeoutCommandContext) c).interrupted();
            }
            throw ex;
        }
    }
539864
public void completeExecutorTask()
  {
    ExecutorQueueItem item = null;

    synchronized (_executorLock) {
      _executorTaskCount--;

      assert(_executorTaskCount >= 0);

      if (_executorQueueHead != null) {
        item = _executorQueueHead;

        _executorQueueHead = item._next;

        if (_executorQueueHead == null)
          _executorQueueTail = null;
      }
    }

    if (item != null) {
      Runnable task = item.getRunnable();
      ClassLoader loader = item.getLoader();

      boolean isPriority = false;
      boolean isQueue = true;
      boolean isWake = true;

      scheduleImpl(task, loader, MAX_EXPIRE, isPriority, isQueue, isWake);
    }
  }
109461
private void executeTasklet(final ExecutorService commandExecutor,
                              final ConcurrentMap<Integer, Future> futures,
                              final MasterToWorkerRequest masterToWorkerRequest) {
    final CountDownLatch latch = new CountDownLatch(1);
    final TaskletExecutionRequest taskletExecutionRequest = (TaskletExecutionRequest) masterToWorkerRequest;

    // Scheduler Thread: Pass the command to the worker thread pool to be executed
    // Record future to support cancellation.
    futures.put(
        taskletExecutionRequest.getTaskletId(),
        commandExecutor.submit(new Runnable() {
          @Override
          public void run() {
            final WorkerToMasterReports reports;
            final List<WorkerToMasterReport> holder = new ArrayList<>();

            try {
              // Command Executor: Execute the command
              final WorkerToMasterReport workerToMasterReport =
                  new TaskletResultReport(taskletExecutionRequest.getTaskletId(), taskletExecutionRequest.execute());
              holder.add(workerToMasterReport);
            } catch (final InterruptedException ex) {
              // Assumes that user's thread follows convention that cancelled Futures
              // should throw InterruptedException.
              final WorkerToMasterReport workerToMasterReport =
                  new TaskletCancelledReport(taskletExecutionRequest.getTaskletId());
              LOG.log(Level.WARNING, "Tasklet with ID {0} has been cancelled", taskletExecutionRequest.getTaskletId());
              holder.add(workerToMasterReport);
            } catch (Exception e) {
              // Command Executor: Tasklet throws an exception
              final WorkerToMasterReport workerToMasterReport =
                  new TaskletFailureReport(taskletExecutionRequest.getTaskletId(), e);
              holder.add(workerToMasterReport);
            }

            reports = new WorkerToMasterReports(holder);
            workerReports.addLast(kryoUtils.serialize(reports));
            try {
              latch.await();
            } catch (final InterruptedException e) {
              LOG.log(Level.SEVERE, "Cannot wait for Future to be put.");
              throw new RuntimeException(e);
            }
            futures.remove(taskletExecutionRequest.getTaskletId());
            heartBeatTriggerManager.triggerHeartBeat();
          }
        }));

    // Signal that future is put.
    latch.countDown();
  }
426800
@Override
    public final void run() {
        try {
            registry_.updateCollection();

            final long t0 = System.nanoTime();

            processors_.forEach(p -> {
                try {
                    run_implementation_(p);
                } catch (Exception ex) {
                    logger.log(Level.SEVERE, p.getClass().getName() + " failed to run properly, some or all metrics may be missed this cycle", ex);
                }
            });

            final long t_processor = System.nanoTime();
            registry_.updateProcessorDuration(Duration.millis(TimeUnit.NANOSECONDS.toMillis(t_processor - t0)));
        } catch (Throwable t) {
            /*
             * We catch any and all throwables.
             * If we don't and let an exception or error escape,
             * the scheduled executor service will _silently_ drop our task.
             */
            logger.log(Level.SEVERE, "failed to perform collection", t);
        }
    }
280107
public void setLongRunningThreadPool(BlockingExecutor executor)
   {
      if (trace)
         log.trace("long running executor:" + (executor != null ? executor.getClass() : "null"));
 
      if (executor != null)
      {
         if (executor instanceof StatisticsExecutor)
         {
            this.longRunningExecutor = (StatisticsExecutor) executor;
         }
         else
         {
            this.longRunningExecutor = new StatisticsExecutorImpl(executor);
         }
      }
   }
336381
public static void setExecutor(Executor executor) {
        Validate.notNull(executor, "executor");
        synchronized (LOCK) {
            Settings.executor = executor;
        }
    }
689614
public void setExecutorService(ExecutorService v)
   {
      if (v != null)
      {
         executorService = v;
         isExternal = true;
      }
      else
      {
         executorService = null;
         isExternal = false;
      }
   }
1213275
protected void executeTaskIfMatchInternal(long millis) {
		for (int i = 0; i < size; i++) {
			if (patterns.get(i).match(timezone, millis, this.scheduler.matchSecond)) {
				this.scheduler.taskExecutorManager.spawnExecutor(tasks.get(i));
			}
		}
	}
1159953
public void start() throws Exception
    {
        Preconditions.checkState(state.compareAndSet(State.LATENT, State.STARTED), "Cannot be started more than once");

        task = executor.scheduleWithFixedDelay
        (
            new Runnable()
            {
                @Override
                public void run()
                {
                    doWork();
                }
            },
            reapingThresholdMs,
            reapingThresholdMs,
            TimeUnit.MILLISECONDS
        );
        if (leaderLatch != null)
        {
            leaderLatch.start();
        }
        reaper.start();
    }
1186943
private void setCallbackExecutor(Builder clientBuilder) {
    if (clientBuilder.callbackExecutor == null) {
      callbackExecutor = Platform.get().callbackExecutor();
    } else {
      callbackExecutor = clientBuilder.callbackExecutor;
    }
  }
1349710
@Override
    public void run() {
        ExecutorService executorService = Executors.newFixedThreadPool(maxClients);
        try {
            serverSocket = new ServerSocket(port, maxClients);
            while (!shuttingDown) {
                try {
                    Socket socket = serverSocket.accept();
                    debugConnection = new DebugConnection(socket);
                    executorService.submit(debugConnection);
                } catch (SocketException e) {
                    // closed
                    debugConnection = null;
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                debugConnection = null;
                serverSocket.close();
            } catch (Exception e) {
            }
            executorService.shutdownNow();
        }
    }
492077
protected void fireIteratorUpdate() {
		if (this.listeningIterators != null) {
			for (final IClockwiseIterator iterator : this.listeningIterators) {
				if (iterator != null) {
					iterator.dataStructureUpdated();
				}
			}
		}
	}
402735
public void run() throws Exception {

        CmsObject cms = getCmsObject();
        String seoFilePath = cms.getRequestContext().getUri();
        CmsResource seoFile = cms.readResource(seoFilePath);
        m_configuration = new CmsXmlSeoConfiguration();
        m_configuration.load(cms, seoFile);
        String mode = m_configuration.getMode();
        if (mode.equals(CmsXmlSeoConfiguration.MODE_ROBOTS_TXT)) {
            showRobotsTxt();
        } else {
            boolean updateCache = Boolean.parseBoolean(getRequest().getParameter("updateCache"));
            String value = "";
            if (updateCache && m_configuration.usesCache()) {
                // update request, and caching is configured -> update the cache
                CmsXmlSitemapGenerator generator = prepareSitemapGenerator(seoFile, m_configuration);
                value = generator.renderSitemap();
                CmsXmlSitemapCache.INSTANCE.put(seoFile.getRootPath(), value);
            } else if (!updateCache && m_configuration.usesCache()) {
                // normal request, and caching is configured -> look in the cache first, and if not found, calculate sitemap and store it in cache
                String cachedValue = CmsXmlSitemapCache.INSTANCE.get(seoFile.getRootPath());
                if (cachedValue != null) {
                    value = cachedValue;
                } else {
                    CmsXmlSitemapGenerator generator = prepareSitemapGenerator(seoFile, m_configuration);
                    value = generator.renderSitemap();
                    CmsXmlSitemapCache.INSTANCE.put(seoFile.getRootPath(), value);
                }
            } else if (!updateCache && !m_configuration.usesCache()) {
                // normal request, caching is not configured -> always generate a fresh sitemap
                CmsXmlSitemapGenerator generator = prepareSitemapGenerator(seoFile, m_configuration);
                value = generator.renderSitemap();
            } else if (updateCache && !m_configuration.usesCache()) {
                // update request with no caching configured -> ignore
            }
            getResponse().getWriter().print(value);
        }

    }
850259
public void execute() throws CommandException {

		try {
			CommandsParser parser = new CommandsParser( this.app, this.commandsFile );
			if( RoboconfErrorHelpers.containsCriticalErrors( parser.getParsingErrors()))
				throw new CommandException( "Invalid command file. " + this.commandsFile.getName() + " contains errors." );

			for( AbstractCommandInstruction instr : parser.getInstructions()) {
				if( instr.isDisabled()) {
					this.logger.fine( "Skipping disabled instruction: " + instr.getClass().getSimpleName());
					this.instructionSkipped = true;
					continue;
				}

				AbstractCommandExecution executor = findExecutor( instr );
				if( executor == null ) {
					this.logger.fine( "Skipping non-executable instruction: " + instr.getClass().getSimpleName());
					continue;
				}

				executor.setExecutionContext( this.executionContext );
				executor.execute();
			}

		} catch( CommandException e ) {
			throw e;

		} catch( Exception e ) {
			throw new CommandException( e );
		}
	}