Package java.util.concurrent

Examples of java.util.concurrent.ScheduledExecutorService.schedule()


    ScheduledFuture<?> f7 = scheduler.schedule(new CancelTask(failoverconnection[0], 7), 600, TimeUnit.MILLISECONDS);
    ScheduledFuture<?> f8 = scheduler.schedule(new CancelTask(failoverconnection[1], 8), 600, TimeUnit.MILLISECONDS);
    ScheduledFuture<?> f9 = scheduler.schedule(new CancelTask(failoverconnection[2], 9), 600, TimeUnit.MILLISECONDS);
    ScheduledFuture<?> f10 = scheduler.schedule(new CancelTask(loadbalancedconnection[0], 10), 600, TimeUnit.MILLISECONDS);
    ScheduledFuture<?> f11 = scheduler.schedule(new CancelTask(loadbalancedconnection[1], 11), 600, TimeUnit.MILLISECONDS);
    ScheduledFuture<?> f12 = scheduler.schedule(new CancelTask(loadbalancedconnection[2], 12), 600, TimeUnit.MILLISECONDS);

    try {
      while (f1.get(5, TimeUnit.SECONDS) != null || f2.get(5, TimeUnit.SECONDS) != null ||
          f3.get(5, TimeUnit.SECONDS) != null || f4.get(5, TimeUnit.SECONDS) != null ||
          f5.get(5, TimeUnit.SECONDS) != null || f6.get(5, TimeUnit.SECONDS) != null ||
View Full Code Here


    ScheduledExecutorService executorService =
        Executors.newSingleThreadScheduledExecutor(
            new ServiceThreadFactory(getName(), true));
    setExecutor(executorService);
    scheduledFuture =
        executorService.schedule(command, delay, TimeUnit.MILLISECONDS);
  }

  /**
   * Stop the service.
   * If there is any exception noted from any executed notification,
View Full Code Here

            LOG.debug("***  send message 2 to broker");
            m.setText("2");

            // need to reset the flag in a seperate thread during the send
            ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
            executor.schedule(new Runnable() {
                @Override
                public void run() {
                    testTransactionContext.throwSQLException = false;
                    jdbc.throwSQLException = false;
                }
View Full Code Here

      ClusterStatus clusterStatus = groomServerManager.getClusterStatus(false);
      final int numGroomServers = clusterStatus.getGroomServers();
      final ScheduledExecutorService sched = Executors
          .newScheduledThreadPool(statuses.length + 5);
      for (GroomServerStatus status : statuses) {
        sched
            .schedule(new TaskWorker(status, numGroomServers, job), 0, SECONDS);
      }// for
    }
  }
View Full Code Here

    long chaosMonkeyDelay = conf.getLong(String.format("%s.%s", TEST_NAME, CHAOS_MONKEY_DELAY_KEY)
      , DEFAUL_CHAOS_MONKEY_DELAY);
    ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
    LOG.info(String.format("ChaosMonkey delay is : %d seconds. Will start %s " +
        "ChaosMonkey after delay", chaosMonkeyDelay / 1000, monkeyToUse));
    ScheduledFuture<?> result = executorService.schedule(new Runnable() {
      @Override
      public void run() {
        try {
          LOG.info("Starting ChaosMonkey");
          monkey.start();
View Full Code Here

          stat = BSStat.ERROR;
        } else {
          stat = BSStat.SUCCESS;
        }

        scheduler.schedule(new BSStatusCollector(), 0, TimeUnit.SECONDS);
        long startTime = System.currentTimeMillis();
        while (true) {
          if (LOG.isDebugEnabled()) {
            LOG.debug("Waiting for hosts status to be updated");
          }
View Full Code Here

      } catch (InterruptedException e) {
        throw new IOException(e);
      } finally {
        handle.cancel(true);
        /* schedule a last update */
        scheduler.schedule(new BSStatusCollector(), 0, TimeUnit.SECONDS);
        scheduler.shutdownNow();
        try {
          scheduler.awaitTermination(10, TimeUnit.SECONDS);
        } catch (InterruptedException e) {
          LOG.info("Interruped while waiting for scheduler");
View Full Code Here

          stat = BSStat.ERROR;
        } else {
          stat = BSStat.SUCCESS;
        }

        scheduler.schedule(new BSStatusCollector(), 0, TimeUnit.SECONDS);
        long startTime = System.currentTimeMillis();
        while (true) {
          if (LOG.isDebugEnabled()) {
            LOG.debug("Waiting for hosts status to be updated");
          }
View Full Code Here

      } catch (InterruptedException e) {
        throw new IOException(e);
      } finally {
        handle.cancel(true);
        /* schedule a last update */
        scheduler.schedule(new BSStatusCollector(), 0, TimeUnit.SECONDS);
        scheduler.shutdownNow();
        try {
          scheduler.awaitTermination(10, TimeUnit.SECONDS);
        } catch (InterruptedException e) {
          LOG.info("Interruped while waiting for scheduler");
View Full Code Here

    System.out.printf("Main: Starting at: %s\n",new Date());
   
    // Send the tasks to the executor with the specified delay
    for (int i=0; i<5; i++) {
      Task task=new Task("Task "+i);
      executor.schedule(task,i+1 , TimeUnit.SECONDS);
    }
   
    // Finish the executor
    executor.shutdown();
   
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.