Manage servlet call for stats servlet in Azkaban execution server {@inheritDoc}

@see azkaban.executor.ExecutorManagerAdapter#callExecutorStats(int, java.lang.String,
azkaban.utils.Pair[])
514486
@Override
  public Map<String, Object> callExecutorStats(final int executorId, final String action,
      final Pair<String, String>... params) throws IOException, ExecutorManagerException {
    final Executor executor = fetchExecutor(executorId);

    final List<Pair<String, String>> paramList =
        new ArrayList<>();

    // if params = null
    if (params != null) {
      paramList.addAll(Arrays.asList(params));
    }

    paramList
        .add(new Pair<>(ConnectorParams.ACTION_PARAM, action));

    return this.apiGateway.callForJsonObjectMap(executor.getHost(), executor.getPort(),
        "/stats", paramList);
  }
660047
@Override
    public String execute(String[] options) {

        if (this.tcapStacks == null || this.tcapStacks.size() == 0) {
            logger.warn("TCAPStackImpl not set. Command will not be executed ");
            return TCAPAnsiOAMMessage.SERVER_ERROR;
        }

        // At least 1 option is passed?
        if (options == null || options.length < 2) {
            return TCAPAnsiOAMMessage.INVALID_COMMAND;
        }

        String firstOption = options[1];

        if (firstOption == null) {
            return TCAPAnsiOAMMessage.INVALID_COMMAND;
        }

        try {
            if (firstOption.equals("set")) {
                return this.manageSet(options);
            } else if (firstOption.equals("get")) {
                return this.manageGet(options);
            }
            // } catch (Exception e) {
            // logger.error(String.format("Error while executing command %s", Arrays.toString(options)), e);
            // return e.getMessage();
        } catch (Throwable t) {
            logger.error(String.format("Error while executing comand %s", Arrays.toString(options)), t);
            return t.getMessage();
        }

        return TCAPAnsiOAMMessage.INVALID_COMMAND;
    }
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));
			}
		}
	}
1033949
public Object execute(BlueprintCallExecutor executor, Object... parameters) throws Exception{
		stats.addRequest();
		long startTime = System.nanoTime();
		TracedCall aTracedCall = RunningTraceContainer.getCurrentlyTracedCall();
		TraceStep currentElement = null;
		CurrentlyTracedCall currentlyTracedCall = aTracedCall.callTraced() ?
				(CurrentlyTracedCall)aTracedCall : null; 
		if (currentlyTracedCall !=null)
			currentElement = currentlyTracedCall.startStep(new StringBuilder(getProducerId()).append('.').append("execute").toString(), this, "execute");
		try {
			return executor.execute(parameters);
		}  catch (Exception e) {
			stats.notifyError(e);
			throw e;
		} finally {
			long duration = System.nanoTime() - startTime;
			stats.addExecutionTime(duration);
			stats.notifyRequestFinished();
			if (currentElement!=null)
				currentElement.setDuration(duration);
			if (currentlyTracedCall !=null)
				currentlyTracedCall.endStep();
		}
		
	}
289514
public void addCallback(final ClientTransport.PingCallback callback, Executor executor) {
    Runnable runnable;
    synchronized (this) {
      if (!completed) {
        callbacks.put(callback, executor);
        return;
      }
      // otherwise, invoke callback immediately (but not while holding lock)
      runnable = this.failureCause != null ? asRunnable(callback, failureCause)
                                           : asRunnable(callback, roundTripTimeNanos);
    }
    doExecute(executor, runnable);
  }
1075991
public void doProcess(BasicServlet servlet, HttpServletRequest req, HttpServletResponse res, PrintWriter out) 
        throws ServletException, IOException
    {
        Map<String,Object> propRequest = this.getRequestProperties(req, true);
        String strBaseURL = (String)propRequest.get(DBParams.BASE_URL);
        if (strBaseURL != null)
        {
            if (strBaseURL.endsWith(AJAX))
                strBaseURL = strBaseURL.substring(0, strBaseURL.length() - AJAX.length());
            propRequest.put(DBParams.BASE_URL, strBaseURL);
        }
        String strCodeBase = this.getRealPath(req, DBConstants.BLANK);
        if ((strCodeBase != null) && (strCodeBase.length() > 0))
        {
            if (!strCodeBase.endsWith(System.getProperty("file.separator")))
                strCodeBase = strCodeBase + System.getProperty("file.separator");
            if (strCodeBase != null)
                propRequest.put(Params.CODEBASE, strCodeBase);
        }

        servlet.setContentType(res);
        InputStream in = null;  // Not used for the default.
        if (out == null)
            out = servlet.getOutputStream(res);

        String strTarget = (String)propRequest.get(TARGET);
        if (strTarget == null)
        {   // Application method
            String strCommand = (String)propRequest.get(REMOTE_COMMAND);
            if (CREATE_REMOTE_TASK.equals(strCommand))
            {
            	Map<String, Object> taskProperties = this.getProperties();
                if (taskProperties != null)
                    propRequest.putAll(taskProperties);
                Map<String,Object> properties = this.getNextPropertiesParam(in, PROPERTIES, propRequest);
                if (properties != null)
                    propRequest.putAll(properties);
                RemoteTask remoteTask = this.getNewRemoteTask(null, propRequest);
                String strUniqueID = this.add(new TaskHolder(this, remoteTask));
                out.write(strUniqueID);
            }
        }
        else 
        {
            try {
                BaseHolder baseHolder = this.getSessionFromPath(strTarget);
                if (baseHolder != null)
                	baseHolder.doProcess(in, out, propRequest);
                else
                {
                    if (ProxyConstants.FREE_REMOTE_SESSION.equals(propRequest.get(REMOTE_COMMAND)))
                        Utility.getLogger().info("Session not found, command: " + propRequest.get(REMOTE_COMMAND)); // Common to free main session first.
                    else
                        Utility.getLogger().warning("Session not found, command: " + propRequest.get(REMOTE_COMMAND));
                }
            } catch (RemoteException ex) {
                try {
                    this.setErrorReturn(out, ex);
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
            }
        }
    }
368113
public static int[] executeBatch(Connection conn, String... sqls) throws SQLException {
		return executeBatch(conn, new ArrayIter<String>(sqls));
	}
775222
private void executeInternalBatch(int size) throws SQLException {
    executeQueryPrologue(true);
    results = new Results(this, 0, true, size, false, resultSetScrollType,
            resultSetConcurrency, autoGeneratedKeys, protocol.getAutoIncrementIncrement());
    if (protocol
        .executeBatchClient(protocol.isMasterConnection(), results, prepareResult, parameterList,
            hasLongData)) {
      return;
    }

    //send query one by one, reading results for each query before sending another one
    SQLException exception = null;

    if (queryTimeout > 0) {
      for (int batchQueriesCount = 0; batchQueriesCount < size; batchQueriesCount++) {
        protocol.stopIfInterrupted();
        try {
          protocol.executeQuery(protocol.isMasterConnection(), results, prepareResult,
              parameterList.get(batchQueriesCount));
        } catch (SQLException e) {
          if (options.continueBatchOnError) {
            exception = e;
          } else {
            throw e;
          }
        }
      }

    } else {
      for (int batchQueriesCount = 0; batchQueriesCount < size; batchQueriesCount++) {
        try {
          protocol.executeQuery(protocol.isMasterConnection(), results, prepareResult,
              parameterList.get(batchQueriesCount));
        } catch (SQLException e) {
          if (options.continueBatchOnError) {
            exception = e;
          } else {
            throw e;
          }
        }
      }
    }
    if (exception != null) {
      throw exception;
    }

  }
591904
private static void doExecute(Executor executor, Runnable runnable) {
    try {
      executor.execute(runnable);
    } catch (Throwable th) {
      log.log(Level.SEVERE, "Failed to execute PingCallback", th);
    }
  }
984186
public Value callMethod(ExecutionContext context, Map<String, Value> params) {
        validateParameters(params);
        fillDefaultValues(params);
        return internalCallMethod(context, params);
    }
1303033
public static void main(String[] args) throws Exception {
		
		if(!parseParameters(args)) {
			return;
		}
		
		// set up execution environment
		final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
		
		// get input data
		DataSet<Tuple1<Long>> pagesInput = getPagesDataSet(env);
		DataSet<Tuple2<Long, Long>> linksInput = getLinksDataSet(env);
		
		// assign initial rank to pages
		DataSet<Tuple2<Long, Double>> pagesWithRanks = pagesInput.
				map(new RankAssigner((1.0d / numPages)));
		
		// build adjecency list from link input
		DataSet<Tuple2<Long, Long[]>> adjacencyListInput = 
				linksInput.groupBy(0).reduceGroup(new BuildOutgoingEdgeList());
		
		// set iterative data set
		IterativeDataSet<Tuple2<Long, Double>> iteration = pagesWithRanks.iterate(maxIterations);
		
		DataSet<Tuple2<Long, Double>> newRanks = iteration
				// join pages with outgoing edges and distribute rank
				.join(adjacencyListInput).where(0).equalTo(0).flatMap(new JoinVertexWithEdgesMatch())
				// collect and sum ranks
				.groupBy(0).aggregate(SUM, 1)
				// apply dampening factor
				.map(new Dampener(DAMPENING_FACTOR, numPages));
		
		DataSet<Tuple2<Long, Double>> finalPageRanks = iteration.closeWith(
				newRanks, 
				newRanks.join(iteration).where(0).equalTo(0)
				// termination condition
				.filter(new EpsilonFilter()));

		// emit result
		if(fileOutput) {
			finalPageRanks.writeAsCsv(outputPath, "\n", " ");
		} else {
			finalPageRanks.print();
		}

		// execute program
		env.execute("Basic Page Rank Example");
		
	}
209271
public int[] executeBatch(String... sqls) throws SQLException {
		Connection conn = null;
		try {
			conn = this.getConnection();
			return SqlExecutor.executeBatch(conn, sqls);
		} catch (SQLException e) {
			throw e;
		} finally {
			this.closeConnection(conn);
		}
	}
1003879
public CallbackResult<V> processCallbacks(Object... params)
	{
		if (callbacks.size() == 0)
			return CallbackResult.noResult();

		CallbackResult<V> result = CallbackResult.noResult();
		Priority lastPriority = Priority.HIGHEST;
		for (Pair<C, CallbackOption<P>> pair : callbacks)
		{
			if (result.isCancelled() && pair.getRight().getPriority() != lastPriority)
				return result;

			if (pair.getRight().apply(params))
			{
				CallbackResult<V> tmp = pair.getLeft().call(params);
				result = reduce.apply(result, tmp);
				if (result.isForcedCancelled())
					return result;

				lastPriority = pair.getRight().getPriority();
			}
		}

		return result;
	}
519106
private void startWorkers(final ExecutorService executorService, final int numTasks) {
        for (int i = 0; i < numTasks; i++) {
            workerFutures.add(executorService.submit(new Callable<Void>() {
                @Override
                public Void call() throws Exception {
                    runWorkLoop();
                    return null;
                }
            }));
        }
    }
1272757
def setExecutorEnv(self, key=None, value=None, pairs=None):
        """"""
        if (key is not None and pairs is not None) or (key is None and pairs is None):
            raise Exception("Either pass one key-value pair or a list of pairs")
        elif key is not None:
            self.set("spark.executorEnv." + key, value)
        elif pairs is not None:
            for (k, v) in pairs:
                self.set("spark.executorEnv." + k, v)
        return self
1358637
synchronized void execute(File root, Runnable task) {
    if (executors == null) {
      throw new RuntimeException("AsyncDiskService is already shutdown");
    }
    ThreadPoolExecutor executor = executors.get(root);
    if (executor == null) {
      throw new RuntimeException("Cannot find root " + root
          + " for execution of task " + task);
    } else {
      executor.execute(task);
    }
  }
178469
@Override
    public ServletMethodExecutor getExecutor(ServletProtocolConfiguration protocolConfiguration,
        ProtocolMetaData metaData, CommandCallback callback) {
        Collection<HTTPContext> contexts = metaData.getContexts(HTTPContext.class);
        if (contexts.size() == 0) {
            throw new IllegalArgumentException(
                "No " + HTTPContext.class.getName() + " found in " + ProtocolMetaData.class.getName() + ". " +
                    "Servlet protocol can not be used");
        }
        return new ServletMethodExecutor(protocolConfiguration, contexts, callback);
    }