Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Better replicate #723

Merged
merged 7 commits into from
Sep 8, 2017
Merged

Better replicate #723

merged 7 commits into from
Sep 8, 2017

Conversation

woodsaj
Copy link
Member

@woodsaj woodsaj commented Sep 7, 2017

use kafkamdm Input plugin to consume from kafka instead of using the saramaCluster consumergroups

woodsaj added 2 commits September 8, 2017 03:24
- make cluster.ClusterManager an interface
- rename ClusterManager struct to MemberlistClusterManager
- add a SingleNodeManager that implements the clusterManager interface
- when initializing the cluster, if Mode=multi use MemberlistClusterManager
  otherwise use SingleNodeManager
- use the kafkaMdm input plugin to consume from kafka.  This consumes
  from explicit partitions, rather then using the high level
  sarama.cluster consumer groups
- add metrics to track how things are running
node.Updated = time.Now()
m.node = node
nodeReady.Set(state == NodeReady)
return
Copy link
Contributor

Choose a reason for hiding this comment

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

does that return have any effect?

// lower values == higher priority
func (m *SingleNodeManager) SetPriority(prio int) {
m.Lock()
defer m.RUnlock()
Copy link
Contributor

Choose a reason for hiding this comment

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

This is first acquiring a write lock and then releasing a read lock. I don't know what happens in this case

Copy link
Member Author

Choose a reason for hiding this comment

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

nothing good. Will fix it up

node := m.node
node.Priority = prio
node.Updated = time.Now()
m.node = node
Copy link
Contributor

@replay replay Sep 8, 2017

Choose a reason for hiding this comment

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

Not important, but assuming the write lock is held you might as well directly

m.node.Priority = prio
m.Updated = time.Now()

@Dieterbe
Copy link
Contributor

Dieterbe commented Sep 8, 2017

use kafkamdm Input plugin to consume from kafka instead of using the saramaCluster consumergroups

why do we want this? is this because we're seeing a bug with saramacluster?

@woodsaj
Copy link
Member Author

woodsaj commented Sep 8, 2017

why do we want this? is this because we're seeing a bug with saramacluster?
yes.

Copy link
Contributor

@replay replay left a comment

Choose a reason for hiding this comment

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

LGTM

@replay
Copy link
Contributor

replay commented Sep 8, 2017

that's going to end up being a complicated rebase for https://github.com/raintank/metrictank/pull/555/files, if you merge now i'll directly do that rebase now

@@ -46,26 +47,62 @@ var (
unmarshalErrMergeRemoteState = stats.NewCounter32("cluster.decode_err.merge_remote_state")
)

type ClusterManager struct {
type ClusterManager interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

this goes against go's "no stuttering" naming convention. can just call this Manager since it's in package cluster

Copy link
Member Author

Choose a reason for hiding this comment

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

there is a pacakge var called "Manager" already.

Start()
}

type MemberlistClusterManager struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

similar, no stuttering. so MemberlistManager

Copy link
Member Author

Choose a reason for hiding this comment

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

this i can change

mgr.cfg.Delegate = mgr
h := sha256.New()
h.Write([]byte(ClusterName))
mgr.cfg.SecretKey = h.Sum(nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't this stuff better go into a MemberlistManager constructor?

Copy link
Member Author

Choose a reason for hiding this comment

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

that would be better.

@@ -7,6 +7,7 @@ import (
)

func TestPeersForQuery(t *testing.T) {
Mode = ModeMulti
Copy link
Contributor

Choose a reason for hiding this comment

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

a few lines below this it says Convey("when cluster in single mode", t, func() {
whereas here we're testing multi mode with 1 node.
maybe we should make a separate test case for an actual single mode

@replay replay merged commit b3c1245 into master Sep 8, 2017
@woodsaj woodsaj deleted the betterReplicate branch September 8, 2017 19:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants