public class HostImpl extends Object implements Host
Constructor and Description |
---|
HostImpl(HostEntity hostEntity,
com.google.gson.Gson gson,
HostDAO hostDAO,
HostStateDAO hostStateDAO) |
Modifier and Type | Method and Description |
---|---|
boolean |
addDesiredConfig(long clusterId,
boolean selected,
String user,
Config config)
Adds a desired configuration to the host instance.
|
void |
calculateHostStatus(Long clusterId) |
int |
compareTo(Object o) |
HostResponse |
convertToResponse() |
boolean |
equals(Object o) |
AgentVersion |
getAgentVersion()
Version of the Ambari Agent running on the host
|
AgentVersion |
getAgentVersion(HostStateEntity hostStateEntity)
Gets version of the ambari agent running on the host.
|
List<HostVersionEntity> |
getAllHostVersions()
Get all of the HostVersionEntity objects for the host.
|
long |
getAvailableMemBytes()
Get the Amount of available memory for the Host.
|
int |
getCpuCount() |
Integer |
getCurrentPingPort() |
Map<String,DesiredConfig> |
getDesiredConfigs(long clusterId)
Gets all the selected configurations for the host.
|
Map<String,HostConfig> |
getDesiredHostConfigs(Cluster cluster,
Map<String,DesiredConfig> clusterDesiredConfigs)
Get the desired configurations for the host including overrides
|
List<DiskInfo> |
getDisksInfo()
Get information on disks available on the host.
|
HostHealthStatus |
getHealthStatus() |
HostHealthStatus |
getHealthStatus(HostStateEntity hostStateEntity)
Gets the health status from host attributes
|
Map<String,String> |
getHostAttributes()
Get additional host attributes
For example, public/hostname/IP for AWS
|
Map<String,String> |
getHostAttributes(HostEntity hostEntity)
Gets host attributes from host entity
|
HostEntity |
getHostEntity() |
Long |
getHostId() |
String |
getHostName() |
HostStateEntity |
getHostStateEntity() |
String |
getIPv4()
IPv4 assigned to the Host
|
String |
getIPv6()
IPv6 assigned to the Host
|
AgentEnv |
getLastAgentEnv()
Gets the latest agent environment that arrived in a heartbeat.
|
long |
getLastAgentStartTime()
Time the Ambari Agent was started.
|
long |
getLastHeartbeatTime()
Last time the Ambari Server received a heartbeat from the Host
( Unix timestamp )
|
long |
getLastRegistrationTime()
Last time the host registered with the Ambari Server
( Unix timestamp )
|
MaintenanceState |
getMaintenanceState(long clusterId) |
String |
getOsArch()
Get the OS Architecture.
|
String |
getOsFamily()
Get the os Family:
redhat6: for centos6, rhel6, oraclelinux6 ..
|
String |
getOsFamily(Map<String,String> hostAttributes)
Gets the os family from host attributes
|
String |
getOSFamilyFromHostAttributes(Map<String,String> hostAttributes) |
String |
getOsInfo()
Get the General OS information.
|
String |
getOsType()
Get the OS Type: RHEL6/CentOS6/...
|
int |
getPhCpuCount() |
String |
getPrefix()
Get the prefix path of all logs
|
String |
getPublicHostName()
Sets the public-facing host name.
|
String |
getRackInfo() |
RecoveryReport |
getRecoveryReport()
Get detailed recovery report for the host
|
HostState |
getState()
Get Current Host State
|
String |
getStatus()
Get Current Host Status
|
long |
getTimeInState()
Get time spent in the current state i.e.
|
long |
getTotalMemBytes()
Get the Amount of physical memory for the Host.
|
void |
handleEvent(HostEvent event)
Send an event to the Host's StateMachine
|
boolean |
hasComponentsAdvertisingVersions(StackId stackId)
Gets whether this host has components which advertise their version.
|
int |
hashCode() |
void |
importHostInfo(HostInfo hostInfo) |
boolean |
isRepositoryVersionCorrect(RepositoryVersionEntity repositoryVersion)
Gets whether all host components whose desired repository version matches
the repository version specified have reported the correct version and are
no longer upgrading.
|
void |
setAgentVersion(AgentVersion agentVersion) |
void |
setAvailableMemBytes(long availableMemBytes)
Set the Amount of available memory for the Host.
|
void |
setCpuCount(int cpuCount) |
void |
setCurrentPingPort(Integer currentPingPort) |
void |
setDisksInfo(List<DiskInfo> disksInfo) |
void |
setHealthStatus(HostHealthStatus healthStatus) |
void |
setHostAttributes(Map<String,String> hostAttributes) |
void |
setIPv4(String ip) |
void |
setIPv6(String ip) |
void |
setLastAgentEnv(AgentEnv env)
Sets the latest agent environment that arrived in a heartbeat.
|
void |
setLastAgentStartTime(long lastAgentStartTime) |
void |
setLastHeartbeatTime(long lastHeartbeatTime) |
void |
setLastRegistrationTime(long lastRegistrationTime) |
void |
setMaintenanceState(long clusterId,
MaintenanceState state)
Sets the maintenance state for the host.
|
void |
setOsArch(String osArch) |
void |
setOsInfo(String osInfo) |
void |
setOsType(String osType) |
void |
setPhCpuCount(int phCpuCount) |
void |
setPrefix(String prefix)
Set the prefix path of all logs of the host
|
void |
setPublicHostName(String hostName)
Gets the public-facing host name.
|
void |
setRackInfo(String rackInfo) |
void |
setRecoveryReport(RecoveryReport recoveryReport)
Set detailed recovery report for the host
|
void |
setState(HostState state)
Set the State of the Host
|
void |
setStateMachineState(HostState state)
Set state of host's state machine.
|
void |
setStatus(String status)
Set the Status of the Host
|
void |
setTimeInState(long timeInState) |
void |
setTotalMemBytes(long totalMemBytes)
Set the Amount of physical memory for the Host.
|
void |
updateHost(HostRegistrationRequestEvent e) |
void |
updateHostTimestamps(HostRegistrationRequestEvent e) |
@Inject public HostImpl(HostEntity hostEntity, com.google.gson.Gson gson, HostDAO hostDAO, HostStateDAO hostStateDAO)
public int compareTo(Object o)
compareTo
in interface Comparable
public void importHostInfo(HostInfo hostInfo)
importHostInfo
in interface Host
hostInfo
- the host informationpublic void setLastAgentEnv(AgentEnv env)
Host
setLastAgentEnv
in interface Host
public AgentEnv getLastAgentEnv()
Host
getLastAgentEnv
in interface Host
public void setState(HostState state)
Host
public void setStateMachineState(HostState state)
Host
setStateMachineState
in interface Host
public void handleEvent(HostEvent event) throws InvalidStateTransitionException
Host
handleEvent
in interface Host
event
- HostEventInvalidStateTransitionException
public String getHostName()
getHostName
in interface Host
public Integer getCurrentPingPort()
getCurrentPingPort
in interface Host
public void setCurrentPingPort(Integer currentPingPort)
setCurrentPingPort
in interface Host
currentPingPort
- the currentPingPort to setpublic void setPublicHostName(String hostName)
Host
setPublicHostName
in interface Host
public String getPublicHostName()
Host
getPublicHostName
in interface Host
public void setIPv4(String ip)
public void setIPv6(String ip)
public int getCpuCount()
getCpuCount
in interface Host
public void setCpuCount(int cpuCount)
setCpuCount
in interface Host
cpuCount
- the cpuCount to setpublic int getPhCpuCount()
getPhCpuCount
in interface Host
public void setPhCpuCount(int phCpuCount)
setPhCpuCount
in interface Host
phCpuCount
- the physical cpu cores to setpublic long getTotalMemBytes()
Host
getTotalMemBytes
in interface Host
public void setTotalMemBytes(long totalMemBytes)
Host
setTotalMemBytes
in interface Host
totalMemBytes
- the totalMemBytes to setpublic long getAvailableMemBytes()
Host
getAvailableMemBytes
in interface Host
public void setAvailableMemBytes(long availableMemBytes)
Host
setAvailableMemBytes
in interface Host
availableMemBytes
- the availableMemBytes to setpublic String getOsArch()
Host
public void setOsArch(String osArch)
public String getOsInfo()
Host
public void setOsInfo(String osInfo)
public String getOsType()
Host
public void setOsType(String osType)
public String getOsFamily()
Host
getOsFamily
in interface Host
public String getOsFamily(Map<String,String> hostAttributes)
Host
getOsFamily
in interface Host
hostAttributes
- host attributespublic String getOSFamilyFromHostAttributes(Map<String,String> hostAttributes)
getOSFamilyFromHostAttributes
in interface Host
public List<DiskInfo> getDisksInfo()
Host
getDisksInfo
in interface Host
public void setDisksInfo(List<DiskInfo> disksInfo)
setDisksInfo
in interface Host
disksInfo
- the disksInfo to setpublic RecoveryReport getRecoveryReport()
Host
getRecoveryReport
in interface Host
public void setRecoveryReport(RecoveryReport recoveryReport)
Host
setRecoveryReport
in interface Host
public HostHealthStatus getHealthStatus()
getHealthStatus
in interface Host
public HostHealthStatus getHealthStatus(HostStateEntity hostStateEntity)
Host
getHealthStatus
in interface Host
hostStateEntity
- host attributespublic void setHealthStatus(HostHealthStatus healthStatus)
setHealthStatus
in interface Host
healthStatus
- the healthStatus to setpublic String getPrefix()
Host
public void setPrefix(String prefix)
Host
public Map<String,String> getHostAttributes()
Host
getHostAttributes
in interface Host
public Map<String,String> getHostAttributes(HostEntity hostEntity)
Host
getHostAttributes
in interface Host
hostEntity
- host entitypublic void setHostAttributes(Map<String,String> hostAttributes)
setHostAttributes
in interface Host
hostAttributes
- the hostAttributes to setpublic String getRackInfo()
getRackInfo
in interface Host
public void setRackInfo(String rackInfo)
setRackInfo
in interface Host
rackInfo
- the rackInfo to setpublic long getLastRegistrationTime()
Host
getLastRegistrationTime
in interface Host
public void setLastRegistrationTime(long lastRegistrationTime)
setLastRegistrationTime
in interface Host
lastRegistrationTime
- the lastRegistrationTime to setpublic long getLastHeartbeatTime()
Host
getLastHeartbeatTime
in interface Host
public void setLastHeartbeatTime(long lastHeartbeatTime)
setLastHeartbeatTime
in interface Host
lastHeartbeatTime
- the lastHeartbeatTime to setpublic long getLastAgentStartTime()
Host
getLastAgentStartTime
in interface Host
public void setLastAgentStartTime(long lastAgentStartTime)
setLastAgentStartTime
in interface Host
lastAgentStartTime
- the lastAgentStartTime to setpublic AgentVersion getAgentVersion()
Host
getAgentVersion
in interface Host
public AgentVersion getAgentVersion(HostStateEntity hostStateEntity)
Host
getAgentVersion
in interface Host
hostStateEntity
- host state entitypublic void setAgentVersion(AgentVersion agentVersion)
setAgentVersion
in interface Host
agentVersion
- the agentVersion to setpublic long getTimeInState()
Host
getTimeInState
in interface Host
public void setTimeInState(long timeInState)
setTimeInState
in interface Host
timeInState
- the timeInState to setpublic void setStatus(String status)
Host
public HostResponse convertToResponse()
convertToResponse
in interface Host
public boolean addDesiredConfig(long clusterId, boolean selected, String user, Config config)
Host
addDesiredConfig
in interface Host
clusterId
- the cluster id that the config applies toselected
- true
if the configuration is selected. Applies
only to remove the override, otherwise this value should always be true
.user
- the user making the change for audit purposesconfig
- the configuration objecttrue
if the config was added, or false
if the config is already set as the currentpublic Map<String,DesiredConfig> getDesiredConfigs(long clusterId)
Host
DesiredConfig
instances.getDesiredConfigs
in interface Host
public Map<String,HostConfig> getDesiredHostConfigs(Cluster cluster, Map<String,DesiredConfig> clusterDesiredConfigs) throws org.apache.ambari.server.AmbariException
getDesiredHostConfigs
in interface Host
clusterDesiredConfigs
- the desired configurations for the cluster. Obtaining these can be
expensive and since this method operates on hosts, it could be
called 1,000's of times when generating host responses. Therefore,
the caller should build these once and pass them in. If
null
, then this method will retrieve them at runtime,
incurring a performance penality.org.apache.ambari.server.AmbariException
public void setMaintenanceState(long clusterId, MaintenanceState state)
Host
setMaintenanceState
in interface Host
clusterId
- the cluster idstate
- the statepublic MaintenanceState getMaintenanceState(long clusterId)
getMaintenanceState
in interface Host
clusterId
- the cluster idpublic List<HostVersionEntity> getAllHostVersions()
getAllHostVersions
in interface Host
public HostEntity getHostEntity()
getHostEntity
in interface Host
public HostStateEntity getHostStateEntity()
public boolean hasComponentsAdvertisingVersions(StackId stackId) throws org.apache.ambari.server.AmbariException
hasComponentsAdvertisingVersions
in interface Host
stackId
- the version of the stack to use when checking version
advertise-ability.true
if at least 1 component on this host advertises its
version.org.apache.ambari.server.AmbariException
- if there is a problem retrieving the component from the stack.ComponentInfo.isVersionAdvertised()
public void calculateHostStatus(Long clusterId) throws org.apache.ambari.server.AmbariException
calculateHostStatus
in interface Host
org.apache.ambari.server.AmbariException
public void updateHost(HostRegistrationRequestEvent e)
public void updateHostTimestamps(HostRegistrationRequestEvent e)
public boolean isRepositoryVersionCorrect(RepositoryVersionEntity repositoryVersion) throws org.apache.ambari.server.AmbariException
isRepositoryVersionCorrect
in interface Host
repositoryVersion
- the repository version to check for (not null
).true
if all components on this host have checked in with
the correct version if their desired repository matches the one
specified.org.apache.ambari.server.AmbariException
Copyright © 2022 Apache Software Foundation. All rights reserved.