AtlasTransientTypeRegistry lockTypeRegistryForUpdate(int lockMaxWaitTimeInSeconds) throws AtlasBaseException { LOG.debug("==> lockTypeRegistryForUpdate()"); boolean alreadyLockedByCurrentThread = typeRegistryUpdateLock.isHeldByCurrentThread(); if (!alreadyLockedByCurrentThread) { if (LOG.isDebugEnabled()) { LOG.debug("lockTypeRegistryForUpdate(): waiting for lock to be released by thread {}", lockedByThread); } } else { LOG.warn("lockTypeRegistryForUpdate(): already locked. currentLockCount={}", typeRegistryUpdateLock.getHoldCount()); } try { boolean isLocked = typeRegistryUpdateLock.tryLock(lockMaxWaitTimeInSeconds, TimeUnit.SECONDS); if (!isLocked) { throw new AtlasBaseException(AtlasErrorCode.FAILED_TO_OBTAIN_TYPE_UPDATE_LOCK); } } catch (InterruptedException excp) { throw new AtlasBaseException(AtlasErrorCode.FAILED_TO_OBTAIN_TYPE_UPDATE_LOCK, excp); } if (!alreadyLockedByCurrentThread) { if (LOG.isDebugEnabled()) { LOG.debug("lockTypeRegistryForUpdate(): wait over..got the lock"); } typeRegistryUnderUpdate = new AtlasTransientTypeRegistry(typeRegistry); lockedByThread = Thread.currentThread().getName(); } LOG.debug("<== lockTypeRegistryForUpdate()"); return typeRegistryUnderUpdate; }
AtlasTransientTypeRegistry lockTypeRegistryForUpdate(int lockMaxWaitTimeInSeconds) throws AtlasBaseException { LOG.debug("==> lockTypeRegistryForUpdate()"); boolean alreadyLockedByCurrentThread = typeRegistryUpdateLock.isHeldByCurrentThread(); if (!alreadyLockedByCurrentThread) { if (lockedByThread != null) { LOG.info("lockTypeRegistryForUpdate(): waiting for lock to be released by thread {}", lockedByThread); } } else { LOG.warn("lockTypeRegistryForUpdate(): already locked. currentLockCount={}", typeRegistryUpdateLock.getHoldCount()); } try { boolean isLocked = typeRegistryUpdateLock.tryLock(lockMaxWaitTimeInSeconds, TimeUnit.SECONDS); if (!isLocked) { throw new AtlasBaseException(AtlasErrorCode.FAILED_TO_OBTAIN_TYPE_UPDATE_LOCK); } } catch (InterruptedException excp) { throw new AtlasBaseException(AtlasErrorCode.FAILED_TO_OBTAIN_TYPE_UPDATE_LOCK, excp); } if (!alreadyLockedByCurrentThread) { if (LOG.isDebugEnabled()) { LOG.debug("lockTypeRegistryForUpdate(): wait over..got the lock"); } typeRegistryUnderUpdate = new AtlasTransientTypeRegistry(typeRegistry); lockedByThread = Thread.currentThread().getName(); } LOG.debug("<== lockTypeRegistryForUpdate()"); return typeRegistryUnderUpdate; }