From 0b058c0ea920eef4af07d11da1b4a3ab47b0958a Mon Sep 17 00:00:00 2001 From: Quanzheng Long Date: Sun, 6 Jun 2021 09:41:58 -0700 Subject: [PATCH] Rename MetadataManager to DomainManager --- common/cache/domainCache.go | 12 +++---- common/domain/failover_watcher.go | 24 ++++++------- common/domain/handler.go | 26 +++++++------- .../handler_GlobalDomainDisabled_test.go | 6 ++-- ..._GlobalDomainEnabled_MasterCluster_test.go | 8 ++--- ...obalDomainEnabled_NotMasterCluster_test.go | 18 +++++----- common/domain/handler_test.go | 12 +++---- common/domain/replicationTaskExecutor.go | 26 +++++++------- common/domain/replicationTaskExecutor_test.go | 28 +++++++-------- common/persistence/client/bean.go | 28 +++++++-------- common/persistence/client/bean_mock.go | 16 ++++----- common/persistence/client/factory.go | 16 ++++----- common/persistence/dataInterfaces.go | 4 +-- .../{metadataStore.go => domainManager.go} | 34 +++++++++---------- .../metadataPersistenceV2Test.go | 16 ++++----- .../persistence-tests/persistenceTestBase.go | 6 ++-- .../persistenceErrorInjectionClients.go | 12 +++---- common/persistence/persistenceInterface.go | 2 +- .../persistence/persistenceMetricClients.go | 12 +++---- .../persistenceRateLimitedClients.go | 12 +++---- common/resource/resource.go | 2 +- common/resource/resourceImpl.go | 6 ++-- common/resource/resourceTest.go | 2 +- host/integrationbase.go | 2 +- host/onebox.go | 12 +++---- host/testcluster.go | 4 +-- service/frontend/adminHandler.go | 4 +-- service/frontend/workflowHandler.go | 2 +- service/history/failover/coordinator.go | 8 ++--- service/history/handler.go | 2 +- service/worker/service.go | 6 ++-- tools/cli/domainUtils.go | 12 +++---- 32 files changed, 190 insertions(+), 190 deletions(-) rename common/persistence/{metadataStore.go => domainManager.go} (87%) diff --git a/common/cache/domainCache.go b/common/cache/domainCache.go index f045e3c8383..f2e8a487da4 100644 --- a/common/cache/domainCache.go +++ b/common/cache/domainCache.go @@ -106,7 +106,7 @@ type ( shutdownChan chan struct{} cacheNameToID *atomic.Value cacheByID *atomic.Value - metadataMgr persistence.MetadataManager + domainManager persistence.DomainManager clusterMetadata cluster.Metadata timeSource clock.TimeSource metricsClient metrics.Client @@ -145,7 +145,7 @@ type ( // NewDomainCache creates a new instance of cache for holding onto domain information to reduce the load on persistence func NewDomainCache( - metadataMgr persistence.MetadataManager, + domainManager persistence.DomainManager, clusterMetadata cluster.Metadata, metricsClient metrics.Client, logger log.Logger, @@ -156,7 +156,7 @@ func NewDomainCache( shutdownChan: make(chan struct{}), cacheNameToID: &atomic.Value{}, cacheByID: &atomic.Value{}, - metadataMgr: metadataMgr, + domainManager: domainManager, clusterMetadata: clusterMetadata, timeSource: clock.NewRealTimeSource(), metricsClient: metricsClient, @@ -450,7 +450,7 @@ func (c *domainCache) refreshDomainsLocked() error { // this can guarantee that domains in the cache are not updated more than metadata record ctx, cancel := context.WithTimeout(context.Background(), domainCachePersistenceTimeout) defer cancel() - metadata, err := c.metadataMgr.GetMetadata(ctx) + metadata, err := c.domainManager.GetMetadata(ctx) if err != nil { return err } @@ -463,7 +463,7 @@ func (c *domainCache) refreshDomainsLocked() error { for continuePage { ctx, cancel := context.WithTimeout(context.Background(), domainCachePersistenceTimeout) request.NextPageToken = token - response, err := c.metadataMgr.ListDomains(ctx, request) + response, err := c.domainManager.ListDomains(ctx, request) cancel() if err != nil { return err @@ -541,7 +541,7 @@ func (c *domainCache) checkDomainExists( ctx, cancel := context.WithTimeout(context.Background(), domainCachePersistenceTimeout) defer cancel() - _, err := c.metadataMgr.GetDomain(ctx, &persistence.GetDomainRequest{Name: name, ID: id}) + _, err := c.domainManager.GetDomain(ctx, &persistence.GetDomainRequest{Name: name, ID: id}) return err } diff --git a/common/domain/failover_watcher.go b/common/domain/failover_watcher.go index 012c14d7a29..06bd6824958 100644 --- a/common/domain/failover_watcher.go +++ b/common/domain/failover_watcher.go @@ -57,11 +57,11 @@ type ( refreshJitter dynamicconfig.FloatPropertyFn retryPolicy backoff.RetryPolicy - metadataMgr persistence.MetadataManager - domainCache cache.DomainCache - timeSource clock.TimeSource - metrics metrics.Client - logger log.Logger + domainManager persistence.DomainManager + domainCache cache.DomainCache + timeSource clock.TimeSource + metrics metrics.Client + logger log.Logger } ) @@ -70,7 +70,7 @@ var _ FailoverWatcher = (*failoverWatcherImpl)(nil) // NewFailoverWatcher initializes domain failover processor func NewFailoverWatcher( domainCache cache.DomainCache, - metadataMgr persistence.MetadataManager, + domainManager persistence.DomainManager, timeSource clock.TimeSource, refreshInterval dynamicconfig.DurationPropertyFn, refreshJitter dynamicconfig.FloatPropertyFn, @@ -90,7 +90,7 @@ func NewFailoverWatcher( refreshJitter: refreshJitter, retryPolicy: retryPolicy, domainCache: domainCache, - metadataMgr: metadataMgr, + domainManager: domainManager, timeSource: timeSource, metrics: metrics, logger: logger, @@ -157,7 +157,7 @@ func (p *failoverWatcherImpl) handleFailoverTimeout( domainID := domain.GetInfo().ID // force failover the domain without setting the failover timeout if err := CleanPendingActiveState( - p.metadataMgr, + p.domainManager, domainID, domain.GetFailoverVersion(), p.retryPolicy, @@ -170,7 +170,7 @@ func (p *failoverWatcherImpl) handleFailoverTimeout( // CleanPendingActiveState removes the pending active state from the domain func CleanPendingActiveState( - metadataMgr persistence.MetadataManager, + domainManager persistence.DomainManager, domainID string, failoverVersion int64, policy backoff.RetryPolicy, @@ -180,13 +180,13 @@ func CleanPendingActiveState( // this version can be regarded as the lock on the v2 domain table // and since we do not know which table will return the domain afterwards // this call has to be made - metadata, err := metadataMgr.GetMetadata(context.Background()) + metadata, err := domainManager.GetMetadata(context.Background()) if err != nil { return err } notificationVersion := metadata.NotificationVersion - getResponse, err := metadataMgr.GetDomain(context.Background(), &persistence.GetDomainRequest{ID: domainID}) + getResponse, err := domainManager.GetDomain(context.Background(), &persistence.GetDomainRequest{ID: domainID}) if err != nil { return err } @@ -207,7 +207,7 @@ func CleanPendingActiveState( NotificationVersion: notificationVersion, } op := func() error { - return metadataMgr.UpdateDomain(context.Background(), updateReq) + return domainManager.UpdateDomain(context.Background(), updateReq) } if err := backoff.Retry( op, diff --git a/common/domain/handler.go b/common/domain/handler.go index 92b4ec13860..0b8d1282bfb 100644 --- a/common/domain/handler.go +++ b/common/domain/handler.go @@ -72,7 +72,7 @@ type ( // handlerImpl is the domain operation handler implementation handlerImpl struct { - metadataMgr persistence.MetadataManager + domainManager persistence.DomainManager clusterMetadata cluster.Metadata domainReplicator Replicator domainAttrValidator *AttrValidatorImpl @@ -99,7 +99,7 @@ var _ Handler = (*handlerImpl)(nil) func NewHandler( config Config, logger log.Logger, - metadataMgr persistence.MetadataManager, + domainManager persistence.DomainManager, clusterMetadata cluster.Metadata, domainReplicator Replicator, archivalMetadata archiver.ArchivalMetadata, @@ -108,7 +108,7 @@ func NewHandler( ) Handler { return &handlerImpl{ logger: logger, - metadataMgr: metadataMgr, + domainManager: domainManager, clusterMetadata: clusterMetadata, domainReplicator: domainReplicator, domainAttrValidator: newAttrValidator(clusterMetadata, int32(config.MinRetentionDays())), @@ -137,7 +137,7 @@ func (d *handlerImpl) RegisterDomain( } // first check if the name is already registered as the local domain - _, err := d.metadataMgr.GetDomain(ctx, &persistence.GetDomainRequest{Name: registerRequest.GetName()}) + _, err := d.domainManager.GetDomain(ctx, &persistence.GetDomainRequest{Name: registerRequest.GetName()}) switch err.(type) { case nil: // domain already exists, cannot proceed @@ -256,7 +256,7 @@ func (d *handlerImpl) RegisterDomain( LastUpdatedTime: d.timeSource.Now().UnixNano(), } - domainResponse, err := d.metadataMgr.CreateDomain(ctx, domainRequest) + domainResponse, err := d.domainManager.CreateDomain(ctx, domainRequest) if err != nil { return err } @@ -297,7 +297,7 @@ func (d *handlerImpl) ListDomains( pageSize = int(listRequest.GetPageSize()) } - resp, err := d.metadataMgr.ListDomains(ctx, &persistence.ListDomainsRequest{ + resp, err := d.domainManager.ListDomains(ctx, &persistence.ListDomainsRequest{ PageSize: pageSize, NextPageToken: listRequest.NextPageToken, }) @@ -335,7 +335,7 @@ func (d *handlerImpl) DescribeDomain( Name: describeRequest.GetName(), ID: describeRequest.GetUUID(), } - resp, err := d.metadataMgr.GetDomain(ctx, req) + resp, err := d.domainManager.GetDomain(ctx, req) if err != nil { return nil, err } @@ -358,12 +358,12 @@ func (d *handlerImpl) UpdateDomain( // this version can be regarded as the lock on the v2 domain table // and since we do not know which table will return the domain afterwards // this call has to be made - metadata, err := d.metadataMgr.GetMetadata(ctx) + metadata, err := d.domainManager.GetMetadata(ctx) if err != nil { return nil, err } notificationVersion := metadata.NotificationVersion - getResponse, err := d.metadataMgr.GetDomain(ctx, &persistence.GetDomainRequest{Name: updateRequest.GetName()}) + getResponse, err := d.domainManager.GetDomain(ctx, &persistence.GetDomainRequest{Name: updateRequest.GetName()}) if err != nil { return nil, err } @@ -534,7 +534,7 @@ func (d *handlerImpl) UpdateDomain( LastUpdatedTime: lastUpdatedTime.UnixNano(), NotificationVersion: notificationVersion, } - err = d.metadataMgr.UpdateDomain(ctx, updateReq) + err = d.domainManager.UpdateDomain(ctx, updateReq) if err != nil { return nil, err } @@ -579,12 +579,12 @@ func (d *handlerImpl) DeprecateDomain( // this version can be regarded as the lock on the v2 domain table // and since we do not know which table will return the domain afterwards // this call has to be made - metadata, err := d.metadataMgr.GetMetadata(ctx) + metadata, err := d.domainManager.GetMetadata(ctx) if err != nil { return err } notificationVersion := metadata.NotificationVersion - getResponse, err := d.metadataMgr.GetDomain(ctx, &persistence.GetDomainRequest{Name: deprecateRequest.GetName()}) + getResponse, err := d.domainManager.GetDomain(ctx, &persistence.GetDomainRequest{Name: deprecateRequest.GetName()}) if err != nil { return err } @@ -608,7 +608,7 @@ func (d *handlerImpl) DeprecateDomain( LastUpdatedTime: d.timeSource.Now().UnixNano(), NotificationVersion: notificationVersion, } - err = d.metadataMgr.UpdateDomain(ctx, updateReq) + err = d.domainManager.UpdateDomain(ctx, updateReq) if err != nil { return err } diff --git a/common/domain/handler_GlobalDomainDisabled_test.go b/common/domain/handler_GlobalDomainDisabled_test.go index 60ca1f200e2..a1c506acfd5 100644 --- a/common/domain/handler_GlobalDomainDisabled_test.go +++ b/common/domain/handler_GlobalDomainDisabled_test.go @@ -52,7 +52,7 @@ type ( minRetentionDays int maxBadBinaryCount int - metadataMgr persistence.MetadataManager + domainManager persistence.DomainManager mockProducer *mocks.KafkaProducer mockDomainReplicator Replicator archivalMetadata archiver.ArchivalMetadata @@ -87,7 +87,7 @@ func (s *domainHandlerGlobalDomainDisabledSuite) SetupTest() { dcCollection := dc.NewCollection(dc.NewNopClient(), logger) s.minRetentionDays = 1 s.maxBadBinaryCount = 10 - s.metadataMgr = s.TestBase.MetadataManager + s.domainManager = s.TestBase.DomainManager s.mockProducer = &mocks.KafkaProducer{} s.mockDomainReplicator = NewDomainReplicator(s.mockProducer, logger) s.archivalMetadata = archiver.NewArchivalMetadata( @@ -107,7 +107,7 @@ func (s *domainHandlerGlobalDomainDisabledSuite) SetupTest() { s.handler = NewHandler( domainConfig, logger, - s.metadataMgr, + s.domainManager, s.ClusterMetadata, s.mockDomainReplicator, s.archivalMetadata, diff --git a/common/domain/handler_GlobalDomainEnabled_MasterCluster_test.go b/common/domain/handler_GlobalDomainEnabled_MasterCluster_test.go index 91927d38954..dc4462143c2 100644 --- a/common/domain/handler_GlobalDomainEnabled_MasterCluster_test.go +++ b/common/domain/handler_GlobalDomainEnabled_MasterCluster_test.go @@ -53,7 +53,7 @@ type ( minRetentionDays int maxBadBinaryCount int - metadataMgr persistence.MetadataManager + domainManager persistence.DomainManager mockProducer *mocks.KafkaProducer mockDomainReplicator Replicator archivalMetadata archiver.ArchivalMetadata @@ -88,7 +88,7 @@ func (s *domainHandlerGlobalDomainEnabledPrimaryClusterSuite) SetupTest() { dcCollection := dc.NewCollection(dc.NewNopClient(), logger) s.minRetentionDays = 1 s.maxBadBinaryCount = 10 - s.metadataMgr = s.TestBase.MetadataManager + s.domainManager = s.TestBase.DomainManager s.mockProducer = &mocks.KafkaProducer{} s.mockDomainReplicator = NewDomainReplicator(s.mockProducer, logger) s.archivalMetadata = archiver.NewArchivalMetadata( @@ -108,7 +108,7 @@ func (s *domainHandlerGlobalDomainEnabledPrimaryClusterSuite) SetupTest() { s.handler = NewHandler( domainConfig, logger, - s.metadataMgr, + s.domainManager, s.ClusterMetadata, s.mockDomainReplicator, s.archivalMetadata, @@ -870,7 +870,7 @@ func (s *domainHandlerGlobalDomainEnabledPrimaryClusterSuite) TestUpdateDomain_C s.handler = NewHandler( domainConfig, loggerimpl.NewNopLogger(), - s.metadataMgr, + s.domainManager, s.ClusterMetadata, s.mockDomainReplicator, s.archivalMetadata, diff --git a/common/domain/handler_GlobalDomainEnabled_NotMasterCluster_test.go b/common/domain/handler_GlobalDomainEnabled_NotMasterCluster_test.go index cba5e80c5d1..65b251fa9b2 100644 --- a/common/domain/handler_GlobalDomainEnabled_NotMasterCluster_test.go +++ b/common/domain/handler_GlobalDomainEnabled_NotMasterCluster_test.go @@ -53,7 +53,7 @@ type ( minRetentionDays int maxBadBinaryCount int - metadataMgr persistence.MetadataManager + domainManager persistence.DomainManager mockProducer *mocks.KafkaProducer mockDomainReplicator Replicator archivalMetadata archiver.ArchivalMetadata @@ -88,7 +88,7 @@ func (s *domainHandlerGlobalDomainEnabledNotPrimaryClusterSuite) SetupTest() { dcCollection := dc.NewCollection(dc.NewNopClient(), logger) s.minRetentionDays = 1 s.maxBadBinaryCount = 10 - s.metadataMgr = s.TestBase.MetadataManager + s.domainManager = s.TestBase.DomainManager s.mockProducer = &mocks.KafkaProducer{} s.mockDomainReplicator = NewDomainReplicator(s.mockProducer, logger) s.archivalMetadata = archiver.NewArchivalMetadata( @@ -108,7 +108,7 @@ func (s *domainHandlerGlobalDomainEnabledNotPrimaryClusterSuite) SetupTest() { s.handler = NewHandler( domainConfig, logger, - s.metadataMgr, + s.domainManager, s.ClusterMetadata, s.mockDomainReplicator, s.archivalMetadata, @@ -514,7 +514,7 @@ func (s *domainHandlerGlobalDomainEnabledNotPrimaryClusterSuite) TestUpdateGetDo data := map[string]string{"some random key": "some random value"} isGlobalDomain := true - _, err := s.MetadataManager.CreateDomain(context.Background(), &persistence.CreateDomainRequest{ + _, err := s.DomainManager.CreateDomain(context.Background(), &persistence.CreateDomainRequest{ Info: &persistence.DomainInfo{ ID: uuid.New(), Name: domainName, @@ -574,7 +574,7 @@ func (s *domainHandlerGlobalDomainEnabledNotPrimaryClusterSuite) TestUpdateGetDo data := map[string]string{"some random key": "some random value"} isGlobalDomain := true - _, err := s.MetadataManager.CreateDomain(context.Background(), &persistence.CreateDomainRequest{ + _, err := s.DomainManager.CreateDomain(context.Background(), &persistence.CreateDomainRequest{ Info: &persistence.DomainInfo{ ID: uuid.New(), Name: domainName, @@ -647,7 +647,7 @@ func (s *domainHandlerGlobalDomainEnabledNotPrimaryClusterSuite) TestUpdateGetDo data := map[string]string{"some random key": "some random value"} isGlobalDomain := true - _, err := s.MetadataManager.CreateDomain(context.Background(), &persistence.CreateDomainRequest{ + _, err := s.DomainManager.CreateDomain(context.Background(), &persistence.CreateDomainRequest{ Info: &persistence.DomainInfo{ ID: uuid.New(), Name: domainName, @@ -753,10 +753,10 @@ func (s *domainHandlerGlobalDomainEnabledNotPrimaryClusterSuite) setupLocalDomai } func (s *domainHandlerGlobalDomainEnabledNotPrimaryClusterSuite) setupGlobalDomainWithMetadataManager(domainName string) *types.DescribeDomainResponse { - return setupGlobalDomainWithMetadataManager(s.Suite, s.handler, s.ClusterMetadata, s.MetadataManager, domainName) + return setupGlobalDomainWithMetadataManager(s.Suite, s.handler, s.ClusterMetadata, s.DomainManager, domainName) } -func setupGlobalDomainWithMetadataManager(s suite.Suite, handler *handlerImpl, clusterMetadata cluster.Metadata, metadataManager persistence.MetadataManager, domainName string) *types.DescribeDomainResponse { +func setupGlobalDomainWithMetadataManager(s suite.Suite, handler *handlerImpl, clusterMetadata cluster.Metadata, domainManager persistence.DomainManager, domainName string) *types.DescribeDomainResponse { description := "some random description" email := "some random email" retention := int32(7) @@ -776,7 +776,7 @@ func setupGlobalDomainWithMetadataManager(s suite.Suite, handler *handlerImpl, c data := map[string]string{"some random key": "some random value"} isGlobalDomain := true - _, err := metadataManager.CreateDomain(context.Background(), &persistence.CreateDomainRequest{ + _, err := domainManager.CreateDomain(context.Background(), &persistence.CreateDomainRequest{ Info: &persistence.DomainInfo{ ID: uuid.New(), Name: domainName, diff --git a/common/domain/handler_test.go b/common/domain/handler_test.go index f9368e83625..00a6eddc20e 100644 --- a/common/domain/handler_test.go +++ b/common/domain/handler_test.go @@ -54,7 +54,7 @@ type ( minRetentionDays int maxBadBinaryCount int - metadataMgr persistence.MetadataManager + domainManager persistence.DomainManager mockProducer *mocks.KafkaProducer mockDomainReplicator Replicator archivalMetadata archiver.ArchivalMetadata @@ -91,7 +91,7 @@ func (s *domainHandlerCommonSuite) SetupTest() { dcCollection := dc.NewCollection(dc.NewNopClient(), logger) s.minRetentionDays = 1 s.maxBadBinaryCount = 10 - s.metadataMgr = s.TestBase.MetadataManager + s.domainManager = s.TestBase.DomainManager s.mockProducer = &mocks.KafkaProducer{} s.mockDomainReplicator = NewDomainReplicator(s.mockProducer, logger) s.archivalMetadata = archiver.NewArchivalMetadata( @@ -111,7 +111,7 @@ func (s *domainHandlerCommonSuite) SetupTest() { s.handler = NewHandler( domainConfig, logger, - s.metadataMgr, + s.domainManager, s.ClusterMetadata, s.mockDomainReplicator, s.archivalMetadata, @@ -440,7 +440,7 @@ func (s *domainHandlerCommonSuite) TestUpdateDomain_GracefulFailover_Success() { } err := s.handler.RegisterDomain(context.Background(), registerRequest) s.NoError(err) - resp1, _ := s.metadataMgr.GetDomain(context.Background(), &persistence.GetDomainRequest{ + resp1, _ := s.domainManager.GetDomain(context.Background(), &persistence.GetDomainRequest{ Name: domain, }) s.Equal("standby", resp1.ReplicationConfig.ActiveClusterName) @@ -453,7 +453,7 @@ func (s *domainHandlerCommonSuite) TestUpdateDomain_GracefulFailover_Success() { } resp, err := s.handler.UpdateDomain(context.Background(), updateRequest) s.NoError(err) - resp2, err := s.metadataMgr.GetDomain(context.Background(), &persistence.GetDomainRequest{ + resp2, err := s.domainManager.GetDomain(context.Background(), &persistence.GetDomainRequest{ ID: resp.GetDomainInfo().GetUUID(), }) s.NoError(err) @@ -591,7 +591,7 @@ func (s *domainHandlerCommonSuite) TestUpdateDomain_GracefulFailover_After_Force } _, err = s.handler.UpdateDomain(context.Background(), updateRequest) s.NoError(err) - resp2, err := s.metadataMgr.GetDomain(context.Background(), &persistence.GetDomainRequest{ + resp2, err := s.domainManager.GetDomain(context.Background(), &persistence.GetDomainRequest{ ID: resp.GetDomainInfo().GetUUID(), }) s.NoError(err) diff --git a/common/domain/replicationTaskExecutor.go b/common/domain/replicationTaskExecutor.go index 24d9cbe6e75..f9a0f2ddf31 100644 --- a/common/domain/replicationTaskExecutor.go +++ b/common/domain/replicationTaskExecutor.go @@ -64,23 +64,23 @@ type ( } domainReplicationTaskExecutorImpl struct { - metadataManager persistence.MetadataManager - timeSource clock.TimeSource - logger log.Logger + domainManager persistence.DomainManager + timeSource clock.TimeSource + logger log.Logger } ) // NewReplicationTaskExecutor create a new instance of domain replicator func NewReplicationTaskExecutor( - metadataMgr persistence.MetadataManager, + domainManager persistence.DomainManager, timeSource clock.TimeSource, logger log.Logger, ) ReplicationTaskExecutor { return &domainReplicationTaskExecutorImpl{ - metadataManager: metadataMgr, - timeSource: timeSource, - logger: logger, + domainManager: domainManager, + timeSource: timeSource, + logger: logger, } } @@ -138,14 +138,14 @@ func (h *domainReplicationTaskExecutorImpl) handleDomainCreationReplicationTask( LastUpdatedTime: h.timeSource.Now().UnixNano(), } - _, err = h.metadataManager.CreateDomain(ctx, request) + _, err = h.domainManager.CreateDomain(ctx, request) if err != nil { // SQL and Cassandra handle domain UUID collision differently // here, whenever seeing a error replicating a domain // do a check if there is a name / UUID collision recordExists := true - resp, getErr := h.metadataManager.GetDomain(ctx, &persistence.GetDomainRequest{ + resp, getErr := h.domainManager.GetDomain(ctx, &persistence.GetDomainRequest{ Name: task.Info.GetName(), }) switch getErr.(type) { @@ -161,7 +161,7 @@ func (h *domainReplicationTaskExecutorImpl) handleDomainCreationReplicationTask( return err } - resp, getErr = h.metadataManager.GetDomain(ctx, &persistence.GetDomainRequest{ + resp, getErr = h.domainManager.GetDomain(ctx, &persistence.GetDomainRequest{ ID: task.GetID(), }) switch getErr.(type) { @@ -196,7 +196,7 @@ func (h *domainReplicationTaskExecutorImpl) handleDomainUpdateReplicationTask(ct } // first we need to get the current notification version since we need to it for conditional update - metadata, err := h.metadataManager.GetMetadata(ctx) + metadata, err := h.domainManager.GetMetadata(ctx) if err != nil { return err } @@ -204,7 +204,7 @@ func (h *domainReplicationTaskExecutorImpl) handleDomainUpdateReplicationTask(ct // plus, we need to check whether the config version is <= the config version set in the input // plus, we need to check whether the failover version is <= the failover version set in the input - resp, err := h.metadataManager.GetDomain(ctx, &persistence.GetDomainRequest{ + resp, err := h.domainManager.GetDomain(ctx, &persistence.GetDomainRequest{ Name: task.Info.GetName(), }) if err != nil { @@ -265,7 +265,7 @@ func (h *domainReplicationTaskExecutorImpl) handleDomainUpdateReplicationTask(ct return nil } - return h.metadataManager.UpdateDomain(ctx, request) + return h.domainManager.UpdateDomain(ctx, request) } func (h *domainReplicationTaskExecutorImpl) validateDomainReplicationTask(task *types.DomainTaskAttributes) error { diff --git a/common/domain/replicationTaskExecutor_test.go b/common/domain/replicationTaskExecutor_test.go index 3ecbd0d16bc..fddad617bce 100644 --- a/common/domain/replicationTaskExecutor_test.go +++ b/common/domain/replicationTaskExecutor_test.go @@ -64,7 +64,7 @@ func (s *domainReplicationTaskExecutorSuite) SetupTest() { s.Require().NoError(err) logger := loggerimpl.NewLogger(zapLogger) s.domainReplicator = NewReplicationTaskExecutor( - s.MetadataManager, + s.DomainManager, clock.NewRealTimeSource(), logger, ).(*domainReplicationTaskExecutorImpl) @@ -196,13 +196,13 @@ func (s *domainReplicationTaskExecutorSuite) TestExecute_RegisterDomainTask() { FailoverVersion: failoverVersion, } - metadata, err := s.MetadataManager.GetMetadata(context.Background()) + metadata, err := s.DomainManager.GetMetadata(context.Background()) s.Nil(err) notificationVersion := metadata.NotificationVersion err = s.domainReplicator.Execute(task) s.Nil(err) - resp, err := s.MetadataManager.GetDomain(context.Background(), &persistence.GetDomainRequest{ID: id}) + resp, err := s.DomainManager.GetDomain(context.Background(), &persistence.GetDomainRequest{ID: id}) s.Nil(err) s.NotNil(resp) s.Equal(id, resp.Info.ID) @@ -282,13 +282,13 @@ func (s *domainReplicationTaskExecutorSuite) TestExecute_UpdateDomainTask_Domain FailoverVersion: failoverVersion, } - metadata, err := s.MetadataManager.GetMetadata(context.Background()) + metadata, err := s.DomainManager.GetMetadata(context.Background()) s.Nil(err) notificationVersion := metadata.NotificationVersion err = s.domainReplicator.Execute(updateTask) s.Nil(err) - resp, err := s.MetadataManager.GetDomain(context.Background(), &persistence.GetDomainRequest{Name: name}) + resp, err := s.DomainManager.GetDomain(context.Background(), &persistence.GetDomainRequest{Name: name}) s.Nil(err) s.NotNil(resp) s.Equal(id, resp.Info.ID) @@ -416,12 +416,12 @@ func (s *domainReplicationTaskExecutorSuite) TestExecute_UpdateDomainTask_Update ConfigVersion: updateConfigVersion, FailoverVersion: updateFailoverVersion, } - metadata, err := s.MetadataManager.GetMetadata(context.Background()) + metadata, err := s.DomainManager.GetMetadata(context.Background()) s.Nil(err) notificationVersion := metadata.NotificationVersion err = s.domainReplicator.Execute(updateTask) s.Nil(err) - resp, err := s.MetadataManager.GetDomain(context.Background(), &persistence.GetDomainRequest{Name: name}) + resp, err := s.DomainManager.GetDomain(context.Background(), &persistence.GetDomainRequest{Name: name}) s.Nil(err) s.NotNil(resp) s.Equal(id, resp.Info.ID) @@ -551,12 +551,12 @@ func (s *domainReplicationTaskExecutorSuite) TestExecute_UpdateDomainTask_Update FailoverVersion: updateFailoverVersion, PreviousFailoverVersion: previousFailoverVersion, } - metadata, err := s.MetadataManager.GetMetadata(context.Background()) + metadata, err := s.DomainManager.GetMetadata(context.Background()) s.Nil(err) notificationVersion := metadata.NotificationVersion err = s.domainReplicator.Execute(updateTask) s.Nil(err) - resp, err := s.MetadataManager.GetDomain(context.Background(), &persistence.GetDomainRequest{Name: name}) + resp, err := s.DomainManager.GetDomain(context.Background(), &persistence.GetDomainRequest{Name: name}) s.Nil(err) s.NotNil(resp) s.Equal(id, resp.Info.ID) @@ -637,7 +637,7 @@ func (s *domainReplicationTaskExecutorSuite) TestExecute_UpdateDomainTask_NoUpda err := s.domainReplicator.Execute(createTask) s.Nil(err) - resp1, err := s.MetadataManager.GetDomain(context.Background(), &persistence.GetDomainRequest{Name: name}) + resp1, err := s.DomainManager.GetDomain(context.Background(), &persistence.GetDomainRequest{Name: name}) s.Nil(err) s.NotNil(resp1) s.Equal(id, resp1.Info.ID) @@ -704,12 +704,12 @@ func (s *domainReplicationTaskExecutorSuite) TestExecute_UpdateDomainTask_NoUpda FailoverVersion: updateFailoverVersion, PreviousFailoverVersion: failoverVersion, } - metadata, err := s.MetadataManager.GetMetadata(context.Background()) + metadata, err := s.DomainManager.GetMetadata(context.Background()) s.Nil(err) notificationVersion := metadata.NotificationVersion err = s.domainReplicator.Execute(updateTask) s.Nil(err) - resp, err := s.MetadataManager.GetDomain(context.Background(), &persistence.GetDomainRequest{Name: name}) + resp, err := s.DomainManager.GetDomain(context.Background(), &persistence.GetDomainRequest{Name: name}) s.Nil(err) s.NotNil(resp) s.Equal(id, resp.Info.ID) @@ -786,7 +786,7 @@ func (s *domainReplicationTaskExecutorSuite) TestExecute_UpdateDomainTask_NoUpda ConfigVersion: configVersion, FailoverVersion: failoverVersion, } - metadata, err := s.MetadataManager.GetMetadata(context.Background()) + metadata, err := s.DomainManager.GetMetadata(context.Background()) s.Nil(err) notificationVersion := metadata.NotificationVersion err = s.domainReplicator.Execute(createTask) @@ -840,7 +840,7 @@ func (s *domainReplicationTaskExecutorSuite) TestExecute_UpdateDomainTask_NoUpda } err = s.domainReplicator.Execute(updateTask) s.Nil(err) - resp, err := s.MetadataManager.GetDomain(context.Background(), &persistence.GetDomainRequest{Name: name}) + resp, err := s.DomainManager.GetDomain(context.Background(), &persistence.GetDomainRequest{Name: name}) s.Nil(err) s.NotNil(resp) s.Equal(id, resp.Info.ID) diff --git a/common/persistence/client/bean.go b/common/persistence/client/bean.go index a3023c2c12b..0078b4d628a 100644 --- a/common/persistence/client/bean.go +++ b/common/persistence/client/bean.go @@ -35,8 +35,8 @@ type ( Bean interface { Close() - GetMetadataManager() persistence.MetadataManager - SetMetadataManager(persistence.MetadataManager) + GetDomainManager() persistence.DomainManager + SetDomainManager(persistence.DomainManager) GetTaskManager() persistence.TaskManager SetTaskManager(persistence.TaskManager) @@ -59,7 +59,7 @@ type ( // BeanImpl stores persistence managers BeanImpl struct { - metadataManager persistence.MetadataManager + domainManager persistence.DomainManager taskManager persistence.TaskManager visibilityManager persistence.VisibilityManager domainReplicationQueueManager persistence.QueueManager @@ -79,7 +79,7 @@ func NewBeanFromFactory( resourceConfig *config.ResourceConfig, ) (*BeanImpl, error) { - metadataMgr, err := factory.NewMetadataManager() + metadataMgr, err := factory.NewDomainManager() if err != nil { return nil, err } @@ -122,7 +122,7 @@ func NewBeanFromFactory( // NewBean create a new store bean func NewBean( - metadataManager persistence.MetadataManager, + domainManager persistence.DomainManager, taskManager persistence.TaskManager, visibilityManager persistence.VisibilityManager, domainReplicationQueueManager persistence.QueueManager, @@ -131,7 +131,7 @@ func NewBean( executionManagerFactory persistence.ExecutionManagerFactory, ) *BeanImpl { return &BeanImpl{ - metadataManager: metadataManager, + domainManager: domainManager, taskManager: taskManager, visibilityManager: visibilityManager, domainReplicationQueueManager: domainReplicationQueueManager, @@ -143,24 +143,24 @@ func NewBean( } } -// GetMetadataManager get MetadataManager -func (s *BeanImpl) GetMetadataManager() persistence.MetadataManager { +// GetDomainManager get DomainManager +func (s *BeanImpl) GetDomainManager() persistence.DomainManager { s.RLock() defer s.RUnlock() - return s.metadataManager + return s.domainManager } -// SetMetadataManager set MetadataManager -func (s *BeanImpl) SetMetadataManager( - metadataManager persistence.MetadataManager, +// SetMetadataManager set DomainManager +func (s *BeanImpl) SetDomainManager( + domainManager persistence.DomainManager, ) { s.Lock() defer s.Unlock() - s.metadataManager = metadataManager + s.domainManager = domainManager } // GetTaskManager get TaskManager @@ -311,7 +311,7 @@ func (s *BeanImpl) Close() { s.Lock() defer s.Unlock() - s.metadataManager.Close() + s.domainManager.Close() s.taskManager.Close() if s.visibilityManager != nil { // visibilityManager can be nil diff --git a/common/persistence/client/bean_mock.go b/common/persistence/client/bean_mock.go index 2d618b53630..a58a8f17f20 100644 --- a/common/persistence/client/bean_mock.go +++ b/common/persistence/client/bean_mock.go @@ -69,30 +69,30 @@ func (mr *MockBeanMockRecorder) Close() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockBean)(nil).Close)) } -// GetMetadataManager mocks base method -func (m *MockBean) GetMetadataManager() persistence.MetadataManager { +// GetDomainManager mocks base method +func (m *MockBean) GetDomainManager() persistence.DomainManager { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetMetadataManager") - ret0, _ := ret[0].(persistence.MetadataManager) + ret := m.ctrl.Call(m, "GetDomainManager") + ret0, _ := ret[0].(persistence.DomainManager) return ret0 } // GetMetadataManager indicates an expected call of GetMetadataManager func (mr *MockBeanMockRecorder) GetMetadataManager() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMetadataManager", reflect.TypeOf((*MockBean)(nil).GetMetadataManager)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDomainManager", reflect.TypeOf((*MockBean)(nil).GetDomainManager)) } // SetMetadataManager mocks base method -func (m *MockBean) SetMetadataManager(arg0 persistence.MetadataManager) { +func (m *MockBean) SetDomainManager(arg0 persistence.DomainManager) { m.ctrl.T.Helper() - m.ctrl.Call(m, "SetMetadataManager", arg0) + m.ctrl.Call(m, "SetDomainManager", arg0) } // SetMetadataManager indicates an expected call of SetMetadataManager func (mr *MockBeanMockRecorder) SetMetadataManager(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetMetadataManager", reflect.TypeOf((*MockBean)(nil).SetMetadataManager), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetDomainManager", reflect.TypeOf((*MockBean)(nil).SetDomainManager), arg0) } // GetTaskManager mocks base method diff --git a/common/persistence/client/factory.go b/common/persistence/client/factory.go index 78c41f5f352..686ef98bf6b 100644 --- a/common/persistence/client/factory.go +++ b/common/persistence/client/factory.go @@ -54,8 +54,8 @@ type ( NewShardManager() (p.ShardManager, error) // NewHistoryManager returns a new history manager NewHistoryManager() (p.HistoryManager, error) - // NewMetadataManager returns a new metadata manager - NewMetadataManager() (p.MetadataManager, error) + // NewDomainManager returns a new metadata manager + NewDomainManager() (p.DomainManager, error) // NewExecutionManager returns a new execution manager for a given shardID NewExecutionManager(shardID int) (p.ExecutionManager, error) // NewVisibilityManager returns a new visibility manager @@ -207,8 +207,8 @@ func (f *factoryImpl) NewHistoryManager() (p.HistoryManager, error) { return result, nil } -// NewMetadataManager returns a new metadata manager -func (f *factoryImpl) NewMetadataManager() (p.MetadataManager, error) { +// NewDomainManager returns a new metadata manager +func (f *factoryImpl) NewDomainManager() (p.DomainManager, error) { var err error var store p.MetadataStore ds := f.datastores[storeTypeMetadata] @@ -216,15 +216,15 @@ func (f *factoryImpl) NewMetadataManager() (p.MetadataManager, error) { if err != nil { return nil, err } - result := p.NewMetadataManagerImpl(store, f.logger) + result := p.NewDomainManagerImpl(store, f.logger) if errorRate := f.config.ErrorInjectionRate(); errorRate != 0 { - result = p.NewMetadataPersistenceErrorInjectionClient(result, errorRate, f.logger) + result = p.NewDomainPersistenceErrorInjectionClient(result, errorRate, f.logger) } if ds.ratelimit != nil { - result = p.NewMetadataPersistenceRateLimitedClient(result, ds.ratelimit, f.logger) + result = p.NewDomainPersistenceRateLimitedClient(result, ds.ratelimit, f.logger) } if f.metricsClient != nil { - result = p.NewMetadataPersistenceMetricsClient(result, f.metricsClient, f.logger) + result = p.NewDomainPersistenceMetricsClient(result, f.metricsClient, f.logger) } return result, nil } diff --git a/common/persistence/dataInterfaces.go b/common/persistence/dataInterfaces.go index 6f16f6eaa01..e7575b58ba0 100644 --- a/common/persistence/dataInterfaces.go +++ b/common/persistence/dataInterfaces.go @@ -1677,8 +1677,8 @@ type ( GetAllHistoryTreeBranches(ctx context.Context, request *GetAllHistoryTreeBranchesRequest) (*GetAllHistoryTreeBranchesResponse, error) } - // MetadataManager is used to manage metadata CRUD for domain entities - MetadataManager interface { + // DomainManager is used to manage metadata CRUD for domain entities + DomainManager interface { Closeable GetName() string CreateDomain(ctx context.Context, request *CreateDomainRequest) (*CreateDomainResponse, error) diff --git a/common/persistence/metadataStore.go b/common/persistence/domainManager.go similarity index 87% rename from common/persistence/metadataStore.go rename to common/persistence/domainManager.go index 6e21d0c2673..b5fb3607de7 100644 --- a/common/persistence/metadataStore.go +++ b/common/persistence/domainManager.go @@ -31,30 +31,30 @@ import ( type ( - // metadataManagerImpl implements MetadataManager based on MetadataStore and PayloadSerializer - metadataManagerImpl struct { + // domainManagerImpl implements DomainManager based on MetadataStore and PayloadSerializer + domainManagerImpl struct { serializer PayloadSerializer persistence MetadataStore logger log.Logger } ) -var _ MetadataManager = (*metadataManagerImpl)(nil) +var _ DomainManager = (*domainManagerImpl)(nil) -//NewMetadataManagerImpl returns new MetadataManager -func NewMetadataManagerImpl(persistence MetadataStore, logger log.Logger) MetadataManager { - return &metadataManagerImpl{ +//NewDomainManagerImpl returns new DomainManager +func NewDomainManagerImpl(persistence MetadataStore, logger log.Logger) DomainManager { + return &domainManagerImpl{ serializer: NewPayloadSerializer(), persistence: persistence, logger: logger, } } -func (m *metadataManagerImpl) GetName() string { +func (m *domainManagerImpl) GetName() string { return m.persistence.GetName() } -func (m *metadataManagerImpl) CreateDomain( +func (m *domainManagerImpl) CreateDomain( ctx context.Context, request *CreateDomainRequest, ) (*CreateDomainResponse, error) { @@ -73,7 +73,7 @@ func (m *metadataManagerImpl) CreateDomain( }) } -func (m *metadataManagerImpl) GetDomain( +func (m *domainManagerImpl) GetDomain( ctx context.Context, request *GetDomainRequest, ) (*GetDomainResponse, error) { @@ -105,7 +105,7 @@ func (m *metadataManagerImpl) GetDomain( return resp, nil } -func (m *metadataManagerImpl) UpdateDomain( +func (m *domainManagerImpl) UpdateDomain( ctx context.Context, request *UpdateDomainRequest, ) error { @@ -130,21 +130,21 @@ func (m *metadataManagerImpl) UpdateDomain( return m.persistence.UpdateDomain(ctx, internalReq) } -func (m *metadataManagerImpl) DeleteDomain( +func (m *domainManagerImpl) DeleteDomain( ctx context.Context, request *DeleteDomainRequest, ) error { return m.persistence.DeleteDomain(ctx, request) } -func (m *metadataManagerImpl) DeleteDomainByName( +func (m *domainManagerImpl) DeleteDomainByName( ctx context.Context, request *DeleteDomainByNameRequest, ) error { return m.persistence.DeleteDomainByName(ctx, request) } -func (m *metadataManagerImpl) ListDomains( +func (m *domainManagerImpl) ListDomains( ctx context.Context, request *ListDomainsRequest, ) (*ListDomainsResponse, error) { @@ -180,7 +180,7 @@ func (m *metadataManagerImpl) ListDomains( }, nil } -func (m *metadataManagerImpl) toInternalDomainConfig(c *DomainConfig) (InternalDomainConfig, error) { +func (m *domainManagerImpl) toInternalDomainConfig(c *DomainConfig) (InternalDomainConfig, error) { if c == nil { return InternalDomainConfig{}, nil } @@ -202,7 +202,7 @@ func (m *metadataManagerImpl) toInternalDomainConfig(c *DomainConfig) (InternalD }, nil } -func (m *metadataManagerImpl) fromInternalDomainConfig(ic *InternalDomainConfig) (DomainConfig, error) { +func (m *domainManagerImpl) fromInternalDomainConfig(ic *InternalDomainConfig) (DomainConfig, error) { if ic == nil { return DomainConfig{}, nil } @@ -224,12 +224,12 @@ func (m *metadataManagerImpl) fromInternalDomainConfig(ic *InternalDomainConfig) }, nil } -func (m *metadataManagerImpl) GetMetadata( +func (m *domainManagerImpl) GetMetadata( ctx context.Context, ) (*GetMetadataResponse, error) { return m.persistence.GetMetadata(ctx) } -func (m *metadataManagerImpl) Close() { +func (m *domainManagerImpl) Close() { m.persistence.Close() } diff --git a/common/persistence/persistence-tests/metadataPersistenceV2Test.go b/common/persistence/persistence-tests/metadataPersistenceV2Test.go index 1b463e60aee..62a6d0d923f 100644 --- a/common/persistence/persistence-tests/metadataPersistenceV2Test.go +++ b/common/persistence/persistence-tests/metadataPersistenceV2Test.go @@ -573,7 +573,7 @@ func (m *MetadataPersistenceSuiteV2) TestConcurrentUpdateDomain() { resp2, err2 := m.GetDomain(ctx, id, "") m.NoError(err2) m.Equal(badBinaries, resp2.Config.BadBinaries) - metadata, err := m.MetadataManager.GetMetadata(ctx) + metadata, err := m.DomainManager.GetMetadata(ctx) m.NoError(err) notificationVersion := metadata.NotificationVersion @@ -743,7 +743,7 @@ func (m *MetadataPersistenceSuiteV2) TestUpdateDomain() { resp2, err2 := m.GetDomain(ctx, id, "") m.NoError(err2) m.Nil(resp2.FailoverEndTime) - metadata, err := m.MetadataManager.GetMetadata(ctx) + metadata, err := m.DomainManager.GetMetadata(ctx) m.NoError(err) notificationVersion := metadata.NotificationVersion @@ -1219,7 +1219,7 @@ func (m *MetadataPersistenceSuiteV2) CreateDomain( lastUpdateTime int64, ) (*p.CreateDomainResponse, error) { - return m.MetadataManager.CreateDomain(ctx, &p.CreateDomainRequest{ + return m.DomainManager.CreateDomain(ctx, &p.CreateDomainRequest{ Info: info, Config: config, ReplicationConfig: replicationConfig, @@ -1232,7 +1232,7 @@ func (m *MetadataPersistenceSuiteV2) CreateDomain( // GetDomain helper method func (m *MetadataPersistenceSuiteV2) GetDomain(ctx context.Context, id, name string) (*p.GetDomainResponse, error) { - return m.MetadataManager.GetDomain(ctx, &p.GetDomainRequest{ + return m.DomainManager.GetDomain(ctx, &p.GetDomainRequest{ ID: id, Name: name, }) @@ -1253,7 +1253,7 @@ func (m *MetadataPersistenceSuiteV2) UpdateDomain( lastUpdateTime int64, ) error { - return m.MetadataManager.UpdateDomain(ctx, &p.UpdateDomainRequest{ + return m.DomainManager.UpdateDomain(ctx, &p.UpdateDomainRequest{ Info: info, Config: config, ReplicationConfig: replicationConfig, @@ -1270,14 +1270,14 @@ func (m *MetadataPersistenceSuiteV2) UpdateDomain( // DeleteDomain helper method func (m *MetadataPersistenceSuiteV2) DeleteDomain(ctx context.Context, id, name string) error { if len(id) > 0 { - return m.MetadataManager.DeleteDomain(ctx, &p.DeleteDomainRequest{ID: id}) + return m.DomainManager.DeleteDomain(ctx, &p.DeleteDomainRequest{ID: id}) } - return m.MetadataManager.DeleteDomainByName(ctx, &p.DeleteDomainByNameRequest{Name: name}) + return m.DomainManager.DeleteDomainByName(ctx, &p.DeleteDomainByNameRequest{Name: name}) } // ListDomains helper method func (m *MetadataPersistenceSuiteV2) ListDomains(ctx context.Context, pageSize int, pageToken []byte) (*p.ListDomainsResponse, error) { - return m.MetadataManager.ListDomains(ctx, &p.ListDomainsRequest{ + return m.DomainManager.ListDomains(ctx, &p.ListDomainsRequest{ PageSize: pageSize, NextPageToken: pageToken, }) diff --git a/common/persistence/persistence-tests/persistenceTestBase.go b/common/persistence/persistence-tests/persistenceTestBase.go index 984d208c5ad..e8b50b07614 100644 --- a/common/persistence/persistence-tests/persistenceTestBase.go +++ b/common/persistence/persistence-tests/persistenceTestBase.go @@ -76,7 +76,7 @@ type ( ExecutionManager p.ExecutionManager TaskMgr p.TaskManager HistoryV2Mgr p.HistoryManager - MetadataManager p.MetadataManager + DomainManager p.DomainManager DomainReplicationQueueMgr p.QueueManager ShardInfo *p.ShardInfo TaskIDGenerator TransferTaskIDGenerator @@ -202,8 +202,8 @@ func (s *TestBase) Setup() { s.TaskMgr, err = factory.NewTaskManager() s.fatalOnError("NewTaskManager", err) - s.MetadataManager, err = factory.NewMetadataManager() - s.fatalOnError("NewMetadataManager", err) + s.DomainManager, err = factory.NewDomainManager() + s.fatalOnError("NewDomainManager", err) s.HistoryV2Mgr, err = factory.NewHistoryManager() s.fatalOnError("NewHistoryManager", err) diff --git a/common/persistence/persistenceErrorInjectionClients.go b/common/persistence/persistenceErrorInjectionClients.go index a7059d21947..a10cc03ded4 100644 --- a/common/persistence/persistenceErrorInjectionClients.go +++ b/common/persistence/persistenceErrorInjectionClients.go @@ -73,7 +73,7 @@ type ( } metadataErrorInjectionPersistenceClient struct { - persistence MetadataManager + persistence DomainManager errorRate float64 logger log.Logger } @@ -95,7 +95,7 @@ var _ ShardManager = (*shardErrorInjectionPersistenceClient)(nil) var _ ExecutionManager = (*workflowExecutionErrorInjectionPersistenceClient)(nil) var _ TaskManager = (*taskErrorInjectionPersistenceClient)(nil) var _ HistoryManager = (*historyErrorInjectionPersistenceClient)(nil) -var _ MetadataManager = (*metadataErrorInjectionPersistenceClient)(nil) +var _ DomainManager = (*metadataErrorInjectionPersistenceClient)(nil) var _ VisibilityManager = (*visibilityErrorInjectionPersistenceClient)(nil) var _ QueueManager = (*queueErrorInjectionPersistenceClient)(nil) @@ -151,12 +151,12 @@ func NewHistoryPersistenceErrorInjectionClient( } } -// NewMetadataPersistenceErrorInjectionClient creates an error injection MetadataManager client to manage metadata -func NewMetadataPersistenceErrorInjectionClient( - persistence MetadataManager, +// NewDomainPersistenceErrorInjectionClient creates an error injection DomainManager client to manage metadata +func NewDomainPersistenceErrorInjectionClient( + persistence DomainManager, errorRate float64, logger log.Logger, -) MetadataManager { +) DomainManager { return &metadataErrorInjectionPersistenceClient{ persistence: persistence, errorRate: errorRate, diff --git a/common/persistence/persistenceInterface.go b/common/persistence/persistenceInterface.go index 331a1572035..a19e8f38197 100644 --- a/common/persistence/persistenceInterface.go +++ b/common/persistence/persistenceInterface.go @@ -76,7 +76,7 @@ type ( GetOrphanTasks(ctx context.Context, request *GetOrphanTasksRequest) (*GetOrphanTasksResponse, error) } - // MetadataStore is a lower level of MetadataManager + // MetadataStore is a lower level of DomainManager MetadataStore interface { Closeable GetName() string diff --git a/common/persistence/persistenceMetricClients.go b/common/persistence/persistenceMetricClients.go index 11b1031d738..058dc1b2085 100644 --- a/common/persistence/persistenceMetricClients.go +++ b/common/persistence/persistenceMetricClients.go @@ -56,7 +56,7 @@ type ( metadataPersistenceClient struct { metricClient metrics.Client - persistence MetadataManager + persistence DomainManager logger log.Logger } @@ -77,7 +77,7 @@ var _ ShardManager = (*shardPersistenceClient)(nil) var _ ExecutionManager = (*workflowExecutionPersistenceClient)(nil) var _ TaskManager = (*taskPersistenceClient)(nil) var _ HistoryManager = (*historyPersistenceClient)(nil) -var _ MetadataManager = (*metadataPersistenceClient)(nil) +var _ DomainManager = (*metadataPersistenceClient)(nil) var _ VisibilityManager = (*visibilityPersistenceClient)(nil) var _ QueueManager = (*queuePersistenceClient)(nil) @@ -133,12 +133,12 @@ func NewHistoryPersistenceMetricsClient( } } -// NewMetadataPersistenceMetricsClient creates a MetadataManager client to manage metadata -func NewMetadataPersistenceMetricsClient( - persistence MetadataManager, +// NewDomainPersistenceMetricsClient creates a DomainManager client to manage metadata +func NewDomainPersistenceMetricsClient( + persistence DomainManager, metricClient metrics.Client, logger log.Logger, -) MetadataManager { +) DomainManager { return &metadataPersistenceClient{ persistence: persistence, metricClient: metricClient, diff --git a/common/persistence/persistenceRateLimitedClients.go b/common/persistence/persistenceRateLimitedClients.go index fa8df72ac41..57b532421d6 100644 --- a/common/persistence/persistenceRateLimitedClients.go +++ b/common/persistence/persistenceRateLimitedClients.go @@ -60,7 +60,7 @@ type ( metadataRateLimitedPersistenceClient struct { rateLimiter quotas.Limiter - persistence MetadataManager + persistence DomainManager logger log.Logger } @@ -81,7 +81,7 @@ var _ ShardManager = (*shardRateLimitedPersistenceClient)(nil) var _ ExecutionManager = (*workflowExecutionRateLimitedPersistenceClient)(nil) var _ TaskManager = (*taskRateLimitedPersistenceClient)(nil) var _ HistoryManager = (*historyRateLimitedPersistenceClient)(nil) -var _ MetadataManager = (*metadataRateLimitedPersistenceClient)(nil) +var _ DomainManager = (*metadataRateLimitedPersistenceClient)(nil) var _ VisibilityManager = (*visibilityRateLimitedPersistenceClient)(nil) var _ QueueManager = (*queueRateLimitedPersistenceClient)(nil) @@ -137,12 +137,12 @@ func NewHistoryPersistenceRateLimitedClient( } } -// NewMetadataPersistenceRateLimitedClient creates a MetadataManager client to manage metadata -func NewMetadataPersistenceRateLimitedClient( - persistence MetadataManager, +// NewDomainPersistenceRateLimitedClient creates a DomainManager client to manage metadata +func NewDomainPersistenceRateLimitedClient( + persistence DomainManager, rateLimiter quotas.Limiter, logger log.Logger, -) MetadataManager { +) DomainManager { return &metadataRateLimitedPersistenceClient{ persistence: persistence, rateLimiter: rateLimiter, diff --git a/common/resource/resource.go b/common/resource/resource.go index f95ab8c2a9d..a30e8e0e926 100644 --- a/common/resource/resource.go +++ b/common/resource/resource.go @@ -94,7 +94,7 @@ type ( // persistence clients - GetMetadataManager() persistence.MetadataManager + GetDomainManager() persistence.DomainManager GetTaskManager() persistence.TaskManager GetVisibilityManager() persistence.VisibilityManager GetShardManager() persistence.ShardManager diff --git a/common/resource/resourceImpl.go b/common/resource/resourceImpl.go index e63647bbf6d..b8aecf4dc4e 100644 --- a/common/resource/resourceImpl.go +++ b/common/resource/resourceImpl.go @@ -216,7 +216,7 @@ func New( } domainCache := cache.NewDomainCache( - persistenceBean.GetMetadataManager(), + persistenceBean.GetDomainManager(), params.ClusterMetadata, params.MetricsClient, logger, @@ -560,8 +560,8 @@ func (h *Impl) GetClientBean() client.Bean { // persistence clients // GetMetadataManager return metadata manager -func (h *Impl) GetMetadataManager() persistence.MetadataManager { - return h.persistenceBean.GetMetadataManager() +func (h *Impl) GetDomainManager() persistence.DomainManager { + return h.persistenceBean.GetDomainManager() } // GetTaskManager return task manager diff --git a/common/resource/resourceTest.go b/common/resource/resourceTest.go index baea8beae7d..6378874b01a 100644 --- a/common/resource/resourceTest.go +++ b/common/resource/resourceTest.go @@ -389,7 +389,7 @@ func (s *Test) GetClientBean() client.Bean { // persistence clients // GetMetadataManager for testing -func (s *Test) GetMetadataManager() persistence.MetadataManager { +func (s *Test) GetDomainManager() persistence.DomainManager { return s.MetadataMgr } diff --git a/host/integrationbase.go b/host/integrationbase.go index 7af17e22d3d..a7fecc8984a 100644 --- a/host/integrationbase.go +++ b/host/integrationbase.go @@ -284,7 +284,7 @@ func (s *IntegrationBase) registerArchivalDomain() error { IsGlobalDomain: false, FailoverVersion: common.EmptyVersion, } - response, err := s.testCluster.testBase.MetadataManager.CreateDomain(ctx, domainRequest) + response, err := s.testCluster.testBase.DomainManager.CreateDomain(ctx, domainRequest) if err == nil { s.Logger.Info("Register domain succeeded", tag.WorkflowDomainName(s.archivalDomainName), diff --git a/host/onebox.go b/host/onebox.go index 45ad11856fa..9cc21e8702d 100644 --- a/host/onebox.go +++ b/host/onebox.go @@ -95,7 +95,7 @@ type ( persistenceConfig config.Persistence dispatcherProvider client.DispatcherProvider messagingClient messaging.Client - metadataMgr persistence.MetadataManager + domainManager persistence.DomainManager historyV2Mgr persistence.HistoryManager executionMgrFactory persistence.ExecutionManagerFactory domainReplicationQueue domain.ReplicationQueue @@ -129,7 +129,7 @@ type ( PersistenceConfig config.Persistence DispatcherProvider client.DispatcherProvider MessagingClient messaging.Client - MetadataMgr persistence.MetadataManager + DomainManager persistence.DomainManager HistoryV2Mgr persistence.HistoryManager ExecutionMgrFactory persistence.ExecutionManagerFactory DomainReplicationQueue domain.ReplicationQueue @@ -160,7 +160,7 @@ func NewCadence(params *CadenceParams) Cadence { persistenceConfig: params.PersistenceConfig, dispatcherProvider: params.DispatcherProvider, messagingClient: params.MessagingClient, - metadataMgr: params.MetadataMgr, + domainManager: params.DomainManager, historyV2Mgr: params.HistoryV2Mgr, executionMgrFactory: params.ExecutionMgrFactory, domainReplicationQueue: params.DomainReplicationQueue, @@ -597,7 +597,7 @@ func (c *cadenceImpl) startWorker(hosts map[string][]string, startWG *sync.WaitG var replicatorDomainCache cache.DomainCache if c.workerConfig.EnableReplicator { - metadataManager := persistence.NewMetadataPersistenceMetricsClient(c.metadataMgr, service.GetMetricsClient(), c.logger) + metadataManager := persistence.NewDomainPersistenceMetricsClient(c.domainManager, service.GetMetricsClient(), c.logger) replicatorDomainCache = cache.NewDomainCache(metadataManager, params.ClusterMetadata, service.GetMetricsClient(), service.GetLogger()) replicatorDomainCache.Start() c.startWorkerReplicator(params, service, replicatorDomainCache) @@ -605,7 +605,7 @@ func (c *cadenceImpl) startWorker(hosts map[string][]string, startWG *sync.WaitG var clientWorkerDomainCache cache.DomainCache if c.workerConfig.EnableArchiver { - metadataProxyManager := persistence.NewMetadataPersistenceMetricsClient(c.metadataMgr, service.GetMetricsClient(), c.logger) + metadataProxyManager := persistence.NewDomainPersistenceMetricsClient(c.domainManager, service.GetMetricsClient(), c.logger) clientWorkerDomainCache = cache.NewDomainCache(metadataProxyManager, params.ClusterMetadata, service.GetMetricsClient(), service.GetLogger()) clientWorkerDomainCache.Start() c.startWorkerClientWorker(params, service, clientWorkerDomainCache) @@ -699,7 +699,7 @@ func (c *cadenceImpl) createSystemDomain() error { ctx, cancel := context.WithTimeout(context.Background(), defaultTestPersistenceTimeout) defer cancel() - _, err := c.metadataMgr.CreateDomain(ctx, &persistence.CreateDomainRequest{ + _, err := c.domainManager.CreateDomain(ctx, &persistence.CreateDomainRequest{ Info: &persistence.DomainInfo{ ID: uuid.New(), Name: "cadence-system", diff --git a/host/testcluster.go b/host/testcluster.go index a03f49c39f7..2c3a7fa4c59 100644 --- a/host/testcluster.go +++ b/host/testcluster.go @@ -137,7 +137,7 @@ func NewCluster(options *TestClusterConfig, logger log.Logger, params persistenc PersistenceConfig: pConfig, DispatcherProvider: client.NewDNSYarpcDispatcherProvider(logger, 0), MessagingClient: messagingClient, - MetadataMgr: testBase.MetadataManager, + DomainManager: testBase.DomainManager, HistoryV2Mgr: testBase.HistoryV2Mgr, ExecutionMgrFactory: testBase.ExecutionMgrFactory, DomainReplicationQueue: domainReplicationQueue, @@ -150,7 +150,7 @@ func NewCluster(options *TestClusterConfig, logger log.Logger, params persistenc HistoryConfig: options.HistoryConfig, WorkerConfig: options.WorkerConfig, MockAdminClient: options.MockAdminClient, - DomainReplicationTaskExecutor: domain.NewReplicationTaskExecutor(testBase.MetadataManager, clock.NewRealTimeSource(), logger), + DomainReplicationTaskExecutor: domain.NewReplicationTaskExecutor(testBase.DomainManager, clock.NewRealTimeSource(), logger), } cluster := NewCadence(cadenceParams) if err := cluster.Start(); err != nil { diff --git a/service/frontend/adminHandler.go b/service/frontend/adminHandler.go index 58ef0fab834..cd737672747 100644 --- a/service/frontend/adminHandler.go +++ b/service/frontend/adminHandler.go @@ -122,7 +122,7 @@ func NewAdminHandler( ) *adminHandlerImpl { domainReplicationTaskExecutor := domain.NewReplicationTaskExecutor( - resource.GetMetadataManager(), + resource.GetDomainManager(), resource.GetTimeSource(), resource.GetLogger(), ) @@ -138,7 +138,7 @@ func NewAdminHandler( ), domainFailoverWatcher: domain.NewFailoverWatcher( resource.GetDomainCache(), - resource.GetMetadataManager(), + resource.GetDomainManager(), resource.GetTimeSource(), config.DomainFailoverRefreshInterval, config.DomainFailoverRefreshTimerJitterCoefficient, diff --git a/service/frontend/workflowHandler.go b/service/frontend/workflowHandler.go index 1121d1c2bb2..e4c7d442d23 100644 --- a/service/frontend/workflowHandler.go +++ b/service/frontend/workflowHandler.go @@ -176,7 +176,7 @@ func NewWorkflowHandler( domainHandler: domain.NewHandler( config.domainConfig, resource.GetLogger(), - resource.GetMetadataManager(), + resource.GetDomainManager(), resource.GetClusterMetadata(), domain.NewDomainReplicator(replicationMessageSink, resource.GetLogger()), resource.GetArchivalMetadata(), diff --git a/service/history/failover/coordinator.go b/service/history/failover/coordinator.go index f02c46968df..c263a3c8585 100644 --- a/service/history/failover/coordinator.go +++ b/service/history/failover/coordinator.go @@ -70,7 +70,7 @@ type ( shutdownChan chan struct{} retryPolicy backoff.RetryPolicy - metadataMgr persistence.MetadataManager + domainManager persistence.DomainManager historyClient history.Client config *config.Config timeSource clock.TimeSource @@ -98,7 +98,7 @@ type ( // NewCoordinator initialize a failover coordinator func NewCoordinator( - metadataMgr persistence.MetadataManager, + domainManager persistence.DomainManager, historyClient history.Client, timeSource clock.TimeSource, domainCache cache.DomainCache, @@ -118,7 +118,7 @@ func NewCoordinator( receiveChan: make(chan *receiveRequest, receiveChanBufferSize), shutdownChan: make(chan struct{}), retryPolicy: retryPolicy, - metadataMgr: metadataMgr, + domainManager: domainManager, historyClient: historyClient, timeSource: timeSource, domainCache: domainCache, @@ -269,7 +269,7 @@ func (c *coordinatorImpl) handleFailoverMarkers( if len(record.shards) == c.config.NumberOfShards { if err := domain.CleanPendingActiveState( - c.metadataMgr, + c.domainManager, domainID, record.failoverVersion, c.retryPolicy, diff --git a/service/history/handler.go b/service/history/handler.go index c3107be8d1a..05c8f7a578e 100644 --- a/service/history/handler.go +++ b/service/history/handler.go @@ -192,7 +192,7 @@ func (h *handlerImpl) Start() { h.historyEventNotifier.Start() h.failoverCoordinator = failover.NewCoordinator( - h.GetMetadataManager(), + h.GetDomainManager(), h.GetHistoryClient(), h.GetTimeSource(), h.GetDomainCache(), diff --git a/service/worker/service.go b/service/worker/service.go index 7eeee97c27e..b520add4be2 100644 --- a/service/worker/service.go +++ b/service/worker/service.go @@ -276,7 +276,7 @@ func (s *Service) startScanner() { func (s *Service) startReplicator() { domainReplicationTaskExecutor := domain.NewReplicationTaskExecutor( - s.Resource.GetMetadataManager(), + s.Resource.GetDomainManager(), s.Resource.GetTimeSource(), s.Resource.GetLogger(), ) @@ -357,7 +357,7 @@ func (s *Service) startWorkflowShadower() { } func (s *Service) ensureDomainExists(domain string) { - _, err := s.GetMetadataManager().GetDomain(context.Background(), &persistence.GetDomainRequest{Name: domain}) + _, err := s.GetDomainManager().GetDomain(context.Background(), &persistence.GetDomainRequest{Name: domain}) switch err.(type) { case nil: // noop @@ -372,7 +372,7 @@ func (s *Service) ensureDomainExists(domain string) { func (s *Service) registerSystemDomain(domain string) { currentClusterName := s.GetClusterMetadata().GetCurrentClusterName() - _, err := s.GetMetadataManager().CreateDomain(context.Background(), &persistence.CreateDomainRequest{ + _, err := s.GetDomainManager().CreateDomain(context.Background(), &persistence.CreateDomainRequest{ Info: &persistence.DomainInfo{ ID: getDomainID(domain), Name: domain, diff --git a/tools/cli/domainUtils.go b/tools/cli/domainUtils.go index 7cb09c44f92..9e02a79b068 100644 --- a/tools/cli/domainUtils.go +++ b/tools/cli/domainUtils.go @@ -249,7 +249,7 @@ func initializeAdminDomainHandler( configuration, logger, ) - metadataMgr := initializeMetadataMgr( + metadataMgr := initializeDomainMgr( configuration, clusterMetadata, metricsClient, @@ -281,7 +281,7 @@ func loadConfig( func initializeDomainHandler( logger log.Logger, - metadataMgr persistence.MetadataManager, + domainManager persistence.DomainManager, clusterMetadata cluster.Metadata, archivalMetadata archiver.ArchivalMetadata, archiverProvider provider.ArchiverProvider, @@ -295,7 +295,7 @@ func initializeDomainHandler( return domain.NewHandler( domainConfig, logger, - metadataMgr, + domainManager, clusterMetadata, initializeDomainReplicator(logger), archivalMetadata, @@ -314,12 +314,12 @@ func initializeLogger( return loggerimpl.NewLogger(zapLogger) } -func initializeMetadataMgr( +func initializeDomainMgr( serviceConfig *config.Config, clusterMetadata cluster.Metadata, metricsClient metrics.Client, logger log.Logger, -) persistence.MetadataManager { +) persistence.DomainManager { pConfig := serviceConfig.Persistence pFactory := client.NewFactory( @@ -329,7 +329,7 @@ func initializeMetadataMgr( metricsClient, logger, ) - metadata, err := pFactory.NewMetadataManager() + metadata, err := pFactory.NewDomainManager() if err != nil { ErrorAndExit("Unable to initialize metadata manager.", err) }