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

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


  public void testExistingJobKey() throws Exception {
    String role = "testRole";
    String env = "testEnv";
    String job = "testJob";

    ILock lock = makeLock(JobKeys.from(role, env, job).newBuilder());

    saveLocks(lock);
    removeLocks(lock);
    saveLocks(lock);
View Full Code Here


    String role = "testRole";
    String env = "testEnv";
    String job = "testJob";

    final ILock lock = makeLock(JobKeys.from(role, env, job).newBuilder());

    assertEquals(Optional.absent(), getLock(lock.getKey()));

    saveLocks(lock);
    assertEquals(Optional.<ILock>of(lock), getLock(lock.getKey()));
  }
View Full Code Here

    String role = "testRole";
    String env = "testEnv";
    String job1 = "testJob1";
    String job2 = "testJob2";

    ILock lock1 = makeLock(JobKeys.from(role, env, job1).newBuilder());
    ILock lock2 = makeLock(JobKeys.from(role, env, job2).newBuilder());

    saveLocks(lock1, lock2);
    assertLocks(lock1, lock2);

    storage.write(new MutateWork.Quiet<Void>() {
View Full Code Here

        ImmutableSet.of(new Attribute("attr", ImmutableSet.of("value")))));
    StoredJob job = new StoredJob(
        "jobManager",
        new JobConfiguration().setKey(new JobKey("owner", "env", "name")));
    String frameworkId = "framework_id";
    ILock lock = ILock.build(new Lock()
        .setKey(LockKey.job(JobKeys.from("testRole", "testEnv", "testJob").newBuilder()))
        .setToken("lockId")
        .setUser("testUser")
        .setTimestampMs(12345L));
    SchedulerMetadata metadata = new SchedulerMetadata()
View Full Code Here

              formatLockKey(lockKey),
              new Date(existingLock.get().getTimestampMs()).toString(),
              existingLock.get().getUser()));
        }

        ILock lock = ILock.build(new Lock()
            .setKey(lockKey.newBuilder())
            .setToken(tokenGenerator.createNew().toString())
            .setTimestampMs(clock.nowMillis())
            .setUser(user));
View Full Code Here

    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) {
View Full Code Here

    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);
View Full Code Here

              formatLockKey(lockKey),
              new Date(existingLock.get().getTimestampMs()).toString(),
              existingLock.get().getUser()));
        }

        ILock lock = ILock.build(new Lock()
            .setKey(lockKey.newBuilder())
            .setToken(tokenGenerator.createNew().toString())
            .setTimestampMs(clock.nowMillis())
            .setUser(user));
View Full Code Here

        if (instructions.getInitialState().isEmpty() && !instructions.isSetDesiredState()) {
          throw new IllegalArgumentException("Update instruction is a no-op.");
        }

        LOG.info("Starting update for job " + job);
        ILock lock;
        try {
          lock =
              lockManager.acquireLock(ILockKey.build(LockKey.job(job.newBuilder())), updatingUser);
        } catch (LockException e) {
          throw new UpdateStateException(e.getMessage(), e);
        }

        storeProvider.getJobUpdateStore().saveJobUpdate(
            update,
            Optional.of(requireNonNull(lock.getToken())));

        recordAndChangeJobUpdateStatus(
            storeProvider,
            summary.getUpdateId(),
            job,
View Full Code Here

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

      ILock lock = lockManager.acquireLock(lockKey, context.getIdentity());
      return okResponse(Result.acquireLockResult(
          new AcquireLockResult().setLock(lock.newBuilder())));
    } catch (AuthFailedException e) {
      return errorResponse(AUTH_FAILED, e);
    } catch (LockException e) {
      return errorResponse(LOCK_ERROR, e);
    }
View Full Code Here

TOP

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

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.