in ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java [375:474]
public void importHostInfo(HostInfo hostInfo) {
try {
writeLock.lock();
if (hostInfo.getIPAddress() != null
&& !hostInfo.getIPAddress().isEmpty()) {
setIPv4(hostInfo.getIPAddress());
setIPv6(hostInfo.getIPAddress());
}
setCpuCount(hostInfo.getProcessorCount());
setPhCpuCount(hostInfo.getPhysicalProcessorCount());
setTotalMemBytes(hostInfo.getMemoryTotal());
setAvailableMemBytes(hostInfo.getFreeMemory());
if (hostInfo.getArchitecture() != null
&& !hostInfo.getArchitecture().isEmpty()) {
setOsArch(hostInfo.getArchitecture());
}
if (hostInfo.getOS() != null
&& !hostInfo.getOS().isEmpty()) {
String osType = hostInfo.getOS();
if (hostInfo.getOSRelease() != null) {
String[] release = hostInfo.getOSRelease().split("\\.");
if (release.length > 0) {
osType += release[0];
}
}
setOsType(osType.toLowerCase());
}
if (hostInfo.getMounts() != null
&& !hostInfo.getMounts().isEmpty()) {
setDisksInfo(hostInfo.getMounts());
}
// FIXME add all other information into host attributes
this.setAgentVersion(new AgentVersion(
hostInfo.getAgentUserId()));
Map<String, String> attrs = new HashMap<String, String>();
if (hostInfo.getHardwareIsa() != null) {
attrs.put(HARDWAREISA, hostInfo.getHardwareIsa());
}
if (hostInfo.getHardwareModel() != null) {
attrs.put(HARDWAREMODEL, hostInfo.getHardwareModel());
}
if (hostInfo.getInterfaces() != null) {
attrs.put(INTERFACES, hostInfo.getInterfaces());
}
if (hostInfo.getKernel() != null) {
attrs.put(KERNEL, hostInfo.getKernel());
}
if (hostInfo.getKernelMajVersion() != null) {
attrs.put(KERNELMAJOREVERSON, hostInfo.getKernelMajVersion());
}
if (hostInfo.getKernelRelease() != null) {
attrs.put(KERNELRELEASE, hostInfo.getKernelRelease());
}
if (hostInfo.getKernelVersion() != null) {
attrs.put(KERNELVERSION, hostInfo.getKernelVersion());
}
if (hostInfo.getMacAddress() != null) {
attrs.put(MACADDRESS, hostInfo.getMacAddress());
}
if (hostInfo.getNetMask() != null) {
attrs.put(NETMASK, hostInfo.getNetMask());
}
if (hostInfo.getOSFamily() != null) {
attrs.put(OSFAMILY, hostInfo.getOSFamily());
}
if (hostInfo.getPhysicalProcessorCount() != 0) {
attrs.put(PHYSICALPROCESSORCOUNT,
Long.toString(hostInfo.getPhysicalProcessorCount()));
}
if (hostInfo.getProcessorCount() != 0) {
attrs.put(PROCESSORCOUNT,
Long.toString(hostInfo.getProcessorCount()));
}
if (Boolean.toString(hostInfo.getSeLinux()) != null) {
attrs.put(SELINUXENABLED, Boolean.toString(hostInfo.getSeLinux()));
}
if (hostInfo.getSwapSize() != null) {
attrs.put(SWAPSIZE, hostInfo.getSwapSize());
}
if (hostInfo.getSwapFree() != null) {
attrs.put(SWAPFREE, hostInfo.getSwapFree());
}
if (hostInfo.getTimeZone() != null) {
attrs.put(TIMEZONE, hostInfo.getTimeZone());
}
setHostAttributes(attrs);
saveIfPersisted();
}
finally {
writeLock.unlock();
}
}