-
Notifications
You must be signed in to change notification settings - Fork 28.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-13746][Tests]stop using deprecated SynchronizedSet #11580
Changes from 2 commits
c0bcba3
6721259
3ef58f7
be3830f
c1e4e41
bb8b83a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ package org.apache.spark | |
|
||
import java.lang.ref.WeakReference | ||
|
||
import scala.collection.mutable.{HashSet, SynchronizedSet} | ||
import scala.collection.mutable.HashSet | ||
import scala.language.existentials | ||
import scala.util.Random | ||
|
||
|
@@ -442,25 +442,25 @@ class CleanerTester( | |
checkpointIds: Seq[Long] = Seq.empty) | ||
extends Logging { | ||
|
||
val toBeCleanedRDDIds = new HashSet[Int] with SynchronizedSet[Int] ++= rddIds | ||
val toBeCleanedShuffleIds = new HashSet[Int] with SynchronizedSet[Int] ++= shuffleIds | ||
val toBeCleanedBroadcstIds = new HashSet[Long] with SynchronizedSet[Long] ++= broadcastIds | ||
val toBeCheckpointIds = new HashSet[Long] with SynchronizedSet[Long] ++= checkpointIds | ||
val toBeCleanedRDDIds = new HashSet[Int] ++= rddIds | ||
val toBeCleanedShuffleIds = new HashSet[Int] ++= shuffleIds | ||
val toBeCleanedBroadcstIds = new HashSet[Long] ++= broadcastIds | ||
val toBeCheckpointIds = new HashSet[Long] ++= checkpointIds | ||
val isDistributed = !sc.isLocal | ||
|
||
val cleanerListener = new CleanerListener { | ||
def rddCleaned(rddId: Int): Unit = { | ||
toBeCleanedRDDIds -= rddId | ||
toBeCleanedRDDIds.synchronized { toBeCleanedRDDIds -= rddId } | ||
logInfo("RDD " + rddId + " cleaned") | ||
} | ||
|
||
def shuffleCleaned(shuffleId: Int): Unit = { | ||
toBeCleanedShuffleIds -= shuffleId | ||
toBeCleanedShuffleIds.synchronized { toBeCleanedShuffleIds -= shuffleId } | ||
logInfo("Shuffle " + shuffleId + " cleaned") | ||
} | ||
|
||
def broadcastCleaned(broadcastId: Long): Unit = { | ||
toBeCleanedBroadcstIds -= broadcastId | ||
toBeCleanedBroadcstIds.synchronized { toBeCleanedBroadcstIds -= broadcastId } | ||
logInfo("Broadcast " + broadcastId + " cleaned") | ||
} | ||
|
||
|
@@ -469,7 +469,7 @@ class CleanerTester( | |
} | ||
|
||
def checkpointCleaned(rddId: Long): Unit = { | ||
toBeCheckpointIds -= rddId | ||
toBeCheckpointIds.synchronized { toBeCheckpointIds -= rddId } | ||
logInfo("checkpoint " + rddId + " cleaned") | ||
} | ||
} | ||
|
@@ -579,17 +579,20 @@ class CleanerTester( | |
|
||
private def uncleanedResourcesToString = { | ||
s""" | ||
|\tRDDs = ${toBeCleanedRDDIds.toSeq.sorted.mkString("[", ", ", "]")} | ||
|\tShuffles = ${toBeCleanedShuffleIds.toSeq.sorted.mkString("[", ", ", "]")} | ||
|\tBroadcasts = ${toBeCleanedBroadcstIds.toSeq.sorted.mkString("[", ", ", "]")} | ||
|\tRDDs = ${toBeCleanedRDDIds.synchronized | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At this point it's getting hard to read this in the interpolated string. I'd just pull out the calls to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @srowen |
||
{toBeCleanedRDDIds.toSeq.sorted.mkString("[", ", ", "]")}} | ||
|\tShuffles = ${toBeCleanedShuffleIds.synchronized | ||
{toBeCleanedShuffleIds.toSeq.sorted.mkString("[", ", ", "]")}} | ||
|\tBroadcasts = ${toBeCleanedBroadcstIds.synchronized | ||
{toBeCleanedBroadcstIds.toSeq.sorted.mkString("[", ", ", "]")}} | ||
""".stripMargin | ||
} | ||
|
||
private def isAllCleanedUp = | ||
toBeCleanedRDDIds.isEmpty && | ||
toBeCleanedShuffleIds.isEmpty && | ||
toBeCleanedBroadcstIds.isEmpty && | ||
toBeCheckpointIds.isEmpty | ||
toBeCleanedRDDIds.synchronized { toBeCleanedRDDIds.isEmpty } && | ||
toBeCleanedShuffleIds.synchronized { toBeCleanedShuffleIds.isEmpty } && | ||
toBeCleanedBroadcstIds.synchronized { toBeCleanedBroadcstIds.isEmpty } && | ||
toBeCheckpointIds.synchronized { toBeCheckpointIds.isEmpty } | ||
|
||
private def getRDDBlocks(rddId: Int): Seq[BlockId] = { | ||
blockManager.master.getMatchingBlockIds( _ match { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this just be
= HashSet(rddIds)
and similarly for the next 4?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@srowen
I tried to change to val toBeCleanedRDDIds = HashSet(rddIds), but I got error at
toBeCleanedRDDIds -= rddId
so I will keep val toBeCleanedRDDIds = new HashSet[Int] ++= rddIds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right Scala doesn't have a constructor that builds a set from a list/seq, so this makes a set of a
Seq[Int]
. Yes this is fine.