From f4482225c405b9cfe078deac74e4c28e2dcc97c3 Mon Sep 17 00:00:00 2001 From: hyukjinkwon Date: Fri, 12 Aug 2016 10:00:58 +0100 Subject: [MINOR][DOC] Fix style in examples across documentation ## What changes were proposed in this pull request? This PR fixes the documentation as below: - Python has 4 spaces and Java and Scala has 2 spaces (See https://cwiki.apache.org/confluence/display/SPARK/Spark+Code+Style+Guide). - Avoid excessive parentheses and curly braces for anonymous functions. (See https://github.com/databricks/scala-style-guide#anonymous) ## How was this patch tested? N/A Author: hyukjinkwon Closes #14593 from HyukjinKwon/minor-documentation. --- docs/streaming-custom-receivers.md | 48 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'docs/streaming-custom-receivers.md') diff --git a/docs/streaming-custom-receivers.md b/docs/streaming-custom-receivers.md index 479140f519..fae5901e8d 100644 --- a/docs/streaming-custom-receivers.md +++ b/docs/streaming-custom-receivers.md @@ -59,8 +59,8 @@ class CustomReceiver(host: String, port: Int) } def onStop() { - // There is nothing much to do as the thread calling receive() - // is designed to stop by itself if isStopped() returns false + // There is nothing much to do as the thread calling receive() + // is designed to stop by itself if isStopped() returns false } /** Create a socket connection and receive data until receiver is stopped */ @@ -68,29 +68,29 @@ class CustomReceiver(host: String, port: Int) var socket: Socket = null var userInput: String = null try { - // Connect to host:port - socket = new Socket(host, port) - - // Until stopped or connection broken continue reading - val reader = new BufferedReader( - new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8)) - userInput = reader.readLine() - while(!isStopped && userInput != null) { - store(userInput) - userInput = reader.readLine() - } - reader.close() - socket.close() - - // Restart in an attempt to connect again when server is active again - restart("Trying to connect again") + // Connect to host:port + socket = new Socket(host, port) + + // Until stopped or connection broken continue reading + val reader = new BufferedReader( + new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8)) + userInput = reader.readLine() + while(!isStopped && userInput != null) { + store(userInput) + userInput = reader.readLine() + } + reader.close() + socket.close() + + // Restart in an attempt to connect again when server is active again + restart("Trying to connect again") } catch { - case e: java.net.ConnectException => - // restart if could not connect to server - restart("Error connecting to " + host + ":" + port, e) - case t: Throwable => - // restart if there is any other error - restart("Error receiving data", t) + case e: java.net.ConnectException => + // restart if could not connect to server + restart("Error connecting to " + host + ":" + port, e) + case t: Throwable => + // restart if there is any other error + restart("Error receiving data", t) } } } -- cgit v1.2.3