You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by gb...@apache.org on 2015/09/14 08:40:53 UTC

helix git commit: De-couple IPC host / instance name

Repository: helix
Updated Branches:
  refs/heads/master eb82c9516 -> 9e51cb7bd


De-couple IPC host / instance name


Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/9e51cb7b
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/9e51cb7b
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/9e51cb7b

Branch: refs/heads/master
Commit: 9e51cb7bdf8424df46c6fa353e7c80d984c21193
Parents: eb82c95
Author: Greg Brandt <br...@gmail.com>
Authored: Mon Sep 7 20:30:49 2015 -0700
Committer: Greg Brandt <br...@gmail.com>
Committed: Sun Sep 13 23:38:13 2015 -0700

----------------------------------------------------------------------
 .../java/org/apache/helix/ipc/HelixIPCService.java  |  1 +
 .../helix/resolver/AbstractHelixResolver.java       | 16 +++++++++-------
 .../apache/helix/ipc/TestNettyHelixIPCService.java  |  8 ++++++++
 .../apache/helix/resolver/TestZKHelixResolver.java  |  1 +
 4 files changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/9e51cb7b/helix-ipc/src/main/java/org/apache/helix/ipc/HelixIPCService.java
----------------------------------------------------------------------
diff --git a/helix-ipc/src/main/java/org/apache/helix/ipc/HelixIPCService.java b/helix-ipc/src/main/java/org/apache/helix/ipc/HelixIPCService.java
index 6158514..b878aeb 100644
--- a/helix-ipc/src/main/java/org/apache/helix/ipc/HelixIPCService.java
+++ b/helix-ipc/src/main/java/org/apache/helix/ipc/HelixIPCService.java
@@ -33,6 +33,7 @@ import java.util.UUID;
  */
 public interface HelixIPCService {
 
+  static final String IPC_HOST = "IPC_HOST";
   static final String IPC_PORT = "IPC_PORT";
 
   /** Starts service (must call before {@link #send}) */

http://git-wip-us.apache.org/repos/asf/helix/blob/9e51cb7b/helix-ipc/src/main/java/org/apache/helix/resolver/AbstractHelixResolver.java
----------------------------------------------------------------------
diff --git a/helix-ipc/src/main/java/org/apache/helix/resolver/AbstractHelixResolver.java b/helix-ipc/src/main/java/org/apache/helix/resolver/AbstractHelixResolver.java
index c0fd2bb..9e2c45f 100644
--- a/helix-ipc/src/main/java/org/apache/helix/resolver/AbstractHelixResolver.java
+++ b/helix-ipc/src/main/java/org/apache/helix/resolver/AbstractHelixResolver.java
@@ -47,6 +47,7 @@ public abstract class AbstractHelixResolver implements HelixResolver {
   private static final int DEFAULT_THREAD_POOL_SIZE = 10;
   private static final long DEFAULT_LEASE_LENGTH_MS = 60 * 60 * 1000; // TODO: are these good
                                                                       // values?
+  private static final String IPC_HOST = "IPC_HOST";
   private static final String IPC_PORT = "IPC_PORT";
   private final Map<String, Spectator> _connections;
   private boolean _isConnected;
@@ -142,13 +143,13 @@ public abstract class AbstractHelixResolver implements HelixResolver {
     // Resolve those participants
     Set<HelixAddress> result = new HashSet<HelixAddress>();
     for (InstanceConfig participant : participants) {
+      String ipcHost = participant.getRecord().getSimpleField(IPC_HOST);
       String ipcPort = participant.getRecord().getSimpleField(IPC_PORT);
-      if (ipcPort == null) {
-        LOG.error("No ipc address registered for target instance " + participant.getInstanceName()
-            + ", skipping");
+      if (ipcHost == null || ipcPort == null) {
+        throw new IllegalStateException("Could not resolve " + participant);
       } else {
-        result.add(new HelixAddress(scope, participant.getInstanceName(), new InetSocketAddress(
-            participant.getHostName(), Integer.valueOf(ipcPort))));
+        result.add(new HelixAddress(scope, participant.getInstanceName(),
+            new InetSocketAddress(ipcHost, Integer.valueOf(ipcPort))));
       }
     }
 
@@ -175,13 +176,14 @@ public abstract class AbstractHelixResolver implements HelixResolver {
 
     if (scope.getSourceInstance() != null) {
       InstanceConfig config = routingTable.getInstanceConfig(scope.getSourceInstance());
+      String ipcHost = config.getRecord().getSimpleField(IPC_HOST);
       String ipcPort = config.getRecord().getSimpleField(IPC_PORT);
-      if (ipcPort == null) {
+      if (ipcPort == null || ipcHost == null) {
         throw new IllegalStateException("No IPC address registered for source instance "
             + scope.getSourceInstance());
       }
       return new HelixAddress(scope, scope.getSourceInstance(), new InetSocketAddress(
-          config.getHostName(), Integer.valueOf(ipcPort)));
+          ipcHost, Integer.valueOf(ipcPort)));
     }
 
     return null;

http://git-wip-us.apache.org/repos/asf/helix/blob/9e51cb7b/helix-ipc/src/test/java/org/apache/helix/ipc/TestNettyHelixIPCService.java
----------------------------------------------------------------------
diff --git a/helix-ipc/src/test/java/org/apache/helix/ipc/TestNettyHelixIPCService.java b/helix-ipc/src/test/java/org/apache/helix/ipc/TestNettyHelixIPCService.java
index 25833d7..d83a8fc 100644
--- a/helix-ipc/src/test/java/org/apache/helix/ipc/TestNettyHelixIPCService.java
+++ b/helix-ipc/src/test/java/org/apache/helix/ipc/TestNettyHelixIPCService.java
@@ -127,10 +127,18 @@ public class TestNettyHelixIPCService extends ZkTestBase {
         new HelixConfigScopeBuilder(HelixConfigScope.ConfigScopeProperty.PARTICIPANT)
             .forCluster(firstNode.getClusterName()).forParticipant(firstNode.getInstanceName())
             .build(), HelixIPCService.IPC_PORT, String.valueOf(firstPort));
+    firstNode.getConfigAccessor().set(
+        new HelixConfigScopeBuilder(HelixConfigScope.ConfigScopeProperty.PARTICIPANT)
+            .forCluster(firstNode.getClusterName()).forParticipant(firstNode.getInstanceName())
+            .build(), HelixIPCService.IPC_HOST, "localhost");
     secondNode.getConfigAccessor().set(
         new HelixConfigScopeBuilder(HelixConfigScope.ConfigScopeProperty.PARTICIPANT)
             .forCluster(secondNode.getClusterName()).forParticipant(secondNode.getInstanceName())
             .build(), HelixIPCService.IPC_PORT, String.valueOf(secondPort));
+    secondNode.getConfigAccessor().set(
+        new HelixConfigScopeBuilder(HelixConfigScope.ConfigScopeProperty.PARTICIPANT)
+            .forCluster(secondNode.getClusterName()).forParticipant(secondNode.getInstanceName())
+            .build(), HelixIPCService.IPC_HOST, "localhost");
   }
 
   @AfterClass

http://git-wip-us.apache.org/repos/asf/helix/blob/9e51cb7b/helix-ipc/src/test/java/org/apache/helix/resolver/TestZKHelixResolver.java
----------------------------------------------------------------------
diff --git a/helix-ipc/src/test/java/org/apache/helix/resolver/TestZKHelixResolver.java b/helix-ipc/src/test/java/org/apache/helix/resolver/TestZKHelixResolver.java
index 4e802d7..843c6b0 100644
--- a/helix-ipc/src/test/java/org/apache/helix/resolver/TestZKHelixResolver.java
+++ b/helix-ipc/src/test/java/org/apache/helix/resolver/TestZKHelixResolver.java
@@ -77,6 +77,7 @@ public class TestZKHelixResolver extends ZkTestBase {
       InstanceConfig config = new InstanceConfig(instanceName);
       config.setHostName(host);
       config.setPort(Integer.toString(port));
+      config.getRecord().setSimpleField("IPC_HOST", host);
       config.getRecord().setSimpleField("IPC_PORT", Integer.toString(ipcPort));
       admin.addInstance(CLUSTER_NAME, config);
       _socketMap.put(instanceName, new InetSocketAddress(host, ipcPort));