@@ -41,9 +41,7 @@ private[spark] case class ProcfsMetrics(
4141
4242// Some of the ideas here are taken from the ProcfsBasedProcessTree class in hadoop
4343// project.
44- private [spark] class ProcfsMetricsGetter (
45- val procfsDir : String = " /proc/" ,
46- val pSizeForTest : Long = 0 ) extends Logging {
44+ private [spark] class ProcfsMetricsGetter (val procfsDir : String = " /proc/" ) extends Logging {
4745 val procfsStatFile = " stat"
4846 val testing = sys.env.contains(" SPARK_TESTING" ) || sys.props.contains(" spark.testing" )
4947 val pageSize = computePageSize()
@@ -91,7 +89,7 @@ private[spark] class ProcfsMetricsGetter(
9189
9290 private def computePageSize (): Long = {
9391 if (testing) {
94- return pSizeForTest ;
92+ return 4096 ;
9593 }
9694 try {
9795 val cmd = Array (" getconf" , " PAGESIZE" )
@@ -114,10 +112,10 @@ private[spark] class ProcfsMetricsGetter(
114112 ptree += pid
115113 val queue = mutable.Queue .empty[Int ]
116114 queue += pid
117- while ( ! queue.isEmpty ) {
115+ while ( ! queue.isEmpty ) {
118116 val p = queue.dequeue()
119117 val c = getChildPids(p)
120- if (! c.isEmpty) {
118+ if (! c.isEmpty) {
121119 queue ++= c
122120 ptree ++= c.toSet
123121 }
@@ -142,9 +140,7 @@ private[spark] class ProcfsMetricsGetter(
142140 val stdErrThread = Utils .processStreamByLine(
143141 " stderr for pgrep" ,
144142 process.getErrorStream,
145- { line =>
146- errorStringBuilder.append(line)
147- })
143+ line => errorStringBuilder.append(line))
148144 val exitCode = process.waitFor()
149145 stdoutThread.join()
150146 stdErrThread.join()
@@ -203,7 +199,7 @@ private[spark] class ProcfsMetricsGetter(
203199 }
204200 }
205201 } catch {
206- case f : FileNotFoundException =>
202+ case f : IOException =>
207203 logWarning(" There was a problem with reading" +
208204 " the stat file of the process. " , f)
209205 ProcfsMetrics (0 , 0 , 0 , 0 , 0 , 0 )
@@ -219,7 +215,7 @@ private[spark] class ProcfsMetricsGetter(
219215 for (p <- pids) {
220216 allMetrics = addProcfsMetricsFromOneProcess(allMetrics, p)
221217 }
222- return allMetrics
218+ allMetrics
223219 }
224220}
225221
0 commit comments