Executes the given task.

@param jobId the job id
@param taskId the task id
@param jobConfig the job configuration
@param taskArgs the arguments
@param context the context of the worker
491824
public synchronized void executeTask(long jobId, int taskId, JobConfig jobConfig,
      Serializable taskArgs, RunTaskContext context) {
    Future<?> future = mTaskExecutionService
        .submit(new TaskExecutor(jobId, taskId, jobConfig, taskArgs, context, this));
    Pair<Long, Integer> id = new Pair<>(jobId, taskId);
    mTaskFutures.put(id, future);
    TaskInfo.Builder taskInfo = TaskInfo.newBuilder();
    taskInfo.setJobId(jobId);
    taskInfo.setTaskId(taskId);
    taskInfo.setStatus(Status.RUNNING);
    mUnfinishedTasks.put(id, taskInfo);
    mTaskUpdates.put(id, taskInfo.build());
    LOG.info("Task {} for job {} started", taskId, jobId);
  }
764423
public void configure(JobConf job) {
    this.longCounters = new TreeMap<Object, Long>();
    this.doubleCounters = new TreeMap<Object, Double>();
  }
1284606
@Override
	public JobExecutionResult execute(String jobName) throws Exception {
		// transform the streaming program into a JobGraph
		StreamGraph streamGraph = getStreamGraph();
		streamGraph.setJobName(jobName);

		JobGraph jobGraph = streamGraph.getJobGraph();
		jobGraph.setAllowQueuedScheduling(true);

		Configuration configuration = new Configuration();
		configuration.addAll(jobGraph.getJobConfiguration());
		configuration.setString(TaskManagerOptions.MANAGED_MEMORY_SIZE, "0");

		// add (and override) the settings with what the user defined
		configuration.addAll(this.configuration);

		if (!configuration.contains(RestOptions.BIND_PORT)) {
			configuration.setString(RestOptions.BIND_PORT, "0");
		}

		int numSlotsPerTaskManager = configuration.getInteger(TaskManagerOptions.NUM_TASK_SLOTS, jobGraph.getMaximumParallelism());

		MiniClusterConfiguration cfg = new MiniClusterConfiguration.Builder()
			.setConfiguration(configuration)
			.setNumSlotsPerTaskManager(numSlotsPerTaskManager)
			.build();

		if (LOG.isInfoEnabled()) {
			LOG.info("Running job on local embedded Flink mini cluster");
		}

		MiniCluster miniCluster = new MiniCluster(cfg);

		try {
			miniCluster.start();
			configuration.setInteger(RestOptions.PORT, miniCluster.getRestAddress().get().getPort());

			return miniCluster.executeJobBlocking(jobGraph);
		}
		finally {
			transformations.clear();
			miniCluster.close();
		}
	}
1086362
public static void main(String argv[]) throws Exception {
    StringUtils.startupShutdownMessage(TaskTracker.class, argv, LOG);
    try {
      if (argv.length == 0) {
        JobConf conf = new JobConf();
        ReflectionUtils.setContentionTracing
        (conf.getBoolean("tasktracker.contention.tracking", false));
        new TaskTracker(conf).run();
        return;
      }
      if ("-instance".equals(argv[0]) && argv.length == 2) {
        int instance = Integer.parseInt(argv[1]);
        if (instance == 0 || instance == 1) {
          JobConf conf = new JobConf();
          JobConf.overrideConfiguration(conf, instance);
          // enable the server to track time spent waiting on locks
          ReflectionUtils.setContentionTracing
          (conf.getBoolean("tasktracker.contention.tracking", false));
          new TaskTracker(conf).run();
          return;
        }
      }
      System.out.println("usage: TaskTracker [-instance <0|1>]");
      System.exit(-1);
    } catch (Throwable e) {
      LOG.error("Can not start task tracker because "+
                StringUtils.stringifyException(e));
      System.exit(-1);
    }
  }
1282059
@Override
	public void execute(final Object context, int uiTaskId, final Object... args) {
		
		Activity activity = ContextUtils.asActivity(context);
		
		Set<Method> methods = MethodUtils.getAllMethods(context, UI.class);
		
		for (final Method method : methods) {
			
			final UI uiTask = method.getAnnotation(UI.class);
			
			if(uiTask.value() == uiTaskId) {
			
				final Runnable runnable = new Runnable() {
				
					@Override
					public void run() {
					
						try {
										
							if(!method.isAccessible()) method.setAccessible(true);
										
							method.invoke(context, args);
						} 
						catch (Exception e) {
							
							StringBuilder stringBuilder = new StringBuilder()
							.append("Failed to execute UI task ")
							.append(method.getName())
							.append(" on ")
							.append(context.getClass().getName())
							.append(" with arguments ")
							.append(Arrays.toString(args))
							.append(". ");
										
							Log.e(UITaskService.class.getName(), stringBuilder.toString(), e);
						}
					}
				};
				
				if(uiTask.delay() > 0l) {
				
					try {
						
						Thread.sleep(uiTask.delay());
					}
					catch (InterruptedException ie) {
						
						StringBuilder stringBuilder = new StringBuilder()
						.append("UI task delay of ")
						.append(uiTask.delay())
						.append(" for ")
						.append(method.getName())
						.append(" on ")
						.append(context.getClass().getName())
						.append(" was interrupted!");
						
						Log.e(getClass().getSimpleName(), stringBuilder.toString(), ie);
					}
				}
				
				activity.runOnUiThread(runnable);
				break;
			}
		}
	}
560852
@Override
	public void setup(TaskContext<ReduceFunction<T>, T> context) {
		this.taskContext = context;
		this.running = true;
	}
598632
function CopyKeyJob(options, context, taskId) {
        CopyKeyJob.super_.call(this, logger, options, context, taskId);
        assert.string(this.context.target);
        this.nodeId = this.context.target;
        this.commandUtil = new CommandUtil(this.nodeId);
    }
333099
@Override
    public void execute() throws ActivityException {
        Long instanceId = null;  // pre-existing instanceId
        String instanceIdSpec = getInstanceIdVariable();
        if (instanceIdSpec != null) {
            Object value = getValue(instanceIdSpec);
            if (value instanceof Long)
                instanceId = (Long) value;
            else if (value != null)
                instanceId = Long.parseLong(value.toString());
        }
        try {
            if (instanceId == null) {
                TaskInstance taskInstance = createTaskInstance();
                instanceId = taskInstance.getTaskInstanceId();
                if (instanceIdSpec != null)
                    setValue(instanceIdSpec, instanceId);
            }
            else {
                // update secondary owner
                updateOwningTransition(instanceId);
            }

            String taskInstCorrelationId = TaskAttributeConstant.TASK_CORRELATION_ID_PREFIX + instanceId;
            super.loginfo("Task instance created - ID " + instanceId);
            if (this.needSuspend()) {
                getEngine().createEventWaitInstance(
                        this.getActivityInstanceId(),
                        taskInstCorrelationId,
                        EventType.EVENTNAME_FINISH, true, true);
                EventWaitInstance received = registerWaitEvents(false,true);
                if (received!=null)
                        resume(getExternalEventInstanceDetails(received.getMessageDocumentId()),
                                         received.getCompletionCode());
            }
        } catch (Exception e) {
            throw new ActivityException(-1, e.getMessage(), e);
        }
    }
739220
public void execute(JobExecutionContext context) throws JobExecutionException {

        JobDataMap jobDataMap = context.getMergedJobDataMap();
        ValidatingSessionManager sessionManager = (ValidatingSessionManager) jobDataMap.get(SESSION_MANAGER_KEY);

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Executing session validation Quartz job...");
        }

        sessionManager.validateSessions();

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Session validation Quartz job complete.");
        }
    }
807972
private void executeTask(DataSourceJdbcTask jdbcTask) {
		JdbcActivity jdbcActivity = jdbcRA.createActivity();
		ActivityContextInterface jdbcACI = jdbcACIF
				.getActivityContextInterface(jdbcActivity);
		jdbcACI.attach(sbbContextExt.getSbbLocalObject());
		jdbcActivity.execute(jdbcTask);
	}
156973
public static void main(String[] args) {
    if (args.length != 0) {
      LOG.info("java -cp {} {}", RuntimeConstants.ALLUXIO_JAR,
          AlluxioJobWorker.class.getCanonicalName());
      System.exit(-1);
    }

    if (!ConfigurationUtils.masterHostConfigured(ServerConfiguration.global())) {
      System.out.println(ConfigurationUtils
          .getMasterHostNotConfiguredMessage("Alluxio job worker"));
      System.exit(1);
    }

    if (!ConfigurationUtils.jobMasterHostConfigured(ServerConfiguration.global())) {
      System.out.println(ConfigurationUtils
          .getJobMasterHostNotConfiguredMessage("Alluxio job worker"));
      System.exit(1);
    }

    CommonUtils.PROCESS_TYPE.set(CommonUtils.ProcessType.JOB_WORKER);
    MasterInquireClient masterInquireClient =
        MasterInquireClient.Factory.create(ServerConfiguration.global());
    try {
      RetryUtils.retry("load cluster default configuration with master", () -> {
        InetSocketAddress masterAddress = masterInquireClient.getPrimaryRpcAddress();
        ServerConfiguration.loadClusterDefaults(masterAddress);
      },
          RetryUtils.defaultWorkerMasterClientRetry(
              ServerConfiguration.getDuration(PropertyKey.WORKER_MASTER_CONNECT_RETRY_TIMEOUT)));
    } catch (IOException e) {
      ProcessUtils.fatalError(LOG,
          "Failed to load cluster default configuration for job worker: %s", e.getMessage());
    }
    JobWorkerProcess process = JobWorkerProcess.Factory.create();
    ProcessUtils.run(process);
  }
730396
function RestJob(options, context, taskId){
        var self = this;
        self.options = options;
        self.context = context;

        RestJob.super_.call(self, logger, options, context, taskId);
        self.restClient = new HttpTool();
    }
987577
private void registerExecutingJob(long jobExecutionId, BatchJobWorkUnit workUnit) {

        if (executingJobs.containsKey(jobExecutionId)) {
            throw new IllegalStateException("Already have entry in executingJobs map for job exec id = " + jobExecutionId);
        }

        executingJobs.put(jobExecutionId, workUnit);
    }
813449
public static JobExecutionResult execute(Program pa, String... args) throws Exception {
		return execute(pa.getPlan(args));
	}
81408
public synchronized void submitTask(final ActiveContext context) {
    final TaskEntity task = taskQueue.poll();
    final Integer taskId = task.getId();
    final String command = task.getCommand();

    final Configuration taskConf = TaskConfiguration.CONF
        .set(TaskConfiguration.TASK, ShellTask.class)
        .set(TaskConfiguration.IDENTIFIER, taskId.toString())
        .build();
    final Configuration commandConf = Tang.Factory.getTang().newConfigurationBuilder()
        .bindNamedParameter(Command.class, command)
        .build();

    final Configuration merged = Configurations.merge(taskConf, commandConf);
    context.submitTask(merged);
    runningTasks.add(task);
  }
89655
public static void runAsyncTask(Object context, int asyncTaskId, Object... args) {
		
		if(!ProfileService.getInstance(context).isActive(context, Profile.THREADING)) {

			StringBuilder builder = new StringBuilder()
			.append("Async task with ID ")
			.append(asyncTaskId)
			.append("cannot be run since the threading profile is inactive.");
			
			Log.w("Async task cannot ", builder.toString());

			return;
		}
		
		TaskManagers.ASYNC.execute(context, asyncTaskId, args);
	}
509609
private synchronized void runTask(Task task) {
        if (taskThread == null) {
            taskThread = new TaskThread();
        }
        taskThread.runTask(task);
    }