Skip to content

Commit 4d8ae70

Browse files
hsaputrarxin
authored andcommitted
Cleanup on Connection and ConnectionManager
Simple cleanup on Connection and ConnectionManager to make IDE happy while working of issue: 1. Replace var with var 2. Add parentheses to Queue#dequeu to be consistent with side-effects. 3. Remove return on final line of a method. Author: Henry Saputra <[email protected]> Closes #1060 from hsaputra/cleanup_connection_classes and squashes the following commits: 245fd09 [Henry Saputra] Cleanup on Connection and ConnectionManager to make IDE happy while working of issue: 1. Replace var with var 2. Add parentheses to Queue#dequeu to be consistent with side-effects. 3. Remove return on final line of a method.
1 parent e056320 commit 4d8ae70

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

core/src/main/scala/org/apache/spark/network/Connection.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class SendingConnection(val address: InetSocketAddress, selector_ : Selector,
210210
var nextMessageToBeUsed = 0
211211

212212
def addMessage(message: Message) {
213-
messages.synchronized{
213+
messages.synchronized {
214214
/* messages += message */
215215
messages.enqueue(message)
216216
logDebug("Added [" + message + "] to outbox for sending to " +
@@ -223,7 +223,7 @@ class SendingConnection(val address: InetSocketAddress, selector_ : Selector,
223223
while (!messages.isEmpty) {
224224
/* nextMessageToBeUsed = nextMessageToBeUsed % messages.size */
225225
/* val message = messages(nextMessageToBeUsed) */
226-
val message = messages.dequeue
226+
val message = messages.dequeue()
227227
val chunk = message.getChunkForSending(defaultChunkSize)
228228
if (chunk.isDefined) {
229229
messages.enqueue(message)

core/src/main/scala/org/apache/spark/network/ConnectionManager.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,14 @@ private[spark] class ConnectionManager(port: Int, conf: SparkConf,
250250
try {
251251
while(!selectorThread.isInterrupted) {
252252
while (! registerRequests.isEmpty) {
253-
val conn: SendingConnection = registerRequests.dequeue
253+
val conn: SendingConnection = registerRequests.dequeue()
254254
addListeners(conn)
255255
conn.connect()
256256
addConnection(conn)
257257
}
258258

259259
while(!keyInterestChangeRequests.isEmpty) {
260-
val (key, ops) = keyInterestChangeRequests.dequeue
260+
val (key, ops) = keyInterestChangeRequests.dequeue()
261261

262262
try {
263263
if (key.isValid) {
@@ -532,9 +532,9 @@ private[spark] class ConnectionManager(port: Int, conf: SparkConf,
532532
}
533533
return
534534
}
535-
var securityMsgResp = SecurityMessage.fromResponse(replyToken,
535+
val securityMsgResp = SecurityMessage.fromResponse(replyToken,
536536
securityMsg.getConnectionId.toString())
537-
var message = securityMsgResp.toBufferMessage
537+
val message = securityMsgResp.toBufferMessage
538538
if (message == null) throw new Exception("Error creating security message")
539539
sendSecurityMessage(waitingConn.getRemoteConnectionManagerId(), message)
540540
} catch {
@@ -568,9 +568,9 @@ private[spark] class ConnectionManager(port: Int, conf: SparkConf,
568568
logDebug("Server sasl not completed: " + connection.connectionId)
569569
}
570570
if (replyToken != null) {
571-
var securityMsgResp = SecurityMessage.fromResponse(replyToken,
571+
val securityMsgResp = SecurityMessage.fromResponse(replyToken,
572572
securityMsg.getConnectionId)
573-
var message = securityMsgResp.toBufferMessage
573+
val message = securityMsgResp.toBufferMessage
574574
if (message == null) throw new Exception("Error creating security Message")
575575
sendSecurityMessage(connection.getRemoteConnectionManagerId(), message)
576576
}
@@ -618,7 +618,7 @@ private[spark] class ConnectionManager(port: Int, conf: SparkConf,
618618
return true
619619
}
620620
}
621-
return false
621+
false
622622
}
623623

624624
private def handleMessage(
@@ -694,9 +694,9 @@ private[spark] class ConnectionManager(port: Int, conf: SparkConf,
694694
var firstResponse: Array[Byte] = null
695695
try {
696696
firstResponse = conn.sparkSaslClient.firstToken()
697-
var securityMsg = SecurityMessage.fromResponse(firstResponse,
697+
val securityMsg = SecurityMessage.fromResponse(firstResponse,
698698
conn.connectionId.toString())
699-
var message = securityMsg.toBufferMessage
699+
val message = securityMsg.toBufferMessage
700700
if (message == null) throw new Exception("Error creating security message")
701701
connectionsAwaitingSasl += ((conn.connectionId, conn))
702702
sendSecurityMessage(connManagerId, message)

0 commit comments

Comments
 (0)