Iterator<String> order = iterator.next().iterator(); Preconditions.checkArgument(order.hasNext(), "Runnable launch order should have at least one runnable name"); Builder.NextOrder nextOrder = runnableSetter.withOrder().begin(order.next(), Iterators.toArray(order, String.class)); afterOrder = nextOrder;
Iterator<String> order = iterator.next().iterator(); Preconditions.checkArgument(order.hasNext(), "Runnable launch order should have at least one runnable name"); Builder.NextOrder nextOrder = runnableSetter.withOrder().begin(order.next(), Iterators.toArray(order, String.class)); afterOrder = nextOrder;
String[] flowletArray = new String[flowletNames.size()]; flowletArray = flowletNames.toArray(flowletArray); return runnableSetter.withOrder().begin(TXMANAGER).nextWhenStarted(firstFlowlet, flowletArray) .withEventHandler(eventHandler).build();
.begin(org.apache.fluo.cluster.runnable.OracleRunnable.ORACLE_NAME) .nextWhenStarted(org.apache.fluo.cluster.runnable.WorkerRunnable.WORKER_NAME).build();
.begin(org.apache.fluo.cluster.runnable.OracleRunnable.ORACLE_NAME) .nextWhenStarted(org.apache.fluo.cluster.runnable.WorkerRunnable.WORKER_NAME).build();
return runnableSetter.withOrder().begin(FluoOracleMain.ORACLE_NAME) .nextWhenStarted(FluoWorkerMain.WORKER_NAME).build();
@Override public TwillSpecification configure() { // It is always present in cdap-default.xml final long noContainerTimeout = cConf.getLong(Constants.CFG_TWILL_NO_CONTAINER_TIMEOUT, Long.MAX_VALUE); TwillSpecification.Builder.RunnableSetter runnableSetter = addMessaging( addDatasetOpExecutor( addLogSaverService( addTransactionService( addMetricsProcessor ( addMetricsService( TwillSpecification.Builder.with().setName(NAME).withRunnable() ) ) ) ) ) ); if (cConf.getBoolean(Constants.Explore.EXPLORE_ENABLED)) { LOG.info("Adding explore runnable."); runnableSetter = addExploreService(runnableSetter); } else { LOG.info("Explore module disabled - will not launch explore runnable."); } return runnableSetter .withOrder() .begin(Constants.Service.MESSAGING_SERVICE, Constants.Service.TRANSACTION, Constants.Service.DATASET_EXECUTOR) .withEventHandler(new AbortOnTimeoutEventHandler(noContainerTimeout)) .build(); }
@Override public TwillSpecification configure() { ResourceSpecification largeRes = ResourceSpecification.Builder.with() .setVirtualCores(1) .setMemory(1024, ResourceSpecification.SizeUnit.MEGA) .build(); ResourceSpecification smallRes = ResourceSpecification.Builder.with() .setVirtualCores(1) .setMemory(512, ResourceSpecification.SizeUnit.MEGA) .build(); return TwillSpecification.Builder.with() .setName("SleepApp") .withRunnable() .add("sleep1", new SleepRunnable(12345), largeRes).noLocalFiles() .add("sleep2", new SleepRunnable(12346), smallRes).noLocalFiles() .withOrder() .begin("sleep1") .nextWhenStarted("sleep2") .build(); } }
@Test public void testOrder() { TwillSpecification spec = TwillSpecification.Builder.with() .setName("Testing") .withRunnable() .add("r1", new DummyRunnable()).noLocalFiles() .add("r2", new DummyRunnable()).noLocalFiles() .add("r3", new DummyRunnable()).noLocalFiles() .add("r4", new DummyRunnable()).noLocalFiles() .withOrder().begin("r1", "r2").nextWhenStarted("r3") .build(); Assert.assertEquals(4, spec.getRunnables().size()); List<TwillSpecification.Order> orders = spec.getOrders(); Assert.assertEquals(3, orders.size()); Assert.assertEquals(ImmutableSet.of("r1", "r2"), orders.get(0).getNames()); Assert.assertEquals(ImmutableSet.of("r3"), orders.get(1).getNames()); Assert.assertEquals(ImmutableSet.of("r4"), orders.get(2).getNames()); } }
@Override public TwillSpecification configure() { return TwillSpecification.Builder.with() .setName(RestartTestApplication.class.getSimpleName()) .withRunnable() .add(HANGING_RUNNABLE, new HangingRunnable()).noLocalFiles() .add(STOPPING_RUNNABLE, new StoppingRunnable()).noLocalFiles() .withOrder() .begin(HANGING_RUNNABLE) .nextWhenStarted(STOPPING_RUNNABLE) .build(); } }