| 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
ClustersaddCluster in interface ClustersclusterName - the cluster name (not null).stackId - the stack for the cluster (not null).org.apache.ambari.server.AmbariExceptionpublic void addCluster(String clusterName, StackId stackId, SecurityType securityType) throws org.apache.ambari.server.AmbariException
ClustersaddCluster in interface ClustersclusterName - 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.AmbariExceptionpublic Cluster getCluster(String clusterName) throws org.apache.ambari.server.AmbariException
ClustersgetCluster in interface ClustersclusterName - Name of the Cluster to retrieveCluster identified by the given nameorg.apache.ambari.server.AmbariExceptionpublic Cluster getCluster(Long clusterId) throws org.apache.ambari.server.AmbariException
ClustersgetCluster in interface ClustersclusterId - Id of the Cluster to retrieveCluster identified by the given idorg.apache.ambari.server.AmbariExceptionpublic Cluster getClusterById(long id) throws org.apache.ambari.server.AmbariException
ClustersgetClusterById in interface Clustersid - The identifier associated with the clusterCluster identified by the identifierorg.apache.ambari.server.AmbariExceptionpublic List<Host> getHosts()
Clusterspublic Set<Cluster> getClustersForHost(String hostname) throws org.apache.ambari.server.AmbariException
ClustersgetClustersForHost in interface Clustersorg.apache.ambari.server.AmbariExceptionpublic Host getHost(String hostname) throws org.apache.ambari.server.AmbariException
Clusterspublic boolean hostExists(String hostname)
ClustershostExists in interface Clustershostname - Name of the host requestedpublic boolean isHostMappedToCluster(long clusterId,
String hostName)
isHostMappedToCluster in interface ClustersclusterId - 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
ClustersgetHostById in interface ClustershostId - Host Id from the HostEntity objectyorg.apache.ambari.server.AmbariExceptionpublic void updateHostMappings(Host host)
updateHostMappings in interface Clustershost - 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
ClustersupdateHostWithClusterAndAttributes in interface Clustersorg.apache.ambari.server.AmbariExceptionpublic void mapAndPublishHostsToCluster(Set<String> hostnames, String clusterName) throws org.apache.ambari.server.AmbariException
mapAndPublishHostsToCluster in interface Clustershostnames - Collection of host namesclusterName - Cluster nameorg.apache.ambari.server.AmbariExceptionpublic void mapHostToCluster(String hostname, String clusterName) throws org.apache.ambari.server.AmbariException
mapHostToCluster in interface Clustershostname - Host nameclusterName - Cluster nameorg.apache.ambari.server.AmbariException - May throw a DuplicateResourceException.public Map<String,Cluster> getClusters()
ClustersgetClusters in interface ClustersMap of clusters with cluster name as keypublic void updateClusterName(String oldName, String newName)
ClustersupdateClusterName in interface Clusterspublic void debugDump(StringBuilder sb)
Clusterspublic Map<String,Host> getHostsForCluster(String clusterName)
ClustersgetHostsForCluster in interface ClustersclusterName - The name of the clusterMap containing host name and Hostpublic Map<Long,Host> getHostIdsForCluster(String clusterName) throws org.apache.ambari.server.AmbariException
ClustersgetHostIdsForCluster in interface ClustersclusterName - The name of the clusterMap containing host id and Hostorg.apache.ambari.server.AmbariExceptionpublic void deleteCluster(String clusterName) throws org.apache.ambari.server.AmbariException
ClustersdeleteCluster in interface ClustersclusterName - The name of the clusterorg.apache.ambari.server.AmbariExceptionpublic void unmapHostFromCluster(String hostname, String clusterName) throws org.apache.ambari.server.AmbariException
ClustersunmapHostFromCluster in interface Clustersorg.apache.ambari.server.AmbariExceptionpublic void deleteHost(String hostname) throws org.apache.ambari.server.AmbariException
HostNotFoundException.deleteHost in interface Clustershostname - org.apache.ambari.server.AmbariExceptionpublic void publishHostsDeletion(Set<Long> hostIds, Set<String> hostNames) throws org.apache.ambari.server.AmbariException
ClusterspublishHostsDeletion in interface Clustersorg.apache.ambari.server.AmbariExceptionpublic boolean checkPermission(String clusterName, boolean readOnly)
ClusterscheckPermission in interface ClustersclusterName - the cluster namereadOnly - indicate whether or not this check is for a read only operationpublic void addSessionAttributes(String name, Map<String,Object> attributes)
ClustersaddSessionAttributes in interface Clustersname - the cluster nameattributes - the session attributespublic Map<String,Object> getSessionAttributes(String name)
ClustersgetSessionAttributes in interface Clustersname - the cluster namepublic int getClusterSize(String clusterName)
getClusterSize in interface ClustersclusterName - the name that identifies the clusterprotected Cluster findCluster(String name)
name - the cluster namepublic void invalidate(Cluster cluster)
invalidate in interface Clusterscluster - the cluster to invalidate and refresh (not null).public void invalidateAllClusters()
invalidateAllClusters in interface ClustersCopyright © 2022 Apache Software Foundation. All rights reserved.