You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by gd...@apache.org on 2010/07/22 16:09:02 UTC
svn commit: r966668 - in /cassandra/branches/cassandra-0.6: CHANGES.txt
src/java/org/apache/cassandra/config/DatabaseDescriptor.java
src/java/org/apache/cassandra/locator/LocalStrategy.java
src/java/org/apache/cassandra/service/StorageService.java
Author: gdusbabek
Date: Thu Jul 22 14:09:01 2010
New Revision: 966668
URL: http://svn.apache.org/viewvc?rev=966668&view=rev
Log:
create a local replication strategy for system keyspace. Patch by Ching-Shen Chen, reviewed by Gary Dusbabek. CASSANDRA-1307
Added:
cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/locator/LocalStrategy.java
Modified:
cassandra/branches/cassandra-0.6/CHANGES.txt
cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageService.java
Modified: cassandra/branches/cassandra-0.6/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/CHANGES.txt?rev=966668&r1=966667&r2=966668&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.6/CHANGES.txt Thu Jul 22 14:09:01 2010
@@ -15,7 +15,9 @@
* fix duplicate rows being read during mapreduce (CASSANDRA-1142)
* failure detection wasn't closing command sockets (CASSANDRA-1221)
* cassandra-cli.bat works on windows (CASSANDRA-1236)
-
+ * create a local replication strategy for system keyspace
+ (CASSANDRA-1307)
+
0.6.3
* retry to make streaming connections up to 8 times. (CASSANDRA-1019)
Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/config/DatabaseDescriptor.java?rev=966668&r1=966667&r2=966668&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/config/DatabaseDescriptor.java (original)
+++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/config/DatabaseDescriptor.java Thu Jul 22 14:09:01 2010
@@ -29,6 +29,7 @@ import org.apache.cassandra.dht.IPartiti
import org.apache.cassandra.locator.IEndPointSnitch;
import org.apache.cassandra.locator.AbstractReplicationStrategy;
import org.apache.cassandra.io.util.FileUtils;
+import org.apache.cassandra.locator.LocalStrategy;
import org.apache.cassandra.utils.FBUtilities;
import org.apache.cassandra.utils.XMLUtils;
import org.apache.log4j.Logger;
@@ -500,7 +501,7 @@ public class DatabaseDescriptor
throw new ConfigurationException("No keyspaces configured");
// Hardcoded system tables
- KSMetaData systemMeta = new KSMetaData(Table.SYSTEM_TABLE, null, -1, null);
+ KSMetaData systemMeta = new KSMetaData(Table.SYSTEM_TABLE, LocalStrategy.class, 1, null);
tables.put(Table.SYSTEM_TABLE, systemMeta);
systemMeta.cfMetaData.put(SystemTable.STATUS_CF, new CFMetaData(Table.SYSTEM_TABLE,
SystemTable.STATUS_CF,
Added: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/locator/LocalStrategy.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/locator/LocalStrategy.java?rev=966668&view=auto
==============================================================================
--- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/locator/LocalStrategy.java (added)
+++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/locator/LocalStrategy.java Thu Jul 22 14:09:01 2010
@@ -0,0 +1,44 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.cassandra.locator;
+
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.cassandra.utils.FBUtilities;
+import org.apache.cassandra.dht.Token;
+
+public class LocalStrategy extends AbstractReplicationStrategy
+{
+ public LocalStrategy(TokenMetadata tokenMetadata, IEndPointSnitch snitch)
+ {
+ super(tokenMetadata, snitch);
+ }
+
+ public ArrayList<InetAddress> getNaturalEndpoints(Token token, TokenMetadata metadata, String table)
+ {
+ ArrayList<InetAddress> endpoints = new ArrayList<InetAddress>(1);
+ InetAddress local = FBUtilities.getLocalAddress();
+ endpoints.add(local);
+ return endpoints;
+ }
+}
Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageService.java?rev=966668&r1=966667&r2=966668&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageService.java (original)
+++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageService.java Thu Jul 22 14:09:01 2010
@@ -228,7 +228,7 @@ public class StorageService implements I
MessagingService.instance.registerVerbHandlers(Verb.GOSSIP_DIGEST_ACK2, new GossipDigestAck2VerbHandler());
replicationStrategies = new HashMap<String, AbstractReplicationStrategy>();
- for (String table : DatabaseDescriptor.getNonSystemTables())
+ for (String table : DatabaseDescriptor.getTables())
{
AbstractReplicationStrategy strat = getReplicationStrategy(tokenMetadata_, table);
replicationStrategies.put(table, strat);