aboutsummaryrefslogtreecommitdiff
path: root/docs/streaming-custom-receivers.md
diff options
context:
space:
mode:
authorhyukjinkwon <gurwls223@gmail.com>2016-08-12 10:00:58 +0100
committerSean Owen <sowen@cloudera.com>2016-08-12 10:00:58 +0100
commitf4482225c405b9cfe078deac74e4c28e2dcc97c3 (patch)
treeeacdde1d4a2cab3177e63029a7f532c498a34454 /docs/streaming-custom-receivers.md
parent993923c8f5ca719daf905285738b7fdcaf944d8c (diff)
downloadspark-f4482225c405b9cfe078deac74e4c28e2dcc97c3.tar.gz
spark-f4482225c405b9cfe078deac74e4c28e2dcc97c3.tar.bz2
spark-f4482225c405b9cfe078deac74e4c28e2dcc97c3.zip
[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 <gurwls223@gmail.com> Closes #14593 from HyukjinKwon/minor-documentation.
Diffstat (limited to 'docs/streaming-custom-receivers.md')
-rw-r--r--docs/streaming-custom-receivers.md48
1 files changed, 24 insertions, 24 deletions
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)
}
}
}