Example usage for java.util.concurrent ConcurrentMap remove

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

Introduction

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

Prototype

V remove(Object key);

Source Link

Document

Removes the mapping for a key from this map if it is present (optional operation).

Usage

From source file:com.networknt.light.rule.access.AbstractAccessRule.java

protected void delAccess(Map<String, Object> data) throws Exception {
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {/*from   ww  w  .  j  a va2 s. c  o m*/
        graph.begin();
        Vertex access = graph.getVertexByKey("Access.ruleClass", data.get("ruleClass"));
        if (access != null) {
            graph.removeVertex(access);
        }
        graph.commit();
    } catch (Exception e) {
        logger.error("Exception:", e);
        graph.rollback();
        throw e;
    } finally {
        graph.shutdown();
    }
    Map<String, Object> accessMap = ServiceLocator.getInstance().getMemoryImage("accessMap");
    ConcurrentMap<Object, Object> cache = (ConcurrentMap<Object, Object>) accessMap.get("cache");
    if (cache != null) {
        cache.remove(data.get("ruleClass"));
    }
}

From source file:com.splout.db.hazelcast.DistributedRegistry.java

public synchronized void unregister() {
    String myself = localMember();
    log.info("Unregistering myself [" + myself + " -> " + nodeInfo + "] on registry [" + registryName + "]");
    ConcurrentMap<String, Object> members = hzInstance.getMap(registryName);
    members.remove(myself);
    amIRegistered.set(false);//from www .  j  a v  a 2 s  .c om
}

From source file:org.apache.nifi.web.security.otp.OtpService.java

/**
 * Gets the corresponding authentication for the specified one time use token. The specified token will be removed.
 *
 * @param cache                     The cache
 * @param token                     The one time use token
 * @return                          The authenticated identity
 */// ww  w.  j  av a  2  s  . c o  m
private String getAuthenticationFromToken(final ConcurrentMap<CacheKey, String> cache, final String token)
        throws OtpAuthenticationException {
    final String authenticatedUser = cache.remove(new CacheKey(token));
    if (authenticatedUser == null) {
        throw new OtpAuthenticationException("Unable to validate the access token.");
    }

    return authenticatedUser;
}

From source file:com.networknt.light.rule.validation.AbstractValidationRule.java

protected void delValidation(Map<String, Object> data) throws Exception {
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {//from www.  j a v  a 2  s  . co m
        graph.begin();
        Vertex validation = graph.getVertexByKey("Validation.ruleClass", data.get("ruleClass"));
        if (validation != null) {
            graph.removeVertex(validation);
        }
        graph.commit();
    } catch (Exception e) {
        logger.error("Exception:", e);
        graph.rollback();
        throw e;
    } finally {
        graph.shutdown();
    }
    // remove the cached list if in order to reload it
    Map<String, Object> ruleMap = ServiceLocator.getInstance().getMemoryImage("ruleMap");
    ConcurrentMap<Object, Object> cache = (ConcurrentMap<Object, Object>) ruleMap.get("cache");
    if (cache != null) {
        cache.remove(data.get("ruleClass"));
    }
}

From source file:com.networknt.light.rule.validation.AbstractValidationRule.java

protected void addValidation(Map<String, Object> data) throws Exception {
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {/*from w  w  w .  j  av a2 s. c o  m*/
        graph.begin();
        String createUserId = (String) data.remove("createUserId");
        OrientVertex validation = graph.addVertex("class:Validation", data);
        Vertex user = graph.getVertexByKey("User.userId", createUserId);
        user.addEdge("Create", validation);
        graph.commit();
    } catch (Exception e) {
        graph.rollback();
        logger.error("Exception:", e);
        throw e;
    } finally {
        graph.shutdown();
        ;
    }
    // remove the cached list if in order to reload it
    Map<String, Object> ruleMap = ServiceLocator.getInstance().getMemoryImage("ruleMap");
    ConcurrentMap<Object, Object> cache = (ConcurrentMap<Object, Object>) ruleMap.get("cache");
    if (cache != null) {
        cache.remove(data.get("ruleClass"));
    }
}

From source file:com.networknt.light.rule.validation.AbstractValidationRule.java

protected void updValidation(Map<String, Object> data) throws Exception {
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {/*from w w w .  ja v a2 s  .  c o m*/
        graph.begin();
        Vertex validation = graph.getVertexByKey("Validation.ruleClass", data.get("ruleClass"));
        if (validation != null) {
            validation.setProperty("schema", data.get("schema"));
            validation.setProperty("updateDate", data.get("updateDate"));
        }
        Vertex user = graph.getVertexByKey("User.userId", data.get("updateUserId"));
        user.addEdge("Update", validation);
        graph.commit();
    } catch (Exception e) {
        graph.rollback();
        logger.error("Exception:", e);
        throw e;
    } finally {
        graph.shutdown();
    }
    // remove the cached list if in order to reload it
    Map<String, Object> ruleMap = ServiceLocator.getInstance().getMemoryImage("ruleMap");
    ConcurrentMap<Object, Object> cache = (ConcurrentMap<Object, Object>) ruleMap.get("cache");
    if (cache != null) {
        cache.remove(data.get("ruleClass"));
    }
}

From source file:com.starit.diamond.client.impl.DefaultSubscriberListener.java

/**
 * DataIDManagerListeners// w w w. j av a 2s .  co m
 * 
 * @param dataId
 */
public void removeManagerListeners(String dataId, String group, String instanceId) {
    if (null == dataId || null == instanceId) {
        return;
    }
    String key = makeKey(dataId, group);
    ConcurrentMap<String, CopyOnWriteArrayList<ManagerListener>> map = allListeners.get(key);
    if (map != null) {
        map.remove(instanceId);
    }
}

From source file:com.sastix.cms.server.services.cache.hazelcast.HazelcastCacheService.java

@Override
public void removeCachedResource(RemoveCacheDTO removeCacheDTO) throws DataNotFound, CacheValidationException {
    LOG.info("HazelcastCacheService->removeCachedResource");
    nullValidationChecker(removeCacheDTO, RemoveCacheDTO.class);
    String cacheKey = removeCacheDTO.getCacheKey();
    String cacheRegion = removeCacheDTO.getCacheRegion();

    if (cacheKey == null) {
        throw new CacheValidationException("You cannot remove a cached a resource with a null cache key");
    }/*from ww  w. jav a  2s .  c  om*/

    if (!StringUtils.isEmpty(cacheRegion)) {
        ConcurrentMap<String, String> cMap = cm.getCache(cacheRegion);
        if (cMap.containsKey(cacheKey)) {
            cMap.remove(cacheKey);
        } else {
            throw new DataNotFound(
                    "Nothing to remove. There is no cached resource with the given key: " + cacheKey);
        }
    } else {
        if (this.cache.containsKey(cacheKey)) {
            this.cache.remove(cacheKey);
        } else {
            throw new DataNotFound(
                    "Nothing to remove. There is no cached resource with the given key: " + cacheKey);
        }
    }
}

From source file:com.networknt.light.rule.product.AbstractProductRule.java

protected void delProduct(String productRid) throws Exception {
    ODocument product = DbService.delODocumentByRid(productRid);
    // rebuild cache in memory.
    Map<String, Object> productMap = (Map<String, Object>) ServiceLocator.getInstance()
            .getMemoryImage("productMap");
    // update central cache
    ConcurrentMap<Object, Object> cache = (ConcurrentMap<Object, Object>) productMap.get("cache");
    if (cache != null) {
        cache.remove(productRid);
    }/*from   ww w  . j a v  a  2 s . com*/
}

From source file:codetoanalyze.java.checkers.ContainerWrapper.java

void accessToSychronizedMapsOk(String key, ConcurrentMap<String, String> concurrentMap,
        ConcurrentHashMap<String, String> concurrentHashMap) {

    concurrentMap.remove(key);
    concurrentHashMap.remove(key);//from ww w.j  av a2s  .com
}