Github user tdas commented on the pull request:
https://github.com/apache/spark/pull/566#issuecomment-41611069
Hey @tmalaska, I pondered about the code a bit more, especially about the
lazy vals. The lazy val in this case is probably not a good idea. The receivers
are now (after #300) are designed to be restartable multiple times. So
onStart() + onStop() could be called multiple times if the receiver decides to
restart itself (to handle exceptions). In which case, start() will be called on
the netty server after it has been closed. I am not sure that is possible. So
its best to create a new NettyServer every time a onStart() is called, rather
than lazy initialize and use the netty server.
So its probably best to do something like this.
```
FlumeReceiver .... {
var server: NettyServer = null
def onStart() {
synchronized {
server = initServer()
server.start()
}
}
def onStop() {
synchronized {
if (server != null) {
server.stop()
}
}
}
...
}
```
---
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.
---