@Override public void unlock() { if (entry == -1) return; log.debug("Removing lock entry {} userData {} lockType {}", entry, new String(this.userData, UTF_8), lockType()); qlock.removeEntry(entry); entry = -1; }
@Override public boolean tryLock() { if (entry == -1) { entry = qlock.addEntry(new ParsedLock(this.lockType(), this.userData).getLockData()); log.info("Added lock entry {} userData {} lockTpye {}", entry, new String(this.userData, UTF_8), lockType()); } SortedMap<Long,byte[]> entries = qlock.getEarlierEntries(entry); for (Entry<Long,byte[]> entry : entries.entrySet()) { ParsedLock parsed = new ParsedLock(entry.getValue()); if (entry.getKey().equals(this.entry)) return true; if (parsed.type == LockType.WRITE) return false; } throw new IllegalStateException("Did not find our own lock in the queue: " + this.entry + " userData " + new String(this.userData, UTF_8) + " lockType " + lockType()); }
@Override public void unlock() { if (entry == -1) return; log.debug("Removing lock entry " + entry + " userData " + new String(this.userData, UTF_8) + " lockType " + lockType()); qlock.removeEntry(entry); entry = -1; }
@Override public boolean tryLock() { if (entry == -1) { entry = qlock.addEntry(new ParsedLock(this.lockType(), this.userData).getLockData()); log.info("Added lock entry " + entry + " userData " + new String(this.userData, UTF_8) + " lockType " + lockType()); } SortedMap<Long,byte[]> entries = qlock.getEarlierEntries(entry); for (Entry<Long,byte[]> entry : entries.entrySet()) { ParsedLock parsed = new ParsedLock(entry.getValue()); if (entry.getKey().equals(this.entry)) return true; if (parsed.type == LockType.WRITE) return false; } throw new IllegalStateException("Did not find our own lock in the queue: " + this.entry + " userData " + new String(this.userData, UTF_8) + " lockType " + lockType()); }