Skip to content
Snippets Groups Projects
Commit 3a671ce9 authored by Mosharaf Chowdhury's avatar Mosharaf Chowdhury
Browse files

Config parameters are in place. Good to go (I think)

parent 476a216d
No related branches found
No related tags found
No related merge requests found
...@@ -84,13 +84,13 @@ class LocalFileShuffle[K, V, C] extends Shuffle[K, V, C] with Logging { ...@@ -84,13 +84,13 @@ class LocalFileShuffle[K, V, C] extends Shuffle[K, V, C] with Logging {
splitsInRequestBitVector = new BitSet (totalSplits) splitsInRequestBitVector = new BitSet (totalSplits)
combiners = new HashMap[K, C] combiners = new HashMap[K, C]
// TODO: Fix config param var threadPool =
var threadPool = LocalFileShuffle.newDaemonFixedThreadPool (2) LocalFileShuffle.newDaemonFixedThreadPool (LocalFileShuffle.MaxTxPeers)
while (hasSplits < totalSplits) { while (hasSplits < totalSplits) {
// TODO: var numThreadsToCreate =
var numThreadsToCreate = Math.min (totalSplits, LocalFileShuffle.MaxTxPeers) -
Math.min (totalSplits, 2) - threadPool.getActiveCount threadPool.getActiveCount
while (hasSplits < totalSplits && numThreadsToCreate > 0) { while (hasSplits < totalSplits && numThreadsToCreate > 0) {
// Select a random split to pull // Select a random split to pull
...@@ -112,8 +112,8 @@ class LocalFileShuffle[K, V, C] extends Shuffle[K, V, C] with Logging { ...@@ -112,8 +112,8 @@ class LocalFileShuffle[K, V, C] extends Shuffle[K, V, C] with Logging {
numThreadsToCreate = numThreadsToCreate - 1 numThreadsToCreate = numThreadsToCreate - 1
} }
// TODO: // Sleep for a while before creating new threads
Thread.sleep (1000) Thread.sleep (LocalFileShuffle.MinKnockInterval)
} }
threadPool.shutdown threadPool.shutdown
...@@ -162,9 +162,7 @@ class LocalFileShuffle[K, V, C] extends Shuffle[K, V, C] with Logging { ...@@ -162,9 +162,7 @@ class LocalFileShuffle[K, V, C] extends Shuffle[K, V, C] with Logging {
} }
var timeOutTimer = new Timer var timeOutTimer = new Timer
// TODO: Set wait timer timeOutTimer.schedule (timeOutTask, LocalFileShuffle.MaxKnockInterval)
// TODO: If its too small, things FAIL
timeOutTimer.schedule (timeOutTask, 5000)
logInfo ("ShuffleClient started... => %s:%d#%s".format(hostAddress, listenPort, requestPath)) logInfo ("ShuffleClient started... => %s:%d#%s".format(hostAddress, listenPort, requestPath))
...@@ -201,8 +199,6 @@ class LocalFileShuffle[K, V, C] extends Shuffle[K, V, C] with Logging { ...@@ -201,8 +199,6 @@ class LocalFileShuffle[K, V, C] extends Shuffle[K, V, C] with Logging {
} }
} }
logInfo ("Finished reading " + requestPath)
// Now add this to combiners // Now add this to combiners
val inputStream = new ObjectInputStream ( val inputStream = new ObjectInputStream (
new ByteArrayInputStream(byteArray)) new ByteArrayInputStream(byteArray))
...@@ -221,8 +217,6 @@ class LocalFileShuffle[K, V, C] extends Shuffle[K, V, C] with Logging { ...@@ -221,8 +217,6 @@ class LocalFileShuffle[K, V, C] extends Shuffle[K, V, C] with Logging {
} }
inputStream.close inputStream.close
logInfo ("Finished combining " + requestPath)
// Reception completed. Update stats. // Reception completed. Update stats.
hasSplitsBitVector.synchronized { hasSplitsBitVector.synchronized {
hasSplitsBitVector.set (splitIndex) hasSplitsBitVector.set (splitIndex)
...@@ -275,6 +269,14 @@ class LocalFileShuffle[K, V, C] extends Shuffle[K, V, C] with Logging { ...@@ -275,6 +269,14 @@ class LocalFileShuffle[K, V, C] extends Shuffle[K, V, C] with Logging {
} }
object LocalFileShuffle extends Logging { object LocalFileShuffle extends Logging {
// Used thoughout the code for small and large waits/timeouts
private var MinKnockInterval_ = 1000
private var MaxKnockInterval_ = 5000
// Maximum number of receiving and sending threads
private var MaxRxPeers_ = 4
private var MaxTxPeers_ = 4
private var initialized = false private var initialized = false
private var nextShuffleId = new AtomicLong(0) private var nextShuffleId = new AtomicLong(0)
...@@ -290,6 +292,17 @@ object LocalFileShuffle extends Logging { ...@@ -290,6 +292,17 @@ object LocalFileShuffle extends Logging {
private def initializeIfNeeded() = synchronized { private def initializeIfNeeded() = synchronized {
if (!initialized) { if (!initialized) {
// Load config parameters
MinKnockInterval_ =
System.getProperty ("spark.shuffle.MinKnockInterval", "1000").toInt
MaxKnockInterval_ =
System.getProperty ("spark.shuffle.MaxKnockInterval", "5000").toInt
MaxRxPeers_ =
System.getProperty ("spark.shuffle.MaxRxPeers", "4").toInt
MaxTxPeers_ =
System.getProperty ("spark.shuffle.MaxTxPeers", "4").toInt
// TODO: localDir should be created by some mechanism common to Spark // TODO: localDir should be created by some mechanism common to Spark
// so that it can be shared among shuffle, broadcast, etc // so that it can be shared among shuffle, broadcast, etc
val localDirRoot = System.getProperty("spark.local.dir", "/tmp") val localDirRoot = System.getProperty("spark.local.dir", "/tmp")
...@@ -330,6 +343,12 @@ object LocalFileShuffle extends Logging { ...@@ -330,6 +343,12 @@ object LocalFileShuffle extends Logging {
} }
} }
def MinKnockInterval = MinKnockInterval_
def MaxKnockInterval = MaxKnockInterval_
def MaxRxPeers = MaxRxPeers_
def MaxTxPeers = MaxTxPeers_
def getOutputFile(shuffleId: Long, inputId: Int, outputId: Int): File = { def getOutputFile(shuffleId: Long, inputId: Int, outputId: Int): File = {
initializeIfNeeded() initializeIfNeeded()
val dir = new File(shuffleDir, shuffleId + "/" + inputId) val dir = new File(shuffleDir, shuffleId + "/" + inputId)
...@@ -365,8 +384,7 @@ object LocalFileShuffle extends Logging { ...@@ -365,8 +384,7 @@ object LocalFileShuffle extends Logging {
class ShuffleServer class ShuffleServer
extends Thread with Logging { extends Thread with Logging {
// TODO: Set config param var threadPool = newDaemonFixedThreadPool(LocalFileShuffle.MaxRxPeers)
var threadPool = newDaemonFixedThreadPool(2)
var serverSocket: ServerSocket = null var serverSocket: ServerSocket = null
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment