public virtual DatanodeStorageInfo.AddBlockResult AddBlock(BlockInfoContiguous b) { // First check whether the block belongs to a different storage // on the same DN. DatanodeStorageInfo.AddBlockResult result = DatanodeStorageInfo.AddBlockResult.Added; DatanodeStorageInfo otherStorage = b.FindStorageInfo(GetDatanodeDescriptor()); if (otherStorage != null) { if (otherStorage != this) { // The block belongs to a different storage. Remove it first. otherStorage.RemoveBlock(b); result = DatanodeStorageInfo.AddBlockResult.Replaced; } else { // The block is already associated with this storage. return(DatanodeStorageInfo.AddBlockResult.AlreadyExist); } } // add to the head of the data-node list b.AddStorage(this); blockList = b.ListInsert(blockList, this); numBlocks++; return(result); }
/// <summary>Remove block from the list of blocks belonging to the data-node.</summary> /// <remarks> /// Remove block from the list of blocks belonging to the data-node. Remove /// data-node from the block. /// </remarks> internal virtual bool RemoveBlock(string storageID, BlockInfoContiguous b) { DatanodeStorageInfo s = GetStorageInfo(storageID); if (s != null) { return(s.RemoveBlock(b)); } return(false); }
/// <summary>Remove block from the list of blocks belonging to the data-node.</summary> /// <remarks> /// Remove block from the list of blocks belonging to the data-node. Remove /// data-node from the block. /// </remarks> internal virtual bool RemoveBlock(BlockInfoContiguous b) { DatanodeStorageInfo s = b.FindStorageInfo(this); // if block exists on this datanode if (s != null) { return(s.RemoveBlock(b)); } return(false); }