Java 类java.util.concurrent.ConcurrentMap 实例源码

项目:q-mail    文件:Storage.java   
void doInTransaction(Runnable dbWork) {
    ConcurrentMap<String, String> newStorage = new ConcurrentHashMap<String, String>();
    newStorage.putAll(storage);
    workingStorage.set(newStorage);

    SQLiteDatabase mDb = openDB();
    workingDB.set(mDb);

    List<String> changedKeys = new ArrayList<String>();
    workingChangedKeys.set(changedKeys);

    mDb.beginTransaction();
    try {
        dbWork.run();
        mDb.setTransactionSuccessful();
        storage = newStorage;
    } finally {
        workingDB.remove();
        workingStorage.remove();
        workingChangedKeys.remove();
        mDb.endTransaction();
        mDb.close();
    }
}
项目:powsybl-core    文件:MapDbAppStorage.java   
private <P extends AbstractPoint, C extends ArrayChunk<P, C>, T extends TimeSeries<P, T>>
    List<T> getTimeSeries(String nodeId, Set<String> timeSeriesNames, int version,
                          ConcurrentMap<TimeSeriesChunkKey, C> map, BiFunction<TimeSeriesMetadata, List<C>, T> constr) {
    UUID nodeUuid = checkNodeId(nodeId);
    Objects.requireNonNull(timeSeriesNames);
    TimeSeriesIndex.checkVersion(version);
    Objects.requireNonNull(map);
    Objects.requireNonNull(constr);
    List<T> timeSeriesList = new ArrayList<>();
    for (String timeSeriesName : timeSeriesNames) {
        TimeSeriesMetadata metadata = timeSeriesMetadataMap.get(new NamedLink(nodeUuid, timeSeriesName));
        if (metadata == null) {
            throw createTimeSeriesNotFoundAtNode(timeSeriesName, nodeUuid);
        }
        List<C> chunks = getChunks(nodeUuid, version, timeSeriesName, metadata, map);
        if (!chunks.isEmpty()) {
            timeSeriesList.add(constr.apply(metadata, chunks));
        }
    }
    return timeSeriesList;
}
项目:dubbo2    文件:ConsumerServiceImpl.java   
public List<String> findServicesByApplication(String application) {
    List<String> ret = new ArrayList<String>();
    ConcurrentMap<String, Map<Long, URL>> consumerUrls = getRegistryCache().get(Constants.CONSUMERS_CATEGORY);
    if(consumerUrls == null || application == null || application.length() == 0) return ret;

    for(Map.Entry<String, Map<Long, URL>> e1 : consumerUrls.entrySet()) {
        Map<Long, URL> value = e1.getValue();
        for(Map.Entry<Long, URL> e2 : value.entrySet()) {
            URL u = e2.getValue();
            if(application.equals(u.getParameter(Constants.APPLICATION_KEY))) {
                ret.add(e1.getKey());
                break;
            }
        }
    }

    return ret;
}
项目:dubbocloud    文件:ConsumerServiceImpl.java   
public List<String> findServicesByApplication(String application) {
    List<String> ret = new ArrayList<String>();
    ConcurrentMap<String, Map<Long, URL>> consumerUrls = getRegistryCache().get(Constants.CONSUMERS_CATEGORY);
    if(consumerUrls == null || application == null || application.length() == 0) return ret;

    for(Map.Entry<String, Map<Long, URL>> e1 : consumerUrls.entrySet()) {
        Map<Long, URL> value = e1.getValue();
        for(Map.Entry<Long, URL> e2 : value.entrySet()) {
            URL u = e2.getValue();
            if(application.equals(u.getParameter(Constants.APPLICATION_KEY))) {
                ret.add(e1.getKey());
                break;
            }
        }
    }

    return ret;
}
项目:vertx-zero    文件:Dual.java   
private static ConcurrentMap<Object, JsonObject> mapZip(
        final JsonArray sources,
        final String field
) {
    final ConcurrentMap<Object, JsonObject> resultMap =
            new ConcurrentHashMap<>();
    Observable.fromIterable(sources)
            .map(item -> (JsonObject) item)
            .subscribe(item -> {
                if (item.containsKey(field)) {
                    final Object value = item.getValue(field);
                    if (null != value) {
                        resultMap.put(value, item);
                    }
                }
            });
    return resultMap;
}
项目:googles-monorepo-demo    文件:ConcurrentHashMultisetTest.java   
public void testSerializationWithMapMaker_preservesIdentityKeyEquivalence() {
  ConcurrentMap<String, AtomicInteger> map =
      new MapMaker().keyEquivalence(Equivalence.identity()).makeMap();

  ConcurrentHashMultiset<String> multiset = ConcurrentHashMultiset.create(map);
  multiset = reserializeAndAssert(multiset);

  String s1 = new String("a");
  String s2 = new String("a");
  assertEquals(s1, s2); // Stating the obvious.
  assertTrue(s1 != s2); // Stating the obvious.

  multiset.add(s1);
  assertTrue(multiset.contains(s1));
  assertFalse(multiset.contains(s2));
  assertEquals(1, multiset.count(s1));
  assertEquals(0, multiset.count(s2));
}
项目:diorite-configs-java8    文件:YamlCollectionCreator.java   
static void putAllCollections(Map<Class<?>, IntFunction<?>> map, Map<Class<?>, Function<?, ?>> unmodMap)
{
    safePut(map, ArrayList.class, ArrayList::new);
    safePut(map, HashSet.class, LinkedHashSet::new);
    safePut(map, Properties.class, x -> new Properties());
    safePut(map, Hashtable.class, Hashtable::new);

    safePut(map, Collection.class, ArrayList::new);
    safePut(map, Set.class, LinkedHashSet::new);
    safePut(map, List.class, ArrayList::new);
    safePut(map, SortedSet.class, x -> new TreeSet<>());
    safePut(map, Queue.class, x -> new ConcurrentLinkedQueue<>());
    safePut(map, Deque.class, x -> new ConcurrentLinkedDeque<>());
    safePut(map, BlockingQueue.class, x -> new LinkedBlockingQueue<>());
    safePut(map, BlockingDeque.class, x -> new LinkedBlockingDeque<>());


    safePut(map, HashMap.class, LinkedHashMap::new);
    safePut(map, LinkedHashMap.class, LinkedHashMap::new);
    safePut(map, ConcurrentHashMap.class, ConcurrentHashMap::new);

    safePut(map, Map.class, LinkedHashMap::new);
    safePut(map, ConcurrentMap.class, x -> new ConcurrentSkipListMap<>());
    safePut(map, ConcurrentNavigableMap.class, x -> new ConcurrentSkipListMap<>());
    safePut(map, SortedMap.class, i -> new TreeMap<>());
}
项目:myfaces-trinidad    文件:FileSystemStyleCache.java   
private Entry _getEntry(
  StyleContext context,
  StyleSheetDocument document,
  ConcurrentMap<Key, Future<Entry>> cache,
  Key key,
  boolean checkModified
  )
{
  Future<Entry> f = cache.get(key);
  Entry entry = _getEntryFromFuture(context, document, cache, key, f);
  if ((entry != null) && !_validateEntry(entry, checkModified))
  {
    // atomically remove the key from the cache if it currently points to the entry
    cache.remove(key, f);
    entry = null;
  }

  return entry;
}
项目:dubbo2    文件:ProviderServiceImpl.java   
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;
}
项目:verify-hub    文件:SamlEngineModule.java   
@Provides
private AuthnRequestToIdaRequestFromRelyingPartyTransformer getAuthnRequestAuthnRequestFromRelyingPartyTransformer(
        @Named("authnRequestKeyStore") SigningKeyStore signingKeyStore,
        IdaKeyStore decryptionKeyStore,
        SamlConfiguration samlConfiguration,
        ConcurrentMap<AuthnRequestIdKey, DateTime> duplicateIds,
        SamlDuplicateRequestValidationConfiguration duplicateRequestValidationConfiguration,
        SamlAuthnRequestValidityDurationConfiguration authnRequestValidityDurationConfiguration
) {
    return hubTransformersFactory.getAuthnRequestToAuthnRequestFromTransactionTransformer(
            samlConfiguration.getExpectedDestinationHost(),
            signingKeyStore,
            decryptionKeyStore,
            duplicateIds,
            duplicateRequestValidationConfiguration,
            authnRequestValidityDurationConfiguration
    );
}
项目:vertx-zero    文件:ZeroApiWorker.java   
private ConcurrentMap<Flag, Set<String>> calculateServices(
        final ConcurrentMap<String, Record> services) {
    // Read new services.
    final Set<String> populated = new HashSet<>();
    Observable.fromIterable(services.keySet())
            .subscribe(populated::add);

    // Existed = Yes, Populated = No
    final Set<String> deleted = new HashSet<>(REGISTRITIONS.keySet());
    deleted.removeAll(populated);

    // Existed = Yes, Populated = Yes
    final Set<String> updated = new HashSet<>(REGISTRITIONS.keySet());
    updated.retainAll(populated);

    // Existed = No, Populated = Yes
    final Set<String> added = new HashSet<>(populated);
    added.removeAll(REGISTRITIONS.keySet());

    // Mapping data
    final ConcurrentMap<Flag, Set<String>> result = new ConcurrentHashMap<>();
    result.put(Flag.DELETE, deleted);
    result.put(Flag.NEW, added);
    result.put(Flag.UPDATE, updated);
    return result;
}
项目:github-test    文件:ProviderServiceImpl.java   
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;
}
项目:myfaces-trinidad    文件:ConcurrentMapTestCase.java   
public void testReplace()
{
  ConcurrentMap<String, Object> cache = createMap();
  _putTwo(cache);
  Object val = cache.replace(C_STR, ONE);
  assertNull(val);
  assertEquals("Replace operation did not work as expected.", 2, cache.size());
  assertEquals(ONE, cache.get(A_STR));
  assertEquals(TWO, cache.get(B_STR));

  val = cache.replace(A_STR, "aaaString");
  assertEquals(ONE, val);
  assertEquals("Replace operation did not work as expected.", 2, cache.size());
  assertEquals("aaaString", cache.get(A_STR));

  boolean bool = cache.replace(B_STR, "bb", "newValue");
  assertFalse(bool);
  assertEquals("Replace operation did not work as expected.", 2, cache.size());
  assertEquals(TWO, cache.get(B_STR));

  bool = cache.replace(B_STR, TWO, "newValue");
  assertTrue(bool);
  assertEquals("Replace operation did not work as expected.", 2, cache.size());
  assertEquals("newValue", cache.get(B_STR));
}
项目:JRediClients    文件:RedissonConcurrentMapTest.java   
@Test
public void testSingleReplace_SingleInstance() throws InterruptedException {
    final String name = "testSingleReplace_SingleInstance";

    ConcurrentMap<String, String> map = BaseTest.createInstance().getMap(name);
    map.put("1", "0");

    testSingleInstanceConcurrency(100, r -> {
        ConcurrentMap<String, String> map1 = r.getMap(name);
        map1.replace("1", "3");
    });

    ConcurrentMap<String, String> testMap = BaseTest.createInstance().getMap(name);
    Assert.assertEquals("3", testMap.get("1"));

    assertMapSize(1, name);
}
项目:JRediClients    文件:RedissonConcurrentMapTest.java   
@Test
public void testSinglePutIfAbsent_SingleInstance() throws InterruptedException {
    final String name = "testSinglePutIfAbsent_SingleInstance";

    ConcurrentMap<String, String> map = BaseTest.createInstance().getMap(name);
    map.putIfAbsent("1", "0");
    testSingleInstanceConcurrency(100, r -> {
        ConcurrentMap<String, String> map1 = r.getMap(name);
        map1.putIfAbsent("1", "1");
    });

    ConcurrentMap<String, String> testMap = BaseTest.createInstance().getMap(name);
    Assert.assertEquals("0", testMap.get("1"));

    assertMapSize(1, name);
}
项目:myfaces-trinidad    文件:SkinStyleProvider.java   
private static ConcurrentMap<ProviderKey, StyleProvider> _getProviders()
{
  ConcurrentMap<String, Object> appMap = 
    RequestContext.getCurrentInstance().getApplicationScopedConcurrentMap();

  ConcurrentMap<ProviderKey, StyleProvider> styleProviders =
    (ConcurrentMap<ProviderKey, StyleProvider>)appMap.get(_SKIN_PROVIDERS_KEY);

  if (styleProviders == null)
  {
    styleProviders = _createProvidersCache();

    ConcurrentMap<ProviderKey, StyleProvider> oldStyleProviders =
      (ConcurrentMap<ProviderKey, StyleProvider>)appMap.putIfAbsent(_SKIN_PROVIDERS_KEY, styleProviders);

    if (oldStyleProviders != null)
      styleProviders = oldStyleProviders;
  }

  return styleProviders;
}
项目:github-test    文件:ConsumerServiceImpl.java   
public List<String> findServicesByApplication(String application) {
    List<String> ret = new ArrayList<String>();
    ConcurrentMap<String, Map<Long, URL>> consumerUrls = getRegistryCache().get(Constants.CONSUMERS_CATEGORY);
    if (consumerUrls == null || application == null || application.length() == 0) return ret;

    for (Map.Entry<String, Map<Long, URL>> e1 : consumerUrls.entrySet()) {
        Map<Long, URL> value = e1.getValue();
        for (Map.Entry<Long, URL> e2 : value.entrySet()) {
            URL u = e2.getValue();
            if (application.equals(u.getParameter(Constants.APPLICATION_KEY))) {
                ret.add(e1.getKey());
                break;
            }
        }
    }

    return ret;
}
项目:dubbox-hystrix    文件:ProviderServiceImpl.java   
public List<String> findServicesByAddress(String address) {
    List<String> ret = new ArrayList<String>();

    ConcurrentMap<String, Map<Long, URL>> providerUrls = getRegistryCache().get(Constants.PROVIDERS_CATEGORY);
    if(providerUrls == null || address == null || address.length() == 0) return ret;

    for(Map.Entry<String, Map<Long, URL>> e1 : providerUrls.entrySet()) {
        Map<Long, URL> value = e1.getValue();
        for(Map.Entry<Long, URL> e2 : value.entrySet()) {
            URL u = e2.getValue();
            if(address.equals(u.getAddress())) {
                ret.add(e1.getKey());
                break;
            }
        }
    }

    return ret;
}
项目:dubbox-hystrix    文件:ProviderServiceImpl.java   
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;
}
项目:myfaces-trinidad    文件:SessionChangeManager.java   
/**
 * Apply the attribute changes for this component
 * @param context
 * @param component
 */
protected void applySimpleComponentChanges(FacesContext context, UIComponent component)
{
  // Simple component changes always use logical scoped ids because they are consistent across
  // all phases including tag execution
  String scopedId = ComponentUtils.getLogicalScopedIdForComponent(component, context.getViewRoot());

  ConcurrentMap<String, AttributeComponentChange> attributeCmponentChanges = _attrChanges.get(scopedId);

  if (attributeCmponentChanges != null)
  {
    for (ComponentChange change : attributeCmponentChanges.values())
    {
      change.changeComponent(component);
    }
  }
}
项目:V8LogScanner    文件:RgxOpManager.java   
public static RegExp anyMatch(String input, ConcurrentMap<RegExp, Pattern> eventPatterns) {

        RegExp foundEvent = null;

        Matcher matcher;
        Set<RegExp> keys = eventPatterns.keySet();
        for (RegExp event : keys) {
            Pattern pattern = eventPatterns.get(event);
            matcher = pattern.matcher(input);
            if (matcher.find()) {
                foundEvent = event;
                break;
            }
        }
        return foundEvent;
    }
项目:EatDubbo    文件:ConsumerServiceImpl.java   
public List<String> findApplications() {
    List<String> ret = new ArrayList<String>();
    ConcurrentMap<String, Map<Long, URL>> consumerUrls = getRegistryCache().get(Constants.CONSUMERS_CATEGORY);
    if(consumerUrls == null) return ret;

    for(Map.Entry<String, Map<Long, URL>> e1 : consumerUrls.entrySet()) {
        Map<Long, URL> value = e1.getValue();
        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;
}
项目:EatDubbo    文件:ConsumerServiceImpl.java   
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;
}
项目:ditb    文件:RegionCoprocessorHost.java   
/**
 * Constructor
 * @param impl the coprocessor instance
 * @param priority chaining priority
 */
public RegionEnvironment(final Coprocessor impl, final int priority,
    final int seq, final Configuration conf, final Region region,
    final RegionServerServices services, final ConcurrentMap<String, Object> sharedData) {
  super(impl, priority, seq, conf);
  this.region = region;
  this.rsServices = services;
  this.sharedData = sharedData;
  // Pick which version of the WAL related events we'll call.
  // This way we avoid calling the new version on older RegionObservers so
  // we can maintain binary compatibility.
  // See notes in javadoc for RegionObserver
  useLegacyPre = useLegacyMethod(impl.getClass(), "preWALRestore", ObserverContext.class,
      HRegionInfo.class, WALKey.class, WALEdit.class);
  useLegacyPost = useLegacyMethod(impl.getClass(), "postWALRestore", ObserverContext.class,
      HRegionInfo.class, WALKey.class, WALEdit.class);
}
项目:EatDubbo    文件:ProviderServiceImpl.java   
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;
}
项目:github-test    文件:ConsumerServiceImpl.java   
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;
}
项目:V8LogScanner    文件:HeapOp.java   
private ConcurrentMap<String, List<String>> mapLogs(ArrayList<String> sourceCol, String filename) {

        ConcurrentMap<String, List<String>> mapResults = null;

        if (groupType == GroupTypes.BY_PROPS) {
            mapResults = sourceCol
                    .parallelStream()
                    .unordered()
                    .filter(n -> RgxOpManager.anyMatch(n, eventPatterns, integerFilters, integerCompTypes))
                    .collect(Collectors.groupingByConcurrent(input -> {
                                return RgxOpManager.getEventProperty(input, eventPatterns, cleanPropsRgx, groupPropsRgx);
                            }
                    ));
        } else if (groupType == GroupTypes.BY_FILE_NAMES) {
            mapResults = sourceCol
                    .parallelStream()
                    .unordered()
                    .filter(n -> RgxOpManager.anyMatch(n, eventPatterns, integerFilters, integerCompTypes))
                    .collect(Collectors.groupingByConcurrent(n -> filename));
        }

        return mapResults;
    }
项目:rocketmq-rocketmq-all-4.1.0-incubating    文件:ConsumerOffsetManager.java   
public Set<String> whichGroupByTopic(final String topic) {
    Set<String> groups = new HashSet<String>();

    Iterator<Entry<String, ConcurrentMap<Integer, Long>>> it = this.offsetTable.entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, ConcurrentMap<Integer, Long>> next = it.next();
        String topicAtGroup = next.getKey();
        String[] arrays = topicAtGroup.split(TOPIC_GROUP_SEPARATOR);
        if (arrays.length == 2) {
            if (topic.equals(arrays[0])) {
                groups.add(arrays[1]);
            }
        }
    }

    return groups;
}
项目:googles-monorepo-demo    文件:CacheTesting.java   
static void checkEmpty(ConcurrentMap<?, ?> map) {
  checkEmpty(map.keySet());
  checkEmpty(map.values());
  checkEmpty(map.entrySet());
  assertEquals(ImmutableMap.of(), map);
  assertEquals(ImmutableMap.of().hashCode(), map.hashCode());
  assertEquals(ImmutableMap.of().toString(), map.toString());

  if (map instanceof LocalCache) {
    LocalCache<?, ?> cchm = (LocalCache<?, ?>) map;

    checkValidState(cchm);
    assertTrue(cchm.isEmpty());
    assertEquals(0, cchm.size());
    for (LocalCache.Segment<?, ?> segment : cchm.segments) {
      assertEquals(0, segment.count);
      assertEquals(0, segmentSize(segment));
      assertTrue(segment.writeQueue.isEmpty());
      assertTrue(segment.accessQueue.isEmpty());
    }
  }
}
项目:ditb    文件:SequenceIdAccounting.java   
/**
 * We've been passed a new sequenceid for the region. Set it as highest seen for this region and
 * if we are to record oldest, or lowest sequenceids, save it as oldest seen if nothing
 * currently older.
 * @param encodedRegionName
 * @param families
 * @param sequenceid
 * @param lowest Whether to keep running account of oldest sequence id.
 */
void update(byte[] encodedRegionName, Set<byte[]> families, long sequenceid,
    final boolean lowest) {
  Long l = Long.valueOf(sequenceid);
  this.highestSequenceIds.put(encodedRegionName, l);
  if (lowest) {
    ConcurrentMap<byte[], Long> m = getOrCreateLowestSequenceIds(encodedRegionName);
    for (byte[] familyName : families) {
      m.putIfAbsent(familyName, l);
    }
  }
}
项目:myfaces-trinidad    文件:LRUCopyOnWriteArrayMapTest.java   
public void testEvictionAtMiddleInsertAtTail()
{
  ConcurrentMap<String, Object> cache = createMap();
  _putThree(cache, A_STR, B_STR, C_STR);

  cache.get(A_STR);
  cache.get(C_STR);

  cache.put(D_STR, FOUR);
  assertOldestEvicted(cache, B_STR);
  assertContains(cache, A_STR, C_STR, D_STR);
}
项目:myfaces-trinidad    文件:FileSystemStyleCache.java   
public Entry(
  List<String> uris,
  Styles styles,
  ConcurrentMap<String, Icon> icons,
  ConcurrentMap<Object, Object> skinProperties)
{
  this.uris = uris;
  this.styles = styles;
  this.icons = icons;
  this.skinProperties = skinProperties;
}
项目:gemini.blueprint    文件:BlueprintEditorRegistrar.java   
public void registerCustomEditors(PropertyEditorRegistry registry) {
    // Date
    registry.registerCustomEditor(Date.class, new DateEditor());
    // Collection concrete types
    registry.registerCustomEditor(Stack.class, new BlueprintCustomCollectionEditor(Stack.class));
    registry.registerCustomEditor(Vector.class, new BlueprintCustomCollectionEditor(Vector.class));

    // Spring creates a LinkedHashSet for Collection, RFC mandates an ArrayList
    // reinitialize default editors
    registry.registerCustomEditor(Collection.class, new BlueprintCustomCollectionEditor(Collection.class));
    registry.registerCustomEditor(Set.class, new BlueprintCustomCollectionEditor(Set.class));
    registry.registerCustomEditor(SortedSet.class, new BlueprintCustomCollectionEditor(SortedSet.class));
    registry.registerCustomEditor(List.class, new BlueprintCustomCollectionEditor(List.class));
    registry.registerCustomEditor(SortedMap.class, new CustomMapEditor(SortedMap.class));

    registry.registerCustomEditor(HashSet.class, new BlueprintCustomCollectionEditor(HashSet.class));
    registry.registerCustomEditor(LinkedHashSet.class, new BlueprintCustomCollectionEditor(LinkedHashSet.class));
    registry.registerCustomEditor(TreeSet.class, new BlueprintCustomCollectionEditor(TreeSet.class));

    registry.registerCustomEditor(ArrayList.class, new BlueprintCustomCollectionEditor(ArrayList.class));
    registry.registerCustomEditor(LinkedList.class, new BlueprintCustomCollectionEditor(LinkedList.class));

    // Map concrete types
    registry.registerCustomEditor(HashMap.class, new CustomMapEditor(HashMap.class));
    registry.registerCustomEditor(LinkedHashMap.class, new CustomMapEditor(LinkedHashMap.class));
    registry.registerCustomEditor(Hashtable.class, new CustomMapEditor(Hashtable.class));
    registry.registerCustomEditor(TreeMap.class, new CustomMapEditor(TreeMap.class));
    registry.registerCustomEditor(Properties.class, new PropertiesEditor());

    // JDK 5 types
    registry.registerCustomEditor(ConcurrentMap.class, new CustomMapEditor(ConcurrentHashMap.class));
    registry.registerCustomEditor(ConcurrentHashMap.class, new CustomMapEditor(ConcurrentHashMap.class));
    registry.registerCustomEditor(Queue.class, new BlueprintCustomCollectionEditor(LinkedList.class));

    // Legacy types
    registry.registerCustomEditor(Dictionary.class, new CustomMapEditor(Hashtable.class));
}
项目:rocketmq-rocketmq-all-4.1.0-incubating    文件:DefaultMessageStore.java   
public ConsumeQueue findConsumeQueue(String topic, int queueId) {
    ConcurrentMap<Integer, ConsumeQueue> map = consumeQueueTable.get(topic);
    if (null == map) {
        ConcurrentMap<Integer, ConsumeQueue> newMap = new ConcurrentHashMap<Integer, ConsumeQueue>(128);
        ConcurrentMap<Integer, ConsumeQueue> oldMap = consumeQueueTable.putIfAbsent(topic, newMap);
        if (oldMap != null) {
            map = oldMap;
        } else {
            map = newMap;
        }
    }

    ConsumeQueue logic = map.get(queueId);
    if (null == logic) {
        ConsumeQueue newLogic = new ConsumeQueue(//
            topic, //
            queueId, //
            StorePathConfigHelper.getStorePathConsumeQueue(this.messageStoreConfig.getStorePathRootDir()), //
            this.getMessageStoreConfig().getMapedFileSizeConsumeQueue(), //
            this);
        ConsumeQueue oldLogic = map.putIfAbsent(queueId, newLogic);
        if (oldLogic != null) {
            logic = oldLogic;
        } else {
            logic = newLogic;
        }
    }

    return logic;
}
项目:monarch    文件:RegisterInterestTracker.java   
/**
 * Return keys of interest for a given region. The keys in this Map are the full names of the
 * regions. The values are instances of RegionInterestEntry.
 *
 * @param interestType the type to return
 * @return the map
 */
public ConcurrentMap getRegionToInterestsMap(int interestType, boolean isDurable,
    boolean receiveUpdatesAsInvalidates) {
  FailoverInterestList fil =
      this.fils[getInterestLookupIndex(isDurable, receiveUpdatesAsInvalidates)];

  ConcurrentMap mapOfInterest = null;

  switch (interestType) {
    case InterestType.KEY:
      mapOfInterest = fil.keysOfInterest;
      break;
    case InterestType.REGULAR_EXPRESSION:
      mapOfInterest = fil.regexOfInterest;
      break;
    case InterestType.FILTER_CLASS:
      mapOfInterest = fil.filtersOfInterest;
      break;
    case InterestType.CQ:
      mapOfInterest = fil.cqsOfInterest;
      break;
    case InterestType.OQL_QUERY:
      mapOfInterest = fil.queriesOfInterest;
      break;
    default:
      throw new InternalGemFireError("Unknown interestType");
  }
  return mapOfInterest;
}
项目:rocketmq-rocketmq-all-4.1.0-incubating    文件:ConsumerOffsetManager.java   
private boolean offsetBehindMuchThanData(final String topic, ConcurrentMap<Integer, Long> table) {
    Iterator<Entry<Integer, Long>> it = table.entrySet().iterator();
    boolean result = !table.isEmpty();

    while (it.hasNext() && result) {
        Entry<Integer, Long> next = it.next();
        long minOffsetInStore = this.brokerController.getMessageStore().getMinOffsetInQueue(topic, next.getKey());
        long offsetInPersist = next.getValue();
        result = offsetInPersist <= minOffsetInStore;
    }

    return result;
}
项目:sstore-soft    文件:MapMakerInternalMap.java   
SerializationProxy(Strength keyStrength, Strength valueStrength,
    Equivalence<Object> keyEquivalence, Equivalence<Object> valueEquivalence,
    long expireAfterWriteNanos, long expireAfterAccessNanos, int maximumSize,
    int concurrencyLevel, RemovalListener<? super K, ? super V> removalListener,
    ConcurrentMap<K, V> delegate) {
  super(keyStrength, valueStrength, keyEquivalence, valueEquivalence, expireAfterWriteNanos,
      expireAfterAccessNanos, maximumSize, concurrencyLevel, removalListener, delegate);
}
项目:rocketmq-rocketmq-all-4.1.0-incubating    文件:DefaultMessageStore.java   
private void doFlush(int retryTimes) {
    /**
     * 变量含义:如果大于0,则标识这次刷盘必须刷多少个page,如果=0,则有多少刷多少
     */
    int flushConsumeQueueLeastPages = DefaultMessageStore.this.getMessageStoreConfig().getFlushConsumeQueueLeastPages();

    if (retryTimes == RETRY_TIMES_OVER) {
        flushConsumeQueueLeastPages = 0;
    }

    long logicsMsgTimestamp = 0;

    // 定时刷盘
    int flushConsumeQueueThoroughInterval = DefaultMessageStore.this.getMessageStoreConfig().getFlushConsumeQueueThoroughInterval();
    long currentTimeMillis = System.currentTimeMillis();
    if (currentTimeMillis >= (this.lastFlushTimestamp + flushConsumeQueueThoroughInterval)) {
        this.lastFlushTimestamp = currentTimeMillis;
        flushConsumeQueueLeastPages = 0;
        logicsMsgTimestamp = DefaultMessageStore.this.getStoreCheckpoint().getLogicsMsgTimestamp();
    }

    ConcurrentMap<String, ConcurrentMap<Integer, ConsumeQueue>> tables = DefaultMessageStore.this.consumeQueueTable;

    for (ConcurrentMap<Integer, ConsumeQueue> maps : tables.values()) {
        for (ConsumeQueue cq : maps.values()) {
            boolean result = false;
            for (int i = 0; i < retryTimes && !result; i++) {
                result = cq.flush(flushConsumeQueueLeastPages);
            }
        }
    }

    if (0 == flushConsumeQueueLeastPages) {
        if (logicsMsgTimestamp > 0) {
            DefaultMessageStore.this.getStoreCheckpoint().setLogicsMsgTimestamp(logicsMsgTimestamp);
        }
        DefaultMessageStore.this.getStoreCheckpoint().flush();
    }
}
项目:JRediClients    文件:RedissonMapCacheTest.java   
@Test
public void testReplaceOldValueFail() {
    ConcurrentMap<SimpleKey, SimpleValue> map = redisson.getMapCache("simple");
    map.put(new SimpleKey("1"), new SimpleValue("2"));

    boolean res = map.replace(new SimpleKey("1"), new SimpleValue("43"), new SimpleValue("31"));
    Assert.assertFalse(res);

    SimpleValue val1 = map.get(new SimpleKey("1"));
    Assert.assertEquals("2", val1.getValue());
}
项目:googles-monorepo-demo    文件:BenchmarkHelpers.java   
@Override
<K, V> Map<K, V> create(Map<K, V> map) {
  ConcurrentMap<K, V> newMap = new MapMaker().weakValues().makeMap();
  checkState(newMap instanceof MapMakerInternalMap);
  newMap.putAll(map);
  return newMap;
}