@@ -245,25 +245,7 @@ func (m *managerImpl) LookupNewWorkflow(ctx context.Context, domainID string, po
245245 }, nil
246246 }
247247
248- if policy .GetStrategy () != types .ActiveClusterSelectionStrategyExternalEntity {
249- return nil , fmt .Errorf ("unsupported active cluster selection strategy: %s" , policy .GetStrategy ())
250- }
251-
252- // find cluster name & failover version of the external entity
253- externalEntity , err := m .getExternalEntity (ctx , policy .ExternalEntityType , policy .ExternalEntityKey )
254- if err != nil {
255- return nil , err
256- }
257- cluster , err := m .ClusterNameForFailoverVersion (externalEntity .FailoverVersion , domainID )
258- if err != nil {
259- return nil , err
260- }
261-
262- return & LookupResult {
263- Region : externalEntity .Region ,
264- ClusterName : cluster ,
265- FailoverVersion : externalEntity .FailoverVersion ,
266- }, nil
248+ return nil , fmt .Errorf ("unsupported active cluster selection strategy: %s" , policy .GetStrategy ())
267249}
268250
269251func (m * managerImpl ) LookupWorkflow (ctx context.Context , domainID , wfID , rID string ) (res * LookupResult , e error ) {
@@ -345,7 +327,7 @@ func (m *managerImpl) LookupWorkflow(ctx context.Context, domainID, wfID, rID st
345327 return nil , err
346328 }
347329
348- cluster , err := m .ClusterNameForFailoverVersion (externalEntity .FailoverVersion , domainID )
330+ cluster , err := m .clusterMetadata . ClusterNameForFailoverVersion (externalEntity .FailoverVersion )
349331 if err != nil {
350332 return nil , err
351333 }
@@ -398,88 +380,6 @@ func (m *managerImpl) LookupWorkflow(ctx context.Context, domainID, wfID, rID st
398380 }, nil
399381}
400382
401- func (m * managerImpl ) LookupCluster (ctx context.Context , domainID , clusterName string ) (res * LookupResult , e error ) {
402- d , scope , err := m .getDomainAndScope (domainID , LookupClusterOpName )
403- if err != nil {
404- return nil , err
405- }
406- defer m .handleError (scope , & e , time .Now ())
407-
408- clusterInfo , ok := m .clusterMetadata .GetAllClusterInfo ()[clusterName ]
409- if ! ok {
410- return nil , newClusterNotFoundError (clusterName )
411- }
412-
413- if ! d .GetReplicationConfig ().IsActiveActive () {
414- // Not an active-active domain. return ActiveClusterName from domain entry
415- m .logger .Debug ("LookupCluster: not an active-active domain. returning given clusterName" ,
416- tag .WorkflowDomainID (domainID ),
417- tag .ClusterName (clusterName ),
418- )
419-
420- return & LookupResult {
421- ClusterName : clusterName ,
422- FailoverVersion : clusterInfo .InitialFailoverVersion ,
423- Region : clusterInfo .Region ,
424- }, nil
425- }
426-
427- region := clusterInfo .Region
428- activeCluster , ok := d .GetReplicationConfig ().ActiveClusters .ActiveClustersByRegion [region ]
429- if ! ok {
430- return nil , newRegionNotFoundForDomainError (region , domainID )
431- }
432-
433- return & LookupResult {
434- Region : region ,
435- ClusterName : activeCluster .ActiveClusterName ,
436- FailoverVersion : activeCluster .FailoverVersion ,
437- }, nil
438- }
439-
440- func (m * managerImpl ) ClusterNameForFailoverVersion (failoverVersion int64 , domainID string ) (string , error ) {
441- d , err := m .domainIDToDomainFn (domainID )
442- if err != nil {
443- return "" , err
444- }
445-
446- if ! d .GetReplicationConfig ().IsActiveActive () {
447- cluster , err := m .clusterMetadata .ClusterNameForFailoverVersion (failoverVersion )
448- if err != nil {
449- return "" , err
450- }
451- return cluster , nil
452- }
453-
454- // For active-active domains, the failover version might be mapped to a cluster or a region
455- // First check if it maps to a cluster
456- cluster , err := m .clusterMetadata .ClusterNameForFailoverVersion (failoverVersion )
457- if err == nil {
458- // failover version belongs to a cluster.
459- return cluster , nil
460- }
461-
462- // Check if it maps to a region.
463- region , err := m .clusterMetadata .RegionForFailoverVersion (failoverVersion )
464- if err != nil {
465- return "" , err
466- }
467-
468- // Now we know the region, find the cluster in the domain's active cluster list which belongs to the region
469- cfg , ok := d .GetReplicationConfig ().ActiveClusters .ActiveClustersByRegion [region ]
470- if ! ok {
471- return "" , newRegionNotFoundForDomainError (region , domainID )
472- }
473-
474- allClusters := m .clusterMetadata .GetAllClusterInfo ()
475- _ , ok = allClusters [cfg .ActiveClusterName ]
476- if ! ok {
477- return "" , newClusterNotFoundForRegionError (cfg .ActiveClusterName , region )
478- }
479-
480- return cfg .ActiveClusterName , nil
481- }
482-
483383func (m * managerImpl ) RegisterChangeCallback (shardID int , callback func (ChangeType )) {
484384 m .changeCallbacksLock .Lock ()
485385 defer m .changeCallbacksLock .Unlock ()
0 commit comments