本文整理汇总了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);
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
}
示例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();
}
}
}
示例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);
}
}
示例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();
}
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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();
}
示例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;
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
}
}