List of usage examples for java.util.concurrent ConcurrentMap remove
V remove(Object key);
From source file:com.networknt.light.rule.form.AbstractFormRule.java
protected String updForm(Map<String, Object> data) throws Exception { String json = null;// ww w. java 2 s . c o m String formId = (String) data.get("formId"); OrientGraph graph = ServiceLocator.getInstance().getGraph(); try { graph.begin(); OrientVertex form = (OrientVertex) graph.getVertexByKey("Form.formId", formId); if (form != null) { form.setProperty("action", data.get("action")); form.setProperty("schema", data.get("schema")); form.setProperty("form", data.get("form")); form.setProperty("modelData", data.get("modelData")); form.setProperty("updateDate", data.get("updateDate")); Vertex updateUser = graph.getVertexByKey("User.userId", data.get("updateUserId")); updateUser.addEdge("Update", form); // According to action in the list, populate validation schema. List<Map<String, Object>> actions = form.getProperty("action"); for (Map<String, Object> action : actions) { String ruleClass = Util.getCommandRuleId(action); Vertex validation = graph.getVertexByKey("Validation.ruleClass", ruleClass); if (validation != null) { validation.setProperty("schema", data.get("schema")); } } } graph.commit(); json = form.getRecord().toJSON(); } catch (Exception e) { graph.rollback(); logger.error("Exception:", e); } finally { graph.shutdown(); } Map<String, Object> formMap = ServiceLocator.getInstance().getMemoryImage("formMap"); ConcurrentMap<Object, Object> cache = (ConcurrentMap<Object, Object>) formMap.get("cache"); if (cache != null) { cache.remove(formId); } return json; }
From source file:com.networknt.light.rule.transform.AbstractTransformRule.java
protected void updTransformRequest(Map<String, Object> data) throws Exception { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try {/*w ww .j ava 2 s .c om*/ graph.begin(); OIndex<?> reqRuleSequenceIdx = graph.getRawGraph().getMetadata().getIndexManager() .getIndex("ReqRuleSequenceIdx"); OCompositeKey key = new OCompositeKey(data.get("ruleClass"), data.get("sequence")); OIdentifiable oid = (OIdentifiable) reqRuleSequenceIdx.get(key); if (oid != null) { ODocument transform = (ODocument) oid.getRecord(); transform.field("transformRule", data.get("transformRule")); // transformData is a json string, convert it to map. Object transformData = data.get("transformData"); if (transformData != null) { Map<String, Object> map = mapper.readValue((String) transformData, new TypeReference<HashMap<String, Object>>() { }); transform.field("transformData", map); } transform.field("updateDate", data.get("updateDate")); transform.field("updateUserId", data.get("updateUserId")); transform.save(); 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.transform.AbstractTransformRule.java
protected void updTransformResponse(Map<String, Object> data) throws Exception { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try {//from w ww . j av a 2s . co m graph.begin(); OIndex<?> resRuleSequenceIdx = graph.getRawGraph().getMetadata().getIndexManager() .getIndex("ResRuleSequenceIdx"); OCompositeKey key = new OCompositeKey(data.get("ruleClass"), data.get("sequence")); OIdentifiable oid = (OIdentifiable) resRuleSequenceIdx.get(key); if (oid != null) { ODocument transform = (ODocument) oid.getRecord(); transform.field("transformRule", data.get("transformRule")); // transformData is a json string, convert it to map. Object transformData = data.get("transformData"); if (transformData != null) { Map<String, Object> map = mapper.readValue((String) transformData, new TypeReference<HashMap<String, Object>>() { }); transform.field("transformData", map); } transform.field("updateDate", data.get("updateDate")); transform.field("updateUserId", data.get("updateUserId")); transform.save(); 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.form.AbstractFormRule.java
protected String impForm(Map<String, Object> data) throws Exception { String json = null;//from ww w . j a va 2 s .com String formId = (String) data.get("formId"); OrientGraph graph = ServiceLocator.getInstance().getGraph(); try { graph.begin(); OrientVertex form = (OrientVertex) graph.getVertexByKey("Form.formId", formId); if (form != null) { List<Map<String, Object>> actions = form.getProperty("action"); for (Map<String, Object> action : actions) { String ruleClass = Util.getCommandRuleId(action); Vertex validation = graph.getVertexByKey("Validation.ruleClass", ruleClass); if (validation != null) { graph.removeVertex(validation); } } graph.removeVertex(form); } Vertex createUser = graph.getVertexByKey("User.userId", data.remove("createUserId")); form = graph.addVertex("class:Form", data); createUser.addEdge("Create", form); // According to action in the list, populate validation schema. List<Map<String, Object>> actions = form.getProperty("action"); for (Map<String, Object> action : actions) { String ruleClass = Util.getCommandRuleId(action); graph.addVertex("class:Validation", "ruleClass", ruleClass, "schema", data.get("schema")); } graph.commit(); json = form.getRecord().toJSON(); } catch (Exception e) { graph.rollback(); logger.error("Exception:", e); throw e; } finally { graph.shutdown(); } Map<String, Object> formMap = ServiceLocator.getInstance().getMemoryImage("formMap"); ConcurrentMap<Object, Object> cache = (ConcurrentMap<Object, Object>) formMap.get("cache"); if (cache != null) { cache.remove(formId); } return json; }
From source file:org.onosproject.store.trivial.impl.SimpleGroupStore.java
@Override public void removeExtraneousGroupEntry(Group group) { ConcurrentMap<GroupId, Group> extraneousIdTable = getExtraneousGroupIdTable(group.deviceId()); extraneousIdTable.remove(group.id()); }
From source file:org.onosproject.store.trivial.impl.SimpleGroupStore.java
/** * Removes the group entry from store./*from w w w .ja va2s .c o m*/ * * @param group group entry */ @Override public void removeGroupEntry(Group group) { StoredGroupEntry existing = (groupEntriesById.get(group.deviceId()) != null) ? groupEntriesById.get(group.deviceId()).get(group.id()) : null; if (existing != null) { ConcurrentMap<GroupKey, StoredGroupEntry> keyTable = getGroupKeyTable(existing.deviceId()); ConcurrentMap<GroupId, StoredGroupEntry> idTable = getGroupIdTable(existing.deviceId()); idTable.remove(existing.id()); keyTable.remove(existing.appCookie()); notifyDelegate(new GroupEvent(Type.GROUP_REMOVED, existing)); } }
From source file:org.onosproject.store.trivial.impl.SimpleGroupStore.java
@Override public void groupOperationFailed(DeviceId deviceId, GroupOperation operation) { StoredGroupEntry existing = (groupEntriesById.get(deviceId) != null) ? groupEntriesById.get(deviceId).get(operation.groupId()) : null;//from w ww. j av a 2 s .co m if (existing == null) { log.warn("No group entry with ID {} found ", operation.groupId()); return; } switch (operation.opType()) { case ADD: notifyDelegate(new GroupEvent(Type.GROUP_ADD_FAILED, existing)); break; case MODIFY: notifyDelegate(new GroupEvent(Type.GROUP_UPDATE_FAILED, existing)); break; case DELETE: notifyDelegate(new GroupEvent(Type.GROUP_REMOVE_FAILED, existing)); break; default: log.warn("Unknown group operation type {}", operation.opType()); } ConcurrentMap<GroupKey, StoredGroupEntry> keyTable = getGroupKeyTable(existing.deviceId()); ConcurrentMap<GroupId, StoredGroupEntry> idTable = getGroupIdTable(existing.deviceId()); idTable.remove(existing.id()); keyTable.remove(existing.appCookie()); }
From source file:com.alibaba.dubbo.governance.sync.RegistryServerSync.java
public void notify(List<URL> urls) { if (urls == null || urls.isEmpty()) { return;//from w w w . ja v a 2 s .c o m } // Map<category, Map<servicename, Map<Long, URL>>> final Map<String, Map<String, Map<Long, URL>>> categories = new HashMap<String, Map<String, Map<Long, URL>>>(); for (URL url : urls) { String category = url.getParameter(Constants.CATEGORY_KEY, Constants.PROVIDERS_CATEGORY); if (Constants.EMPTY_PROTOCOL.equalsIgnoreCase(url.getProtocol())) { // ?empty??groupversion* ConcurrentMap<String, Map<Long, URL>> services = registryCache.get(category); if (services != null) { String group = url.getParameter(Constants.GROUP_KEY); String version = url.getParameter(Constants.VERSION_KEY); // ?empty??groupversion* if (!Constants.ANY_VALUE.equals(group) && !Constants.ANY_VALUE.equals(version)) { services.remove(url.getServiceKey()); } else { for (Map.Entry<String, Map<Long, URL>> serviceEntry : services.entrySet()) { String service = serviceEntry.getKey(); if (Tool.getInterface(service).equals(url.getServiceInterface()) && (Constants.ANY_VALUE.equals(group) || StringUtils.isEquals(group, Tool.getGroup(service))) && (Constants.ANY_VALUE.equals(version) || StringUtils.isEquals(version, Tool.getVersion(service)))) { services.remove(service); } } } } } else { Map<String, Map<Long, URL>> services = categories.get(category); if (services == null) { services = new HashMap<String, Map<Long, URL>>(); categories.put(category, services); } String service = url.getServiceKey(); Map<Long, URL> ids = services.get(service); if (ids == null) { ids = new HashMap<Long, URL>(); services.put(service, ids); } ids.put(ID.incrementAndGet(), url); } } for (Map.Entry<String, Map<String, Map<Long, URL>>> categoryEntry : categories.entrySet()) { String category = categoryEntry.getKey(); ConcurrentMap<String, Map<Long, URL>> services = registryCache.get(category); if (services == null) { services = new ConcurrentHashMap<String, Map<Long, URL>>(); registryCache.put(category, services); } services.putAll(categoryEntry.getValue()); } }
From source file:com.networknt.light.rule.catalog.AbstractCatalogRule.java
public boolean addProduct(Object... objects) throws Exception { Map<String, Object> inputMap = (Map<String, Object>) objects[0]; Map<String, Object> data = (Map<String, Object>) inputMap.get("data"); String parentId = (String) data.get("parentId"); String host = (String) data.get("host"); String error = null;// w w w . ja v a 2 s. c o m Map<String, Object> payload = (Map<String, Object>) inputMap.get("payload"); OrientGraph graph = ServiceLocator.getInstance().getGraph(); try { OrientVertex parent = getBranchByHostId(graph, branchType, host, parentId); if (parent == null) { error = "Id " + parentId + " doesn't exist on host " + host; inputMap.put("responseCode", 400); } else { Map<String, Object> user = (Map<String, Object>) payload.get("user"); Map eventMap = getEventMap(inputMap); Map<String, Object> eventData = (Map<String, Object>) eventMap.get("data"); inputMap.put("eventMap", eventMap); eventData.putAll((Map<String, Object>) inputMap.get("data")); eventData.put("productId", HashUtil.generateUUID()); eventData.put("createDate", new java.util.Date()); eventData.put("createUserId", user.get("userId")); } } catch (Exception e) { logger.error("Exception:", e); throw e; } finally { graph.shutdown(); } if (error != null) { inputMap.put("result", error); return false; } else { // update the branch tree as the number of products has changed. Map<String, Object> branchMap = ServiceLocator.getInstance().getMemoryImage("branchMap"); ConcurrentMap<Object, Object> cache = (ConcurrentMap<Object, Object>) branchMap.get("treeCache"); if (cache != null) { cache.remove(host + branchType); } return true; } }
From source file:com.networknt.light.rule.AbstractBfnRule.java
public boolean addPost(String bfnType, Object... objects) throws Exception { Map<String, Object> inputMap = (Map<String, Object>) objects[0]; Map<String, Object> data = (Map<String, Object>) inputMap.get("data"); String parentId = (String) data.get("parentId"); String host = (String) data.get("host"); String error = null;//from w ww . java2 s. co m Map<String, Object> payload = (Map<String, Object>) inputMap.get("payload"); OrientGraph graph = ServiceLocator.getInstance().getGraph(); try { OrientVertex parent = getBranchByHostId(graph, bfnType, host, parentId); if (parent == null) { error = "Id " + parentId + " doesn't exist on host " + host; inputMap.put("responseCode", 400); } else { Map<String, Object> user = (Map<String, Object>) payload.get("user"); Map eventMap = getEventMap(inputMap); Map<String, Object> eventData = (Map<String, Object>) eventMap.get("data"); inputMap.put("eventMap", eventMap); eventData.putAll((Map<String, Object>) inputMap.get("data")); eventData.put("postId", HashUtil.generateUUID()); eventData.put("createDate", new java.util.Date()); eventData.put("createUserId", user.get("userId")); } } catch (Exception e) { logger.error("Exception:", e); throw e; } finally { graph.shutdown(); } if (error != null) { inputMap.put("result", error); return false; } else { // update the bfn tree as the number of posts has changed. Map<String, Object> bfnMap = ServiceLocator.getInstance().getMemoryImage("bfnMap"); ConcurrentMap<Object, Object> cache = (ConcurrentMap<Object, Object>) bfnMap.get("treeCache"); if (cache != null) { cache.remove(host + bfnType); } return true; } }