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> |
attributeSupplier(EntityAndAttribute<T> tuple) |
static <T> |
attributeSupplier(Entity entity,
AttributeSensor<T> sensor) |
static <T> |
attributeSupplierWhenReady(EntityAndAttribute<T> tuple) |
static <T> |
attributeSupplierWhenReady(Entity entity,
AttributeSensor<T> sensor) |
static Entity |
catalogItemScopeRoot(Entity entity) |
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 java.lang.Iterable<Entity> |
descendants(Entity root,
Returns the entity matching the given predicate
|
static java.lang.Iterable<Entity> |
descendants(Entity root,
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(Feed feed,
java.lang.String currentIndentation,
java.lang.String tab) |
static void |
dumpInfo(Feed feed,
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.util.Set<Location> |
getAllInheritedLocations(Entity entity) |
static ManagementContext |
getManagementContext(Entity entity) |
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(Entity callingEntity,
Entity entityToCall,
Effector<T> effector) |
static <T> Task<T> |
invokeEffector(Entity callingEntity,
Entity entityToCall,
Effector<T> effector,
java.util.Map<java.lang.String,?> parameters) |
static Task<?> |
invokeEffector(Entity callingEntity,
java.lang.Iterable<? extends Entity> entitiesToCall,
Effector<?> effector)
Invokes in parallel if multiple, but otherwise invokes the item directly.
|
static Task<?> |
invokeEffector(Entity 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(Entity callingEntity,
java.lang.Iterable<? extends Entity> entitiesToCall,
Effector<T> effector) |
static <T> Task<java.util.List<T>> |
invokeEffectorList(Entity 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(Entity callingEntity,
java.lang.Iterable<? extends Entity> entitiesToCall,
Effector<T> effector,
java.lang.Object... args) |
static <T> Task<java.util.List<T>> |
invokeEffectorListWithMap(Entity callingEntity,
java.lang.Iterable<? extends Entity> entitiesToCall,
Effector<T> effector,
java.util.Map<java.lang.String,?> parameters) |
static <T> Task<T> |
invokeEffectorWithArgs(Entity 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)
Deprecated.
since 0.9.0; entities are automatically managed when created via
Entity.addChild(EntitySpec) ,
or with EntityManager.createEntity(EntitySpec) (it is strongly encouraged to include the parent
if using the latter for anything but a top-level app). |
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)
Deprecated.
since 0.9.0; entities are automatically managed when created via
Entity.addChild(EntitySpec) ,
or with EntityManager.createEntity(EntitySpec) . For top-level apps, use code like
managementContext.getEntityManager().createEntity(EntitySpec.create(...)) . |
static ManagementContext |
startManagement(Application app,
ManagementContext mgmt)
Deprecated.
since 0.9.0; entities are automatically managed when created with
EntityManager.createEntity(EntitySpec) . For top-level apps, use code like
managementContext.getEntityManager().createEntity(EntitySpec.create(...)) . |
static ManagementContext |
startManagement(Entity e)
Deprecated.
since 0.9.0; entities are automatically managed when created via
Entity.addChild(EntitySpec) ,
or with EntityManager.createEntity(EntitySpec) . |
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(Entity 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(Entity 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(Entity callingEntity, java.lang.Iterable<? extends Entity> entitiesToCall, Effector<T> effector, java.lang.Object... args)
public static <T> Task<java.util.List<T>> invokeEffectorList(Entity callingEntity, java.lang.Iterable<? extends Entity> entitiesToCall, Effector<T> effector)
public static <T> Task<T> invokeEffector(Entity callingEntity, Entity entityToCall, Effector<T> effector, java.util.Map<java.lang.String,?> parameters)
public static <T> Task<T> invokeEffectorWithArgs(Entity callingEntity, Entity entityToCall, Effector<T> effector, java.lang.Object... args)
public static <T> Task<T> invokeEffector(Entity callingEntity, Entity entityToCall, Effector<T> effector)
public static Task<?> invokeEffector(Entity callingEntity, java.lang.Iterable<? extends Entity> entitiesToCall, Effector<?> effector, java.util.Map<java.lang.String,?> parameters)
public static Task<?> invokeEffector(Entity 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(Feed feed, java.lang.String currentIndentation, java.lang.String tab) throws java.io.IOException
java.io.IOException
public static void dumpInfo(Feed feed, 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,matching, boolean includeSelf)
EntityPredicates} for useful second arguments.
public static java.lang.Iterable<Entity> descendants(Entity root,matching)
#descendants(Entity, Predicate, boolean)
public static java.lang.Iterable<Entity> descendants(Entity root)
#descendants(Entity, Predicate, boolean)
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)
public static java.lang.Boolean isReadOnly(Entity e)
EntityManagerInternal#isReadOnly(Entity)
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.
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.@Deprecated public static boolean manage(Entity e)
Entity.addChild(EntitySpec)
,
or with EntityManager.createEntity(EntitySpec)
(it is strongly encouraged to include the parent
if using the latter for anything but a top-level app).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)
@Deprecated public static ManagementContext startManagement(Entity e)
Entity.addChild(EntitySpec)
,
or with EntityManager.createEntity(EntitySpec)
.
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!
@Deprecated public static ManagementContext startManagement(Application app, ManagementContext mgmt)
EntityManager.createEntity(EntitySpec)
. For top-level apps, use code like
managementContext.getEntityManager().createEntity(EntitySpec.create(...))
.startManagement(Entity)
@Deprecated public static ManagementContext startManagement(Application app, BrooklynProperties props)
Entity.addChild(EntitySpec)
,
or with EntityManager.createEntity(EntitySpec)
. For top-level apps, use code like
managementContext.getEntityManager().createEntity(EntitySpec.create(...))
.startManagement(Entity)
public static ManagementContext newManagementContext()
public static ManagementContext newManagementContext(BrooklynProperties props)
public static ManagementContext newManagementContext(java.util.Map<?,?> props)
public static ManagementContext getManagementContext(Entity entity)
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>attributeSupplier(Entity entity, AttributeSensor<T> sensor)
public static <T>attributeSupplier(EntityAndAttribute<T> tuple)
public static <T>attributeSupplierWhenReady(EntityAndAttribute<T> tuple)
public static <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)
public static ProcessTaskWrapper<java.lang.Integer> shell(ManagementContext mgmt, java.lang.String command)