Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

Commit

Permalink
add dummy config updater
Browse files Browse the repository at this point in the history
  • Loading branch information
datoug committed Apr 11, 2017
1 parent 28f30ac commit 4764970
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 12 deletions.
3 changes: 2 additions & 1 deletion cmd/servicecmd/servicestartcmd.go
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/uber/cherami-server/clients/metadata"
"github.com/uber/cherami-server/common"
"github.com/uber/cherami-server/common/configure"
"github.com/uber/cherami-server/common/dconfig"
"github.com/uber/cherami-server/common/dconfigclient"
"github.com/uber/cherami-server/services/controllerhost"
"github.com/uber/cherami-server/services/frontendhost"
Expand Down Expand Up @@ -99,7 +100,7 @@ func StartControllerService() {
reporter := common.NewMetricReporterWithHostname(cfg.GetServiceConfig(serviceName))
dClient := dconfigclient.NewDconfigClient(cfg.GetServiceConfig(serviceName), serviceName)
sVice := common.NewService(serviceName, uuid.New(), cfg.GetServiceConfig(serviceName), common.NewUUIDResolver(meta), hwInfoReader, reporter, dClient)
mcp, tc := controllerhost.NewController(cfg, sVice, meta)
mcp, tc := controllerhost.NewController(cfg, sVice, meta, dconfig.NewDummyConfigUpdater())
mcp.Start(tc)
common.ServiceLoop(cfg.GetServiceConfig(serviceName).GetPort()+diagnosticPortOffset, cfg, mcp.Service)
}
Expand Down
28 changes: 28 additions & 0 deletions common/dconfig/configupdater.go
@@ -0,0 +1,28 @@
package dconfig

import (
"github.com/uber/cherami-server/common"
)

// ConfigUpdater is a daemon that can be used to update the config based on information from some external source
type (
ConfigUpdater interface {
common.Daemon
}

dummyConfigUpdater struct {
}
)

// NewDummyConfigUpdater creates a dummy config updater
func NewDummyConfigUpdater() ConfigUpdater {
return &dummyConfigUpdater{}
}

func (d *dummyConfigUpdater) Start() {
return
}

func (d *dummyConfigUpdater) Stop() {
return
}
7 changes: 6 additions & 1 deletion services/controllerhost/controllerhost.go
Expand Up @@ -104,6 +104,7 @@ type (
localZone string
mm MetadataMgr
rpm common.RingpopMonitor
configUpdater dconfig.ConfigUpdater
failureDetector Dfdd
log bark.Logger
dstLock LockMgr
Expand Down Expand Up @@ -147,7 +148,7 @@ type (
var _ c.TChanController = (*Mcp)(nil)

// NewController creates and returns a new instance of Mcp controller
func NewController(cfg configure.CommonAppConfig, sVice *common.Service, metadataClient m.TChanMetadataService) (*Mcp, []thrift.TChanServer) {
func NewController(cfg configure.CommonAppConfig, sVice *common.Service, metadataClient m.TChanMetadataService, configUpdater dconfig.ConfigUpdater) (*Mcp, []thrift.TChanServer) {
hostID := uuid.New()

instance := new(Mcp)
Expand All @@ -169,6 +170,7 @@ func NewController(cfg configure.CommonAppConfig, sVice *common.Service, metadat
}

context.localZone, _ = common.GetLocalClusterInfo(strings.ToLower(deploymentName))
context.configUpdater = configUpdater

context.dstLock = lockMgr
context.m3Client = metrics.NewClient(instance.Service.GetMetricsReporter(), metrics.Controller)
Expand Down Expand Up @@ -203,6 +205,8 @@ func (mcp *Mcp) Start(thriftService []thrift.TChanServer) {
context.channel = mcp.GetTChannel()
context.rpm = mcp.GetRingpopMonitor()

context.configUpdater.Start()

context.eventPipeline = NewEventPipeline(context, nEventPipelineWorkers)
context.eventPipeline.Start()

Expand Down Expand Up @@ -235,6 +239,7 @@ func (mcp *Mcp) Start(thriftService []thrift.TChanServer) {
// Stop stops the controller service
func (mcp *Mcp) Stop() {
mcp.hostIDHeartbeater.Stop()
mcp.context.configUpdater.Stop()
mcp.context.extentMonitor.Stop()
mcp.context.retMgr.Stop()
mcp.context.failureDetector.Stop()
Expand Down
7 changes: 4 additions & 3 deletions services/controllerhost/controllerhost_test.go
Expand Up @@ -32,7 +32,8 @@ import (
mc "github.com/uber/cherami-server/clients/metadata"
"github.com/uber/cherami-server/common"
"github.com/uber/cherami-server/common/configure"
dconfig "github.com/uber/cherami-server/common/dconfigclient"
"github.com/uber/cherami-server/common/dconfig"
"github.com/uber/cherami-server/common/dconfigclient"
"github.com/uber/cherami-server/test"
mockcommon "github.com/uber/cherami-server/test/mocks/common"
mockreplicator "github.com/uber/cherami-server/test/mocks/replicator"
Expand Down Expand Up @@ -106,11 +107,11 @@ func (s *McpSuite) startController() {

serviceName := common.ControllerServiceName
reporter := common.NewMetricReporterWithHostname(configure.NewCommonServiceConfig())
dClient := dconfig.NewDconfigClient(serviceConfig, common.ControllerServiceName)
dClient := dconfigclient.NewDconfigClient(serviceConfig, common.ControllerServiceName)

sVice := common.NewService(serviceName, uuid.New(), serviceConfig, common.NewUUIDResolver(s.mClient), common.NewHostHardwareInfoReader(s.mClient), reporter, dClient)
//serviceConfig.SetRingHosts(
mcp, tc := NewController(s.cfg, sVice, s.mClient)
mcp, tc := NewController(s.cfg, sVice, s.mClient, dconfig.NewDummyConfigUpdater())
s.mcp = mcp

context := s.mcp.context
Expand Down
1 change: 1 addition & 0 deletions services/controllerhost/dConfigUpdater.go
@@ -0,0 +1 @@
package controllerhost
7 changes: 4 additions & 3 deletions services/controllerhost/event_pipeline_test.go
Expand Up @@ -39,7 +39,8 @@ import (
mc "github.com/uber/cherami-server/clients/metadata"
"github.com/uber/cherami-server/common"
"github.com/uber/cherami-server/common/configure"
dconfig "github.com/uber/cherami-server/common/dconfigclient"
"github.com/uber/cherami-server/common/dconfig"
"github.com/uber/cherami-server/common/dconfigclient"
localMetrics "github.com/uber/cherami-server/common/metrics"
storeStream "github.com/uber/cherami-server/stream"
"github.com/uber/cherami-thrift/.generated/go/admin"
Expand Down Expand Up @@ -88,9 +89,9 @@ func (s *EventPipelineSuite) SetupTest() {

serviceName := common.ControllerServiceName
reporter := common.NewMetricReporterWithHostname(configure.NewCommonServiceConfig())
dClient := dconfig.NewDconfigClient(serviceConfig, common.ControllerServiceName)
dClient := dconfigclient.NewDconfigClient(serviceConfig, common.ControllerServiceName)
sVice := common.NewService(serviceName, uuid.New(), serviceConfig, common.NewUUIDResolver(s.mClient), common.NewHostHardwareInfoReader(s.mClient), reporter, dClient)
mcp, _ := NewController(s.cfg, sVice, s.mClient)
mcp, _ := NewController(s.cfg, sVice, s.mClient, dconfig.NewDummyConfigUpdater())
mcp.context.m3Client = &MockM3Metrics{}
s.mcp = mcp
ch, err := tchannel.NewChannel("event-pipeline-test", nil)
Expand Down
7 changes: 4 additions & 3 deletions services/controllerhost/extentmon_test.go
Expand Up @@ -36,7 +36,8 @@ import (
mc "github.com/uber/cherami-server/clients/metadata"
"github.com/uber/cherami-server/common"
"github.com/uber/cherami-server/common/configure"
dconfig "github.com/uber/cherami-server/common/dconfigclient"
"github.com/uber/cherami-server/common/dconfig"
"github.com/uber/cherami-server/common/dconfigclient"
"github.com/uber/cherami-server/common/metrics"
"github.com/uber/cherami-thrift/.generated/go/admin"
m "github.com/uber/cherami-thrift/.generated/go/metadata"
Expand Down Expand Up @@ -87,11 +88,11 @@ func (s *ExtentStateMonitorSuite) SetupTest() {

serviceName := common.ControllerServiceName
reporter := common.NewMetricReporterWithHostname(configure.NewCommonServiceConfig())
dClient := dconfig.NewDconfigClient(serviceConfig, common.ControllerServiceName)
dClient := dconfigclient.NewDconfigClient(serviceConfig, common.ControllerServiceName)

sVice := common.NewService(serviceName, uuid.New(), serviceConfig, common.NewUUIDResolver(s.mClient), common.NewHostHardwareInfoReader(s.mClient), reporter, dClient)

mcp, _ := NewController(s.cfg, sVice, s.mClient)
mcp, _ := NewController(s.cfg, sVice, s.mClient, dconfig.NewDummyConfigUpdater())
mcp.context.m3Client = &MockM3Metrics{}
s.mcp = mcp
ch, err := tchannel.NewChannel("extent-state-monitor-test", nil)
Expand Down
2 changes: 1 addition & 1 deletion test/integration/base.go
Expand Up @@ -270,7 +270,7 @@ func (tb *testBase) SetUp(clusterSz map[string]int, numReplicas int) {
reporter := common.NewTestMetricsReporter()
dClient := dconfig.NewDconfigClient(configure.NewCommonServiceConfig(), common.ControllerServiceName)
sVice := common.NewService(serviceName, uuid.New(), cfg.ServiceConfig[serviceName], tb.UUIDResolver, hwInfoReader, reporter, dClient)
ch, tc := controllerhost.NewController(cfg, sVice, tb.mClient)
ch, tc := controllerhost.NewController(cfg, sVice, tb.mClient, cassConfig.NewDummyConfigUpdater())
ch.Start(tc)
tb.Controllers[hostID] = ch
}
Expand Down

0 comments on commit 4764970

Please sign in to comment.