List of usage examples for java.util.concurrent ConcurrentHashMap get
public V get(Object key)
From source file:org.wrml.runtime.rest.Resource.java
public URI getDefaultDocumentUri() { final UriTemplate uriTemplate = getUriTemplate(); final String[] parameterNames = uriTemplate.getParameterNames(); final Map<String, Object> parameterMap = new LinkedHashMap<>(); if (parameterNames != null && parameterNames.length > 0) { final Api api = getApiNavigator().getApi(); final Context context = api.getContext(); final SchemaLoader schemaLoader = context.getSchemaLoader(); final URI defaultSchemaUri = getDefaultSchemaUri(); final Prototype defaultPrototype = (defaultSchemaUri != null) ? schemaLoader.getPrototype(defaultSchemaUri) : null;/* ww w . j a va 2 s .c om*/ for (int i = 0; i < parameterNames.length; i++) { final String parameterName = parameterNames[i]; URI keyedSchemaUri = null; if (defaultPrototype != null) { final Set<String> allKeySlotNames = defaultPrototype.getAllKeySlotNames(); if (allKeySlotNames != null && allKeySlotNames.contains(parameterName)) { keyedSchemaUri = defaultSchemaUri; } } if (keyedSchemaUri == null) { final ConcurrentHashMap<URI, LinkTemplate> referenceTemplates = getReferenceTemplates(); if (referenceTemplates != null && !referenceTemplates.isEmpty()) { final Set<URI> referenceLinkRelationUris = getReferenceLinkRelationUris(Method.Get); if (referenceLinkRelationUris != null && !referenceLinkRelationUris.isEmpty()) { for (URI linkRelationUri : referenceLinkRelationUris) { final LinkTemplate referenceTemplate = referenceTemplates.get(linkRelationUri); final URI responseSchemaUri = referenceTemplate.getResponseSchemaUri(); final Prototype responseSchemaPrototype = schemaLoader .getPrototype(responseSchemaUri); if (responseSchemaPrototype != null) { final Set<String> allKeySlotNames = responseSchemaPrototype .getAllKeySlotNames(); if (allKeySlotNames != null && allKeySlotNames.contains(parameterName)) { keyedSchemaUri = responseSchemaUri; break; } } } } } } Object defaultValue = null; if (keyedSchemaUri != null) { final Prototype keyedPrototype = schemaLoader.getPrototype(keyedSchemaUri); final ProtoSlot keyProtoSlot = keyedPrototype.getProtoSlot(parameterName); if (keyProtoSlot instanceof PropertyProtoSlot) { final PropertyProtoSlot keyPropertyProtoSlot = (PropertyProtoSlot) keyProtoSlot; // TODO: Allow more fine grain control of the default parameter value defaultValue = keyPropertyProtoSlot.getDefaultValue(); if (defaultValue == null) { defaultValue = keyPropertyProtoSlot.getValueType().getDefaultValue(); } } } parameterMap.put(parameterName, defaultValue); } } return uriTemplate.evaluate(parameterMap, true); }
From source file:org.apache.oodt.cas.catalog.struct.impl.index.DataSourceIndex.java
/** * {@inheritDoc}//from ww w .j a v a 2s.c o m */ public List<TermBucket> getBuckets(TransactionId<?> transactionId) throws QueryServiceException { Connection conn = null; Statement stmt = null; ResultSet rs = null; try { ConcurrentHashMap<String, TermBucket> termBuckets = new ConcurrentHashMap<String, TermBucket>(); conn = this.dataSource.getConnection(); stmt = conn.createStatement(); rs = stmt.executeQuery( "SELECT bucket_name,term_name,term_value FROM transaction_terms WHERE transaction_id = '" + transactionId + "'"); while (rs.next()) { String bucketName = rs.getString("bucket_name"); String termName = rs.getString("term_name"); String termValue = rs.getString("term_value"); TermBucket bucket = termBuckets.get(bucketName); if (bucket == null) { bucket = new TermBucket(bucketName); } Term term = new Term(termName, Collections .singletonList((this.useUTF8 ? URLDecoder.decode(termValue, "UTF8") : termValue))); bucket.addTerm(term); termBuckets.put(bucketName, bucket); } return new Vector<TermBucket>(termBuckets.values()); } catch (Exception e) { throw new QueryServiceException( "Failed to get term buckets for transaction id '" + transactionId + "' : " + e.getMessage(), e); } finally { try { conn.close(); } catch (Exception ignored) { } try { stmt.close(); } catch (Exception ignored) { } try { rs.close(); } catch (Exception ignored) { } } }
From source file:org.wso2.carbon.event.input.adapter.core.internal.CarbonInputEventAdapterService.java
@Override public void create(InputEventAdapterConfiguration inputEventAdapterConfiguration, InputEventAdapterSubscription inputEventAdapterSubscription) throws InputEventAdapterException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); ConcurrentHashMap<String, InputAdapterRuntime> eventAdapters = tenantSpecificEventAdapters.get(tenantId); if (eventAdapters == null) { tenantSpecificEventAdapters.putIfAbsent(tenantId, new ConcurrentHashMap<String, InputAdapterRuntime>()); eventAdapters = tenantSpecificEventAdapters.get(tenantId); }/*from ww w .j av a 2s. c o m*/ InputEventAdapterFactory adapterFactory = eventAdapterFactoryMap .get(inputEventAdapterConfiguration.getType()); if (adapterFactory == null) { throw new InputEventAdapterException( "Input Event Adapter not created as no adapter factory is registered " + "with type " + inputEventAdapterConfiguration.getType()); } if (inputEventAdapterConfiguration.getName() == null) { throw new InputEventAdapterException("Input Event Adapter name cannot be null, for the adapter type " + inputEventAdapterConfiguration.getType()); } if (eventAdapters.get(inputEventAdapterConfiguration.getName()) != null) { throw new InputEventAdapterException( "Input Event Adapter not created as another adapter with same name '" + inputEventAdapterConfiguration.getName() + "' already exist for tenant " + tenantId); } Map<String, String> globalProperties = InputEventAdapterServiceValueHolder.getGlobalAdapterConfigs() .getAdapterConfig(inputEventAdapterConfiguration.getType()).getGlobalPropertiesAsMap(); InputEventAdapter inputEventAdapter = adapterFactory.createEventAdapter(inputEventAdapterConfiguration, globalProperties); InputAdapterRuntime inputAdapterRuntime = new InputAdapterRuntime(inputEventAdapter, inputEventAdapterConfiguration.getName(), inputEventAdapterSubscription); eventAdapters.put(inputEventAdapterConfiguration.getName(), inputAdapterRuntime); if (startTriggered) { inputAdapterRuntime.start(); } if (startPollingTriggered) { inputAdapterRuntime.startPolling(); } }
From source file:org.wso2.carbon.event.output.adapter.core.internal.CarbonOutputEventAdapterService.java
@Override public void create(OutputEventAdapterConfiguration outputEventAdapterConfiguration) throws OutputEventAdapterException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); ConcurrentHashMap<String, OutputAdapterRuntime> eventAdapters = tenantSpecificEventAdapters.get(tenantId); if (eventAdapters == null) { tenantSpecificEventAdapters.putIfAbsent(tenantId, new ConcurrentHashMap<String, OutputAdapterRuntime>()); eventAdapters = tenantSpecificEventAdapters.get(tenantId); }// w ww. ja v a2s.c o m OutputEventAdapterFactory adapterFactory = eventAdapterFactoryMap .get(outputEventAdapterConfiguration.getType()); if (adapterFactory == null) { throw new OutputEventAdapterException( "Output Event Adapter not created as no adapter factory is registered " + "with type " + outputEventAdapterConfiguration.getType()); } if (outputEventAdapterConfiguration.getName() == null) { throw new OutputEventAdapterException("Output Event Adapter name cannot by null, for the adapter type " + outputEventAdapterConfiguration.getType()); } if (eventAdapters.get(outputEventAdapterConfiguration.getName()) != null) { throw new OutputEventAdapterException( "Output Event Adapter not created as another adapter with same name '" + outputEventAdapterConfiguration.getName() + "' already exist for tenant " + tenantId); } //check if all the required properties are given here List<Property> staticPropertyList = adapterFactory.getStaticPropertyList(); if (staticPropertyList != null) { Map<String, String> staticPropertyMap = outputEventAdapterConfiguration.getStaticProperties(); for (Property property : staticPropertyList) { if (property.isRequired()) { if (staticPropertyMap == null) { throw new OutputEventAdapterException( "Output Event Adapter not created as the 'staticProperties' are null, " + "which means, the required property " + property.getPropertyName() + " is not being set, for the adapter type " + outputEventAdapterConfiguration.getType()); } if (staticPropertyMap.get(property.getPropertyName()) == null) { throw new OutputEventAdapterException( "Output Event Adapter not created as the required property: " + property.getPropertyName() + " is not set, for the adapter type " + outputEventAdapterConfiguration.getType()); } } } } Map<String, String> globalProperties = OutputEventAdapterServiceValueHolder.getGlobalAdapterConfigs() .getAdapterConfig(outputEventAdapterConfiguration.getType()).getGlobalPropertiesAsMap(); eventAdapters.put(outputEventAdapterConfiguration.getName(), new OutputAdapterRuntime( adapterFactory.createEventAdapter(outputEventAdapterConfiguration, globalProperties), outputEventAdapterConfiguration.getName())); }
From source file:cn.leancloud.diamond.client.impl.DefaultDiamondSubscriber.java
private CacheData getCacheData(String dataId, String group) { CacheData cacheData = null;//from w ww. 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; }
From source file:org.wso2.carbon.event.input.adaptor.wso2event.WSO2EventEventAdaptorType.java
public String subscribe(InputEventAdaptorMessageConfiguration inputEventAdaptorMessageConfiguration, InputEventAdaptorListener inputEventAdaptorListener, InputEventAdaptorConfiguration inputEventAdaptorConfiguration, AxisConfiguration axisConfiguration) { String subscriptionId = UUID.randomUUID().toString(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); EventAdaptorConf eventAdaptorConf = new EventAdaptorConf(inputEventAdaptorListener, tenantId, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); ConcurrentHashMap<InputEventAdaptorMessageConfiguration, ConcurrentHashMap<String, EventAdaptorConf>> tenantSpecificAdaptorListenerMap = inputEventAdaptorListenerMap .get(tenantId);//from w ww . j a v a 2s . c o m if (tenantSpecificAdaptorListenerMap == null) { tenantSpecificAdaptorListenerMap = new ConcurrentHashMap<InputEventAdaptorMessageConfiguration, ConcurrentHashMap<String, EventAdaptorConf>>(); inputEventAdaptorListenerMap.put(tenantId, tenantSpecificAdaptorListenerMap); } if (!tenantSpecificAdaptorListenerMap.keySet().contains(inputEventAdaptorMessageConfiguration)) { ConcurrentHashMap<String, EventAdaptorConf> map = new ConcurrentHashMap<String, WSO2EventEventAdaptorType.EventAdaptorConf>(); map.put(subscriptionId, eventAdaptorConf); tenantSpecificAdaptorListenerMap.put(inputEventAdaptorMessageConfiguration, map); } else { tenantSpecificAdaptorListenerMap.get(inputEventAdaptorMessageConfiguration).put(subscriptionId, eventAdaptorConf); ConcurrentHashMap<InputEventAdaptorMessageConfiguration, StreamDefinition> tenantSpecificInputStreamDefinitionMap = inputStreamDefinitionMap .get(tenantId); if (tenantSpecificInputStreamDefinitionMap != null) { StreamDefinition streamDefinition = tenantSpecificInputStreamDefinitionMap .get(inputEventAdaptorMessageConfiguration); if (streamDefinition != null) { inputEventAdaptorListener.addEventDefinitionCall(streamDefinition); } } } return subscriptionId; }
From source file:org.wso2.carbon.event.input.adaptor.jms.JMSEventAdaptorType.java
private void createJMSAdaptorListener( InputEventAdaptorMessageConfiguration inputEventAdaptorMessageConfiguration, InputEventAdaptorListener inputEventAdaptorListener, InputEventAdaptorConfiguration inputEventAdaptorConfiguration, AxisConfiguration axisConfiguration, String subscriptionId, int tenantId) { ConcurrentHashMap<String, ConcurrentHashMap<String, ConcurrentHashMap<String, SubscriptionDetails>>> adaptorDestinationSubscriptionsMap = tenantAdaptorDestinationSubscriptionsMap .get(tenantId);/*from w w w .j av a 2s.c o m*/ if (adaptorDestinationSubscriptionsMap == null) { adaptorDestinationSubscriptionsMap = new ConcurrentHashMap<String, ConcurrentHashMap<String, ConcurrentHashMap<String, SubscriptionDetails>>>(); if (null != tenantAdaptorDestinationSubscriptionsMap.putIfAbsent(tenantId, adaptorDestinationSubscriptionsMap)) { adaptorDestinationSubscriptionsMap = tenantAdaptorDestinationSubscriptionsMap.get(tenantId); } } ConcurrentHashMap<String, ConcurrentHashMap<String, SubscriptionDetails>> destinationSubscriptionsMap = adaptorDestinationSubscriptionsMap .get(inputEventAdaptorConfiguration.getName()); if (destinationSubscriptionsMap == null) { destinationSubscriptionsMap = new ConcurrentHashMap<String, ConcurrentHashMap<String, SubscriptionDetails>>(); if (null != adaptorDestinationSubscriptionsMap.putIfAbsent(inputEventAdaptorConfiguration.getName(), destinationSubscriptionsMap)) { destinationSubscriptionsMap = adaptorDestinationSubscriptionsMap .get(inputEventAdaptorConfiguration.getName()); } } String destination = inputEventAdaptorMessageConfiguration.getInputMessageProperties() .get(JMSEventAdaptorConstants.ADAPTOR_JMS_DESTINATION); ConcurrentHashMap<String, SubscriptionDetails> subscriptionsMap = destinationSubscriptionsMap .get(destination); if (subscriptionsMap == null) { subscriptionsMap = new ConcurrentHashMap<String, SubscriptionDetails>(); if (null != destinationSubscriptionsMap.putIfAbsent(destination, subscriptionsMap)) { subscriptionsMap = destinationSubscriptionsMap.get(destination); } } Map<String, String> adaptorProperties = new HashMap<String, String>(); if (inputEventAdaptorConfiguration.getInputProperties() .get(JMSEventAdaptorConstants.ADAPTOR_JMS_DURABLE_SUBSCRIBER_NAME) != null) { InternalInputEventAdaptorConfiguration internalInputEventAdaptorConfiguration = inputEventAdaptorConfiguration .getInputConfiguration(); internalInputEventAdaptorConfiguration .addEventAdaptorProperty(JMSEventAdaptorConstants.ADAPTOR_JMS_SUBSCRIPTION_DURABLE, "true"); inputEventAdaptorConfiguration.setInputConfiguration(internalInputEventAdaptorConfiguration); } else { InternalInputEventAdaptorConfiguration internalInputEventAdaptorConfiguration = inputEventAdaptorConfiguration .getInputConfiguration(); internalInputEventAdaptorConfiguration .addEventAdaptorProperty(JMSEventAdaptorConstants.ADAPTOR_JMS_SUBSCRIPTION_DURABLE, "false"); inputEventAdaptorConfiguration.setInputConfiguration(internalInputEventAdaptorConfiguration); } adaptorProperties.putAll(inputEventAdaptorConfiguration.getInputProperties()); JMSConnectionFactory jmsConnectionFactory = new JMSConnectionFactory( new Hashtable<String, String>(adaptorProperties), inputEventAdaptorConfiguration.getName()); Map<String, String> messageConfig = new HashMap<String, String>(); messageConfig.put(JMSConstants.PARAM_DESTINATION, destination); JMSTaskManager jmsTaskManager = JMSTaskManagerFactory .createTaskManagerForService( jmsConnectionFactory, inputEventAdaptorConfiguration.getName(), new NativeWorkerPool(4, 100, 1000, 1000, "JMS Threads", "JMSThreads" + UUID.randomUUID().toString()), messageConfig); jmsTaskManager.setJmsMessageListener(new JMSMessageListener(inputEventAdaptorListener, axisConfiguration)); JMSListener jmsListener = new JMSListener(inputEventAdaptorConfiguration.getName() + "#" + destination, jmsTaskManager); jmsListener.startListener(); SubscriptionDetails subscriptionDetails = new SubscriptionDetails(jmsConnectionFactory, jmsListener); subscriptionsMap.put(subscriptionId, subscriptionDetails); }
From source file:org.starnub.starnubserver.connections.player.session.PlayerSession.java
private boolean hasFullPermission(String basePermission, String subPermission, String fullPermission, boolean checkWildCards) { if (PERMISSIONS.containsKey("*") && checkWildCards) { return true; }/*from w w w . j a v a 2s .com*/ ConcurrentHashMap<String, ArrayList<String>> concurrentHashMap = PERMISSIONS.get(basePermission); if (concurrentHashMap == null) { return false; } if (concurrentHashMap.containsKey("*") && checkWildCards) { return true; } ArrayList<String> strings = concurrentHashMap.get(subPermission); if (strings == null) { return false; } if (checkWildCards) { return strings.contains("*") || strings.contains(fullPermission); } else { return false; } }
From source file:com.taobao.diamond.client.impl.DefaultDiamondSubscriber.java
private void checkDiamondServerConfigInfo() { Set<String> updateDataIdGroupPairs = checkUpdateDataIds(diamondConfigure.getReceiveWaitTime()); if (null == updateDataIdGroupPairs || updateDataIdGroupPairs.size() == 0) { log.debug("DataID"); return;//from w w w . ja v a2 s .c o m } // DataID for (String freshDataIdGroupPair : updateDataIdGroupPairs) { int middleIndex = freshDataIdGroupPair.indexOf(WORD_SEPARATOR); if (middleIndex == -1) continue; String freshDataId = freshDataIdGroupPair.substring(0, middleIndex); String freshGroup = freshDataIdGroupPair.substring(middleIndex + 1); ConcurrentHashMap<String, CacheData> cacheDatas = cache.get(freshDataId); if (null == cacheDatas) { continue; } CacheData cacheData = cacheDatas.get(freshGroup); if (null == cacheData) { continue; } receiveConfigInfo(cacheData); } }
From source file:cn.leancloud.diamond.client.impl.DefaultDiamondSubscriber.java
private void checkDiamondServerConfigInfo() { Set<String> updateDataIdGroupPairs = checkUpdateDataIds(diamondConfigure.getReceiveWaitTime()); if (null == updateDataIdGroupPairs || updateDataIdGroupPairs.size() == 0) { log.debug("DataID"); return;/* w ww.jav a 2 s . c o m*/ } // ???DataID?? for (String freshDataIdGroupPair : updateDataIdGroupPairs) { int middleIndex = freshDataIdGroupPair.indexOf(Constants.WORD_SEPARATOR); if (middleIndex == -1) continue; String freshDataId = freshDataIdGroupPair.substring(0, middleIndex); String freshGroup = freshDataIdGroupPair.substring(middleIndex + 1); ConcurrentHashMap<String, CacheData> cacheDatas = cache.get(freshDataId); if (null == cacheDatas) { continue; } CacheData cacheData = cacheDatas.get(freshGroup); if (null == cacheData) { continue; } receiveConfigInfo(cacheData); } }