Skip to content

Commit

Permalink
formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kishorvpatil committed Sep 8, 2016
1 parent 99b1d1b commit 70a67fb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
43 changes: 22 additions & 21 deletions core/src/main/scala/org/apache/spark/launcher/LauncherBackend.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,26 @@ private[spark] abstract class LauncherBackend extends Logging {
}

def connect(port: Int, secret: String): Unit = {
if (port != None && secret != None) {
val s = new Socket(InetAddress.getLoopbackAddress(), port)
connection = new BackendConnection(s)
connection.send(new Hello(secret, SPARK_VERSION))
clientThread = LauncherBackend.threadFactory.newThread(connection)
clientThread.start()
_isConnected = true
if(stopFlag) {
logDebug("Adding shutdown hook") // force eager creation of logger
var _shutdownHookRef = ShutdownHookManager.addShutdownHook(
ShutdownHookManager.SPARK_CONTEXT_SHUTDOWN_PRIORITY) { () =>
logInfo("Invoking onStopRequest() from shutdown hook")
try {
if (_isConnected && stopFlag) {
onStopRequest()
}
}
catch {
case anotherIOE: IOException =>
logError("Error while running LauncherBackend shutdownHook...", anotherIOE)
val s = new Socket(InetAddress.getLoopbackAddress(), port)
connection = new BackendConnection(s)
connection.send(new Hello(secret, SPARK_VERSION))
clientThread = LauncherBackend.threadFactory.newThread(connection)
clientThread.start()
_isConnected = true
if (stopFlag) {
logDebug("Adding shutdown hook") // force eager creation of logger
var _shutdownHookRef = ShutdownHookManager.addShutdownHook(
ShutdownHookManager.SPARK_CONTEXT_SHUTDOWN_PRIORITY) { () =>
logInfo("Invoking onStopRequest() from shutdown hook")
try {
if (_isConnected && stopFlag) {
onStopRequest()
}
}
catch {
case anotherIOE: IOException =>
logError("Error while running LauncherBackend shutdownHook...", anotherIOE)
}
}
}
}
Expand Down Expand Up @@ -106,7 +104,7 @@ private[spark] abstract class LauncherBackend extends Logging {
if (connection != null && lastState != state) {
connection.send(new SetState(state))
lastState = state
if(!_isConnected && stopFlag) {
if (!_isConnected && stopFlag) {
fireStopRequest()
}
}
Expand Down Expand Up @@ -148,6 +146,9 @@ private[spark] abstract class LauncherBackend extends Logging {
override def close(): Unit = {
try {
super.close()
if (!_isConnected && stopFlag) {
fireStopRequest()
}
} finally {
onDisconnected()
_isConnected = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public abstract class AbstractSparkAppHandle implements SparkAppHandle {

OutputRedirector redirector;



public AbstractSparkAppHandle(LauncherServer server, String secret) {
this.server = server;
this.secret = secret;
Expand Down Expand Up @@ -135,4 +133,3 @@ private synchronized void fireEvent(boolean isInfoChanged) {
}

}

0 comments on commit 70a67fb

Please sign in to comment.