当前位置: 首页>>代码示例>>Java>>正文


Java ConcurrentMap.get方法代码示例

本文整理汇总了Java中java.util.concurrent.ConcurrentMap.get方法的典型用法代码示例。如果您正苦于以下问题:Java ConcurrentMap.get方法的具体用法?Java ConcurrentMap.get怎么用?Java ConcurrentMap.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.ConcurrentMap的用法示例。


在下文中一共展示了ConcurrentMap.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: propertyExists

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
public static boolean propertyExists(Object target, String propertyName) {
    Class<?> targetType = target.getClass();
    ConcurrentMap<String, Boolean> cached;
    synchronized (PROPERTY_CACHE) {
        cached = PROPERTY_CACHE.get(targetType);
        if (cached == null) {
            cached = new ConcurrentHashMap<String, Boolean>();
            PROPERTY_CACHE.put(targetType, cached);
        }
    }
    Boolean res = cached.get(propertyName);
    if (res != null) {
        return res;
    }
    Method getterMethod = findGetterMethod(target.getClass(), propertyName);
    if (getterMethod == null) {
        if (findField(targetType, propertyName) == null) {
            cached.putIfAbsent(propertyName, false);
            return false;
        }
    }
    cached.putIfAbsent(propertyName, true);
    return true;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:25,代码来源:JavaReflectionUtil.java

示例2: findMethodsByService

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
public List<String> findMethodsByService(String service) {
    List<String> ret = new ArrayList<String>();

    ConcurrentMap<String, Map<Long, URL>> providerUrls = getRegistryCache().get(Constants.PROVIDERS_CATEGORY);
    if(providerUrls == null || service == null || service.length() == 0) return ret;
    
    Map<Long, URL> providers = providerUrls.get(service);
    if(null == providers || providers.isEmpty()) return ret;
    
    Entry<Long, URL> p = providers.entrySet().iterator().next();
    String value = p.getValue().getParameter("methods");
    if (value == null || value.length() == 0) {
        return ret;
    }
    String[] methods = value.split(ParseUtils.METHOD_SPLIT);
    if (methods == null || methods.length == 0) {
        return ret;
    }
    
    for(String m : methods) {
        ret.add(m);
    }
    return ret;
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:25,代码来源:ProviderServiceImpl.java

示例3: findApplicationsByServiceName

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
public List<String> findApplicationsByServiceName(String service) {
    List<String> ret = new ArrayList<String>();
    ConcurrentMap<String, Map<Long, URL>> providerUrls = getRegistryCache().get(Constants.PROVIDERS_CATEGORY);
    if(null == providerUrls) return ret;
    
    Map<Long, URL> value = providerUrls.get(service);
    if(value == null){
    	return ret;
    }
    for(Map.Entry<Long, URL> e2 : value.entrySet()) {
        URL u = e2.getValue();
        String app = u.getParameter(Constants.APPLICATION_KEY);
        if(app != null) ret.add(app);
    }
    
    return ret;
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:18,代码来源:ProviderServiceImpl.java

示例4: testEvictionAtTailInsertAtTailWithClashingHashCodeKeys

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
public void testEvictionAtTailInsertAtTailWithClashingHashCodeKeys()
{
  ConcurrentMap<LameKey, Object> cache = createMapWithLameKey();
  _putThree(cache, AAA, ABB, ACC);
  cache.get(AAA);
  cache.get(ABB);
  cache.put(CCC, FOUR);
  assertOldestEvicted(cache, ACC);
  assertContains(cache, AAA, ABB, CCC);

  cache = createMapWithLameKey();
  _putThree(cache, AAA, BAA, BBB);
  cache.get(AAA);
  cache.get(BAA);
  cache.put(CCC, FOUR);
  assertOldestEvicted(cache, BBB);
  assertContains(cache, AAA, BAA, CCC);

  cache = createMapWithLameKey();
  _putThree(cache, AAA, ABB, BBB);
  cache.get(AAA);
  cache.get(ABB);
  cache.put(CCC, FOUR);
  assertOldestEvicted(cache, BBB);
  assertContains(cache, AAA, ABB, CCC);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:27,代码来源:LRUCopyOnWriteArrayMapTest.java

示例5: applicationAttemptFinished

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
@Override
public void applicationAttemptFinished(
    ApplicationAttemptFinishData appAttemptFinish) throws IOException {
  ConcurrentMap<ApplicationAttemptId, ApplicationAttemptHistoryData> subMap =
      getSubMap(appAttemptFinish.getApplicationAttemptId().getApplicationId());
  ApplicationAttemptHistoryData data =
      subMap.get(appAttemptFinish.getApplicationAttemptId());
  if (data == null) {
    throw new IOException("The finish information of application attempt "
        + appAttemptFinish.getApplicationAttemptId() + " is stored before"
        + " the start information.");
  }
  // Make the assumption that YarnApplicationAttemptState should not be null
  // if the finish information is already recorded
  if (data.getYarnApplicationAttemptState() != null) {
    throw new IOException("The finish information of application attempt "
        + appAttemptFinish.getApplicationAttemptId() + " is already stored.");
  }
  data.setTrackingURL(appAttemptFinish.getTrackingURL());
  data.setDiagnosticsInfo(appAttemptFinish.getDiagnosticsInfo());
  data
    .setFinalApplicationStatus(appAttemptFinish.getFinalApplicationStatus());
  data.setYarnApplicationAttemptState(appAttemptFinish
    .getYarnApplicationAttemptState());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:MemoryApplicationHistoryStore.java

示例6: testEvictionAtTailInsertAtHeadWithClashingHashCodeKeys

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
public void testEvictionAtTailInsertAtHeadWithClashingHashCodeKeys()
{
  ConcurrentMap<LameKey, Object> cache = createMapWithLameKey();
  _putThree(cache, CAA, CBB, CCC);
  cache.get(CAA);
  cache.get(CBB);
  cache.put(AAA, FOUR);
  assertOldestEvicted(cache, CCC);
  assertContains(cache, CAA, CBB, AAA);

  cache = createMapWithLameKey();
  _putThree(cache, CAA, DAA, DBB);
  cache.get(CAA);
  cache.get(DAA);
  cache.put(AAA, FOUR);
  assertOldestEvicted(cache, DBB);
  assertContains(cache, CAA, DAA, AAA);

  cache = createMapWithLameKey();
  _putThree(cache, CAA, CBB, DAA);
  cache.get(CAA);
  cache.get(CBB);
  cache.put(AAA, FOUR);
  assertOldestEvicted(cache, DAA);
  assertContains(cache, CAA, CBB, AAA);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:27,代码来源:LRUCopyOnWriteArrayMapTest.java

示例7: getLocaleSpecificStrategy

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
/**
 * Construct a Strategy that parses a Text field
 *
 * @param field            The Calendar field
 * @param definingCalendar The calendar to obtain the short and long values
 * @return a TextStrategy for the field and Locale
 */
private Strategy getLocaleSpecificStrategy(final int field, final Calendar definingCalendar) {
    final ConcurrentMap<Locale, Strategy> cache = getCache(field);
    Strategy strategy = cache.get(locale);
    if (strategy == null) {
        strategy = field == Calendar.ZONE_OFFSET
                ? new TimeZoneStrategy(locale)
                : new TextStrategy(field, definingCalendar, locale);
        final Strategy inCache = cache.putIfAbsent(locale, strategy);
        if (inCache != null) {
            return inCache;
        }
    }
    return strategy;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:22,代码来源:FastDateParser.java

示例8: findApplicationsByServiceName

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
public List<String> findApplicationsByServiceName(String service) {
    List<String> ret = new ArrayList<String>();
    ConcurrentMap<String, Map<Long, URL>> consumerUrls = getRegistryCache().get(Constants.CONSUMERS_CATEGORY);
    if(consumerUrls == null) return ret;
    
    Map<Long, URL> value = consumerUrls.get(service);
    if(value == null){
    	return ret;
    }
    for(Map.Entry<Long, URL> e2 : value.entrySet()) {
        URL u = e2.getValue();
        String app = u.getParameter(Constants.APPLICATION_KEY);
        if(app != null) ret.add(app);
    }
    
    return ret;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:18,代码来源:ConsumerServiceImpl.java

示例9: cleanEventProperty

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
/**
 * Delete properties in the input event that are not allow to accomplish grouping.
 * Method signature is suitable for RgxGrouper function
 *
 * @param input
 * @param input
 * @return
 */
private static String cleanEventProperty(String input,
                                         RegExp foundEvent, ConcurrentMap<RegExp, List<String>> props) {

    List<String> unicRgx = props.get(foundEvent);

    if (unicRgx == null)
        return input;

    for (String currRgx : unicRgx) {
        String regex = currRgx + ",?";
        input = input.replaceFirst(regex, "");
    }

    return input;
}
 
开发者ID:ripreal,项目名称:V8LogScanner,代码行数:24,代码来源:RgxOpManager.java

示例10: __getCachableServices

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
/**
 * Gets all the registered services of the supplied type. Once instantiated, the services are
 *  cached in the application scoped storage, and any further requests to this function will
 *  get the cached services. It is assumed that the name of the service file and the type of
 *  the service class is the same.
 * @param service The class type of the service
 * @return The list of registered service instances
 */
static <T> List<T> __getCachableServices(Class<T> service)
{
  List<T> services = Collections.emptyList();
  String serviceName = service.getName();
  ConcurrentMap<String, Object> concurrentAppMap =
    RequestContext.getCurrentInstance().getApplicationScopedConcurrentMap();
  Object serviceObject = concurrentAppMap.get(serviceName);

  if (serviceObject == null)
  {
    services = ClassLoaderUtils.getServices(service);
    Object oldValue = concurrentAppMap.putIfAbsent(serviceName, services);
    
    // if a different thread raced us and added one, use that
    if (oldValue != null)
    {
      services = (List<T>) oldValue;
    }
  }
  else
  {
    services = (List<T>) serviceObject;
  }
  
  return services;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:35,代码来源:ClassLoaderUtils.java

示例11: testRemoveValueFail

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
@Test
public void testRemoveValueFail() {
    ConcurrentMap<SimpleKey, SimpleValue> map = redisson.getMapCache("simple");
    map.put(new SimpleKey("1"), new SimpleValue("2"));

    boolean res = map.remove(new SimpleKey("2"), new SimpleValue("1"));
    Assert.assertFalse(res);

    boolean res1 = map.remove(new SimpleKey("1"), new SimpleValue("3"));
    Assert.assertFalse(res1);

    SimpleValue val1 = map.get(new SimpleKey("1"));
    Assert.assertEquals("2", val1.getValue());
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:15,代码来源:RedissonMapCacheTest.java

示例12: doUnsubscribe

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
protected void doUnsubscribe(URL url, NotifyListener listener) {
    ConcurrentMap<NotifyListener, ChildListener> listeners = zkListeners.get(url);
    if (listeners != null) {
        ChildListener zkListener = listeners.get(listener);
        if (zkListener != null) {
            zkClient.removeChildListener(toUrlPath(url), zkListener);
        }
    }
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:10,代码来源:ZookeeperRegistry.java

示例13: _getCompatibleEntry

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
/**
 * Look in the entry cache for a compatible entry.
 * A compatible entry is one with the same DerivationKey, which is essentially the
 * same StyleSheetNodes.
 */
private Entry _getCompatibleEntry(
  ConcurrentMap<Key, Future<Entry>> cache,
  Key                          key,
  DerivationKey                derivationKey,
  ConcurrentMap<Object, Entry> entryCache,
  boolean                      checkModified
  )
{
  Entry entry = entryCache.get(derivationKey);
  if ((entry != null) && !_validateEntry(entry, checkModified))
  {
    entryCache.remove(derivationKey, entry);
    entry = null;
  }

  if (entry != null)
  {
    // If we've find a matching entry, store it in the main Key-based cache.
    cache.putIfAbsent(key, new ResolvedFuture<Entry>(entry));
    
    // If the cache already contains an entry (ie. putIfAbsent returns a 
    // non-null value), this means that the Key-based cached and the 
    // DerivationKey-based cache will contain different Entry instances.
    // This is somewhat unexpected but not necessarily fatal, so we don't 
    // take any special action for this case.
  }

  return entry;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:35,代码来源:FileSystemStyleCache.java

示例14: computPullFromWhichFilterServer

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
private String computPullFromWhichFilterServer(final String topic, final String brokerAddr)
    throws MQClientException {
    ConcurrentMap<String, TopicRouteData> topicRouteTable = this.mQClientFactory.getTopicRouteTable();
    if (topicRouteTable != null) {
        TopicRouteData topicRouteData = topicRouteTable.get(topic);
        List<String> list = topicRouteData.getFilterServerTable().get(brokerAddr);

        if (list != null && !list.isEmpty()) {
            return list.get(randomNum() % list.size());
        }
    }

    throw new MQClientException("Find Filter Server Failed, Broker Addr: " + brokerAddr + " topic: "
        + topic, null);
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:16,代码来源:PullAPIWrapper.java

示例15: updatePortStatus

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
@Override
public DeviceEvent updatePortStatus(ProviderId providerId, DeviceId deviceId,
                                    PortDescription portDescription) {
    Device device = devices.get(deviceId);
    checkArgument(device != null, DEVICE_NOT_FOUND, deviceId);

    Map<ProviderId, DeviceDescriptions> descsMap = deviceDescs.get(deviceId);
    checkArgument(descsMap != null, DEVICE_NOT_FOUND, deviceId);

    synchronized (descsMap) {
        DeviceDescriptions descs = descsMap.get(providerId);
        // assuming all providers must give DeviceDescription first
        checkArgument(descs != null,
                      "Device description for Device ID %s from Provider %s was not found",
                      deviceId, providerId);

        ConcurrentMap<PortNumber, Port> ports = getPortMap(deviceId);
        final PortNumber number = portDescription.portNumber();
        final Port oldPort = ports.get(number);
        final Port newPort;

        // update description
        descs.putPortDesc(portDescription);
        newPort = composePort(device, number, descsMap);

        if (oldPort == null) {
            return createPort(device, newPort, ports);
        } else {
            return updatePort(device, oldPort, newPort, ports);
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:33,代码来源:SimpleDeviceStore.java


注:本文中的java.util.concurrent.ConcurrentMap.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。