Package java.util.concurrent

Examples of java.util.concurrent.ScheduledFuture.cancel()


   @SuppressWarnings({ "rawtypes", "unchecked" })
   public void testStopMonitoringWhenFutureIsNotComplete() {
      ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class);
      expect(mockFuture.isCancelled()).andReturn(false);
      expect(mockFuture.isDone()).andReturn(false);
      expect(mockFuture.cancel(false)).andReturn(true);

      ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class);
      expect(
            schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(),
                  anyObject(TimeUnit.class))).andReturn(mockFuture);
View Full Code Here


    public void touch() {
        // if the task of killing is cancelled successfully then reset the session monitor. otherwise this session
        // has already been killed and there's nothing left to do with this session.
        final ScheduledFuture killFuture = kill.get();
        if (null == killFuture || !killFuture.isDone()) {
            if (killFuture != null) killFuture.cancel(false);
            kill.set(this.scheduledExecutorService.schedule(() -> {
                // when the session is killed open transaction should be rolled back
                graphs.getGraphs().values().forEach(g -> {
                    if (g.features().graph().supportsTransactions()) {
                        // have to execute the rollback in the executor because the transaction is associated with
View Full Code Here

    @Override
    public void deleteMessage(DeleteMessageRequest deleteMessageRequest) throws AmazonClientException {
        String receiptHandle = deleteMessageRequest.getReceiptHandle();
        if (inFlight.containsKey(receiptHandle)) {
            ScheduledFuture inFlightTask = inFlight.get(receiptHandle);
            inFlightTask.cancel(true);
        }
    }

    @Override
    public void setQueueAttributes(SetQueueAttributesRequest setQueueAttributesRequest) throws AmazonServiceException, AmazonClientException {
View Full Code Here

        {
            // cancel our schedules gently: do not interrupt when polling is in progress
            for (Iterator<ScheduledFuture> i = schedules.keySet().iterator(); i.hasNext();)
            {
                ScheduledFuture schedule = i.next();
                schedule.cancel(false);
                // Wait until in-progress PollingRecevierWorker completes.
                int shutdownTimeout = endpoint.getMuleContext().getConfiguration().getShutdownTimeout();
                PollingReceiverWorker worker = schedules.get(schedule);
                for (int elapsed = 0; worker.isRunning() && elapsed < shutdownTimeout; elapsed += 50)
                {
View Full Code Here

        if (entries.isEmpty()) {
            scheduledEntries.remove(second);

            ScheduledFuture removed = scheduledTaskMap.remove(second);
            if (removed != null) {
                removed.cancel(false);
            }
        }
        return result;
    }
View Full Code Here

        boolean signalComplete;
        synchronized (this)
        {
            ScheduledFuture timeout = timeoutTasks.remove(sequenceNumber);
            if (timeout != null)
                timeout.cancel(false);

            OutgoingFileMessage file = files.remove(sequenceNumber);
            if (file != null)
                file.sstable.releaseReference();
View Full Code Here

    public synchronized OutgoingFileMessage createMessageForRetry(int sequenceNumber)
    {
        // remove previous time out task to be rescheduled later
        ScheduledFuture future = timeoutTasks.remove(sequenceNumber);
        if (future != null)
            future.cancel(false);
        return files.get(sequenceNumber);
    }

    /**
     * Schedule timeout task to release reference for file sent.
View Full Code Here

  }

  public void removeScheduledJob(Runnable runnable) {
    final ScheduledFuture scheduledTaskInfo = scheduledRunnable.remove(runnable);
    if (scheduledTaskInfo != null) {
      scheduledTaskInfo.cancel(false);
    }
  }

  public void runAsync(Runnable runnable) {
    internalAsyncTaskService.runAsync(runnable);
View Full Code Here

   @SuppressWarnings({ "rawtypes", "unchecked" })
   public void testStopMonitoringWhenFutureIsNotComplete() {
      ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class);
      expect(mockFuture.isCancelled()).andReturn(false);
      expect(mockFuture.isDone()).andReturn(false);
      expect(mockFuture.cancel(false)).andReturn(true);

      ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class);
      expect(
            schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(),
                  anyObject(TimeUnit.class))).andReturn(mockFuture);
View Full Code Here

    }, 0, 1000, TimeUnit.MILLISECONDS);

    System.out.println("Press enter to shutdown");
    System.out.println("===========================================================\n\n");
    System.in.read();
    task.cancel(false);

    System.out.println("Shutting down...");
    shutdown(d2Client, executorService, clientShutdownTimeout);
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.