Package org.apache.aurora.scheduler.storage.entities

Examples of org.apache.aurora.scheduler.storage.entities.IJobConfiguration


    assertResponse(LOCK_ERROR, thrift.createJob(job.newBuilder(), LOCK.newBuilder(), SESSION));
  }

  @Test
  public void testCreateJobFails() throws Exception {
    IJobConfiguration job = IJobConfiguration.build(makeJob());
    expectAuth(ROLE, true);
    lockManager.validateIfLocked(LOCK_KEY, Optional.of(LOCK));
    scheduler.createJob(SanitizedConfiguration.fromUnsanitized(job));
    expectLastCall().andThrow(new ScheduleException("fail"));
    control.replay();

    assertResponse(
        INVALID_REQUEST,
        thrift.createJob(job.newBuilder(), LOCK.newBuilder(), SESSION));
  }
View Full Code Here


      throws ScheduleException {

    storage.write(new MutateWork.NoResult<ScheduleException>() {
      @Override
      protected void execute(MutableStoreProvider storeProvider) throws ScheduleException {
        final IJobConfiguration job = sanitizedConfiguration.getJobConfig();
        if (hasActiveJob(job)) {
          throw new ScheduleException(
              "Job already exists: " + JobKeys.canonicalString(job.getKey()));
        }

        validateTaskLimits(job.getTaskConfig(), job.getInstanceCount());
        // TODO(mchucarroll): deprecate cron as a part of create/kill job.(AURORA-454)
        if (sanitizedConfiguration.isCron()) {
          try {
            LOG.warning("Deprecated behavior: scheduling job " + job.getKey()
                + " with cron via createJob (AURORA_454)");
            cronJobManager.createJob(SanitizedCronJob.from(sanitizedConfiguration));
          } catch (CronException e) {
            throw new ScheduleException(e);
          }
View Full Code Here

  public Response createJob(
      JobConfiguration mutableJob,
      @Nullable Lock mutableLock,
      SessionKey session) {

    IJobConfiguration job = IJobConfiguration.build(mutableJob);
    IJobKey jobKey = JobKeys.assertValid(job.getKey());
    requireNonNull(session);

    Response response = Util.emptyResponse();

    try {
      sessionValidator.checkAuthenticated(session, ImmutableSet.of(job.getOwner().getRole()));
    } catch (AuthFailedException e) {
      return addMessage(response, AUTH_FAILED, e);
    }

    try {
View Full Code Here

  public Response scheduleCronJob(
      JobConfiguration mutableJob,
      @Nullable Lock mutableLock,
      SessionKey session) {

    IJobConfiguration job = IJobConfiguration.build(mutableJob);
    IJobKey jobKey = JobKeys.assertValid(job.getKey());
    requireNonNull(session);

    Response response = Util.emptyResponse();

    try {
      sessionValidator.checkAuthenticated(session, ImmutableSet.of(job.getOwner().getRole()));
    } catch (AuthFailedException e) {
      return addMessage(response, AUTH_FAILED, e);
    }

    try {
View Full Code Here

      JobConfiguration mutableConfig,
      @Nullable Lock mutableLock,
      SessionKey session) {

    requireNonNull(mutableConfig);
    IJobConfiguration job = IJobConfiguration.build(mutableConfig);
    IJobKey jobKey = JobKeys.assertValid(job.getKey());
    requireNonNull(session);

    Response response = Util.emptyResponse();
    try {
      sessionValidator.checkAuthenticated(session, ImmutableSet.of(job.getOwner().getRole()));
    } catch (AuthFailedException e) {
      return addMessage(response, AUTH_FAILED, e);
    }

    try {
View Full Code Here

    final Map<IJobKey, IJobConfiguration> jobs = getJobs(ownerRole, tasks);

    Function<IJobKey, JobSummary> makeJobSummary = new Function<IJobKey, JobSummary>() {
      @Override
      public JobSummary apply(IJobKey jobKey) {
        IJobConfiguration job = jobs.get(jobKey);
        JobSummary summary = new JobSummary()
            .setJob(job.newBuilder())
            .setStats(Jobs.getJobStats(tasks.get(jobKey)).newBuilder());

        return Strings.isNullOrEmpty(job.getCronSchedule())
            ? summary
            : summary.setNextCronRunMs(
                cronPredictor.predictNextRun(CrontabEntry.parse(job.getCronSchedule())).getTime());
      }
    };

    ImmutableSet<JobSummary> jobSummaries =
        FluentIterable.from(jobs.keySet()).transform(makeJobSummary).toSet();
View Full Code Here

      }
    });
  }

  private Optional<String> rewriteJob(JobConfigRewrite jobRewrite, JobStore.Mutable jobStore) {
    IJobConfiguration existingJob = IJobConfiguration.build(jobRewrite.getOldJob());
    IJobConfiguration rewrittenJob;
    Optional<String> error = Optional.absent();
    try {
      rewrittenJob = ConfigurationManager.validateAndPopulate(
          IJobConfiguration.build(jobRewrite.getRewrittenJob()));
    } catch (TaskDescriptionException e) {
      // We could add an error here, but this is probably a hint of something wrong in
      // the client that's causing a bad configuration to be applied.
      throw Throwables.propagate(e);
    }

    if (existingJob.getKey().equals(rewrittenJob.getKey())) {
      if (existingJob.getOwner().equals(rewrittenJob.getOwner())) {
        Multimap<String, IJobConfiguration> matches = jobsByKey(jobStore, existingJob.getKey());
        switch (matches.size()) {
          case 0:
            error = Optional.of(
                "No jobs found for key " + JobKeys.canonicalString(existingJob.getKey()));
            break;

          case 1:
            Map.Entry<String, IJobConfiguration> match =
                Iterables.getOnlyElement(matches.entries());
            IJobConfiguration storedJob = match.getValue();
            if (storedJob.equals(existingJob)) {
              jobStore.saveAcceptedJob(match.getKey(), rewrittenJob);
            } else {
              error = Optional.of(
                  "CAS compare failed for " + JobKeys.canonicalString(storedJob.getKey()));
            }
            break;

          default:
            error = Optional.of("Multiple jobs found for key "
View Full Code Here

    }

    return storage.write(new MutateWork.Quiet<Response>() {
      @Override
      public Response apply(MutableStoreProvider storeProvider) {
        final IJobConfiguration job = sanitized.getJobConfig();

        try {
          lockManager.validateIfLocked(
              ILockKey.build(LockKey.job(job.getKey().newBuilder())),
              Optional.fromNullable(mutableLock).transform(ILock.FROM_BUILDER));

          if (!storeProvider.getTaskStore().fetchTasks(
              Query.jobScoped(job.getKey()).active()).isEmpty()
              || cronJobManager.hasJob(job.getKey())) {

            return invalidResponse("Job already exists: " + JobKeys.canonicalString(job.getKey()));
          }

          ITaskConfig template = sanitized.getJobConfig().getTaskConfig();
          int count = sanitized.getJobConfig().getInstanceCount();

          validateTaskLimits(template, count, quotaManager.checkInstanceAddition(template, count));

          // TODO(mchucarroll): deprecate cron as a part of create/kill job.(AURORA-454)
          if (sanitized.isCron()) {
            LOG.warning("Deprecated behavior: scheduling job " + job.getKey()
                + " with cron via createJob (AURORA_454)");
            cronJobManager.createJob(SanitizedCronJob.from(sanitized));
          } else {
            LOG.info("Launching " + count + " tasks.");
            stateManager.insertPendingTasks(
View Full Code Here

  public Response scheduleCronJob(
      JobConfiguration mutableJob,
      @Nullable Lock mutableLock,
      SessionKey session) {

    IJobConfiguration job = IJobConfiguration.build(mutableJob);
    IJobKey jobKey = JobKeys.assertValid(job.getKey());
    requireNonNull(session);

    try {
      sessionValidator.checkAuthenticated(session, ImmutableSet.of(jobKey.getRole()));
    } catch (AuthFailedException e) {
View Full Code Here

      JobConfiguration mutableConfig,
      @Nullable Lock mutableLock,
      SessionKey session) {

    requireNonNull(mutableConfig);
    IJobConfiguration job = IJobConfiguration.build(mutableConfig);
    IJobKey jobKey = JobKeys.assertValid(job.getKey());
    requireNonNull(session);

    try {
      sessionValidator.checkAuthenticated(session, ImmutableSet.of(jobKey.getRole()));
    } catch (AuthFailedException e) {
View Full Code Here

TOP

Related Classes of org.apache.aurora.scheduler.storage.entities.IJobConfiguration

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.