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

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


  @Test
  public void testAcquireLock() throws Exception {
    control.replay();

    ILock expected = ILock.build(new Lock()
        .setKey(LOCK_KEY.newBuilder())
        .setToken(TOKEN.toString())
        .setTimestampMs(timestampMs)
        .setUser(USER));

    ILock actual = lockManager.acquireLock(expected.getKey(), USER);
    assertEquals(expected, actual);
  }
View Full Code Here


  @Test
  public void testReleaseLock() throws Exception {
    control.replay();

    ILock lock = lockManager.acquireLock(LOCK_KEY, USER);
    lockManager.releaseLock(lock);

    // Should be able to lock again after releasing.
    lockManager.acquireLock(LOCK_KEY, USER);
  }
View Full Code Here

  @Test
  public void testValidateLockStoredEqualHeld() throws Exception {
    control.replay();

    ILock lock = lockManager.acquireLock(LOCK_KEY, USER);
    lockManager.validateIfLocked(LOCK_KEY, Optional.of(lock));
  }
View Full Code Here

  @Test
  public void testValidateLockStoredNotEqualHeld() throws Exception {
    control.replay();

    expectLockException(JOB_KEY);
    ILock lock = lockManager.acquireLock(LOCK_KEY, USER);
    lock = ILock.build(lock.newBuilder().setUser("bob"));
    lockManager.validateIfLocked(LOCK_KEY, Optional.of(lock));
  }
View Full Code Here

  public void testValidateLockNotStoredHeld() throws Exception {
    control.replay();

    IJobKey jobKey = JobKeys.from("r", "e", "n");
    expectLockException(jobKey);
    ILock lock = lockManager.acquireLock(LOCK_KEY, USER);
    ILockKey key = ILockKey.build(LockKey.job(jobKey.newBuilder()));
    lockManager.validateIfLocked(key, Optional.of(lock));
  }
View Full Code Here

  @Test
  public void testGetLocks() throws Exception {
    control.replay();

    ILock lock = lockManager.acquireLock(LOCK_KEY, USER);
    assertEquals(lock, Iterables.getOnlyElement(lockManager.getLocks()));
  }
View Full Code Here

  @Test(expected = UpdateStateException.class)
  public void testJobLocked() throws Exception {
    control.replay();

    ILock lock = lockManager.acquireLock(ILockKey.build(LockKey.job(JOB.newBuilder())), USER);
    try {
      updater.start(makeJobUpdate(makeInstanceConfig(0, 0, NEW_CONFIG)), USER);
    } finally {
      lockManager.releaseLock(lock);
    }
View Full Code Here

  private ILock saveJobUpdate(
      JobUpdateStore.Mutable store,
      IJobUpdate update,
      JobUpdateStatus status) {

    ILock lock;
    try {
      lock = lockManager.acquireLock(
          ILockKey.build(LockKey.job(update.getSummary().getJobKey().newBuilder())), USER);
    } catch (LockManager.LockException e) {
      throw Throwables.propagate(e);
    }

    store.saveJobUpdate(update, Optional.of(lock.getToken()));
    store.saveJobUpdateEvent(
        IJobUpdateEvent.build(
            new JobUpdateEvent()
                .setStatus(status)
                .setTimestampMs(clock.nowMillis())),
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.