Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1120,10 +1120,15 @@ private[spark] class BlockManager(
"the disk, memory, or external block store")
}
blockInfo.remove(blockId)
val status = getCurrentBlockStatus(blockId, info)
if (tellMaster && info.tellMaster) {
val status = getCurrentBlockStatus(blockId, info)
reportBlockStatus(blockId, info, status)
}
Option(TaskContext.get()).foreach { tc =>
val metrics = tc.taskMetrics()
val lastUpdatedBlocks = metrics.updatedBlocks.getOrElse(Seq[(BlockId, BlockStatus)]())
metrics.updatedBlocks = Some(lastUpdatedBlocks ++ Seq((blockId, status)))
}
}
} else {
// The block has already been removed; do nothing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,17 @@ class BlockManagerSuite extends SparkFunSuite with Matchers with BeforeAndAfterE
val list = List.fill(2)(new Array[Byte](2000))
val bigList = List.fill(8)(new Array[Byte](2000))

def getUpdatedBlocks(task: => Unit): Seq[(BlockId, BlockStatus)] = {
val context = TaskContext.empty()
try {
TaskContext.setTaskContext(context)
task
} finally {
TaskContext.unset()
}
context.taskMetrics.updatedBlocks.getOrElse(Seq[(BlockId, BlockStatus)]())
}

// 1 updated block (i.e. list1)
val updatedBlocks1 =
store.putIterator("list1", list.iterator, StorageLevel.MEMORY_ONLY, tellMaster = true)
Expand Down Expand Up @@ -954,6 +965,16 @@ class BlockManagerSuite extends SparkFunSuite with Matchers with BeforeAndAfterE
assert(!store.diskStore.contains("list3"), "list3 was in disk store")
assert(!store.diskStore.contains("list4"), "list4 was in disk store")
assert(!store.diskStore.contains("list5"), "list5 was in disk store")

// remove block - list2 should be removed from disk
val updatedBlocks6 = getUpdatedBlocks {
store.removeBlock(
"list2", tellMaster = true)
}
assert(updatedBlocks6.size === 1)
assert(updatedBlocks6.head._1 === TestBlockId("list2"))
assert(updatedBlocks6.head._2.storageLevel == StorageLevel.NONE)
assert(!store.diskStore.contains("list2"), "list2 was in disk store")
}

test("query block statuses") {
Expand Down