Examples of ScheduledFuture


Examples of java.util.concurrent.ScheduledFuture

      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

Examples of java.util.concurrent.ScheduledFuture

      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

Examples of java.util.concurrent.ScheduledFuture

        if (null == taskObject) {
            return null;
        }
        final Logger logger = this.getLogger();
        final ScheduledExecutorService scheduled = Executors.newSingleThreadScheduledExecutor();
        ScheduledFuture future = null;
        if (taskObject instanceof Runnable) {
            if (TaskTypes.oneShot.equals(taskType)) {
                future = this.schedule((Runnable) taskObject,
                        scheduled, delay, unit);
            } else if (TaskTypes.atFixedRate.equals(taskType)) {
View Full Code Here

Examples of java.util.concurrent.ScheduledFuture

     * Cancel a particular task which updates a repo
     *
     * @param fileSystemRepo The location in the file system
     */
    public static void cancelTask(String fileSystemRepo) {
        ScheduledFuture scheduledFuture = futures.get(fileSystemRepo);
        if (scheduledFuture != null) {
            scheduledFuture.cancel(true);
            exec.purge();
            futures.remove(fileSystemRepo);
        }
    }
View Full Code Here

Examples of java.util.concurrent.ScheduledFuture

            // we use scheduleWithFixedDelay to prevent queue-up of tasks when
            // polling takes longer than the specified frequency, e.g. when the
            // polled database or network is slow or returns large amounts of
            // data.
            PollingReceiverWorker pollingReceiverWorker = this.createWork();
            ScheduledFuture schedule = connector.getScheduler().scheduleWithFixedDelay(
                    new PollingReceiverWorkerSchedule(pollingReceiverWorker), DEFAULT_STARTUP_DELAY,
                    this.getFrequency(), this.getTimeUnit());
            schedules.put(schedule, pollingReceiverWorker);

            if (logger.isDebugEnabled())
View Full Code Here

Examples of java.util.concurrent.ScheduledFuture

        synchronized (schedules)
        {
            // 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 = connector.getMuleContext().getConfiguration().getShutdownTimeout();
                PollingReceiverWorker worker = schedules.get(schedule);
                for (int elapsed = 0; worker.isRunning() && elapsed < shutdownTimeout; elapsed += 50)
                {
View Full Code Here

Examples of java.util.concurrent.ScheduledFuture

            new MergedRemoteIndexesTaskRequest( indexMergerRequest, indexMerger );

        logger.info( "schedule merge remote index for group {} with cron {}", repositoryGroup.getId(),
                     repositoryGroup.getCronExpression() );

        ScheduledFuture scheduledFuture =
            taskScheduler.schedule( new MergedRemoteIndexesTask( taskRequest ), cronTrigger );
        scheduledFutureMap.put( repositoryGroup.getId(), scheduledFuture );
    }
View Full Code Here

Examples of java.util.concurrent.ScheduledFuture

    }

    @Override
    public void unschedule( RepositoryGroup repositoryGroup )
    {
        ScheduledFuture scheduledFuture = scheduledFutureMap.remove( repositoryGroup.getId() );
        if ( scheduledFuture != null )
        {
            scheduledFuture.cancel( true );
        }
    }
View Full Code Here

Examples of java.util.concurrent.ScheduledFuture

      return this.currentFuture.isDone();
    }
  }

  public Object get() throws InterruptedException, ExecutionException {
    ScheduledFuture curr;
    synchronized (this.triggerContextMonitor) {
      curr = this.currentFuture;
    }
    return curr.get();
  }
View Full Code Here

Examples of java.util.concurrent.ScheduledFuture

    }
    return curr.get(timeout, unit);
  }

  public long getDelay(TimeUnit unit) {
    ScheduledFuture curr;
    synchronized (this.triggerContextMonitor) {
      curr = this.currentFuture;
    }
    return curr.getDelay(unit);
  }
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.