From 1c25a245444b4f951731b3cb32216f0fc121b425 Mon Sep 17 00:00:00 2001 From: Bowei Xu Date: Fri, 15 Jun 2018 13:42:50 -0700 Subject: [PATCH 1/3] Add EnableGlobalDomain as dynamic config --- cmd/server/server.go | 8 +++++--- common/cluster/metadata.go | 11 +++++++---- common/cluster/metadataTestBase.go | 4 +++- common/service/dynamicconfig/constants.go | 17 ++++++++++++----- hostxdc/Integration_domain_failover_test.go | 3 ++- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/cmd/server/server.go b/cmd/server/server.go index d1549663c77..2580558245e 100644 --- a/cmd/server/server.go +++ b/cmd/server/server.go @@ -105,12 +105,16 @@ func (s *server) startService() common.Daemon { log.Fatalf("error creating ringpop factory: %v", err) } + params.DynamicConfig = dynamicconfig.NewNopClient() + dc := dynamicconfig.NewCollection(params.DynamicConfig, params.Logger) + svcCfg := s.cfg.Services[s.name] params.MetricScope = svcCfg.Metrics.NewScope() params.RPCFactory = svcCfg.RPC.NewFactory(params.Name, params.Logger) params.PProfInitializer = svcCfg.PProf.NewInitializer(params.Logger) + enableGlobalDomain := dc.GetBoolProperty(dynamicconfig.EnableGlobalDomainKey, s.cfg.ClustersInfo.EnableGlobalDomain) params.ClusterMetadata = cluster.NewMetadata( - s.cfg.ClustersInfo.EnableGlobalDomain, + enableGlobalDomain, s.cfg.ClustersInfo.FailoverVersionIncrement, s.cfg.ClustersInfo.MasterClusterName, s.cfg.ClustersInfo.CurrentClusterName, @@ -123,8 +127,6 @@ func (s *server) startService() common.Daemon { params.MessagingClient = nil } - params.DynamicConfig = dynamicconfig.NewNopClient() - var daemon common.Daemon switch s.name { diff --git a/common/cluster/metadata.go b/common/cluster/metadata.go index c181cf61247..08a93225468 100644 --- a/common/cluster/metadata.go +++ b/common/cluster/metadata.go @@ -20,7 +20,10 @@ package cluster -import "fmt" +import ( + "fmt" + "github.com/uber/cadence/common/service/dynamicconfig" +) type ( // Metadata provides information about clusters @@ -45,7 +48,7 @@ type ( metadataImpl struct { // EnableGlobalDomain whether the global domain is enabled, // this attr should be discarded when cross DC is made public - enableGlobalDomain bool + enableGlobalDomain dynamicconfig.BoolPropertyFn // failoverVersionIncrement is the increment of each cluster failover version failoverVersionIncrement int64 // masterClusterName is the name of the master cluster, only the master cluster can register / update domain @@ -61,7 +64,7 @@ type ( ) // NewMetadata create a new instance of Metadata -func NewMetadata(enableGlobalDomain bool, failoverVersionIncrement int64, +func NewMetadata(enableGlobalDomain dynamicconfig.BoolPropertyFn, failoverVersionIncrement int64, masterClusterName string, currentClusterName string, clusterInitialFailoverVersions map[string]int64) Metadata { if len(clusterInitialFailoverVersions) < 0 { @@ -109,7 +112,7 @@ func NewMetadata(enableGlobalDomain bool, failoverVersionIncrement int64, // IsGlobalDomainEnabled whether the global domain is enabled, // this attr should be discarded when cross DC is made public func (metadata *metadataImpl) IsGlobalDomainEnabled() bool { - return metadata.enableGlobalDomain + return metadata.enableGlobalDomain() } // GetNextFailoverVersion return the next failover version based on input diff --git a/common/cluster/metadataTestBase.go b/common/cluster/metadataTestBase.go index 378fbf6178d..ff6392b6618 100644 --- a/common/cluster/metadataTestBase.go +++ b/common/cluster/metadataTestBase.go @@ -20,6 +20,8 @@ package cluster +import "github.com/uber/cadence/common/service/dynamicconfig" + const ( // TestCurrentClusterInitialFailoverVersion is initial failover version for current cluster TestCurrentClusterInitialFailoverVersion = int64(0) @@ -50,7 +52,7 @@ func GetTestClusterMetadata(enableGlobalDomain bool, isMasterCluster bool) Metad masterClusterName = TestAlternativeClusterName } return NewMetadata( - enableGlobalDomain, + dynamicconfig.GetBoolPropertyFn(enableGlobalDomain), TestFailoverVersionIncrement, masterClusterName, TestCurrentClusterName, diff --git a/common/service/dynamicconfig/constants.go b/common/service/dynamicconfig/constants.go index ec0ee882b99..f2605aaa5c4 100644 --- a/common/service/dynamicconfig/constants.go +++ b/common/service/dynamicconfig/constants.go @@ -35,11 +35,15 @@ func (k Key) String() string { var keys = map[Key]string{ unknownKey: "unknownKey", - testGetPropertyKey: "testGetPropertyKey", - testGetIntPropertyKey: "testGetIntPropertyKey", - testGetFloat64PropertyKey: "testGetFloat64PropertyKey", - testGetDurationPropertyKey: "testGetDurationPropertyKey", - testGetBoolPropertyKey: "testGetBoolPropertyKey", + testGetPropertyKey: "testGetPropertyKey", + testGetIntPropertyKey: "testGetIntPropertyKey", + testGetFloat64PropertyKey: "testGetFloat64PropertyKey", + testGetDurationPropertyKey: "testGetDurationPropertyKey", + testGetBoolPropertyKey: "testGetBoolPropertyKey", + testGetIntPropertyFilteredByDomainKey: "testGetIntPropertyFilteredByDomainKey", + testGetDurationPropertyFilteredByDomainKey: "testGetDurationPropertyFilteredByDomainKey", + + EnableGlobalDomainKey: "enableGlobalDomainKey", // frontend settings FrontendVisibilityMaxPageSize: "frontend.visibilityMaxPageSize", @@ -108,6 +112,9 @@ const ( testGetIntPropertyFilteredByDomainKey testGetDurationPropertyFilteredByDomainKey + // EnableGlobalDomainKey is key for enable global domain + EnableGlobalDomainKey + // key for frontend // FrontendVisibilityMaxPageSize is default max size for ListWorkflowExecutions in one page diff --git a/hostxdc/Integration_domain_failover_test.go b/hostxdc/Integration_domain_failover_test.go index 1ae0d341758..6594d586b82 100644 --- a/hostxdc/Integration_domain_failover_test.go +++ b/hostxdc/Integration_domain_failover_test.go @@ -43,6 +43,7 @@ import ( "github.com/uber/cadence/common/messaging" "github.com/uber/cadence/common/persistence" "github.com/uber/cadence/common/service/config" + "github.com/uber/cadence/common/service/dynamicconfig" "github.com/uber/cadence/host" "go.uber.org/zap" ) @@ -116,7 +117,7 @@ func (s *testCluster) setupCluster(no int) { options.SchemaDir = ".." clusterInfo := clustersInfo[no] metadata := cluster.NewMetadata( - clusterInfo.EnableGlobalDomain, + dynamicconfig.GetBoolPropertyFn(clusterInfo.EnableGlobalDomain), clusterInfo.FailoverVersionIncrement, clusterInfo.MasterClusterName, clusterInfo.CurrentClusterName, From 55363276af3b4f97bdeb635e5636dcf2b08c28f6 Mon Sep 17 00:00:00 2001 From: Bowei Xu Date: Tue, 19 Jun 2018 13:45:52 -0700 Subject: [PATCH 2/3] Address comments --- common/service/dynamicconfig/constants.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/common/service/dynamicconfig/constants.go b/common/service/dynamicconfig/constants.go index f2605aaa5c4..a7c73d9ca55 100644 --- a/common/service/dynamicconfig/constants.go +++ b/common/service/dynamicconfig/constants.go @@ -35,6 +35,7 @@ func (k Key) String() string { var keys = map[Key]string{ unknownKey: "unknownKey", + // tests keys testGetPropertyKey: "testGetPropertyKey", testGetIntPropertyKey: "testGetIntPropertyKey", testGetFloat64PropertyKey: "testGetFloat64PropertyKey", @@ -43,7 +44,8 @@ var keys = map[Key]string{ testGetIntPropertyFilteredByDomainKey: "testGetIntPropertyFilteredByDomainKey", testGetDurationPropertyFilteredByDomainKey: "testGetDurationPropertyFilteredByDomainKey", - EnableGlobalDomainKey: "enableGlobalDomainKey", + // system settings + EnableGlobalDomain: "system.enableGlobalDomain", // frontend settings FrontendVisibilityMaxPageSize: "frontend.visibilityMaxPageSize", @@ -112,8 +114,8 @@ const ( testGetIntPropertyFilteredByDomainKey testGetDurationPropertyFilteredByDomainKey - // EnableGlobalDomainKey is key for enable global domain - EnableGlobalDomainKey + // EnableGlobalDomain is key for enable global domain + EnableGlobalDomain // key for frontend From ec62ead8bd35a61f4ad607963ad3150e8294e526 Mon Sep 17 00:00:00 2001 From: Bowei Xu Date: Tue, 19 Jun 2018 14:00:45 -0700 Subject: [PATCH 3/3] Address comments --- cmd/server/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/server/server.go b/cmd/server/server.go index 2580558245e..0f04e78229c 100644 --- a/cmd/server/server.go +++ b/cmd/server/server.go @@ -112,7 +112,7 @@ func (s *server) startService() common.Daemon { params.MetricScope = svcCfg.Metrics.NewScope() params.RPCFactory = svcCfg.RPC.NewFactory(params.Name, params.Logger) params.PProfInitializer = svcCfg.PProf.NewInitializer(params.Logger) - enableGlobalDomain := dc.GetBoolProperty(dynamicconfig.EnableGlobalDomainKey, s.cfg.ClustersInfo.EnableGlobalDomain) + enableGlobalDomain := dc.GetBoolProperty(dynamicconfig.EnableGlobalDomain, s.cfg.ClustersInfo.EnableGlobalDomain) params.ClusterMetadata = cluster.NewMetadata( enableGlobalDomain, s.cfg.ClustersInfo.FailoverVersionIncrement,