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

Replicator update #523

Merged
merged 6 commits into from
Feb 16, 2017
Merged

Replicator update #523

merged 6 commits into from
Feb 16, 2017

Conversation

woodsaj
Copy link
Member

@woodsaj woodsaj commented Feb 8, 2017

No description provided.

@@ -100,13 +100,13 @@ func main() {
select {
case <-consumer.Done:
log.Info("metrics consumer ended.")
publisher.Stop()
return
case <-sigChan:
log.Info("metrics shutdown started.")
consumer.Stop()
Copy link
Contributor

Choose a reason for hiding this comment

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

don't we need to also stop publisher here?

partitionScheme = flag.String("partition-scheme", "byOrg", "method used for partitioning metrics. (byOrg|bySeries)")
compression = flag.String("compression", "none", "compression: none|gzip|snappy")
replicateMetrics = flag.Bool("metrics", false, "replicate metrics")
replicatePersist = flag.Bool("persist", false, "replicate persistMetrics")
Copy link
Contributor

Choose a reason for hiding this comment

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

let's print an error if neither of these modes is enabled.

@Dieterbe
Copy link
Contributor

Dieterbe commented Feb 13, 2017

also:

$ unused
/home/dieter/go/src/github.com/raintank/metrictank/cmd/mt-replicator/consume.go:95:20: func kafkaNotifications is unused
/home/dieter/go/src/github.com/raintank/metrictank/cmd/mt-replicator/main.go:34:2: var wg is unused
/home/dieter/go/src/github.com/raintank/metrictank/cmd/mt-replicator/main.go:37:6: type topic is unused
/home/dieter/go/src/github.com/raintank/metrictank/cmd/mt-replicator/metricpersist.go:104:24: func kafkaNotifications is unused

unused is a really useful tool. i can recommend it: go get -u honnef.co/go/unused

@Dieterbe
Copy link
Contributor

I think this code would be quite a bit easier to understand if there was a bit more symmetry between the metrics relay and the persist relay, right now the code is structured differently (see PersistRelay type vs Consumer and Producer type), for the metrics we call Stop(), but for the persistrelay we call Close() which then calls Stop(), so why not use the Stop() terminology as well?
I would try to make them as similar as possible, it would make things more clear and bugs easier to spot.

for {
select {
case <-metricPersist.Done:
log.Info("metricPersist ended.")
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we close the producer here? (or inside of the actual relay code)

woodsaj and others added 4 commits February 16, 2017 12:45
If metric relay was more important or common than persist relaying,
or the default one, then we could have it as it was.
However since both are disabled by default, it makes more sense to be
explicit
@woodsaj woodsaj force-pushed the replicatorUpdate branch 2 times, most recently from 42d9dfb to 874732a Compare February 16, 2017 04:49
- use similar code structure for replicating metrics and persist
messages.
- send persistMessages in batches to greatly improve performance
@Dieterbe
Copy link
Contributor

for the persist relay, don't we have to make sure to route the persist messages to the correct partition? since notifierKafka has recently become partition aware.

func (r *MetricsReplicator) Flush(metrics []*schema.MetricData) {
if len(metrics) == 0 {
return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

since you already check the len before calling Flush, this can be removed. it would also be more akin to metricpersist which also doesn't have this check.

@woodsaj
Copy link
Member Author

woodsaj commented Feb 16, 2017

for the persist relay, don't we have to make sure to route the persist messages to the correct partition? since notifierKafka has recently become partition aware.

we do, by re-using the sarama.ProducerMessage.Key from the original message. The sarama lib will then correctly set the partitionId based on the number of partitions in use on the destination kafka cluster.

@Dieterbe
Copy link
Contributor

Dieterbe commented Feb 16, 2017

that makes sense. So would it be correct to say that now mt-replicator can switch the partitioning method (byOrg vs bySeries) for metrics, but not for metricpersist messages? (which is fine by me)

other then my small last comment about the check in Flush, this LGTM

@woodsaj
Copy link
Member Author

woodsaj commented Feb 16, 2017

correct. the metricpersist messages can be replicated and re-allocated to new partitions, but the partitioning method cant be changed.
Also, replicating peristsMessages only works if the current MT version is 0.7.x

@woodsaj woodsaj merged commit 02041d6 into master Feb 16, 2017
@woodsaj woodsaj deleted the replicatorUpdate branch February 16, 2017 17:24
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.

2 participants