Java Code Examples for org.apache.commons.lang3.mutable.MutableInt#decrement()

The following examples show how to use org.apache.commons.lang3.mutable.MutableInt#decrement() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IPCUtil.java    From hbase with Apache License 2.0 6 votes vote down vote up
static void execute(EventLoop eventLoop, Runnable action) {
  if (eventLoop.inEventLoop()) {
    // this is used to prevent stack overflow, you can see the same trick in netty's LocalChannel
    // implementation.
    MutableInt depth = DEPTH.get();
    if (depth.intValue() < MAX_DEPTH) {
      depth.increment();
      try {
        action.run();
      } finally {
        depth.decrement();
      }
    } else {
      eventLoop.execute(action);
    }
  } else {
    eventLoop.execute(action);
  }
}
 
Example 2
Source File: ZKConnectionRegistry.java    From hbase with Apache License 2.0 5 votes vote down vote up
private static void tryComplete(MutableInt remaining, HRegionLocation[] locs,
    CompletableFuture<RegionLocations> future) {
  remaining.decrement();
  if (remaining.intValue() > 0) {
    return;
  }
  future.complete(new RegionLocations(locs));
}
 
Example 3
Source File: BehaviourFilterImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
@Extend(traitAPI = BehaviourFilterTrait.class, extensionAPI = BehaviourFilterExtension.class)
public void enableBehaviour(QName className)
{
    ParameterCheck.mandatory("className", className);
    
    if (logger.isDebugEnabled())
    {
        logger.debug("Behaviour: ENABLE (" + AlfrescoTransactionSupport.getTransactionId() + "): " + className);
    }
    
    TransactionalResourceHelper.decrementCount(KEY_FILTER_COUNT, false);
    
    if (!TransactionalResourceHelper.isResourcePresent(KEY_CLASS_FILTERS))
    {
        // Nothing was disabled
        return;
    }
    Map<ClassFilter, MutableInt> classFilters = TransactionalResourceHelper.getMap(KEY_CLASS_FILTERS);
    MutableInt filterNumber = null;
    for (ClassFilter classFilter : classFilters.keySet())
    {
        if (classFilter.getClassName().equals(className))
        {
            filterNumber = classFilters.get(classFilter);
            break;
        }
    }
    if (filterNumber == null)
    {
        // Class was not disabled
        return;
    }
    else if (filterNumber.intValue() <= 0)
    {
        // Can't go below zero for this
    }
    else
    {
        filterNumber.decrement();
    }
    
    if (logger.isDebugEnabled())
    {
        logger.debug("   Now: "+ filterNumber);
    }
}
 
Example 4
Source File: BehaviourFilterImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
@Extend(traitAPI = BehaviourFilterTrait.class, extensionAPI = BehaviourFilterExtension.class)
public void enableBehaviour(NodeRef nodeRef, QName className)
{
    ParameterCheck.mandatory("nodeRef",  nodeRef);
    ParameterCheck.mandatory("className",  className);
    
    if (logger.isDebugEnabled())
    {
        logger.debug("Behaviour: ENABLE (" + AlfrescoTransactionSupport.getTransactionId() + "): " + nodeRef + "/" + className);
    }
    
    TransactionalResourceHelper.decrementCount(KEY_FILTER_COUNT, false);
    
    if (!TransactionalResourceHelper.isResourcePresent(KEY_INSTANCE_CLASS_FILTERS))
    {
        // Nothing was disabled
        return;
    }
    nodeRef = tenantService.getName(nodeRef);

    Map<NodeRef, Map<QName, MutableInt>> instanceClassFilters = TransactionalResourceHelper.getMap(KEY_INSTANCE_CLASS_FILTERS);
    Map<QName, MutableInt> classFilters = instanceClassFilters.get(nodeRef);
    if (classFilters == null)
    {
        // Instance classes were not disabled
        return;
    }
    MutableInt filter = classFilters.get(className);
    if (filter == null)
    {
        // Class was not disabled
        return;
    }
    else if (filter.intValue() <= 0)
    {
        // Can't go below zero for this
    }
    else
    {
        filter.decrement();
    }
    
    if (logger.isDebugEnabled())
    {
        logger.debug("   Now: "+ filter);
    }
}
 
Example 5
Source File: BehaviourFilterImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
@Extend(traitAPI = BehaviourFilterTrait.class, extensionAPI = BehaviourFilterExtension.class)
public void enableBehaviour(NodeRef nodeRef)
{
    ParameterCheck.mandatory("nodeRef",  nodeRef);
    
    if (logger.isDebugEnabled())
    {
        logger.debug("Behaviour: ENABLE (" + AlfrescoTransactionSupport.getTransactionId() + "): " + nodeRef + "/ALL");
    }
    
    TransactionalResourceHelper.decrementCount(KEY_FILTER_COUNT, false);
    
    if (!TransactionalResourceHelper.isResourcePresent(KEY_INSTANCE_FILTERS))
    {
        // Nothing was disabled
        return;
    }
    nodeRef = tenantService.getName(nodeRef);

    Map<NodeRef, MutableInt> instanceFilters = TransactionalResourceHelper.getMap(KEY_INSTANCE_FILTERS);
    MutableInt filter = instanceFilters.get(nodeRef);
    if (filter == null)
    {
        // Instance was not disabled
        return;
    }
    else if (filter.intValue() <= 0)
    {
        // Can't go below zero for this
    }
    else
    {
        filter.decrement();
    }
    
    if (logger.isDebugEnabled())
    {
        logger.debug("   Now:" + filter);
    }
}