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


Java ConcurrentMap.remove方法代码示例

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


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

示例1: clearCache

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
/**
 * Delete a cached location for a table, row and server
 */
public void clearCache(final TableName tableName, final byte [] row, ServerName serverName) {
  ConcurrentMap<byte[], RegionLocations> tableLocations = getTableLocations(tableName);

  RegionLocations regionLocations = getCachedLocation(tableName, row);
  if (regionLocations != null) {
    RegionLocations updatedLocations = regionLocations.removeByServer(serverName);
    if (updatedLocations != regionLocations) {
      byte[] startKey = regionLocations.getRegionLocation().getRegionInfo().getStartKey();
      boolean removed = false;
      if (updatedLocations.isEmpty()) {
        removed = tableLocations.remove(startKey, regionLocations);
      } else {
        removed = tableLocations.replace(startKey, regionLocations, updatedLocations);
      }
      if (removed && LOG.isTraceEnabled()) {
        LOG.trace("Removed locations of table: " + tableName + " ,row: " + Bytes.toString(row)
          + " mapping to server: " + serverName + " from cache");
      }
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:25,代码来源:MetaCache.java

示例2: _removeAttributeChange

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
private AttributeComponentChange _removeAttributeChange(
  ConcurrentMap<String, ConcurrentMap<String, AttributeComponentChange>> attrChanges,
  ConcurrentMap<String, String>                                          renameMap,
  String                                                                 logicalScopedId,
  AttributeComponentChange                                               componentChange)
{
  // get all the attribute changes for this component after considering possible moves
  ConcurrentMap<String, AttributeComponentChange> changesForComponent = 
    _getAttributeChangesAfterHandlingMove(attrChanges, renameMap, logicalScopedId, false);
  
  if (changesForComponent != null)
  {
    return changesForComponent.remove(componentChange.getAttributeName());
  }
  
  return null;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:18,代码来源:SessionChangeManager.java

示例3: _updateRenameMap

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
/**
 * Update the renamemap with a change
 * @param renameMap
 * @param moveChange
 */
private void _updateRenameMap(
  ConcurrentMap<String, String> renameMap,
  MoveChildComponentChange      moveChange)
{
  String sourceScopedId      = moveChange.getSourceLogicalScopedId();
  String destinationScopedId = moveChange.getDestinationLogicalScopedId();
  
  // we only need to update the map if we actually changed scoped ids
  if (!(sourceScopedId.equals(destinationScopedId)))
  {
    // remove the old mapping for source
    String originalScodeId = renameMap.remove(sourceScopedId);
    
    // we don't bother adding mappings if there has been no rename, plus there might
    // not be any attribute changes yet.  In this case, the source scoped id must
    // be the original id
    if (originalScodeId == null)
      originalScodeId = sourceScopedId;
    
    // add the new, updated mapping to account for the move
    renameMap.put(destinationScopedId, originalScodeId);
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:29,代码来源:SessionChangeManager.java

示例4: removeChildListener

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
public void removeChildListener(String path, ChildListener listener) {
	ConcurrentMap<ChildListener, TargetChildListener> listeners = childListeners.get(path);
	if (listeners != null) {
		TargetChildListener targetListener = listeners.remove(listener);
		if (targetListener != null) {
			removeTargetChildListener(path, targetListener);
		}
	}
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:10,代码来源:AbstractZookeeperClient.java

示例5: removeStatus

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
/**
 * 
 * @param url
 */
public static void removeStatus(URL url, String methodName) {
    String uri = url.toIdentityString();
    ConcurrentMap<String, RpcStatus> map = METHOD_STATISTICS.get(uri);
    if (map != null) {
        map.remove(methodName);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:12,代码来源:RpcStatus.java

示例6: processQueue

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
/**
 * Removes from the specified map any keys that have been enqueued
 * on the specified reference queue.
 */
static void processQueue(ReferenceQueue<Class<?>> queue,
                         ConcurrentMap<? extends
                         WeakReference<Class<?>>, ?> map)
{
    Reference<? extends Class<?>> ref;
    while((ref = queue.poll()) != null) {
        map.remove(ref);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:ObjectStreamClass.java

示例7: recycle

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
public XulCacheModel recycle(ConcurrentMap<String, XulCacheModel> caches) {
    XulCacheModel cache = null;
    for (XulRecycleStrategy strategy : _strategies) {
        cache = strategy.findRecycledCache(caches.values());
        if (cache != null) {
            caches.remove(cache.getKey());
            break;
        }
    }

    return cache;
}
 
开发者ID:starcor-company,项目名称:starcor.xul,代码行数:13,代码来源:XulCacheRecycle.java

示例8: _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

示例9: testRemoveKeyValue

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
public void testRemoveKeyValue()
{
  ConcurrentMap<String, Object> cache = createMap();
  _putTwo(cache);
  boolean bool = cache.remove(A_STR, "aStr");
  assertFalse(bool);
  assertEquals("Remove operation did not work as expected.", 2, cache.size());
  assertNotNull("Entry with key 'aaa' expected to be available.",
                cache.get(A_STR));
  bool = cache.remove(A_STR, ONE);
  assertTrue(bool);
  assertEquals("Remove operation did not work as expected.", 1, cache.size());
  assertNull("Entry with key 'aaa' expected to be removed.",
             cache.get(A_STR));
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:16,代码来源:ConcurrentMapTestCase.java

示例10: testConcurrentMap_merge_racy

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
/**
 * Simulates races by modifying the map within the remapping function.
 */
@Test
public void testConcurrentMap_merge_racy() {
    final AtomicBoolean b = new AtomicBoolean(true);
    final ConcurrentMap<Long,Long> map = new ImplementsConcurrentMap<>();
    final Long two = 2L;
    BiFunction<Long,Long,Long> f, g;

    for (Long val : new Long[] { null, 86L }) {
        map.clear();

        f = (v, w) -> { throw new AssertionError(); };
        assertEquals(99L, (long)map.merge(two, 99L, f));
        assertEquals(99L, (long)map.get(two));

        f = (v, w) -> { map.put(two, 42L); return val; };
        g = (v, w) -> {
            assertEquals(42L, (long)v);
            assertEquals(3L, (long)w);
            return v + w;
        };
        assertEquals(45L, (long)map.merge(two, 3L, twoStep(b, f, g)));
        assertEquals(45L, (long)map.get(two));
        assertTrue(b.get());

        f = (v, w) -> { map.remove(two); return val; };
        g = (k, v) -> { throw new AssertionError(); };
        assertEquals(55L, (long)map.merge(two, 55L, twoStep(b, f, g)));
        assertEquals(55L, (long)map.get(two));
        assertTrue(map.containsKey(two));
        assertFalse(b.get()); b.set(true);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:Defaults.java

示例11: expungeFrom

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
void expungeFrom(ConcurrentMap<?, ? extends ConcurrentMap<?, ?>> map,
                 ConcurrentMap<?, Boolean> reverseMap) {
    // removing just by key is always safe here because after a CacheKey
    // is cleared and enqueue-ed it is only equal to itself
    // (see equals method)...
    ConcurrentMap<?, ?> valuesMap = map.remove(this);
    // remove also from reverseMap if needed
    if (valuesMap != null) {
        for (Object cacheValue : valuesMap.values()) {
            reverseMap.remove(cacheValue);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:WeakCache.java

示例12: collapseFeatures

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
@Override
protected void collapseFeatures(final ConcurrentMap<String, ConcurrentMap<String, List<Gene>>> mRnaStuffMap,
                                Gene gene, final ConcurrentMap<String, ConcurrentMap<String, Gene>> mRnaMap,
                                Double scaleFactor, List<Gene> passedGenes) {
    final ConcurrentMap<String, Gene> mrnas = mRnaMap.remove(gene.getGroupId());

    if (mrnas != null && scaleFactor > LARGE_SCALE_FACTOR_LIMIT) {
        IntervalTreeMap<Gene> stuffIntervalMap = new IntervalTreeMap<>();
        Gene canonicalTranscript = createCanonicalTranscript(gene);

        for (Map.Entry<String, Gene> mrnaEntry : mrnas.entrySet()) {
            setCanonicalTranscriptIndexes(canonicalTranscript, mrnaEntry.getValue());

            if (mRnaStuffMap.containsKey(gene.getGroupId())
                    && mRnaStuffMap.get(gene.getGroupId()).containsKey(mrnaEntry.getKey())) {
                List<Gene> mRnaStuff = mRnaStuffMap.get(gene.getGroupId()).remove(mrnaEntry.getKey());
                removeIfEmpty(mRnaStuffMap, gene.getGroupId());

                groupMrnaStuff(mRnaStuff, stuffIntervalMap);
            }
        }

        canonicalTranscript.setItems(new ArrayList<>(stuffIntervalMap.values()));
        gene.setItems(Collections.singletonList(canonicalTranscript));

        if (gene.getExonsCount() == null) {
            calculateExonsCountAndLength(gene, canonicalTranscript.getItems());
        }
    }

    if (passesScaleFactor(gene, scaleFactor)) {
        passedGenes.add(gene);
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:35,代码来源:GtfReader.java

示例13: testConcurrentMap_compute_racy

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
/**
 * Simulates races by modifying the map within the remapping function.
 */
@Test
public void testConcurrentMap_compute_racy() {
    final AtomicBoolean b = new AtomicBoolean(true);
    final ConcurrentMap<Long,Long> map = new ImplementsConcurrentMap<>();
    final Long two = 2L;
    BiFunction<Long,Long,Long> f, g;

    // null -> null is a no-op; race not detected
    f = (k, v) -> { map.put(two, 42L); return null; };
    assertNull(map.compute(two, f));
    assertEquals(42L, (long)map.get(two));

    for (Long val : new Long[] { null, 86L }) {
        map.clear();

        f = (k, v) -> { map.put(two, 42L); return 86L; };
        g = (k, v) -> {
            assertSame(two, k);
            assertEquals(42L, (long)v);
            return k + v;
        };
        assertEquals(44L, (long)map.compute(two, twoStep(b, f, g)));
        assertEquals(44L, (long)map.get(two));
        assertTrue(b.get());

        f = (k, v) -> { map.remove(two); return val; };
        g = (k, v) -> {
            assertSame(two, k);
            assertNull(v);
            return 44L;
        };
        assertEquals(44L, (long)map.compute(two, twoStep(b, f, g)));
        assertEquals(44L, (long)map.get(two));
        assertTrue(map.containsKey(two));
        assertTrue(b.get());

        f = (k, v) -> { map.remove(two); return val; };
        g = (k, v) -> {
            assertSame(two, k);
            assertNull(v);
            return null;
        };
        assertNull(map.compute(two, twoStep(b, f, g)));
        assertNull(map.get(two));
        assertFalse(map.containsKey(two));
        assertTrue(b.get());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:52,代码来源:Defaults.java

示例14: updateGroupDescription

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
/**
 * Updates the existing group entry with the information
 * from group description.
 *
 * @param deviceId the device ID
 * @param oldAppCookie the current group key
 * @param type update type
 * @param newBuckets group buckets for updates
 * @param newAppCookie optional new group key
 */
@Override
public void updateGroupDescription(DeviceId deviceId,
                            GroupKey oldAppCookie,
                            UpdateType type,
                            GroupBuckets newBuckets,
                            GroupKey newAppCookie) {
    // Check if a group is existing with the provided key
    Group oldGroup = getGroup(deviceId, oldAppCookie);
    if (oldGroup == null) {
        return;
    }

    List<GroupBucket> newBucketList = getUpdatedBucketList(oldGroup,
                                                           type,
                                                           newBuckets);
    if (newBucketList != null) {
        // Create a new group object from the old group
        GroupBuckets updatedBuckets = new GroupBuckets(newBucketList);
        GroupKey newCookie = (newAppCookie != null) ? newAppCookie : oldAppCookie;
        GroupDescription updatedGroupDesc = new DefaultGroupDescription(
                                                    oldGroup.deviceId(),
                                                    oldGroup.type(),
                                                    updatedBuckets,
                                                    newCookie,
                                                    oldGroup.givenGroupId(),
                                                    oldGroup.appId());
        StoredGroupEntry newGroup = new DefaultGroup(oldGroup.id(),
                                                 updatedGroupDesc);
        newGroup.setState(GroupState.PENDING_UPDATE);
        newGroup.setLife(oldGroup.life());
        newGroup.setPackets(oldGroup.packets());
        newGroup.setBytes(oldGroup.bytes());
        // Remove the old entry from maps and add new entry using new key
        ConcurrentMap<GroupKey, StoredGroupEntry> keyTable =
                getGroupKeyTable(oldGroup.deviceId());
        ConcurrentMap<GroupId, StoredGroupEntry> idTable =
                getGroupIdTable(oldGroup.deviceId());
        keyTable.remove(oldGroup.appCookie());
        idTable.remove(oldGroup.id());
        keyTable.put(newGroup.appCookie(), newGroup);
        idTable.put(newGroup.id(), newGroup);
        notifyDelegate(new GroupEvent(Type.GROUP_UPDATE_REQUESTED, newGroup));
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:55,代码来源:SimpleGroupStore.java

示例15: testMapMethods

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
public void testMapMethods() {
  Cache<Integer, Integer> cache = CacheBuilder.newBuilder()
      .build();

  ConcurrentMap<Integer, Integer> asMap = cache.asMap();

  cache.put(10, 100);
  cache.put(2, 52);

  asMap.replace(2, 79);
  asMap.replace(3, 60);

  assertEquals(null, cache.getIfPresent(3));
  assertEquals(null, asMap.get(3));

  assertEquals(Integer.valueOf(79), cache.getIfPresent(2));
  assertEquals(Integer.valueOf(79), asMap.get(2));

  asMap.replace(10, 100, 50);
  asMap.replace(2, 52, 99);

  assertEquals(Integer.valueOf(50), cache.getIfPresent(10));
  assertEquals(Integer.valueOf(50), asMap.get(10));
  assertEquals(Integer.valueOf(79), cache.getIfPresent(2));
  assertEquals(Integer.valueOf(79), asMap.get(2));

  asMap.remove(10, 100);
  asMap.remove(2, 79);

  assertEquals(Integer.valueOf(50), cache.getIfPresent(10));
  assertEquals(Integer.valueOf(50), asMap.get(10));
  assertEquals(null, cache.getIfPresent(2));
  assertEquals(null, asMap.get(2));

  asMap.putIfAbsent(2, 20);
  asMap.putIfAbsent(10, 20);

  assertEquals(Integer.valueOf(20), cache.getIfPresent(2));
  assertEquals(Integer.valueOf(20), asMap.get(2));
  assertEquals(Integer.valueOf(50), cache.getIfPresent(10));
  assertEquals(Integer.valueOf(50), asMap.get(10));
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:43,代码来源:CacheBuilderGwtTest.java


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