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 2012/04/07 00:31:34 UTC
[7/13] git commit: allow short snitch names & update snitch comments
patch by jbellis; reviewed by vijay for CASSANDRA-4130
allow short snitch names & update snitch comments
patch by jbellis; reviewed by vijay for CASSANDRA-4130
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/01624478
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/01624478
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/01624478
Branch: refs/heads/cassandra-1.0
Commit: 016244785802c29cace8d89b6c3f022af668ee1b
Parents: 17d6354
Author: Jonathan Ellis <jb...@apache.org>
Authored: Fri Apr 6 17:21:17 2012 -0500
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Fri Apr 6 17:21:17 2012 -0500
----------------------------------------------------------------------
CHANGES.txt | 1 +
conf/cassandra.yaml | 48 ++++++++++++---
.../cassandra/config/DatabaseDescriptor.java | 6 +-
.../cassandra/locator/Ec2MultiRegionSnitch.java | 11 +---
.../cassandra/net/OutboundTcpConnectionPool.java | 7 ++-
5 files changed, 53 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/01624478/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 5a00cb6..1349299 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
1.0.10
+ * allow short snitch names (CASSANDRA-4130)
* cqlsh: guess correct version of Python for Arch Linux (CASSANDRA-4090)
* (CLI) properly handle quotes in create/update keyspace commands (CASSANDRA-4129)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/01624478/conf/cassandra.yaml
----------------------------------------------------------------------
diff --git a/conf/cassandra.yaml b/conf/cassandra.yaml
index 209bcb8..207d8f9 100644
--- a/conf/cassandra.yaml
+++ b/conf/cassandra.yaml
@@ -327,20 +327,50 @@ rpc_timeout_in_ms: 10000
# phi_convict_threshold: 8
# endpoint_snitch -- Set this to a class that implements
-# IEndpointSnitch, which will let Cassandra know enough
-# about your network topology to route requests efficiently.
+# IEndpointSnitch. The snitch has two functions:
+# - it teaches Cassandra enough about your network topology to route
+# requests efficiently
+# - it allows Cassandra to spread replicas around your cluster to avoid
+# correlated failures. It does this by grouping machines into
+# "datacenters" and "racks." Cassandra will do its best not to have
+# more than one replica on the same "rack" (which may not actually
+# be a physical location)
+#
+# IF YOU CHANGE THE SNITCH AFTER DATA IS INSERTED INTO THE CLUSTER,
+# YOU MUST RUN A FULL REPAIR, SINCE THE SNITCH AFFECTS WHERE REPLICAS
+# ARE PLACED.
+#
# Out of the box, Cassandra provides
-# - org.apache.cassandra.locator.SimpleSnitch:
+# - SimpleSnitch:
# Treats Strategy order as proximity. This improves cache locality
# when disabling read repair, which can further improve throughput.
-# - org.apache.cassandra.locator.RackInferringSnitch:
+# Only appropriate for single-datacenter deployments.
+# - PropertyFileSnitch:
# Proximity is determined by rack and data center, which are
-# assumed to correspond to the 3rd and 2nd octet of each node's
-# IP address, respectively
-# org.apache.cassandra.locator.PropertyFileSnitch:
-# - Proximity is determined by rack and data center, which are
# explicitly configured in cassandra-topology.properties.
-endpoint_snitch: org.apache.cassandra.locator.SimpleSnitch
+# - RackInferringSnitch:
+# Proximity is determined by rack and data center, which are
+# assumed to correspond to the 3rd and 2nd octet of each node's
+# IP address, respectively. Unless this happens to match your
+# deployment conventions (as it did Facebook's), this is best used
+# as an example of writing a custom Snitch class.
+# - Ec2Snitch:
+# Appropriate for EC2 deployments in a single Region. Loads Region
+# and Availability Zone information from the EC2 API. The Region is
+# treated as the Datacenter, and the Availability Zone as the rack.
+# Only private IPs are used, so this will not work across multiple
+# Regions.
+# - Ec2MultiRegionSnitch:
+# Uses public IPs as broadcast_address to allow cross-region
+# connectivity. (Thus, you should set seed addresses to the public
+# IP as well.) You will need to open the storage_port or
+# ssl_storage_port on the public IP firewall. (For intra-Region
+# traffic, Cassandra will switch to the private IP after
+# establishing a connection.)
+#
+# You can use a custom Snitch by setting this to the full class name
+# of the snitch, which will be assumed to be on your classpath.
+endpoint_snitch: SimpleSnitch
# controls how often to perform the more expensive part of host score
# calculation
http://git-wip-us.apache.org/repos/asf/cassandra/blob/01624478/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
index 839e228..667c90a 100644
--- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
+++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
@@ -449,9 +449,11 @@ public class DatabaseDescriptor
}
}
- private static IEndpointSnitch createEndpointSnitch(String endpointSnitchClassName) throws ConfigurationException
+ private static IEndpointSnitch createEndpointSnitch(String snitchClassName) throws ConfigurationException
{
- IEndpointSnitch snitch = FBUtilities.construct(endpointSnitchClassName, "snitch");
+ if (!snitchClassName.contains("."))
+ snitchClassName = "org.apache.cassandra.locator." + snitchClassName;
+ IEndpointSnitch snitch = FBUtilities.construct(snitchClassName, "snitch");
return conf.dynamic_snitch ? new DynamicEndpointSnitch(snitch) : snitch;
}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/01624478/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 b5a7deb..9b16801 100644
--- a/src/java/org/apache/cassandra/locator/Ec2MultiRegionSnitch.java
+++ b/src/java/org/apache/cassandra/locator/Ec2MultiRegionSnitch.java
@@ -65,41 +65,35 @@ public class Ec2MultiRegionSnitch extends Ec2Snitch implements IEndpointStateCha
// use the Public IP to broadcast Address to other nodes.
DatabaseDescriptor.setBroadcastAddress(public_ip);
}
-
- @Override
+
public void onJoin(InetAddress endpoint, EndpointState epState)
{
if (epState.getApplicationState(ApplicationState.INTERNAL_IP) != null)
reConnect(endpoint, epState.getApplicationState(ApplicationState.INTERNAL_IP));
}
- @Override
public void onChange(InetAddress endpoint, ApplicationState state, VersionedValue value)
{
if (state == ApplicationState.INTERNAL_IP)
reConnect(endpoint, value);
}
- @Override
public void onAlive(InetAddress endpoint, EndpointState state)
{
if (state.getApplicationState(ApplicationState.INTERNAL_IP) != null)
reConnect(endpoint, state.getApplicationState(ApplicationState.INTERNAL_IP));
}
- @Override
public void onDead(InetAddress endpoint, EndpointState state)
{
// do nothing
}
- @Override
public void onRestart(InetAddress endpoint, EndpointState state)
{
// do nothing
}
- @Override
public void onRemove(InetAddress endpoint)
{
// do nothing.
@@ -120,7 +114,8 @@ public class Ec2MultiRegionSnitch extends Ec2Snitch implements IEndpointStateCha
logger.error("Error in getting the IP address resolved: ", e);
}
}
-
+
+ @Override
public void gossiperStarting()
{
super.gossiperStarting();
http://git-wip-us.apache.org/repos/asf/cassandra/blob/01624478/src/java/org/apache/cassandra/net/OutboundTcpConnectionPool.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/net/OutboundTcpConnectionPool.java b/src/java/org/apache/cassandra/net/OutboundTcpConnectionPool.java
index a75dafe..7f4c626 100644
--- a/src/java/org/apache/cassandra/net/OutboundTcpConnectionPool.java
+++ b/src/java/org/apache/cassandra/net/OutboundTcpConnectionPool.java
@@ -64,7 +64,12 @@ public class OutboundTcpConnectionPool
for (OutboundTcpConnection con : new OutboundTcpConnection[] { cmdCon, ackCon })
con.closeSocket();
}
-
+
+ /**
+ * reconnect to @param remoteEP (after the current message backlog is exhausted).
+ * Used by Ec2MultiRegionSnitch to force nodes in the same region to communicate over their private IPs.
+ * @param remoteEP
+ */
public void reset(InetAddress remoteEP)
{
resetedEndpoint = remoteEP;