Package org.apache.aurora.gen

Examples of org.apache.aurora.gen.Response


    requireNonNull(config);
    requireNonNull(session);
    checkNotBlank(config.getInstanceIds());
    IJobKey jobKey = JobKeys.assertValid(IJobKey.build(config.getKey()));

    Response resp = Util.emptyResponse();
    try {
      sessionValidator.checkAuthenticated(session, ImmutableSet.of(jobKey.getRole()));
      ITaskConfig task = ConfigurationManager.validateAndPopulate(
          ITaskConfig.build(config.getTaskConfig()));

      if (cronJobManager.hasJob(jobKey)) {
        return addMessage(resp, INVALID_REQUEST, "Instances may not be added to cron jobs.");
      }

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

      schedulerCore.addInstances(jobKey, ImmutableSet.copyOf(config.getInstanceIds()), task);
      return resp.setResponseCode(OK);
    } catch (AuthFailedException e) {
      return addMessage(resp, AUTH_FAILED, e);
    } catch (LockException e) {
      return addMessage(resp, LOCK_ERROR, e);
    } catch (TaskDescriptionException | ScheduleException e) {
View Full Code Here


  public Response acquireLock(LockKey mutableLockKey, SessionKey session) {
    requireNonNull(mutableLockKey);
    requireNonNull(session);

    ILockKey lockKey = ILockKey.build(mutableLockKey);
    Response response = Util.emptyResponse();

    try {
      SessionContext context = sessionValidator.checkAuthenticated(
          session,
          ImmutableSet.of(getRoleFromLockKey(lockKey)));

      ILock lock = lockManager.acquireLock(lockKey, context.getIdentity());
      response.setResult(Result.acquireLockResult(
          new AcquireLockResult().setLock(lock.newBuilder())));

      return response.setResponseCode(OK);
    } catch (AuthFailedException e) {
      return addMessage(response, AUTH_FAILED, e);
    } catch (LockException e) {
      return addMessage(response, LOCK_ERROR, e);
    }
View Full Code Here

  public Response releaseLock(Lock mutableLock, LockValidation validation, SessionKey session) {
    requireNonNull(mutableLock);
    requireNonNull(validation);
    requireNonNull(session);

    Response response = Util.emptyResponse();
    ILock lock = ILock.build(mutableLock);

    try {
      sessionValidator.checkAuthenticated(
          session,
          ImmutableSet.of(getRoleFromLockKey(lock.getKey())));

      if (validation == LockValidation.CHECKED) {
        lockManager.validateIfLocked(lock.getKey(), Optional.of(lock));
      }
      lockManager.releaseLock(lock);
      return response.setResponseCode(OK);
    } catch (AuthFailedException e) {
      return addMessage(response, AUTH_FAILED, e);
    } catch (LockException e) {
      return addMessage(response, LOCK_ERROR, e);
    }
View Full Code Here

    decoratedThrift = injector.getInstance(AuroraAdmin.Iface.class);
  }

  @Test
  public void testVersionIsSet() throws Exception {
    Response response = okResponse(
        Result.getJobsResult(
            new GetJobsResult().setConfigs(ImmutableSet.<JobConfiguration>of())));

    expect(realThrift.getJobs(ROLE)).andReturn(response);
    control.replay();
View Full Code Here

  @Test
  public void testServerInfoIsSet() throws Exception {
    ServerInfo previousServerInfo =
        new ServerInfo().setClusterName("FAKECLUSTER").setThriftAPIVersion(100000);

    Response response = okResponse(
        Result.getJobsResult(
            new GetJobsResult().setConfigs(ImmutableSet.<JobConfiguration>of())))
        .setServerInfo(previousServerInfo);

    expect(realThrift.getJobs(ROLE)).andReturn(response);
View Full Code Here

    assertEquals(SERVER_INFO.newBuilder(), decoratedThrift.getJobs(ROLE).getServerInfo());
  }

  private static Response okResponse(Result result) {
    return new Response()
        .setResponseCode(OK)
        .setResult(result);
  }
View Full Code Here

          if (error.isPresent()) {
            errors.add(error.get());
          }
        }

        Response resp = emptyResponse();
        if (errors.isEmpty()) {
          resp.setResponseCode(OK);
        } else {
          for (String error : errors) {
            addMessage(resp, WARNING, error);
          }
        }
View Full Code Here

        thriftClass.getClassLoader(),
        new Class<?>[] {thriftClass},
        new InvocationHandler() {
          @Override
          public Object invoke(Object o, Method method, Object[] args) throws Throwable {
            Response response = (Response) method.invoke(realThrift, args);
            assertTrue(response.isSetResponseCode());
            assertNotNull(response.getDetails());
            return response;
          }
        });
  }
View Full Code Here

  public void testPopulateJobConfig() throws Exception {
    IJobConfiguration job = IJobConfiguration.build(makeJob());
    SanitizedConfiguration sanitized = SanitizedConfiguration.fromUnsanitized(job);
    control.replay();

    Response response = assertOkResponse(thrift.populateJobConfig(job.newBuilder()));
    assertEquals(
        ImmutableSet.of(sanitized.getJobConfig().getTaskConfig().newBuilder()),
        response.getResult().getPopulateJobResult().getPopulatedDEPRECATED());

    assertEquals(
        sanitized.getJobConfig().getTaskConfig().newBuilder(),
        response.getResult().getPopulateJobResult().getTaskConfig());
  }
View Full Code Here

    job.getTaskConfig().unsetExecutorConfig();
    expectAuth(ROLE, true);

    control.replay();

    Response response = thrift.createJob(job, LOCK.newBuilder(), SESSION);
    assertResponse(INVALID_REQUEST, response);
    // TODO(wfarner): Don't rely on a magic string here, reference a constant from the source.
    assertMessageMatches(response, "Configuration may not be null");
  }
View Full Code Here

TOP

Related Classes of org.apache.aurora.gen.Response

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.