Java Code Examples for org.apache.brooklyn.core.effector.Effectors#invocation()
The following examples show how to use
org.apache.brooklyn.core.effector.Effectors#invocation() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BrooklynNodeImpl.java From brooklyn-server with Apache License 2.0 | 5 votes |
private void queueShutdownTask() { ConfigBag stopParameters = BrooklynTaskTags.getCurrentEffectorParameters(); ConfigBag shutdownParameters; if (stopParameters != null) { shutdownParameters = ConfigBag.newInstanceCopying(stopParameters); } else { shutdownParameters = ConfigBag.newInstance(); } shutdownParameters.putIfAbsent(ShutdownEffector.REQUEST_TIMEOUT, Duration.ONE_MINUTE); shutdownParameters.putIfAbsent(ShutdownEffector.FORCE_SHUTDOWN_ON_ERROR, Boolean.TRUE); TaskAdaptable<Void> shutdownTask = Effectors.invocation(this, SHUTDOWN, shutdownParameters); //Mark inessential so that even if it fails the process stop task will run afterwards to clean up. TaskTags.markInessential(shutdownTask); DynamicTasks.queue(shutdownTask); }
Example 2
Source File: ApplicationLoggingTest.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Test public void testLogging() throws Exception { String loggerName = ApplicationLoggingTest.class.getName(); ch.qos.logback.classic.Level logLevel = ch.qos.logback.classic.Level.INFO; Deque<String> ids = new ArrayDeque<>(); ids.push(app.getId()); final TestEntityWithLogging entity = app.createAndManageChild(EntitySpec.create(TestEntityWithLogging.class)); final TestEntityWithLogging child = entity.addChild(EntitySpec.create(EntitySpec.create(TestEntityWithLogging.class))); try (LogWatcher watcher = new LogWatcher(loggerName, logLevel, containsMessage(app.getId()))) { app.start(ImmutableList.of(app.newSimulatedLocation())); assertHealthEventually(app, Lifecycle.RUNNING, true); final TaskAdaptable<Void> stopTask = Effectors.invocation(app, Startable.STOP, ImmutableMap.of()); final String stopId = stopTask.asTask().getId(); LOG.info("Stop task id is {}", stopId); final ExecutionContext executionContext = mgmt.getExecutionContext(app); executionContext.submit(stopTask); assertHealthEventually(app, Lifecycle.STOPPED, false); // Look for output like // 2018-02-05 16:23:11,485 INFO K09KEX1U-[y4lgil3hya,xn0fmqrhzd,khx0py82ba] Hello from entity khx0py82ba // 2018-02-05 16:23:11,488 INFO kD8Q76x0-[y4lgil3hya,xn0fmqrhzd] Hello from entity xn0fmqrhzd // 2018-02-05 16:23:11,488 INFO ZsU4OGEp-[y4lgil3hya] Hello world // 2018-02-05 16:23:11,496 INFO - Stop task id is pOp03ybS // 2018-02-05 16:23:11,498 INFO pOp03ybS-[y4lgil3hya] Goodbye cruel world // 2018-02-05 16:23:11,499 INFO c1Pcn3FR-[y4lgil3hya,xn0fmqrhzd] Goodbye from entity xn0fmqrhzd // 2018-02-05 16:23:11,500 INFO eq9akWgK-[y4lgil3hya,xn0fmqrhzd,khx0py82ba] Goodbye from entity khx0py82ba watcher.assertHasEvent(containsMessage(stopId + "-")); watcher.assertHasEvent(matchingRegexes(".*" + app.getApplicationId() + ".*Hello world.*"));; watcher.assertHasEvent(matchingRegexes(".*" + ImmutableList.of(app.getId(), entity.getId()).toString() + ".*from entity.*" + entity.getId() + ".*")); watcher.assertHasEvent(matchingRegexes(".*" + ImmutableList.of(app.getId(), entity.getId(), child.getId()).toString() + ".*from entity.*" + child.getId() + ".*")); } }
Example 3
Source File: StartableMethods.java From brooklyn-server with Apache License 2.0 | 4 votes |
/** unsubmitted task for starting children of the given entity at the given locations */ public static TaskAdaptable<?> startingChildren(Entity entity, Iterable<? extends Location> locations) { return Effectors.invocation(Startable.START, MutableMap.of("locations", locations), filterStartableManagedEntities(entity.getChildren())); }
Example 4
Source File: StartableMethods.java From brooklyn-server with Apache License 2.0 | 4 votes |
/** unsubmitted task for stopping children of the given entity */ public static TaskAdaptable<?> stoppingChildren(Entity entity) { return Effectors.invocation(Startable.STOP, Collections.emptyMap(), filterStartableManagedEntities(entity.getChildren())); }
Example 5
Source File: StartableMethods.java From brooklyn-server with Apache License 2.0 | 4 votes |
/** unsubmitted task for restarting children of the given entity */ public static TaskAdaptable<?> restartingChildren(Entity entity, ConfigBag parameters) { return Effectors.invocation(Startable.RESTART, parameters.getAllConfig(), filterStartableManagedEntities(entity.getChildren())); }