/** Activates the policy. Schedules acquire/release tasks with specified period. */
  @Override
  public BooleanWrapper activate() {
    cronScheduler.schedule(
        nodeAcquision,
        new Runnable() {
          public void run() {
            logger.info("Acquiring nodes");
            thisStub.acquireAllNodes();
          }
        });
    cronScheduler.schedule(
        nodeRemoval,
        new Runnable() {
          public void run() {
            logger.info("Removing nodes");
            thisStub.removeAllNodes(preemptive);
          }
        });
    cronScheduler.start();

    if (forceDeployment) {
      logger.info("Acquiring nodes");
      thisStub.acquireAllNodes();
    }
    return new BooleanWrapper(true);
  }
Esempio n. 2
0
 public static final void init(File dir) {
   if (dir == null || dir.listFiles() == null) return;
   scheduler = new Scheduler();
   scheduler.setDaemon(true);
   for (File file : dir.listFiles()) {
     scheduler.scheduleFile(file);
   }
   scheduler.start();
 }
Esempio n. 3
0
 public static void main(String[] args) {
   // Prepares the listener.
   MySchedulerListener listener = new MySchedulerListener();
   // Prepares the task.
   MyTask task = new MyTask();
   // Creates the scheduler.
   Scheduler scheduler = new Scheduler();
   // Registers the listener.
   scheduler.addSchedulerListener(listener);
   // Schedules the task, once every minute.
   scheduler.schedule("* * * * *", task);
   // Starts the scheduler.
   scheduler.start();
   // Stays alive for five minutes.
   try {
     Thread.sleep(5L * 60L * 1000L);
   } catch (InterruptedException e) {;
   }
   // Stops the scheduler.
   scheduler.stop();
 }
Esempio n. 4
0
 public static final void destroy() {
   if (scheduler != null) scheduler.stop();
 }
 /** Shutdown the policy and clears the timer. */
 @Override
 public void shutdown(Client initiator) {
   cronScheduler.stop();
   super.shutdown(initiator);
 }