List of usage examples for java.util Map merge
default V merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction)
From source file:org.apache.hadoop.hbase.quotas.FileArchiverNotifierImpl.java
/** * For the given snapshot, find all files which this {@code snapshotName} references. After a file * is found to be referenced by the snapshot, it is removed from {@code filesToUpdate} and * {@code snapshotSizeChanges} is updated in concert. * * @param snapshotName The snapshot to check * @param filesToUpdate A mapping of archived files to their size * @param snapshotSizeChanges A mapping of snapshots and their change in size *//*from w w w. j av a 2s .c om*/ void bucketFilesToSnapshot(String snapshotName, Map<String, Long> filesToUpdate, Map<String, Long> snapshotSizeChanges) throws IOException { // A quick check to avoid doing work if the caller unnecessarily invoked this method. if (filesToUpdate.isEmpty()) { return; } Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, FSUtils.getRootDir(conf)); SnapshotDescription sd = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir); SnapshotManifest manifest = SnapshotManifest.open(conf, fs, snapshotDir, sd); // For each region referenced by the snapshot for (SnapshotRegionManifest rm : manifest.getRegionManifests()) { // For each column family in this region for (FamilyFiles ff : rm.getFamilyFilesList()) { // And each store file in that family for (StoreFile sf : ff.getStoreFilesList()) { Long valueOrNull = filesToUpdate.remove(sf.getName()); if (valueOrNull != null) { // This storefile was recently archived, we should update this snapshot with its size snapshotSizeChanges.merge(snapshotName, valueOrNull, Long::sum); } // Short-circuit, if we have no more files that were archived, we don't need to iterate // over the rest of the snapshot. if (filesToUpdate.isEmpty()) { return; } } } } }
From source file:org.apache.geode.management.internal.beans.DistributedSystemBridge.java
public Map<String, Boolean> viewRemoteClusterStatus() { if (mapOfGatewaySenders.values().size() > 0) { Map<String, Boolean> senderMap = new HashMap<>(); for (GatewaySenderMXBean bean : mapOfGatewaySenders.values()) { Integer dsId = bean.getRemoteDSId(); if (dsId != null) { senderMap.merge(dsId.toString(), bean.isRunning(), Boolean::logicalAnd); }/* w w w. jav a 2s . c om*/ } return senderMap; } return Collections.emptyMap(); }