void initBlockPool(String bpid) { checkBlockPool(bpid); try (AutoCloseableLock l = lock.acquire()) { FoldedTreeSet<ReplicaInfo> set = map.get(bpid); if (set == null) { // Add an entry for block pool if it does not exist already set = new FoldedTreeSet<>(); map.put(bpid, set); } } }
/** * Add a replica's meta information into the map * * @param bpid block pool id * @param replicaInfo a replica's meta information * @return previous meta information of the replica * @throws IllegalArgumentException if the input parameter is null */ ReplicaInfo add(String bpid, ReplicaInfo replicaInfo) { checkBlockPool(bpid); checkBlock(replicaInfo); try (AutoCloseableLock l = lock.acquire()) { FoldedTreeSet<ReplicaInfo> set = map.get(bpid); if (set == null) { // Add an entry for block pool if it does not exist already set = new FoldedTreeSet<>(); map.put(bpid, set); } return set.addOrReplace(replicaInfo); } }
/** * Add a replica's meta information into the map, if already exist * return the old replicaInfo. */ ReplicaInfo addAndGet(String bpid, ReplicaInfo replicaInfo) { checkBlockPool(bpid); checkBlock(replicaInfo); try (AutoCloseableLock l = lock.acquire()) { FoldedTreeSet<ReplicaInfo> set = map.get(bpid); if (set == null) { // Add an entry for block pool if it does not exist already set = new FoldedTreeSet<>(); map.put(bpid, set); } ReplicaInfo oldReplicaInfo = set.get(replicaInfo.getBlockId(), LONG_AND_BLOCK_COMPARATOR); if (oldReplicaInfo != null) { return oldReplicaInfo; } else { set.addOrReplace(replicaInfo); } return replicaInfo; } }
storageInfo.getDatanodeDescriptor().getDatanodeUuid(), VersionInfo.getVersion()); Set<BlockReportReplica> set = new FoldedTreeSet<>(); for (BlockReportReplica iblk : report) { set.add(new BlockReportReplica(iblk));