Permalink
Browse files

remove withLock, no longer used

  • Loading branch information...
1 parent 484305d commit 43d68b2996de872dbead3c667f036bb8f9126a00 @freels freels committed Aug 2, 2011
@@ -53,17 +53,4 @@ class ReadWriteShardAdapter(shard: shards.ReadWriteShard[Shard])
def negate(sourceId: Long, destinationId: Long, position: Long, updatedAt: Time) = shard.writeOperation(_.negate(sourceId, destinationId, position, updatedAt))
def archive(sourceId: Long, destinationId: Long, position: Long, updatedAt: Time) = shard.writeOperation(_.archive(sourceId, destinationId, position, updatedAt))
def archive(sourceId: Long, updatedAt: Time) = shard.writeOperation(_.archive(sourceId, updatedAt))
-
- def withLock[A](sourceId: Long)(f: (Shard, Metadata) => A) = {
- if (shard.isInstanceOf[shards.ReplicatingShard[_]]) {
- val replicatingShard = shard.asInstanceOf[shards.ReplicatingShard[Shard]]
- val lockServer = children.head.asInstanceOf[Shard]
- val rest = children.drop(1).asInstanceOf[Seq[Shard]]
- lockServer.withLock(sourceId) { (lock, metadata) =>
- f(new ReadWriteShardAdapter(new shards.ReplicatingShard(shardInfo, weight, List(lock) ++ rest, replicatingShard.loadBalancer, replicatingShard.future)), metadata)
- }
- } else {
- shard.writeOperation(_.withLock(sourceId)(f))
- }
- }
}
@@ -31,7 +31,6 @@ trait Shard extends shards.Shard {
Seq(try { Right(getMetadata(sourceId)) } catch { case e => Left(e) })
}
- @throws(classOf[shards.ShardException]) def withLock[A](sourceId: Long)(f: (Shard, Metadata) => A): A
@throws(classOf[shards.ShardException]) def optimistically(sourceId: Long)(f: State => Unit)
@throws(classOf[shards.ShardException]) def count(sourceId: Long, states: Seq[State]): Int
@@ -561,12 +561,6 @@ class SqlShard(val queryEvaluator: QueryEvaluator, val shardInfo: shards.ShardIn
}
}
- def withLock[A](sourceId: Long)(f: (Shard, Metadata) => A) = {
- atomically(sourceId) { (transaction, metadata) =>
- f(new SqlShard(transaction, shardInfo, weight, children, deadlockRetries), metadata)
- }
- }
-
private def atomically[A](sourceId: Long)(f: (Transaction, Metadata) => A): A = {
try {
queryEvaluator.transaction { transaction =>
@@ -31,10 +31,6 @@ import jobs.multi.{Archive, RemoveAll, Unarchive}
import jobs.single.{Add, Remove, Archive, NodePair}
-class FakeLockingShard(shard: Shard) extends SqlShard(null, new ShardInfo("a", "b", "c"), 1, Nil, 0) {
- override def withLock[A](sourceId: Long)(f: (Shard, Metadata) => A) = f(shard, shard.getMetadata(sourceId).get) // jMock is not up to the task
-}
-
class SimpleAdapter(shard: Shard) extends ReadWriteShardAdapter(new IdentityShard[Shard](shard))
class IdentityShard[ConcreteShard <: Shard](shard: ConcreteShard)
@@ -30,30 +30,6 @@ object ReadWriteShardAdapterSpec extends ConfiguredSpecification with JMocker wi
var shard2: Shard = null
var shard3: Shard = null
- "ReadWriteShardAdapter" should {
- doBefore {
- shard1 = mock[Shard]
- shard2 = mock[Shard]
- shard3 = mock[Shard]
- }
-
- "call withLock only on the primary child" in {
- Time.withCurrentTimeFrozen { time =>
- val sourceId = 23
- val metadata = mock[Metadata]
-
- expect {
- one(shard2).getMetadata(sourceId) willReturn Some(metadata)
- one(shard2).add(sourceId, Time.now)
- }
-
- val fake2 = new FakeLockingShard(shard2)
- val fake1 = new FakeReadWriteShard[Shard](fake2, null, 1, Nil)
- val shard = new ReadWriteShardAdapter(fake1)
- shard.withLock(sourceId) { (innerShard, metadata) =>
- innerShard.add(sourceId, Time.now)
- }
- }
- }
+ "ReadWriteShardAdapter" in {
}
}

0 comments on commit 43d68b2

Please sign in to comment.