Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/5891#discussion_r29611874
--- Diff:
streaming/src/test/scala/org/apache/spark/streaming/InputStreamsSuite.scala ---
@@ -368,31 +381,42 @@ class TestServer(portToBind: Int = 0) extends Logging
{
val serverSocket = new ServerSocket(portToBind)
+ private val startLatch = new CountDownLatch(1)
+
val servingThread = new Thread() {
override def run() {
try {
while(true) {
logInfo("Accepting connections on port " + port)
val clientSocket = serverSocket.accept()
- logInfo("New connection")
- try {
- clientSocket.setTcpNoDelay(true)
- val outputStream = new BufferedWriter(
- new OutputStreamWriter(clientSocket.getOutputStream))
-
- while(clientSocket.isConnected) {
- val msg = queue.poll(100, TimeUnit.MILLISECONDS)
- if (msg != null) {
- outputStream.write(msg)
- outputStream.flush()
- logInfo("Message '" + msg + "' sent")
+ if (startLatch.getCount == 1) {
+ // The first connection is a test connection to implement
"waitForStart", so skip it
+ // and send a signal
+ clientSocket.close()
+ startLatch.countDown()
+ }
+ else {
--- End diff --
LGTM overall. One nit about this line, where the else should stay one line
above. You can wait a bit to see if there's more feedback before making more
changes. Maybe also change `if (!clientSocket.isClosed) clientSocket.close()`
to exist on two lines but this is trivial.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]