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


Java ConcurrentMap.values方法代码示例

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


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

示例1: test_Multi_Replace_MultiInstance

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
@Test
public void test_Multi_Replace_MultiInstance() throws InterruptedException {
    final String name = "test_Multi_Replace_MultiInstance";

    ConcurrentMap<Integer, Integer> map = BaseTest.createInstance().getMap(name);
    for (int i = 0; i < 5; i++) {
        map.put(i, 1);
    }

    final SecureRandom secureRandom = new SecureRandom();
    testSingleInstanceConcurrency(100, r -> {
        ConcurrentMap<Integer, Integer> map1 = r.getMap(name);
        Assert.assertNotNull(map1.replace(secureRandom.nextInt(5), 2));
    });

    ConcurrentMap<Integer, Integer> testMap = BaseTest.createInstance().getMap(name);
    for (Integer value : testMap.values()) {
        Assert.assertEquals(2, (int)value);
    }
    assertMapSize(5, name);

}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:23,代码来源:RedissonConcurrentMapTest.java

示例2: applySimpleComponentChanges

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
/**
 * 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);
    }
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:22,代码来源:SessionChangeManager.java

示例3: getConnections

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
@Override
public Collection<IWebSocketConnection> getConnections(Application application, String sessionId)
{
	Args.notNull(application, "application");
	Args.notNull(sessionId, "sessionId");

	Collection<IWebSocketConnection> connections = Collections.emptyList();
	ConcurrentMap<String, ConcurrentMap<IKey, IWebSocketConnection>> connectionsBySession = application.getMetaData(KEY);
	if (connectionsBySession != null)
	{
		ConcurrentMap<IKey, IWebSocketConnection> connectionsByPage = connectionsBySession.get(sessionId);
		if (connectionsByPage != null)
		{
			connections = connectionsByPage.values();
		}
	}
	return connections;
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:19,代码来源:SimpleWebSocketConnectionRegistry.java

示例4: truncateDirtyLogicFiles

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
public void truncateDirtyLogicFiles(long phyOffset) {
    ConcurrentMap<String, ConcurrentMap<Integer, ConsumeQueue>> tables = DefaultMessageStore.this.consumeQueueTable;

    for (ConcurrentMap<Integer, ConsumeQueue> maps : tables.values()) {
        for (ConsumeQueue logic : maps.values()) {
            logic.truncateDirtyLogicFiles(phyOffset);
        }
    }
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:10,代码来源:DefaultMessageStore.java

示例5: destroyLogics

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
public void destroyLogics() {
    for (ConcurrentMap<Integer, ConsumeQueue> maps : this.consumeQueueTable.values()) {
        for (ConsumeQueue logic : maps.values()) {
            logic.destroy();
        }
    }
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:8,代码来源:DefaultMessageStore.java

示例6: testAddAndRemove

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
private void testAddAndRemove(ConcurrentMap<String, AtomicInteger> map)
    throws ExecutionException, InterruptedException {

  final ConcurrentHashMultiset<String> multiset = new ConcurrentHashMultiset<String>(map);
  int nThreads = 20;
  int tasksPerThread = 10;
  int nTasks = nThreads * tasksPerThread;
  ExecutorService pool = Executors.newFixedThreadPool(nThreads);
  ImmutableList<String> keys = ImmutableList.of("a", "b", "c");
  try {
    List<Future<int[]>> futures = Lists.newArrayListWithExpectedSize(nTasks);
    for (int i = 0; i < nTasks; i++) {
      futures.add(pool.submit(new MutateTask(multiset, keys)));
    }

    int[] deltas = new int[3];
    for (Future<int[]> future : futures) {
      int[] taskDeltas = future.get();
      for (int i = 0; i < deltas.length; i++) {
        deltas[i] += taskDeltas[i];
      }
    }

    List<Integer> actualCounts = Lists.transform(keys,
        new Function<String, Integer>() {
          @Override public Integer apply(String key) {
            return multiset.count(key);
          }
        });
    assertEquals("Counts not as expected", Ints.asList(deltas), actualCounts);
  } finally {
    pool.shutdownNow();
  }

  // Since we have access to the backing map, verify that there are no zeroes in the map
  for (AtomicInteger value : map.values()) {
    assertTrue("map should not contain a zero", value.get() != 0);
  }
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:40,代码来源:ConcurrentHashMultisetBasherTest.java

示例7: recoverConsumeQueue

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
private void recoverConsumeQueue() {
    for (ConcurrentMap<Integer, ConsumeQueue> maps : this.consumeQueueTable.values()) {
        for (ConsumeQueue logic : maps.values()) {
            logic.recover();
        }
    }
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:8,代码来源:DefaultMessageStore.java

示例8: recoverTopicQueueTable

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
private void recoverTopicQueueTable() {
    HashMap<String/* topic-queueid */, Long/* offset */> table = new HashMap<String, Long>(1024);
    long minPhyOffset = this.commitLog.getMinOffset();
    for (ConcurrentMap<Integer, ConsumeQueue> maps : this.consumeQueueTable.values()) {
        for (ConsumeQueue logic : maps.values()) {
            // 恢复写入消息时,记录的队列offset
            String key = logic.getTopic() + "-" + logic.getQueueId();
            table.put(key, logic.getMaxOffsetInQueue());
            // 恢复每个队列的最小offset
            logic.correctMinOffset(minPhyOffset);
        }
    }

    this.commitLog.setTopicQueueTable(table);
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:16,代码来源:DefaultMessageStore.java

示例9: deleteExpiredFiles

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
private void deleteExpiredFiles() {
    int deleteLogicsFilesInterval = DefaultMessageStore.this.getMessageStoreConfig().getDeleteConsumeQueueFilesInterval();

    long minOffset = DefaultMessageStore.this.commitLog.getMinOffset();
    if (minOffset > this.lastPhysicalMinOffset) {
        this.lastPhysicalMinOffset = minOffset;

        // 删除逻辑队列文件
        ConcurrentMap<String, ConcurrentMap<Integer, ConsumeQueue>> tables = DefaultMessageStore.this.consumeQueueTable;

        for (ConcurrentMap<Integer, ConsumeQueue> maps : tables.values()) {
            for (ConsumeQueue logic : maps.values()) {
                int deleteCount = logic.deleteExpiredFile(minOffset);

                if (deleteCount > 0 && deleteLogicsFilesInterval > 0) {
                    try {
                        Thread.sleep(deleteLogicsFilesInterval);
                    } catch (InterruptedException ignored) {
                    }
                }
            }
        }

        // 删除索引
        DefaultMessageStore.this.indexService.deleteExpiredFile(minOffset);
    }
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:28,代码来源:DefaultMessageStore.java

示例10: execute

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
public static void execute(ManagerConnection c) {
    ByteBuffer buffer = c.allocate();

    // write header
    buffer = HEADER.write(buffer, c, true);

    // write fields
    for (FieldPacket field : FIELDS) {
        buffer = field.write(buffer, c, true);
    }

    // write eof
    buffer = EOF.write(buffer, c, true);

    // write rows
    byte packetId = EOF.getPacketId();
    int i = 0;
    Map<String, UserStat> statMap = UserStatAnalyzer.getInstance().getUserStatMap();
    for (UserStat userStat : statMap.values()) {
        String user = userStat.getUser();
        ConcurrentMap<String, SqlResultSet> map = userStat.getSqlResultSizeRecorder().getSqlResultSet();
        if (map != null) {
            for (SqlResultSet sqlResultSet : map.values()) {
                RowDataPacket row = getRow(++i, user, sqlResultSet.getSql(), sqlResultSet.getCount(), sqlResultSet.getResultSetSize(), c.getCharset().getResults());
                row.setPacketId(++packetId);
                buffer = row.write(buffer, c, true);
            }
        }
    }
    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.setPacketId(++packetId);
    buffer = lastEof.write(buffer, c, true);

    // write buffer
    c.write(buffer);
}
 
开发者ID:actiontech,项目名称:dble,代码行数:38,代码来源:ShowSqlResultSet.java

示例11: getInstanceMethods

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
final Iterable<Method> getInstanceMethods(Class<?> cls) {
  ConcurrentMap<Signature, Method> map = Maps.newConcurrentMap();
  for (Method method : getVisibleMethods(cls)) {
    if (!Invokable.from(method).isStatic()) {
      map.putIfAbsent(new Signature(method), method);
    }
  }
  return map.values();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:10,代码来源:NullPointerTester.java

示例12: getRegistryData

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
@Override
public ConcurrentMap<String, Record> getRegistryData() {
    final ConcurrentMap<String, Record> map = readData(EtcdPath.IPC);
    for (final Record record : map.values()) {
        record.setStatus(Status.UP);
        record.setType("IPC");
        // Alpn Enabled for Rpc, ssl must be true.
        record.getLocation().put("ssl", Boolean.TRUE);
    }
    return map;
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:12,代码来源:IpcOrigin.java

示例13: 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

示例14: checkForInitialSet

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
private void checkForInitialSet(int i, ConcurrentMap testMap, Map initialSet) {
  HashSet found = new HashSet(testMap.values());
  if (!found.containsAll(initialSet.values())) {
    HashSet missed = new HashSet(initialSet.values());
    missed.removeAll(found);
    fail("On run " + i + " did not find these elements of the initial set using the iterator "
        + missed);
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:10,代码来源:ConcurrentHashMapIteratorJUnitTest.java

示例15: deviceInitialAuditCompleted

import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
@Override
public void deviceInitialAuditCompleted(DeviceId deviceId,
                                        boolean completed) {
    synchronized (deviceAuditStatus) {
        if (completed) {
            log.debug("deviceInitialAuditCompleted: AUDIT "
                    + "completed for device {}", deviceId);
            deviceAuditStatus.put(deviceId, true);
            // Execute all pending group requests
            ConcurrentMap<GroupKey, StoredGroupEntry> pendingGroupRequests =
                    getPendingGroupKeyTable(deviceId);
            for (Group group:pendingGroupRequests.values()) {
                GroupDescription tmp = new DefaultGroupDescription(
                                                                   group.deviceId(),
                                                                   group.type(),
                                                                   group.buckets(),
                                                                   group.appCookie(),
                                                                   group.givenGroupId(),
                                                                   group.appId());
                storeGroupDescriptionInternal(tmp);
            }
            getPendingGroupKeyTable(deviceId).clear();
        } else {
            if (deviceAuditStatus.get(deviceId)) {
                log.debug("deviceInitialAuditCompleted: Clearing AUDIT "
                        + "status for device {}", deviceId);
                deviceAuditStatus.put(deviceId, false);
            }
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:32,代码来源:SimpleGroupStore.java


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