Author: gdusbabek
Date: Thu Jul 22 13:52:10 2010
New Revision: 966657
URL: http://svn.apache.org/viewvc?rev=966657&view=rev
Log:
create a local replication strategy for system keyspace. patch by Ching-Shen
Chen, reviewed by Gary Dusbabek. CASSANDRA-1307
Added:
cassandra/trunk/src/java/org/apache/cassandra/locator/LocalStrategy.java
Modified:
cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
Modified:
cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
URL:
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java?rev=966657&r1=966656&r2=966657&view=diff
==============================================================================
---
cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
(original)
+++
cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
Thu Jul 22 13:52:10 2010
@@ -47,6 +47,7 @@ import org.apache.cassandra.db.migration
import org.apache.cassandra.dht.IPartitioner;
import org.apache.cassandra.io.util.FileUtils;
import org.apache.cassandra.locator.AbstractReplicationStrategy;
+import org.apache.cassandra.locator.LocalStrategy;
import org.apache.cassandra.locator.IEndpointSnitch;
import org.apache.cassandra.scheduler.IRequestScheduler;
import org.apache.cassandra.scheduler.NoScheduler;
@@ -344,7 +345,7 @@ public class DatabaseDescriptor
CommitLog.setSegmentSize(conf.commitlog_rotation_threshold_in_mb * 1024 * 1024);
// Hardcoded system tables
- KSMetaData systemMeta = new KSMetaData(Table.SYSTEM_TABLE, null,
-1, new CFMetaData[]{CFMetaData.StatusCf,
+ KSMetaData systemMeta = new KSMetaData(Table.SYSTEM_TABLE,
LocalStrategy.class, 1, new CFMetaData[]{CFMetaData.StatusCf,
CFMetaData.HintsCf,
CFMetaData.MigrationsCf,
CFMetaData.SchemaCf
Added: cassandra/trunk/src/java/org/apache/cassandra/locator/LocalStrategy.java
URL:
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/locator/LocalStrategy.java?rev=966657&view=auto
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/locator/LocalStrategy.java
(added)
+++ cassandra/trunk/src/java/org/apache/cassandra/locator/LocalStrategy.java
Thu Jul 22 13:52:10 2010
@@ -0,0 +1,43 @@
+/*
+* 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.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 Set<InetAddress> calculateNaturalEndpoints(Token token,
TokenMetadata metadata, String table)
+ {
+ Set<InetAddress> endpoints = new HashSet<InetAddress>(1);
+ InetAddress local = FBUtilities.getLocalAddress();
+ endpoints.add(local);
+ return endpoints;
+ }
+}
Modified:
cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
URL:
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java?rev=966657&r1=966656&r2=966657&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
(original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
Thu Jul 22 13:52:10 2010
@@ -245,7 +245,7 @@ public class StorageService implements I
MessagingService.instance.registerVerbHandlers(Verb.SCHEMA_CHECK, new
SchemaCheckVerbHandler());
replicationStrategies = new HashMap<String,
AbstractReplicationStrategy>();
- for (String table : DatabaseDescriptor.getNonSystemTables())
+ for (String table : DatabaseDescriptor.getTables())
initReplicationStrategy(table);
// spin up the streaming serivice so it is available for jmx tools.