SLIDER-343. Command files have incorrect hostname

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

Branch: refs/heads/feature/SLIDER-158_slider_diagnostic_option
Commit: 314c3cce5d52e11e04e3d591f1795d128e9b722a
Parents: 9ce88ce
Author: Sumit Mohanty <[email protected]>
Authored: Wed Sep 24 13:43:13 2014 -0700
Committer: Sumit Mohanty <[email protected]>
Committed: Wed Sep 24 13:43:13 2014 -0700

----------------------------------------------------------------------
 .../src/main/python/agent/CustomServiceOrchestrator.py    |  7 +++++--
 .../test/python/agent/TestCustomServiceOrchestrator.py    | 10 ++++++++++
 .../server/appmaster/web/rest/agent/ExecutionCommand.java |  1 +
 3 files changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/314c3cce/slider-agent/src/main/python/agent/CustomServiceOrchestrator.py
----------------------------------------------------------------------
diff --git a/slider-agent/src/main/python/agent/CustomServiceOrchestrator.py 
b/slider-agent/src/main/python/agent/CustomServiceOrchestrator.py
index 30eedde..7b49a67 100644
--- a/slider-agent/src/main/python/agent/CustomServiceOrchestrator.py
+++ b/slider-agent/src/main/python/agent/CustomServiceOrchestrator.py
@@ -216,8 +216,11 @@ class CustomServiceOrchestrator():
     """
     # Perform few modifications to stay compatible with the way in which
     # site.pp files are generated by manifestGenerator.py
-    public_fqdn = self.public_fqdn
-    command['public_hostname'] = public_fqdn
+    command['public_hostname'] = self.public_fqdn
+    if 'hostname' in command:
+      command['appmaster_hostname'] = command['hostname']
+    command['hostname'] = self.public_fqdn
+
     # Now, dump the json file
     command_type = command['commandType']
     from ActionQueue import ActionQueue  # To avoid cyclic dependency

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/314c3cce/slider-agent/src/test/python/agent/TestCustomServiceOrchestrator.py
----------------------------------------------------------------------
diff --git 
a/slider-agent/src/test/python/agent/TestCustomServiceOrchestrator.py 
b/slider-agent/src/test/python/agent/TestCustomServiceOrchestrator.py
index 4548aac..2fb1611 100644
--- a/slider-agent/src/test/python/agent/TestCustomServiceOrchestrator.py
+++ b/slider-agent/src/test/python/agent/TestCustomServiceOrchestrator.py
@@ -55,6 +55,7 @@ class TestCustomServiceOrchestrator(TestCase):
     hostname_mock.return_value = "test.hst"
     command = {
       'commandType': 'EXECUTION_COMMAND',
+      'hostname' : 'host1',
       'componentName': 'NAMENODE',
       'role': u'DATANODE',
       'roleCommand': u'INSTALL',
@@ -80,6 +81,7 @@ class TestCustomServiceOrchestrator(TestCase):
     dummy_controller = MagicMock()
     orchestrator = CustomServiceOrchestrator(config, dummy_controller)
     isfile_mock.return_value = True
+    self.assertEquals(command['hostname'], "host1")
     # Test dumping EXECUTION_COMMAND
     json_file = orchestrator.dump_command_to_json(command, {})
     self.assertTrue(os.path.exists(json_file))
@@ -87,6 +89,12 @@ class TestCustomServiceOrchestrator(TestCase):
     self.assertEqual(oct(os.stat(json_file).st_mode & 0777), '0600')
     self.assertTrue(json_file.endswith("command-3.json"))
     os.unlink(json_file)
+
+    # Testing side effect of dump_command_to_json
+    self.assertEquals(command['public_hostname'], "test.hst")
+    self.assertEquals(command['hostname'], "test.hst")
+    self.assertEquals(command['appmaster_hostname'], "host1")
+
     # Test dumping STATUS_COMMAND
     command['commandType'] = 'STATUS_COMMAND'
     json_file = orchestrator.dump_command_to_json(command, {})
@@ -97,6 +105,8 @@ class TestCustomServiceOrchestrator(TestCase):
     os.unlink(json_file)
     # Testing side effect of dump_command_to_json
     self.assertEquals(command['public_hostname'], "test.hst")
+    self.assertEquals(command['hostname'], "test.hst")
+    self.assertEquals(command['appmaster_hostname'], "test.hst")
     self.assertTrue(unlink_mock.called)
 
 

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/314c3cce/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/ExecutionCommand.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/ExecutionCommand.java
 
b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/ExecutionCommand.java
index 94aa29f..5fb3b5e 100644
--- 
a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/ExecutionCommand.java
+++ 
b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/ExecutionCommand.java
@@ -36,6 +36,7 @@ public class ExecutionCommand {
   private String clusterName;
   private long taskId;
   private String commandId;
+  //TODO Remove hostname from being set in the command
   private String hostname;
   private String role;
   private Map<String, String> hostLevelParams = new HashMap<String, String>();

Reply via email to