private Builder(SortedLockCollection<LockDescriptor> lockMap) { this.lockMap = lockMap; Preconditions.checkArgument(!this.lockMap.isEmpty()); }
/** * Returns the set of locks which were successfully acquired, as a mapping * from descriptor to lock mode. */ @JsonIgnore public SortedLockCollection<LockDescriptor> getLocks() { Preconditions.checkState(!lockMap.isEmpty()); return lockMap; }
/** * These grants should not be constructed by users. Only the lock service should hand them out. */ public HeldLocksGrant(BigInteger grantId, long creationDateMs, long expirationDateMs, SortedLockCollection<LockDescriptor> lockMap, TimeDuration lockTimeout, @Nullable Long versionId) { this.grantId = Preconditions.checkNotNull(grantId, "grantId should not be null"); this.creationDateMs = creationDateMs; this.expirationDateMs = expirationDateMs; this.lockMap = lockMap; this.lockTimeout = SimpleTimeDuration.of(lockTimeout); this.versionId = versionId; Preconditions.checkArgument(!this.lockMap.isEmpty()); }
/** * This should only be created by the Lock Service. */ public HeldLocksToken(BigInteger tokenId, LockClient client, long creationDateMs, long expirationDateMs, SortedLockCollection<LockDescriptor> lockMap, TimeDuration lockTimeout, @Nullable Long versionId, String requestingThread) { this.tokenId = Preconditions.checkNotNull(tokenId, "tokenId should not be null"); this.client = Preconditions.checkNotNull(client, "client should not be null"); this.creationDateMs = creationDateMs; this.expirationDateMs = expirationDateMs; this.lockMap = lockMap; this.lockTimeout = SimpleTimeDuration.of(lockTimeout); this.versionId = versionId; this.requestingThread = requestingThread; Preconditions.checkArgument(!this.lockMap.isEmpty()); }
Object readResolve() { return lockMap.isEmpty() ? new HeldLocksGrant(grantId) : new HeldLocksGrant(grantId, creationDateMs, expirationDateMs, lockMap, lockTimeout, versionId); } }
@JsonCreator SerializationProxy(@JsonProperty("tokenId") BigInteger tokenId, @JsonProperty("client") LockClient client, @JsonProperty("creationDateMs") long creationDateMs, @JsonProperty("expirationDateMs") long expirationDateMs, @JsonProperty("locks") List<LockWithMode> locks, @JsonProperty("lockTimeout") TimeDuration lockTimeout, @JsonProperty("versionId") Long versionId, @JsonProperty("requestingThread") String requestingThread) { ImmutableSortedMap.Builder<LockDescriptor, LockMode> localLockMapBuilder = ImmutableSortedMap.naturalOrder(); for (LockWithMode lock : locks) { localLockMapBuilder.put(lock.getLockDescriptor(), lock.getLockMode()); } this.lockMap = LockCollections.of(localLockMapBuilder.build()); this.tokenId = Preconditions.checkNotNull(tokenId, "tokenId"); this.client = Preconditions.checkNotNull(client, "client"); this.creationDateMs = creationDateMs; this.expirationDateMs = expirationDateMs; this.lockTimeout = SimpleTimeDuration.of(lockTimeout); this.versionId = versionId; this.requestingThread = requestingThread; Preconditions.checkArgument(!this.lockMap.isEmpty()); }
private Builder(SortedLockCollection<LockDescriptor> lockMap) { this.lockMap = lockMap; Preconditions.checkArgument(!this.lockMap.isEmpty()); }
/** * Returns the set of locks which were successfully acquired, as a mapping * from descriptor to lock mode. */ @JsonIgnore public SortedLockCollection<LockDescriptor> getLocks() { Preconditions.checkState(!lockMap.isEmpty()); return lockMap; }
/** * These grants should not be constructed by users. Only the lock service should hand them out. */ public HeldLocksGrant(BigInteger grantId, long creationDateMs, long expirationDateMs, SortedLockCollection<LockDescriptor> lockMap, TimeDuration lockTimeout, @Nullable Long versionId) { this.grantId = Preconditions.checkNotNull(grantId, "grantId should not be null"); this.creationDateMs = creationDateMs; this.expirationDateMs = expirationDateMs; this.lockMap = lockMap; this.lockTimeout = SimpleTimeDuration.of(lockTimeout); this.versionId = versionId; Preconditions.checkArgument(!this.lockMap.isEmpty()); }
/** * This should only be created by the Lock Service. */ public HeldLocksToken(BigInteger tokenId, LockClient client, long creationDateMs, long expirationDateMs, SortedLockCollection<LockDescriptor> lockMap, TimeDuration lockTimeout, @Nullable Long versionId, String requestingThread) { this.tokenId = Preconditions.checkNotNull(tokenId, "tokenId should not be null"); this.client = Preconditions.checkNotNull(client, "client should not be null"); this.creationDateMs = creationDateMs; this.expirationDateMs = expirationDateMs; this.lockMap = lockMap; this.lockTimeout = SimpleTimeDuration.of(lockTimeout); this.versionId = versionId; this.requestingThread = requestingThread; Preconditions.checkArgument(!this.lockMap.isEmpty()); }
Object readResolve() { return lockMap.isEmpty() ? new HeldLocksGrant(grantId) : new HeldLocksGrant(grantId, creationDateMs, expirationDateMs, lockMap, lockTimeout, versionId); } }
@JsonCreator SerializationProxy(@JsonProperty("tokenId") BigInteger tokenId, @JsonProperty("client") LockClient client, @JsonProperty("creationDateMs") long creationDateMs, @JsonProperty("expirationDateMs") long expirationDateMs, @JsonProperty("locks") List<LockWithMode> locks, @JsonProperty("lockTimeout") TimeDuration lockTimeout, @JsonProperty("versionId") Long versionId, @JsonProperty("requestingThread") String requestingThread) { ImmutableSortedMap.Builder<LockDescriptor, LockMode> localLockMapBuilder = ImmutableSortedMap.naturalOrder(); for (LockWithMode lock : locks) { localLockMapBuilder.put(lock.getLockDescriptor(), lock.getLockMode()); } this.lockMap = LockCollections.of(localLockMapBuilder.build()); this.tokenId = Preconditions.checkNotNull(tokenId, "tokenId"); this.client = Preconditions.checkNotNull(client, "client"); this.creationDateMs = creationDateMs; this.expirationDateMs = expirationDateMs; this.lockTimeout = SimpleTimeDuration.of(lockTimeout); this.versionId = versionId; this.requestingThread = requestingThread; Preconditions.checkArgument(!this.lockMap.isEmpty()); }