cluster

package
v0.0.0-...-2c42c2a Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterConfig

type ClusterConfig struct {
	Fs                       afero.Fs
	NumNodes                 int
	ManageOracleTickInterval time.Duration
	RaftSnapCount            uint64
}

ClusterConfig describes the config to start testcluster with.

type ClusterTime

type ClusterTime map[int]int64

ClusterTime is the time on all the nodes.

func (ClusterTime) Relative

func (ct ClusterTime) Relative() map[int]time.Duration

Relative gives the relative time of all the nodes in the cluster, wrt the minimum time on the nodes. eg.[1,2,3] - [0,1,2]. It is used for pretty printing of ClusterTime.

func (ClusterTime) Since

func (ct ClusterTime) Since(pastTime ClusterTime) map[int]time.Duration

Since gives the time passed on all the nodes since pastTime was captured.

type ErrMultipleOracles

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

ErrMultipleOracles is returned in case different nodes consider different servers as oracle. It contains the list of oracles according to each node.

func (*ErrMultipleOracles) Error

func (e *ErrMultipleOracles) Error() string

type Operation

type Operation uint16

Operation denotes the operation supported by goreman on clusters

const (
	// Start a node
	Start Operation = iota
	// Stop a node
	Stop
	// Restart a node
	Restart
)

func (Operation) String

func (op Operation) String() string

type TestCluster

type TestCluster struct {
	Nodes                    []*testNode
	ManageOracleTickInterval time.Duration
	CertsDir                 string
	RaftSnapCount            uint64
	ErrCh                    chan error
	// contains filtered or unexported fields
}

TestCluster is a kronos test cluster, that can be used to test kronos in various scenarios.

func NewCluster

func NewCluster(ctx context.Context, cc ClusterConfig) (*TestCluster, error)

NewCluster returns an instance of a test kronos cluster. It returns - The test_cluster - Error if any while creating the testcluster TestCluster should be closed using Close method once test is finished. This returns a cluster which runs in secure mode.

func NewInsecureCluster

func NewInsecureCluster(ctx context.Context, cc ClusterConfig) (*TestCluster, error)

NewInsecureCluster returns an instance of a test kronos cluster. It returns - The test_cluster - Error if any while creating the testcluster TestCluster should be closed using Close method once test is finished. This returns a cluster which runs in insecure mode.

func (*TestCluster) AddNode

func (tc *TestCluster) AddNode(ctx context.Context, idx int) (string, error)

AddNode adds a new node to testCluster and returns the newly assigned nodeID.

func (*TestCluster) Backup

func (tc *TestCluster) Backup(ctx context.Context, idx int) error

Backup backs up cluster metadata of node idx

func (*TestCluster) Close

func (tc *TestCluster) Close() error

Close closes the testcluster.

func (*TestCluster) GetClockConfig

func (tc *TestCluster) GetClockConfig(ctx context.Context, nodeIdx int) *kronospb.DriftTimeConfig

GetClockConfig is used to get the drifting clock config for nodeidx node.

func (*TestCluster) IsRunning

func (tc *TestCluster) IsRunning(nodeIdx int) bool

IsRunning is used to check if nodeIdx node is running or has been stopped.

func (*TestCluster) Oracle

func (tc *TestCluster) Oracle(
	ctx context.Context, checkOnlyRunningNodes bool,
) (oracleIdx int, err error)

Oracle validates that all the nodes in the cluster think that a single node is the oracle and returns that oracle. If two or more nodes consider different nodes as oracle, then this will return an error with what every node thinks is the oracle.

func (*TestCluster) OracleForNode

func (tc *TestCluster) OracleForNode(ctx context.Context, nodeIdx int) (int, error)

OracleForNode is used to get the current oracle according to node nodeIdx.

func (*TestCluster) ReIP

func (tc *TestCluster) ReIP(ctx context.Context) error

ReIP simulates re-ip in testcluster by changing raft ports of all the nodes in the cluster.

func (*TestCluster) RemoveNode

func (tc *TestCluster) RemoveNode(ctx context.Context, idx int) error

RemoveNode removes a node from testCluster and wipes it's data directory

func (*TestCluster) Restore

func (tc *TestCluster) Restore(ctx context.Context, idx int) error

Restore restores cluster metadata of node idx backed up a previous backup

func (*TestCluster) RunOperation

func (tc *TestCluster) RunOperation(ctx context.Context, op Operation, indices ...int) error

RunOperation can be used to start, stop, restart nodes of test cluster tc.

func (*TestCluster) Status

func (tc *TestCluster) Status(hostIdx int, local bool) ([]byte, error)

Status returns kronos status fetched via hostIdx

func (*TestCluster) Time

func (tc *TestCluster) Time(ctx context.Context, nodeIdx int) (int64, error)

Time is used to get kronos time of node nodeIdx.

func (*TestCluster) UpdateClockConfig

func (tc *TestCluster) UpdateClockConfig(
	ctx context.Context, nodeIdx int, config *kronospb.DriftTimeConfig,
) error

UpdateClockConfig is used to update the drifting clock config for nodeidx node.

func (*TestCluster) ValidateTimeInConsensus

func (tc *TestCluster) ValidateTimeInConsensus(
	ctx context.Context, maxDiffAllowed time.Duration, checkOnlyRunningNodes bool,
) (ClusterTime, error)

ValidateTimeInConsensus validates time across the cluster(difference between maxTime and minTime) is within maxDiffAllowed for the running nodes. It returns ClusterTime which is a map of NodeID to time.

Jump to

Keyboard shortcuts

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