incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject git commit: Revert "AMBARI-3770. Need better error log message when agent unable to reach server (Dmytro Shkvyra via dlysnichenko)"
Date Fri, 15 Nov 2013 19:54:08 GMT
Updated Branches:
  refs/heads/trunk b6b6aa86c -> cd7e9f623


Revert "AMBARI-3770. Need better error log message when agent unable to reach server (Dmytro
Shkvyra via dlysnichenko)"

This reverts commit 6ccdcc836fb240fb99e0729dd1fdaa0b451dd8fb.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/cd7e9f62
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/cd7e9f62
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/cd7e9f62

Branch: refs/heads/trunk
Commit: cd7e9f623e901cf4037d03b9a1728fcd8a199f7a
Parents: b6b6aa8
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Fri Nov 15 21:52:21 2013 +0200
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Fri Nov 15 21:52:21 2013 +0200

----------------------------------------------------------------------
 .../src/main/python/ambari_agent/Controller.py  |  8 +------
 ambari-agent/src/test/python/TestController.py  | 22 ++++++++++----------
 .../server/agent/RegistrationResponse.java      |  7 -------
 .../ambari/server/agent/rest/AgentResource.java | 16 +++-----------
 4 files changed, 15 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/cd7e9f62/ambari-agent/src/main/python/ambari_agent/Controller.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/Controller.py b/ambari-agent/src/main/python/ambari_agent/Controller.py
index fbaf0c7..7c51b5f 100644
--- a/ambari-agent/src/main/python/ambari_agent/Controller.py
+++ b/ambari-agent/src/main/python/ambari_agent/Controller.py
@@ -84,13 +84,7 @@ class Controller(threading.Thread):
         logger.info("Registering with the server " + pprint.pformat(data))
         response = self.sendRequest(self.registerUrl, data)
         ret = json.loads(response)
-        errors = None
-        if 'errors' in ret.keys():
-          errors = ret['errors']
-        print str(errors)
-        if not (errors == None or errors == ""):
-          logger.error(ret['errors'])
-          return ret
+
         logger.info("Registered with the server with " + pprint.pformat(ret))
         print("Registered with the server")
         self.responseId= int(ret['responseId'])

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/cd7e9f62/ambari-agent/src/test/python/TestController.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/TestController.py b/ambari-agent/src/test/python/TestController.py
index 6a36115..2b0e614 100644
--- a/ambari-agent/src/test/python/TestController.py
+++ b/ambari-agent/src/test/python/TestController.py
@@ -55,11 +55,12 @@ class TestController(unittest.TestCase):
 
 
   @patch("json.dumps")
+  @patch("json.loads")
   @patch("time.sleep")
   @patch("pprint.pformat")
   @patch.object(Controller, "randint")
   def test_registerWithServer(self, randintMock, pformatMock, sleepMock,
-                              dumpsMock):
+                              loadsMock, dumpsMock):
 
     out = StringIO.StringIO()
     sys.stdout = out
@@ -67,20 +68,19 @@ class TestController(unittest.TestCase):
     register = MagicMock()
     self.controller.register = register
 
-    self.controller.sendRequest = MagicMock()
+    sendRequest = MagicMock()
+    self.controller.sendRequest = sendRequest
 
     dumpsMock.return_value = "request"
-    self.controller.sendRequest.return_value = '{"errors":"Error text"}'
-
-    self.assertEqual({'errors': 'Error text'}, self.controller.registerWithServer())
+    response = {"responseId":1,}
+    loadsMock.return_value = response
 
-    self.controller.sendRequest.return_value = '{"responseId":1}'
-    self.assertEqual({"responseId":1}, self.controller.registerWithServer())
+    self.assertEqual(response, self.controller.registerWithServer())
 
-    self.controller.sendRequest.return_value = '{"responseId":1, "statusCommands": "commands"}'
+    response["statusCommands"] = "commands"
     self.controller.addToQueue = MagicMock(name="addToQueue")
 
-    self.assertEqual({"responseId":1, "statusCommands": "commands"}, self.controller.registerWithServer())
+    self.assertEqual(response, self.controller.registerWithServer())
     self.controller.addToQueue.assert_called_with("commands")
 
     calls = []
@@ -91,10 +91,10 @@ class TestController(unittest.TestCase):
         raise Exception("test")
       return "request"
 
-    self.controller.sendRequest.return_value = '{"responseId":1}'
+    del response["statusCommands"]
 
     dumpsMock.side_effect = side_effect
-    self.assertEqual({"responseId":1}, self.controller.registerWithServer())
+    self.assertEqual(response, self.controller.registerWithServer())
     self.assertTrue(randintMock.called)
     self.assertTrue(sleepMock.called)
 

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/cd7e9f62/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationResponse.java
b/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationResponse.java
index 6c4fd69..5e466aa 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/RegistrationResponse.java
@@ -30,9 +30,6 @@ import org.codehaus.jackson.annotate.JsonProperty;
 public class RegistrationResponse {
   @JsonProperty("response")
   private RegistrationStatus response;
-
-  @JsonProperty("errors")
-  private String errors;
   
   //Response id to start with, usually zero.
   @JsonProperty("responseId")
@@ -65,10 +62,6 @@ public class RegistrationResponse {
     this.responseId = responseId;
   }
 
-  public void setErrors(String errors) {
-    this.errors = errors;
-  }  
-  
   @Override
   public String toString() {
     return "RegistrationResponse{" +

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/cd7e9f62/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java
b/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java
index 0fa24fd..1aac28e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java
@@ -38,7 +38,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import com.google.inject.Inject;
-import org.apache.ambari.server.agent.RegistrationStatus;
 
 /**
  * Agent Resource represents Ambari agent controller.
@@ -76,20 +75,11 @@ public class AgentResource {
   @Produces({MediaType.APPLICATION_JSON})
   public RegistrationResponse register(Register message,
       @Context HttpServletRequest req)
-      throws WebApplicationException, InvalidStateTransitionException {
+      throws WebApplicationException, AmbariException, InvalidStateTransitionException {
     /* Call into the heartbeat handler */
 
-    RegistrationResponse response = null;
-    try {
-      response = hh.handleRegistration(message);
-      LOG.debug("Sending registration response " + response);
-    } catch (AmbariException ex) {
-      response = new RegistrationResponse();
-      response.setResponseId(-1);
-      response.setResponseStatus(RegistrationStatus.FAILED);
-      response.setErrors(ex.getMessage());
-      return response;
-    }
+    RegistrationResponse response = hh.handleRegistration(message);
+    LOG.debug("Sending registration response " + response);
     return response;
   }
 


Mime
View raw message