Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EnableGlobalDomain as dynamic config #858

Merged
merged 4 commits into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.EnableGlobalDomain, 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,
Expand All @@ -123,8 +127,6 @@ func (s *server) startService() common.Daemon {
params.MessagingClient = nil
}

params.DynamicConfig = dynamicconfig.NewNopClient()

var daemon common.Daemon

switch s.name {
Expand Down
11 changes: 7 additions & 4 deletions common/cluster/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@

package cluster

import "fmt"
import (
"fmt"
"github.com/uber/cadence/common/service/dynamicconfig"
)

type (
// Metadata provides information about clusters
Expand All @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion common/cluster/metadataTestBase.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -50,7 +52,7 @@ func GetTestClusterMetadata(enableGlobalDomain bool, isMasterCluster bool) Metad
masterClusterName = TestAlternativeClusterName
}
return NewMetadata(
enableGlobalDomain,
dynamicconfig.GetBoolPropertyFn(enableGlobalDomain),
TestFailoverVersionIncrement,
masterClusterName,
TestCurrentClusterName,
Expand Down
19 changes: 14 additions & 5 deletions common/service/dynamicconfig/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,17 @@ func (k Key) String() string {
var keys = map[Key]string{
unknownKey: "unknownKey",

testGetPropertyKey: "testGetPropertyKey",
testGetIntPropertyKey: "testGetIntPropertyKey",
testGetFloat64PropertyKey: "testGetFloat64PropertyKey",
testGetDurationPropertyKey: "testGetDurationPropertyKey",
testGetBoolPropertyKey: "testGetBoolPropertyKey",
// tests keys
testGetPropertyKey: "testGetPropertyKey",
testGetIntPropertyKey: "testGetIntPropertyKey",
testGetFloat64PropertyKey: "testGetFloat64PropertyKey",
testGetDurationPropertyKey: "testGetDurationPropertyKey",
testGetBoolPropertyKey: "testGetBoolPropertyKey",
testGetIntPropertyFilteredByDomainKey: "testGetIntPropertyFilteredByDomainKey",
testGetDurationPropertyFilteredByDomainKey: "testGetDurationPropertyFilteredByDomainKey",

// system settings
EnableGlobalDomain: "system.enableGlobalDomain",

// frontend settings
FrontendVisibilityMaxPageSize: "frontend.visibilityMaxPageSize",
Expand Down Expand Up @@ -108,6 +114,9 @@ const (
testGetIntPropertyFilteredByDomainKey
testGetDurationPropertyFilteredByDomainKey

// EnableGlobalDomain is key for enable global domain
EnableGlobalDomain

// key for frontend

// FrontendVisibilityMaxPageSize is default max size for ListWorkflowExecutions in one page
Expand Down
3 changes: 2 additions & 1 deletion hostxdc/Integration_domain_failover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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,
Expand Down