Package java.util.concurrent

Examples of java.util.concurrent.ScheduledFuture


  {
    if (!currentRequests.containsKey(requestId))
    {
      return false;
    }
    ScheduledFuture future = currentRequests.get(requestId);
    if (future.isDone())
    {
      currentRequests.remove(requestId);
      return false;
    }
    else
View Full Code Here


     */
    private void scheduleCancelInflight(final String queueUrl, final Message message) {
        if (scheduler != null) {
            int visibility = getVisibilityForQueue(queueUrl);
            if (visibility > 0) {
                ScheduledFuture task = scheduler.schedule(new Runnable() {
                    @Override
                    public void run() {
                        synchronized (messages) {
                            // put it back!
                            messages.add(message);
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);
        }
    }
View Full Code Here

            // 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

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

            task.addTransferFile(sstable, 1, sstable.getPositionsForRanges(ranges));
        }
        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

            V>> entries) {
        final ScheduledEntry<K, V> result = entries.remove(key);
        if (entries.isEmpty()) {
            scheduledEntries.remove(second);

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

        return result;
    }

    private void schedule(final Integer second, final int delaySeconds) {
        EntryProcessorExecutor command = new EntryProcessorExecutor(second);
        ScheduledFuture scheduledFuture = scheduledExecutorService.schedule(command, delaySeconds, TimeUnit.SECONDS);
        scheduledTaskMap.put(second, scheduledFuture);
    }
View Full Code Here

        if (!executor.getQueue().isEmpty()) {
            out.println();
            out.println("Waiting jobs:");
            out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            for (Object o : executor.getQueue()) {
                ScheduledFuture task = (ScheduledFuture)o;
                out.println(Java.extractUnderlyingCallable((FutureTask)task) + " will run in " + task.getDelay(TimeUnit.SECONDS) + " seconds");       
            }
        }
        return sw.toString();
    }
View Full Code Here

                lmnt.setTimeToLive(negativeExpiry);
                cache.put(lmnt);
            }
        };

        ScheduledFuture future = this.pool.schedule(
                timeout, this.expireTime, TimeUnit.MILLISECONDS);

        String ident = task.getIdent();
        this.futures.put(ident, new FuturePackage(task, future));
    }
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.