public abstract class AbstractManagementContext extends java.lang.Object implements ManagementContextInternal
ManagementContext.PropertiesReloadListenerEFFECTOR_TAG, EMPTY_CATALOG_URL, NON_TRANSIENT_TASK_TAG, SUB_TASK_TAG, TRANSIENT_TASK_TAG| Constructor and Description |
|---|
AbstractManagementContext(BrooklynProperties brooklynProperties) |
| Modifier and Type | Method and Description |
|---|---|
java.util.List<java.lang.Throwable> |
errors()
Object which allows adding, removing, and clearing errors.
|
java.lang.ClassLoader |
getBaseClassLoader()
Optional class-loader that this management context should use as its base,
as the first-resort in the catalog, and for scanning (if scanning the default in the catalog).
|
java.lang.Iterable<java.net.URL> |
getBaseClassPathForScanning() |
BrooklynProperties |
getBrooklynProperties() |
BrooklynCatalog |
getCatalog()
Record of configured Brooklyn entities (and templates and policies) which can be loaded
|
java.lang.ClassLoader |
getCatalogClassLoader()
Returns the class loader to be used to load items.
|
CatalogInitialization |
getCatalogInitialization() |
StringConfigMap |
getConfig()
Returns the ConfigMap (e.g.
|
EntitlementManager |
getEntitlementManager()
Active entitlements checker instance.
|
DownloadResolverManager |
getEntityDownloadsManager()
Returns the
DownloadResolverManager for resolving things like which URL to download an installer from. |
EntityDriverManager |
getEntityDriverManager()
Returns the
EntityDriverManager entities can use to create drivers. |
ExecutionContext |
getExecutionContext(Entity e)
Returns an
ExecutionContext instance representing tasks
(from the ExecutionManager) associated with this entity, and capable
of conveniently running such tasks which will be associated with that entity |
ExecutionContext |
getExecutionContext(Entity e,
EntityAdjunct adjunct)
As
ManagementContext.getExecutionContext(Entity) where there is also an adjunct |
ExternalConfigSupplierRegistry |
getExternalConfigProviderRegistry() |
BrooklynGarbageCollector |
getGarbageCollector() |
HighAvailabilityManager |
getHighAvailabilityManager() |
LocationRegistry |
getLocationRegistry()
Record of configured locations and location resolvers
|
java.lang.String |
getManagementNodeId()
UID for this
ManagementContext node (as part of a single management plane). |
Maybe<java.net.URI> |
getManagementNodeUri()
The URI that this management node's REST API is available at, or absent if the node's
API is unavailable.
|
RebindManager |
getRebindManager() |
Scratchpad |
getScratchpad()
Provides a scratchpad area for this ManagementContext.
|
ExecutionContext |
getServerExecutionContext()
Returns an
ExecutionContext within the ExecutionManager for tasks
associated to the Brooklyn node's operation (not any entities). |
BrooklynStorage |
getStorage() |
SubscriptionContext |
getSubscriptionContext(Entity e)
Returns a
SubscriptionContext instance representing subscriptions
(from the SubscriptionManager) associated with this entity, and capable
of conveniently subscribing on behalf of that entity. |
SubscriptionContext |
getSubscriptionContext(Entity e,
EntityAdjunct a)
As
ManagementContext.getSubscriptionContext(Entity) where there is also an adjunct |
SubscriptionContext |
getSubscriptionContext(Location loc)
Returns a
SubscriptionContext instance representing subscriptions
(from the SubscriptionManager) associated with this location, and capable
of conveniently subscribing on behalf of that location |
long |
getTotalEffectorInvocations() |
BrooklynTypeRegistry |
getTypeRegistry()
Record of configured classes which can be loaded
|
<T> Task<T> |
invokeEffector(Entity entity,
Effector<T> eff,
java.util.Map parameters) |
<T> T |
invokeEffectorMethodSync(Entity entity,
Effector<T> eff,
java.util.Map<java.lang.String,?> args)
Method for entity to make effector happen with correct semantics (right place, right task context),
when a method is called on that entity.
|
abstract boolean |
isManagedLocally(Entity e)
Whether the master entity record is local, and sensors and effectors can be properly accessed locally.
|
boolean |
isRunning()
Whether the management context has been initialized and not yet terminated.
|
boolean |
isStartupComplete()
Whether all startup tasks have completed.
|
<T extends BrooklynObject> |
lookup(<any> filter)
Finds a
BrooklynObject known in this management context
satisfying the given predicate, or null |
BrooklynObject |
lookup(java.lang.String id)
As
ManagementContext.lookup(String, Class) but not constraining the return type |
<T extends BrooklynObject> |
lookup(java.lang.String id,
java.lang.Class<T> type)
As
#lookup(Predicate) comparing the ID of the object with the given string |
<T extends BrooklynObject> |
lookupAll(<any> filter)
As
#lookup(Predicate) but returning all such instances |
void |
setBaseClassLoader(java.lang.ClassLoader cl)
See
getBaseClassLoader(). |
void |
setBaseClassPathForScanning(java.lang.Iterable<java.net.URL> urls)
Optional mechanism for setting the classpath which should be scanned by the catalog, if the catalog
is scanning the default classpath.
|
void |
setCatalogInitialization(CatalogInitialization catalogInitialization) |
void |
setManagementNodeUri(java.net.URI uri) |
void |
terminate() |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddEntitySetListener, getAccessManager, getEntityFactory, getLocationFactory, getOsgiManager, getPolicyFactory, getUsageManager, prePreManage, prePreManage, removeEntitySetListeneraddPropertiesReloadListener, getAccessController, getApplications, getEntityManager, getExecutionManager, getLocationManager, getManagementPlaneId, getManagementPlaneIdMaybe, getNodeState, getSubscriptionManager, reloadBrooklynProperties, removePropertiesReloadListenerpublic AbstractManagementContext(BrooklynProperties brooklynProperties)
public void terminate()
terminate in interface ManagementContextInternalpublic boolean isRunning()
ManagementContextManagementContext.isStartupComplete().isRunning in interface ManagementContextpublic boolean isStartupComplete()
ManagementContextManagementContext.isRunning() returns true immediately after construction)
but some subsystems (e.g. persistence, OSGi, webapps, entities started at startup)
may not be available until this returns true.
Also returns false if HA state is transitioning. See ManagementContext.getNodeState() to atomically check node state,
as the preferred way to tell if a node is master.
isStartupComplete in interface ManagementContextpublic java.lang.String getManagementNodeId()
ManagementContextManagementContext node (as part of a single management plane).
No two instances of ManagementContext should ever have the same node UID.
The value of Application#getManagementContext()#getManagementNodeId() may
change if it is rebinded to a different node,
in contrast to ManagementContext.getManagementPlaneIdMaybe() which is the same for all nodes in a Brooklyn plane.
This value should not be null unless the management context is a non-functional (non-deployment) instance.
getManagementNodeId in interface ManagementContextpublic BrooklynStorage getStorage()
getStorage in interface ManagementContextInternalpublic RebindManager getRebindManager()
getRebindManager in interface ManagementContextpublic HighAvailabilityManager getHighAvailabilityManager()
getHighAvailabilityManager in interface ManagementContextpublic long getTotalEffectorInvocations()
getTotalEffectorInvocations in interface ManagementContextInternalpublic ExecutionContext getExecutionContext(Entity e)
ManagementContextExecutionContext instance representing tasks
(from the ExecutionManager) associated with this entity, and capable
of conveniently running such tasks which will be associated with that entitygetExecutionContext in interface ManagementContextpublic ExecutionContext getExecutionContext(Entity e, EntityAdjunct adjunct)
ManagementContextManagementContext.getExecutionContext(Entity) where there is also an adjunctgetExecutionContext in interface ManagementContextpublic ExecutionContext getServerExecutionContext()
ManagementContextExecutionContext within the ExecutionManager for tasks
associated to the Brooklyn node's operation (not any entities).getServerExecutionContext in interface ManagementContextpublic SubscriptionContext getSubscriptionContext(Entity e)
ManagementContextSubscriptionContext instance representing subscriptions
(from the SubscriptionManager) associated with this entity, and capable
of conveniently subscribing on behalf of that entity.
For subscriptions made using this SubscriptionContext, the calls to
SensorEventListener.onEvent(org.apache.brooklyn.api.sensor.SensorEvent)
will be made in a task that has the CONTEXT_ENTITY tag set to this entity (see BrooklynTaskTag).getSubscriptionContext in interface ManagementContextpublic SubscriptionContext getSubscriptionContext(Entity e, EntityAdjunct a)
ManagementContextManagementContext.getSubscriptionContext(Entity) where there is also an adjunctgetSubscriptionContext in interface ManagementContextpublic SubscriptionContext getSubscriptionContext(Location loc)
ManagementContextSubscriptionContext instance representing subscriptions
(from the SubscriptionManager) associated with this location, and capable
of conveniently subscribing on behalf of that locationgetSubscriptionContext in interface ManagementContextpublic EntityDriverManager getEntityDriverManager()
ManagementContextEntityDriverManager entities can use to create drivers. This
manager can also be used to programmatically customize which driver type to use
for entities in different locations.
The default strategy for choosing a driver is to use a naming convention:
DriverDependentEntity.getDriverInterface() returns the interface that the
driver must implement; its name should end in "Driver". For example, this suffix is
replaced with "SshDriver" for SshMachineLocation, for example.getEntityDriverManager in interface ManagementContextpublic DownloadResolverManager getEntityDownloadsManager()
ManagementContextDownloadResolverManager for resolving things like which URL to download an installer from.
The default DownloadResolverManager will retrieve entity.getAttribute(Attributes.DOWNLOAD_URL),
and substitute things like "${version}" etc.
However, additional resolvers can be registered to customize this behaviour (e.g. to always go to an
enterprise's repository).getEntityDownloadsManager in interface ManagementContextpublic EntitlementManager getEntitlementManager()
ManagementContextgetEntitlementManager in interface ManagementContextpublic <T> Task<T> invokeEffector(Entity entity, Effector<T> eff, java.util.Map parameters)
invokeEffector in interface ManagementContextInternalpublic <T> T invokeEffectorMethodSync(Entity entity, Effector<T> eff, java.util.Map<java.lang.String,?> args) throws java.util.concurrent.ExecutionException
invokeEffectorMethodSync in interface ManagementContextInternaljava.util.concurrent.ExecutionExceptionpublic abstract boolean isManagedLocally(Entity e)
public StringConfigMap getConfig()
ManagementContextgetConfig in interface ManagementContextpublic BrooklynProperties getBrooklynProperties()
getBrooklynProperties in interface ManagementContextInternalpublic Scratchpad getScratchpad()
ManagementContextProvides a scratchpad area for this ManagementContext. It can be used for storing any data useful to Brooklyn core or custom entities. Usually it's used for singleton-like objects per ManagementContext. The lifetime of he scratch area is for the duration of the ManagementContext. It's not persisted or shared between HA nodes, doesn't survive restarts.
Code using ManagementContext.getConfig() for the same purpose should migrate to using this method as ManagementContext.getConfig()
will become read-only in future releases. Note that the scratchpad is not reset on reloading brooklyn.properties
unlike ManagementContext.getConfig().
The returned map is thread safe, no locking is required to use it from parallel threads.
getScratchpad in interface ManagementContextpublic LocationRegistry getLocationRegistry()
ManagementContextgetLocationRegistry in interface ManagementContextpublic BrooklynCatalog getCatalog()
ManagementContextgetCatalog in interface ManagementContextpublic BrooklynTypeRegistry getTypeRegistry()
ManagementContextgetTypeRegistry in interface ManagementContextpublic java.lang.ClassLoader getCatalogClassLoader()
ManagementContextgetCatalogClassLoader in interface ManagementContextpublic java.lang.ClassLoader getBaseClassLoader()
getBaseClassLoader in interface ManagementContextInternalpublic void setBaseClassLoader(java.lang.ClassLoader cl)
getBaseClassLoader(). Only settable once and must be invoked before catalog is loaded.public void setBaseClassPathForScanning(java.lang.Iterable<java.net.URL> urls)
This should normally be invoked early in the server startup. Setting it after the catalog is loaded will not take effect without an explicit internal call to do so. Once set, it can be changed prior to catalog loading but it cannot be changed once the catalog is loaded.
ClasspathHelper.forJavaClassPath() is often a good argument to pass, and is used internally in some places when no items are found on the catalog.
setBaseClassPathForScanning in interface ManagementContextInternalpublic java.lang.Iterable<java.net.URL> getBaseClassPathForScanning()
getBaseClassPathForScanning in interface ManagementContextInternalsetBaseClassPathForScanning(Iterable)public BrooklynGarbageCollector getGarbageCollector()
public void setManagementNodeUri(java.net.URI uri)
setManagementNodeUri in interface ManagementContextInternalpublic Maybe<java.net.URI> getManagementNodeUri()
ManagementContextgetManagementNodeUri in interface ManagementContextpublic CatalogInitialization getCatalogInitialization()
getCatalogInitialization in interface ManagementContextInternalpublic void setCatalogInitialization(CatalogInitialization catalogInitialization)
setCatalogInitialization in interface ManagementContextInternalpublic BrooklynObject lookup(java.lang.String id)
ManagementContextManagementContext.lookup(String, Class) but not constraining the return typelookup in interface ManagementContextpublic <T extends BrooklynObject> T lookup(java.lang.String id, java.lang.Class<T> type)
ManagementContext#lookup(Predicate) comparing the ID of the object with the given stringlookup in interface ManagementContextpublic <T extends BrooklynObject> T lookup(<any> filter)
ManagementContextBrooklynObject known in this management context
satisfying the given predicate, or nulllookup in interface ManagementContextpublic <T extends BrooklynObject> java.util.Collection<T> lookupAll(<any> filter)
ManagementContext#lookup(Predicate) but returning all such instanceslookupAll in interface ManagementContextpublic java.util.List<java.lang.Throwable> errors()
ManagementContextInternalerrors in interface ManagementContextInternalpublic ExternalConfigSupplierRegistry getExternalConfigProviderRegistry()
getExternalConfigProviderRegistry in interface ManagementContextInternal