added one way URI to registry

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

Branch: refs/heads/feature/SLIDER-151_REST_API
Commit: e5dd4d96e0d18a146e6386ccdd8771658009551c
Parents: 624cafe
Author: Jon Maron <jma...@hortonworks.com>
Authored: Tue Aug 19 10:20:17 2014 -0400
Committer: Jon Maron <jma...@hortonworks.com>
Committed: Tue Aug 19 10:20:17 2014 -0400

----------------------------------------------------------------------
 slider-agent/src/main/python/agent/Registry.py           | 11 ++++++++---
 slider-agent/src/main/python/agent/main.py               |  7 +++++--
 .../core/registry/info/CustomRegistryConstants.java      |  9 ++++++---
 .../slider/providers/agent/AgentProviderService.java     |  9 +++++++--
 4 files changed, 26 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/e5dd4d96/slider-agent/src/main/python/agent/Registry.py
----------------------------------------------------------------------
diff --git a/slider-agent/src/main/python/agent/Registry.py 
b/slider-agent/src/main/python/agent/Registry.py
index 37736fe..d9d2baf 100644
--- a/slider-agent/src/main/python/agent/Registry.py
+++ b/slider-agent/src/main/python/agent/Registry.py
@@ -39,11 +39,16 @@ class Registry:
       data, stat = zk.get(self.zk_reg_path)
       logger.debug("Registry Data: %s" % (data.decode("utf-8")))
       sliderRegistry = json.loads(data)
-      amUrl = 
sliderRegistry["payload"]["internalView"]["endpoints"]["org.apache.slider.agents"]["address"]
+      amUrl = 
sliderRegistry["payload"]["internalView"]["endpoints"]["org.apache.slider.agents.secure"]["address"]
       amHost = amUrl.split("/")[2].split(":")[0]
       amSecuredPort = amUrl.split(":")[2].split("/")[0]
-      # the port needs to be utf-8 encoded 
+
+      amUnsecureUrl = 
sliderRegistry["payload"]["internalView"]["endpoints"]["org.apache.slider.agents.oneway"]["address"]
+      amUnsecuredPort = amUnsecureUrl.split(":")[2].split("/")[0]
+
+      # the port needs to be utf-8 encoded
       amSecuredPort = amSecuredPort.encode('utf8', 'ignore')
+      amUnecuredPort = amUnsecuredPort.encode('utf8', 'ignore')
     except Exception:
       # log and let empty strings be returned
       logger.error("Could not connect to zk registry at %s in quorum %s" % 
@@ -54,4 +59,4 @@ class Registry:
         zk.stop()
         zk.close()
     logger.info("AM Host = %s, AM Secured Port = %s" % (amHost, amSecuredPort))
-    return amHost, amSecuredPort
+    return amHost, amUnecuredPort, amSecuredPort

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/e5dd4d96/slider-agent/src/main/python/agent/main.py
----------------------------------------------------------------------
diff --git a/slider-agent/src/main/python/agent/main.py 
b/slider-agent/src/main/python/agent/main.py
index f68db04..4f9cd62 100644
--- a/slider-agent/src/main/python/agent/main.py
+++ b/slider-agent/src/main/python/agent/main.py
@@ -219,13 +219,16 @@ def main():
 
   # Extract the AM hostname and secured port from ZK registry
   registry = Registry(options.zk_quorum, options.zk_reg_path)
-  amHost, amSecuredPort = registry.readAMHostPort()
+  amHost, amUnsecuredPort, amSecuredPort = registry.readAMHostPort()
   if amHost:
       agentConfig.set(AgentConfig.SERVER_SECTION, "hostname", amHost)
 
   if amSecuredPort:
       agentConfig.set(AgentConfig.SERVER_SECTION, "secured_port", 
amSecuredPort)
 
+  if amUnsecuredPort:
+      agentConfig.set(AgentConfig.SERVER_SECTION, "port", amUnsecuredPort)
+
   # set the security directory to a subdirectory of the run dir
   secDir = posixpath.join(agentConfig.getResolvedPath(AgentConfig.RUN_DIR), 
"security")
   logger.info("Security/Keys directory: " + secDir)
@@ -250,7 +253,7 @@ def main():
 
   server_url = SERVER_STATUS_URL.format(
     agentConfig.get(AgentConfig.SERVER_SECTION, 'hostname'),
-    agentConfig.get(AgentConfig.SERVER_SECTION, 'secured_port'),
+    agentConfig.get(AgentConfig.SERVER_SECTION, 'port'),
     agentConfig.get(AgentConfig.SERVER_SECTION, 'check_path'))
   print("Connecting to the server at " + server_url + "...")
   logger.info('Connecting to the server at: ' + server_url)

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/e5dd4d96/slider-core/src/main/java/org/apache/slider/core/registry/info/CustomRegistryConstants.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/main/java/org/apache/slider/core/registry/info/CustomRegistryConstants.java
 
b/slider-core/src/main/java/org/apache/slider/core/registry/info/CustomRegistryConstants.java
index 38fb4a5..5ce5f73 100644
--- 
a/slider-core/src/main/java/org/apache/slider/core/registry/info/CustomRegistryConstants.java
+++ 
b/slider-core/src/main/java/org/apache/slider/core/registry/info/CustomRegistryConstants.java
@@ -30,9 +30,12 @@ public class CustomRegistryConstants {
   
   public static final String PUBLISHER_REST_API =
       "org.apache.slider.publisher";
-  
-  public static final String AGENT_REST_API =
-      "org.apache.slider.agents";
+
+  public static final String AGENT_SECURE_REST_API =
+      "org.apache.slider.agents.secure";
+
+  public static final String AGENT_ONEWAY_REST_API =
+      "org.apache.slider.agents.oneway";
 
   public static final String AM_IPC_PROTOCOL =
       "org.apache.slider.appmaster";

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/e5dd4d96/slider-core/src/main/java/org/apache/slider/providers/agent/AgentProviderService.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/main/java/org/apache/slider/providers/agent/AgentProviderService.java
 
b/slider-core/src/main/java/org/apache/slider/providers/agent/AgentProviderService.java
index c7a82d3..df55ed9 100644
--- 
a/slider-core/src/main/java/org/apache/slider/providers/agent/AgentProviderService.java
+++ 
b/slider-core/src/main/java/org/apache/slider/providers/agent/AgentProviderService.java
@@ -592,10 +592,15 @@ public class AgentProviderService extends 
AbstractProviderService implements
 
     try {
       instanceData.internalView.endpoints.put(
-          CustomRegistryConstants.AGENT_REST_API,
+          CustomRegistryConstants.AGENT_SECURE_REST_API,
           new RegisteredEndpoint(
               new URL(secureWebAPI, SLIDER_PATH_AGENTS),
-              "Agent REST API"));
+              "Agent Secure REST API"));
+      instanceData.internalView.endpoints.put(
+          CustomRegistryConstants.AGENT_ONEWAY_REST_API,
+          new RegisteredEndpoint(
+              new URL(unsecureWebAPI, SLIDER_PATH_AGENTS),
+              "Agent Oneway REST API"));
     } catch (URISyntaxException e) {
       throw new IOException(e);
     }

Reply via email to