Skip to content

Commit

Permalink
merge from 0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
jbellis committed May 10, 2011
1 parent fcd02e3 commit 921f499
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 66 deletions.
5 changes: 3 additions & 2 deletions CHANGES.txt
Expand Up @@ -27,6 +27,8 @@
* r/m clustertool (CASSANDRA-2607)
* add support for presenting row key as a column in CQL result sets
(CASSANDRA-2622)
* Don't allow {LOCAL|EACH}_QUORUM unless strategy is NTS (CASSANDRA-2627)
* validate keyspace strategy_options during CQL create (CASSANDRA-2624)


0.8.0-beta2
Expand Down Expand Up @@ -54,12 +56,11 @@
* improve ignoring of obsolete mutations in index maintenance (CASSANDRA-2401)
* recognize attempt to drop just the index while leaving the column
definition alone (CASSANDRA-2619)
* Don't allow {LOCAL|EACH}_QUORUM unless strategy is NTS (CASSANDRA-2627)


0.8.0-beta1
* remove Avro RPC support (CASSANDRA-926)
* adds support for columns that act as incr/decr counters
* support for columns that act as incr/decr counters
(CASSANDRA-1072, 1937, 1944, 1936, 2101, 2093, 2288, 2105, 2384, 2236, 2342,
2454)
* CQL (CASSANDRA-1703, 1704, 1705, 1706, 1707, 1708, 1710, 1711, 1940,
Expand Down
7 changes: 3 additions & 4 deletions NEWS.txt
Expand Up @@ -5,19 +5,18 @@ Upgrading
---------
- Upgrading from version 0.7.1 or later can be done with a rolling
restart, one node at a time. You do not need to bring down the
whole cluster.
whole cluster at once.
- Running nodetool drain before shutting down the 0.7 node is
recommended but not required. (Skipping this will result in
replay of entire commitlog, so it will take longer to restart but
is otherwise harmless.)
- 0.8 is fully API-compatible with 0.7. You can continue
to use your 0.7 clients.
- Avro record classes used in map/reduce and Hadoop streaming code have
moved from org.apache.cassandra.avro to org.apache.cassandra.hadoop.avro,
applications using these classes will need to be updated accordingly.
- The loadbalance command has been removed from nodetool. For similar
behavior, decommission then rebootstrap with empty initial_token.
- repair now works on a token range, rather than the entire ring. This
means that "run repair against each node" will now repair the ring with
no redundant work.

Features
--------
Expand Down
Expand Up @@ -28,7 +28,6 @@
import org.apache.cassandra.db.marshal.AsciiType;
import org.apache.cassandra.thrift.*;
import org.apache.cassandra.utils.ByteBufferUtil;
import org.apache.cassandra.utils.FBUtilities;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -59,7 +58,7 @@ public ColumnDecoder(List<KsDef> defs)
{
try
{
metadata.put(String.format("%s.%s", ks.getName(), cf.getName()), CFMetaData.convertToCFMetaData(cf));
metadata.put(String.format("%s.%s", ks.getName(), cf.getName()), CFMetaData.fromThrift(cf));
}
catch (InvalidRequestException e)
{
Expand Down
2 changes: 1 addition & 1 deletion src/java/org/apache/cassandra/config/CFMetaData.java
Expand Up @@ -629,7 +629,7 @@ public static void applyImplicitDefaults(org.apache.cassandra.thrift.CfDef cf_de
cf_def.setRow_cache_provider(CFMetaData.DEFAULT_ROW_CACHE_PROVIDER);
}

public static CFMetaData convertToCFMetaData(org.apache.cassandra.thrift.CfDef cf_def) throws InvalidRequestException, ConfigurationException
public static CFMetaData fromThrift(org.apache.cassandra.thrift.CfDef cf_def) throws InvalidRequestException, ConfigurationException
{
ColumnFamilyType cfType = ColumnFamilyType.create(cf_def.column_type);
if (cfType == null)
Expand Down
28 changes: 23 additions & 5 deletions src/java/org/apache/cassandra/config/KSMetaData.java
Expand Up @@ -18,17 +18,15 @@

package org.apache.cassandra.config;

import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.*;

import org.apache.commons.lang.ObjectUtils;

import org.apache.avro.util.Utf8;
import org.apache.cassandra.io.SerDeUtils;
import org.apache.cassandra.locator.AbstractReplicationStrategy;
import org.apache.cassandra.locator.NetworkTopologyStrategy;
import org.apache.cassandra.thrift.CfDef;
import org.apache.cassandra.thrift.KsDef;

import org.apache.commons.lang.StringUtils;
Expand All @@ -51,7 +49,7 @@ public KSMetaData(String name, Class<? extends AbstractReplicationStrategy> stra
this.cfMetaData = Collections.unmodifiableMap(cfmap);
}

public static Map<String, String> backwardsCompatibleOptions(KsDef ks_def)
public static Map<String, String> forwardsCompatibleOptions(KsDef ks_def)
{
Map<String, String> options;
if (ks_def.isSetReplication_factor())
Expand Down Expand Up @@ -165,4 +163,24 @@ public static Map<String,String> optsWithRF(final Integer rf)
ret.put("replication_factor", rf.toString());
return ret;
}

public static KSMetaData fromThrift(KsDef ksd, CFMetaData... cfDefs) throws ConfigurationException
{
return new KSMetaData(ksd.name,
AbstractReplicationStrategy.getClass(ksd.strategy_class),
forwardsCompatibleOptions(ksd),
cfDefs);
}

public static KsDef toThrift(KSMetaData ksm)
{
List<CfDef> cfDefs = new ArrayList<CfDef>();
for (CFMetaData cfm : ksm.cfMetaData().values())
cfDefs.add(CFMetaData.convertToThrift(cfm));
KsDef ksdef = new KsDef(ksm.name, ksm.strategyClass.getName(), cfDefs);
ksdef.setStrategy_options(ksm.strategyOptions);
if (ksm.strategyOptions != null && ksm.strategyOptions.containsKey("replication_factor"))
ksdef.setReplication_factor(Integer.parseInt(ksm.strategyOptions.get("replication_factor")));
return ksdef;
}
}
10 changes: 6 additions & 4 deletions src/java/org/apache/cassandra/cql/QueryProcessor.java
Expand Up @@ -638,10 +638,12 @@ public static CqlResult process(String queryString, ClientState clientState)

try
{
KSMetaData ksm = new KSMetaData(create.getName(),
AbstractReplicationStrategy.getClass(create.getStrategyClass()),
create.getStrategyOptions());
applyMigrationOnStage(new AddKeyspace(ksm));
KsDef ksd = new KsDef(create.getName(),
create.getStrategyClass(),
Collections.<org.apache.cassandra.thrift.CfDef>emptyList())
.setStrategy_options(create.getStrategyOptions());
ThriftValidation.validateKsDef(ksd);
applyMigrationOnStage(new AddKeyspace(KSMetaData.fromThrift(ksd)));
}
catch (ConfigurationException e)
{
Expand Down
Expand Up @@ -289,4 +289,19 @@ public static Class<AbstractReplicationStrategy> getClass(String cls) throws Con
String className = cls.contains(".") ? cls : "org.apache.cassandra.locator." + cls;
return FBUtilities.classForName(className, "replication strategy");
}

protected void validateReplicationFactor(String rf) throws ConfigurationException
{
try
{
if (Integer.parseInt(rf) < 0)
{
throw new ConfigurationException("Replication factor must be non-negative; found " + rf);
}
}
catch (NumberFormatException e2)
{
throw new ConfigurationException("Replication factor must be numeric; found " + rf);
}
}
}
Expand Up @@ -146,13 +146,9 @@ public Set<String> getDatacenters()

public void validateOptions() throws ConfigurationException
{
for (Entry<String,String> e : this.configOptions.entrySet())
for (Entry<String, String> e : this.configOptions.entrySet())
{
int rf = Integer.parseInt(e.getValue());
if (rf < 0)
{
throw new ConfigurationException("Replication factor for NTS must be non-negative. dc: " +e.getKey()+", rf: "+rf);
}
validateReplicationFactor(e.getValue());
}

}
Expand Down
Expand Up @@ -111,18 +111,10 @@ public int getReplicationFactor()

public void validateOptions() throws ConfigurationException
{
if (this.configOptions == null)
if (configOptions == null || configOptions.get("replication_factor") == null)
{
throw new ConfigurationException("OldNetworkTopologyStrategy requires a replication_factor strategy option.");
}
if (this.configOptions.get("replication_factor") == null)
{
throw new ConfigurationException("OldNetworkTopologyStrategy requires a replication_factor strategy option.");
}
int rf = Integer.parseInt(this.configOptions.get("replication_factor"));
if (rf < 0)
{
throw new ConfigurationException("Replication factor for OldNetworkTopologyStrategy must be non-negative, "+rf+" given.");
throw new ConfigurationException("SimpleStrategy requires a replication_factor strategy option.");
}
validateReplicationFactor(configOptions.get("replication_factor"));
}
}
12 changes: 2 additions & 10 deletions src/java/org/apache/cassandra/locator/SimpleStrategy.java
Expand Up @@ -70,18 +70,10 @@ public int getReplicationFactor()

public void validateOptions() throws ConfigurationException
{
if (this.configOptions == null)
if (configOptions == null || configOptions.get("replication_factor") == null)
{
throw new ConfigurationException("SimpleStrategy requires a replication_factor strategy option.");
}
if (this.configOptions.get("replication_factor") == null)
{
throw new ConfigurationException("SimpleStrategy requires a replication_factor strategy option.");
}
int rf = Integer.parseInt(this.configOptions.get("replication_factor"));
if (rf < 0)
{
throw new ConfigurationException("Replication factor for SimpleStrategy must be non-negative, "+rf+" given.");
}
validateReplicationFactor(configOptions.get("replication_factor"));
}
}
23 changes: 5 additions & 18 deletions src/java/org/apache/cassandra/thrift/CassandraServer.java
Expand Up @@ -578,12 +578,7 @@ public KsDef describe_keyspace(String table) throws NotFoundException, InvalidRe
if (ksm == null)
throw new NotFoundException();

List<CfDef> cfDefs = new ArrayList<CfDef>();
for (CFMetaData cfm : ksm.cfMetaData().values())
cfDefs.add(CFMetaData.convertToThrift(cfm));
KsDef ksdef = new KsDef(ksm.name, ksm.strategyClass.getName(), cfDefs);
ksdef.setStrategy_options(ksm.strategyOptions);
return ksdef;
return KSMetaData.toThrift(ksm);
}

public List<KeySlice> get_range_slices(ColumnParent column_parent, SlicePredicate predicate, KeyRange range, ConsistencyLevel consistency_level)
Expand Down Expand Up @@ -809,7 +804,7 @@ public synchronized String system_add_column_family(CfDef cf_def)

try
{
applyMigrationOnStage(new AddColumnFamily(CFMetaData.convertToCFMetaData(cf_def)));
applyMigrationOnStage(new AddColumnFamily(CFMetaData.fromThrift(cf_def)));
return DatabaseDescriptor.getDefsVersion().toString();
}
catch (ConfigurationException e)
Expand Down Expand Up @@ -874,16 +869,11 @@ public synchronized String system_add_keyspace(KsDef ks_def)
for (CfDef cfDef : ks_def.cf_defs)
{
ThriftValidation.validateCfDef(cfDef);
cfDefs.add(CFMetaData.convertToCFMetaData(cfDef));
cfDefs.add(CFMetaData.fromThrift(cfDef));
}

ThriftValidation.validateKsDef(ks_def);
KSMetaData ksm = new KSMetaData(ks_def.name,
AbstractReplicationStrategy.getClass(ks_def.strategy_class),
KSMetaData.backwardsCompatibleOptions(ks_def),
cfDefs.toArray(new CFMetaData[cfDefs.size()]));

applyMigrationOnStage(new AddKeyspace(ksm));
applyMigrationOnStage(new AddKeyspace(KSMetaData.fromThrift(ks_def, cfDefs.toArray(new CFMetaData[cfDefs.size()]))));
return DatabaseDescriptor.getDefsVersion().toString();
}
catch (ConfigurationException e)
Expand Down Expand Up @@ -941,10 +931,7 @@ public synchronized String system_update_keyspace(KsDef ks_def)
try
{
ThriftValidation.validateKsDef(ks_def);
KSMetaData ksm = new KSMetaData(ks_def.name,
AbstractReplicationStrategy.getClass(ks_def.strategy_class),
KSMetaData.backwardsCompatibleOptions(ks_def));
applyMigrationOnStage(new UpdateKeyspace(ksm));
applyMigrationOnStage(new UpdateKeyspace(KSMetaData.fromThrift(ks_def)));
return DatabaseDescriptor.getDefsVersion().toString();
}
catch (ConfigurationException e)
Expand Down
4 changes: 2 additions & 2 deletions src/java/org/apache/cassandra/thrift/ThriftValidation.java
Expand Up @@ -591,11 +591,11 @@ public static void validateCommutativeForWrite(CFMetaData metadata, ConsistencyL
}
}

static void validateKsDef(KsDef ks_def) throws ConfigurationException
public static void validateKsDef(KsDef ks_def) throws ConfigurationException
{
// Attempt to instantiate the ARS, which will throw a ConfigException if
// the strategy_options aren't fully formed or if the ARS Classname is invalid.
Map<String, String> options = KSMetaData.backwardsCompatibleOptions(ks_def);
Map<String, String> options = KSMetaData.forwardsCompatibleOptions(ks_def);
TokenMetadata tmd = StorageService.instance.getTokenMetadata();
IEndpointSnitch eps = DatabaseDescriptor.getEndpointSnitch();
Class<? extends AbstractReplicationStrategy> cls = AbstractReplicationStrategy.getClass(ks_def.strategy_class);
Expand Down
2 changes: 1 addition & 1 deletion src/resources/org/apache/cassandra/cli/CliHelp.yaml
Expand Up @@ -391,7 +391,7 @@ commands:
It is also valid to specify the fully-qualified class name to a class that
extends org.apache.Cassandra.db.marshal.AbstractType.
- key_valiation_class: Validator to use for keys.
- key_validation_class: Validator to use for keys.
Default is BytesType which applies no validation.
Supported values are:
Expand Down

0 comments on commit 921f499

Please sign in to comment.