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

server/cache: add kv to cluster #382

Merged
merged 4 commits into from
Nov 17, 2016
Merged

Conversation

huachaohuang
Copy link
Contributor

@huachaohuang huachaohuang commented Nov 8, 2016

We update cache and kv separately in different places, which may not be safe and hard to maintain.
This PR updates both cache and kv consistently inside clusterInfo.

It's more safe to update cache and kv consistenly inside cluster.
@huachaohuang huachaohuang force-pushed the huachao/add-kv-to-cluster branch from 8d9b537 to 8e41da6 Compare November 14, 2016 02:49
@huachaohuang huachaohuang changed the base branch from huachaohuang/add-kv to master November 14, 2016 02:50
@huachaohuang huachaohuang changed the title [DNM] server/cache: add kv to cluster server/cache: add kv to cluster Nov 14, 2016
return c.innerPutMeta(proto.Clone(meta).(*metapb.Cluster))
}

func (c *clusterInfo) innerPutMeta(meta *metapb.Cluster) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer putMetaLocked which means that we must lock before calling this function.

@@ -243,8 +244,9 @@ func newClusterInfo(id IDAllocator) *clusterInfo {
}

// Return nil if cluster is not bootstrapped.
func loadClusterInfo(id IDAllocator, kv *kv) (*clusterInfo, error) {
func newClusterInfoWithKV(id IDAllocator, kv *kv) (*clusterInfo, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newClusterInfo is ok. you use two args, so WithKV is not proper here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have a newClusterInfo without kv for test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we should use a better name here.

@siddontang
Copy link
Contributor

Rest LGTM

@huachaohuang
Copy link
Contributor Author

PTAL @overvenus

Copy link
Member

@overvenus overvenus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@huachaohuang huachaohuang merged commit bc47777 into master Nov 17, 2016
@huachaohuang huachaohuang deleted the huachao/add-kv-to-cluster branch December 7, 2016 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants