Skip to content
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

Closed
wants to merge 4 commits into from

Conversation

gsriram7
Copy link
Collaborator

…econdary partitions

@gsriram7
Copy link
Collaborator Author

@ashwanthkumar

Added a FIXME wrt follower allocation

import in.ashwanthkumar.suuchi.cluster.MemberAddress

case class Shard(primaryPartition: VNode, follower: List[VNode]) {
Copy link
Owner

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]) {
Copy link
Owner

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]()
Copy link
Owner

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) {
Copy link
Owner

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)
Copy link
Owner

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
Copy link
Owner

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 =>
Copy link
Owner

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]) {
Copy link
Owner

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 ?

@ashwanthkumar
Copy link
Owner

@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
@ashwanthkumar
Copy link
Owner

Closing this in favor of #60

@ashwanthkumar ashwanthkumar added this to the 0.2 milestone Jun 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants