Creates or updates a bam task summary instance.

@param ti The source task
@param newStatus The new state for the task.
@param worker Perform additional operations to the bam task summary instance.
@return The created or updated bam task summary instance.
320218
protected BAMTaskSummaryImpl createTask(TaskEvent event, Status newStatus, BAMTaskWorker worker) {
        BAMTaskSummaryImpl result = null;
        Task ti = event.getTask();
        TaskPersistenceContext persistenceContext = getPersistenceContext(((TaskContext)event.getTaskContext()).getPersistenceContext());
        try {
	        if (ti == null) {
	            logger.error("The task instance does not exist.");
	            return result;
	        }
	
	        Status status = newStatus != null ? newStatus : ti.getTaskData().getStatus();
	
	        String actualOwner = "";
	        if (ti.getTaskData().getActualOwner() != null) {
	            actualOwner = ti.getTaskData().getActualOwner().getId();
	        }
	
	        result = new BAMTaskSummaryImpl(ti.getId(), ti.getName(), status.toString(), event.getEventDate(), actualOwner, ti.getTaskData().getProcessInstanceId());
	        if (worker != null) worker.createTask(result, ti);
	        persistenceContext.persist(result);
	    
	
	        return result;
        } finally {
        	cleanup(persistenceContext);
        }
    }
1192401
public static TracyThreadContext createWorkerTheadContext() {
        TracyThreadContext currentCtx = threadContext.get();
        TracyThreadContext workerCtx = null;
        if (isValidContext(currentCtx))  {
            workerCtx = new TracyThreadContext(
                currentCtx.getTaskId(), currentCtx.getOptId(), null);
        }
        return workerCtx;
    }
632928
void updateTaskStatuses(TaskTrackerStatus status) {
    String trackerName = status.getTrackerName();
    for (TaskStatus report : status.getTaskReports()) {
      report.setTaskTracker(trackerName);
      TaskAttemptID taskId = report.getTaskID();

      // Remove it from the expired task list
      if (report.getRunState() != TaskStatus.State.UNASSIGNED) {
        expireLaunchingTasks.removeTask(taskId);
      }

      JobInProgress job = getJob(taskId.getJobID());
      if (job == null) {
        // if job is not there in the cleanup list ... add it
        synchronized (trackerToJobsToCleanup) {
          Set<JobID> jobs = trackerToJobsToCleanup.get(trackerName);
          if (jobs == null) {
            jobs = new HashSet<JobID>();
            trackerToJobsToCleanup.put(trackerName, jobs);
          }
          jobs.add(taskId.getJobID());
        }
        continue;
      }

      if (!job.inited()) {
        // if job is not yet initialized ... kill the attempt
        synchronized (trackerToTasksToCleanup) {
          Set<TaskAttemptID> tasks = trackerToTasksToCleanup.get(trackerName);
          if (tasks == null) {
            tasks = new HashSet<TaskAttemptID>();
            trackerToTasksToCleanup.put(trackerName, tasks);
          }
          tasks.add(taskId);
        }
        continue;
      }

      TaskInProgress tip = taskidToTIPMap.get(taskId);
      // Check if the tip is known to the jobtracker. In case of a restarted
      // jt, some tasks might join in later
      if (tip != null) {
        // Update the job and inform the listeners if necessary
        JobStatus prevStatus = (JobStatus)job.getStatus().clone();
        // Clone TaskStatus object here, because JobInProgress
        // or TaskInProgress can modify this object and
        // the changes should not get reflected in TaskTrackerStatus.
        // An old TaskTrackerStatus is used later in countMapTasks, etc.
        job.updateTaskStatus(tip, (TaskStatus)report.clone());
        JobStatus newStatus = (JobStatus)job.getStatus().clone();

        // Update the listeners if an incomplete job completes
        if (prevStatus.getRunState() != newStatus.getRunState()) {
          JobStatusChangeEvent event =
            new JobStatusChangeEvent(job, EventType.RUN_STATE_CHANGED,
                                     prevStatus, newStatus);
          updateJobInProgressListeners(event);
        }
      } else {
        LOG.info("Serious problem.  While updating status, cannot find taskid "
                 + report.getTaskID());
      }

      // Process 'failed fetch' notifications
      List<TaskAttemptID> failedFetchMaps = report.getFetchFailedMaps();
      if (failedFetchMaps != null) {
        TaskAttemptID reportingAttempt = report.getTaskID();
        for (TaskAttemptID mapTaskId : failedFetchMaps) {
          TaskInProgress failedFetchMap = taskidToTIPMap.get(mapTaskId);

          if (failedFetchMap != null) {
            // Gather information about the map which has to be failed, if need be
            String failedFetchTrackerName = getAssignedTracker(mapTaskId);
            if (failedFetchTrackerName == null) {
              failedFetchTrackerName = "Lost task tracker";
            }
            ((JobInProgress)failedFetchMap.getJob()).fetchFailureNotification(
              reportingAttempt, failedFetchMap, mapTaskId, failedFetchTrackerName);
          }
        }
      }
    }
  }
293895
public WorkflowTaskCoordinator build() {
			if(taskWorkers == null) {
				throw new IllegalArgumentException("No task workers are specified. use withWorkers() to add one mor more task workers");
			}

			if(taskClient == null) {
				throw new IllegalArgumentException("No TaskClient provided. use withTaskClient() to provide one");
			}
			return new WorkflowTaskCoordinator(eurekaClient, taskClient, threadCount, sleepWhenRetry, updateRetryCount,
											   workerQueueSize, taskWorkers, workerNamePrefix);
		}
568428
@Override
  public TaskStatus getTaskStatus(final JobId jobId) {
    final byte[] data = taskStatuses.get(jobId.toString());
    if (data == null) {
      return null;
    }
    try {
      return parse(data, TaskStatus.class);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
927045
public static <Result> TaskBuilder<Result> create(Callable<Result> action,
                                                      TaskCallback<Result> callback,
                                                      Object caller) {
        return new TaskBuilder<Result>().action(action).callback(callback).with(caller);
    }
691930
function createWorker() {
    var worker = new Worker('worker.js');

    // On worker messsage
    worker.onmessage = function(event) {
        if (event.data.event === 'done') {
            console.log('done:', event.data.data);
            $('#start').show();
            $('#abort').hide();
        }
        else if (event.data.event === 'progress') {
            console.log('progress:', event.data.data.percent, '%');
        }
    };

    return worker;
}
1123717
function webworkifyDebug (worker) {
  var targetA = new EventTarget(),
      targetB = new EventTarget();

  targetA.setTarget(targetB);
  targetB.setTarget(targetA);

  worker(targetA);
  return targetB;
}
209963
public static Set<Integer> worker_output_tasks(WorkerData workerData) {
        ContextMaker context_maker = workerData.getContextMaker();
        Set<Integer> taskIds = workerData.getTaskIds();
        StormTopology topology = workerData.getSysTopology();

        Set<Integer> rtn = new HashSet<>();

        for (Integer taskId : taskIds) {
            TopologyContext context = context_maker.makeTopologyContext(topology, taskId, null);

            // <StreamId, <ComponentId, Grouping>>
            Map<String, Map<String, Grouping>> targets = context.getThisTargets();
            for (Map<String, Grouping> e : targets.values()) {
                for (String componentId : e.keySet()) {
                    List<Integer> tasks = context.getComponentTasks(componentId);
                    rtn.addAll(tasks);
                }
            }
        }

        return rtn;
    }
562126
synchronized void statusUpdate(TaskStatus status) {
    setProgress(status.getProgress());
    this.runState = status.getRunState();
    this.stateString = status.getStateString();
    this.nextRecordRange = status.getNextRecordRange();

    setDiagnosticInfo(status.getDiagnosticInfo());
    
    if (status.getStartTime() > 0) {
      this.startTime = status.getStartTime(); 
    }
    if (status.getFinishTime() > 0) {
      setFinishTime(status.getFinishTime()); 
    }
    
    this.phase = status.getPhase();
    this.counters = status.getCounters();
    this.outputSize = status.outputSize;
  }
138646
public TrmClientAttachReply createNewTrmClientAttachReply() throws MessageCreateFailedException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "createNewTrmClientAttachReply");
    TrmClientAttachReply msg = null;
    try {
      msg = new TrmClientAttachReplyImpl();
    }
    catch (MessageDecodeFailedException e) {
      /* No need to FFDC this as JsMsgObject will already have done so */
      // No FFDC code needed
      throw new MessageCreateFailedException(e);
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "createNewTrmClientAttachReply");
    return msg;
  }
498709
static <T extends IncrementalTask> IncrementalTaskState<T> create(
      String taskId, String jobId, long createTime, T initialTask) {
    return new IncrementalTaskState<>(taskId, jobId, createTime, new LockInfo(null, null),
        checkNotNull(initialTask), new Status(StatusCode.RUNNING));
  }
814577
protected long createTaskInternal(String name, String channel, String data, String key1, String key2, Long batchId, int postponeSec, TedStatus status) {
		String sqlLogId = "create_task";
		if (status == null)
			status = TedStatus.NEW;
		String nextts = (status == TedStatus.NEW ? dbType.sql.now() + " + " + dbType.sql.intervalSeconds(postponeSec) : "null");

		String sql = " insert into tedtask (taskId, system, name, channel, bno, status, createTs, nextTs, retries, data, key1, key2, batchId)" +
				" values($nextTaskId, '$sys', ?, ?, null, '$status', $now, $nextts, 0, ?, ?, ?, ?)" +
				" returning taskId";
		sql = sql.replace("$nextTaskId", dbType.sql.sequenceSql("SEQ_TEDTASK_ID"));
		sql = sql.replace("$now", dbType.sql.now());
		sql = sql.replace("$sys", thisSystem);
		sql = sql.replace("$nextts", nextts);
		sql = sql.replace("$status", status.toString());

		List<TaskIdRes> resList = selectData(sqlLogId, sql, TaskIdRes.class, asList(
				sqlParam(name, JetJdbcParamType.STRING),
				sqlParam(channel, JetJdbcParamType.STRING),
				sqlParam(data, JetJdbcParamType.STRING),
				sqlParam(key1, JetJdbcParamType.STRING),
				sqlParam(key2, JetJdbcParamType.STRING),
				sqlParam(batchId, JetJdbcParamType.LONG)
		));
		Long taskId = resList.get(0).taskid;
		logger.trace("Task {} {} created successfully. ", name, taskId);
		return taskId;

	}
796054
private void onTaskStatusMessage(final TaskStatusPOJO taskStatus) {

    if (!(this.task.isPresent() && this.task.get().getId().equals(taskStatus.getTaskId()))) {

      final State state = taskStatus.getState();
      if (state.isRestartable() ||
          this.driverRestartManager.getEvaluatorRestartState(this.evaluatorId).isReregistered()) {

        // [REEF-308] exposes a bug where the .NET evaluator does not send its states in the right order
        // [REEF-289] is a related item which may fix the issue
        if (state.isRunning()) {
          LOG.log(Level.WARNING,
              "Received a message of state {0} for Task {1} before receiving its {2} state",
              new Object[] {State.RUNNING, taskStatus.getTaskId(), State.INIT});
        }

        // FAILED is a legal first state of a Task as it could have failed during construction.
        this.task = Optional.of(
            new TaskRepresenter(taskStatus.getTaskId(),
                this.contextRepresenters.getContext(taskStatus.getContextId()),
                this.messageDispatcher,
                this,
                this.exceptionCodec,
                this.driverRestartManager));
      } else {
        throw new RuntimeException("Received a message of state " + state +
            ", not INIT, RUNNING, or FAILED for Task " + taskStatus.getTaskId() +
            " which we haven't heard from before.");
      }
    }

    this.task.get().onTaskStatusMessage(taskStatus);

    if (this.task.get().isNotRunning()) {
      LOG.log(Level.FINEST, "Task no longer running. De-registering it.");
      this.task = Optional.empty();
    }
  }
1060060
private static TaskHandle createTaskHandle(
            TaskStateMachine taskStateMachine,
            TaskContext taskContext,
            OutputBuffer outputBuffer,
            LocalExecutionPlan localExecutionPlan,
            TaskExecutor taskExecutor)
    {
        TaskHandle taskHandle = taskExecutor.addTask(
                taskStateMachine.getTaskId(),
                outputBuffer::getUtilization,
                getInitialSplitsPerNode(taskContext.getSession()),
                getSplitConcurrencyAdjustmentInterval(taskContext.getSession()),
                getMaxDriversPerTask(taskContext.getSession()));
        taskStateMachine.addStateChangeListener(state -> {
            if (state.isDone()) {
                taskExecutor.removeTask(taskHandle);
                for (DriverFactory factory : localExecutionPlan.getDriverFactories()) {
                    factory.noMoreDrivers();
                }
            }
        });
        return taskHandle;
    }
861011
static TaskStatus createTaskStatus(DataInput in, TaskAttemptID taskId, 
                                     float progress, int numSlots,
                                     State runState, String diagnosticInfo,
                                     String stateString, String taskTracker,
                                     Phase phase, Counters counters) 
  throws IOException {
    boolean isMap = in.readBoolean();
    return createTaskStatus(isMap, taskId, progress, numSlots, runState, 
                            diagnosticInfo, stateString, taskTracker, phase, 
                            counters);
  }
534325
function createNewTask(task) {
        console.log("Creating task...");

        //set up the new list item
        const listItem = document.createElement("li");
        const checkBox = document.createElement("input");
        const label = document.createElement("label");


        //pull the inputed text into label
        label.innerText = task;

        //add properties
        checkBox.type = "checkbox";

        //add items to the li
        listItem.appendChild(checkBox);
        listItem.appendChild(label);
        //everything put together
        return listItem;
    }