-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introducing the notion of shards as an encapsulation of primary and s… #59
Conversation
Added a FIXME wrt follower allocation
|
||
import in.ashwanthkumar.suuchi.cluster.MemberAddress | ||
|
||
case class Shard(primaryPartition: VNode, follower: List[VNode]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please add a notion of id
/ name
to Shard?
|
||
import in.ashwanthkumar.suuchi.cluster.MemberAddress | ||
|
||
case class Shard(primaryPartition: VNode, follower: List[VNode]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For cases where we know they're primary and followers - it would be best if we can abstract those away as MemberAddress
isn't? VNode
doesn't make sense anymore to me. What do you think?
} | ||
|
||
class CHRWithShards(hashFn: Hash, partitionsPerNode: Int, replicationFactor: Int = 2) { | ||
val sortedMap = new util.TreeMap[Integer, Shard]() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please mark this private
? This is exposed as public
.
def getNodes = primaryPartition.node :: follower.map(_.node) | ||
} | ||
|
||
class CHRWithShards(hashFn: Hash, partitionsPerNode: Int, replicationFactor: Int = 2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if we don't have defaults as part of the class and move them as part of the companion object or place them where it's actually being used.
this | ||
} | ||
|
||
private def hash(shard: Shard): Int = hashFn.hash(shard.key.getBytes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move all private
methods to the bottom of the class.
import in.ashwanthkumar.suuchi.cluster.MemberAddress | ||
|
||
case class Shard(primaryPartition: VNode, follower: List[VNode]) { | ||
def key = primaryPartition.node.host + "_" + primaryPartition.node.port + "_" + primaryPartition.nodeReplicaId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's a nodeReplicaId
? Did it come in as part of #58 ?
|
||
def add(node: MemberAddress, nodes: List[MemberAddress]) = { | ||
// FIXME: followers based on nodes.filterNot will lead to a skew in first elements in the list | ||
(1 to partitionsPerNode).map(i => Shard(VNode(node, 1, Primary), followers(nodes.filterNot(_.equals(node))))).foreach { shard => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Selva, Can we please have a test for this? It doesn't look right to me.
|
||
import in.ashwanthkumar.suuchi.cluster.MemberAddress | ||
|
||
case class Shard(primaryPartition: VNode, follower: List[VNode]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I thought we were using partitions
and not partitionsPerNode
?
@gsriram7 Can we also please add tests to this PR? Also can you print the CHRing with some sample data and see if you can plot it on a ring like structure by taking their ranges into account. |
Added tests for NodePriority P.S More tests need to be added to CHRWithShards and method and class names of NodePriority has to be refactored
Closing this in favor of #60 |
…econdary partitions