Skip to content

Commit 3b46f5e

Browse files
committed
Minor fixes
1 parent d934801 commit 3b46f5e

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

core/src/main/scala/org/apache/spark/storage/BlockManagerSource.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ private[spark] class BlockManagerSource(val blockManager: BlockManager, sc: Spar
4646
metricRegistry.register(MetricRegistry.name("memory", "memUsed_MB"), new Gauge[Long] {
4747
override def getValue: Long = {
4848
val storageStatusList = blockManager.master.getStorageStatus
49-
val maxMem = storageStatusList.map(_.maxMem).sum
50-
val remainingMem = storageStatusList.map(_.memRemaining).sum
51-
(maxMem - remainingMem) / 1024 / 1024
49+
val memUsed = storageStatusList.map(_.memUsed).sum
50+
memUsed / 1024 / 1024
5251
}
5352
})
5453

core/src/main/scala/org/apache/spark/storage/StorageUtils.scala

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,13 @@ class StorageStatus(val blockManagerId: BlockManagerId, val maxMem: Long) {
172172
def memRemaining: Long = maxMem - memUsed
173173

174174
/** Return the memory used by this block manager. */
175-
def memUsed: Long =
176-
_nonRddStorageInfo._1 + _rddBlocks.keys.toSeq.map(memUsedByRdd).sum
175+
def memUsed: Long = _nonRddStorageInfo._1 + _rddBlocks.keys.toSeq.map(memUsedByRdd).sum
177176

178177
/** Return the disk space used by this block manager. */
179-
def diskUsed: Long =
180-
_nonRddStorageInfo._2 + _rddBlocks.keys.toSeq.map(diskUsedByRdd).sum
178+
def diskUsed: Long = _nonRddStorageInfo._2 + _rddBlocks.keys.toSeq.map(diskUsedByRdd).sum
181179

182180
/** Return the off-heap space used by this block manager. */
183-
def offHeapUsed: Long =
184-
_nonRddStorageInfo._3 + _rddBlocks.keys.toSeq.map(offHeapUsedByRdd).sum
181+
def offHeapUsed: Long = _nonRddStorageInfo._3 + _rddBlocks.keys.toSeq.map(offHeapUsedByRdd).sum
185182

186183
/** Return the memory used by the given RDD in this block manager in O(1) time. */
187184
def memUsedByRdd(rddId: Int): Long = _rddStorageInfo.get(rddId).map(_._1).getOrElse(0L)
@@ -246,7 +243,7 @@ private[spark] object StorageUtils {
246243
val rddId = rddInfo.id
247244
// Assume all blocks belonging to the same RDD have the same storage level
248245
val storageLevel = statuses
249-
.map(_.rddStorageLevel(rddId)).flatMap(s => s).headOption.getOrElse(StorageLevel.NONE)
246+
.flatMap(_.rddStorageLevel(rddId)).headOption.getOrElse(StorageLevel.NONE)
250247
val numCachedPartitions = statuses.map(_.numRddBlocksById(rddId)).sum
251248
val memSize = statuses.map(_.memUsedByRdd(rddId)).sum
252249
val diskSize = statuses.map(_.diskUsedByRdd(rddId)).sum

0 commit comments

Comments
 (0)