From a2bcc465f13c01f67a04e9a7c48163c91c0368ce Mon Sep 17 00:00:00 2001 From: Nick Desai Date: Thu, 15 Feb 2018 16:19:24 -0500 Subject: [PATCH 1/3] ISSUE 314: use notifier threshold to configure evaluator ShowAll --- core/internal/notifier/coordinator.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/internal/notifier/coordinator.go b/core/internal/notifier/coordinator.go index 7f543f4d..a78febf2 100644 --- a/core/internal/notifier/coordinator.go +++ b/core/internal/notifier/coordinator.go @@ -92,6 +92,11 @@ type Coordinator struct { clusters map[string]*clusterGroups clusterLock *sync.RWMutex + + // The value of the 'ShowAll' parameter when submitting a request to + // the evaluator. This flag is determined based on the notifier + // 'threshold' configuration. + ShowAll bool } // getModuleForClass returns the correct module based on the passed className. As part of the Configure steps, if there @@ -162,6 +167,7 @@ func (nc *Coordinator) Configure() { nc.quitChannel = make(chan struct{}) nc.running = sync.WaitGroup{} nc.evaluatorResponse = make(chan *protocol.ConsumerGroupStatus) + nc.ShowAll = false // Set the function for parsing templates and calling module Notify (configurable to enable testing) if nc.templateParseFunc == nil { @@ -184,6 +190,13 @@ func (nc *Coordinator) Configure() { viper.SetDefault(configRoot+".interval", 60) viper.SetDefault(configRoot+".threshold", 2) + // if any of the notifier thresholds are 1, we need to fetch + // status of all consumer groups from the evaluator + threshold := viper.GetInt(configRoot+".threshold") + if threshold == 1 { + nc.ShowAll = true + } + // Compile the whitelist for the consumer groups to notify for var groupWhitelist *regexp.Regexp whitelist := viper.GetString(configRoot + ".group-whitelist") @@ -373,6 +386,7 @@ func (nc *Coordinator) sendEvaluatorRequests() { Reply: nc.evaluatorResponse, Cluster: sendCluster, Group: sendConsumer, + ShowAll: nc.ShowAll, } }(cluster, consumer) groupInfo.LastEval = timeNow From 31b79e7fc17af0dc8b6c9c783a81204e3a086e02 Mon Sep 17 00:00:00 2001 From: Nick Desai Date: Fri, 16 Feb 2018 11:53:10 -0500 Subject: [PATCH 2/3] fixing gofmt --- core/internal/notifier/coordinator.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/internal/notifier/coordinator.go b/core/internal/notifier/coordinator.go index a78febf2..2e457d32 100644 --- a/core/internal/notifier/coordinator.go +++ b/core/internal/notifier/coordinator.go @@ -96,7 +96,7 @@ type Coordinator struct { // The value of the 'ShowAll' parameter when submitting a request to // the evaluator. This flag is determined based on the notifier // 'threshold' configuration. - ShowAll bool + ShowAll bool } // getModuleForClass returns the correct module based on the passed className. As part of the Configure steps, if there @@ -192,9 +192,9 @@ func (nc *Coordinator) Configure() { // if any of the notifier thresholds are 1, we need to fetch // status of all consumer groups from the evaluator - threshold := viper.GetInt(configRoot+".threshold") + threshold := viper.GetInt(configRoot + ".threshold") if threshold == 1 { - nc.ShowAll = true + nc.ShowAll = true } // Compile the whitelist for the consumer groups to notify for From e15601ac521b32975c93cd1650b3d33dcd2ed168 Mon Sep 17 00:00:00 2001 From: Nick Desai Date: Mon, 26 Feb 2018 09:57:15 -0500 Subject: [PATCH 3/3] test updates --- core/internal/notifier/coordinator_race_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/internal/notifier/coordinator_race_test.go b/core/internal/notifier/coordinator_race_test.go index c90b1820..b3c3d7bf 100644 --- a/core/internal/notifier/coordinator_race_test.go +++ b/core/internal/notifier/coordinator_race_test.go @@ -57,11 +57,11 @@ func TestCoordinator_sendEvaluatorRequests(t *testing.T) { case "testcluster": assert.Equalf(t, "testcluster", request.Cluster, "Expected request cluster to be testcluster, not %v", request.Cluster) assert.Equalf(t, "testgroup", request.Group, "Expected request group to be testgroup, not %v", request.Group) - assert.False(t, request.ShowAll, "Expected ShowAll to be false") + assert.True(t, request.ShowAll, "Expected ShowAll to be true") case "testcluster2": assert.Equalf(t, "testcluster2", request.Cluster, "Expected request cluster to be testcluster2, not %v", request.Cluster) assert.Equalf(t, "testgroup2", request.Group, "Expected request group to be testgroup2, not %v", request.Group) - assert.False(t, request.ShowAll, "Expected ShowAll to be false") + assert.True(t, request.ShowAll, "Expected ShowAll to be true") default: assert.Failf(t, "Received unexpected request for cluster %v, group %v", request.Cluster, request.Group) }