public class Entities
extends java.lang.Object
Also see the various *Methods
classes for traits,
such as StartableMethods
for Startable
implementations.
Modifier and Type | Field and Description |
---|---|
static java.lang.Object |
REMOVE
Special object used by some setting methods to indicate that a value should be removed.
|
static java.util.List<java.lang.String> |
SECRET_NAMES
Deprecated.
since 0.7; instead use
Sanitizer.SECRET_NAMES |
static java.lang.Object |
UNCHANGED
Special object used by some setting methods to indicate that a value should be ignored.
|
Constructor and Description |
---|
Entities() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Iterable<Entity> |
ancestors(Entity root)
Returns the entity, its parent, its parent, and so on.
|
static <T> com.google.common.base.Supplier<T> |
attributeSupplier(EntityAndAttribute<T> tuple) |
static <T> com.google.common.base.Supplier<T> |
attributeSupplier(Entity entity,
AttributeSensor<T> sensor) |
static <T> com.google.common.base.Supplier<T> |
attributeSupplierWhenReady(EntityAndAttribute<T> tuple) |
static <T> com.google.common.base.Supplier<T> |
attributeSupplierWhenReady(Entity entity,
AttributeSensor<T> sensor) |
static java.lang.String |
checkRequiredUrl(Entity entity,
java.lang.String url)
Fails-fast if value of the given URL is null or unresolveable.
|
static AbstractEntity |
deproxy(Entity e)
Unwraps a proxy to retrieve the real item, if available.
|
static java.lang.Iterable<Entity> |
descendants(Entity root)
Returns the entity, its children, and all its children, and so on.
|
static <T extends Entity> |
descendants(Entity root,
java.lang.Class<T> ofType)
Return all descendants of given entity of the given type, potentially including the given root.
|
static java.lang.Iterable<Entity> |
descendants(Entity root,
com.google.common.base.Predicate<? super Entity> matching)
Returns the entity matching the given predicate
|
static java.lang.Iterable<Entity> |
descendants(Entity root,
com.google.common.base.Predicate<? super Entity> matching,
boolean includeSelf)
Return all descendants of given entity matching the given predicate and optionally the entity itself.
|
static void |
destroy(Entity e)
Attempts to stop, destroy, and unmanage the given entity.
|
static void |
destroy(Location loc)
Destroys the given location.
|
static void |
destroyAll(ManagementContext mgmt)
Stops, destroys, and unmanages all apps in the given context, and then terminates the management context.
|
static void |
destroyAllCatching(ManagementContext mgmt)
Same as
destroyAll(ManagementContext) but catching all errors |
static void |
destroyCatching(Entity entity)
Same as
destroy(Entity) but catching all errors. |
static void |
destroyCatching(Location loc)
Same as
destroy(Location) but catching all errors. |
static void |
dumpInfo(Enricher enr) |
static void |
dumpInfo(Enricher enr,
java.lang.String currentIndentation,
java.lang.String tab) |
static void |
dumpInfo(Enricher enr,
java.io.Writer out) |
static void |
dumpInfo(Enricher enr,
java.io.Writer out,
java.lang.String currentIndentation,
java.lang.String tab) |
static void |
dumpInfo(Entity e) |
static void |
dumpInfo(Entity e,
java.lang.String currentIndentation,
java.lang.String tab) |
static void |
dumpInfo(Entity e,
java.io.Writer out) |
static void |
dumpInfo(Entity e,
java.io.Writer out,
java.lang.String currentIndentation,
java.lang.String tab) |
static void |
dumpInfo(java.lang.Iterable<? extends Entity> entities) |
static void |
dumpInfo(Location loc) |
static void |
dumpInfo(Location loc,
java.lang.String currentIndentation,
java.lang.String tab) |
static void |
dumpInfo(Location loc,
java.io.Writer out) |
static void |
dumpInfo(Location loc,
java.io.Writer out,
java.lang.String currentIndentation,
java.lang.String tab) |
static void |
dumpInfo(Policy pol) |
static void |
dumpInfo(Policy pol,
java.lang.String currentIndentation,
java.lang.String tab) |
static void |
dumpInfo(Policy pol,
java.io.Writer out) |
static void |
dumpInfo(Policy pol,
java.io.Writer out,
java.lang.String currentIndentation,
java.lang.String tab) |
static java.lang.String |
getRequiredUrlConfig(Entity entity,
ConfigKey.HasConfigKey<java.lang.String> urlKey) |
static java.lang.String |
getRequiredUrlConfig(Entity entity,
ConfigKey<java.lang.String> urlKey)
Fails-fast if value of the given key is null or unresolveable.
|
static <T> Task<T> |
invokeEffector(EntityLocal callingEntity,
Entity entityToCall,
Effector<T> effector) |
static <T> Task<T> |
invokeEffector(EntityLocal callingEntity,
Entity entityToCall,
Effector<T> effector,
java.util.Map<java.lang.String,?> parameters) |
static Task<?> |
invokeEffector(EntityLocal callingEntity,
java.lang.Iterable<? extends Entity> entitiesToCall,
Effector<?> effector)
Invokes in parallel if multiple, but otherwise invokes the item directly.
|
static Task<?> |
invokeEffector(EntityLocal callingEntity,
java.lang.Iterable<? extends Entity> entitiesToCall,
Effector<?> effector,
java.util.Map<java.lang.String,?> parameters)
Invokes in parallel if multiple, but otherwise invokes the item directly.
|
static <T> Task<java.util.List<T>> |
invokeEffectorList(EntityLocal callingEntity,
java.lang.Iterable<? extends Entity> entitiesToCall,
Effector<T> effector) |
static <T> Task<java.util.List<T>> |
invokeEffectorList(EntityLocal callingEntity,
java.lang.Iterable<? extends Entity> entitiesToCall,
Effector<T> effector,
java.util.Map<java.lang.String,?> parameters)
|
static <T> Task<java.util.List<T>> |
invokeEffectorListWithArgs(EntityLocal callingEntity,
java.lang.Iterable<? extends Entity> entitiesToCall,
Effector<T> effector,
java.lang.Object... args) |
static <T> Task<java.util.List<T>> |
invokeEffectorListWithMap(EntityLocal callingEntity,
java.lang.Iterable<? extends Entity> entitiesToCall,
Effector<T> effector,
java.util.Map<java.lang.String,?> parameters) |
static <T> Task<T> |
invokeEffectorWithArgs(EntityLocal callingEntity,
Entity entityToCall,
Effector<T> effector,
java.lang.Object... args) |
static void |
invokeStopOnShutdown(Entity entity)
Registers a
BrooklynShutdownHooks.invokeStopOnShutdown(Entity) to shutdown this entity when the JVM exits. |
static boolean |
isAncestor(Entity descendant,
Entity potentialAncestor)
Returns true if the given descendant includes the given ancestor in its chain.
|
static boolean |
isDescendant(Entity ancestor,
Entity potentialDescendant)
Checks whether the descendants of the given ancestor contains the given potentialDescendant.
|
static boolean |
isManaged(Entity e) |
static boolean |
isNoLongerManaged(Entity e) |
static java.lang.Boolean |
isReadOnly(Entity e)
as
EntityManagerInternal#isReadOnly(Entity) |
static boolean |
isSecret(java.lang.String name)
Deprecated.
since 0.7; instead use
Sanitizer#IS_SECRET_PREDICATE.apply(Object) |
static boolean |
isTrivial(java.lang.Object v) |
static boolean |
manage(Entity e)
Brings this entity under management only if its ancestor is managed.
|
static void |
manage(Location loc,
ManagementContext managementContext)
Deprecated.
in 0.6.0; use
LocationManager.createLocation(LocationSpec) instead |
static DownloadResolver |
newDownloader(EntityDriver driver) |
static DownloadResolver |
newDownloader(EntityDriver driver,
java.util.Map<java.lang.String,?> properties) |
static DownloadResolver |
newDownloader(EntityDriver driver,
java.lang.String addon) |
static DownloadResolver |
newDownloader(EntityDriver driver,
java.lang.String addon,
java.util.Map<java.lang.String,?> properties) |
static ManagementContext |
newManagementContext() |
static ManagementContext |
newManagementContext(BrooklynProperties props) |
static ManagementContext |
newManagementContext(java.util.Map<?,?> props) |
static <T extends Entity> |
proxy(T e)
Returns the proxy form (if available) of the entity.
|
static java.util.Map<java.lang.String,java.lang.Object> |
sanitize(ConfigBag input)
Deprecated.
since 0.7; instead use
Sanitizer.sanitize(ConfigBag) |
static <K> java.util.Map<K,java.lang.Object> |
sanitize(java.util.Map<K,?> input)
Deprecated.
since 0.7; instead use
Sanitizer.sanitize(Map) |
static ProcessTaskWrapper<java.lang.Integer> |
shell(ManagementContext mgmt,
java.lang.String command)
Convenience for creating and submitted a given shell command against the given mgmt context,
primarily intended for use in the groovy GUI console.
|
static java.util.List<ConfigKey<?>> |
sortConfigKeys(java.util.Set<ConfigKey<?>> configs) |
static <T> java.util.Map<java.lang.String,T> |
sortMap(java.util.Map<java.lang.String,T> map) |
static java.util.List<Sensor<?>> |
sortSensors(java.util.Set<Sensor<?>> sensors) |
static void |
start(Entity e,
java.util.Collection<? extends Location> locations)
convenience for starting an entity, esp a new Startable instance which has been created dynamically
(after the application is started)
|
static ManagementContext |
startManagement(Application app,
BrooklynProperties props)
Starts managing the given (unmanaged) app, setting the given brooklyn properties on the new
management context.
|
static ManagementContext |
startManagement(Application app,
ManagementContext mgmt)
Starts managing the given (unmanaged) app, using the given management context.
|
static ManagementContext |
startManagement(Entity e)
Brings this entity under management, creating a local management context if necessary,
assuming root is an application.
|
static <T extends TaskAdaptable<?>> |
submit(Entity entity,
T task)
Submits a task to run at the entity.
|
static <T extends TaskAdaptable<?>> |
submit(Entity entity,
TaskFactory<T> taskFactory)
Submits a
TaskFactory to construct its task at the entity (in a precursor task) and then to submit it. |
static void |
unmanage(Entity entity) |
static void |
waitForServiceUp(Entity entity) |
static void |
waitForServiceUp(Entity entity,
Duration timeout)
Waits until
Startable.SERVICE_UP returns true. |
static void |
waitForServiceUp(Entity entity,
long duration,
java.util.concurrent.TimeUnit units) |
static void |
warnOnIgnoringConfig(Entity entity,
ConfigKey<?> key)
Logs a warning if an entity has a value for a config key.
|
@Deprecated public static final java.util.List<java.lang.String> SECRET_NAMES
Sanitizer.SECRET_NAMES
public static final java.lang.Object UNCHANGED
See specific usages of this field to confirm where.
public static final java.lang.Object REMOVE
See specific usages of this field to confirm where.
public static <T> Task<java.util.List<T>> invokeEffectorList(EntityLocal callingEntity, java.lang.Iterable<? extends Entity> entitiesToCall, Effector<T> effector, java.util.Map<java.lang.String,?> parameters)
Effector
on multiple entities, with the named arguments from the parameters Map
using the context of the provided Entity
.
Intended for use only from the callingEntity.
Returns a ParallelTask
containing the results from each tasks invocation. Calling
get()
on this will block until all tasks are complete,
and will throw an exception if any task resulted in an error.
ParallelTask
containing results from each invocationpublic static <T> Task<java.util.List<T>> invokeEffectorListWithMap(EntityLocal callingEntity, java.lang.Iterable<? extends Entity> entitiesToCall, Effector<T> effector, java.util.Map<java.lang.String,?> parameters)
public static <T> Task<java.util.List<T>> invokeEffectorListWithArgs(EntityLocal callingEntity, java.lang.Iterable<? extends Entity> entitiesToCall, Effector<T> effector, java.lang.Object... args)
public static <T> Task<java.util.List<T>> invokeEffectorList(EntityLocal callingEntity, java.lang.Iterable<? extends Entity> entitiesToCall, Effector<T> effector)
public static <T> Task<T> invokeEffector(EntityLocal callingEntity, Entity entityToCall, Effector<T> effector, java.util.Map<java.lang.String,?> parameters)
public static <T> Task<T> invokeEffectorWithArgs(EntityLocal callingEntity, Entity entityToCall, Effector<T> effector, java.lang.Object... args)
public static <T> Task<T> invokeEffector(EntityLocal callingEntity, Entity entityToCall, Effector<T> effector)
public static Task<?> invokeEffector(EntityLocal callingEntity, java.lang.Iterable<? extends Entity> entitiesToCall, Effector<?> effector, java.util.Map<java.lang.String,?> parameters)
public static Task<?> invokeEffector(EntityLocal callingEntity, java.lang.Iterable<? extends Entity> entitiesToCall, Effector<?> effector)
@Deprecated public static boolean isSecret(java.lang.String name)
Sanitizer#IS_SECRET_PREDICATE.apply(Object)
public static boolean isTrivial(java.lang.Object v)
@Deprecated public static java.util.Map<java.lang.String,java.lang.Object> sanitize(ConfigBag input)
Sanitizer.sanitize(ConfigBag)
@Deprecated public static <K> java.util.Map<K,java.lang.Object> sanitize(java.util.Map<K,?> input)
Sanitizer.sanitize(Map)
public static void dumpInfo(java.lang.Iterable<? extends Entity> entities)
public static void dumpInfo(Entity e)
public static void dumpInfo(Entity e, java.io.Writer out) throws java.io.IOException
java.io.IOException
public static void dumpInfo(Entity e, java.lang.String currentIndentation, java.lang.String tab) throws java.io.IOException
java.io.IOException
public static void dumpInfo(Entity e, java.io.Writer out, java.lang.String currentIndentation, java.lang.String tab) throws java.io.IOException
java.io.IOException
public static void dumpInfo(Location loc)
public static void dumpInfo(Location loc, java.io.Writer out) throws java.io.IOException
java.io.IOException
public static void dumpInfo(Location loc, java.lang.String currentIndentation, java.lang.String tab) throws java.io.IOException
java.io.IOException
public static void dumpInfo(Location loc, java.io.Writer out, java.lang.String currentIndentation, java.lang.String tab) throws java.io.IOException
java.io.IOException
public static void dumpInfo(Enricher enr)
public static void dumpInfo(Enricher enr, java.io.Writer out) throws java.io.IOException
java.io.IOException
public static void dumpInfo(Enricher enr, java.lang.String currentIndentation, java.lang.String tab) throws java.io.IOException
java.io.IOException
public static void dumpInfo(Enricher enr, java.io.Writer out, java.lang.String currentIndentation, java.lang.String tab) throws java.io.IOException
java.io.IOException
public static void dumpInfo(Policy pol)
public static void dumpInfo(Policy pol, java.io.Writer out) throws java.io.IOException
java.io.IOException
public static void dumpInfo(Policy pol, java.lang.String currentIndentation, java.lang.String tab) throws java.io.IOException
java.io.IOException
public static void dumpInfo(Policy pol, java.io.Writer out, java.lang.String currentIndentation, java.lang.String tab) throws java.io.IOException
java.io.IOException
public static java.util.List<ConfigKey<?>> sortConfigKeys(java.util.Set<ConfigKey<?>> configs)
public static <T> java.util.Map<java.lang.String,T> sortMap(java.util.Map<java.lang.String,T> map)
public static boolean isAncestor(Entity descendant, Entity potentialAncestor)
public static boolean isDescendant(Entity ancestor, Entity potentialDescendant)
In this test, unlike in descendants(Entity)
, an entity is not counted as a descendant.
note, it is usually preferred to use isAncestor() and swap the order, it is a cheaper method.
public static java.lang.Iterable<Entity> descendants(Entity root, com.google.common.base.Predicate<? super Entity> matching, boolean includeSelf)
EntityPredicates} for useful second arguments.
public static java.lang.Iterable<Entity> descendants(Entity root, com.google.common.base.Predicate<? super Entity> matching)
public static java.lang.Iterable<Entity> descendants(Entity root)
public static <T extends Entity> java.lang.Iterable<T> descendants(Entity root, java.lang.Class<T> ofType)
descendants(Entity)
,
Iterables.filter(Iterable, Class)
public static java.lang.Iterable<Entity> ancestors(Entity root)
public static void invokeStopOnShutdown(Entity entity)
BrooklynShutdownHooks.invokeStopOnShutdown(Entity)
to shutdown this entity when the JVM exits.
(Convenience method located in this class for easy access.)public static void start(Entity e, java.util.Collection<? extends Location> locations)
public static void destroy(Entity e)
Actual actions performed will depend on the entity type and its current state.
public static void destroyCatching(Entity entity)
destroy(Entity)
but catching all errors.public static void destroy(Location loc)
public static void destroyCatching(Location loc)
destroy(Location)
but catching all errors.public static void destroyAll(ManagementContext mgmt)
public static void destroyAllCatching(ManagementContext mgmt)
destroyAll(ManagementContext)
but catching all errorspublic static boolean isManaged(Entity e)
public static boolean isNoLongerManaged(Entity e)
@Beta public static java.lang.Boolean isReadOnly(Entity e)
EntityManagerInternal#isReadOnly(Entity)
@Beta public static AbstractEntity deproxy(Entity e)
Only intended for use in tests and occasional internal usage, e.g. persistence. For normal operations, callers should ensure the method is available on an interface and accessed via the proxy.
@Beta public static <T extends Entity> T proxy(T e)
EntitySpec
or YAML for creation), the
proxy may not be avilable; in which case the concrete class passed in will be returned.public static boolean manage(Entity e)
Returns true if successful, otherwise returns false in the expectation that the ancestor will become managed, or throws exception if it has no parent or a non-application root.
java.lang.IllegalStateException
- if e is an Application
.startManagement(Entity)
@Beta public static ManagementContext startManagement(Entity e)
Returns existing management context if there is one (non-deployment) or a new local management
context if not, or throws an exception if root is not an application. Callers are recommended
to use manage(Entity)
instead unless they know a plain-vanilla non-root management
context is sufficient e.g. in tests.
NOTE This method may change, but is provided as a stop-gap to prevent ad-hoc things being done in the code which are even more likely to break!
public static ManagementContext startManagement(Application app, ManagementContext mgmt)
startManagement(Entity)
public static ManagementContext startManagement(Application app, BrooklynProperties props)
startManagement(Entity)
public static ManagementContext newManagementContext()
public static ManagementContext newManagementContext(BrooklynProperties props)
public static ManagementContext newManagementContext(java.util.Map<?,?> props)
public static void unmanage(Entity entity)
public static DownloadResolver newDownloader(EntityDriver driver)
public static DownloadResolver newDownloader(EntityDriver driver, java.util.Map<java.lang.String,?> properties)
public static DownloadResolver newDownloader(EntityDriver driver, java.lang.String addon)
public static DownloadResolver newDownloader(EntityDriver driver, java.lang.String addon, java.util.Map<java.lang.String,?> properties)
public static <T> com.google.common.base.Supplier<T> attributeSupplier(Entity entity, AttributeSensor<T> sensor)
public static <T> com.google.common.base.Supplier<T> attributeSupplier(EntityAndAttribute<T> tuple)
public static <T> com.google.common.base.Supplier<T> attributeSupplierWhenReady(EntityAndAttribute<T> tuple)
public static <T> com.google.common.base.Supplier<T> attributeSupplierWhenReady(Entity entity, AttributeSensor<T> sensor)
@Deprecated public static void manage(Location loc, ManagementContext managementContext)
LocationManager.createLocation(LocationSpec)
insteadpublic static java.lang.String getRequiredUrlConfig(Entity entity, ConfigKey<java.lang.String> urlKey)
public static java.lang.String getRequiredUrlConfig(Entity entity, ConfigKey.HasConfigKey<java.lang.String> urlKey)
public static java.lang.String checkRequiredUrl(Entity entity, java.lang.String url)
public static <T extends TaskAdaptable<?>> T submit(Entity entity, TaskFactory<T> taskFactory)
TaskFactory
to construct its task at the entity (in a precursor task) and then to submit it.
Important if task construction relies on an entity being in scope (in tags, via BrooklynTaskTags
)
public static <T extends TaskAdaptable<?>> T submit(Entity entity, T task)
public static void warnOnIgnoringConfig(Entity entity, ConfigKey<?> key)
public static void waitForServiceUp(Entity entity, Duration timeout)
Startable.SERVICE_UP
returns true.public static void waitForServiceUp(Entity entity, long duration, java.util.concurrent.TimeUnit units)
public static void waitForServiceUp(Entity entity)
@Beta public static ProcessTaskWrapper<java.lang.Integer> shell(ManagementContext mgmt, java.lang.String command)