void cleanUpBlockPool(String bpid) { checkBlockPool(bpid); try (AutoCloseableLock l = lock.acquire()) { map.remove(bpid); } }
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); } } }
/** * Remove the replica's meta information from the map if present * @param bpid block pool id * @param blockId block id of the replica to be removed * @return the removed replica's meta information */ ReplicaInfo remove(String bpid, long blockId) { checkBlockPool(bpid); try (AutoCloseableLock l = lock.acquire()) { FoldedTreeSet<ReplicaInfo> set = map.get(bpid); if (set != null) { return set.removeAndGet(blockId, LONG_AND_BLOCK_COMPARATOR); } } return null; }
/** * Get the meta information of the replica that matches the block id * @param bpid block pool id * @param blockId a block's id * @return the replica's meta information */ ReplicaInfo get(String bpid, long blockId) { checkBlockPool(bpid); try (AutoCloseableLock l = lock.acquire()) { FoldedTreeSet<ReplicaInfo> set = map.get(bpid); if (set == null) { return null; } return set.get(blockId, LONG_AND_BLOCK_COMPARATOR); } }
/** * 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; } }
/** * Get the meta information of the replica that matches both block id * and generation stamp * @param bpid block pool id * @param block block with its id as the key * @return the replica's meta information * @throws IllegalArgumentException if the input block or block pool is null */ ReplicaInfo get(String bpid, Block block) { checkBlockPool(bpid); checkBlock(block); ReplicaInfo replicaInfo = get(bpid, block.getBlockId()); if (replicaInfo != null && block.getGenerationStamp() == replicaInfo.getGenerationStamp()) { return replicaInfo; } return null; }
/** * Remove the replica's meta information from the map that matches * the input block's id and generation stamp * @param bpid block pool id * @param block block with its id as the key * @return the removed replica's meta information * @throws IllegalArgumentException if the input block is null */ ReplicaInfo remove(String bpid, Block block) { checkBlockPool(bpid); checkBlock(block); try (AutoCloseableLock l = lock.acquire()) { FoldedTreeSet<ReplicaInfo> set = map.get(bpid); if (set != null) { ReplicaInfo replicaInfo = set.get(block.getBlockId(), LONG_AND_BLOCK_COMPARATOR); if (replicaInfo != null && block.getGenerationStamp() == replicaInfo.getGenerationStamp()) { return set.removeAndGet(replicaInfo); } } } return null; }
void cleanUpBlockPool(String bpid) { checkBlockPool(bpid); synchronized(mutex) { map.remove(bpid); } }
void cleanUpBlockPool(String bpid) { checkBlockPool(bpid); synchronized(mutex) { map.remove(bpid); } }
/** * Get the meta information of the replica that matches the block id * @param bpid block pool id * @param blockId a block's id * @return the replica's meta information */ ReplicaInfo get(String bpid, long blockId) { checkBlockPool(bpid); synchronized(mutex) { Map<Long, ReplicaInfo> m = map.get(bpid); return m != null ? m.get(blockId) : null; } }
/** * Get the meta information of the replica that matches the block id * @param bpid block pool id * @param blockId a block's id * @return the replica's meta information */ ReplicaInfo get(String bpid, long blockId) { checkBlockPool(bpid); synchronized(mutex) { Map<Long, ReplicaInfo> m = map.get(bpid); return m != null ? m.get(blockId) : null; } }
void initBlockPool(String bpid) { checkBlockPool(bpid); synchronized(mutex) { Map<Long, ReplicaInfo> m = map.get(bpid); if (m == null) { // Add an entry for block pool if it does not exist already m = new HashMap<Long, ReplicaInfo>(); map.put(bpid, m); } } }
void initBlockPool(String bpid) { checkBlockPool(bpid); synchronized(mutex) { Map<Long, ReplicaInfo> m = map.get(bpid); if (m == null) { // Add an entry for block pool if it does not exist already m = new HashMap<Long, ReplicaInfo>(); map.put(bpid, m); } } }
/** * Remove the replica's meta information from the map if present * @param bpid block pool id * @param blockId block id of the replica to be removed * @return the removed replica's meta information */ ReplicaInfo remove(String bpid, long blockId) { checkBlockPool(bpid); synchronized(mutex) { Map<Long, ReplicaInfo> m = map.get(bpid); if (m != null) { return m.remove(blockId); } } return null; }
/** * Remove the replica's meta information from the map if present * @param bpid block pool id * @param blockId block id of the replica to be removed * @return the removed replica's meta information */ ReplicaInfo remove(String bpid, long blockId) { checkBlockPool(bpid); synchronized(mutex) { Map<Long, ReplicaInfo> m = map.get(bpid); if (m != null) { return m.remove(blockId); } } return null; }
/** * 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); synchronized(mutex) { Map<Long, ReplicaInfo> m = map.get(bpid); if (m == null) { // Add an entry for block pool if it does not exist already m = new HashMap<Long, ReplicaInfo>(); map.put(bpid, m); } return m.put(replicaInfo.getBlockId(), replicaInfo); } }
/** * 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); synchronized(mutex) { Map<Long, ReplicaInfo> m = map.get(bpid); if (m == null) { // Add an entry for block pool if it does not exist already m = new HashMap<Long, ReplicaInfo>(); map.put(bpid, m); } return m.put(replicaInfo.getBlockId(), replicaInfo); } }
/** * Get the meta information of the replica that matches both block id * and generation stamp * @param bpid block pool id * @param block block with its id as the key * @return the replica's meta information * @throws IllegalArgumentException if the input block or block pool is null */ ReplicaInfo get(String bpid, Block block) { checkBlockPool(bpid); checkBlock(block); ReplicaInfo replicaInfo = get(bpid, block.getBlockId()); if (replicaInfo != null && block.getGenerationStamp() == replicaInfo.getGenerationStamp()) { return replicaInfo; } return null; }
/** * Get the meta information of the replica that matches both block id * and generation stamp * @param bpid block pool id * @param block block with its id as the key * @return the replica's meta information * @throws IllegalArgumentException if the input block or block pool is null */ ReplicaInfo get(String bpid, Block block) { checkBlockPool(bpid); checkBlock(block); ReplicaInfo replicaInfo = get(bpid, block.getBlockId()); if (replicaInfo != null && block.getGenerationStamp() == replicaInfo.getGenerationStamp()) { return replicaInfo; } return null; }