.setName(TwillAppNames.toTwillAppName(programRunId.getParent())) .withRunnable();
/** * Uses the given {@link TwillRunner} to lookup {@link RuntimeInfo} for the given program run. * * @param twillRunner the {@link TwillRunner} to lookup from * @param programRunId the program run id * @param twillRunId the twill {@link RunId} * @return the corresponding {@link RuntimeInfo} or {@code null} if no runtime information was found */ @Nullable protected RuntimeInfo lookupFromTwillRunner(TwillRunner twillRunner, ProgramRunId programRunId, RunId twillRunId) { TwillController twillController = twillRunner.lookup(TwillAppNames.toTwillAppName(programRunId.getParent()), twillRunId); if (twillController == null) { return null; } return createRuntimeInfo(programRunId.getParent(), RunIds.fromString(programRunId.getRun()), twillController); }
@Override public ProgramLiveInfo getLiveInfo(ProgramId program) { String twillAppName = TwillAppNames.toTwillAppName(program); Iterator<TwillController> controllers = twillRunner.lookup(twillAppName).iterator();
@Test public void test() { ProgramId serviceId = new NamespaceId("test_ns").app("my_app").service("myservice"); String twillAppName = TwillAppNames.toTwillAppName(serviceId); Assert.assertEquals("service.test_ns.my_app.myservice", twillAppName); Assert.assertEquals(serviceId, TwillAppNames.fromTwillAppName(twillAppName)); // parsing from twill app name can be optional (return null) Assert.assertNull(TwillAppNames.fromTwillAppName(Constants.Service.MASTER_SERVICES, false)); try { // if passing true, throws exception, when parsing is not possible TwillAppNames.fromTwillAppName(Constants.Service.MASTER_SERVICES, true); Assert.fail("Expected not being able to parse "); } catch (IllegalArgumentException e) { // expected Assert.assertTrue(e.getMessage().contains("does not match pattern for programs")); } } }
String twillNamespace = injector.getInstance(CConfiguration.class).get(Constants.CFG_TWILL_ZK_NAMESPACE); ZKClient twillZKClient = ZKClients.namespace(zkClient, twillNamespace + "/" + TwillAppNames.toTwillAppName(programId));