In my RecordProcessor implementation, I override shutdown() to capture stats from local Ostrich webserver. I discovered that at times, seemingly haphazardly, statistics were not captured. I traced the root cause of the issue to be the 'oneway' modifier on the ParrotServerService.shutdown() definition. I understand the 'oneway' Thrift modifier causes an RPC call to be async. For my use case, I believe the parrot-server is shutdown before the stats logic can be captured because the invoker of shutdown() does not await a response.
I changed the Thrift definition from:
oneway void shutdown()
to:
void shutdown()
This makes shutdown() invocations synchronous and addresses my problem (i.e. stats are captured via shutdown hook). This change results in a parrot-feeder exception at shutdown. It appears the exception is harmless and I haven't had time to investigate further. Here is the exception:
ERR [20130626-13:18:12.682] util: Error shutting down Parrot: com.twitter.finagle.ChannelClosedException
ERR [20130626-13:18:12.682] util: com.twitter.finagle.ChannelClosedException: ChannelException at remote address: localhost/
127.0.0.1:9999ERR [20130626-13:18:12.682] util: at com.twitter.finagle.NoStacktrace(Unknown Source)
What was the rationale behind marking shutdown() 'oneway'? The justification that comes to mind is to ensure nothing blocks during shutdown (i.e. parrot-server shutdown() is not intended to be long-running). If that's the case, is there a better way to instrument capturing stats at shutdown?
If making the shutdown() call synchronous is the way to go, I can clean up the exception I show above and send a pull request. I appreciate the team's responsiveness.
Michael