Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update to Cassandra 1.0.7

  • Loading branch information...
commit 487d5eb95a0b3a7f348341ae8419f13622bdc90a 1 parent 046c6ef
@titanous authored
View
3  .gitignore
@@ -1,7 +1,10 @@
lib/*.jar
build/*.jar
resources
+out
+*.iml
*~
.project
.classpath
+.idea
build
View
2  build.properties.default
@@ -14,6 +14,6 @@ hadoop-core.build.version: 0.20.203.1-brisk1-beta2
hadoop.build.version: 0.20.203.1-brisk1-beta2
hive.build.version: 0.7.0-brisk1-SNAPSHOT
pig.build.version: 0.8.3
-cassandra.build.version: 1.0.0
+cassandra.build.version: 1.0.7
# change this to always for frequent checks
snapshot.datastax.updatePolicy: daily
View
3  build.xml
@@ -821,7 +821,8 @@
<javac
debug="true"
debuglevel="${debuglevel}"
- destdir="${test.classes}">
+ destdir="${test.classes}"
+ includeantruntime="false">
<classpath refid="cassandra.classpath"/>
<src path="${test.unit.src}"/>
</javac>
View
2  src/java/src/com/datastax/brisk/BriskDaemon.java
@@ -136,7 +136,7 @@ public ThriftServer(InetAddress listenAddr, int listenPort)
Brisk.Processor processor = new Brisk.Processor(briskServer);
// Transport
- TServerSocket tServerSocket = null;
+ TCustomServerSocket tServerSocket = null;
try
{
View
3  src/java/src/org/apache/cassandra/hadoop/fs/CassandraFileSystemThriftStore.java
@@ -37,6 +37,7 @@
import org.apache.cassandra.utils.ByteBufferUtil;
import org.apache.cassandra.utils.FBUtilities;
import org.apache.cassandra.utils.UUIDGen;
+import org.apache.cassandra.utils.Hex;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.BlockLocation;
import org.apache.hadoop.fs.Path;
@@ -646,7 +647,7 @@ ByteBuffer getPathKey(Path path)
ByteBuffer uuidToByteBuffer(UUID id)
{
- return ByteBufferUtil.bytes(FBUtilities.bytesToHex(UUIDGen.decompose(id)));
+ return ByteBufferUtil.bytes(Hex.bytesToHex(UUIDGen.decompose(id)));
}
/**
View
5 src/java/src/org/apache/cassandra/pig/CassandraStorage.java
@@ -27,6 +27,7 @@
import org.apache.cassandra.db.marshal.TypeParser;
import org.apache.cassandra.thrift.*;
import org.apache.cassandra.utils.FBUtilities;
+import org.apache.cassandra.utils.Hex;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -625,7 +626,7 @@ private static String cfdefToString(CfDef cfDef)
TSerializer serializer = new TSerializer(new TBinaryProtocol.Factory());
try
{
- return FBUtilities.bytesToHex(serializer.serialize(cfDef));
+ return Hex.bytesToHex(serializer.serialize(cfDef));
}
catch (TException e)
{
@@ -640,7 +641,7 @@ private static CfDef cfdefFromString(String st)
CfDef cfDef = new CfDef();
try
{
- deserializer.deserialize(cfDef, FBUtilities.hexToBytes(st));
+ deserializer.deserialize(cfDef, Hex.hexToBytes(st));
}
catch (TException e)
{
View
2  test/conf/cassandra.yaml
@@ -10,12 +10,10 @@ partitioner: org.apache.cassandra.dht.RandomPartitioner
rpc_timeout_in_ms: 5000
listen_address: 127.0.0.1
storage_port: 7010
-rpc_address: 0.0.0.0
rpc_port: 9170
column_index_size_in_kb: 4
commitlog_directory: build/test/cassandra/commitlog
saved_caches_directory: build/test/cassandra/saved_caches
-commitlog_rotation_threshold_in_mb: 128
data_file_directories:
- build/test/cassandra/data
disk_access_mode: mmap
View
2  test/unit/org/apache/cassandra/BriskErrorDaemon.java
@@ -89,7 +89,7 @@ public ThriftServer(InetAddress listenAddr, int listenPort)
Brisk.Processor processor = new Brisk.Processor(briskServer);
// Transport
- TServerSocket tServerSocket = null;
+ TCustomServerSocket tServerSocket = null;
try
{
View
8 test/unit/org/apache/cassandra/BriskErrorServer.java
@@ -22,8 +22,8 @@
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.cassandra.config.CFMetaData;
-import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.config.KSMetaData;
+import org.apache.cassandra.config.Schema;
import org.apache.cassandra.service.ClientState;
import org.apache.cassandra.thrift.*;
import org.apache.thrift.TException;
@@ -68,13 +68,13 @@ public String describe_cluster_name() throws TException
public KsDef describe_keyspace(String table) throws NotFoundException, InvalidRequestException, TException
{
- KSMetaData ksm = DatabaseDescriptor.getTableDefinition(table);
+ KSMetaData ksm = Schema.instance.getTableDefinition(table);
if (ksm == null)
throw new NotFoundException();
List<CfDef> cfDefs = new ArrayList<CfDef>();
for (CFMetaData cfm : ksm.cfMetaData().values())
- cfDefs.add(CFMetaData.convertToThrift(cfm));
+ cfDefs.add(cfm.toThrift());
KsDef ksdef = new KsDef(ksm.name, ksm.strategyClass.getName(), cfDefs);
ksdef.setStrategy_options(ksm.strategyOptions);
return ksdef;
@@ -82,7 +82,7 @@ public KsDef describe_keyspace(String table) throws NotFoundException, InvalidRe
public List<KsDef> describe_keyspaces() throws InvalidRequestException, TException
{
- Set<String> keyspaces = DatabaseDescriptor.getTables();
+ Set<String> keyspaces = Schema.instance.getTables();
List<KsDef> ksset = new ArrayList<KsDef>();
for (String ks : keyspaces)
{
View
247 test/unit/org/apache/cassandra/SchemaLoader.java
@@ -21,30 +21,40 @@
import java.nio.ByteBuffer;
import java.util.*;
-import com.google.common.base.Charsets;
-
-import org.junit.BeforeClass;
+import org.apache.cassandra.utils.ByteBufferUtil;
+import com.google.common.base.Charsets;
import org.apache.cassandra.config.*;
import org.apache.cassandra.db.ColumnFamilyType;
import org.apache.cassandra.db.marshal.*;
+import org.apache.cassandra.io.compress.CompressionParameters;
+import org.apache.cassandra.io.compress.SnappyCompressor;
import org.apache.cassandra.locator.AbstractReplicationStrategy;
import org.apache.cassandra.locator.SimpleStrategy;
import org.apache.cassandra.thrift.IndexType;
+import org.junit.BeforeClass;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class SchemaLoader
{
+ private static Logger logger = LoggerFactory.getLogger(SchemaLoader.class);
+
@BeforeClass
public static void loadSchema()
{
- try
+ Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler()
{
- for (KSMetaData ksm : schemaDefinition())
+ public void uncaughtException(Thread t, Throwable e)
{
- for (CFMetaData cfm : ksm.cfMetaData().values())
- CFMetaData.map(cfm);
- DatabaseDescriptor.setTableDefinition(ksm, DatabaseDescriptor.getDefsVersion());
+ logger.error("Fatal exception in thread " + t, e);
}
+ });
+
+ try
+ {
+ Schema.instance.load(schemaDefinition(), Schema.instance.getVersion());
}
catch (ConfigurationException e)
{
@@ -52,7 +62,7 @@ public static void loadSchema()
}
}
- public static Collection<KSMetaData> schemaDefinition()
+ public static Collection<KSMetaData> schemaDefinition() throws ConfigurationException
{
List<KSMetaData> schema = new ArrayList<KSMetaData>();
@@ -62,9 +72,11 @@ public static void loadSchema()
String ks3 = "Keyspace3";
String ks4 = "Keyspace4";
String ks5 = "Keyspace5";
+ String ks6 = "Keyspace6";
String ks_kcs = "KeyCacheSpace";
String ks_rcs = "RowCacheSpace";
-
+ String ks_nocommit = "NoCommitlogSpace";
+
Class<? extends AbstractReplicationStrategy> simple = SimpleStrategy.class;
Map<String, String> opts_rf1 = KSMetaData.optsWithRF(1);
@@ -76,53 +88,210 @@ public static void loadSchema()
ColumnFamilyType su = ColumnFamilyType.Super;
AbstractType bytes = BytesType.instance;
+ AbstractType composite = CompositeType.getInstance(Arrays.asList(new AbstractType[]{BytesType.instance, TimeUUIDType.instance, IntegerType.instance}));
+ Map<Byte, AbstractType> aliases = new HashMap<Byte, AbstractType>();
+ aliases.put((byte)'b', BytesType.instance);
+ aliases.put((byte)'t', TimeUUIDType.instance);
+ AbstractType dynamicComposite = DynamicCompositeType.getInstance(aliases);
+
+ // these column definitions will will be applied to the jdbc utf and integer column familes respectively.
+ Map<ByteBuffer, ColumnDefinition> integerColumn = new HashMap<ByteBuffer, ColumnDefinition>();
+ integerColumn.put(IntegerType.instance.fromString("42"), new ColumnDefinition(
+ IntegerType.instance.fromString("42"),
+ UTF8Type.instance,
+ null,
+ null,
+ "Column42"));
+ Map<ByteBuffer, ColumnDefinition> utf8Column = new HashMap<ByteBuffer, ColumnDefinition>();
+ utf8Column.put(UTF8Type.instance.fromString("fortytwo"), new ColumnDefinition(
+ UTF8Type.instance.fromString("fortytwo"),
+ IntegerType.instance,
+ null,
+ null,
+ "Column42"));
+
// Keyspace 1
- schema.add(new KSMetaData(
- ks1,
- simple,
- opts_rf1,
-
- // Column Families
- standardCFMD(ks1, "Standard1"), standardCFMD(ks1, "Standard2"), standardCFMD(ks1, "Standard3"),
- standardCFMD(ks1, "Standard4"), standardCFMD(ks1, "StandardLong1"), standardCFMD(ks1, "StandardLong2"),
- superCFMD(ks1, "Super1", LongType.instance), superCFMD(ks1, "Super2", LongType.instance), superCFMD(
- ks1, "Super3", LongType.instance), superCFMD(ks1, "Super4", UTF8Type.instance), superCFMD(ks1,
- "Super5", bytes), indexCFMD(ks1, "Indexed1", true), indexCFMD(ks1, "Indexed2", false),
- new CFMetaData(ks1, "StandardInteger1", st, IntegerType.instance, null).keyCacheSize(0),
- new CFMetaData(ks1, "Counter1", st, bytes, null).defaultValidator(CounterColumnType.instance),
- new CFMetaData(ks1, "SuperCounter1", su, bytes, bytes).defaultValidator(CounterColumnType.instance),
- jdbcCFMD(ks1, "JdbcInteger", IntegerType.instance), jdbcCFMD(ks1, "JdbcUtf8", UTF8Type.instance),
- jdbcCFMD(ks1, "JdbcLong", LongType.instance), jdbcCFMD(ks1, "JdbcBytes", bytes), jdbcCFMD(ks1,
- "JdbcAscii", AsciiType.instance)));
+ schema.add(KSMetaData.testMetadata(ks1,
+ simple,
+ opts_rf1,
+
+ // Column Families
+ standardCFMD(ks1, "Standard1"),
+ standardCFMD(ks1, "Standard2"),
+ standardCFMD(ks1, "Standard3"),
+ standardCFMD(ks1, "Standard4"),
+ standardCFMD(ks1, "StandardLong1"),
+ standardCFMD(ks1, "StandardLong2"),
+ new CFMetaData(ks1,
+ "ValuesWithQuotes",
+ st,
+ BytesType.instance,
+ null)
+ .defaultValidator(UTF8Type.instance),
+ superCFMD(ks1, "Super1", LongType.instance),
+ superCFMD(ks1, "Super2", LongType.instance),
+ superCFMD(ks1, "Super3", LongType.instance),
+ superCFMD(ks1, "Super4", UTF8Type.instance),
+ superCFMD(ks1, "Super5", bytes),
+ superCFMD(ks1, "Super6", LexicalUUIDType.instance, UTF8Type.instance),
+ indexCFMD(ks1, "Indexed1", true),
+ indexCFMD(ks1, "Indexed2", false),
+ new CFMetaData(ks1,
+ "StandardInteger1",
+ st,
+ IntegerType.instance,
+ null)
+ .keyCacheSize(0),
+ new CFMetaData(ks1,
+ "Counter1",
+ st,
+ bytes,
+ null)
+ .defaultValidator(CounterColumnType.instance)
+ .mergeShardsChance(1.0),
+ new CFMetaData(ks1,
+ "SuperCounter1",
+ su,
+ bytes,
+ bytes)
+ .defaultValidator(CounterColumnType.instance)
+ .mergeShardsChance(1.0),
+ superCFMD(ks1, "SuperDirectGC", BytesType.instance).gcGraceSeconds(0),
+ jdbcCFMD(ks1, "JdbcInteger", IntegerType.instance).columnMetadata(integerColumn),
+ jdbcCFMD(ks1, "JdbcUtf8", UTF8Type.instance).columnMetadata(utf8Column),
+ jdbcCFMD(ks1, "JdbcLong", LongType.instance),
+ jdbcCFMD(ks1, "JdbcBytes", bytes),
+ jdbcCFMD(ks1, "JdbcAscii", AsciiType.instance),
+ new CFMetaData(ks1,
+ "StandardComposite",
+ st,
+ composite,
+ null),
+ new CFMetaData(ks1,
+ "StandardDynamicComposite",
+ st,
+ dynamicComposite,
+ null)));
+
+ // Keyspace 2
+ schema.add(KSMetaData.testMetadata(ks2,
+ simple,
+ opts_rf1,
+
+ // Column Families
+ standardCFMD(ks2, "Standard1"),
+ standardCFMD(ks2, "Standard3"),
+ superCFMD(ks2, "Super3", bytes),
+ superCFMD(ks2, "Super4", TimeUUIDType.instance),
+ indexCFMD(ks2, "Indexed1", true)));
+
+ // Keyspace 3
+ schema.add(KSMetaData.testMetadata(ks3,
+ simple,
+ opts_rf5,
+
+ // Column Families
+ standardCFMD(ks3, "Standard1"),
+ indexCFMD(ks3, "Indexed1", true)));
+
+ // Keyspace 4
+ schema.add(KSMetaData.testMetadata(ks4,
+ simple,
+ opts_rf3,
+ // Column Families
+ standardCFMD(ks4, "Standard1"),
+ standardCFMD(ks4, "Standard3"),
+ superCFMD(ks4, "Super3", bytes),
+ superCFMD(ks4, "Super4", TimeUUIDType.instance),
+ new CFMetaData(ks4,
+ "Super5",
+ su,
+ TimeUUIDType.instance,
+ bytes)
+ .keyCacheSize(0)));
+ // Keyspace 5
+ schema.add(KSMetaData.testMetadata(ks5,
+ simple,
+ opts_rf2,
+ standardCFMD(ks5, "Standard1"),
+ standardCFMD(ks5, "Counter1")
+ .defaultValidator(CounterColumnType.instance)));
+
+ // Keyspace 6
+ schema.add(KSMetaData.testMetadata(ks6,
+ simple,
+ opts_rf1,
+ indexCFMD(ks6, "Indexed1", true)));
+
+ // KeyCacheSpace
+ schema.add(KSMetaData.testMetadata(ks_kcs,
+ simple,
+ opts_rf1,
+ standardCFMD(ks_kcs, "Standard1")
+ .keyCacheSize(0.5),
+ standardCFMD(ks_kcs, "Standard2")
+ .keyCacheSize(1.0),
+ standardCFMD(ks_kcs, "Standard3")
+ .keyCacheSize(1.0)));
+
+ // RowCacheSpace
+ schema.add(KSMetaData.testMetadata(ks_rcs,
+ simple,
+ opts_rf1,
+ standardCFMD(ks_rcs, "CFWithoutCache"),
+ standardCFMD(ks_rcs, "CachedCF")
+ .rowCacheSize(100)));
+
+ schema.add(KSMetaData.testMetadataNotDurable(ks_nocommit,
+ simple,
+ opts_rf1,
+ standardCFMD(ks_nocommit, "Standard1")));
+
+
+ if (Boolean.parseBoolean(System.getProperty("cassandra.test.compression", "false")))
+ useCompression(schema);
+
return schema;
}
+ private static void useCompression(List<KSMetaData> schema)
+ {
+ for (KSMetaData ksm : schema)
+ {
+ for (CFMetaData cfm : ksm.cfMetaData().values())
+ {
+ cfm.compressionParameters(new CompressionParameters(SnappyCompressor.instance));
+ }
+ }
+ }
+
private static CFMetaData standardCFMD(String ksName, String cfName)
{
return new CFMetaData(ksName, cfName, ColumnFamilyType.Standard, BytesType.instance, null).keyCacheSize(0);
}
-
private static CFMetaData superCFMD(String ksName, String cfName, AbstractType subcc)
{
- return new CFMetaData(ksName, cfName, ColumnFamilyType.Super, BytesType.instance, subcc).keyCacheSize(0);
+ return superCFMD(ksName, cfName, BytesType.instance, subcc).keyCacheSize(0);
}
-
- private static CFMetaData indexCFMD(String ksName, String cfName, final Boolean withIdxType)
+ private static CFMetaData superCFMD(String ksName, String cfName, AbstractType cc, AbstractType subcc)
+ {
+ return new CFMetaData(ksName, cfName, ColumnFamilyType.Super, cc, subcc).keyCacheSize(0);
+ }
+ private static CFMetaData indexCFMD(String ksName, String cfName, final Boolean withIdxType) throws ConfigurationException
{
- return standardCFMD(ksName, cfName).columnMetadata(
- Collections.unmodifiableMap(new HashMap<ByteBuffer, ColumnDefinition>() {
- {
+ return standardCFMD(ksName, cfName)
+ .keyValidator(AsciiType.instance)
+ .columnMetadata(new HashMap<ByteBuffer, ColumnDefinition>()
+ {{
ByteBuffer cName = ByteBuffer.wrap("birthdate".getBytes(Charsets.UTF_8));
IndexType keys = withIdxType ? IndexType.KEYS : null;
- put(cName, new ColumnDefinition(cName, LongType.instance, keys, null));
- }
- }));
+ put(cName, new ColumnDefinition(cName, LongType.instance, keys, null, ByteBufferUtil.bytesToHex(cName)));
+ }});
}
-
private static CFMetaData jdbcCFMD(String ksName, String cfName, AbstractType comp)
{
- return new CFMetaData(ksName, cfName, ColumnFamilyType.Standard, comp, comp).defaultValidator(comp);
+ return new CFMetaData(ksName, cfName, ColumnFamilyType.Standard, comp, null).defaultValidator(comp);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.