public abstract class AbstractManagementContext extends java.lang.Object implements ManagementContextInternal
ManagementContext.PropertiesReloadListener
EFFECTOR_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, wait
addEntitySetListener, getAccessManager, getEntityFactory, getLocationFactory, getOsgiManager, getPolicyFactory, getUsageManager, prePreManage, prePreManage, removeEntitySetListener
addPropertiesReloadListener, getAccessController, getApplications, getEntityManager, getExecutionManager, getLocationManager, getManagementPlaneId, getManagementPlaneIdMaybe, getNodeState, getSubscriptionManager, reloadBrooklynProperties, removePropertiesReloadListener
public AbstractManagementContext(BrooklynProperties brooklynProperties)
public void terminate()
terminate
in interface ManagementContextInternal
public boolean isRunning()
ManagementContext
ManagementContext.isStartupComplete()
.isRunning
in interface ManagementContext
public boolean isStartupComplete()
ManagementContext
ManagementContext.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 ManagementContext
public java.lang.String getManagementNodeId()
ManagementContext
ManagementContext
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 ManagementContext
public BrooklynStorage getStorage()
getStorage
in interface ManagementContextInternal
public RebindManager getRebindManager()
getRebindManager
in interface ManagementContext
public HighAvailabilityManager getHighAvailabilityManager()
getHighAvailabilityManager
in interface ManagementContext
public long getTotalEffectorInvocations()
getTotalEffectorInvocations
in interface ManagementContextInternal
public ExecutionContext getExecutionContext(Entity e)
ManagementContext
ExecutionContext
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 ManagementContext
public ExecutionContext getExecutionContext(Entity e, EntityAdjunct adjunct)
ManagementContext
ManagementContext.getExecutionContext(Entity)
where there is also an adjunctgetExecutionContext
in interface ManagementContext
public ExecutionContext getServerExecutionContext()
ManagementContext
ExecutionContext
within the ExecutionManager
for tasks
associated to the Brooklyn node's operation (not any entities).getServerExecutionContext
in interface ManagementContext
public SubscriptionContext getSubscriptionContext(Entity e)
ManagementContext
SubscriptionContext
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 ManagementContext
public SubscriptionContext getSubscriptionContext(Entity e, EntityAdjunct a)
ManagementContext
ManagementContext.getSubscriptionContext(Entity)
where there is also an adjunctgetSubscriptionContext
in interface ManagementContext
public SubscriptionContext getSubscriptionContext(Location loc)
ManagementContext
SubscriptionContext
instance representing subscriptions
(from the SubscriptionManager
) associated with this location, and capable
of conveniently subscribing on behalf of that locationgetSubscriptionContext
in interface ManagementContext
public EntityDriverManager getEntityDriverManager()
ManagementContext
EntityDriverManager
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 ManagementContext
public DownloadResolverManager getEntityDownloadsManager()
ManagementContext
DownloadResolverManager
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 ManagementContext
public EntitlementManager getEntitlementManager()
ManagementContext
getEntitlementManager
in interface ManagementContext
public <T> Task<T> invokeEffector(Entity entity, Effector<T> eff, java.util.Map parameters)
invokeEffector
in interface ManagementContextInternal
public <T> T invokeEffectorMethodSync(Entity entity, Effector<T> eff, java.util.Map<java.lang.String,?> args) throws java.util.concurrent.ExecutionException
invokeEffectorMethodSync
in interface ManagementContextInternal
java.util.concurrent.ExecutionException
public abstract boolean isManagedLocally(Entity e)
public StringConfigMap getConfig()
ManagementContext
getConfig
in interface ManagementContext
public BrooklynProperties getBrooklynProperties()
getBrooklynProperties
in interface ManagementContextInternal
public Scratchpad getScratchpad()
ManagementContext
Provides 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 ManagementContext
public LocationRegistry getLocationRegistry()
ManagementContext
getLocationRegistry
in interface ManagementContext
public BrooklynCatalog getCatalog()
ManagementContext
getCatalog
in interface ManagementContext
public BrooklynTypeRegistry getTypeRegistry()
ManagementContext
getTypeRegistry
in interface ManagementContext
public java.lang.ClassLoader getCatalogClassLoader()
ManagementContext
getCatalogClassLoader
in interface ManagementContext
public java.lang.ClassLoader getBaseClassLoader()
getBaseClassLoader
in interface ManagementContextInternal
public 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 ManagementContextInternal
public java.lang.Iterable<java.net.URL> getBaseClassPathForScanning()
getBaseClassPathForScanning
in interface ManagementContextInternal
setBaseClassPathForScanning(Iterable)
public BrooklynGarbageCollector getGarbageCollector()
public void setManagementNodeUri(java.net.URI uri)
setManagementNodeUri
in interface ManagementContextInternal
public Maybe<java.net.URI> getManagementNodeUri()
ManagementContext
getManagementNodeUri
in interface ManagementContext
public CatalogInitialization getCatalogInitialization()
getCatalogInitialization
in interface ManagementContextInternal
public void setCatalogInitialization(CatalogInitialization catalogInitialization)
setCatalogInitialization
in interface ManagementContextInternal
public BrooklynObject lookup(java.lang.String id)
ManagementContext
ManagementContext.lookup(String, Class)
but not constraining the return typelookup
in interface ManagementContext
public <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 ManagementContext
public <T extends BrooklynObject> T lookup(<any> filter)
ManagementContext
BrooklynObject
known in this management context
satisfying the given predicate, or nulllookup
in interface ManagementContext
public <T extends BrooklynObject> java.util.Collection<T> lookupAll(<any> filter)
ManagementContext
#lookup(Predicate)
but returning all such instanceslookupAll
in interface ManagementContext
public java.util.List<java.lang.Throwable> errors()
ManagementContextInternal
errors
in interface ManagementContextInternal
public ExternalConfigSupplierRegistry getExternalConfigProviderRegistry()
getExternalConfigProviderRegistry
in interface ManagementContextInternal