Hi Chris, Thanks for the answer. I ended up extending the LocalJobFactory with my own class that register on the JVM Shutdown hook and when fired calls kill() and waitForFinish() on the ThreadJob.
I didn't want to rely on having a steady stream of events to shutdown the process using JMX and than call the task coordinator to stop the ThreadJob. Having a separate topic for control events looked like a good idea that I might implement if the JVM hooks will not succeed. Thanks, Dotan On Mon, Jul 14, 2014 at 6:00 PM, Chris Riccomini < [email protected]> wrote: > Hey Dotan, > > You can shutdown the container by calling coordinator.shutdown. > > To shutdown via JMX, you'd have to have your StreamTask expose a `Boolean > shutdown` variable via JMX. Then, in process(), you'd just check if > shutdown=true, and call coordinator.shutdown. If you go this route, the > SamzaContainer will log its JMX connection information in the Log4J logs, > like so: > > 17:32:19,199 INFO JmxServer:128 - Started JmxServer registry port=33957 > server port=33958 > url=service:jmx:rmi://localhost:33958/jndi/rmi://localhost:33957/jmxrmi > 17:32:19,201 INFO JmxServer:128 - If you are tunneling, you might want to > try JmxServer registry port=33957 server port=33958 > url=service:jmx:rmi://some-host:33958/jndi/rmi://eat1-app587.corp:33957/jmx > rmi > > You can use this information to connect via VisualVM or JConsole, and > trigger the Mbean. > > > An alternative shutdown style, which I'd recommend, is to use a control > stream. I'm going to assume you're using Kafka. If so, you can create > something like a "my-job-control-stream" topic. Your job should then be > configured to read from this stream. You can then send the topic a message > using kafka-console-producer.sh, and code your StreamTask to call > coordinator.shutdown anytime it receives a message from the stream. > > Either of these approaches should work. > > Cheers, > Chris > > On 7/14/14 2:38 AM, "Dotan Patrich" <[email protected]> wrote: > > >Hi, > > > >I'm trying to run a samza task using LocalJobFactory with a task that > >implements ClosableTask interface. > >One thing that I cannot figure out is how to gracefully shutdown the task > >container and call the close method? > >Is there some operation that does that and can be called using JMX? > > > >Thanks, > >Dotan > >
