public interface Cluster
Modifier and Type | Method and Description |
---|---|
void |
addConfig(Config config)
Sets a specific config.
|
void |
addConfigGroup(ConfigGroup configGroup)
Add a new config group to the set of Config groups associated with this
cluster
|
ServiceConfigVersionResponse |
addDesiredConfig(String user,
Set<Config> configs)
Adds and sets a DESIRED configuration to be applied to a cluster.
|
ServiceConfigVersionResponse |
addDesiredConfig(String user,
Set<Config> configs,
String serviceConfigVersionNote)
Adds and sets a DESIRED configuration to be applied to a cluster.
|
void |
addRequestExecution(RequestExecution requestExecution)
Add a @RequestExecution to the cluster
|
void |
addService(Service service)
Add a service to a cluster
|
Service |
addService(String serviceName,
RepositoryVersionEntity repositoryVersion)
Add service to the cluster
|
void |
addServiceComponentHosts(Collection<ServiceComponentHost> serviceComponentHosts)
Adds schs to cluster AND persists them
TODO consider making persisting optional
|
void |
addSessionAttributes(Map<String,Object> attributes)
Add the given map of attributes to the session for this cluster.
|
void |
addSuspendedUpgradeParameters(Map<String,String> commandParams,
Map<String,String> roleParams)
Adds upgrade specific command and role parameters to the command maps if
there is a suspended upgrade.
|
void |
applyLatestConfigurations(StackId stackId,
String serviceName)
Makes the most recent configurations for the specified stack current.
|
org.apache.ambari.spi.ClusterInformation |
buildClusterInformation()
Builds a
ClusterInformation instance from a Cluster . |
boolean |
canBeRemoved()
Gets if the cluster can be deleted
|
boolean |
checkPermission(PrivilegeEntity privilegeEntity,
boolean readOnly)
Determine whether or not access to this cluster resource should be allowed based
on the given privilege.
|
ClusterResponse |
convertToResponse()
Creates a cluster response based on the current cluster definition
|
ServiceConfigVersionResponse |
createServiceConfigVersion(String serviceName,
String user,
String note,
ConfigGroup configGroup) |
void |
debugDump(StringBuilder sb)
Creates a debug dump based on the current cluster state
|
void |
delete()
Delete the cluster
|
void |
deleteAllServices()
Delete all the services associated with this cluster
|
void |
deleteConfigGroup(Long id)
Delete this config group identified by the config group id
|
void |
deleteRequestExecution(Long id)
Delete a @RequestExecution associated with the cluster
|
void |
deleteService(String serviceName,
DeleteHostComponentStatusMetaData deleteMetaData)
Delete the named service associated with this cluster
|
List<ServiceConfigVersionResponse> |
getActiveServiceConfigVersionResponse(String serviceName)
Get active service config version responses for all config groups of a service
|
Map<String,Collection<ServiceConfigVersionResponse>> |
getActiveServiceConfigVersions()
Get currently active service config versions for stack services
|
Collection<Config> |
getAllConfigs()
Gets all configurations defined for a cluster.
|
Map<String,Set<DesiredConfig>> |
getAllDesiredConfigVersions()
Gets all versions of the desired configurations for the cluster.
|
Map<Long,Map<String,DesiredConfig>> |
getAllHostsDesiredConfigs()
Fetch desired configs for all hosts in cluster
|
Map<Long,RequestExecution> |
getAllRequestExecutions()
Get all @RequestExecution objects associated with the cluster
|
ClusterEntity |
getClusterEntity() |
long |
getClusterId()
Get the cluster ID
|
String |
getClusterName()
Get the Cluster Name
|
String |
getClusterProperty(String propertyName,
String defaultValue)
Gets the most recent value of
cluster-env/propertyName where
propertyName is the paramter specified to the method. |
int |
getClusterSize()
Returns the number of hosts that form the cluster.
|
Map<String,Map<String,String>> |
getComponentVersionMap()
Gets a mapping of service to component/version for every installed
component in the cluster which advertises a version and for which the
repository has been resolved.
|
Config |
getConfig(String configType,
String versionTag)
Gets the specific config that matches the specified type and tag.
|
Config |
getConfigByVersion(String configType,
Long configVersion)
Gets the specific config that matches the specified type and version.
|
Map<Long,ConfigGroup> |
getConfigGroups()
Get config groups associated with this cluster
|
Map<Long,ConfigGroup> |
getConfigGroupsByHostname(String hostname)
Find all config groups associated with the give hostname
|
ConfigGroup |
getConfigGroupsById(Long configId)
Find config group by config group id
|
Map<Long,ConfigGroup> |
getConfigGroupsByServiceName(String serviceName)
Find all config groups associated with the give service name
|
Map<PropertyInfo.PropertyType,Set<String>> |
getConfigPropertiesTypes(String configType)
Gets all properties types that matches the specified type for the current stack.
|
Map<PropertyInfo.PropertyType,Set<String>> |
getConfigPropertiesTypes(String configType,
StackId stackId)
Gets all properties types that matches the specified type for the given stack.
|
Map<String,Config> |
getConfigsByType(String configType)
Gets all configs that match the specified type.
|
StackId |
getCurrentStackVersion()
Get current stack version
|
Config |
getDesiredConfigByType(String configType)
Gets the desired (and selected) config by type.
|
Map<String,DesiredConfig> |
getDesiredConfigs()
Gets the active desired configurations for the cluster.
|
Map<String,DesiredConfig> |
getDesiredConfigs(boolean cachedConfigEntities)
Gets the active desired configurations for the cluster.
|
StackId |
getDesiredStackVersion()
Get desired stack version
|
Host |
getHost(Long hostId)
Get specific host info using host id.
|
Host |
getHost(String hostName)
Get specific host info using host name.
|
default Set<String> |
getHostNames() |
Collection<Host> |
getHosts()
Get all hosts associated with this cluster.
|
Set<String> |
getHosts(String serviceName,
String componentName)
Get all of the hosts running the provided service and component.
|
Map<Long,Map<String,DesiredConfig>> |
getHostsDesiredConfigs(Collection<Long> hostIds)
Fetch desired configs for list of hosts in cluster
|
List<Config> |
getLatestConfigsWithTypes(Collection<String> types)
Get latest (including inactive ones) configurations with any of the given types.
|
Long |
getNextConfigVersion(String type)
Get next version of specified config type
|
State |
getProvisioningState()
Gets whether the cluster is still initializing or has finished with its
deployment requests.
|
Long |
getResourceId()
Gets the Cluster's resource ID
|
RoleCommandOrder |
getRoleCommandOrder()
Gets a new instance of a
RoleCommandOrder for this cluster. |
SecurityType |
getSecurityType()
Gets the cluster's security type.
|
Service |
getService(String serviceName)
Get a service
|
Service |
getServiceByComponentName(String componentName)
Gets a service from the given component name.
|
String |
getServiceByConfigType(String configType)
Returns the name of the service that the passed config type belongs to.
|
Map<String,Set<String>> |
getServiceComponentHostMap(Set<String> hostNames,
Set<String> serviceNames)
Gets a map of components to hosts they are installed on.
|
List<ServiceComponentHost> |
getServiceComponentHosts()
Get all ServiceComponentHosts for this cluster.
|
List<ServiceComponentHost> |
getServiceComponentHosts(String hostname)
Get all ServiceComponentHosts on a given host
|
List<ServiceComponentHost> |
getServiceComponentHosts(String serviceName,
String componentName)
Get all ServiceComponentHosts for a given service and optional component
If the component name is
null , all components for the requested service will be returned. |
List<ServiceConfigVersionResponse> |
getServiceConfigVersions()
Get service config version history
|
String |
getServiceForConfigTypes(Collection<String> configTypes) |
Map<String,Service> |
getServices()
Get all services
|
Map<String,Object> |
getSessionAttributes()
Get the map of session attributes for this cluster.
|
UpgradeEntity |
getUpgradeInProgress()
Gets an
UpgradeEntity if there is an upgrade in progress or an
upgrade that has been suspended. |
boolean |
isBluePrintDeployed()
Returns whether this cluster was provisioned by a Blueprint or not.
|
boolean |
isConfigTypeExists(String configType)
Check if config type exists in cluster.
|
boolean |
isUpgradeSuspended()
Gets whether there is an upgrade which has been suspended and not yet
finalized.
|
Map<ServiceComponentHostEvent,String> |
processServiceComponentHostEvents(com.google.common.collect.ListMultimap<String,ServiceComponentHostEvent> eventMap)
Bulk handle service component host events
|
void |
refresh()
Refreshes the cluster details
|
void |
removeConfigurations(StackId stackId,
String serviceName)
Removes all configurations for the specified service and stack.
|
void |
removeServiceComponentHost(ServiceComponentHost svcCompHost)
Remove ServiceComponentHost from cluster
|
void |
removeSessionAttribute(String key)
Removes an attribute from the session for this cluster
|
void |
setClusterName(String clusterName)
Set the Cluster Name
|
void |
setCurrentStackVersion(StackId stackVersion)
Set current stack version
|
void |
setDesiredStackVersion(StackId stackVersion)
Set desired stack version
|
void |
setProvisioningState(State provisioningState)
Sets the provisioning state of the cluster.
|
void |
setSecurityType(SecurityType securityType)
Sets this Cluster's security type.
|
ServiceConfigVersionResponse |
setServiceConfigVersion(String serviceName,
Long version,
String user,
String note)
Apply specified service config version (rollback)
|
void |
setSessionAttribute(String key,
Object value)
Sets or adds an attribute in the session for this cluster
|
void |
setUpgradeEntity(UpgradeEntity upgradeEntity)
Sets or clears the associated upgrade with the cluster.
|
List<Host> |
transitionHostsToInstalling(RepositoryVersionEntity repoVersionEntity,
VersionDefinitionXml versionDefinitionXml,
boolean forceInstalled)
Creates or updates host versions for all of the hosts within a cluster
based on state of cluster stack version.
|
long getClusterId()
String getClusterName()
void setClusterName(String clusterName)
Long getResourceId()
void addService(Service service)
service
- Service getService(String serviceName) throws org.apache.ambari.server.AmbariException
serviceName
- org.apache.ambari.server.AmbariException
Service getServiceByComponentName(String componentName) throws org.apache.ambari.server.AmbariException
componentName
- org.apache.ambari.server.AmbariException
List<ServiceComponentHost> getServiceComponentHosts(String hostname)
hostname
- Map<String,Set<String>> getServiceComponentHostMap(Set<String> hostNames, Set<String> serviceNames)
This may may be filtered by host and/or service by optionally providing a set of hostname
and/or service names to use as a filter. null
for either filter indicates no
filter (or all), an empty set indicates a complete filter (or none).
hostNames
- serviceNames
- List<ServiceComponentHost> getServiceComponentHosts(String serviceName, String componentName)
null
, all components for the requested service will be returned.serviceName
- the name a the desired servicecomponentName
- the name a the desired component - null indicates all components for the serviceList<ServiceComponentHost> getServiceComponentHosts()
Collection<Host> getHosts()
Set<String> getHosts(String serviceName, String componentName)
serviceName
- componentName
- Host getHost(String hostName)
hostName
- the host nameHost
Host getHost(Long hostId)
hostId
- the host idHost
void addServiceComponentHosts(Collection<ServiceComponentHost> serviceComponentHosts) throws org.apache.ambari.server.AmbariException
serviceComponentHosts
- org.apache.ambari.server.AmbariException
void removeServiceComponentHost(ServiceComponentHost svcCompHost) throws org.apache.ambari.server.AmbariException
svcCompHost
- org.apache.ambari.server.AmbariException
StackId getDesiredStackVersion()
void setDesiredStackVersion(StackId stackVersion) throws org.apache.ambari.server.AmbariException
stackVersion
- org.apache.ambari.server.AmbariException
StackId getCurrentStackVersion()
void setCurrentStackVersion(StackId stackVersion) throws org.apache.ambari.server.AmbariException
stackVersion
- org.apache.ambari.server.AmbariException
List<Host> transitionHostsToInstalling(RepositoryVersionEntity repoVersionEntity, VersionDefinitionXml versionDefinitionXml, boolean forceInstalled) throws org.apache.ambari.server.AmbariException
RepositoryVersionState.INSTALLING
).
Hosts that are in maintenance mode will be transitioned directly into
RepositoryVersionState.OUT_OF_SYNC
instead. Hosts which do not need
the version distributed to them will move into the
RepositoryVersionState.NOT_REQUIRED
state.repoVersionEntity
- the repository that the hosts are being transitioned for (not
null
).versionDefinitionXml
- the VDF, or null
if none.forceInstalled
- if true
, then this will transition everything directly to
RepositoryVersionState.INSTALLED
instead of
RepositoryVersionState.INSTALLING
. Hosts which should
received other states (like
RepositoryVersionState.NOT_REQUIRED
will continue to
receive those states.org.apache.ambari.server.AmbariException
State getProvisioningState()
State.INIT
or State.INSTALLED
, never
null
.void setProvisioningState(State provisioningState)
provisioningState
- the provisioning state, not null
.SecurityType getSecurityType()
void setSecurityType(SecurityType securityType)
securityType
- a SecurityType to setMap<String,Config> getConfigsByType(String configType)
configType
- the config type to returnMap<PropertyInfo.PropertyType,Set<String>> getConfigPropertiesTypes(String configType)
configType
- the config type to returnMap<PropertyInfo.PropertyType,Set<String>> getConfigPropertiesTypes(String configType, StackId stackId)
configType
- the config type to returnstackId
- the stack to scan properties forConfig getConfig(String configType, String versionTag)
configType
- the config type to findversionTag
- the config version tag to findConfig
object, or null
if the specific type
and version have not been set.List<Config> getLatestConfigsWithTypes(Collection<String> types)
Config getConfigByVersion(String configType, Long configVersion)
configType
- the config type to findconfigVersion
- the config version to findConfig
object, or null
if the specific type
and version have not been set.void addConfig(Config config)
config
- the config instance to addCollection<Config> getAllConfigs()
ServiceConfigVersionResponse addDesiredConfig(String user, Set<Config> configs) throws org.apache.ambari.server.AmbariException
user
- the user making the change for audit purposesconfigs
- the set of Config
objects to set as desiredtrue
if the config was added, or false
if the config is already set as the currentorg.apache.ambari.server.AmbariException
ServiceConfigVersionResponse addDesiredConfig(String user, Set<Config> configs, String serviceConfigVersionNote) throws org.apache.ambari.server.AmbariException
user
- the user making the change for audit purposesconfigs
- the set of Config
objects to set as desiredserviceConfigVersionNote
- note to attach to service config version if createdtrue
if the config was added, or false
if the config is already set as the currentorg.apache.ambari.server.AmbariException
ServiceConfigVersionResponse createServiceConfigVersion(String serviceName, String user, String note, ConfigGroup configGroup) throws org.apache.ambari.server.AmbariException
org.apache.ambari.server.AmbariException
String getServiceForConfigTypes(Collection<String> configTypes)
ServiceConfigVersionResponse setServiceConfigVersion(String serviceName, Long version, String user, String note) throws org.apache.ambari.server.AmbariException
serviceName
- service nameversion
- service config versionuser
- the user making the change for audit purposesnote
- org.apache.ambari.server.AmbariException
Map<String,Collection<ServiceConfigVersionResponse>> getActiveServiceConfigVersions()
List<ServiceConfigVersionResponse> getActiveServiceConfigVersionResponse(String serviceName)
serviceName
- service nameList<ServiceConfigVersionResponse> getServiceConfigVersions()
Config getDesiredConfigByType(String configType)
configType
- the type of configurationConfig
instance, or null
if the type has
not been set.boolean isConfigTypeExists(String configType)
configType
- the type of configurationtrue
if config type exists, else - false
Map<String,DesiredConfig> getDesiredConfigs()
Map<String,DesiredConfig> getDesiredConfigs(boolean cachedConfigEntities)
cachedConfigEntities
- retrieves cluster config entities from the cache if true, otherwise from the DB directly.ClusterEntity getClusterEntity()
Map<String,Set<DesiredConfig>> getAllDesiredConfigVersions()
ClusterResponse convertToResponse() throws org.apache.ambari.server.AmbariException
org.apache.ambari.server.AmbariException
void refresh()
void debugDump(StringBuilder sb)
sb
- void deleteAllServices() throws org.apache.ambari.server.AmbariException
org.apache.ambari.server.AmbariException
void deleteService(String serviceName, DeleteHostComponentStatusMetaData deleteMetaData) throws org.apache.ambari.server.AmbariException
serviceName
- org.apache.ambari.server.AmbariException
boolean canBeRemoved()
void delete() throws org.apache.ambari.server.AmbariException
org.apache.ambari.server.AmbariException
Service addService(String serviceName, RepositoryVersionEntity repositoryVersion) throws org.apache.ambari.server.AmbariException
serviceName
- the name of the service to add (not null
).repositoryVersion
- the repository from which the service should be installed (not
null
).org.apache.ambari.server.AmbariException
Map<Long,Map<String,DesiredConfig>> getHostsDesiredConfigs(Collection<Long> hostIds)
hostIds
- Map<Long,Map<String,DesiredConfig>> getAllHostsDesiredConfigs()
void addConfigGroup(ConfigGroup configGroup) throws org.apache.ambari.server.AmbariException
configGroup
- org.apache.ambari.server.AmbariException
Map<Long,ConfigGroup> getConfigGroups()
void deleteConfigGroup(Long id) throws org.apache.ambari.server.AmbariException
id
- org.apache.ambari.server.AmbariException
Map<Long,ConfigGroup> getConfigGroupsByHostname(String hostname) throws org.apache.ambari.server.AmbariException
hostname
- org.apache.ambari.server.AmbariException
ConfigGroup getConfigGroupsById(Long configId)
configId
- id of config group to returnMap<Long,ConfigGroup> getConfigGroupsByServiceName(String serviceName)
serviceName
- void addRequestExecution(RequestExecution requestExecution) throws org.apache.ambari.server.AmbariException
requestExecution
- org.apache.ambari.server.AmbariException
Map<Long,RequestExecution> getAllRequestExecutions()
void deleteRequestExecution(Long id) throws org.apache.ambari.server.AmbariException
id
- org.apache.ambari.server.AmbariException
Long getNextConfigVersion(String type)
type
- config typeMap<ServiceComponentHostEvent,String> processServiceComponentHostEvents(com.google.common.collect.ListMultimap<String,ServiceComponentHostEvent> eventMap)
eventMap
- serviceName - event mappingboolean checkPermission(PrivilegeEntity privilegeEntity, boolean readOnly)
privilegeEntity
- the privilegereadOnly
- indicate whether or not this check is for a read only operationvoid addSessionAttributes(Map<String,Object> attributes)
attributes
- the session attributesvoid setSessionAttribute(String key, Object value)
key
- the name of the key which identifies the attribute in the mapvalue
- the value to setvoid removeSessionAttribute(String key)
key
- the name of the key which identifies the attribute in the mapMap<String,Object> getSessionAttributes()
void applyLatestConfigurations(StackId stackId, String serviceName)
stackId
- the stack to use when finding the latest configurations (not
null
).serviceName
- the service to modify configurations for (not null
).void removeConfigurations(StackId stackId, String serviceName)
stackId
- the stack to use when finding the configurations to remove (not
null
).serviceName
- the service to rmeove configurations for (not null
).boolean isBluePrintDeployed()
UpgradeEntity getUpgradeInProgress()
UpgradeEntity
if there is an upgrade in progress or an
upgrade that has been suspended. This will return the associated
UpgradeEntity
if it exists.null
if none.void setUpgradeEntity(UpgradeEntity upgradeEntity) throws org.apache.ambari.server.AmbariException
upgradeEntity
- the upgrade entity to set for cluster, or null
for none.org.apache.ambari.server.AmbariException
boolean isUpgradeSuspended()
true
if the last upgrade is suspendedString getServiceByConfigType(String configType)
configType
- the config type to look up the service byString getClusterProperty(String propertyName, String defaultValue)
cluster-env/propertyName
where
propertyName
is the paramter specified to the method. This will use
the desired configuration for cluster-env
.
The value is cached on this Cluster
instance, so subsequent calls
will not inclur a lookup penalty. This class also responds to
ClusterConfigChangedEvent
in order to clear the cache.propertyName
- the property to lookup in cluster-env
(not null
).defaultValue
- a default value to cache return if none exists (may be
null
).int getClusterSize()
RoleCommandOrder getRoleCommandOrder()
RoleCommandOrder
for this cluster.null
).void addSuspendedUpgradeParameters(Map<String,String> commandParams, Map<String,String> roleParams)
commandParams
- the command parameter map to supplement (not null
).roleParams
- the role parameter map to supplement (not null
).Map<String,Map<String,String>> getComponentVersionMap()
org.apache.ambari.spi.ClusterInformation buildClusterInformation()
ClusterInformation
instance from a Cluster
.ClusterInformation
instance comprised of simple POJOs
and SPI classes.Copyright © 2022 Apache Software Foundation. All rights reserved.