diff --git a/service/frontend/adminHandler.go b/service/frontend/adminHandler.go index fcdb186b191..04cbeb8a02b 100644 --- a/service/frontend/adminHandler.go +++ b/service/frontend/adminHandler.go @@ -31,7 +31,9 @@ import ( gen "github.com/uber/cadence/.gen/go/shared" "github.com/uber/cadence/client/history" "github.com/uber/cadence/common" + "github.com/uber/cadence/common/cache" "github.com/uber/cadence/common/logging" + "github.com/uber/cadence/common/persistence" "github.com/uber/cadence/common/service" ) @@ -42,16 +44,18 @@ type ( AdminHandler struct { numberOfHistoryShards int service.Service - history history.Client + history history.Client + domainCache cache.DomainCache } ) // NewAdminHandler creates a thrift handler for the cadence admin service func NewAdminHandler( - sVice service.Service, numberOfHistoryShards int) *AdminHandler { + sVice service.Service, numberOfHistoryShards int, metadataMgr persistence.MetadataManager) *AdminHandler { handler := &AdminHandler{ numberOfHistoryShards: numberOfHistoryShards, Service: sVice, + domainCache: cache.NewDomainCache(metadataMgr, sVice.GetClusterMetadata(), sVice.GetLogger()), } return handler } @@ -60,6 +64,7 @@ func NewAdminHandler( func (adh *AdminHandler) Start() error { adh.Service.GetDispatcher().Register(adminserviceserver.New(adh)) adh.Service.Start() + adh.domainCache.Start() var err error adh.history, err = adh.Service.GetClientFactory().NewHistoryClient() if err != nil { @@ -70,6 +75,7 @@ func (adh *AdminHandler) Start() error { // Stop stops the handler func (adh *AdminHandler) Stop() { + adh.domainCache.Stop() adh.Service.Stop() } @@ -92,11 +98,16 @@ func (adh *AdminHandler) DescribeWorkflowExecution(ctx context.Context, request return nil, adh.error(err) } + domainID, err := adh.domainCache.GetDomainID(request.GetDomain()) + historyAddr := historyHost.GetAddress() resp, err := adh.history.DescribeMutableState(ctx, &hist.DescribeMutableStateRequest{ - DomainUUID: request.Domain, + DomainUUID: &domainID, Execution: request.Execution, }) + if err != nil { + return &admin.DescribeWorkflowExecutionResponse{}, err + } return &admin.DescribeWorkflowExecutionResponse{ ShardId: common.StringPtr(shardIDForOutput), HistoryAddr: common.StringPtr(historyAddr), diff --git a/service/frontend/service.go b/service/frontend/service.go index bb0bc484279..a171f516b3e 100644 --- a/service/frontend/service.go +++ b/service/frontend/service.go @@ -130,7 +130,7 @@ func (s *Service) Start() { wfHandler := NewWorkflowHandler(base, s.config, metadata, history, visibility, kafkaProducer) wfHandler.Start() - adminHandler := NewAdminHandler(base, p.CassandraConfig.NumHistoryShards) + adminHandler := NewAdminHandler(base, p.CassandraConfig.NumHistoryShards, metadata) adminHandler.Start() log.Infof("%v started", common.FrontendServiceName)