Package java.util.concurrent

Examples of java.util.concurrent.ScheduledFuture


      verify(schedulerMock);
   }

   @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


      verify(schedulerMock);
   }

   @SuppressWarnings({ "rawtypes", "unchecked" })
   public void testMonitorAndDone() {
      ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class);
      expect(mockFuture.isCancelled()).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

      verify(schedulerMock);
   }

   @SuppressWarnings({ "rawtypes", "unchecked" })
   public void testMonitorAndFail() {
      ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class);
      expect(mockFuture.isCancelled()).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

      verify(schedulerMock);
   }

   @SuppressWarnings({ "rawtypes", "unchecked" })
   public void testMonitorAndContinueWithoutTimeout() {
      ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class);
      ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class);
      expect(
            schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(),
                  anyObject(TimeUnit.class))).andReturn(mockFuture);
View Full Code Here

      verify(schedulerMock);
   }

   @SuppressWarnings({ "rawtypes", "unchecked" })
   public void testMonitorAndContinueWithtTimeout() throws InterruptedException {
      ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class);
      expect(mockFuture.isCancelled()).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

                        timeoutExpired(timeout);
                    }
                },
                clock);

        ScheduledFuture future = scheduledService.schedule(timeoutTask, delay, timeUnit);
        openTimeouts.put(sagaId, future);
    }
View Full Code Here

          Callable<Void> callableJob = createCallableJob( job,
                                                            ctx,
                                                            trigger,
                                                            jobHandle,
                                                            this.scheduler );
            ScheduledFuture future = schedule( date,
                                               callableJob,
                                               this.scheduler );
            jobHandle.setFuture( future );

            return jobHandle;
View Full Code Here

            task.addTransferFile(sstable, 1, sstable.getPositionsForRanges(ranges), 0);
        }
        assertEquals(2, task.getTotalNumberOfFiles());

        // if file sending completes before timeout then the task should be canceled.
        ScheduledFuture f = task.scheduleTimeout(0, 1, TimeUnit.SECONDS);
        task.complete(0);
        // timeout task may run after complete but it is noop
        f.get();

        // when timeout runs on second file, task should be completed
        f = task.scheduleTimeout(1, 1, TimeUnit.MILLISECONDS);
        f.get();
        assertEquals(StreamSession.State.WAIT_COMPLETE, session.state());

        // when all streaming are done, time out task should not be scheduled.
        assertNull(task.scheduleTimeout(1, 1, TimeUnit.SECONDS));
    }
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

        {
          processor.run();
        }
      }
    };
    ScheduledFuture future = exe.schedule(runner, 0, TimeUnit.MILLISECONDS);
    String requestId = UidGenerator.generateUid();
    currentRequests.put(requestId, future);
    return requestId;
  }
View Full Code Here

TOP

Related Classes of java.util.concurrent.ScheduledFuture

Copyright © 2018 www.massapicom. 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.