Cancels a local running task with the specified ID.

@param taskID
@return the task canceled
487237
public TimerTask cancel(Serializable taskID) {
		
		if (logger.isDebugEnabled()) {
			logger.debug("Canceling task with timer id "+taskID);
		}
		
		TimerTask task = localRunningTasks.get(taskID);
		if (task != null) {
			// remove task data
			new TimerTaskCacheData(taskID, baseFqn, cluster).remove();

			final SetTimerAfterTxCommitRunnable setAction = task.getSetTimerTransactionalAction();
			if (setAction != null) {
				// we have a tx action scheduled to run when tx commits, to set the timer, lets simply cancel it
				setAction.cancel();
			}
			else {
				// do cancellation
				AfterTxCommitRunnable runnable = new CancelTimerAfterTxCommitRunnable(task,this);
				if (txManager != null) {
					try {
						Transaction tx = txManager.getTransaction();
						if (tx != null) {
							TransactionContext txContext = TransactionContextThreadLocal.getTransactionContext();
							if (txContext == null) {
								txContext = new TransactionContext();
								tx.registerSynchronization(new TransactionSynchronization(txContext));
							}
							txContext.put(taskID, runnable);					
						}
						else {
							runnable.run();
						}
					}
					catch (Throwable e) {
						throw new RuntimeException("Unable to register tx synchronization object",e);
					}
				}
				else {
					runnable.run();
				}			
			}		
		}
		else {
			// not found locally
			// if there is a tx context there may be a set timer action there
			if (txManager != null) {
				try {
					Transaction tx = txManager.getTransaction();
					if (tx != null) {
						TransactionContext txContext = TransactionContextThreadLocal.getTransactionContext();
						if (txContext != null) {
							final AfterTxCommitRunnable r = txContext.remove(taskID);
							if (r != null) {
								task = r.task;
								// remove from cluster
								new TimerTaskCacheData(taskID, baseFqn, cluster).remove();
							}							
						}											
					}
				}
				catch (Throwable e) {
					throw new RuntimeException("Failed to check tx context.",e);
				}
			}			
		}
		
		return task;
	}
613109
public void skipTaskFromWorkflow(String workflowId, String taskReferenceName) {
        Preconditions.checkArgument(StringUtils.isNotBlank(workflowId), "workflow id cannot be blank");
        Preconditions.checkArgument(StringUtils.isNotBlank(taskReferenceName), "Task reference name cannot be blank");

        put("workflow/{workflowId}/skiptask/{taskReferenceName}", null, workflowId, taskReferenceName);
    }
752643
@Override
    public synchronized void deleteTask(Task task) throws TaskNotFoundException {
        if (!this.inprocess.contains(task)) {
            log.error("{} not found.", task);

            throw new TaskNotFoundException("task not found:" + task.toString());
        }

        this.inprocess.remove(task);
        this.completedCount++;
        log.info("{} complete", task);
    }
196482
public Task getTaskDetails(String taskId) {
        Preconditions.checkArgument(StringUtils.isNotBlank(taskId), "Task id cannot be blank");
        return getForEntity("tasks/{taskId}", null, Task.class, taskId);
    }
28794
public function cancelTask($task_id)
    {
        if (empty($task_id)) {
            throw new \InvalidArgumentException("Please set task_id");
        }
        $url = "projects/{$this->project_id}/tasks/$task_id/cancel";
        $request = array();

        $this->setCommonHeaders();
        $res = $this->apiCall(self::POST, $url, $request);
        return self::json_decode($res);
    }
143633
public void removeTaskFromQueue(String taskType, String taskId) {
        Preconditions.checkArgument(StringUtils.isNotBlank(taskType), "Task type cannot be blank");
        Preconditions.checkArgument(StringUtils.isNotBlank(taskId), "Task id cannot be blank");
        stub.removeTaskFromQueue(
                TaskServicePb.RemoveTaskRequest.newBuilder()
                        .setTaskType(taskType)
                        .setTaskId(taskId)
                        .build()
        );
    }
1210184
@Private
  @Override
  public void cancelled(final int pTaskletId) {
    assert taskletId == pTaskletId;

    this.cancelled.set(true);
    if (callbackHandler != null) {
      executor.execute(new Runnable() {
        @Override
        public void run() {
          callbackHandler.onFailure(new InterruptedException("VortexFuture has been cancelled on request."));
        }
      });
    }
    this.countDownLatch.countDown();
  }
18429
@Override
	public boolean registerTaskManager(final ResourceID resourceID) {

		componentMainThreadExecutor.assertRunningInMainThread();

		log.debug("Register new TaskExecutor {}.", resourceID);
		return registeredTaskManagers.add(resourceID);
	}
1039185
public static final void assertTaskUncompleted(final String taskId) {
        Validate.notNull(taskId);

        apiCallback.debug(LogMessage.TASK_2, taskId);
        try {
            getTaskInstanceAssertable().taskIsUncompleted(taskId);
        } catch (final AssertionError ae) {
            apiCallback.fail(ae, LogMessage.ERROR_TASK_2, taskId);
        }
    }
1230503
public Task addRunningTask(TaskAttemptID taskid, 
                             String taskTracker,
                             boolean taskCleanup) {
    // 1 slot is enough for taskCleanup task
    int numSlotsNeeded = taskCleanup ? 1 : numSlotsRequired;
    // create the task
    Task t = null;
    if (isMapTask()) {
      LOG.debug("attempt " + numTaskFailures + " sending skippedRecords "
          + failedRanges.getIndicesCount());
      String splitClass = null;
      BytesWritable split;
      if (!jobSetup && !jobCleanup) {
        splitClass = rawSplit.getClassName();
        split = rawSplit.getBytes();
      } else {
        split = new BytesWritable();
      }
      t = new MapTask(jobFile, taskid, partition, splitClass, split, 
                      numSlotsNeeded, job.getUser());
    } else {
      t = new ReduceTask(jobFile, taskid, partition, numMaps, 
                         numSlotsNeeded, job.getUser());
    }
    if (jobCleanup) {
      t.setJobCleanupTask();
    }
    if (jobSetup) {
      t.setJobSetupTask();
    }
    if (taskCleanup) {
      t.setTaskCleanupTask();
      t.setState(taskStatuses.get(taskid).getRunState());
      cleanupTasks.put(taskid, taskTracker);
    }
    t.setConf(conf);
    LOG.debug("Launching task with skipRanges:"+failedRanges.getSkipRanges());
    t.setSkipRanges(failedRanges.getSkipRanges());
    t.setSkipping(skipping);
    if(failedRanges.isTestAttempt()) {
      t.setWriteSkipRecs(false);
    }

    if (activeTasks.size() >= 1) {
    	speculativeTaskId = taskid;
    } else {
    	speculativeTaskId = null;
    }
    activeTasks.put(taskid, taskTracker);
    tasks.add(taskid);

    // Ask JobTracker to note that the task exists
    // jobtracker.createTaskEntry(taskid, taskTracker, this);

    /*
      // code to find call paths to createTaskEntry
      StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
      boolean found = false;
      for (StackTraceElement s: stackTraceElements) {
      if (s.getMethodName().indexOf("heartbeat") != -1 ||
      s.getMethodName().indexOf("findTask") != -1 ||
      s.getMethodName().indexOf("createAndAddAttempt") != -1 ||
      s.getMethodName().indexOf("processTaskAttempt") != -1) {
      found = true;
      break;
      }
      }

      if (!found) {
      RuntimeException e = new RuntimeException ("calling addRunningTask from outside heartbeat");
      LOG.info(StringUtils.stringifyException(e));
      throw (e);
      }
    */

    // check and set the first attempt
    if (firstTaskId == null) {
      firstTaskId = taskid;
    }
    return t;
  }
585690
public synchronized void cancelTask(long jobId, int taskId) {
    Pair<Long, Integer> id = new Pair<>(jobId, taskId);
    TaskInfo.Builder taskInfo = mUnfinishedTasks.get(id);
    if (!mTaskFutures.containsKey(id) || taskInfo.getStatus().equals(Status.CANCELED)) {
      // job has finished, or failed, or canceled
      return;
    }

    Future<?> future = mTaskFutures.get(id);
    if (!future.cancel(true)) {
      taskInfo.setStatus(Status.FAILED);
      taskInfo.setErrorMessage("Failed to cancel the task");
      finishTask(id);
    }
  }
553065
@Override
  public void cancel(Serializable id) {
    logger.debug("Cancelling timer with id {}", id);
    this.ftScheduler.cancel(id);
  }
410896
public Object recv(Integer taskId, int flags) {
        try {
            DisruptorQueue recvQueue = deserializeQueues.get(taskId);
            if ((flags & 0x01) == 0x01) {
                return recvQueue.poll();
                // non-blocking
            } else {
                return recvQueue.take();
            }
        } catch (Exception e) {
            LOG.warn("Unknown exception ", e);
            return null;
        }
    }
1203269
public static synchronized void cancel(TimerTask task) {
        if (task == null) {
            return;
        }
        task.cancel();
        usageCount.decrementAndGet();
        if (usageCount.get() == 0) {
            timer.cancel();
            timer = null;
        }
    }
831505
private void cleanup(final String taskId)
  {
    if (!lifecycleLock.awaitStarted(1, TimeUnit.SECONDS)) {
      return;
    }
    final RemoteTaskRunnerWorkItem removed = completeTasks.remove(taskId);
    final Worker worker = removed.getWorker();
    if (removed == null || worker == null) {
      log.makeAlert("WTF?! Asked to cleanup nonexistent task")
         .addData("taskId", taskId)
         .emit();
    } else {
      final String workerId = worker.getHost();
      log.info("Cleaning up task[%s] on worker[%s]", taskId, workerId);
      final String statusPath = JOINER.join(indexerZkConfig.getStatusPath(), workerId, taskId);
      try {
        cf.delete().guaranteed().forPath(statusPath);
      }
      catch (KeeperException.NoNodeException e) {
        log.info("Tried to delete status path[%s] that didn't exist! Must've gone away already?", statusPath);
      }
      catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
  }
1131138
public function cancelTask($task_id) {
        $redis = Cache::redis();
        $timer_id = $redis->hGet(self::TIMER_TIME_QUEUE, $task_id);
        $redis->hDel(self::TIMER_QUEUE, $task_id);
        $redis->hDel(self::TIMER_TIME_QUEUE, $task_id);
        $redis->hDel(self::SWOOLE_TASK_WAIT, $task_id);
        if ($timer_id) {
            swoole_timer_clear($timer_id);
        }
    }
102348
protected void handleMesosFailure(String taskId) {
    int attempt = TaskUtils.getAttemptForTaskId(taskId);
    BaseContainer container = containersInfo.get(TaskUtils.getContainerIndexForTaskId(taskId));

    boolean hasAttemptsLeft = attempt < container.retries;

    if (hasAttemptsLeft) {
      LOG.warning(String.format("Retrying task: %s, attempt: %d", container.name, attempt + 1));

      String newTaskId = TaskUtils.getTaskId(container.name, attempt + 1);
      scheduleNewTask(newTaskId);
    } else {
      LOG.severe("Would not restart the job since it is beyond retries: " + attempt);
    }
  }