Skip to content

Commit

Permalink
Merge branch 'master' into aanish/visibility/revert
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjdawson2016 authored Oct 30, 2020
2 parents 2b37b3f + e493f3c commit 53dabc4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 48 deletions.
19 changes: 2 additions & 17 deletions common/persistence/cassandra/cassandraMetadataPersistenceV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/uber/cadence/common/persistence/nosql/nosqlplugin"
"github.com/uber/cadence/common/persistence/nosql/nosqlplugin/cassandra"
"github.com/uber/cadence/common/service/config"
"github.com/uber/cadence/common/types/mapper/thrift"
)

const (
Expand All @@ -42,7 +41,6 @@ type (
nosqlDomainManager struct {
nosqlManager
currentClusterName string
serializer p.PayloadSerializer
}
)

Expand All @@ -60,7 +58,6 @@ func newMetadataPersistenceV2(cfg config.Cassandra, currentClusterName string, l
logger: logger,
},
currentClusterName: currentClusterName,
serializer: p.NewPayloadSerializer(),
}, nil
}

Expand Down Expand Up @@ -297,13 +294,6 @@ func (m *nosqlDomainManager) GetMetadata(
func (m *nosqlDomainManager) toNoSQLInternalDomainConfig(
domainConfig *p.InternalDomainConfig,
) (*nosqlplugin.NoSQLInternalDomainConfig, error) {
serializedBadBinaries, err := m.serializer.SerializeBadBinaries(
thrift.FromBadBinaries(&domainConfig.BadBinaries),
common.EncodingTypeThriftRW)
if err != nil {
return nil, err
}

return &nosqlplugin.NoSQLInternalDomainConfig{
Retention: domainConfig.Retention,
EmitMetric: domainConfig.EmitMetric,
Expand All @@ -313,18 +303,13 @@ func (m *nosqlDomainManager) toNoSQLInternalDomainConfig(
HistoryArchivalURI: domainConfig.HistoryArchivalURI,
VisibilityArchivalStatus: domainConfig.VisibilityArchivalStatus,
VisibilityArchivalURI: domainConfig.VisibilityArchivalURI,
BadBinaries: p.NewDataBlob(serializedBadBinaries.Data, serializedBadBinaries.Encoding),
BadBinaries: domainConfig.BadBinaries,
}, nil
}

func (m *nosqlDomainManager) fromNoSQLInternalDomainConfig(
domainConfig *nosqlplugin.NoSQLInternalDomainConfig,
) (*p.InternalDomainConfig, error) {
badBinaries, err := m.serializer.DeserializeBadBinaries(domainConfig.BadBinaries)
if err != nil {
return nil, err
}

return &p.InternalDomainConfig{
Retention: domainConfig.Retention,
EmitMetric: domainConfig.EmitMetric,
Expand All @@ -334,6 +319,6 @@ func (m *nosqlDomainManager) fromNoSQLInternalDomainConfig(
HistoryArchivalURI: domainConfig.HistoryArchivalURI,
VisibilityArchivalStatus: domainConfig.VisibilityArchivalStatus,
VisibilityArchivalURI: domainConfig.VisibilityArchivalURI,
BadBinaries: *thrift.ToBadBinaries(badBinaries),
BadBinaries: domainConfig.BadBinaries,
}, nil
}
17 changes: 15 additions & 2 deletions common/persistence/metadataStore.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ package persistence
import (
"context"

"github.com/uber/cadence/common"

"github.com/uber/cadence/.gen/go/shared"
"github.com/uber/cadence/common/log"
"github.com/uber/cadence/common/types/mapper/thrift"
Expand Down Expand Up @@ -177,29 +179,40 @@ func (m *metadataManagerImpl) toInternalDomainConfig(c *DomainConfig) (InternalD
if c.BadBinaries.Binaries == nil {
c.BadBinaries.Binaries = map[string]*shared.BadBinaryInfo{}
}
badBinaries, err := m.serializer.SerializeBadBinaries(&c.BadBinaries, common.EncodingTypeThriftRW)
if err != nil {
return InternalDomainConfig{}, err
}
return InternalDomainConfig{
Retention: c.Retention,
EmitMetric: c.EmitMetric,
HistoryArchivalStatus: *thrift.ToArchivalStatus(&c.HistoryArchivalStatus),
HistoryArchivalURI: c.HistoryArchivalURI,
VisibilityArchivalStatus: *thrift.ToArchivalStatus(&c.VisibilityArchivalStatus),
VisibilityArchivalURI: c.VisibilityArchivalURI,
BadBinaries: *thrift.ToBadBinaries(&c.BadBinaries),
BadBinaries: badBinaries,
}, nil
}

func (m *metadataManagerImpl) fromInternalDomainConfig(ic *InternalDomainConfig) (DomainConfig, error) {
if ic == nil {
return DomainConfig{}, nil
}
badBinaries, err := m.serializer.DeserializeBadBinaries(ic.BadBinaries)
if err != nil {
return DomainConfig{}, err
}
if badBinaries.Binaries == nil {
badBinaries.Binaries = map[string]*shared.BadBinaryInfo{}
}
return DomainConfig{
Retention: ic.Retention,
EmitMetric: ic.EmitMetric,
HistoryArchivalStatus: *thrift.FromArchivalStatus(&ic.HistoryArchivalStatus),
HistoryArchivalURI: ic.HistoryArchivalURI,
VisibilityArchivalStatus: *thrift.FromArchivalStatus(&ic.VisibilityArchivalStatus),
VisibilityArchivalURI: ic.VisibilityArchivalURI,
BadBinaries: *thrift.FromBadBinaries(&ic.BadBinaries),
BadBinaries: *badBinaries,
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion common/persistence/persistenceInterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ type (
HistoryArchivalURI string
VisibilityArchivalStatus types.ArchivalStatus
VisibilityArchivalURI string
BadBinaries types.BadBinaries
BadBinaries *DataBlob
}

// InternalCreateDomainRequest is used to create the domain
Expand Down
37 changes: 9 additions & 28 deletions common/persistence/sql/sqlMetadataManagerV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,19 @@ import (
"database/sql"
"fmt"

"github.com/uber/cadence/common/persistence/serialization"
"github.com/uber/cadence/common/types"
"github.com/uber/cadence/common/types/mapper/thrift"

workflow "github.com/uber/cadence/.gen/go/shared"
"github.com/uber/cadence/.gen/go/sqlblobs"
"github.com/uber/cadence/common"
"github.com/uber/cadence/common/log"
"github.com/uber/cadence/common/persistence"
"github.com/uber/cadence/common/persistence/serialization"
"github.com/uber/cadence/common/persistence/sql/sqlplugin"
"github.com/uber/cadence/common/types"
)

type sqlMetadataManagerV2 struct {
sqlStore
activeClusterName string
serializer persistence.PayloadSerializer
}

// newMetadataPersistenceV2 creates an instance of sqlMetadataManagerV2
Expand All @@ -56,7 +53,6 @@ func newMetadataPersistenceV2(
logger: logger,
parser: parser,
},
serializer: persistence.NewPayloadSerializer(),
activeClusterName: currentClusterName,
}, nil
}
Expand Down Expand Up @@ -109,15 +105,10 @@ func (m *sqlMetadataManagerV2) CreateDomain(

var badBinaries []byte
var badBinariesEncoding *string

serializedBadBinaries, err := m.serializer.SerializeBadBinaries(
thrift.FromBadBinaries(&request.Config.BadBinaries),
common.EncodingTypeThriftRW)
if err != nil {
return nil, err
if request.Config.BadBinaries != nil {
badBinaries = request.Config.BadBinaries.Data
badBinariesEncoding = common.StringPtr(string(request.Config.BadBinaries.GetEncoding()))
}
badBinaries = serializedBadBinaries.Data
badBinariesEncoding = common.StringPtr(string(serializedBadBinaries.GetEncoding()))

domainInfo := &sqlblobs.DomainInfo{
Status: common.Int32Ptr(int32(request.Info.Status)),
Expand Down Expand Up @@ -240,10 +231,6 @@ func (m *sqlMetadataManagerV2) domainRowToGetDomainResponse(row *sqlplugin.Domai
if domainInfo.BadBinaries != nil {
badBinaries = persistence.NewDataBlob(domainInfo.BadBinaries, common.EncodingType(*domainInfo.BadBinariesEncoding))
}
deserializedBadBinaries, err := m.serializer.DeserializeBadBinaries(badBinaries)
if err != nil {
return nil, err
}

var failoverEndTime *int64
if domainInfo.IsSetFailoverEndTime() {
Expand All @@ -268,7 +255,7 @@ func (m *sqlMetadataManagerV2) domainRowToGetDomainResponse(row *sqlplugin.Domai
HistoryArchivalURI: domainInfo.GetHistoryArchivalURI(),
VisibilityArchivalStatus: types.ArchivalStatus(*domainInfo.VisibilityArchivalStatus),
VisibilityArchivalURI: domainInfo.GetVisibilityArchivalURI(),
BadBinaries: *thrift.ToBadBinaries(deserializedBadBinaries),
BadBinaries: badBinaries,
},
ReplicationConfig: &persistence.DomainReplicationConfig{
ActiveClusterName: persistence.GetOrUseDefaultActiveCluster(m.activeClusterName, domainInfo.GetActiveClusterName()),
Expand Down Expand Up @@ -297,17 +284,11 @@ func (m *sqlMetadataManagerV2) UpdateDomain(

var badBinaries []byte
var badBinariesEncoding *string

serializedBadBinaries, err := m.serializer.SerializeBadBinaries(
thrift.FromBadBinaries(&request.Config.BadBinaries),
common.EncodingTypeThriftRW)
if err != nil {
return err
if request.Config.BadBinaries != nil {
badBinaries = request.Config.BadBinaries.Data
badBinariesEncoding = common.StringPtr(string(request.Config.BadBinaries.GetEncoding()))
}

badBinaries = serializedBadBinaries.Data
badBinariesEncoding = common.StringPtr(string(serializedBadBinaries.GetEncoding()))

var failoverEndTime *int64
if request.FailoverEndTime != nil {
failoverEndTime = request.FailoverEndTime
Expand Down

0 comments on commit 53dabc4

Please sign in to comment.