HI Terence,
Below is my sample implementation:
I verified in the logs and could not find message coming out of "stop" API.
under logs\userlogs directory, I could see that I have 4 container sub
folders (b'cos I have 3 runnables and one container master) and I don't see
the log from stop method.
private static class *ThirdHelloWorldRunnable* extends
AbstractTwillRunnable {
String m_desc;
public ThirdHelloWorldRunnable(String desc){
m_desc = desc;
}
//@Override
public void run() {
LOG.info("Hello Third World. My another runnable program");
}
*@Override*
* public void stop() {*
* LOG.info("Third World. Invoked Stopped...");*
* }*
}
private static class MyRedTwillApplication implements TwillApplication{
//@Override
public TwillSpecification configure() {
return TwillSpecification.Builder.with()
.setName("MyReddyTwillApplication") .withRunnable()
.add("HelloSriniWorld", new HelloWorldRunnable("Red")).noLocalFiles()
.add("HelloSecondWorld", new SecondHelloWorldRunnable("Red")).noLocalFiles()
.add("*HelloThirdWorld*", new *ThirdHelloWorldRunnable*
("Red")).noLocalFiles()
.anyOrder()
.build();
}
}
Public static void main(String args[]){
final TwillRunnerService twillRunner =
new YarnTwillRunnerService(
new YarnConfiguration(), "localhost:2181");
twillRunner.startAndWait();
final TwillController controller = twillRunner.prepare(new
MyRedTwillApplication())
.addLogHandler( new PrinterLogHandler(new PrintWriter(System.out, true)))
.start();
*Runtime.getRuntime().addShutdownHook(new Thread() {*
* @Override*
* public void run() {*
* controller.stopAndWait();*
* } *
* });*
try {
Services.getCompletionFuture(controller).get();
//Services.getCompletionFuture(controller1).get();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
*twillRunner.stopAndWait();*
}
Thanks and regards,
Srini
On Tue, Oct 7, 2014 at 11:33 AM, Terence Yim <[email protected]> wrote:
> Hi Srini,
>
> So I assume you want to stop the Twill application when the client
> shutdown, right? How do you know if the stop method of the
> TwillRunnable has been executed or not? Can you show your
> implementation of TwillRunnable so that I can take a look?
>
> Thanks,
> Terence
>
> On Sat, Oct 4, 2014 at 5:46 PM, Srinivas Reddy Kancharla
> <[email protected]> wrote:
> > Hi,
> >
> > I have 3 AbstractTwillRunnable runnables added to my Twill application
> > which is getting executed successfully. But I am failing to execute
> "stop"
> > method of AbstractTwillRunnable which I override.
> > I am expecting the stop to be invoked for below call:
> >
> > Runtime.getRuntime().addShutdownHook(new Thread() {
> > @Override
> > public void run() {
> > *controller.stopAndWait();*
> > }
> > });
> >
> > "controller" is an instance of TwillController.
> >
> > Also I tried twillRunner.stopAndWait(); where twillRunner is an instance
> of
> > TwillRunnerService. Is there anything I am missing to invoke "stop"
> method?
> >
> > Thanks and regards,
> > Srini
>