@Override public T get() { return task.asTask().getUnchecked(); } };
@Override public Collection<Application> get() { return mgmt.getApplications(); } }
@Override public int compare(Task<?> t1, Task<?> t2) { long end1 = t1.getEndTimeUtc(); long end2 = t2.getEndTimeUtc(); return (end1 < end2) ? -1 : ((end1 == end2) ? 0 : 1); } };
@SuppressWarnings({ "unchecked", "rawtypes" }) private ConcreteLocation createConcrete(Class<?> extensionType, Object extension) { // this cast is needed to make IntelliJ happy return (ConcreteLocation) mgmt.getLocationManager().createLocation(LocationSpec.create(ConcreteLocation.class).extension((Class)extensionType, extension)); }
@Override public void reloaded() { Location resolved = context.getLocationRegistry().resolve(definition); context.getLocationRegistry().updateDefinedLocation(definition); context.getLocationManager().manage(resolved); } };
@Override protected Location getInstanceFromId(String id) { return mgmt.getLocationManager().getLocation(id); } }
@Override protected Entity getInstanceFromId(String id) { return mgmt.getEntityManager().getEntity(id); } }
/** * Submits a task to run at the entity. * * @return the task passed in, for fluency */ public static <T extends TaskAdaptable<?>> T submit(final Entity entity, final T task) { final ExecutionContext executionContext = ((EntityInternal)entity).getExecutionContext(); executionContext.submit(task.asTask()); return task; }
protected SshPutTaskWrapper submit(final SshPutTaskFactory tf) { SshPutTaskWrapper t = tf.newTask(); mgmt.getExecutionManager().submit(t); return t; }
@Override protected Task<?> customReadBody(String type, Map<Object, Object> values, JsonParser jp, DeserializationContext ctxt) throws IOException { return mgmt.getExecutionManager().getTask((String) values.get("id")); } }
@Override public boolean apply(Task<?> input) { return (input != null) && input.isDone(); } @Override
@Override public boolean apply(Task<?> input) { return input.isError(); } });
private static Task<?>[] asTasks(TaskAdaptable<?> ...tasks) { Task<?>[] result = new Task<?>[tasks.length]; for (int i=0; i<tasks.length; i++) result[i] = tasks[i].asTask(); return result; }
public static ManagementContext getManagementContext(Task<?> task) { for (Object tag : task.getTags()) if ((tag instanceof ManagementContext)) return (ManagementContext) tag; return null; }
/** @see SubscriptionManager#publish(SensorEvent) */ @Override public <T> void publish(SensorEvent<T> event) { manager.publish(event); }
@Override public Response canManageEntity(Entity entity) { return (entityManagementAllowed ? Response.allowed() : Response.disallowed("entity management disabled")); } }
/** * @return {@link ManagementContext#getManagementNodeUri()}, located in this utility class for convenience. */ public static Maybe<URI> getBrooklynWebUri(ManagementContext mgmt) { return mgmt.getManagementNodeUri(); }
/** * Whether we have been stopped, ie are stopping are or fully stopped, * in which case will not persist or store anything * (except for a final internal persistence called while STOPPING.) */ private boolean isStopped() { return state == ListenerState.STOPPING || state == ListenerState.STOPPED || executionContext.isShutdown(); }
/** Return the subscriptions associated with this context */ @Override public Set<SubscriptionHandle> getSubscriptions() { return manager.getSubscriptionsForSubscriber(subscriber); }
public static CountingBailOutJcloudsLocation newCountingBailOutJcloudsLocation(ManagementContext mgmt, Map flags) { LocationSpec<CountingBailOutJcloudsLocation> spec = LocationSpec.create(CountingBailOutJcloudsLocation.class) .configure(flags); return mgmt.getLocationManager().createLocation(spec); }