Example usage for java.util.concurrent ConcurrentHashMap remove

List of usage examples for java.util.concurrent ConcurrentHashMap remove

Introduction

In this page you can find the example usage for java.util.concurrent ConcurrentHashMap remove.

Prototype

public V remove(Object key) 

Source Link

Document

Removes the key (and its corresponding value) from this map.

Usage

From source file:com.weibo.api.motan.registry.support.LocalRegistryService.java

@Override
public void doUnsubscribe(URL url, NotifyListener listener) {
    String subscribeKey = getSubscribeKey(url);
    ConcurrentHashMap<URL, ConcurrentHashSet<NotifyListener>> urlListeners = subscribeListeners
            .get(subscribeKey);/* w w w  .  j a va  2s . c  o  m*/
    if (urlListeners != null) {
        urlListeners.remove(url);
    }

    LoggerUtil.info("LocalRegistryService unsubscribe: url={}", url);
}

From source file:com.opengamma.financial.currency.AbstractCurrencyMatrix.java

protected CurrencyMatrixValue removeConversion(final Currency source, final Currency target) {
    ArgumentChecker.notNull(source, "source");
    ArgumentChecker.notNull(target, "target");
    ConcurrentHashMap<Currency, CurrencyMatrixValue> conversions = _values.get(source);
    if (conversions == null) {
        // Nothing from that source
        return null;
    }//from www  . j a  v  a 2 s . com
    final CurrencyMatrixValue value = conversions.remove(target);
    if (value == null) {
        // No conversion from source to target
        return null;
    }
    // Removed a value, so need to decrease the target's reference count
    AtomicInteger targetCount = _targets.get(target);
    if (targetCount != null) {
        // Target count should never be null at this point
        if (targetCount.decrementAndGet() == 0) {
            // This was the last reference to the target, confirm and remove atomically against the "add" operation
            synchronized (targetCount) {
                if (targetCount.get() == 0) {
                    _targets.remove(target);
                }
            }
        }
    }
    return value;
}

From source file:org.wso2.carbon.event.output.adapter.core.internal.CarbonOutputEventAdapterService.java

@Override
public void destroy(String name) {
    int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
    ConcurrentHashMap<String, OutputAdapterRuntime> eventAdapters = tenantSpecificEventAdapters.get(tenantId);
    if (eventAdapters == null) {
        return;/*from  www .j a v  a  2  s. c  o  m*/
    }
    OutputAdapterRuntime outputAdapterRuntime = eventAdapters.remove(name);
    if (outputAdapterRuntime != null) {
        outputAdapterRuntime.destroy();
    }
}

From source file:de.ks.flatadocdb.index.GlobalIndex.java

@Override
public void removeEntry(SessionEntry sessionEntry) {
    IndexElement element = new IndexElement(repository, sessionEntry.getCompletePath(), sessionEntry.getId(),
            sessionEntry.getNaturalId(), sessionEntry.getObject().getClass());
    idToElement.remove(element.getId());
    if (element.hasNaturalId()) {
        naturalIdToElement.remove(element.getNaturalId());
    }//from   w w  w  . ja  v a2  s. c o m
    @SuppressWarnings("unchecked")
    Set<Query<Object, Object>> queries = (Set) sessionEntry.getEntityDescriptor().getQueries();
    for (Query<Object, Object> query : queries) {
        ConcurrentHashMap<IndexElement, Optional<Object>> map = queryElements.get(query);
        if (map != null) {
            map.remove(element);
        }
    }
}

From source file:org.wso2.carbon.event.input.adapter.core.internal.CarbonInputEventAdapterService.java

@Override
public void destroy(String name) {
    int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
    ConcurrentHashMap<String, InputAdapterRuntime> eventAdapters = tenantSpecificEventAdapters.get(tenantId);
    if (eventAdapters == null) {
        return;//w  w  w. ja  v a  2  s .c o  m
    }
    InputAdapterRuntime inputAdapterRuntime = eventAdapters.remove(name);
    if (inputAdapterRuntime != null) {
        inputAdapterRuntime.destroy();
    }
}

From source file:com.taobao.diamond.server.service.GroupService.java

public void removeAddress2GroupMapping(long id) {
    synchronized (this) {
        GroupInfo groupInfo = this.persistService.findGroupInfoByID(id);
        if (groupInfo == null)
            return;
        this.persistService.removeGroupInfoByID(id);
        ConcurrentHashMap<String, GroupInfo> dataIdMap = this.addressGroupCache.get(groupInfo.getAddress());
        if (dataIdMap != null) {
            dataIdMap.remove(groupInfo.getDataId());
        }/*from   w  w w.  j  a v  a2s  .  co m*/
    }
    this.notifyService.notifyGroupChanged();
}

From source file:org.wso2.carbon.event.input.adaptor.soap.SoapEventAdaptorType.java

@Override
public void unsubscribe(InputEventAdaptorMessageConfiguration inputEventAdaptorMessageConfiguration,
        InputEventAdaptorConfiguration inputEventAdaptorConfiguration,

        AxisConfiguration axisConfiguration, String subscriptionId) {

    String operationName = inputEventAdaptorMessageConfiguration.getInputMessageProperties()
            .get(SoapEventAdaptorConstants.ADAPTOR_MESSAGE_OPERATION_NAME);

    int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
    Map<String, ConcurrentHashMap<String, ConcurrentHashMap<String, SoapAdaptorListener>>> tenantSpecificListenerMap = inputEventAdaptorListenerMap
            .get(tenantId);//from w  ww.  j ava2 s  . c o  m
    if (tenantSpecificListenerMap != null) {
        ConcurrentHashMap<String, ConcurrentHashMap<String, SoapAdaptorListener>> adaptorSpecificListeners = tenantSpecificListenerMap
                .get(inputEventAdaptorConfiguration.getName());

        if (adaptorSpecificListeners != null) {
            ConcurrentHashMap<String, SoapAdaptorListener> operationSpecificListeners = adaptorSpecificListeners
                    .get(operationName);
            if (operationSpecificListeners != null) {
                operationSpecificListeners.remove(subscriptionId);
                if (operationSpecificListeners.isEmpty()) {
                    tenantSpecificListenerMap.remove(operationName);
                    try {
                        Axis2Util.removeOperation(inputEventAdaptorMessageConfiguration,
                                inputEventAdaptorConfiguration, axisConfiguration, subscriptionId);
                    } catch (AxisFault axisFault) {
                        throw new InputEventAdaptorEventProcessingException("Can not remove operation ",
                                axisFault);
                    }
                }
            }
        }
    }

}

From source file:com.steffi.index.ImgMapIndex.java

public void commitChanges(IndexOperation<T> operations) {

    if (operations.getNewKeyValues() != null) {
        for (IndexOperationItem opItem : operations.getNewKeyValues()) {
            IndexKeyValue indexKeyValue = new IndexKeyValue(opItem.getKey(), opItem.getValue());
            ConcurrentHashMap<Object, Boolean> curElements = getMap().get(indexKeyValue);

            if (curElements == null)
                curElements = new ConcurrentHashMap<Object, Boolean>();

            if (!opItem.getObject().getClass().equals(this.indexClass)
                    && !opItem.getObject().getClass().getSuperclass().equals(this.indexClass))
                throw new RuntimeException("Index was created for " + indexClass.getSimpleName());

            Cell cellElement = indexClass.cast(opItem.getObject());

            if (cellElement instanceof SteffiEdge) {
                SteffiEdge edge = (SteffiEdge) cellElement;

                curElements.put(new EdgeIndexEntry(edge.getSourceCellId(), edge.getId()), true);
            } else {
                curElements.put(cellElement.getId(), true);
            }/*from  ww  w.  j ava  2s .  c  o m*/

            getMap().put(indexKeyValue, curElements);
        }
    }

    if (operations.getRemovedKeyValues() != null) {
        for (IndexOperationItem opItem : operations.getRemovedKeyValues()) {
            ConcurrentHashMap<Object, Boolean> curValues = getMap()
                    .get(new IndexKeyValue(opItem.getKey(), opItem.getValue()));

            if (curValues != null) {

                Cell cellElement = indexClass.cast(opItem.getObject());

                if (cellElement instanceof SteffiVertex) {
                    curValues.remove(cellElement.getId());
                } else {
                    SteffiEdge edge = (SteffiEdge) cellElement;
                    curValues.remove(new EdgeIndexEntry(edge.getSourceCellId(), edge.getId()));
                }

            }
        }
    }

}

From source file:org.springframework.cloud.config.server.EncryptionController.java

public Environment decrypt(Environment environment) {
    Environment result = new Environment(environment.getName(), environment.getLabel());
    for (PropertySource source : environment.getPropertySources()) {
        ConcurrentHashMap<Object, Object> map = new ConcurrentHashMap<Object, Object>(source.getSource());
        for (Object key : map.keySet()) {
            String name = key.toString();
            String value = map.get(key).toString();
            if (value.startsWith("{cipher}")) {
                map.remove(key);
                if (encryptor == null) {
                    map.put(name, value);
                } else {
                    try {
                        value = value == null ? null : encryptor.decrypt(value.substring("{cipher}".length()));
                    } catch (Exception e) {
                        value = "<n/a>";
                        name = "invalid." + name;
                        logger.warn("Cannot decrypt key: " + key + " (" + e.getClass() + ": " + e.getMessage()
                                + ")");
                    }/*from   w w w  .  java  2s  .  c o  m*/
                    map.put(name, value);
                }
            }
        }
        result.add(new PropertySource(source.getName(), map));
    }
    return result;
}

From source file:com.gitpitch.services.OfflineService.java

private void releaseCountDownLatch(ConcurrentHashMap<String, CountDownLatch> latchMap, String latchKey) {

    CountDownLatch completedLatch = latchMap.remove(latchKey);

    if (completedLatch != null) {
        completedLatch.countDown();/* w  ww .j a  va 2s  .  com*/
    }

}