Skip to content

Commit

Permalink
Archival: Update domain config (cadence-workflow#2210)
Browse files Browse the repository at this point in the history
  • Loading branch information
yycptt authored Jul 15, 2019
1 parent a92e5e3 commit 4f19f6b
Show file tree
Hide file tree
Showing 47 changed files with 2,492 additions and 942 deletions.
420 changes: 298 additions & 122 deletions .gen/go/shared/shared.go

Large diffs are not rendered by default.

184 changes: 180 additions & 4 deletions .gen/go/sqlblobs/sqlblobs.go

Large diffs are not rendered by default.

152 changes: 152 additions & 0 deletions common/archiver/interface_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions common/archiver/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ func NewArchiverProvider(
return &archiverProvider{
historyArchiverConfigs: historyArchiverConfigs,
visibilityArchiverConfigs: visibilityArchiverConfigs,
historyContainers: make(map[string]*archiver.HistoryBootstrapContainer),
visibilityContainers: make(map[string]*archiver.VisibilityBootstrapContainer),
historyArchivers: make(map[string]archiver.HistoryArchiver),
visibilityArchivers: make(map[string]archiver.VisibilityArchiver),
}
}

Expand Down
12 changes: 7 additions & 5 deletions common/cache/domainCache.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,11 +609,13 @@ func (entry *DomainCacheEntry) duplicate() *DomainCacheEntry {
result.info.Data[k] = v
}
result.config = &persistence.DomainConfig{
Retention: entry.config.Retention,
EmitMetric: entry.config.EmitMetric,
ArchivalBucket: entry.config.ArchivalBucket,
ArchivalStatus: entry.config.ArchivalStatus,
BadBinaries: copyResetBinary(entry.config.BadBinaries),
Retention: entry.config.Retention,
EmitMetric: entry.config.EmitMetric,
HistoryArchivalStatus: entry.config.HistoryArchivalStatus,
HistoryArchivalURI: entry.config.HistoryArchivalURI,
VisibilityArchivalStatus: entry.config.VisibilityArchivalStatus,
VisibilityArchivalURI: entry.config.VisibilityArchivalURI,
BadBinaries: copyResetBinary(entry.config.BadBinaries),
}
result.replicationConfig = &persistence.DomainReplicationConfig{
ActiveClusterName: entry.replicationConfig.ActiveClusterName,
Expand Down
6 changes: 2 additions & 4 deletions common/cache/domainCache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ import (
"testing"
"time"

"github.com/uber/cadence/common"

"github.com/uber/cadence/.gen/go/shared"

"github.com/pborman/uuid"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/uber-go/tally"
"github.com/uber/cadence/.gen/go/shared"
"github.com/uber/cadence/common"
"github.com/uber/cadence/common/cluster"
"github.com/uber/cadence/common/log"
"github.com/uber/cadence/common/log/loggerimpl"
Expand Down
39 changes: 12 additions & 27 deletions common/cluster/archival_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,19 @@ package cluster
import (
"fmt"
"strings"

"github.com/uber/cadence/.gen/go/shared"
)

type (
// ArchivalStatus represents the archival status of the cluster
ArchivalStatus int

// DomainArchivalStatus represents the archival status of a domain
DomainArchivalStatus int

// ArchivalConfig is an immutable representation of the current archival configuration of the cluster
ArchivalConfig struct {
ClusterStatus ArchivalStatus
EnableReadFromArchival bool
DomainDefaultStatus DomainArchivalStatus
DomainDefaultStatus shared.ArchivalStatus
DomainDefaultURI string
}
)
Expand All @@ -48,18 +47,13 @@ const (
ArchivalPaused
// ArchivalEnabled means this cluster is currently archiving
ArchivalEnabled

// DomainArchivalDisabled means a domain is not configured to handle archival
DomainArchivalDisabled DomainArchivalStatus = iota
// DomainArchivalEnabled means a domain is currently archiving
DomainArchivalEnabled
)

// NewArchivalConfig constructs a new valid ArchivalConfig
func NewArchivalConfig(
clusterStatus ArchivalStatus,
enableReadFromArchival bool,
domainDefaultStatus DomainArchivalStatus,
domainDefaultStatus shared.ArchivalStatus,
domainDefaultURI string,
) *ArchivalConfig {
ac := &ArchivalConfig{
Expand All @@ -68,8 +62,8 @@ func NewArchivalConfig(
DomainDefaultStatus: domainDefaultStatus,
DomainDefaultURI: domainDefaultURI,
}
if !ac.isDomainDefaultValid() {
return newDisabledArchivalConfig()
if !ac.isValid() {
panic("invalid cluster level archival configuration")
}
return ac
}
Expand All @@ -79,21 +73,12 @@ func (a *ArchivalConfig) ClusterConfiguredForArchival() bool {
return a.ClusterStatus == ArchivalEnabled
}

func (a *ArchivalConfig) isDomainDefaultValid() bool {
func (a *ArchivalConfig) isValid() bool {
URISet := len(a.DomainDefaultURI) != 0
disabled := a.DomainDefaultStatus == DomainArchivalDisabled
disabled := a.ClusterStatus == ArchivalDisabled
return (!URISet && disabled) || (URISet && !disabled)
}

func newDisabledArchivalConfig() *ArchivalConfig {
return &ArchivalConfig{
ClusterStatus: ArchivalDisabled,
EnableReadFromArchival: false,
DomainDefaultStatus: DomainArchivalDisabled,
DomainDefaultURI: "",
}
}

func getClusterArchivalStatus(str string) (ArchivalStatus, error) {
str = strings.TrimSpace(strings.ToLower(str))
switch str {
Expand All @@ -107,13 +92,13 @@ func getClusterArchivalStatus(str string) (ArchivalStatus, error) {
return ArchivalDisabled, fmt.Errorf("invalid archival status of %v for cluster, valid status are: {\"\", \"disabled\", \"paused\", \"enabled\"}", str)
}

func getDomainArchivalStatus(str string) (DomainArchivalStatus, error) {
func getDomainArchivalStatus(str string) (shared.ArchivalStatus, error) {
str = strings.TrimSpace(strings.ToLower(str))
switch str {
case "", "disabled":
return DomainArchivalDisabled, nil
return shared.ArchivalStatusDisabled, nil
case "enabled":
return DomainArchivalEnabled, nil
return shared.ArchivalStatusEnabled, nil
}
return DomainArchivalDisabled, fmt.Errorf("invalid archival status of %v for domain, valid status are: {\"\", \"disabled\", \"enabled\"}", str)
return shared.ArchivalStatusDisabled, fmt.Errorf("invalid archival status of %v for domain, valid status are: {\"\", \"disabled\", \"enabled\"}", str)
}
15 changes: 13 additions & 2 deletions common/cluster/metadataTestBase.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func GetTestClusterMetadata(enableGlobalDomain bool, isMasterCluster bool, enabl
}

archivalClusterConfig := config.Archival{}
archivalDomainDefaults := config.ArchivalDomainDefaults{}
if enableArchival {
archivalClusterConfig = config.Archival{
History: config.HistoryArchival{
Expand All @@ -95,6 +96,16 @@ func GetTestClusterMetadata(enableGlobalDomain bool, isMasterCluster bool, enabl
EnableReadFromArchival: true,
},
}
archivalDomainDefaults = config.ArchivalDomainDefaults{
History: config.HistoryArchivalDomainDefaults{
DefaultStatus: "enabled",
DefaultURI: "testScheme://test/archive/path",
},
Visibility: config.VisibilityArchivalDomainDefaults{
DefaultStatus: "enabled",
DefaultURI: "testScheme://test/archive/path",
},
}
}
if enableGlobalDomain {
return NewMetadata(
Expand All @@ -106,7 +117,7 @@ func GetTestClusterMetadata(enableGlobalDomain bool, isMasterCluster bool, enabl
TestCurrentClusterName,
TestAllClusterInfo,
archivalClusterConfig,
config.ArchivalDomainDefaults{},
archivalDomainDefaults,
)
}

Expand All @@ -119,6 +130,6 @@ func GetTestClusterMetadata(enableGlobalDomain bool, isMasterCluster bool, enabl
TestCurrentClusterName,
TestSingleDCClusterInfo,
archivalClusterConfig,
config.ArchivalDomainDefaults{},
archivalDomainDefaults,
)
}
Loading

0 comments on commit 4f19f6b

Please sign in to comment.