You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2013/06/20 22:47:19 UTC

[1/3] git commit: cleanup

Updated Branches:
  refs/heads/cassandra-1.2 998fe9676 -> 7dc2eb95c
  refs/heads/trunk 8df9d1f4c -> 21deff6c9


cleanup


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/7dc2eb95
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/7dc2eb95
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/7dc2eb95

Branch: refs/heads/cassandra-1.2
Commit: 7dc2eb95c1752eb661b93c72a831ceb783d42ce4
Parents: 998fe96
Author: Jonathan Ellis <jb...@apache.org>
Authored: Thu Jun 20 15:47:06 2013 -0500
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Thu Jun 20 15:47:06 2013 -0500

----------------------------------------------------------------------
 .../cassandra/locator/Ec2MultiRegionSnitch.java | 42 +++++++++++---------
 1 file changed, 23 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/7dc2eb95/src/java/org/apache/cassandra/locator/Ec2MultiRegionSnitch.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/locator/Ec2MultiRegionSnitch.java b/src/java/org/apache/cassandra/locator/Ec2MultiRegionSnitch.java
index ea41bc0..9317941 100644
--- a/src/java/org/apache/cassandra/locator/Ec2MultiRegionSnitch.java
+++ b/src/java/org/apache/cassandra/locator/Ec2MultiRegionSnitch.java
@@ -49,35 +49,35 @@ public class Ec2MultiRegionSnitch extends Ec2Snitch implements IEndpointStateCha
 {
     private static final String PUBLIC_IP_QUERY_URL = "http://169.254.169.254/latest/meta-data/public-ipv4";
     private static final String PRIVATE_IP_QUERY_URL = "http://169.254.169.254/latest/meta-data/local-ipv4";
-    private final InetAddress public_ip;
-    private final String private_ip;
+    private final InetAddress localPublicAddress;
+    private final String localPrivateAddress;
 
     public Ec2MultiRegionSnitch() throws IOException, ConfigurationException
     {
         super();
-        public_ip = InetAddress.getByName(awsApiCall(PUBLIC_IP_QUERY_URL));
-        logger.info("EC2Snitch using publicIP as identifier: " + public_ip);
-        private_ip = awsApiCall(PRIVATE_IP_QUERY_URL);
+        localPublicAddress = InetAddress.getByName(awsApiCall(PUBLIC_IP_QUERY_URL));
+        logger.info("EC2Snitch using publicIP as identifier: " + localPublicAddress);
+        localPrivateAddress = awsApiCall(PRIVATE_IP_QUERY_URL);
         // use the Public IP to broadcast Address to other nodes.
-        DatabaseDescriptor.setBroadcastAddress(public_ip);
+        DatabaseDescriptor.setBroadcastAddress(localPublicAddress);
     }
 
     public void onJoin(InetAddress endpoint, EndpointState epState)
     {
         if (epState.getApplicationState(ApplicationState.INTERNAL_IP) != null)
-            reConnect(endpoint, epState.getApplicationState(ApplicationState.INTERNAL_IP));
+            reconnect(endpoint, epState.getApplicationState(ApplicationState.INTERNAL_IP));
     }
 
     public void onChange(InetAddress endpoint, ApplicationState state, VersionedValue value)
     {
         if (state == ApplicationState.INTERNAL_IP)
-            reConnect(endpoint, value);
+            reconnect(endpoint, value);
     }
 
     public void onAlive(InetAddress endpoint, EndpointState state)
     {
         if (state.getApplicationState(ApplicationState.INTERNAL_IP) != null)
-            reConnect(endpoint, state.getApplicationState(ApplicationState.INTERNAL_IP));
+            reconnect(endpoint, state.getApplicationState(ApplicationState.INTERNAL_IP));
     }
 
     public void onDead(InetAddress endpoint, EndpointState state)
@@ -95,18 +95,11 @@ public class Ec2MultiRegionSnitch extends Ec2Snitch implements IEndpointStateCha
         // do nothing.
     }
 
-    private void reConnect(InetAddress endpoint, VersionedValue versionedValue)
+    private void reconnect(InetAddress publicAddress, VersionedValue localAddressValue)
     {
         try
         {
-            InetAddress localEc2IP = InetAddress.getByName(versionedValue.value);
-            if (getDatacenter(endpoint).equals(getDatacenter(public_ip))
-                && MessagingService.instance().getVersion(endpoint) == MessagingService.current_version
-                && !MessagingService.instance().getConnectionPool(endpoint).endPoint().equals(localEc2IP))
-            {
-                MessagingService.instance().getConnectionPool(endpoint).reset(localEc2IP);
-                logger.debug(String.format("Intiated reconnect to an Internal IP %s for the %s", localEc2IP, endpoint));
-            }
+            reconnect(publicAddress, InetAddress.getByName(localAddressValue.value));
         }
         catch (UnknownHostException e)
         {
@@ -114,11 +107,22 @@ public class Ec2MultiRegionSnitch extends Ec2Snitch implements IEndpointStateCha
         }
     }
 
+    private void reconnect(InetAddress publicAddress, InetAddress localAddress)
+    {
+        if (getDatacenter(publicAddress).equals(getDatacenter(localPublicAddress))
+            && MessagingService.instance().getVersion(publicAddress) == MessagingService.current_version
+            && !MessagingService.instance().getConnectionPool(publicAddress).endPoint().equals(localAddress))
+        {
+            MessagingService.instance().getConnectionPool(publicAddress).reset(localAddress);
+            logger.debug(String.format("Intiated reconnect to an Internal IP %s for the %s", localAddress, publicAddress));
+        }
+    }
+
     @Override
     public void gossiperStarting()
     {
         super.gossiperStarting();
-        Gossiper.instance.addLocalApplicationState(ApplicationState.INTERNAL_IP, StorageService.instance.valueFactory.internalIP(private_ip));
+        Gossiper.instance.addLocalApplicationState(ApplicationState.INTERNAL_IP, StorageService.instance.valueFactory.internalIP(localPrivateAddress));
         Gossiper.instance.register(this);
     }
 }


[2/3] git commit: cleanup

Posted by jb...@apache.org.
cleanup


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/7dc2eb95
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/7dc2eb95
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/7dc2eb95

Branch: refs/heads/trunk
Commit: 7dc2eb95c1752eb661b93c72a831ceb783d42ce4
Parents: 998fe96
Author: Jonathan Ellis <jb...@apache.org>
Authored: Thu Jun 20 15:47:06 2013 -0500
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Thu Jun 20 15:47:06 2013 -0500

----------------------------------------------------------------------
 .../cassandra/locator/Ec2MultiRegionSnitch.java | 42 +++++++++++---------
 1 file changed, 23 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/7dc2eb95/src/java/org/apache/cassandra/locator/Ec2MultiRegionSnitch.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/locator/Ec2MultiRegionSnitch.java b/src/java/org/apache/cassandra/locator/Ec2MultiRegionSnitch.java
index ea41bc0..9317941 100644
--- a/src/java/org/apache/cassandra/locator/Ec2MultiRegionSnitch.java
+++ b/src/java/org/apache/cassandra/locator/Ec2MultiRegionSnitch.java
@@ -49,35 +49,35 @@ public class Ec2MultiRegionSnitch extends Ec2Snitch implements IEndpointStateCha
 {
     private static final String PUBLIC_IP_QUERY_URL = "http://169.254.169.254/latest/meta-data/public-ipv4";
     private static final String PRIVATE_IP_QUERY_URL = "http://169.254.169.254/latest/meta-data/local-ipv4";
-    private final InetAddress public_ip;
-    private final String private_ip;
+    private final InetAddress localPublicAddress;
+    private final String localPrivateAddress;
 
     public Ec2MultiRegionSnitch() throws IOException, ConfigurationException
     {
         super();
-        public_ip = InetAddress.getByName(awsApiCall(PUBLIC_IP_QUERY_URL));
-        logger.info("EC2Snitch using publicIP as identifier: " + public_ip);
-        private_ip = awsApiCall(PRIVATE_IP_QUERY_URL);
+        localPublicAddress = InetAddress.getByName(awsApiCall(PUBLIC_IP_QUERY_URL));
+        logger.info("EC2Snitch using publicIP as identifier: " + localPublicAddress);
+        localPrivateAddress = awsApiCall(PRIVATE_IP_QUERY_URL);
         // use the Public IP to broadcast Address to other nodes.
-        DatabaseDescriptor.setBroadcastAddress(public_ip);
+        DatabaseDescriptor.setBroadcastAddress(localPublicAddress);
     }
 
     public void onJoin(InetAddress endpoint, EndpointState epState)
     {
         if (epState.getApplicationState(ApplicationState.INTERNAL_IP) != null)
-            reConnect(endpoint, epState.getApplicationState(ApplicationState.INTERNAL_IP));
+            reconnect(endpoint, epState.getApplicationState(ApplicationState.INTERNAL_IP));
     }
 
     public void onChange(InetAddress endpoint, ApplicationState state, VersionedValue value)
     {
         if (state == ApplicationState.INTERNAL_IP)
-            reConnect(endpoint, value);
+            reconnect(endpoint, value);
     }
 
     public void onAlive(InetAddress endpoint, EndpointState state)
     {
         if (state.getApplicationState(ApplicationState.INTERNAL_IP) != null)
-            reConnect(endpoint, state.getApplicationState(ApplicationState.INTERNAL_IP));
+            reconnect(endpoint, state.getApplicationState(ApplicationState.INTERNAL_IP));
     }
 
     public void onDead(InetAddress endpoint, EndpointState state)
@@ -95,18 +95,11 @@ public class Ec2MultiRegionSnitch extends Ec2Snitch implements IEndpointStateCha
         // do nothing.
     }
 
-    private void reConnect(InetAddress endpoint, VersionedValue versionedValue)
+    private void reconnect(InetAddress publicAddress, VersionedValue localAddressValue)
     {
         try
         {
-            InetAddress localEc2IP = InetAddress.getByName(versionedValue.value);
-            if (getDatacenter(endpoint).equals(getDatacenter(public_ip))
-                && MessagingService.instance().getVersion(endpoint) == MessagingService.current_version
-                && !MessagingService.instance().getConnectionPool(endpoint).endPoint().equals(localEc2IP))
-            {
-                MessagingService.instance().getConnectionPool(endpoint).reset(localEc2IP);
-                logger.debug(String.format("Intiated reconnect to an Internal IP %s for the %s", localEc2IP, endpoint));
-            }
+            reconnect(publicAddress, InetAddress.getByName(localAddressValue.value));
         }
         catch (UnknownHostException e)
         {
@@ -114,11 +107,22 @@ public class Ec2MultiRegionSnitch extends Ec2Snitch implements IEndpointStateCha
         }
     }
 
+    private void reconnect(InetAddress publicAddress, InetAddress localAddress)
+    {
+        if (getDatacenter(publicAddress).equals(getDatacenter(localPublicAddress))
+            && MessagingService.instance().getVersion(publicAddress) == MessagingService.current_version
+            && !MessagingService.instance().getConnectionPool(publicAddress).endPoint().equals(localAddress))
+        {
+            MessagingService.instance().getConnectionPool(publicAddress).reset(localAddress);
+            logger.debug(String.format("Intiated reconnect to an Internal IP %s for the %s", localAddress, publicAddress));
+        }
+    }
+
     @Override
     public void gossiperStarting()
     {
         super.gossiperStarting();
-        Gossiper.instance.addLocalApplicationState(ApplicationState.INTERNAL_IP, StorageService.instance.valueFactory.internalIP(private_ip));
+        Gossiper.instance.addLocalApplicationState(ApplicationState.INTERNAL_IP, StorageService.instance.valueFactory.internalIP(localPrivateAddress));
         Gossiper.instance.register(this);
     }
 }


[3/3] git commit: Merge branch 'cassandra-1.2' into trunk

Posted by jb...@apache.org.
Merge branch 'cassandra-1.2' into trunk


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/21deff6c
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/21deff6c
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/21deff6c

Branch: refs/heads/trunk
Commit: 21deff6c99992a454771aa3df0170cc15dbc0ee6
Parents: 8df9d1f 7dc2eb9
Author: Jonathan Ellis <jb...@apache.org>
Authored: Thu Jun 20 15:47:13 2013 -0500
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Thu Jun 20 15:47:13 2013 -0500

----------------------------------------------------------------------
 .../cassandra/locator/Ec2MultiRegionSnitch.java | 42 +++++++++++---------
 1 file changed, 23 insertions(+), 19 deletions(-)
----------------------------------------------------------------------