Ejemplo n.º 1
0
 LockToken makeToken() {
   LockToken token = new LockToken();
   token.info = lock.lockInfo;
   token.timeout = new LockTimeout(lock.seconds);
   token.tokenId = lock.lockId;
   return token;
 }
Ejemplo n.º 2
0
  public LockToken getCurrentLock() {
    if (this.lock == null) return null;
    LockToken token = new LockToken();
    token.info = this.lock.lockInfo;
    token.timeout = new LockTimeout(this.lock.seconds);
    token.tokenId = this.lock.lockId;

    return token;
  }
Ejemplo n.º 3
0
  public LockResult lock(LockTimeout timeout, LockInfo lockInfo) {
    System.out.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  locking");
    //        if( lock != null ) {
    //            // todo
    //            throw new RuntimeException("already locked");
    //        }

    LockTimeout.DateAndSeconds lockedUntil = timeout.getLockedUntil(60l, 3600l);

    this.lock =
        new TLock(lockedUntil.date, UUID.randomUUID().toString(), lockedUntil.seconds, lockInfo);

    LockToken token = new LockToken();
    token.info = lockInfo;
    token.timeout = new LockTimeout(lockedUntil.seconds);
    token.tokenId = this.lock.lockId;

    return LockResult.success(token);
  }