757
initialIndexSearchAttributes map[string]*persistencespb.IndexSearchAttributes,
758
logger log.Logger,
760
>
var clusterId string
761
>
currentClusterName := svc.ClusterMetadata.CurrentClusterName
762
>
currentClusterInfo := svc.ClusterMetadata.ClusterInformation[currentClusterName]
763
>
if uuid.Validate(currentClusterInfo.ClusterID) != nil {
764
>
if currentClusterInfo.ClusterID != "" {
765
logger.Warn("Cluster Id in Cluster Metadata config is not a valid uuid. Generating a new Cluster Id")
766
}
767
>
clusterId = uuid.NewString()
fx.go
768
} else {
769
clusterId = currentClusterInfo.ClusterID
770
}
771
772
>
applied, err := clusterMetadataManager.SaveClusterMetadata(
fx.go
773
>
ctx,
774
>
&persistence.SaveClusterMetadataRequest{
775
>
ClusterMetadata: &persistencespb.ClusterMetadata{
776
>
HistoryShardCount: svc.Persistence.NumHistoryShards,
777
>
ClusterName: currentClusterName,
778
>
ClusterId: clusterId,
779
>
ClusterAddress: currentClusterInfo.RPCAddress,
780
>
HttpAddress: currentClusterInfo.HTTPAddress,
781
>
FailoverVersionIncrement: svc.ClusterMetadata.FailoverVersionIncrement,
782
>
InitialFailoverVersion: currentClusterInfo.InitialFailoverVersion,
783
>
IsGlobalNamespaceEnabled: svc.ClusterMetadata.EnableGlobalNamespace,
784
>
IsConnectionEnabled: currentClusterInfo.Enabled,
785
>
UseClusterIdMembership: true, // Enable this for new cluster after 1.19. This is to prevent two clusters join into one ring.
786
>
IndexSearchAttributes: initialIndexSearchAttributes,
787
>
Tags: svc.ClusterMetadata.Tags,
788
>
},
789
>
})
790
>
if err != nil {
791
logger.Warn("Failed to save cluster metadata.", tag.Error(err), tag.ClusterName(currentClusterName))
792
return err
793
}
794
>
if !applied {
fx.go
795
logger.Error("Failed to apply cluster metadata.", tag.ClusterName(currentClusterName))
796
return clusterMetadataInitErr
797
}
799
}
800