cluster

package
v1.23.0-rc9 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: MIT Imports: 20 Imported by: 5

Documentation

Overview

Package cluster is a generated GoMock package.

Index

Constants

View Source
const (
	// TestCurrentClusterInitialFailoverVersion is initial failover version for current cluster
	TestCurrentClusterInitialFailoverVersion = int64(1)
	// TestAlternativeClusterInitialFailoverVersion is initial failover version for alternative cluster
	TestAlternativeClusterInitialFailoverVersion = 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"
	// TestCurrentClusterFrontendAddress is the ip port address of current cluster
	TestCurrentClusterFrontendAddress = "127.0.0.1:7134"
	// TestAlternativeClusterFrontendAddress is the ip port address of alternative cluster
	TestAlternativeClusterFrontendAddress = "127.0.0.1:8134"
)

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]ClusterInformation{
		TestCurrentClusterName: {
			Enabled:                true,
			InitialFailoverVersion: TestCurrentClusterInitialFailoverVersion,
			RPCAddress:             TestCurrentClusterFrontendAddress,
			ShardCount:             8,
		},
		TestAlternativeClusterName: {
			Enabled:                true,
			InitialFailoverVersion: TestAlternativeClusterInitialFailoverVersion,
			RPCAddress:             TestAlternativeClusterFrontendAddress,
			ShardCount:             4,
		},
	}

	// 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]ClusterInformation{
		TestCurrentClusterName: {
			Enabled:                true,
			InitialFailoverVersion: TestCurrentClusterInitialFailoverVersion,
			RPCAddress:             TestCurrentClusterFrontendAddress,
		},
	}
)
View Source
var MetadataLifetimeHooksModule = fx.Options(
	fx.Provide(NewMetadataFromConfig),
	fx.Invoke(MetadataLifetimeHooks),
	fx.Provide(fx.Annotate(
		func(p Metadata) common.Pingable { return p },
		fx.ResultTags(`group:"deadlockDetectorRoots"`),
	)),
)

Functions

func MetadataLifetimeHooks added in v1.14.4

func MetadataLifetimeHooks(
	lc fx.Lifecycle,
	clusterMetadata Metadata,
)

Types

type CallbackFn added in v1.14.0

type CallbackFn func(oldClusterMetadata map[string]*ClusterInformation, newClusterMetadata map[string]*ClusterInformation)

type ClusterInformation added in v1.14.0

type ClusterInformation struct {
	Enabled                bool  `yaml:"enabled"`
	InitialFailoverVersion int64 `yaml:"initialFailoverVersion"`
	// Address indicate the remote service address(Host:Port). Host can be DNS name.
	RPCAddress string `yaml:"rpcAddress"`
	// Cluster ID allows to explicitly set the ID of the cluster. Optional.
	ClusterID  string            `yaml:"-"`
	ShardCount int32             `yaml:"-"` // Ignore this field when loading config.
	Tags       map[string]string `yaml:"-"` // Ignore this field. Use cluster.Config.Tags for customized tags.
	// contains filtered or unexported fields
}

ClusterInformation contains the information about each cluster which participated in cross DC

type Config added in v1.14.0

type Config struct {
	EnableGlobalNamespace bool `yaml:"enableGlobalNamespace"`
	// FailoverVersionIncrement is the increment of each cluster version when failover happens
	FailoverVersionIncrement int64 `yaml:"failoverVersionIncrement"`
	// MasterClusterName is the master cluster name, only the master cluster can register / update namespace
	// all clusters can do namespace failover
	MasterClusterName string `yaml:"masterClusterName"`
	// CurrentClusterName is the name of the current cluster
	CurrentClusterName string `yaml:"currentClusterName"`
	// ClusterInformation contains all cluster names to corresponding information about that cluster
	ClusterInformation map[string]ClusterInformation `yaml:"clusterInformation"`
	// Tag contains customized tag about the current cluster
	Tags map[string]string `yaml:"tags"`
}

Config contains the all cluster which participated in cross DC

func NewTestClusterMetadataConfig added in v1.10.0

func NewTestClusterMetadataConfig(enableGlobalNamespace bool, isMasterCluster bool) *Config

NewTestClusterMetadataConfig return an cluster metadata config

type Metadata

type Metadata interface {
	common.Pingable

	// IsGlobalNamespaceEnabled whether the global namespace is enabled,
	// this attr should be discarded when cross DC is made public
	IsGlobalNamespaceEnabled() bool
	// IsMasterCluster whether current cluster is master cluster
	IsMasterCluster() bool
	// GetClusterID return the cluster ID, which is also the initial failover version
	GetClusterID() int64
	// GetNextFailoverVersion return the next failover version for namespace failover
	GetNextFailoverVersion(string, int64) int64
	// IsVersionFromSameCluster return true if 2 version are used for the same cluster
	IsVersionFromSameCluster(version1 int64, version2 int64) bool
	// GetMasterClusterName return the master cluster name
	GetMasterClusterName() string
	// GetCurrentClusterName return the current cluster name
	GetCurrentClusterName() string
	// GetAllClusterInfo return the all cluster name -> corresponding info
	GetAllClusterInfo() map[string]ClusterInformation
	// ClusterNameForFailoverVersion return the corresponding cluster name for a given failover version
	ClusterNameForFailoverVersion(isGlobalNamespace bool, failoverVersion int64) string
	// GetFailoverVersionIncrement return the Failover version increment value
	GetFailoverVersionIncrement() int64
	RegisterMetadataChangeCallback(callbackId any, cb CallbackFn)
	UnRegisterMetadataChangeCallback(callbackId any)
	Start()
	Stop()
}

func NewMetadata

func NewMetadata(
	enableGlobalNamespace bool,
	failoverVersionIncrement int64,
	masterClusterName string,
	currentClusterName string,
	clusterInfo map[string]ClusterInformation,
	clusterMetadataStore persistence.ClusterMetadataManager,
	refreshDuration dynamicconfig.DurationPropertyFn,
	logger log.Logger,
) Metadata

func NewMetadataForTest added in v1.14.0

func NewMetadataForTest(
	config *Config,
) Metadata

func NewMetadataFromConfig added in v1.14.0

func NewMetadataFromConfig(
	config *Config,
	clusterMetadataStore persistence.ClusterMetadataManager,
	dynamicCollection *dynamicconfig.Collection,
	logger log.Logger,
) Metadata

type MockMetadata added in v0.27.0

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

MockMetadata is a mock of Metadata interface.

func NewMockMetadata added in v0.27.0

func NewMockMetadata(ctrl *gomock.Controller) *MockMetadata

NewMockMetadata creates a new mock instance.

func (*MockMetadata) ClusterNameForFailoverVersion added in v0.27.0

func (m *MockMetadata) ClusterNameForFailoverVersion(isGlobalNamespace bool, failoverVersion int64) string

ClusterNameForFailoverVersion mocks base method.

func (*MockMetadata) EXPECT added in v0.27.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockMetadata) GetAllClusterInfo added in v0.27.0

func (m *MockMetadata) GetAllClusterInfo() map[string]ClusterInformation

GetAllClusterInfo mocks base method.

func (*MockMetadata) GetClusterID added in v1.17.0

func (m *MockMetadata) GetClusterID() int64

GetClusterID mocks base method.

func (*MockMetadata) GetCurrentClusterName added in v0.27.0

func (m *MockMetadata) GetCurrentClusterName() string

GetCurrentClusterName mocks base method.

func (*MockMetadata) GetFailoverVersionIncrement added in v1.14.0

func (m *MockMetadata) GetFailoverVersionIncrement() int64

GetFailoverVersionIncrement mocks base method.

func (*MockMetadata) GetMasterClusterName added in v0.27.0

func (m *MockMetadata) GetMasterClusterName() string

GetMasterClusterName mocks base method.

func (*MockMetadata) GetNextFailoverVersion added in v0.27.0

func (m *MockMetadata) GetNextFailoverVersion(arg0 string, arg1 int64) int64

GetNextFailoverVersion mocks base method.

func (*MockMetadata) GetPingChecks added in v1.19.0

func (m *MockMetadata) GetPingChecks() []common.PingCheck

GetPingChecks mocks base method.

func (*MockMetadata) IsGlobalNamespaceEnabled added in v0.27.0

func (m *MockMetadata) IsGlobalNamespaceEnabled() bool

IsGlobalNamespaceEnabled mocks base method.

func (*MockMetadata) IsMasterCluster added in v0.27.0

func (m *MockMetadata) IsMasterCluster() bool

IsMasterCluster mocks base method.

func (*MockMetadata) IsVersionFromSameCluster added in v0.27.0

func (m *MockMetadata) IsVersionFromSameCluster(version1, version2 int64) bool

IsVersionFromSameCluster mocks base method.

func (*MockMetadata) RegisterMetadataChangeCallback added in v1.14.0

func (m *MockMetadata) RegisterMetadataChangeCallback(callbackId any, cb CallbackFn)

RegisterMetadataChangeCallback mocks base method.

func (*MockMetadata) Start added in v1.14.0

func (m *MockMetadata) Start()

Start mocks base method.

func (*MockMetadata) Stop added in v1.14.0

func (m *MockMetadata) Stop()

Stop mocks base method.

func (*MockMetadata) UnRegisterMetadataChangeCallback added in v1.14.0

func (m *MockMetadata) UnRegisterMetadataChangeCallback(callbackId any)

UnRegisterMetadataChangeCallback mocks base method.

type MockMetadataMockRecorder added in v0.27.0

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

MockMetadataMockRecorder is the mock recorder for MockMetadata.

func (*MockMetadataMockRecorder) ClusterNameForFailoverVersion added in v0.27.0

func (mr *MockMetadataMockRecorder) ClusterNameForFailoverVersion(isGlobalNamespace, failoverVersion interface{}) *gomock.Call

ClusterNameForFailoverVersion indicates an expected call of ClusterNameForFailoverVersion.

func (*MockMetadataMockRecorder) GetAllClusterInfo added in v0.27.0

func (mr *MockMetadataMockRecorder) GetAllClusterInfo() *gomock.Call

GetAllClusterInfo indicates an expected call of GetAllClusterInfo.

func (*MockMetadataMockRecorder) GetClusterID added in v1.17.0

func (mr *MockMetadataMockRecorder) GetClusterID() *gomock.Call

GetClusterID indicates an expected call of GetClusterID.

func (*MockMetadataMockRecorder) GetCurrentClusterName added in v0.27.0

func (mr *MockMetadataMockRecorder) GetCurrentClusterName() *gomock.Call

GetCurrentClusterName indicates an expected call of GetCurrentClusterName.

func (*MockMetadataMockRecorder) GetFailoverVersionIncrement added in v1.14.0

func (mr *MockMetadataMockRecorder) GetFailoverVersionIncrement() *gomock.Call

GetFailoverVersionIncrement indicates an expected call of GetFailoverVersionIncrement.

func (*MockMetadataMockRecorder) GetMasterClusterName added in v0.27.0

func (mr *MockMetadataMockRecorder) GetMasterClusterName() *gomock.Call

GetMasterClusterName indicates an expected call of GetMasterClusterName.

func (*MockMetadataMockRecorder) GetNextFailoverVersion added in v0.27.0

func (mr *MockMetadataMockRecorder) GetNextFailoverVersion(arg0, arg1 interface{}) *gomock.Call

GetNextFailoverVersion indicates an expected call of GetNextFailoverVersion.

func (*MockMetadataMockRecorder) GetPingChecks added in v1.19.0

func (mr *MockMetadataMockRecorder) GetPingChecks() *gomock.Call

GetPingChecks indicates an expected call of GetPingChecks.

func (*MockMetadataMockRecorder) IsGlobalNamespaceEnabled added in v0.27.0

func (mr *MockMetadataMockRecorder) IsGlobalNamespaceEnabled() *gomock.Call

IsGlobalNamespaceEnabled indicates an expected call of IsGlobalNamespaceEnabled.

func (*MockMetadataMockRecorder) IsMasterCluster added in v0.27.0

func (mr *MockMetadataMockRecorder) IsMasterCluster() *gomock.Call

IsMasterCluster indicates an expected call of IsMasterCluster.

func (*MockMetadataMockRecorder) IsVersionFromSameCluster added in v0.27.0

func (mr *MockMetadataMockRecorder) IsVersionFromSameCluster(version1, version2 interface{}) *gomock.Call

IsVersionFromSameCluster indicates an expected call of IsVersionFromSameCluster.

func (*MockMetadataMockRecorder) RegisterMetadataChangeCallback added in v1.14.0

func (mr *MockMetadataMockRecorder) RegisterMetadataChangeCallback(callbackId, cb interface{}) *gomock.Call

RegisterMetadataChangeCallback indicates an expected call of RegisterMetadataChangeCallback.

func (*MockMetadataMockRecorder) Start added in v1.14.0

func (mr *MockMetadataMockRecorder) Start() *gomock.Call

Start indicates an expected call of Start.

func (*MockMetadataMockRecorder) Stop added in v1.14.0

func (mr *MockMetadataMockRecorder) Stop() *gomock.Call

Stop indicates an expected call of Stop.

func (*MockMetadataMockRecorder) UnRegisterMetadataChangeCallback added in v1.14.0

func (mr *MockMetadataMockRecorder) UnRegisterMetadataChangeCallback(callbackId interface{}) *gomock.Call

UnRegisterMetadataChangeCallback indicates an expected call of UnRegisterMetadataChangeCallback.

Jump to

Keyboard shortcuts

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