Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Commit

Permalink
take away the ability to configure the clock.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanking committed Mar 30, 2011
1 parent 6e049fc commit 19eed05
Show file tree
Hide file tree
Showing 19 changed files with 13 additions and 59 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
@@ -1,6 +1,7 @@
# master
* you can now set a connection timeout
* support for counter column families
* clocks are no longer configurable. everyone gets MicrosecondEpochClock

# 0.3.0 [2011-03-04]

Expand Down
Expand Up @@ -5,7 +5,6 @@ import java.util.{List, Map, Set}
import java.util.Collections.{singleton => singletonSet}

import codecs.{Codec, Utf8Codec}
import clocks.Clock
import java.util.{ArrayList, HashMap}
import org.apache.cassandra.finagle.thrift.{SlicePredicate, Deletion, Mutation, Column => TColumn, ColumnOrSuperColumn}
import scala.collection.mutable.ListBuffer
Expand Down
@@ -1,6 +1,6 @@
package com.twitter.cassie

import clocks.Clock
import clocks.MicrosecondEpochClock
import codecs.{Codec, Utf8Codec}
import connection.ClientProvider

Expand All @@ -25,18 +25,17 @@ case class ColumnFamily[Key, Name, Value](
keyspace: String,
name: String,
provider: ClientProvider,
clock: Clock,
defaultKeyCodec: Codec[Key],
defaultNameCodec: Codec[Name],
defaultValueCodec: Codec[Value],
readConsistency: ReadConsistency = ReadConsistency.Quorum,
writeConsistency: WriteConsistency = WriteConsistency.Quorum) {

val log = Logger.get
val clock = MicrosecondEpochClock

import ColumnFamily._

def clock(clock: Clock) = copy(clock = clock)
def keysAs[K](codec: Codec[K]): ColumnFamily[K, Name, Value] = copy(defaultKeyCodec = codec)
def namesAs[N](codec: Codec[N]): ColumnFamily[Key, N, Value] = copy(defaultNameCodec = codec)
def valuesAs[V](codec: Codec[V]): ColumnFamily[Key, Name, V] = copy(defaultValueCodec = codec)
Expand Down
@@ -1,7 +1,5 @@
package com.twitter.cassie

import clocks.Clock

import codecs.Codec
import org.apache.cassandra.finagle.thrift

Expand Down
@@ -1,6 +1,5 @@
package com.twitter.cassie

import clocks.Clock
import codecs.{Codec, Utf8Codec}
import connection.ClientProvider

Expand Down
4 changes: 2 additions & 2 deletions cassie-core/src/main/scala/com/twitter/cassie/Keyspace.scala
Expand Up @@ -13,11 +13,11 @@ class Keyspace(val name: String, val provider: ClientProvider) {
/**
* Returns a ColumnFamily with the given name and column/value codecs.
*/
def columnFamily[Key, Name, Value](name: String, clock: Clock)
def columnFamily[Key, Name, Value](name: String)
(implicit defaultKeyCodec: Codec[Key],
defaultNameCodec: Codec[Name],
defaultValueCodec: Codec[Value]) =
new ColumnFamily(this.name, name, provider, clock, defaultKeyCodec, defaultNameCodec, defaultValueCodec)
new ColumnFamily(this.name, name, provider, defaultKeyCodec, defaultNameCodec, defaultValueCodec)

/**
* Closes connections to the cluster for this keyspace.
Expand Down

This file was deleted.

Expand Up @@ -9,7 +9,6 @@
import com.twitter.util.Promise;

import com.twitter.cassie.ColumnFamily;
import com.twitter.cassie.clocks.MicrosecondEpochClock;
import com.twitter.cassie.connection.ClientProvider;
import com.twitter.cassie.codecs.Utf8Codec;
import com.twitter.cassie.ReadConsistency;
Expand Down
Expand Up @@ -34,7 +34,7 @@ public void before() throws Exception {
@Test
public void test() {
ColumnFamily cf = new ColumnFamily("ks", "cf", new MockCassandraClient.SimpleProvider(mock.client),
MicrosecondEpochClock.get(), Utf8Codec.get(), Utf8Codec.get(), Utf8Codec.get(),
Utf8Codec.get(), Utf8Codec.get(), Utf8Codec.get(),
ReadConsistency.Quorum(), WriteConsistency.Quorum());
cf.getColumn("key", "name");
ColumnParent cp = new ColumnParent("cf");
Expand Down
Expand Up @@ -33,7 +33,7 @@ public static void main(String[] args) throws Exception {
.connect();

// create a column family
ColumnFamily<String, String, String> cass = keyspace.columnFamily("Standard1", MicrosecondEpochClock.get(), Utf8Codec.get(), Utf8Codec.get(), Utf8Codec.get());
ColumnFamily<String, String, String> cass = keyspace.columnFamily("Standard1", Utf8Codec.get(), Utf8Codec.get(), Utf8Codec.get());

info("inserting some columns asynchronously");
cass.insert("yay for me", cass.newColumn("name", "Coda")).apply();
Expand Down

This file was deleted.

@@ -1,7 +1,6 @@
package com.twitter.cassie.tests.examples

import com.twitter.cassie._
import clocks.MicrosecondEpochClock
import com.twitter.cassie.Codecs._
import com.twitter.logging.Logger
import types.{LexicalUUID, VarInt, AsciiString, FixedLong}
Expand All @@ -25,7 +24,7 @@ object CassieRun {
.connect()

// create a column family
val cass = keyspace.columnFamily[String, String, String]("Standard1", MicrosecondEpochClock)
val cass = keyspace.columnFamily[String, String, String]("Standard1")

log.info("inserting some columns")
cass.insert("yay for me", Column("name", "Coda")).apply()
Expand Down
Expand Up @@ -7,13 +7,12 @@ import org.scalatest.Spec
import org.scalatest.matchers.MustMatchers
import org.scalatest.mock.MockitoSugar
import com.twitter.cassie._
import clocks.{MicrosecondEpochClock, Clock}
import com.twitter.cassie.MockCassandraClient.SimpleProvider

class BatchMutationBuilderTest extends Spec with MustMatchers with MockitoSugar {
val mcc = new MockCassandraClient
val cf = new ColumnFamily("ks", "People", new SimpleProvider(mcc.client),
MicrosecondEpochClock.get(), Utf8Codec.get(), Utf8Codec.get(), Utf8Codec.get(),
Utf8Codec.get(), Utf8Codec.get(), Utf8Codec.get(),
ReadConsistency.Quorum, WriteConsistency.Quorum)

def setup() = new BatchMutationBuilder(cf)
Expand Down
Expand Up @@ -14,7 +14,6 @@ import java.nio.ByteBuffer
import thrift.Mutation
import com.twitter.cassie._

import com.twitter.cassie.clocks.{MicrosecondEpochClock, Clock}
import MockCassandraClient._

/**
Expand All @@ -36,7 +35,7 @@ class ColumnFamilyTest extends Spec with MustMatchers with MockitoSugar {
def setup = {
val mcc = new MockCassandraClient
val cf = new ColumnFamily("ks", "cf", new SimpleProvider(mcc.client),
MicrosecondEpochClock.get(), Utf8Codec.get(), Utf8Codec.get(), Utf8Codec.get(),
Utf8Codec.get(), Utf8Codec.get(), Utf8Codec.get(),
ReadConsistency.Quorum, WriteConsistency.Quorum)
(mcc.client, cf)
}
Expand Down
Expand Up @@ -3,7 +3,6 @@ package com.twitter.cassie.tests
import org.scalatest.Spec
import org.scalatest.matchers.MustMatchers
import com.twitter.cassie.Column
import com.twitter.cassie.clocks.Clock
import com.twitter.conversions.time._

class ColumnTest extends Spec with MustMatchers {
Expand Down
Expand Up @@ -6,7 +6,6 @@ import org.scalatest.mock.MockitoSugar
import com.twitter.cassie.codecs.Utf8Codec
import com.twitter.cassie.Codecs._
import com.twitter.cassie.{WriteConsistency, ReadConsistency, Keyspace}
import com.twitter.cassie.clocks.MicrosecondEpochClock
import com.twitter.cassie.connection.ClientProvider

class KeyspaceTest extends Spec with MustMatchers with MockitoSugar {
Expand All @@ -15,7 +14,7 @@ class KeyspaceTest extends Spec with MustMatchers with MockitoSugar {
val keyspace = new Keyspace("MyApp", provider)

it("builds a column family with the same ClientProvider") {
val cf = keyspace.columnFamily[String, String, String]("People", MicrosecondEpochClock)
val cf = keyspace.columnFamily[String, String, String]("People")
cf.keyspace must equal("MyApp")
cf.name must equal("People")
cf.readConsistency must equal(ReadConsistency.Quorum)
Expand Down
Expand Up @@ -8,6 +8,6 @@ import com.twitter.cassie.{MockCassandraClient, ReadConsistency, WriteConsistenc
trait ColumnFamilyTestHelper {
val mockCassandraClient = new MockCassandraClient
var columnFamily = new ColumnFamily("ks", "cf", new SimpleProvider(mockCassandraClient.client),
MicrosecondEpochClock.get(), Utf8Codec.get(), Utf8Codec.get(), Utf8Codec.get(),
Utf8Codec.get(), Utf8Codec.get(), Utf8Codec.get(),
ReadConsistency.Quorum, WriteConsistency.Quorum)
}
Expand Up @@ -45,7 +45,7 @@ class CassieReducer extends Reducer[BytesWritable, ColumnWritable, BytesWritable
if(conf(PAGE_SIZE) != null ) page = Integer.valueOf(conf(PAGE_SIZE)).intValue
if(conf(MAX_FUTURES) != null ) maxFutures = Integer.valueOf(conf(MAX_FUTURES)).intValue
keyspace = cluster.keyspace(conf(KEYSPACE)).retryAttempts(2).connect()
columnFamily = keyspace.columnFamily[ByteBuffer, ByteBuffer, ByteBuffer](conf(COLUMN_FAMILY), MicrosecondEpochClock)
columnFamily = keyspace.columnFamily[ByteBuffer, ByteBuffer, ByteBuffer](conf(COLUMN_FAMILY))
batch = columnFamily.batch
}

Expand Down
Expand Up @@ -4,7 +4,6 @@ import org.apache.hadoop.mapreduce._
import org.apache.hadoop.io._
import java.nio.ByteBuffer
import com.twitter.cassie.codecs._
import com.twitter.cassie.clocks._
import scala.collection.JavaConversions._

class ColumnWritable extends ArrayWritable(classOf[BytesWritable]) {
Expand Down

0 comments on commit 19eed05

Please sign in to comment.