geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject [23/50] [abbrv] incubator-geode git commit: GEODE-2000 Now ClientMembershipListener returns host on which CacheServer is bind
Date Wed, 19 Oct 2016 19:59:51 GMT
GEODE-2000 Now ClientMembershipListener returns host on which
CacheServer is bind


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

Branch: refs/heads/feature/GEODE-1874
Commit: 8a080323070dbbc1d7037612d0d8e1188dcf1507
Parents: f2c3ca4
Author: Hitesh Khamesra <hkhamesra@pivotal.io>
Authored: Wed Oct 12 15:18:21 2016 -0700
Committer: Hitesh Khamesra <hkhamesra@pivotal.io>
Committed: Thu Oct 13 14:38:14 2016 -0700

----------------------------------------------------------------------
 .../membership/InternalDistributedMember.java   |  7 ++++-
 .../internal/cache/tier/sockets/HandShake.java  |  8 +++---
 .../AutoConnectionSourceImplJUnitTest.java      | 27 ++++++++++++++++++++
 3 files changed, 38 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8a080323/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/InternalDistributedMember.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/InternalDistributedMember.java
b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/InternalDistributedMember.java
index 775fa24..3c16bb3 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/InternalDistributedMember.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/InternalDistributedMember.java
@@ -1031,6 +1031,7 @@ public class InternalDistributedMember
     int port = in.readInt();
 
     this.hostName = DataSerializer.readString(in);
+    
     this.hostName = SocketCreator.resolve_dns? SocketCreator.getCanonicalHostName(inetAddr,
hostName) : inetAddr.getHostAddress();
 
     int flags = in.readUnsignedByte();
@@ -1210,7 +1211,11 @@ public class InternalDistributedMember
   }
 
   public String getHost() {
-    return this.netMbr.getInetAddress().getCanonicalHostName();
+    return this.hostName;
+  }
+  
+  public void setHost(String h) {
+    this.hostName = h;
   }
 
   public int getProcessId() {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8a080323/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/HandShake.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/HandShake.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/HandShake.java
index d63dfa0..885b61b 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/HandShake.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/HandShake.java
@@ -1320,7 +1320,7 @@ public class HandShake implements ClientHandShake
       int qSize = dis.readInt();
 
       // Read the server member
-      member = readServerMember(dis);
+      member = readServerMember(dis, location);
       serverQStatus = new ServerQueueStatus(epType, qSize,member);
 
       // Read the message (if any)
@@ -1439,7 +1439,7 @@ public class HandShake implements ClientHandShake
     return sqs;
   }
 
-  protected DistributedMember readServerMember(DataInputStream p_dis) throws IOException
{
+  public static DistributedMember readServerMember(DataInputStream p_dis, ServerLocation
serverLocation) throws IOException {
 
     byte[] memberBytes = DataSerializer.readByteArray(p_dis);
     ByteArrayInputStream bais = new ByteArrayInputStream(memberBytes);
@@ -1449,7 +1449,9 @@ public class HandShake implements ClientHandShake
       dis = new VersionedDataInputStream(dis, v);
     }
     try {
-      return (DistributedMember)DataSerializer.readObject(dis);
+      InternalDistributedMember ids = (InternalDistributedMember)DataSerializer.readObject(dis);
+      ids.setHost(serverLocation.getHostName());
+      return ids;
     }
     catch (EOFException e) {
       throw e;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8a080323/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImplJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImplJUnitTest.java
b/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImplJUnitTest.java
index fb4b970..ab6f626 100644
--- a/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImplJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImplJUnitTest.java
@@ -17,6 +17,7 @@
 package org.apache.geode.cache.client.internal;
 
 import org.apache.geode.CancelCriterion;
+import org.apache.geode.DataSerializer;
 import org.apache.geode.cache.*;
 import org.apache.geode.cache.client.NoAvailableLocatorsException;
 import org.apache.geode.cache.client.SubscriptionNotEnabledException;
@@ -24,22 +25,29 @@ import org.apache.geode.cache.client.internal.locator.ClientConnectionRequest;
 import org.apache.geode.cache.client.internal.locator.ClientConnectionResponse;
 import org.apache.geode.cache.client.internal.locator.LocatorListResponse;
 import org.apache.geode.cache.query.QueryService;
+import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.distributed.DistributedSystem;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.distributed.internal.PoolStatHelper;
 import org.apache.geode.distributed.internal.ServerLocation;
 import org.apache.geode.distributed.internal.SharedConfiguration;
+import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
 import org.apache.geode.distributed.internal.tcpserver.TcpClient;
 import org.apache.geode.distributed.internal.tcpserver.TcpHandler;
 import org.apache.geode.distributed.internal.tcpserver.TcpServer;
 import org.apache.geode.internal.AvailablePortHelper;
+import org.apache.geode.internal.HeapDataOutputStream;
+import org.apache.geode.internal.Version;
 import org.apache.geode.internal.cache.PoolStats;
+import org.apache.geode.internal.cache.tier.sockets.HandShake;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
 import java.io.IOException;
 import java.net.ConnectException;
 import java.net.InetAddress;
@@ -140,6 +148,25 @@ public class AutoConnectionSourceImplJUnitTest {
   }
   
   @Test
+  public void testClientMembershipListenerHostAtClient() throws IOException {
+    String fakeHost = "fake.com";
+    InternalDistributedMember member = new InternalDistributedMember("localhost", 54638);
+    ServerLocation sl = new ServerLocation(fakeHost, 420);
+    
+    HeapDataOutputStream dos = new HeapDataOutputStream( Version.CURRENT);
+    HeapDataOutputStream hdos = new HeapDataOutputStream(Version.CURRENT);
+    DataSerializer.writeObject(member, hdos);
+    DataSerializer.writeByteArray(hdos.toByteArray(), dos);
+    hdos.close();
+    
+    DataInputStream dis = new DataInputStream(new ByteArrayInputStream(dos.toByteArray()));
+    
+    DistributedMember ret = (DistributedMember)HandShake.readServerMember(dis, sl);
+    
+    assertEquals(fakeHost, ret.getHost());
+  }
+  
+  @Test
   public void testNoServers() throws Exception {
     startFakeLocator();
     handler.nextConnectionResponse = new ClientConnectionResponse(null);


Mime
View raw message