Examples of ScheduledFuture


Examples of java.util.concurrent.ScheduledFuture

            this.event = event;
        }

        public void run()
        {
            ScheduledFuture future = null;
            try
            {
                future = scheduledExecutor.schedule(new Runnable()
                {
                    public void run()
                    {
                        loggers.log(listener.reference, LogService.LOG_WARNING, "Listener timeout, will be blacklisted");
                        LOGGER.log(Level.WARNING, "Listener timeout, will be blacklisted");

                        remove(listener);
                    }
                }, timeout, timeUnit);

                listener.handleEvent(event);
            }
            catch (RejectedExecutionException ree)
            {
                loggers.log(listener.reference, LogService.LOG_WARNING, "Unable to schedule timeout for listener call, call skipped", ree);
                LOGGER.log(Level.WARNING, "Unable to schedule timeout for listener call, call skipped", ree);
            }
            catch (Throwable t)
            {
                loggers.log(listener.reference, LogService.LOG_WARNING, "Listener threw exception", t);
                LOGGER.log(Level.WARNING, "Listener threw exception", t);
            }
            finally
            {
                if (future != null) future.cancel(false);
                if (latch != null) latch.countDown();
            }
        }
View Full Code Here

Examples of java.util.concurrent.ScheduledFuture

        pool.initialize(10);
        System.out.println("About to execute new thread immediately");
        pool.execute(new MyTest("Executing immediately"));

        //ScheduledFuture sf = pool.schedule(new MyTest("Should execute in 30 seconds"), 30, TimeUnit.SECONDS);
        ScheduledFuture sf2 = pool.scheduleAtFixedRate(new MyTest("Should execute every 3 seconds after 10"), 10, 3, TimeUnit.SECONDS);
        ScheduledFuture sf3 = pool.schedule(new MyTest("Should never execute because cancelled"), 60, TimeUnit.SECONDS);
        Thread.sleep(30 * 1000);
        sf3.cancel(false);
        pool.schedule(new MyTest("Should execute after about 40 total seconds"), 5, TimeUnit.SECONDS);
        sf2.cancel(false);
        System.out.println("all done");
        Thread.sleep(30 * 1000);
        System.exit(-1);
View Full Code Here

Examples of java.util.concurrent.ScheduledFuture

    }

    @SuppressWarnings("unchecked")
    @Test
    public void scheduleWithFixedDelay() {
        @SuppressWarnings("rawtypes")
        ScheduledFuture expected = mock(ScheduledFuture.class);
        Runnable task = mock(Runnable.class);
        long delay = 10L;
        long period = 20L;
        TimeUnit unit = TimeUnit.SECONDS;
View Full Code Here

Examples of java.util.concurrent.ScheduledFuture

        }

        @Override
        public Date getNextRunTime(LastExecution lastExecution, Date taskScheduledTime) {
            Date nextRunTime = trigger.getNextRunTime(lastExecution, taskScheduledTime);
            final ScheduledFuture future = this.future;
            if (future != null && future.isCancelled()) {
                nextRunTime = null;
            }
            return nextRunTime;
        }
View Full Code Here

Examples of java.util.concurrent.ScheduledFuture

                        timeoutExpired(timeout);
                    }
                },
                clock);

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

Examples of java.util.concurrent.ScheduledFuture

*/
@Test(groups = "unit", testName = "AsyncMonitorTest")
public class AsyncMonitorTest {
   @SuppressWarnings({ "rawtypes", "unchecked" })
   public void testStartMonitoringWithoutTimeout() {
      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

Examples of java.util.concurrent.ScheduledFuture

      monitor.startMonitoring(100L, null);
   }

   @SuppressWarnings({ "rawtypes", "unchecked" })
   public void testStartMonitoringWithoutTimeoutAndNullTimeUnit() {
      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

Examples of java.util.concurrent.ScheduledFuture

      verify(schedulerMock);
   }

   @SuppressWarnings({ "rawtypes", "unchecked" })
   public void testStartMonitoringWithTimeout() {
      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

Examples of java.util.concurrent.ScheduledFuture

      verify(schedulerMock);
   }

   @SuppressWarnings({ "rawtypes", "unchecked" })
   public void testStartMonitoringWithTimeoutInMinutes() {
      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

Examples of java.util.concurrent.ScheduledFuture

      verify(schedulerMock);
   }

   @SuppressWarnings({ "rawtypes", "unchecked" })
   public void testIsTimeoutWhenNullTimeout() {
      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
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.