zkctl

package
v0.20.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: Apache-2.0 Imports: 16 Imported by: 4

Documentation

Index

Constants

View Source
const GuessMyID = 0

Variables

This section is empty.

Functions

func MakeZooCfg

func MakeZooCfg(cnfFiles []string, cnf *ZkConfig, header string) (string, error)

Search for first existing file in cnfFiles and subsitute in the right values.

Types

type ZkConfig

type ZkConfig struct {
	ServerId   uint32 // nolint:revive
	ClientPort int
	Servers    []zkServerAddr
	Extra      []string
	Global     bool
}

func MakeZkConfigFromString

func MakeZkConfigFromString(cmdLine string, myID uint32) *ZkConfig

Create a config for this instance.

<server_id>@<hostname>:<leader_port>:<election_port>:<client_port>

If server_id > 1000, then we assume this is a global quorum. server_id's must be 1-255, global id's are 1001-1255 mod 1000.

func NewZkConfig

func NewZkConfig() *ZkConfig

ServerId is a unique id for a server - must be 1-255

func (*ZkConfig) ConfigFile

func (cnf *ZkConfig) ConfigFile() string

func (*ZkConfig) DataDir

func (cnf *ZkConfig) DataDir() string

func (*ZkConfig) DirectoryList

func (cnf *ZkConfig) DirectoryList() []string

func (*ZkConfig) LogDir

func (cnf *ZkConfig) LogDir() string

func (*ZkConfig) MyidFile

func (cnf *ZkConfig) MyidFile() string

func (*ZkConfig) PidFile

func (cnf *ZkConfig) PidFile() string

func (*ZkConfig) WriteMyid

func (cnf *ZkConfig) WriteMyid() error

type Zkd

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

Zkd manages the running of ZooKeeper servers.

func NewZkd

func NewZkd(config *ZkConfig) *Zkd

NewZkd creates a Zkd.

func StartLocalZk

func StartLocalZk(id, port int) (*Zkd, string)

StartLocalZk is a helper method to create a local ZK process. Used in tests, mostly. It will log.Fatal out if there is an error. Each call should use different serverID / ports, so tests don't interfere with eachother. Use the testfiles package to achieve this.

func (*Zkd) Done

func (zkd *Zkd) Done() <-chan struct{}

Done returns a channel that is closed when the underlying process started by this Zkd has terminated. If the process was started by someone else, this channel will never be closed.

func (*Zkd) Init

func (zkd *Zkd) Init() error

Init generates a new config and then starts ZooKeeper.

func (*Zkd) Inited

func (zkd *Zkd) Inited() bool

Inited returns true if the server config has been initialized.

func (*Zkd) Shutdown

func (zkd *Zkd) Shutdown() error

Shutdown kills a ZooKeeper server, but keeps its data dir intact.

func (*Zkd) Start

func (zkd *Zkd) Start() error

Start runs an already initialized ZooKeeper server.

func (*Zkd) Teardown

func (zkd *Zkd) Teardown() error

Teardown shuts down the server and removes its data dir.

Jump to

Keyboard shortcuts

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