@Override public boolean tryLock() { if (entry == -1) { entry = qlock.addEntry(new ParsedLock(this.lockType(), this.userData).getLockData()); log.info("Added lock entry {} userData {} lockType {}", entry, new String(this.userData, UTF_8), lockType()); } SortedMap<Long,byte[]> entries = qlock.getEarlierEntries(entry); Iterator<Entry<Long,byte[]>> iterator = entries.entrySet().iterator(); if (!iterator.hasNext()) throw new IllegalStateException("Did not find our own lock in the queue: " + this.entry + " userData " + new String(this.userData, UTF_8) + " lockType " + lockType()); return iterator.next().getKey().equals(entry); } }
@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 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); Iterator<Entry<Long,byte[]>> iterator = entries.entrySet().iterator(); if (!iterator.hasNext()) throw new IllegalStateException("Did not find our own lock in the queue: " + this.entry + " userData " + new String(this.userData, UTF_8) + " lockType " + lockType()); if (iterator.next().getKey().equals(entry)) return true; return false; } }
@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()); }