You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ma...@apache.org on 2012/10/17 04:51:06 UTC

svn commit: r1399085 - in /incubator/ambari/branches/AMBARI-666: AMBARI-666-CHANGES.txt ambari-server/src/main/java/org/apache/ambari/server/agent/HostInfo.java ambari-server/src/test/java/org/apache/ambari/server/agent/AgentHostInfoTest.java

Author: mahadev
Date: Wed Oct 17 02:51:05 2012
New Revision: 1399085

URL: http://svn.apache.org/viewvc?rev=1399085&view=rev
Log:
AMBARI-874. Fix hostinfo reporting at the server and add a unit test for deserilization for the host information from agent. (mahadev)

Added:
    incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentHostInfoTest.java
Modified:
    incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HostInfo.java

Modified: incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt?rev=1399085&r1=1399084&r2=1399085&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Wed Oct 17 02:51:05 2012
@@ -12,6 +12,9 @@ AMBARI-666 branch (unreleased changes)
 
   NEW FEATURES
 
+  AMBARI-874. Fix hostinfo reporting at the server and add a unit test for
+  deserilization for the host information from agent. (mahadev)
+
   AMBARI-873. Support for multiple objects' updates in controller. (hitesh)
 
   AMBARI-870. Support metric types other than string (Tom Beerbower via

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HostInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HostInfo.java?rev=1399085&r1=1399084&r2=1399085&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HostInfo.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HostInfo.java Wed Oct 17 02:51:05 2012
@@ -21,6 +21,8 @@ package org.apache.ambari.server.agent;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.codehaus.jackson.annotate.JsonProperty;
+
 /**
  *
  * Data model for Ambari Agent to send hardware profile to Ambari Server.
@@ -59,250 +61,312 @@ public class HostInfo {
   private long uptime_days;
   private long uptime_hours;
 
+  @JsonProperty("architecture")
   public String getArchitecture() {
     return this.architecture;
   }
-
+  
+  @JsonProperty("architecture")
   public void setArchitecture(String architecture) {
     this.architecture = architecture;
   }
 
+  @JsonProperty("domain")
   public String getDomain() {
     return this.domain;
   }
-
+  
+  @JsonProperty("domain")
   public void setDomain(String domain) {
     this.domain = domain;
   }
 
+  @JsonProperty("fqdn")
   public String getFQDN() {
     return this.fqdn;
   }
-
+  
+  @JsonProperty("fqdn")
   public void setFQDN(String fqdn) {
     this.fqdn = fqdn;
   }
 
+  @JsonProperty("hardwareisa")
   public String getHardwareIsa() {
     return hardwareisa;
   }
 
+  @JsonProperty("hardwareisa")
   public void setHardwareIsa(String hardwareisa) {
     this.hardwareisa = hardwareisa;
   }
-
+  
+  @JsonProperty("hardwaremodel")
   public String getHardwareModel() {
     return this.hardwaremodel;
   }
 
+  @JsonProperty("hardwaremodel")
   public void setHardwareModel(String hardwaremodel) {
     this.hardwaremodel = hardwaremodel;
   }
 
+  @JsonProperty("hostname")
   public String getHostName() {
     return this.hostname;
   }
-
+  
+  @JsonProperty("hostname")
   public void setHostName(String hostname) {
     this.hostname = hostname;
   }
 
+  @JsonProperty("id")
   public String getAgentUserId() {
     return id;
   }
 
+  @JsonProperty("id")
   public void setAgentUserId(String id) {
     this.id = id;
   }
 
+  @JsonProperty("interfaces")
   public String getInterfaces() {
     return this.interfaces;
   }
-
+  
+  @JsonProperty("interfaces")
   public void setInterfaces(String interfaces) {
     this.interfaces = interfaces;
   }
 
+  @JsonProperty("ipaddress")
   public String getIPAddress() {
     return this.ipaddress;
   }
-
+  
+  @JsonProperty("ipaddress")
   public void setIPAddress(String ipaddress) {
     this.ipaddress = ipaddress;
   }
 
+  @JsonProperty("kernel")
   public String getKernel() {
     return this.kernel;
   }
 
+  @JsonProperty("kernel")
   public void setKernel(String kernel) {
     this.kernel = kernel;
   }
-
+  
+  @JsonProperty("kernelmajversion")
   public String getKernelMajVersion() {
     return this.kernelmajversion;
   }
-
+  
+  @JsonProperty("kernelmajversion")
   public void setKernelMajVersion(String kernelmajversion) {
     this.kernelmajversion = kernelmajversion;
   }
-
+  
+  @JsonProperty("kernelrelease")
   public String getKernelRelease() {
     return this.kernelrelease;
   }
-
+  
+  @JsonProperty("kernelrelease")
   public void setKernelRelease(String kernelrelease) {
     this.kernelrelease = kernelrelease;
   }
-
+  
+  @JsonProperty("kernelversion")
   public String getKernelVersion() {
     return this.kernelversion;
   }
 
+  @JsonProperty("kernelversion")
   public void setKernelVersion(String kernelversion) {
     this.kernelversion = kernelversion;
   }
 
+  @JsonProperty("macaddress")
   public String getMacAddress() {
     return this.macaddress;
   }
 
+  @JsonProperty("macaddress")
   public void setMacAddress(String macaddress) {
     this.macaddress = macaddress;
   }
 
+  @JsonProperty("memoryfree")
   public long getFreeMemory() {
     return this.memoryfree;
   }
-
+  
+  @JsonProperty("memoryfree")
   public void setFreeMemory(long memoryfree) {
     this.memoryfree = memoryfree;
   }
-
+  
+  @JsonProperty("memorysize")
   public long getMemorySize() {
     return this.memorysize;
   }
-
+  
+  @JsonProperty("memorysize")
   public void setMemorySize(long memorysize) {
     this.memorysize = memorysize;
   }
-
+  
+  @JsonProperty("mounts")
   public List<DiskInfo> getMounts() {
     return this.mounts;
   }
-
+  
+  @JsonProperty("mounts")
   public void setMounts(List<DiskInfo> mounts) {
     this.mounts = mounts;
   }
-
+  
+  @JsonProperty("memorytotal")
   public long getMemoryTotal() {
     return this.memorytotal;
   }
 
+  @JsonProperty("memorytotal")
   public void setMemoryTotal(long memorytotal) {
     this.memorytotal = memorytotal;
   }
-
+  
+  @JsonProperty("netmask")
   public String getNetMask() {
     return this.netmask;
   }
-
+  
+  @JsonProperty("netmask")
   public void setNetMask(String netmask) {
     this.netmask = netmask;
   }
 
+  @JsonProperty("operatingsystem")
   public String getOS() {
     return this.operatingsystem;
   }
-
+  
+  @JsonProperty("operatingsystem")
   public void setOS(String operatingsystem) {
     this.operatingsystem = operatingsystem;
   }
 
+  @JsonProperty("operatingsystemrelease")
   public String getOSRelease() {
     return this.operatingsystemrelease;
   }
-
+  
+  @JsonProperty("operatingsystemrelease")
   public void setOSRelease(String operatingsystemrelease) {
     this.operatingsystemrelease = operatingsystemrelease;
   }
-
+  
+  @JsonProperty("osfamily")
   public String getOSFamily() {
     return this.osfamily;
   }
-
+  
+  @JsonProperty("osfamily")
   public void setOSFamily(String osfamily) {
     this.osfamily = osfamily;
   }
-
+  
+  @JsonProperty("physicalprocessorcount")
   public int getPhysicalProcessorCount() {
     return this.physicalprocessorcount;
   }
-
+  
+  @JsonProperty("physicalprocessorcount")
   public void setPhysicalProcessorCount(int physicalprocessorcount) {
     this.physicalprocessorcount = physicalprocessorcount;
   }
 
+  @JsonProperty("processorcount")
   public int getProcessorCount() {
     return this.processorcount;
   }
-
+  
+  @JsonProperty("processorcount")
   public void setProcessorCount(int processorcount) {
     this.processorcount = processorcount;
   }
 
+  @JsonProperty("selinux")
   public boolean getSeLinux() {
     return selinux;
   }
-
+  
+  @JsonProperty("selinux")
   public void setSeLinux(boolean selinux) {
     this.selinux = selinux;
   }
-
+  
+  @JsonProperty("swapfree")
   public String getSwapFree() {
     return this.swapfree;
   }
-
+  
+  @JsonProperty("swapfree")
   public void setSwapFree(String swapfree) {
     this.swapfree = swapfree;
   }
-
+  
+  @JsonProperty("swapsize")
   public String getSwapSize() {
     return swapsize;
   }
-
+  
+  @JsonProperty("swapsize")
   public void setSwapSize(String swapsize) {
     this.swapsize = swapsize;
   }
-
+ 
+  @JsonProperty("timezone")
   public String getTimeZone() {
     return this.timezone;
   }
-
+  
+  @JsonProperty("timezone")
   public void setTimeZone(String timezone) {
     this.timezone = timezone;
   }
 
+  @JsonProperty("uptime")
   public String getUptime() {
     return this.uptime;
   }
-
+  
+  @JsonProperty("uptime")
   public void setUpTime(String uptime) {
     this.uptime = uptime;
   }
 
+  @JsonProperty("uptime_hours")
   public long getUptimeHours() {
     return this.uptime_hours;
   }
-
+  
+  @JsonProperty("uptime_hours")
   public void setUpTimeHours(long uptime_hours) {
     this.uptime_hours = uptime_hours;
   }
 
+  @JsonProperty("uptime_days")
   public long getUpTimeDays() {
     return this.uptime_days;
   }
-
+  
+  @JsonProperty("uptime_days")
   public void setUpTimeDays(long uptime_days) {
     this.uptime_days = uptime_days;
   }

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentHostInfoTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentHostInfoTest.java?rev=1399085&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentHostInfoTest.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentHostInfoTest.java Wed Oct 17 02:51:05 2012
@@ -0,0 +1,81 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.ambari.server.agent;
+
+import java.io.IOException;
+
+import junit.framework.Assert;
+
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.junit.Test;
+
+/**
+ * This tests makes sure the contract between the server and agent for info
+ * is in tact.
+ */
+public class AgentHostInfoTest {
+  
+  @Test
+  public void testDeserializeHostInfo() throws JsonParseException, 
+    JsonMappingException, IOException {
+    String hostinfo = "{\"architecture\": \"x86_64\", " +
+        "\"augeasversion\": \"0.10.0\"," +
+    		"\"domain\": \"test.com\", " +
+    		"\"facterversion\": \"1.6.10\"," +
+    		"\"fqdn\": \"dev.test.com\", " +
+    		"\"hardwareisa\": \"x86_64\", " +
+    		"\"hardwaremodel\": \"x86_64\"," +
+    		"\"hostname\": \"dev\", " +
+    		"\"id\": \"root\", " +
+    		"\"interfaces\": \"eth0,lo\", " +
+    		"\"ipaddress\": \"10.0.2.15\"," +
+    		"\"ipaddress_eth0\": \"10.0.2.15\"," +
+    		"\"ipaddress_lo\": \"127.0.0.1\"," +
+    		"\"is_virtual\": true," +
+    		"\"kernel\": \"Linux\", " +
+    		"\"kernelmajversion\": \"2.6\"," +
+    		"\"kernelrelease\": \"2.6.18-238.12.1.el5\"," +
+    		"\"kernelversion\": \"2.6.18\", " +
+    		"\"lsbdistcodename\": \"Final\"," +
+    		"\"lsbdistdescription\": \"CentOS release 5.8 (Final)\"," +
+    		"\"lsbdistid\": \"CentOS\", " +
+    		"\"lsbdistrelease\": \"5.8\", " +
+    		"\"lsbmajdistrelease\": \"5\"," +
+    		"\"macaddress\": \"08:00:27:D2:59:B2\", " +
+    		"\"macaddress_eth0\": \"08:00:27:D2:59:B2\"," +
+    		"\"manufacturer\": \"innotek GmbH\"," +
+    		"\"memoryfree\": 2453667," +
+    		"\"memorysize\": 3051356, " +
+    		"\"memorytotal\": 3051356," +
+    		"\"netmask\": \"255.255.255.0\"}";
+    ObjectMapper mapper = new ObjectMapper();
+    mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+    HostInfo info = mapper.readValue(hostinfo, HostInfo.class);
+    Assert.assertEquals(info.getMemoryTotal(), 3051356L);
+    Assert.assertEquals(info.getKernel(), "Linux");
+    Assert.assertEquals(info.getFQDN(),"dev.test.com");
+    Assert.assertEquals(info.getAgentUserId(), "root");
+    Assert.assertEquals(info.getMemorySize(), 3051356L);
+    Assert.assertEquals(info.getArchitecture(), "x86_64");
+  }
+}