Package org.apache.aurora.scheduler.cron

Examples of org.apache.aurora.scheduler.cron.SanitizedCronJob


    RUNNING_FLAG.set(1);

    // TODO(ksweeney): Refactor the interface - we really only need the job keys here.
    for (IJobConfiguration job : cronJobManager.getJobs()) {
      try {
        SanitizedCronJob cronJob = SanitizedCronJob.fromUnsanitized(job);
        cronJobManager.scheduleJob(
            cronJob.getCrontabEntry(),
            cronJob.getSanitizedConfig().getJobConfig().getKey());
      } catch (CronException | ConfigurationManager.TaskDescriptionException e) {
        logLaunchFailure(job, e);
      }
    }
    LOADED_FLAG.set(1);
View Full Code Here


                  path));
              CRON_JOB_MISFIRES.incrementAndGet();
              return Optional.absent();
            }

            SanitizedCronJob cronJob;
            try {
              cronJob = SanitizedCronJob.fromUnsanitized(config.get());
            } catch (ConfigurationManager.TaskDescriptionException | CronException e) {
              LOG.warning(String.format(
                  "Invalid cron job for %s in storage - failed to parse with %s", key, e));
              CRON_JOB_PARSE_FAILURES.incrementAndGet();
              return Optional.absent();
            }

            CronCollisionPolicy collisionPolicy = cronJob.getCronCollisionPolicy();
            LOG.info(String.format(
                "Cron triggered for %s at %s with policy %s", path, new Date(), collisionPolicy));
            CRON_JOB_TRIGGERS.incrementAndGet();

            ImmutableMap<Integer, ITaskConfig> pendingTasks =
                ImmutableMap.copyOf(cronJob.getSanitizedConfig().getTaskConfigs());

            final Query.Builder activeQuery = Query.jobScoped(key).active();
            Set<String> activeTasks =
                Tasks.ids(storeProvider.getTaskStore().fetchTasks(activeQuery));
View Full Code Here

    cronJobManager.startJobNow(QuartzTestUtil.AURORA_JOB_KEY);
  }

  @Test
  public void testUpdateExistingJob() throws Exception {
    SanitizedCronJob sanitizedCronJob = QuartzTestUtil.makeSanitizedCronJob();

    expect(scheduler.deleteJob(QuartzTestUtil.QUARTZ_JOB_KEY)).andReturn(true);
    expect(scheduler.scheduleJob(anyObject(JobDetail.class), anyObject(Trigger.class)))
       .andReturn(null);

    populateStorage();

    control.replay();

    cronJobManager.updateJob(sanitizedCronJob);
    assertEquals(sanitizedCronJob.getSanitizedConfig().getJobConfig(), fetchFromStorage().orNull());
  }
View Full Code Here

    assertEquals(Optional.<IJobConfiguration>absent(), fetchFromStorage());
  }

  @Test
  public void testCreateNonexistentJob() throws Exception {
    SanitizedCronJob sanitizedCronJob = QuartzTestUtil.makeSanitizedCronJob();

    expect(scheduler.scheduleJob(anyObject(JobDetail.class), anyObject(Trigger.class)))
        .andReturn(null);

    control.replay();

    cronJobManager.createJob(sanitizedCronJob);

    assertEquals(
        sanitizedCronJob.getSanitizedConfig().getJobConfig(),
        fetchFromStorage().orNull());
  }
View Full Code Here

        fetchFromStorage().orNull());
  }

  @Test(expected = CronException.class)
  public void testCreateExistingJobFails() throws Exception {
    SanitizedCronJob sanitizedCronJob = QuartzTestUtil.makeSanitizedCronJob();
    populateStorage();
    control.replay();

    cronJobManager.createJob(sanitizedCronJob);
  }
View Full Code Here

        Iterables.getOnlyElement(cronJobManager.getJobs()));
  }

  @Test
  public void testNoRunOverlap() throws Exception {
    SanitizedCronJob runOverlapJob = SanitizedCronJob.fromUnsanitized(
        IJobConfiguration.build(QuartzTestUtil.JOB.newBuilder()
            .setCronCollisionPolicy(CronCollisionPolicy.RUN_OVERLAP)));

    control.replay();
View Full Code Here

    RUNNING_FLAG.set(1);

    // TODO(ksweeney): Refactor the interface - we really only need the job keys here.
    for (IJobConfiguration job : cronJobManager.getJobs()) {
      try {
        SanitizedCronJob cronJob = SanitizedCronJob.fromUnsanitized(job);
        cronJobManager.scheduleJob(
            cronJob.getCrontabEntry(),
            cronJob.getSanitizedConfig().getJobConfig().getKey());
      } catch (CronException | ConfigurationManager.TaskDescriptionException e) {
        logLaunchFailure(job, e);
      }
    }
    LOADED_FLAG.set(1);
View Full Code Here

                  path));
              CRON_JOB_MISFIRES.incrementAndGet();
              return Optional.absent();
            }

            SanitizedCronJob cronJob;
            try {
              cronJob = SanitizedCronJob.fromUnsanitized(config.get());
            } catch (ConfigurationManager.TaskDescriptionException | CronException e) {
              LOG.warning(String.format(
                  "Invalid cron job for %s in storage - failed to parse with %s", key, e));
              CRON_JOB_PARSE_FAILURES.incrementAndGet();
              return Optional.absent();
            }

            CronCollisionPolicy collisionPolicy = cronJob.getCronCollisionPolicy();
            LOG.info(String.format(
                "Cron triggered for %s at %s with policy %s", path, new Date(), collisionPolicy));
            CRON_JOB_TRIGGERS.incrementAndGet();

            final Query.Builder activeQuery = Query.jobScoped(key).active();
            Set<String> activeTasks =
                Tasks.ids(storeProvider.getTaskStore().fetchTasks(activeQuery));

            ITaskConfig task = cronJob.getSanitizedConfig().getJobConfig().getTaskConfig();
            Set<Integer> instanceIds = cronJob.getSanitizedConfig().getInstanceIds();
            if (activeTasks.isEmpty()) {
              stateManager.insertPendingTasks(storeProvider, task, instanceIds);

              return Optional.absent();
            }
View Full Code Here

TOP

Related Classes of org.apache.aurora.scheduler.cron.SanitizedCronJob

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.