List of usage examples for java.util.concurrent ConcurrentHashMap remove
public V remove(Object key)
From source file:org.apache.storm.cluster.StormClusterStateImpl.java
protected void issueMapCallback(ConcurrentHashMap<String, Runnable> callbackConcurrentHashMap, String key) { Runnable callback = callbackConcurrentHashMap.remove(key); if (callback != null) callback.run();/*from w w w .j a v a 2 s .c o m*/ }
From source file:org.wso2.carbon.event.input.adaptor.mqtt.MQTTEventAdaptorType.java
public void unsubscribe(InputEventAdaptorMessageConfiguration inputEventAdaptorMessageConfiguration, InputEventAdaptorConfiguration inputEventAdaptorConfiguration, AxisConfiguration axisConfiguration, String subscriptionId) {//from w w w .j a va 2s .co m String topic = inputEventAdaptorMessageConfiguration.getInputMessageProperties() .get(MQTTEventAdaptorConstants.ADAPTOR_MESSAGE_TOPIC); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); Map<String, ConcurrentHashMap<String, ConcurrentHashMap<String, MQTTAdaptorListener>>> adaptorDestinationSubscriptionsMap = inputEventAdaptorListenerMap .get(tenantId); if (adaptorDestinationSubscriptionsMap == null) { throw new InputEventAdaptorEventProcessingException("There is no subscription for " + topic + " for tenant " + PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true)); } ConcurrentHashMap<String, ConcurrentHashMap<String, MQTTAdaptorListener>> destinationSubscriptionsMap = adaptorDestinationSubscriptionsMap .get(inputEventAdaptorConfiguration.getName()); if (destinationSubscriptionsMap == null) { throw new InputEventAdaptorEventProcessingException("There is no subscription for " + topic + " for event adaptor " + inputEventAdaptorConfiguration.getName()); } ConcurrentHashMap<String, MQTTAdaptorListener> subscriptionsMap = destinationSubscriptionsMap.get(topic); if (subscriptionsMap == null) { throw new InputEventAdaptorEventProcessingException("There is no subscription for " + topic); } MQTTAdaptorListener mqttAdaptorListener = subscriptionsMap.get(subscriptionId); if (mqttAdaptorListener != null) { mqttAdaptorListener.stopListener(inputEventAdaptorConfiguration.getName()); subscriptionsMap.remove(subscriptionId); } }
From source file:com.alibaba.napoli.gecko.service.impl.BaseRemotingController.java
public Object removeAttribute(final String url, final String key) { final ConcurrentHashMap<String, Object> subAttr = this.attributes.get(url); if (subAttr == null) { return null; }/*from w w w . j a va 2s .co m*/ return subAttr.remove(key); }
From source file:ddf.catalog.source.opensearch.TestOpenSearchSource.java
private void verifyOpenSearchUrl(List<NameValuePair> pairs, NameValuePair... answers) { ConcurrentHashMap<String, String> nvpMap = createMapFor(pairs); for (NameValuePair answerPair : answers) { assertThat(nvpMap.get(answerPair.getName()), is(answerPair.getValue())); nvpMap.remove(answerPair.getName()); }/*from w w w .j av a 2 s . co m*/ assertThat(nvpMap.get("count"), is("20")); nvpMap.remove("count"); assertThat(nvpMap.get("mt"), is("0")); nvpMap.remove("mt"); assertThat(nvpMap.get("src"), is("local")); nvpMap.remove("src"); verifyAllEntriesBlank(nvpMap); }
From source file:org.wso2.carbon.event.output.adaptor.mqtt.MQTTEventAdaptorType.java
@Override public void removeConnectionInfo(OutputEventAdaptorMessageConfiguration outputEventAdaptorMessageConfiguration, OutputEventAdaptorConfiguration outputEventAdaptorConfiguration, int tenantId) { ConcurrentHashMap<String, ConcurrentHashMap<String, MQTTAdaptorPublisher>> clientIdSpecificEventSenderMap = publisherMap .get(outputEventAdaptorConfiguration.getName()); if (clientIdSpecificEventSenderMap != null) { String clientId = outputEventAdaptorMessageConfiguration.getOutputMessageProperties() .get(MQTTEventAdaptorConstants.ADAPTOR_MESSAGE_CLIENTID); ConcurrentHashMap<String, MQTTAdaptorPublisher> topicSpecificEventSenderMap = clientIdSpecificEventSenderMap .get(clientId);/* w w w . j a v a 2 s .c o m*/ if (topicSpecificEventSenderMap != null) { String topicName = outputEventAdaptorMessageConfiguration.getOutputMessageProperties() .get(MQTTEventAdaptorConstants.ADAPTOR_MESSAGE_TOPIC); MQTTAdaptorPublisher mqttAdaptorPublisher = topicSpecificEventSenderMap.get(topicName); if (mqttAdaptorPublisher != null) { try { mqttAdaptorPublisher.close(); } catch (OutputEventAdaptorEventProcessingException e) { throw new OutputEventAdaptorEventProcessingException(e); } } topicSpecificEventSenderMap.remove(topicName); } } }
From source file:org.wso2.carbon.event.input.adaptor.jms.JMSEventAdaptorType.java
public void unsubscribe(InputEventAdaptorMessageConfiguration inputEventMessageConfiguration, InputEventAdaptorConfiguration inputEventAdaptorConfiguration, AxisConfiguration axisConfiguration, String subscriptionId) {/*from w w w .j a v a 2s. c o m*/ String destination = inputEventMessageConfiguration.getInputMessageProperties() .get(JMSEventAdaptorConstants.ADAPTOR_JMS_DESTINATION); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); ConcurrentHashMap<String, ConcurrentHashMap<String, ConcurrentHashMap<String, SubscriptionDetails>>> adaptorDestinationSubscriptionsMap = tenantAdaptorDestinationSubscriptionsMap .get(tenantId); if (adaptorDestinationSubscriptionsMap == null) { throw new InputEventAdaptorEventProcessingException("There is no subscription for " + destination + " for tenant " + PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true)); } ConcurrentHashMap<String, ConcurrentHashMap<String, SubscriptionDetails>> destinationSubscriptionsMap = adaptorDestinationSubscriptionsMap .get(inputEventAdaptorConfiguration.getName()); if (destinationSubscriptionsMap == null) { throw new InputEventAdaptorEventProcessingException("There is no subscription for " + destination + " for event adaptor " + inputEventAdaptorConfiguration.getName()); } ConcurrentHashMap<String, SubscriptionDetails> subscriptionsMap = destinationSubscriptionsMap .get(destination); if (subscriptionsMap == null) { throw new InputEventAdaptorEventProcessingException("There is no subscription for " + destination); } SubscriptionDetails subscriptionDetails = subscriptionsMap.get(subscriptionId); if (subscriptionDetails == null) { throw new InputEventAdaptorEventProcessingException( "There is no subscription for " + destination + " for the subscriptionId:" + subscriptionId); } else { try { subscriptionDetails.close(); subscriptionsMap.remove(subscriptionId); } catch (JMSException e) { throw new InputEventAdaptorEventProcessingException("Can not unsubscribe from the destination " + destination + " with the event adaptor " + inputEventAdaptorConfiguration.getName(), e); } } }
From source file:com.taobao.diamond.client.impl.DefaultDiamondSubscriber.java
public synchronized void removeDataId(String dataId, String group) { if (null == group) { group = Constants.DEFAULT_GROUP; }//w ww . j av a 2 s . com ConcurrentHashMap<String, CacheData> cacheDatas = this.cache.get(dataId); if (null == cacheDatas) { return; } cacheDatas.remove(group); log.warn("DataID[" + dataId + "]Group: " + group); if (cacheDatas.size() == 0) { this.cache.remove(dataId); log.warn("DataID[" + dataId + "]"); } }
From source file:cn.leancloud.diamond.client.impl.DefaultDiamondSubscriber.java
public synchronized void removeDataId(String dataId, String group) { if (null == group) { group = Constants.DEFAULT_GROUP; }// w w w . j a v a 2s . c om ConcurrentHashMap<String, CacheData> cacheDatas = this.cache.get(dataId); if (null == cacheDatas) { return; } cacheDatas.remove(group); log.warn("DataID[" + dataId + "]Group: " + group); if (cacheDatas.size() == 0) { this.cache.remove(dataId); log.warn("DataID[" + dataId + "]"); } }
From source file:cc.osint.graphd.server.GraphServerHandler.java
public String executeRequest(Channel responseChannel, String clientId, ConcurrentHashMap<String, String> clientState, String request) throws Exception { StringBuffer rsb = new StringBuffer(); String cmd;//from w w w. j av a 2 s . co m String[] args; if (request.indexOf(GraphServerProtocol.SPACE) != -1) { cmd = request.substring(0, request.indexOf(GraphServerProtocol.SPACE)).trim().toLowerCase(); args = request.substring(request.indexOf(GraphServerProtocol.SPACE)).trim() .split(GraphServerProtocol.SPACE); } else { cmd = request.trim().toLowerCase(); args = new String[0]; } // USE GRAPH: use <graphName> if (cmd.equals(GraphServerProtocol.CMD_USE)) { if (null == nameGraphMap.get(args[0])) { rsb.append(GraphServerProtocol.R_ERR); rsb.append(" DB_NOT_EXIST"); } else { if (null != clientState.get(ST_DB)) clientState.remove(ST_DB); clientState.put(ST_DB, args[0]); rsb.append(GraphServerProtocol.R_OK); } // CREATE GRAPH: create <graphName> } else if (cmd.equals(GraphServerProtocol.CMD_CREATE)) { if (null != nameGraphMap.get(args[0])) { rsb.append(GraphServerProtocol.R_ERR); rsb.append(" DB_ALREADY_EXISTS"); } else { Graph newGraph = new Graph(args[0]); nameGraphMap.put(args[0], newGraph); WeakReference<Graph> graphRef = new WeakReference<Graph>(newGraph); GraphCommandExecutor graphCommandExecutor = new GraphCommandExecutor(args[0], graphRef); graphCommandExecutorService.execute(graphCommandExecutor); graphCommandExecutorMap.put(args[0], graphCommandExecutor); rsb.append(GraphServerProtocol.R_OK); } // DROP GRAPH: drop <graphName> } else if (cmd.equals(GraphServerProtocol.CMD_DROP)) { if (null == nameGraphMap.get(args[0])) { rsb.append(GraphServerProtocol.R_ERR); rsb.append(" DB_NOT_EXIST"); } else { nameGraphMap.remove(args[0]); graphCommandExecutorMap.remove(args[0]); // TODO: DROP <KEY> // TODO: KILL graphCommandExecutor (via poisonPill message) rsb.append(GraphServerProtocol.R_OK); } // NAME THIS CONNECTION: namecon <name> } else if (cmd.equals(GraphServerProtocol.CMD_NAMECON)) { clientState.put(ST_NAMECON, args[0] + "-" + clientId); rsb.append(clientState.get(ST_NAMECON)); rsb.append(GraphServerProtocol.NL); rsb.append(GraphServerProtocol.R_OK); // DUMP CLIENT STATE: clstate } else if (cmd.equals(GraphServerProtocol.CMD_CLSTATE)) { JSONObject result = new JSONObject(clientState); rsb.append(result.toString()); rsb.append(GraphServerProtocol.NL); rsb.append(GraphServerProtocol.R_OK); // SERVER STATUS: sstat } else if (cmd.equals(GraphServerProtocol.CMD_SSTAT)) { JSONObject result = new JSONObject(); JSONObject names = new JSONObject(); names.put("TYPE_FIELD", Graph.TYPE_FIELD); names.put("KEY_FIELD", Graph.KEY_FIELD); names.put("WEIGHT_FIELD", Graph.WEIGHT_FIELD); names.put("EDGE_SOURCE_FIELD", Graph.EDGE_SOURCE_FIELD); names.put("EDGE_TARGET_FIELD", Graph.EDGE_TARGET_FIELD); names.put("RELATION_FIELD", Graph.RELATION_FIELD); names.put("VERTEX_TYPE", Graph.VERTEX_TYPE); names.put("EDGE_TYPE", Graph.EDGE_TYPE); result.put("names", names); rsb.append(result.toString()); rsb.append(GraphServerProtocol.NL); rsb.append(GraphServerProtocol.R_OK); // LIST NAMED GRAPHS } else if (cmd.equals(GraphServerProtocol.CMD_LISTG)) { for (String name : nameGraphMap.keySet()) { rsb.append(name); rsb.append(GraphServerProtocol.NL); } rsb.append(GraphServerProtocol.R_OK); // GRAPH STATUS: gstat <name> } else if (cmd.equals(GraphServerProtocol.CMD_GSTAT)) { Graph gr0 = nameGraphMap.get(args[0]); if (null == gr0) { rsb.append(GraphServerProtocol.R_NOT_EXIST); } else { JSONObject result = new JSONObject(); result.put("vertex_count", gr0.numVertices()); result.put("edge_count", gr0.numEdges()); rsb.append(result.toString()); rsb.append(GraphServerProtocol.NL); rsb.append(GraphServerProtocol.R_OK); } } else { // // graph-specific operations // WeakReference<InboundChannelProcess> inboundChannelProcessRef = inboundChannelMap.get(clientId); // // async override handler // if (cmd.startsWith("&")) { cmd = cmd.substring(1); request = request.substring(1); responseChannel.write(graphCommandExecutorMap.get(clientState.get(GraphServerHandler.ST_DB)) .execute(responseChannel, clientId, clientState, inboundChannelProcessRef.get(), request, cmd, args) + GraphServerProtocol.NL); } else { // // graph-specific, queue-driven ordered operations // GraphCommand graphCommand = new GraphCommand(); graphCommand.responseChannel = responseChannel; graphCommand.clientId = clientId; graphCommand.clientState = clientState; graphCommand.inboundChannelProcess = inboundChannelProcessRef.get(); graphCommand.request = request; graphCommand.cmd = cmd; graphCommand.args = args; graphCommand.poisonPill = false; graphCommandExecutorMap.get(clientState.get(GraphServerHandler.ST_DB)).queue(graphCommand); } // a null return value indicates it's been queued for execution // by the appropriate GraphCommandExecutor return null; } // unknown request if (rsb.toString().equals("")) { log.info("GraphServerProtocol.R_UNK: " + cmd); rsb.append(GraphServerProtocol.R_UNK); rsb.append(GraphServerProtocol.SPACE); rsb.append(cmd); } rsb.append(GraphServerProtocol.NL); return rsb.toString(); }
From source file:com.web.server.EJBDeployer.java
@Override public void fileDeleted(FileChangeEvent arg0) throws Exception { FileObject baseFile = arg0.getFile(); if (baseFile.getName().getURI().endsWith(".jar")) { System.out.println(jarEJBMap.get(baseFile.getName().getURI())); EJBContext ejbContext = jarEJBMap.get(baseFile.getName().getURI()); if (ejbContext != null) { HashMap<String, Class> bindings = ejbContext.getRemoteBindings(); Set<String> remoteBindings = bindings.keySet(); Iterator<String> remoteBinding = remoteBindings.iterator(); while (remoteBinding.hasNext()) { String binding = (String) remoteBinding.next(); registry.unbind(binding); System.out.println("unregistering the class" + bindings.get(binding)); }// w w w.j ava2 s .c o m jarEJBMap.remove(baseFile.getName().getURI()); } ConcurrentHashMap<String, MDBContext> mdbContexts = jarMDBMap.get(baseFile.getName().getURI()); MDBContext mdbContext; if (mdbContexts != null) { Iterator<String> mdbnames = mdbContexts.keySet().iterator(); while (mdbnames.hasNext()) { String mdbname = mdbnames.next(); mdbContext = mdbContexts.get(mdbname); if (mdbContext.getConsumer() != null) { mdbContext.getConsumer().setMessageListener(null); mdbContext.getConsumer().close(); } if (mdbContext.getSession() != null) mdbContext.getSession().close(); if (mdbContext.getConnection() != null) mdbContext.getConnection().close(); mdbContexts.remove(mdbname); } jarMDBMap.remove(baseFile.getName().getURI()); } } System.out.println(baseFile.getName().getURI() + " UnDeployed"); }