本文整理汇总了Java中java.util.concurrent.ConcurrentMap.entrySet方法的典型用法代码示例。如果您正苦于以下问题:Java ConcurrentMap.entrySet方法的具体用法?Java ConcurrentMap.entrySet怎么用?Java ConcurrentMap.entrySet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.ConcurrentMap
的用法示例。
在下文中一共展示了ConcurrentMap.entrySet方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findAddresses
import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
public List<String> findAddresses() {
List<String> ret = new ArrayList<String>();
ConcurrentMap<String, Map<Long, URL>> consumerUrls = getRegistryCache().get(Constants.CONSUMERS_CATEGORY);
if(null == consumerUrls) 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.getAddress();
if(app != null) ret.add(app);
}
}
return ret;
}
示例2: findServicesByApplication
import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
public List<String> findServicesByApplication(String application) {
List<String> ret = new ArrayList<String>();
ConcurrentMap<String, Map<Long, URL>> providerUrls = getRegistryCache().get(Constants.PROVIDERS_CATEGORY);
if(providerUrls == null || application == null || application.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(application.equals(u.getParameter(Constants.APPLICATION_KEY))) {
ret.add(e1.getKey());
break;
}
}
}
return ret;
}
示例3: assembleFeatures
import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
@Override
protected void assembleFeatures(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) {
for (Map.Entry<String, Gene> mrnaEntry : mrnas.entrySet()) {
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());
mrnaEntry.getValue().setItems(mRnaStuff);
setExonsCountAndLength(mrnaEntry.getValue(), mRnaStuff);
}
}
gene.setItems(new ArrayList<>(mrnas.values()));
}
if (passesScaleFactor(gene, scaleFactor)) {
passedGenes.add(gene);
}
}
示例4: findApplications
import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
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;
}
示例5: findServicesByApplication
import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
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;
}
示例6: findAddressesByApplication
import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
public List<String> findAddressesByApplication(String application) {
List<String> ret = new ArrayList<String>();
ConcurrentMap<String, Map<Long, URL>> providerUrls = getRegistryCache().get(Constants.PROVIDERS_CATEGORY);
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(application.equals(u.getParameter(Constants.APPLICATION_KEY))) {
String addr = u.getAddress();
if(addr != null) ret.add(addr);
}
}
}
return ret;
}
示例7: findServicesByAddress
import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
public List<String> findServicesByAddress(String address) {
List<String> ret = new ArrayList<String>();
ConcurrentMap<String, Map<Long, URL>> consumerUrls = getRegistryCache().get(Constants.CONSUMERS_CATEGORY);
if(consumerUrls == null || address == null || address.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(address.equals(u.getAddress())) {
ret.add(e1.getKey());
break;
}
}
}
return ret;
}
示例8: findAddresses
import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
public List<String> findAddresses() {
List<String> ret = new ArrayList<String>();
ConcurrentMap<String, Map<Long, URL>> providerUrls = getRegistryCache().get(Constants.PROVIDERS_CATEGORY);
if(null == providerUrls) 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();
String app = u.getAddress();
if(app != null) ret.add(app);
}
}
return ret;
}
示例9: findServicesByAddress
import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
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;
}
示例10: 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);
}
}
示例11: clearCache
import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
/**
* Delete all cached entries of a server.
*/
public void clearCache(final ServerName serverName) {
if (!this.cachedServers.contains(serverName)) {
return;
}
boolean deletedSomething = false;
synchronized (this.cachedServers) {
// We block here, because if there is an error on a server, it's likely that multiple
// threads will get the error simultaneously. If there are hundreds of thousand of
// region location to check, it's better to do this only once. A better pattern would
// be to check if the server is dead when we get the region location.
if (!this.cachedServers.contains(serverName)) {
return;
}
for (ConcurrentMap<byte[], RegionLocations> tableLocations : cachedRegionLocations.values()){
for (Entry<byte[], RegionLocations> e : tableLocations.entrySet()) {
RegionLocations regionLocations = e.getValue();
if (regionLocations != null) {
RegionLocations updatedLocations = regionLocations.removeByServer(serverName);
if (updatedLocations != regionLocations) {
if (updatedLocations.isEmpty()) {
deletedSomething |= tableLocations.remove(e.getKey(), regionLocations);
} else {
deletedSomething |= tableLocations.replace(e.getKey(), regionLocations, updatedLocations);
}
}
}
}
}
this.cachedServers.remove(serverName);
}
if (deletedSomething && LOG.isTraceEnabled()) {
LOG.trace("Removed all cached region locations that map to " + serverName);
}
}
示例12: showDirectMemoryTotal
import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
private static void showDirectMemoryTotal(ManagerConnection c) {
ByteBuffer buffer = c.allocate();
// write header
buffer = TOTAL_HEADER.write(buffer, c, true);
// write fields
for (FieldPacket field : TOTAL_FIELDS) {
buffer = field.write(buffer, c, true);
}
// write eof
buffer = TOTAL_EOF.write(buffer, c, true);
ConcurrentMap<Long, Long> networkBufferPool = DbleServer.getInstance().
getBufferPool().getNetDirectMemoryUsage();
RowDataPacket row = new RowDataPacket(TOTAL_FIELD_COUNT);
long usedForNetwork = 0;
/* the value of -XX:MaxDirectMemorySize */
long totalAvailable = Platform.getMaxDirectMemory();
row.add(StringUtil.encode(JavaUtils.bytesToString2(totalAvailable), c.getCharset().getResults()));
/* IO packet used in DirectMemory in buffer pool */
for (Map.Entry<Long, Long> entry : networkBufferPool.entrySet()) {
usedForNetwork += entry.getValue();
}
row.add(StringUtil.encode(JavaUtils.bytesToString2(usedForNetwork), c.getCharset().getResults()));
row.add(StringUtil.encode(JavaUtils.bytesToString2(totalAvailable - usedForNetwork), c.getCharset().getResults()));
// write rows
byte packetId = TOTAL_EOF.getPacketId();
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);
}
示例13: forEach
import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
/**
* Performs the given action for each entry in the map until all entries
* have been processed or the action throws an exception. Unless
* otherwise specified by the implementing class, actions are performed in
* the order of entry set iteration (if an iteration order is specified.)
* Exceptions thrown by the action are relayed to the caller.
*
* <p><b>Implementation Requirements:</b><br> The default implementation
* is equivalent to, for the
* {@code map}:
* <pre> {@code
* for ((Map.Entry<K, V> entry : map.entrySet())
* action.accept(entry.getKey(), entry.getValue());
* }</pre>
*
* <p><b>Implementation Note:</b><br> The default implementation assumes that
* {@code IllegalStateException} thrown by {@code getKey()} or
* {@code getValue()} indicates that the entry has been removed and cannot
* be processed. Operation continues for subsequent entries.
*
* @param <K> the type of keys maintained by the passed map
* @param <V> the type of mapped values in the passed map
* @param map the {@code ConcurrentMap} on which to execute the {@code forEach}
* operation.
* @param action The action to be performed for each entry
* @throws NullPointerException if the specified map or action is null
* @throws ConcurrentModificationException if an entry is found to be
* removed during iteration
* @since 1.8
*/
public static <K, V> void forEach(ConcurrentMap<K, V> map, BiConsumer<? super K, ? super V> action) {
Objects.requireNonNull(map);
Objects.requireNonNull(action);
for (Map.Entry<K, V> entry : map.entrySet()) {
K k;
V v;
try {
k = entry.getKey();
v = entry.getValue();
} catch (IllegalStateException ise) {
// this usually means the entry is no longer in the map.
continue;
}
action.accept(k, v);
}
}
示例14: maybeScheduleASpeculation
import java.util.concurrent.ConcurrentMap; //导入方法依赖的package包/类
private int maybeScheduleASpeculation(TaskType type) {
int successes = 0;
long now = clock.getTime();
ConcurrentMap<JobId, AtomicInteger> containerNeeds
= type == TaskType.MAP ? mapContainerNeeds : reduceContainerNeeds;
for (ConcurrentMap.Entry<JobId, AtomicInteger> jobEntry : containerNeeds.entrySet()) {
// This race conditon is okay. If we skip a speculation attempt we
// should have tried because the event that lowers the number of
// containers needed to zero hasn't come through, it will next time.
// Also, if we miss the fact that the number of containers needed was
// zero but increased due to a failure it's not too bad to launch one
// container prematurely.
if (jobEntry.getValue().get() > 0) {
continue;
}
int numberSpeculationsAlready = 0;
int numberRunningTasks = 0;
// loop through the tasks of the kind
Job job = context.getJob(jobEntry.getKey());
Map<TaskId, Task> tasks = job.getTasks(type);
int numberAllowedSpeculativeTasks
= (int) Math.max(minimumAllowedSpeculativeTasks,
proportionTotalTasksSpeculatable * tasks.size());
TaskId bestTaskID = null;
long bestSpeculationValue = -1L;
// this loop is potentially pricey.
// TODO track the tasks that are potentially worth looking at
for (Map.Entry<TaskId, Task> taskEntry : tasks.entrySet()) {
long mySpeculationValue = speculationValue(taskEntry.getKey(), now);
if (mySpeculationValue == ALREADY_SPECULATING) {
++numberSpeculationsAlready;
}
if (mySpeculationValue != NOT_RUNNING) {
++numberRunningTasks;
}
if (mySpeculationValue > bestSpeculationValue) {
bestTaskID = taskEntry.getKey();
bestSpeculationValue = mySpeculationValue;
}
}
numberAllowedSpeculativeTasks
= (int) Math.max(numberAllowedSpeculativeTasks,
proportionRunningTasksSpeculatable * numberRunningTasks);
// If we found a speculation target, fire it off
if (bestTaskID != null
&& numberAllowedSpeculativeTasks > numberSpeculationsAlready) {
addSpeculativeAttempt(bestTaskID);
++successes;
}
}
return successes;
}