@Override public void acquire() throws IOException { if (LOG.isTraceEnabled()) { LOG.trace("Attempt to acquire table " + (isShared ? "read" : "write") + " lock on: " + tableName + " for:" + purpose); } lock = createTableLock(); try { if (lockTimeoutMs == -1) { // Wait indefinitely lock.acquire(); } else { if (!lock.tryAcquire(lockTimeoutMs)) { throw new LockTimeoutException("Timed out acquiring " + (isShared ? "read" : "write") + "lock for table:" + tableName + "for:" + purpose + " after " + lockTimeoutMs + " ms."); } } } catch (InterruptedException e) { LOG.warn("Interrupted acquiring a lock for " + tableName, e); Thread.currentThread().interrupt(); throw new InterruptedIOException("Interrupted acquiring a lock"); } if (LOG.isTraceEnabled()) LOG.trace("Acquired table " + (isShared ? "read" : "write") + " lock on " + tableName + " for " + purpose); }