Permalink
Browse files

add getCurrentShard & listCurrentDownwardLinks.

  • Loading branch information...
1 parent 169ee98 commit c5aa05c4e5e7a87db7494a8380632bdbc35d8280 Robey Pointer committed Aug 30, 2010
@@ -138,6 +138,10 @@ class NameServer[S <: shards.Shard](nameServerShard: Shard, shardRepository: Sha
findShardById(shardInfo.id)
}
+ def listCurrentDownwardLinks(id: ShardId) = getChildren(id)
+
+ def getCurrentShard(id: ShardId) = getShardInfo(id)
+
@throws(classOf[shards.ShardException]) def createShard[S <: shards.Shard](shardInfo: ShardInfo, repository: ShardRepository[S]) = nameServerShard.createShard(shardInfo, repository)
@throws(classOf[shards.ShardException]) def getShard(id: ShardId) = nameServerShard.getShard(id)
@throws(classOf[shards.ShardException]) def deleteShard(id: ShardId) = nameServerShard.deleteShard(id)
@@ -95,10 +95,6 @@ class ShardManagerService[ConcreteShard <: shards.Shard](nameServer: NameServer[
nameServer.reload()
}
- def find_current_forwarding(tableId: Int, id: Long) = wrapWithThriftExceptions {
- nameServer.findCurrentForwarding(tableId, id).shardInfo.toThrift
- }
-
def shards_for_hostname(hostname: String): java.util.List[ShardInfo] = wrapWithThriftExceptions {
nameServer.shardsForHostname(hostname).map(_.toThrift).toJavaList
}
@@ -114,4 +110,16 @@ class ShardManagerService[ConcreteShard <: shards.Shard](nameServer: NameServer[
def rebuild_schema() = wrapWithThriftExceptions {
nameServer.rebuildSchema()
}
+
+ def find_current_forwarding(tableId: Int, id: Long) = wrapWithThriftExceptions {
+ nameServer.findCurrentForwarding(tableId, id).shardInfo.toThrift
+ }
+
+ def list_current_downward_links(id: ShardId) = wrapWithThriftExceptions {
+ nameServer.listCurrentDownwardLinks(id.fromThrift).map(_.toThrift).toJavaList
+ }
+
+ def get_current_shard(id: ShardId) = wrapWithThriftExceptions {
+ nameServer.getCurrentShard(id.fromThrift).toThrift
+ }
}
@@ -61,6 +61,9 @@ service ShardManager {
void rebuild_schema() throws(1: ShardException ex)
- // operate on the current forwardings in memory
+ // ----- operate on the current forwardings in memory:
+
ShardInfo find_current_forwarding(1: i32 table_id, 2: i64 id) throws(1: ShardException ex)
+ list<LinkInfo> list_current_downward_links(1: ShardId id) throws(1: ShardException ex)
+ ShardInfo get_current_shard(1: ShardId id) throws(1: ShardException ex)
}
@@ -64,6 +64,14 @@ object NameServerSpec extends ConfiguredSpecification with JMocker with ClassMoc
nameServer.findCurrentForwarding(1, 2) mustEqual shard
}
+ "list current downward links" in {
+ nameServer.listCurrentDownwardLinks(shardInfos(2).id).toList mustEqual linksList
+ }
+
+ "get current shard" in {
+ nameServer.getCurrentShard(shardInfos(1).id) mustEqual shardInfos(1)
+ }
+
"find shard by id" in {
expect {
one(shardRepository).find(shardInfos(3), 1, List()) willReturn shard

0 comments on commit c5aa05c

Please sign in to comment.