NodeMetaInfoProvider { public static boolean decreaseConcurrentOperationCount( String nodeId ) { boolean relasedLockForOperationOnNode = false; nodeServiceLock.lock(); try { logger.debug( "Got the lock descreasing operation count for node:" + nodeId ); Integer currentOperationCount = (Integer) nodeMetaInfoMap.get( nodeId ); if ( currentOperationCount == null ) { logger.warn( "Strange!! Operation count for Node:" + nodeId + " is NOT present" ); } else if ( currentOperationCount > 0 ) { --currentOperationCount; logger.debug( "Decreasing concurrent operation count for Node:" + nodeId + " to:" + currentOperationCount ); nodeMetaInfoMap.put( nodeId, currentOperationCount ); relasedLockForOperationOnNode = true; } else { logger.warn( "Not resetting Concurrent operation count for Node:" + nodeId + " as it is:" + currentOperationCount ); } } catch ( Exception ex ) { logger.warn( "Error while decreasing for current operation count for Node:" + nodeId, ex ); } finally { nodeServiceLock.unlock(); } return relasedLockForOperationOnNode; }  static boolean increaseConcurrentOperationCount( String nodeId ); static boolean decreaseConcurrentOperationCount( String nodeId );  }
@Test public void decreaseConcurrentOperationCountTest() { NodeMetaInfoProvider.increaseConcurrentOperationCount( "N1" ); Boolean lockAcquired = NodeMetaInfoProvider.decreaseConcurrentOperationCount( "N1" ); assertTrue( lockAcquired ); }