Constructor and Description |
---|
ClustersImpl(ClusterDAO clusterDAO,
ClusterFactory clusterFactory,
HostDAO hostDAO,
HostFactory hostFactory) |
Modifier and Type | Method and Description |
---|---|
void |
addCluster(String clusterName,
StackId stackId)
Add a new Cluster
|
void |
addCluster(String clusterName,
StackId stackId,
SecurityType securityType)
Add a new cluster
|
void |
addHost(String hostname)
Register a host by creating a
HostEntity object in the database and setting its state to
HostState.INIT . |
void |
addSessionAttributes(String name,
Map<String,Object> attributes)
Add the given map of attributes to the session for the cluster identified by the given name.
|
boolean |
checkPermission(String clusterName,
boolean readOnly)
Determine whether or not access to the cluster resource identified
by the given cluster name should be allowed based on the permissions
granted to the current user.
|
void |
debugDump(StringBuilder sb)
Produces a debug dump into the supplied string buffer
|
void |
deleteCluster(String clusterName)
Deletes the cluster identified by the name
|
void |
deleteHost(String hostname)
Delete a host entirely from the cluster and all database tables, except
AlertHistory.
|
protected Cluster |
findCluster(String name)
Find the cluster for the given name.
|
Cluster |
getCluster(Long clusterId)
Gets the Cluster given the cluster id
|
Cluster |
getCluster(String clusterName)
Gets the Cluster given the cluster name
|
Cluster |
getClusterById(long id)
Gets the cluster using the id.
|
Map<String,Cluster> |
getClusters()
Get all clusters
|
Set<Cluster> |
getClustersForHost(String hostname)
Returns all the cluster names for this hostname
|
int |
getClusterSize(String clusterName)
Returns the number of hosts that form the cluster identified by the given name.
|
Host |
getHost(String hostname)
Get a Host object managed by this server
|
Host |
getHostById(Long hostId)
Get a Host object managed by this server
|
Map<Long,Host> |
getHostIdsForCluster(String clusterName)
Gets all the host Ids associated with the cluster
|
List<Host> |
getHosts()
Get all hosts being tracked by the Ambari server
|
Map<String,Host> |
getHostsForCluster(String clusterName)
Gets all the hosts associated with the cluster
|
Map<String,Object> |
getSessionAttributes(String name)
Get the map of session attributes for the cluster identified by the given name.
|
boolean |
hostExists(String hostname)
Check if host exists
|
void |
invalidate(Cluster cluster)
Invalidates the specified cluster by retrieving it from the database and
refreshing all of the internal stateful collections.
|
void |
invalidateAllClusters()
Invalidates all clusters by retrieving each from the database and refreshing all of its internal
stateful collections.
|
boolean |
isHostMappedToCluster(long clusterId,
String hostName)
Gets whether the specified cluster has a mapping for the specified host.
|
void |
mapAndPublishHostsToCluster(Set<String> hostnames,
String clusterName)
For each host, attempts to map it to the cluster, and apply the cluster's current version to the host.
|
void |
mapHostToCluster(String hostname,
String clusterName)
Attempts to map the host to the cluster via clusterhostmapping table if not already present, and add a host_version
record for the cluster's currently applied (stack, version) if not already present.
|
void |
publishHostsDeletion(Set<Long> hostIds,
Set<String> hostNames)
Publish event set of hosts were removed
|
void |
unmapHostFromCluster(String hostname,
String clusterName)
Removes a host from a cluster.
|
void |
updateClusterName(String oldName,
String newName)
Updates the name of the cluster
|
void |
updateHostMappings(Host host)
Updates the internal mappings of hosts using the specified host.
|
void |
updateHostWithClusterAndAttributes(Map<String,Set<String>> hostClusters,
Map<String,Map<String,String>> hostAttributes)
Update the host set for clusters and the host attributes associated with the hosts
|
@Inject public ClustersImpl(ClusterDAO clusterDAO, ClusterFactory clusterFactory, HostDAO hostDAO, HostFactory hostFactory)
public void addCluster(String clusterName, StackId stackId) throws org.apache.ambari.server.AmbariException
Clusters
addCluster
in interface Clusters
clusterName
- the cluster name (not null
).stackId
- the stack for the cluster (not null
).org.apache.ambari.server.AmbariException
public void addCluster(String clusterName, StackId stackId, SecurityType securityType) throws org.apache.ambari.server.AmbariException
Clusters
addCluster
in interface Clusters
clusterName
- the cluster name (not null
).stackId
- the stack for the cluster (not null
).securityType
- the cluster will be created with this security type.org.apache.ambari.server.AmbariException
public Cluster getCluster(String clusterName) throws org.apache.ambari.server.AmbariException
Clusters
getCluster
in interface Clusters
clusterName
- Name of the Cluster to retrieveCluster
identified by the given nameorg.apache.ambari.server.AmbariException
public Cluster getCluster(Long clusterId) throws org.apache.ambari.server.AmbariException
Clusters
getCluster
in interface Clusters
clusterId
- Id of the Cluster to retrieveCluster
identified by the given idorg.apache.ambari.server.AmbariException
public Cluster getClusterById(long id) throws org.apache.ambari.server.AmbariException
Clusters
getClusterById
in interface Clusters
id
- The identifier associated with the clusterCluster
identified by the identifierorg.apache.ambari.server.AmbariException
public List<Host> getHosts()
Clusters
public Set<Cluster> getClustersForHost(String hostname) throws org.apache.ambari.server.AmbariException
Clusters
getClustersForHost
in interface Clusters
org.apache.ambari.server.AmbariException
public Host getHost(String hostname) throws org.apache.ambari.server.AmbariException
Clusters
public boolean hostExists(String hostname)
Clusters
hostExists
in interface Clusters
hostname
- Name of the host requestedpublic boolean isHostMappedToCluster(long clusterId, String hostName)
isHostMappedToCluster
in interface Clusters
clusterId
- the cluster IDhostName
- the host (not null
).true
if the host belongs to the cluster, false
otherwise.public Host getHostById(Long hostId) throws org.apache.ambari.server.AmbariException
Clusters
getHostById
in interface Clusters
hostId
- Host Id from the HostEntity
objectyorg.apache.ambari.server.AmbariException
public void updateHostMappings(Host host)
updateHostMappings
in interface Clusters
host
- the host to update the internal mappings for.public void addHost(String hostname) throws org.apache.ambari.server.AmbariException
HostEntity
object in the database and setting its state to
HostState.INIT
. This does not add the host the cluster.public void updateHostWithClusterAndAttributes(Map<String,Set<String>> hostClusters, Map<String,Map<String,String>> hostAttributes) throws org.apache.ambari.server.AmbariException
Clusters
updateHostWithClusterAndAttributes
in interface Clusters
org.apache.ambari.server.AmbariException
public void mapAndPublishHostsToCluster(Set<String> hostnames, String clusterName) throws org.apache.ambari.server.AmbariException
mapAndPublishHostsToCluster
in interface Clusters
hostnames
- Collection of host namesclusterName
- Cluster nameorg.apache.ambari.server.AmbariException
public void mapHostToCluster(String hostname, String clusterName) throws org.apache.ambari.server.AmbariException
mapHostToCluster
in interface Clusters
hostname
- Host nameclusterName
- Cluster nameorg.apache.ambari.server.AmbariException
- May throw a DuplicateResourceException.public Map<String,Cluster> getClusters()
Clusters
getClusters
in interface Clusters
Map
of clusters with cluster name as keypublic void updateClusterName(String oldName, String newName)
Clusters
updateClusterName
in interface Clusters
public void debugDump(StringBuilder sb)
Clusters
public Map<String,Host> getHostsForCluster(String clusterName)
Clusters
getHostsForCluster
in interface Clusters
clusterName
- The name of the clusterMap
containing host name and Host
public Map<Long,Host> getHostIdsForCluster(String clusterName) throws org.apache.ambari.server.AmbariException
Clusters
getHostIdsForCluster
in interface Clusters
clusterName
- The name of the clusterMap
containing host id and Host
org.apache.ambari.server.AmbariException
public void deleteCluster(String clusterName) throws org.apache.ambari.server.AmbariException
Clusters
deleteCluster
in interface Clusters
clusterName
- The name of the clusterorg.apache.ambari.server.AmbariException
public void unmapHostFromCluster(String hostname, String clusterName) throws org.apache.ambari.server.AmbariException
Clusters
unmapHostFromCluster
in interface Clusters
org.apache.ambari.server.AmbariException
public void deleteHost(String hostname) throws org.apache.ambari.server.AmbariException
HostNotFoundException
.deleteHost
in interface Clusters
hostname
- org.apache.ambari.server.AmbariException
public void publishHostsDeletion(Set<Long> hostIds, Set<String> hostNames) throws org.apache.ambari.server.AmbariException
Clusters
publishHostsDeletion
in interface Clusters
org.apache.ambari.server.AmbariException
public boolean checkPermission(String clusterName, boolean readOnly)
Clusters
checkPermission
in interface Clusters
clusterName
- the cluster namereadOnly
- indicate whether or not this check is for a read only operationpublic void addSessionAttributes(String name, Map<String,Object> attributes)
Clusters
addSessionAttributes
in interface Clusters
name
- the cluster nameattributes
- the session attributespublic Map<String,Object> getSessionAttributes(String name)
Clusters
getSessionAttributes
in interface Clusters
name
- the cluster namepublic int getClusterSize(String clusterName)
getClusterSize
in interface Clusters
clusterName
- the name that identifies the clusterprotected Cluster findCluster(String name)
name
- the cluster namepublic void invalidate(Cluster cluster)
invalidate
in interface Clusters
cluster
- the cluster to invalidate and refresh (not null
).public void invalidateAllClusters()
invalidateAllClusters
in interface Clusters
Copyright © 2022 Apache Software Foundation. All rights reserved.