java.util.concurrent.ConcurrentHashMap.putAll()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(186)

本文整理了Java中java.util.concurrent.ConcurrentHashMap.putAll()方法的一些代码示例,展示了ConcurrentHashMap.putAll()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ConcurrentHashMap.putAll()方法的具体详情如下:
包路径:java.util.concurrent.ConcurrentHashMap
类名称:ConcurrentHashMap
方法名:putAll

ConcurrentHashMap.putAll介绍

[英]Copies all of the mappings from the specified map to this one. These mappings replace any mappings that this map had for any of the keys currently in the specified map.
[中]将指定映射中的所有映射复制到此映射。这些映射将替换此映射对指定映射中当前任何键所具有的任何映射。

代码示例

代码示例来源:origin: apache/storm

@Override
public void sendLoadMetrics(Map<Integer, Double> taskToLoad) {
  _load.putAll(taskToLoad);
}

代码示例来源:origin: Alluxio/alluxio

/**
 * @param alluxioProperties properties to copy
 */
public AlluxioProperties(AlluxioProperties alluxioProperties) {
 mUserProps.putAll(alluxioProperties.mUserProps);
 mSources.putAll(alluxioProperties.mSources);
}

代码示例来源:origin: apache/ignite

/** {@inheritDoc} */
@Override public synchronized void putAll(Map<? extends K, ? extends V> m) {
  super.putAll(m);
}

代码示例来源:origin: wildfly/wildfly

public void putAll(final Map<? extends K, ? extends V> m) {
  backingMap.putAll(m);
}

代码示例来源:origin: org.codehaus.groovy/groovy

/**
 * Constructs a cache and initialize the cache with the specified map
 * @param m the map to initialize the cache
 */
public UnlimitedConcurrentCache(Map<? extends K, ? extends V> m) {
  this();
  map.putAll(m);
}

代码示例来源:origin: killme2008/Metamorphosis

@Override
public void putAll(final Map<BytesKey, OpItem> map) {
  this.map.putAll(map);
}

代码示例来源:origin: org.codehaus.groovy/groovy

@Override
public void putAll(Map<? extends K, ? extends V> m) {
  map.putAll(m);
}

代码示例来源:origin: k9mail/k-9

@SuppressWarnings("unchecked")
private void restoreAccountStats(Bundle icicle) {
  if (icicle != null) {
    Map<String, AccountStats> oldStats = (Map<String, AccountStats>)icicle.get(ACCOUNT_STATS);
    if (oldStats != null) {
      accountStats.putAll(oldStats);
    }
  }
}

代码示例来源:origin: jdbi/jdbi

private ColumnMappers(ColumnMappers that) {
  factories.addAll(that.factories);
  cache.putAll(that.cache);
}

代码示例来源:origin: jdbi/jdbi

private RowMappers(RowMappers that) {
  factories.addAll(that.factories);
  cache.putAll(that.cache);
}

代码示例来源:origin: robovm/robovm

/**
 * Creates a new map with the same mappings as the given map.
 * The map is created with a capacity of 1.5 times the number
 * of mappings in the given map or 16 (whichever is greater),
 * and a default load factor (0.75) and concurrencyLevel (16).
 *
 * @param m the map
 */
public ConcurrentHashMap(Map<? extends K, ? extends V> m) {
  this(Math.max((int) (m.size() / DEFAULT_LOAD_FACTOR) + 1,
         DEFAULT_INITIAL_CAPACITY),
     DEFAULT_LOAD_FACTOR, DEFAULT_CONCURRENCY_LEVEL);
  putAll(m);
}

代码示例来源:origin: oracle/helidon

@Override
public void putAll(Map<? extends K, ? extends V> m) {
  m.keySet()
   .stream()
   .forEach(k -> created.put(k, System.currentTimeMillis()));
  super.putAll(m);
}

代码示例来源:origin: alibaba/jstorm

private void updateTaskComponentMap() throws Exception {
  Map<Integer, String> tmp = Common.getTaskToComponent(Cluster.get_all_taskInfo(zkCluster, topologyId));
  this.tasksToComponent.putAll(tmp);
  LOG.info("Updated tasksToComponentMap:" + tasksToComponent);
  this.componentToSortedTasks.putAll(JStormUtils.reverse_map(tmp));
  for (java.util.Map.Entry<String, List<Integer>> entry : componentToSortedTasks.entrySet()) {
    List<Integer> tasks = entry.getValue();
    Collections.sort(tasks);
  }
}

代码示例来源:origin: igniterealtime/Openfire

@Override
public void putAll(Map<? extends K, ? extends V> m) {
  super.putAll(m);
  // drop the transient sets; will be rebuilt when/if needed
  clearCache();
}

代码示例来源:origin: protostuff/protostuff

@Override
public void putAll(Map<? extends String, ? extends Object> m)
{
  voProperties.putAll(m);
}

代码示例来源:origin: apache/incubator-druid

@VisibleForTesting
public void addTaskGroupToPendingCompletionTaskGroup(
  int taskGroupId,
  ImmutableMap<PartitionIdType, SequenceOffsetType> partitionOffsets,
  Optional<DateTime> minMsgTime,
  Optional<DateTime> maxMsgTime,
  Set<String> tasks,
  Set<PartitionIdType> exclusiveStartingSequencePartitions
)
{
 TaskGroup group = new TaskGroup(
   taskGroupId,
   partitionOffsets,
   minMsgTime,
   maxMsgTime,
   exclusiveStartingSequencePartitions
 );
 group.tasks.putAll(tasks.stream().collect(Collectors.toMap(x -> x, x -> new TaskData())));
 pendingCompletionTaskGroups.computeIfAbsent(taskGroupId, x -> new CopyOnWriteArrayList<>())
               .add(group);
}

代码示例来源:origin: ben-manes/caffeine

@Override
public void putAll(Map<? extends K, ? extends V> map) {
 if (!hasRemovalListener() && (writer == CacheWriter.disabledWriter())) {
  data.putAll(map);
  return;
 }
 map.forEach(this::put);
}

代码示例来源:origin: azkaban/azkaban

private void loadRunningExecutions() throws ExecutorManagerException {
 logger.info("Loading running flows from database..");
 final Map<Integer, Pair<ExecutionReference, ExecutableFlow>> activeFlows = this.executorLoader
   .fetchActiveFlows();
 logger.info("Loaded " + activeFlows.size() + " running flows");
 this.runningExecutions.get().putAll(activeFlows);
}

代码示例来源:origin: apache/incubator-druid

@VisibleForTesting
public void addTaskGroupToActivelyReadingTaskGroup(
  int taskGroupId,
  ImmutableMap<PartitionIdType, SequenceOffsetType> partitionOffsets,
  Optional<DateTime> minMsgTime,
  Optional<DateTime> maxMsgTime,
  Set<String> tasks,
  Set<PartitionIdType> exclusiveStartingSequencePartitions
)
{
 TaskGroup group = new TaskGroup(
   taskGroupId,
   partitionOffsets,
   minMsgTime,
   maxMsgTime,
   exclusiveStartingSequencePartitions
 );
 group.tasks.putAll(tasks.stream().collect(Collectors.toMap(x -> x, x -> new TaskData())));
 if (activelyReadingTaskGroups.putIfAbsent(taskGroupId, group) != null) {
  throw new ISE(
    "trying to add taskGroup with RandomIdUtils [%s] to actively reading task groups, but group already exists.",
    taskGroupId
  );
 }
}

代码示例来源:origin: alibaba/jstorm

public void initTaskHb() {
  this.taskHbs = new TopologyTaskHbInfo(this.topologyId, this.taskId);
  ConcurrentHashMap<Integer, TaskHeartbeat> tmpTaskHbMap = new ConcurrentHashMap<>();
  try {
    TopologyTaskHbInfo taskHbInfo = zkCluster.topology_heartbeat(topologyId);
    if (taskHbInfo != null) {
      LOG.info("Found task heartbeat info left in zk for " + topologyId + ": " + taskHbInfo.toString());
      if (taskHbInfo.get_taskHbs() != null) {
        tmpTaskHbMap.putAll(taskHbInfo.get_taskHbs());
      }
    }
  } catch (Exception e) {
    LOG.warn("Failed to get topology heartbeat from zk", e);
  }
  this.taskHbMap.set(tmpTaskHbMap);
  taskHbs.set_taskHbs(tmpTaskHbMap);
}

相关文章