List of usage examples for java.util.concurrent ConcurrentHashMap putIfAbsent
public V putIfAbsent(K key, V value)
From source file:com.opengamma.util.test.DbTool.java
/** * * @return db_name => version_number => (create_script, migrate_script) *//* w ww . j a v a 2s. co m*/ public Map<String, Map<Integer, Pair<File, File>>> getScriptDirs() { Map<String, ConcurrentHashMap<Integer, File>> createScripts = new ConcurrentHashMap<String, ConcurrentHashMap<Integer, File>>() { private static final long serialVersionUID = 1L; @Override public ConcurrentHashMap<Integer, File> get(Object key) { super.putIfAbsent((String) key, new ConcurrentHashMap<Integer, File>()); return super.get(key); } }; Map<String, ConcurrentHashMap<Integer, File>> migrateScripts = new ConcurrentHashMap<String, ConcurrentHashMap<Integer, File>>() { private static final long serialVersionUID = 1L; @Override public ConcurrentHashMap<Integer, File> get(Object key) { super.putIfAbsent((String) key, new ConcurrentHashMap<Integer, File>()); return super.get(key); } }; for (String scriptDir : _dbScriptDirs) { Map<File, Map<Integer, File>> scripts1 = getScripts( new File(scriptDir, DATABASE_CREATE_FOLDER + File.separatorChar + _dialect.getDatabaseName()), CREATE_SCRIPT_PATTERN); for (Map.Entry<File, Map<Integer, File>> dbFolder2versionedScripts : scripts1.entrySet()) { File dbFolder = dbFolder2versionedScripts.getKey(); createScripts.get(dbFolder.getName()); // creates empty slot for dbFolder.getName() Map<Integer, File> versionedScripts = dbFolder2versionedScripts.getValue(); for (Map.Entry<Integer, File> version2script : versionedScripts.entrySet()) { Integer version = version2script.getKey(); File script = version2script.getValue(); ConcurrentHashMap<Integer, File> createDbScripts = createScripts.get(dbFolder.getName()); File prev = createDbScripts.putIfAbsent(version, script); if (prev != null) { throw new OpenGammaRuntimeException( "Can't add " + script.getAbsolutePath() + " script. Version " + version + " already added by " + prev.getAbsolutePath() + " script."); } } } Map<File, Map<Integer, File>> scripts2 = getScripts( new File(scriptDir, DATABASE_MIGRATE_FOLDER + File.separatorChar + _dialect.getDatabaseName()), MIGRATE_SCRIPT_PATTERN); for (Map.Entry<File, Map<Integer, File>> dbFolder2versionedScripts : scripts2.entrySet()) { File dbFolder = dbFolder2versionedScripts.getKey(); migrateScripts.get(dbFolder.getName()); // creates empty slot for dbFolder.getName() Map<Integer, File> versionedScripts = dbFolder2versionedScripts.getValue(); for (Map.Entry<Integer, File> version2script : versionedScripts.entrySet()) { Integer version = version2script.getKey(); File script = version2script.getValue(); ConcurrentHashMap<Integer, File> migrateDbScripts = migrateScripts.get(dbFolder.getName()); File prev = migrateDbScripts.putIfAbsent(version, script); if (prev != null) { throw new OpenGammaRuntimeException( "Can't add " + script.getAbsolutePath() + " script. Version " + version + " already added by " + prev.getAbsolutePath() + " script."); } } } } Set<String> migrateDbDirs = migrateScripts.keySet(); Set<String> createDbDirs = createScripts.keySet(); Set<String> unmatchedCreateDbDirs = difference(migrateDbDirs, createDbDirs); if (unmatchedCreateDbDirs.size() > 0) { StringBuilder errorMessage = new StringBuilder(); for (String unmatchedCreateDbDir : unmatchedCreateDbDirs) { errorMessage.append("There is no corresponding create db directory for migrate one: " + unmatchedCreateDbDir + "\n"); } throw new OpenGammaRuntimeException(errorMessage.toString()); } Set<String> unmatchedMigrateDbDirs = difference(createDbDirs, migrateDbDirs); if (unmatchedMigrateDbDirs.size() > 0) { StringBuilder errorMessage = new StringBuilder(); for (String unmatchedMigrateDbDir : unmatchedMigrateDbDirs) { errorMessage.append("There is no corresponding migrate db directory for create one: " + unmatchedMigrateDbDir + "\n"); } throw new OpenGammaRuntimeException(errorMessage.toString()); } final Map<String, Map<Integer, Pair<File, File>>> scripts = new ConcurrentHashMap<String, Map<Integer, Pair<File, File>>>() { private static final long serialVersionUID = 1L; @Override public Map<Integer, Pair<File, File>> get(Object key) { super.putIfAbsent((String) key, new ConcurrentHashMap<Integer, Pair<File, File>>()); return super.get(key); } }; for (String dir : migrateDbDirs) { ConcurrentHashMap<Integer, File> versionedCreateScripts = createScripts.get(dir); ConcurrentHashMap<Integer, File> versionedMigrateScripts = migrateScripts.get(dir); Set<Integer> migrateVersions = versionedCreateScripts.keySet(); // Set<Integer> createVersions = versionedMigrateScripts.keySet(); // // Set<Integer> unmatchedCreateVersions = difference(migrateVersions, createVersions); // if (unmatchedCreateVersions.size() > 0) { // StringBuilder errorMessage = new StringBuilder(); // for (Integer unmatchedCreateVersion : unmatchedCreateVersions) { // errorMessage.append("There is no corresponding version of create script for the migrate one: " + DATABASE_CRAETE_SCRIPT_PREFIX + unmatchedCreateVersion + "\n"); // } // throw new OpenGammaRuntimeException(errorMessage.toString()); // } // // Set<Integer> unmatchedMigrateVersions = difference(createVersions, migrateVersions); // if (unmatchedMigrateVersions.size() > 0) { // StringBuilder errorMessage = new StringBuilder(); // for (Integer unmatchedMigrateVersion : unmatchedMigrateVersions) { // errorMessage.append("There is no corresponding version of migrate script for the create one: " + DATABASE_MIGRATE_SCRIPT_PREFIX + unmatchedMigrateVersion + "\n"); // } // throw new OpenGammaRuntimeException(errorMessage.toString()); // } for (Integer version : migrateVersions) { File createScript = versionedCreateScripts.get(version); File migrateScript = versionedMigrateScripts.get(version); scripts.get(dir).put(version, Pair.of(createScript, migrateScript)); } } if (scripts.isEmpty()) { throw new OpenGammaRuntimeException("No script directories found: " + _dbScriptDirs); } return scripts; }
From source file:org.wso2.carbon.event.output.adaptor.websocket.WebsocketEventAdaptor.java
@Override protected void publish(OutputEventAdaptorMessageConfiguration outputEventAdaptorMessageConfiguration, Object message, OutputEventAdaptorConfiguration outputEventAdaptorConfiguration, int tenantId) { String topic = outputEventAdaptorMessageConfiguration.getOutputMessageProperties() .get(WebsocketEventAdaptorConstants.ADAPTER_TOPIC); String socketServerUrl = outputEventAdaptorConfiguration.getOutputProperties() .get(WebsocketEventAdaptorConstants.ADAPTER_SERVER_URL); if (!socketServerUrl.startsWith("ws://")) { throw new OutputEventAdaptorEventProcessingException( "Provided websocket URL - " + socketServerUrl + " is invalid."); }/*from w w w.ja va 2 s. c o m*/ if (topic != null) { socketServerUrl = socketServerUrl + "/" + topic; } ConcurrentHashMap<String, Session> urlSessionMap = outputEventAdaptorSessionMap.get(tenantId); if (urlSessionMap == null) { urlSessionMap = new ConcurrentHashMap<String, Session>(); if (null != outputEventAdaptorSessionMap.putIfAbsent(tenantId, urlSessionMap)) { urlSessionMap = outputEventAdaptorSessionMap.get(tenantId); } } Session session = urlSessionMap.get(socketServerUrl); if (session == null) { //TODO: Handle reconnecting, in case server disconnects. Suggestion: Create a scheduler. ClientEndpointConfig cec = ClientEndpointConfig.Builder.create().build(); ClientManager client = ClientManager.createClient(); try { session = client.connectToServer(new WebsocketClient(), cec, new URI(socketServerUrl)); if (null != urlSessionMap.putIfAbsent(socketServerUrl, session)) { session.close(); session = urlSessionMap.get(socketServerUrl); } } catch (DeploymentException e) { throw new OutputEventAdaptorEventProcessingException(e); } catch (IOException e) { throw new OutputEventAdaptorEventProcessingException(e); } catch (URISyntaxException e) { throw new OutputEventAdaptorEventProcessingException(e); } } session.getAsyncRemote().sendText(message.toString()); }
From source file:com.kixeye.chassis.support.logging.FlumeLoggerLoader.java
@PostConstruct public void initialize() { multicaster.addApplicationListener(loggingListener); ConcurrentHashMap<String, String> flumeConfig = new ConcurrentHashMap<>(); List<String> sinks = new ArrayList<>(); for (String server : servers) { String sinkName = server.replace(":", "-").replace(".", "_"); String[] servers = server.split(":", 2); if (servers.length == 2) { flumeConfig.put(sinkName + ".type", "avro"); flumeConfig.put(sinkName + ".channels", "channel-" + name); flumeConfig.put(sinkName + ".hostname", servers[0]); flumeConfig.put(sinkName + ".port", servers[1]); } else {//from w ww. j av a2 s .c o m logger.error("Invalid server format [{}], should be [hostname:port]", server); } sinks.add(sinkName); } // force some properties flumeConfig.put("channel.type", "file"); flumeConfig.put("sinks", StringUtils.collectionToDelimitedString(sinks, " ")); flumeConfig.putIfAbsent("processor.type", serversUsage); flumeConfig.put("channel.checkpointDir", SystemPropertyUtils.resolvePlaceholders("${user.dir}/flume-data/checkpoint")); flumeConfig.put("channel.dataDirs", SystemPropertyUtils.resolvePlaceholders("${user.dir}/flume-data/data")); agent = new EmbeddedAgent(name); agent.configure(flumeConfig); agent.start(); appender = new FlumeLogAppender(agent, serviceName); installFlumeAppender(); }
From source file:org.wso2.carbon.event.input.adaptor.websocket.WebsocketEventAdaptorType.java
@Override public String subscribe(InputEventAdaptorMessageConfiguration inputEventAdaptorMessageConfiguration, InputEventAdaptorListener inputEventAdaptorListener, InputEventAdaptorConfiguration inputEventAdaptorConfiguration, AxisConfiguration axisConfiguration) { String subscriptionId = UUID.randomUUID().toString(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); String topic = inputEventAdaptorMessageConfiguration.getInputMessageProperties() .get(WebsocketEventAdaptorConstants.ADAPTOR_MESSAGE_TOPIC); String socketServerUrl = inputEventAdaptorConfiguration.getInputProperties() .get(WebsocketEventAdaptorConstants.ADAPTER_SERVER_URL); if (!socketServerUrl.startsWith("ws://")) { throw new InputEventAdaptorEventProcessingException( "Provided websocket URL " + socketServerUrl + " is invalid."); //TODO: Make this exception propagate to the UI. }//from w ww . j a va 2 s . c om if (topic != null) { socketServerUrl = socketServerUrl + "/" + topic; } else { topic = ""; //Using empty string to map the cases with no topic, because topic is optional } ConcurrentHashMap<String, ConcurrentHashMap<String, CopyOnWriteArrayList<ClientManagerWrapper>>> tenantSpecificAdaptorMap = inputEventAdaptorClientManagerMap .get(tenantId); if (tenantSpecificAdaptorMap == null) { tenantSpecificAdaptorMap = new ConcurrentHashMap<String, ConcurrentHashMap<String, CopyOnWriteArrayList<ClientManagerWrapper>>>(); if (null != inputEventAdaptorClientManagerMap.putIfAbsent(tenantId, tenantSpecificAdaptorMap)) { tenantSpecificAdaptorMap = inputEventAdaptorClientManagerMap.get(tenantId); } } ConcurrentHashMap<String, CopyOnWriteArrayList<ClientManagerWrapper>> adaptorSpecificTopicMap = tenantSpecificAdaptorMap .get(inputEventAdaptorConfiguration.getName()); if (adaptorSpecificTopicMap == null) { adaptorSpecificTopicMap = new ConcurrentHashMap<String, CopyOnWriteArrayList<ClientManagerWrapper>>(); if (null != tenantSpecificAdaptorMap.put(inputEventAdaptorConfiguration.getName(), adaptorSpecificTopicMap)) { adaptorSpecificTopicMap = tenantSpecificAdaptorMap.get(inputEventAdaptorConfiguration.getName()); } } CopyOnWriteArrayList<ClientManagerWrapper> topicSpecificClientManagers = adaptorSpecificTopicMap.get(topic); if (topicSpecificClientManagers == null) { topicSpecificClientManagers = new CopyOnWriteArrayList<ClientManagerWrapper>(); if (null != adaptorSpecificTopicMap.putIfAbsent(topic, topicSpecificClientManagers)) { topicSpecificClientManagers = adaptorSpecificTopicMap.get(topic); } } ClientEndpointConfig clientEndpointConfig = ClientEndpointConfig.Builder.create().build(); ClientManager client = ClientManager.createClient(); ClientManagerWrapper clientManagerWrapper = new ClientManagerWrapper(); clientManagerWrapper.setClientManager(client); clientManagerWrapper.setSubscriptionId(subscriptionId); try { client.connectToServer(new WebsocketClient(inputEventAdaptorListener), clientEndpointConfig, new URI(socketServerUrl)); //TODO: Handle reconnecting, in case server disconnects. Suggestion: Create a scheduler. topicSpecificClientManagers.add(clientManagerWrapper); } catch (DeploymentException e) { throw new InputEventAdaptorEventProcessingException(e); //TODO: These exceptions might get modified into new types, as these do not propagate to the UI. } catch (IOException e) { throw new InputEventAdaptorEventProcessingException(e); } catch (Throwable e) { throw new InputEventAdaptorEventProcessingException(e); } return subscriptionId; }
From source file:com.alibaba.napoli.gecko.service.impl.BaseRemotingController.java
public Object setAttributeIfAbsent(final String url, final String key, final Object value) { ConcurrentHashMap<String, Object> subAttr = this.attributes.get(url); if (subAttr == null) { subAttr = new ConcurrentHashMap<String, Object>(); final ConcurrentHashMap<String, Object> oldSubAttr = this.attributes.putIfAbsent(url, subAttr); if (oldSubAttr != null) { subAttr = oldSubAttr;/*from w w w . j ava 2s .co m*/ } } return subAttr.putIfAbsent(key, value); }
From source file:org.wso2.carbon.event.output.adaptor.wso2event.WSO2EventAdaptorType.java
/** * @param outputEventAdaptorMessageConfiguration * - topic name to publish messages * @param message - is and Object[]{Event, EventDefinition} * @param outputEventAdaptorConfiguration * * @param tenantId// w w w .j a va 2 s . c om */ public void publish(OutputEventAdaptorMessageConfiguration outputEventAdaptorMessageConfiguration, Object message, OutputEventAdaptorConfiguration outputEventAdaptorConfiguration, int tenantId) { ConcurrentHashMap<OutputEventAdaptorConfiguration, LoadBalancingDataPublisher> dataPublishers = dataPublisherMap .get(tenantId); if (dataPublishers == null) { dataPublishers = new ConcurrentHashMap<OutputEventAdaptorConfiguration, LoadBalancingDataPublisher>(); dataPublisherMap.putIfAbsent(tenantId, dataPublishers); dataPublishers = dataPublisherMap.get(tenantId); } LoadBalancingDataPublisher dataPublisher = dataPublishers.get(outputEventAdaptorConfiguration); if (dataPublisher == null) { synchronized (this) { dataPublisher = dataPublishers.get(outputEventAdaptorConfiguration); if (dataPublisher == null) { dataPublisher = createDataPublisher(outputEventAdaptorConfiguration); dataPublishers.putIfAbsent(outputEventAdaptorConfiguration, dataPublisher); } } } try { Event event = (Event) ((Object[]) message)[0]; StreamDefinition streamDefinition = (StreamDefinition) ((Object[]) message)[1]; if (!dataPublisher.isStreamDefinitionAdded(streamDefinition)) { dataPublisher.addStreamDefinition(streamDefinition); //Sending the first Event publishEvent(outputEventAdaptorConfiguration, dataPublisher, event, streamDefinition); } else { //Sending Events publishEvent(outputEventAdaptorConfiguration, dataPublisher, event, streamDefinition); } } catch (Exception ex) { throw new OutputEventAdaptorEventProcessingException( ex.getMessage() + " Error Occurred When Publishing Events", ex); } }
From source file:org.wso2.carbon.event.input.adaptor.websocket.local.WebsocketLocalEventAdaptorType.java
@Override public String subscribe(InputEventAdaptorMessageConfiguration inputEventAdaptorMessageConfiguration, InputEventAdaptorListener inputEventAdaptorListener, InputEventAdaptorConfiguration inputEventAdaptorConfiguration, AxisConfiguration axisConfiguration) { String subscriptionId = UUID.randomUUID().toString(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); String topic = inputEventAdaptorMessageConfiguration.getInputMessageProperties() .get(WebsocketLocalEventAdaptorConstants.ADAPTOR_MESSAGE_TOPIC); ConcurrentHashMap<String, ConcurrentHashMap<String, CopyOnWriteArrayList<WebsocketAdaptorListener>>> tenantSpecificListenerMap = inputEventAdaptorListenerMap .get(tenantId);//from w w w . j a v a 2 s . c o m if (tenantSpecificListenerMap == null) { tenantSpecificListenerMap = new ConcurrentHashMap<String, ConcurrentHashMap<String, CopyOnWriteArrayList<WebsocketAdaptorListener>>>(); if (null != inputEventAdaptorListenerMap.putIfAbsent(tenantId, tenantSpecificListenerMap)) { tenantSpecificListenerMap = inputEventAdaptorListenerMap.get(tenantId); } } ConcurrentHashMap<String, CopyOnWriteArrayList<WebsocketAdaptorListener>> adaptorSpecificListeners = tenantSpecificListenerMap .get(inputEventAdaptorConfiguration.getName()); if (adaptorSpecificListeners == null) { adaptorSpecificListeners = new ConcurrentHashMap<String, CopyOnWriteArrayList<WebsocketAdaptorListener>>(); if (null != tenantSpecificListenerMap.putIfAbsent(inputEventAdaptorConfiguration.getName(), adaptorSpecificListeners)) { adaptorSpecificListeners = tenantSpecificListenerMap.get(inputEventAdaptorConfiguration.getName()); } } CopyOnWriteArrayList<WebsocketAdaptorListener> topicSpecificListeners = adaptorSpecificListeners.get(topic); if (topicSpecificListeners == null) { topicSpecificListeners = new CopyOnWriteArrayList<WebsocketAdaptorListener>(); if (null != adaptorSpecificListeners.putIfAbsent(topic, topicSpecificListeners)) { topicSpecificListeners = adaptorSpecificListeners.get(topic); } } topicSpecificListeners .add(new WebsocketAdaptorListener(subscriptionId, inputEventAdaptorListener, tenantId)); return subscriptionId; }
From source file:uk.ac.ebi.fg.jobs.PubMedSimilarityJob.java
public void doExecute(JobExecutionContext jobExecutionContext) throws JobExecutionException, InterruptedException { JobDataMap dataMap = jobExecutionContext.getMergedJobDataMap(); Map<String, String> expToPubMedIdMap = (ConcurrentHashMap<String, String>) dataMap.get("expToPubMedIdMap"); Map<String, SortedSet<PubMedId>> pubMedIdRelationMap = (Map<String, SortedSet<PubMedId>>) dataMap .get("pubMedIdRelationMap"); ConcurrentHashMap<String, SortedSet<ExperimentId>> pubMedResults = (ConcurrentHashMap<String, SortedSet<ExperimentId>>) dataMap .get("pubMedResults"); Configuration properties = (Configuration) dataMap.get("properties"); final int maxPubMedSimilarityCount = properties.getInt("max_displayed_PubMed_similarities"); Map<String, SortedSet<String>> pubMedIdToExpAccessionMap = reverseMap(expToPubMedIdMap); expToPubMedIdMap.clear();/* ww w . j ava 2 s .co m*/ logger.info("PubMedSimilarityJob started"); for (Map.Entry<String, SortedSet<String>> pubMedIdToExpAccession : pubMedIdToExpAccessionMap.entrySet()) { SortedSet<ExperimentId> result = new TreeSet<ExperimentId>(); if (pubMedIdRelationMap.containsKey(pubMedIdToExpAccession.getKey())) { // false - failed to get similar PubMed ids for (PubMedId publication : pubMedIdRelationMap.get(pubMedIdToExpAccession.getKey())) { result.addAll(getExperiments(pubMedIdToExpAccessionMap, publication)); } for (String expAccession : pubMedIdToExpAccession.getValue()) { pubMedResults.putIfAbsent(expAccession, limitPubMedExperimentCount(result, maxPubMedSimilarityCount, expAccession)); } } Thread.currentThread().wait(1); } pubMedIdToExpAccessionMap.clear(); pubMedIdRelationMap.clear(); logger.info("PubMedSimilarityJob finished"); }
From source file:org.wso2.carbon.event.input.adaptor.mqtt.MQTTEventAdaptorType.java
private void createMQTTAdaptorListener( InputEventAdaptorMessageConfiguration inputEventAdaptorMessageConfiguration, InputEventAdaptorListener inputEventAdaptorListener, InputEventAdaptorConfiguration inputEventAdaptorConfiguration, AxisConfiguration axisConfiguration, String subscriptionId, int tenantId) { String topic = inputEventAdaptorMessageConfiguration.getInputMessageProperties() .get(MQTTEventAdaptorConstants.ADAPTOR_MESSAGE_TOPIC); Map<String, ConcurrentHashMap<String, ConcurrentHashMap<String, MQTTAdaptorListener>>> tenantSpecificListenerMap = inputEventAdaptorListenerMap .get(tenantId);//from w w w .ja v a2 s . co m if (tenantSpecificListenerMap == null) { tenantSpecificListenerMap = new ConcurrentHashMap<String, ConcurrentHashMap<String, ConcurrentHashMap<String, MQTTAdaptorListener>>>(); inputEventAdaptorListenerMap.put(tenantId, tenantSpecificListenerMap); } ConcurrentHashMap<String, ConcurrentHashMap<String, MQTTAdaptorListener>> adaptorSpecificListenerMap = tenantSpecificListenerMap .get(inputEventAdaptorConfiguration.getName()); if (adaptorSpecificListenerMap == null) { adaptorSpecificListenerMap = new ConcurrentHashMap<String, ConcurrentHashMap<String, MQTTAdaptorListener>>(); if (null != tenantSpecificListenerMap.put(inputEventAdaptorConfiguration.getName(), adaptorSpecificListenerMap)) { adaptorSpecificListenerMap = tenantSpecificListenerMap .get(inputEventAdaptorConfiguration.getName()); } } ConcurrentHashMap<String, MQTTAdaptorListener> topicSpecificListenMap = adaptorSpecificListenerMap .get(topic); if (topicSpecificListenMap == null) { topicSpecificListenMap = new ConcurrentHashMap<String, MQTTAdaptorListener>(); if (null != adaptorSpecificListenerMap.putIfAbsent(topic, topicSpecificListenMap)) { topicSpecificListenMap = adaptorSpecificListenerMap.get(topic); } } MQTTBrokerConnectionConfiguration mqttBrokerConnectionConfiguration = new MQTTBrokerConnectionConfiguration( inputEventAdaptorConfiguration.getInputProperties().get(MQTTEventAdaptorConstants.ADAPTOR_CONF_URL), inputEventAdaptorConfiguration.getInputProperties() .get(MQTTEventAdaptorConstants.ADAPTOR_CONF_USERNAME), inputEventAdaptorConfiguration.getInputProperties() .get(MQTTEventAdaptorConstants.ADAPTOR_CONF_PASSWORD), inputEventAdaptorConfiguration.getInputProperties() .get(MQTTEventAdaptorConstants.ADAPTOR_CONF_CLEAN_SESSION), inputEventAdaptorConfiguration.getInputProperties() .get(MQTTEventAdaptorConstants.ADAPTOR_CONF_KEEP_ALIVE)); MQTTAdaptorListener mqttAdaptorListener = new MQTTAdaptorListener(mqttBrokerConnectionConfiguration, inputEventAdaptorMessageConfiguration.getInputMessageProperties() .get(MQTTEventAdaptorConstants.ADAPTOR_MESSAGE_TOPIC), inputEventAdaptorMessageConfiguration.getInputMessageProperties().get( MQTTEventAdaptorConstants.ADAPTOR_MESSAGE_CLIENTID), inputEventAdaptorListener, tenantId); topicSpecificListenMap.put(subscriptionId, mqttAdaptorListener); mqttAdaptorListener.createConnection(); }
From source file:cn.leancloud.diamond.client.impl.DefaultDiamondSubscriber.java
private CacheData getCacheData(String dataId, String group) { CacheData cacheData = null;/* w w w .j a v a 2s . c o m*/ ConcurrentHashMap<String, CacheData> cacheDatas = this.cache.get(dataId); if (null != cacheDatas) { cacheData = cacheDatas.get(group); } if (null == cacheData) { cacheData = new CacheData(dataId, group); ConcurrentHashMap<String, CacheData> newCacheDatas = new ConcurrentHashMap<String, CacheData>(); ConcurrentHashMap<String, CacheData> oldCacheDatas = this.cache.putIfAbsent(dataId, newCacheDatas); if (null == oldCacheDatas) { oldCacheDatas = newCacheDatas; } if (null != oldCacheDatas.putIfAbsent(group, cacheData)) { cacheData = oldCacheDatas.get(group); } } return cacheData; }