cluster

package
v1.2.13-prerelease07 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2024 License: MIT Imports: 10 Imported by: 20

Documentation

Index

Constants

View Source
const (
	// TestCurrentClusterInitialFailoverVersion is initial failover version for current cluster
	TestCurrentClusterInitialFailoverVersion = int64(0)
	// TestAlternativeClusterInitialFailoverVersion is initial failover version for alternative cluster
	TestAlternativeClusterInitialFailoverVersion = int64(1)
	// TestDisabledClusterInitialFailoverVersion is initial failover version for disabled cluster
	TestDisabledClusterInitialFailoverVersion = int64(2)
	// TestFailoverVersionIncrement is failover version increment used for test
	TestFailoverVersionIncrement = int64(10)
	// TestCurrentClusterName is current cluster used for test
	TestCurrentClusterName = "active"
	// TestAlternativeClusterName is alternative cluster used for test
	TestAlternativeClusterName = "standby"
	// TestDisabledClusterName is disabled cluster used for test
	TestDisabledClusterName = "disabled"
	// TestCurrentClusterFrontendAddress is the ip port address of current cluster
	TestCurrentClusterFrontendAddress = "127.0.0.1:7104"
	// TestAlternativeClusterFrontendAddress is the ip port address of alternative cluster
	TestAlternativeClusterFrontendAddress = "127.0.0.1:8104"
	// TestClusterXDCTransport is the RPC transport used for XDC traffic <tchannel|grpc>
	TestClusterXDCTransport = "grpc"
)

Variables

View Source
var (
	// TestAllClusterNames is the all cluster names used for test
	TestAllClusterNames = []string{TestCurrentClusterName, TestAlternativeClusterName}
	// TestAllClusterInfo is the same as above, just convenient for test mocking
	TestAllClusterInfo = map[string]config.ClusterInformation{
		TestCurrentClusterName: {
			Enabled:                true,
			InitialFailoverVersion: TestCurrentClusterInitialFailoverVersion,
			RPCName:                service.Frontend,
			RPCAddress:             TestCurrentClusterFrontendAddress,
			RPCTransport:           TestClusterXDCTransport,
		},
		TestAlternativeClusterName: {
			Enabled:                true,
			InitialFailoverVersion: TestAlternativeClusterInitialFailoverVersion,
			RPCName:                service.Frontend,
			RPCAddress:             TestAlternativeClusterFrontendAddress,
			RPCTransport:           TestClusterXDCTransport,
		},
		TestDisabledClusterName: {
			Enabled:                false,
			InitialFailoverVersion: TestDisabledClusterInitialFailoverVersion,
		},
	}

	// TestSingleDCAllClusterNames is the all cluster names used for test
	TestSingleDCAllClusterNames = []string{TestCurrentClusterName}
	// TestSingleDCClusterInfo is the same as above, just convenient for test mocking
	TestSingleDCClusterInfo = map[string]config.ClusterInformation{
		TestCurrentClusterName: {
			Enabled:                true,
			InitialFailoverVersion: TestCurrentClusterInitialFailoverVersion,
			RPCName:                service.Frontend,
			RPCAddress:             TestCurrentClusterFrontendAddress,
			RPCTransport:           TestClusterXDCTransport,
		},
	}

	// TestActiveClusterMetadata is metadata for an active cluster
	TestActiveClusterMetadata = NewMetadata(
		TestFailoverVersionIncrement,
		TestCurrentClusterName,
		TestCurrentClusterName,
		TestAllClusterInfo,
		func(d string) bool { return false },
		commonMetrics.NewNoopMetricsClient(),
		loggerimpl.NewNopLogger(),
	)

	// TestPassiveClusterMetadata is metadata for a passive cluster
	TestPassiveClusterMetadata = NewMetadata(
		TestFailoverVersionIncrement,
		TestCurrentClusterName,
		TestAlternativeClusterName,
		TestAllClusterInfo,
		func(d string) bool { return false },
		commonMetrics.NewNoopMetricsClient(),
		loggerimpl.NewNopLogger(),
	)
)

Functions

func GetOrUseDefaultActiveCluster added in v0.22.0

func GetOrUseDefaultActiveCluster(currentClusterName string, activeClusterName string) string

GetOrUseDefaultActiveCluster return the current cluster name or use the input if valid

func GetOrUseDefaultClusters added in v0.22.0

func GetOrUseDefaultClusters(currentClusterName string, clusters []*persistence.ClusterReplicationConfig) []*persistence.ClusterReplicationConfig

GetOrUseDefaultClusters return the current cluster or use the input if valid

Types

type Metadata

type Metadata struct {
	// contains filtered or unexported fields
}

Metadata provides information about clusters

func GetTestClusterMetadata added in v0.3.11

func GetTestClusterMetadata(isPrimaryCluster bool) Metadata

GetTestClusterMetadata return an cluster metadata instance, which is initialized

func NewMetadata

func NewMetadata(
	failoverVersionIncrement int64,
	primaryClusterName string,
	currentClusterName string,
	clusterGroup map[string]config.ClusterInformation,
	useMinFailoverVersionOverrideConfig dynamicconfig.BoolPropertyFnWithDomainFilter,
	metricsClient metrics.Client,
	logger log.Logger,
) Metadata

NewMetadata create a new instance of Metadata

func (Metadata) ClusterNameForFailoverVersion added in v0.3.11

func (m Metadata) ClusterNameForFailoverVersion(failoverVersion int64) (string, error)

ClusterNameForFailoverVersion return the corresponding cluster name for a given failover version

func (Metadata) GetAllClusterInfo added in v0.5.8

func (m Metadata) GetAllClusterInfo() map[string]config.ClusterInformation

GetAllClusterInfo return all cluster info

func (Metadata) GetCurrentClusterName

func (m Metadata) GetCurrentClusterName() string

GetCurrentClusterName return the current cluster name

func (Metadata) GetEnabledClusterInfo added in v0.25.0

func (m Metadata) GetEnabledClusterInfo() map[string]config.ClusterInformation

GetEnabledClusterInfo return enabled cluster info

func (Metadata) GetNextFailoverVersion

func (m Metadata) GetNextFailoverVersion(cluster string, currentFailoverVersion int64, domainName string) int64

GetNextFailoverVersion return the next failover version based on input

func (Metadata) GetRemoteClusterInfo added in v0.25.0

func (m Metadata) GetRemoteClusterInfo() map[string]config.ClusterInformation

GetRemoteClusterInfo return enabled AND remote cluster info

func (Metadata) IsPrimaryCluster added in v0.22.0

func (m Metadata) IsPrimaryCluster() bool

func (Metadata) IsVersionFromSameCluster added in v0.3.14

func (m Metadata) IsVersionFromSameCluster(version1 int64, version2 int64) bool

IsVersionFromSameCluster return true if the new version is used for the same cluster

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL