當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。