Caleb,
I tend to use the version of lookup that does not take a RunId. That
will return all Controllers. I think your understanding of lookupLive
is correct. Looking at the code, it seems like the liveInfo is not
populated until there is some type of change in the application. This
is a bug. I will file a ticket.
-Martin
Hey Martin,
Thanks for the reply. I am trying to use the simple class name to do a lookup.
Here's an excerpt from client A:
String zkStr = args[0];
YarnConfiguration yarnConfiguration = new YarnConfiguration();
TwillRunnerService runner = new
YarnTwillRunnerService(yarnConfiguration, zkStr);
runner.start();
runner.prepare(new NotificationRunnable())
.addLogHandler(new PrinterLogHandler(new
PrintWriter(System.out)))
.start();
Here's an excerpt from client B:
String zkStr = args[0];
YarnConfiguration yarnConfiguration = new YarnConfiguration();
TwillRunnerService runner = new
YarnTwillRunnerService(yarnConfiguration, zkStr);
runner.start();
TwillController controller =
runner.lookup(NotificationRunnable.class.getSimpleName(),
RunIds.fromString("yarn_applicationId"));
Iterable<LiveInfo> info = runner.lookupLive();
for(LiveInfo i: info) {
System.out.println("LiveInfo is " + i.getApplicationName());
}
if(controller == null) {
System.out.println("No instances of NotificationRunnable are
running. Please start an instance of NotificationRunnable"
+ " before attempting to add or delete
notifications");
}
The runnable is pretty simple. It's implementing AbstractTwillRunnable, so the
application name should be the simple class name. When I run client A,
the main terminates and the runnable continues to run--I verify this by looking at the
running applications in Yarn. When I run client B, I use the
"yarn_applicationId"
that I see in Yarn to discover the controller. However, the controller that
gets returned is null and no LiveInfo gets returned, which is indicated by the
System.out.println().
Am I using the incorrect Id, or am I misinterpreting the use of
runner.lookupLive()?
Caleb A. Meier, Ph.D.
Software Engineer II ♦ Analyst
Parsons Corporation
1911 N. Fort Myer Drive, Suite 800 ♦ Arlington, VA 22209
Office: (703)797-3066
caleb.me...@parsons.com ♦ www.parsons.com
-----Original Message-----
From: Martin Serrano [mailto:mar...@attivio.com]
Sent: Friday, February 10, 2017 2:10 PM
To: dev@twill.apache.org
Cc: Meier, Caleb
Subject: Re: Gaining Control of Runnable after client terminates
Caleb,
Sorry, made a mistake there. In the simple case the application has the simple
classname, not the full one.
-Martin
On 02/10/2017 02:02 PM, Martin Serrano wrote:
Caleb,
The TwillRunnerService handles the ZK registration of applications for
you. When TwillClient B starts the service it can get the controllers
for the application via the TwillRunnerService.lookup method. If you
did not explicitly name your application, then your are probably using
the prepare method that names the application to the full classname of
your runnable.
-Martin
On 02/09/2017 10:53 AM, Meier, Caleb wrote:
Hello,
Suppose that I start an instance of NotificationRunnable with
TwillClient A. NotificationRunnable continues to run after
TwillClient A terminates (I no longer have a handle on the
YarnTwillRunner that prepared it), but I want to send a command to
NotificatonRunnable using an instance of TwillController that I
create in TwillClient B. Is this possible? It seems like I would
still need access to the YarnTwillRunner that started the
NotificationRunnable. I’m basing this on the source code for
YarnTwillRunner.lookup(…) – it seems like this method only returns
controllers for runnables that the enclosing instance of
YarnTwillRunner has prepared. Am I mistaken about this? If not, do
I need to explicitly register my application with a
ZkDiscoveryService and then look it up later through the same
service? Is there a better way to go about this?
Thanks,
Caleb A. Meier, Ph.D.
Software Engineer II ♦ Analyst
Parsons Corporation
1911 N. Fort Myer Drive, Suite 800 ♦ Arlington, VA 22209
Office: (703)797-3066
caleb.me...@parsons.com<mailto:caleb.me...@parsons.com> ♦
www.parsons.com<https://webportal.parsons.com/,DanaInfo=www.parsons.c
om+>