@Override public Future<Integer> changeInstances(String runnable, int newCount) { return delegate.changeInstances(runnable, newCount); }
@Override public Future<Integer> changeInstances(String runnable, int newCount) { return delegate.changeInstances(runnable, newCount); }
@Override public boolean setInstances(int instanceCount) { Preconditions.checkArgument(instanceCount > 0); try { Iterable<TwillController> twillControllerList = twillRunnerService.lookup(Constants.Service.MASTER_SERVICES); if (twillControllerList != null) { for (TwillController twillController : twillControllerList) { twillController.changeInstances(serviceName, instanceCount).get(); } } return true; } catch (Throwable t) { LOG.error("Could not change service instance of {} : {}", serviceName, t.getMessage(), t); return false; } }
@Override public boolean setInstances(int instanceCount) { Preconditions.checkArgument(instanceCount > 0); try { Iterable<TwillController> twillControllerList = twillRunnerService.lookup(Constants.Service.MASTER_SERVICES); if (twillControllerList != null) { for (TwillController twillController : twillControllerList) { twillController.changeInstances(serviceName, instanceCount).get(); } } return true; } catch (Throwable t) { LOG.error("Could not change service instance of {} : {}", serviceName, t.getMessage(), t); return false; } }
private synchronized void changeInstances(String runnableId, int newInstanceCount, int oldInstanceCount) throws Exception { LOG.info("Changing instances of {} from {} to {}", getProgramRunId(), oldInstanceCount, newInstanceCount); getTwillController().changeInstances(runnableId, newInstanceCount).get(); LOG.info("Completed changing instances of {} from {} to {}", getProgramRunId(), oldInstanceCount, newInstanceCount); } }
private synchronized void changeInstances(String runnableId, int newInstanceCount, int oldInstanceCount) throws Exception { LOG.info("Changing instances of {} from {} to {}", getProgramRunId(), oldInstanceCount, newInstanceCount); getTwillController().changeInstances(runnableId, newInstanceCount).get(); LOG.info("Completed changing instances of {} from {} to {}", getProgramRunId(), oldInstanceCount, newInstanceCount); } }
private synchronized void changeInstances(String runnableId, int newInstanceCount, int oldInstanceCount) throws Exception { LOG.info("Changing instances of {} from {} to {}", getProgramRunId(), oldInstanceCount, newInstanceCount); getTwillController().changeInstances(runnableId, newInstanceCount).get(); LOG.info("Completed changing instances of {} from {} to {}", getProgramRunId(), oldInstanceCount, newInstanceCount); } }
private synchronized void changeInstances(String runnableId, int newInstanceCount, int oldInstanceCount) throws Exception { LOG.info("Changing instances of {} from {} to {}", getProgramRunId(), oldInstanceCount, newInstanceCount); getTwillController().changeInstances(runnableId, newInstanceCount).get(); LOG.info("Completed changing instances of {} from {} to {}", getProgramRunId(), oldInstanceCount, newInstanceCount); } }
void update(String flowletId, int newInstanceCount, int oldInstanceCount) throws Exception { FlowletDefinition flowletDefinition = program.getSpecification().getFlowlets().get(flowletId); int maxInstances = flowletDefinition.getFlowletSpec().getMaxInstances(); Preconditions.checkArgument(newInstanceCount <= maxInstances, "Flowlet %s can have a maximum of %s instances", flowletId, maxInstances); waitForInstances(flowletId, oldInstanceCount); twillController.sendCommand(flowletId, ProgramCommands.SUSPEND).get(); FlowUtils.reconfigure(consumerQueues.get(flowletId), FlowUtils.generateConsumerGroupId(program, flowletId), newInstanceCount, queueAdmin); twillController.changeInstances(flowletId, newInstanceCount).get(); twillController.sendCommand(flowletId, ProgramCommands.RESUME).get(); }
void update(final String flowletId, final int newInstanceCount, FlowSpecification flowSpec) throws Exception { // Find all flowlets that are source of the given flowletId. Set<String> flowlets = getUpstreamFlowlets(flowSpec, flowletId, Sets.<String>newHashSet()); flowlets.add(flowletId); // Suspend all upstream flowlets and the flowlet that is going to change instances for (String id : flowlets) { waitForInstances(id, getInstances(flowSpec, id)); // Need to suspend one by one due to a bug in Twill (TWILL-123) twillController.sendCommand(id, ProgramCommands.SUSPEND).get(); } impersonator.doAs(programId, new Callable<Void>() { @Override public Void call() throws Exception { FlowUtils.reconfigure(consumerQueues.get(flowletId), FlowUtils.generateConsumerGroupId(programId, flowletId), newInstanceCount, streamAdmin, queueAdmin, txExecutorFactory); return null; } }); twillController.changeInstances(flowletId, newInstanceCount).get(); for (String id : flowlets) { twillController.sendCommand(id, ProgramCommands.RESUME).get(); } }
private ClusterEnriched resizeClusterAsync(Cluster cluster) throws YarnProvisioningHandlingException { int requestedContainerCount = cluster.getClusterConfig().getClusterSpec().getContainerCount().intValue(); TwillController controller = getTwillControllerHelper(cluster); if (controller != null) { // async call controller.changeInstances(DacDaemonYarnApplication.YARN_RUNNABLE_NAME, requestedContainerCount); cluster.getClusterConfig().getClusterSpec().setContainerCount(requestedContainerCount); return getClusterInfo(cluster); } throw new YarnProvisioningHandlingException("Can not find running application. Unable to resize. May be a " + "temporary condition"); }
LogEntry.Level.WARN); controller.updateLogLevels(LogLevelTestSecondRunnable.class.getSimpleName(), logLevelSecondRunnable).get(); controller.changeInstances(LogLevelTestSecondRunnable.class.getSimpleName(), 2).get(); TimeUnit.SECONDS.sleep(5); waitForLogLevel(controller, LogLevelTestSecondRunnable.class.getSimpleName(), 20L, TimeUnit.SECONDS,
controller.changeInstances(FailingInstanceServer.class.getSimpleName(), 3); retriesExhausted.await(); Assert.assertEquals(3, retriesSeen.get());
allAsList(controller.changeInstances(HANGING_RUNNABLE, 3), controller.changeInstances(STOPPING_RUNNABLE, 2) ).get(120, TimeUnit.SECONDS); waitForInstance(controller, HANGING_RUNNABLE, "005", 120, TimeUnit.SECONDS); // +2 containers allAsList(controller.changeInstances(HANGING_RUNNABLE, 1), controller.changeInstances(STOPPING_RUNNABLE, 1) ).get(120, TimeUnit.SECONDS); waitForInstance(controller, HANGING_RUNNABLE, "007", 120, TimeUnit.SECONDS);
controller.changeInstances("Alice", 4).get(60, TimeUnit.SECONDS); serviceDiscovered = controller.discoverService("DistributedTest"); Assert.assertTrue(waitForSize(serviceDiscovered, 6, 60)); controller.changeInstances("Alice", 1).get(60, TimeUnit.SECONDS); serviceDiscovered = controller.discoverService("DistributedTest"); Assert.assertTrue(waitForSize(serviceDiscovered, 3, 60)); controller.changeInstances("Bob", 3).get(60, TimeUnit.SECONDS); serviceDiscovered = controller.discoverService("DistributedTest"); Assert.assertTrue(waitForSize(serviceDiscovered, 5, 60)); controller.changeInstances("Eve", 3).get(60, TimeUnit.SECONDS); serviceDiscovered = controller.discoverService("DistributedTest"); Assert.assertTrue(waitForSize(serviceDiscovered, 7, 60));
controller.changeInstances("EchoServer", 3).get(60, TimeUnit.SECONDS); Assert.assertTrue(waitForSize(echoServices, 3, 120)); controller.changeInstances("EchoServer", 1).get(60, TimeUnit.SECONDS); Assert.assertTrue(waitForSize(echoServices, 1, 120)); controller.changeInstances("EchoServer", 2).get(60, TimeUnit.SECONDS); Assert.assertTrue(waitForSize(echoServices, 2, 120));
controller.changeInstances("Alice", 2).get(60, TimeUnit.SECONDS); serviceDiscovered = controller.discoverService("DistributedTest"); Assert.assertTrue(waitForSize(serviceDiscovered, 4, 60)); controller.changeInstances("Eve", 2).get(60, TimeUnit.SECONDS); serviceDiscovered = controller.discoverService("DistributedTest"); Assert.assertTrue(waitForSize(serviceDiscovered, 5, 60)); controller.changeInstances("Bob", 2).get(60, TimeUnit.SECONDS); serviceDiscovered = controller.discoverService("DistributedTest"); Assert.assertTrue(waitForSize(serviceDiscovered, 6, 60));
controller.changeInstances("echo1", 1).get(60, TimeUnit.SECONDS); echoServices = controller.discoverService("echo1"); Assert.assertTrue(waitForSize(echoServices, 1, 60));