Reschedules the specified task, cancelling existing one if applicable.

@param taskRef task reference
@param millis  delay in milliseconds
13888
private void rescheduleTask(AtomicReference<TimerTask> taskRef, long millis) {
    ProcessorTask newTask = new ProcessorTask();
    timer.schedule(newTask, millis);
    swapAndCancelTask(taskRef, newTask);
  }
418432
public void schedule(Runnable task, long delayInMillis) {
        if (isTerminatedOrSteppedDown()) {
            return;
        }

        raftIntegration.schedule(task, delayInMillis, MILLISECONDS);
    }
299475
public void executeTaskIfMatch(long millis) {
		final Lock readLock = lock.readLock();
		try {
			readLock.lock();
			executeTaskIfMatchInternal(millis);
		} finally {
			readLock.unlock();
		}
	}
1333330
private void scheduleRetry() {
        Context appContext = getApplicationContext();
        long nextRetry = System.currentTimeMillis() + RetryPolicy.incrementAndGetTime(appContext);
        scheduleWingsService(appContext, nextRetry);
    }
33867
private void sendCancelRpcCall(int numberRetries) {
		final LogicalSlot slot = assignedResource;

		if (slot != null) {
			final TaskManagerGateway taskManagerGateway = slot.getTaskManagerGateway();
			final ComponentMainThreadExecutor jobMasterMainThreadExecutor =
				getVertex().getExecutionGraph().getJobMasterMainThreadExecutor();

			CompletableFuture<Acknowledge> cancelResultFuture = FutureUtils.retry(
				() -> taskManagerGateway.cancelTask(attemptId, rpcTimeout),
				numberRetries,
				jobMasterMainThreadExecutor);

			cancelResultFuture.whenComplete(
				(ack, failure) -> {
					if (failure != null) {
						fail(new Exception("Task could not be canceled.", failure));
					}
				});
		}
	}
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);
        }
    }
508538
public synchronized void cancel() {
    for (int taskId : mJobInfo.getTaskIdList()) {
      mCommandManager.submitCancelTaskCommand(mJobInfo.getId(), taskId,
          mTaskIdToWorkerInfo.get(taskId).getId());
    }
  }
1180599
private void setTaskFinish() {
        m_taskRecord.setProperty(TaskRecord.PROP_EXECUTOR, m_hostID);
        m_taskRecord.setProperty(TaskRecord.PROP_FINISH_TIME, Long.toString(System.currentTimeMillis()));
        m_taskRecord.setStatus(TaskStatus.COMPLETED);
        TaskManagerService.instance().updateTaskStatus(m_tenant, m_taskRecord, true);
    }
863220
private void scheduleRenewalThresholdUpdateTask() {
        timer.schedule(new TimerTask() {
                           @Override
                           public void run() {
                               updateRenewalThreshold();
                           }
                       }, serverConfig.getRenewalThresholdUpdateIntervalMs(),
                serverConfig.getRenewalThresholdUpdateIntervalMs());
    }
51178
public void cancel(TaskInProgress tip) {
    LOG.info("Canceling task "  + tip.getTask().getTaskID() + " of job " +
        tip.getTask().getJobID());
    // Cancel & remove the map completion finish thread for reduce tasks.
    if (!tip.getTask().isMapTask() && !tip.getTask().isTaskCleanupTask()) {
      if (!mapperWaitThreadMap.containsKey(tip)) {
        throw new RuntimeException("Mapper wait thread doesn't exist " +
            "for " + tip.getTask().getTaskID());
      }
      LOG.debug("Interrupting mapper wait thread for " +
          tip.getTask().getTaskID() + " job " +
          tip.getTask().getJobID());
      mapperWaitThreadMap.get(tip).interrupt();
      LOG.debug("Removing mapper wait thread for " +
          tip.getTask().getTaskID() + " job " + tip.getTask().getJobID());
      mapperWaitThreadMap.remove(tip);
    } else {
      LOG.debug(tip.getTask().getTaskID() + " is not a reduce task, so " +
          "not canceling mapper wait thread");
    }
    removeFromFinishingQueue(tip);
  }
1207621
public synchronized int cancelTask(final int taskId) throws UnsuccessfulException, NotFoundException {
    if (getTask(taskId, runningTasks) != null) {
      throw new UnsuccessfulException("The task " + taskId + " is running");
    } else if (getTask(taskId, finishedTasks) != null) {
      throw new UnsuccessfulException("The task " + taskId + " has finished");
    }

    final TaskEntity task = getTask(taskId, taskQueue);
    if (task == null) {
      final String message =
          new StringBuilder().append("Task with ID ").append(taskId).append(" is not found").toString();
      throw new NotFoundException(message);
    } else {
      taskQueue.remove(task);
      canceledTasks.add(task);
      return taskId;
    }
  }
932836
public void cancel(ScheduledFuture<?> scheduledFuture) {
        clear();
        if (scheduledFuture != null && !scheduledFuture.isDone()) {
            scheduledFuture.cancel(false);
        }
    }
196369
public final void cancelOld(
            final long starttimeThreshold, final long checkTimeThreshold, final String message) {
        final CriteriaBuilder builder = getSession().getCriteriaBuilder();
        final CriteriaUpdate<PrintJobStatusExtImpl> update =
                builder.createCriteriaUpdate(PrintJobStatusExtImpl.class);
        final Root<PrintJobStatusExtImpl> root = update.from(PrintJobStatusExtImpl.class);
        update.where(builder.and(
                builder.equal(root.get("status"), PrintJobStatus.Status.WAITING),
                builder.or(
                        builder.lessThan(root.get("entry").get("startTime"), starttimeThreshold),
                        builder.and(builder.isNotNull(root.get("lastCheckTime")),
                                    builder.lessThan(root.get("lastCheckTime"), checkTimeThreshold))
                )
        ));
        update.set(root.get("status"), PrintJobStatus.Status.CANCELLED);
        update.set(root.get("error"), message);
        getSession().createQuery(update).executeUpdate();
    }
1041559
public boolean cancel(T task) {
    CancellableTask<K, T> cancellableTask = this.cancellableTaskMap.getIfPresent(task.getKey());
    if (cancellableTask != null && cancellableTask.getScheduledTask() == task && cancellableTask.cancel()) {
      this.cancellableTaskMap.invalidate(task.getKey());
      return true;
    }
    return false;
  }
54779
@Override
  public void runAfter(@Pin Consumer<? super Cancel> task, 
                       long delay, 
                       TimeUnit unit,
                       Result<? super Cancel> result)
  {
    Objects.requireNonNull(task);
    Objects.requireNonNull(unit);

    TimerListener listener = new TimerListener(task, null);

    // _timerMap.put(task, listener);
    
    listener.alarm().runAfter(unit.toMillis(delay));
    
    result.ok(listener);
  }
1039227
public void cancel(TimerTask task) {
        //CANCEL needs to remove the shceduled timer see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6602600
        //to improve perf

        ScheduledFuture<?> future = null;
        Object[] array = super.getQueue().toArray();
        for(int i = 0; i<array.length; i++) {
            if(array[i] instanceof ScheduledFuture<?>){
                future = (ScheduledFuture<?>)array[i];
                try {

                    Field callableField = future.getClass().getDeclaredField("callable");
                    callableField.setAccessible(true);
                    Object callable = callableField.get(future);
                    callableField.setAccessible(false);

                    if(callable!=null){
                        Field taskField = callable.getClass().getDeclaredField("task");
                        taskField.setAccessible(true);
                        TimerTask scheduledTask = null;
                        if(taskField.get(callable) instanceof TimerTask){
                             scheduledTask = (TimerTask) taskField.get(callable);
                        }
                        taskField.setAccessible(false);

                        if(scheduledTask!=null && scheduledTask.equals(task)){
                            break;
                        }
                    }
                } catch (Exception e) {
                    logger.warn("Couldn't clean the timer from the JVM GC ", e);
                }
            }
        }

        if(future != null) {
            boolean removed = super.remove((Runnable) future);
            if(logger.isDebugEnabled()) {
                logger.debug("expiration timer on sip proxy task" + task + " removed : " + removed);
            }
            boolean cancelled = future.cancel(true);
            if(logger.isDebugEnabled()) {
                logger.debug("expiration timer on sip proxy task" + task + " Cancelled : " + cancelled);
            }

            future = null;
            // Purge is expensive when called frequently, only call it every now and then.
            // We do not sync the numCancelled variable. We dont care about correctness of
            // the number, and we will still call purge rought once on every 25 cancels.
            numCancelled++;
            if(numCancelled % 100 == 0) {
                super.purge();
            }
        } else {
            if(logger.isDebugEnabled()) {
                logger.debug("expiration timer future is null, thus cannot be Cancelled");
            }
        }
    }
296789
public static void SubmitDelayed( long millis, Runnable task ) {
        Actors.delayedCalls.schedule( new TimerTask() {
            @Override
            public void run() {
                task.run();
            }
        },millis);
    }