class NodeMetaInfoProvider {

    public static boolean increaseConcurrentOperationCount( String nodeId )
    {
        // Deliberately keeping true as default, as we better allow operations, rather than completely blocking them
        // incase of some issue.
        boolean canPerformOperationOnNode = true;

        // Get the lock for determining if the operation can be performed or not on the given node
        nodeServiceLock.lock();

        try
        {
            logger.debug( "Got the lock for determining feasibility to call operation service for node:" + nodeId );

            Integer currentOperationCount = (Integer) nodeMetaInfoMap.get( nodeId );

            if ( currentOperationCount == null )
            {
                currentOperationCount = 0;
            }

            int maxConcurrentTasksPerNode = CommonProperties.getMaxConcurrentTasksPerNode();

            if ( currentOperationCount >= maxConcurrentTasksPerNode )
            {
                logger.warn( "Will not perform further operation. Reached Max concurrent operation count for Node:"
                    + nodeId + ". Current count:" + maxConcurrentTasksPerNode );
                canPerformOperationOnNode = false;
            }
            else
            {
                ++currentOperationCount;
                logger.debug( "Node can perform operation. Increasing current concurrent operation count for Node:"
                    + nodeId + " set to:" + currentOperationCount );
                nodeMetaInfoMap.put( nodeId, currentOperationCount );
            }
        }
        catch ( Exception ex )
        {
            logger.warn( "Error while checking for current operation count for Node:" + nodeId, ex );
        }
        finally
        {
            nodeServiceLock.unlock();
        }

        return canPerformOperationOnNode;
    }

}