go-vitess.v1: gopkg.in/src-d/go-vitess.v1/vt/topo/zk2topo Index | Files

package zk2topo

import "gopkg.in/src-d/go-vitess.v1/vt/topo/zk2topo"

Index

Package Files

directory.go election.go error.go file.go lock.go server.go utils.go version.go watch.go zk_conn.go

Constants

const (

    // PermDirectory are default permissions for a node.
    PermDirectory = zk.PermAdmin | zk.PermCreate | zk.PermDelete | zk.PermRead | zk.PermWrite

    // PermFile allows a zk node to emulate file behavior by
    // disallowing child nodes.
    PermFile = zk.PermAdmin | zk.PermRead | zk.PermWrite
)

func ChildrenRecursive Uses

func ChildrenRecursive(ctx context.Context, zconn *ZkConn, zkPath string) ([]string, error)

ChildrenRecursive returns the relative path of all the children of the provided node.

func CreateRecursive Uses

func CreateRecursive(ctx context.Context, conn *ZkConn, zkPath string, value []byte, flags int32, aclv []zk.ACL, maxCreationDepth int) (string, error)

CreateRecursive is a helper function on top of Create. It will create a path and any pieces required, think mkdir -p. Intermediate znodes are always created empty. Pass maxCreationDepth=-1 to create all nodes to the top.

func DeleteRecursive Uses

func DeleteRecursive(ctx context.Context, zconn *ZkConn, zkPath string, version int32) error

DeleteRecursive will delete all children of the given path.

func ResolveWildcards Uses

func ResolveWildcards(ctx context.Context, zconn *ZkConn, zkPaths []string) ([]string, error)

ResolveWildcards resolves paths like: /zk/nyc/vt/tablets/*/action /zk/global/vt/keyspaces/*/shards/*/action /zk/*/vt/tablets/*/action into real existing paths

If you send paths that don't contain any wildcard and don't exist, this function will return an empty array.

func Time Uses

func Time(i int64) time.Time

Time returns a time.Time from a ZK int64 milliseconds since Epoch time.

func ZkTime Uses

func ZkTime(t time.Time) int64

ZkTime returns a ZK time (int64) from a time.Time

type Factory Uses

type Factory struct{}

Factory is the zookeeper topo.Factory implementation.

func (Factory) Create Uses

func (f Factory) Create(cell, serverAddr, root string) (topo.Conn, error)

Create is part of the topo.Factory interface.

func (Factory) HasGlobalReadOnlyCell Uses

func (f Factory) HasGlobalReadOnlyCell(serverAddr, root string) bool

HasGlobalReadOnlyCell is part of the topo.Factory interface.

Further implementation design note: Zookeeper supports Observers: https://zookeeper.apache.org/doc/trunk/zookeeperObservers.html To use them, follow these instructions: * setup your observer servers as described in the previous link. * specify a second set of servers in serverAddr, after a '|', like:

global1:port1,global2:port2|observer1:port1,observer2:port2

* if HasGlobalReadOnlyCell detects that the serverAddr has both lists,

it returns true.

* the Create method below also splits the values, and if

cell is GlobalCell, use the left side, if cell is GlobalReadOnlyCell,
use the right side.

type Server Uses

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

Server is the zookeeper topo.Conn implementation.

func NewServer Uses

func NewServer(serverAddr, root string) *Server

NewServer returns a topo.Conn connecting to real Zookeeper processes.

func (*Server) Close Uses

func (zs *Server) Close()

Close is part of topo.Conn interface.

func (*Server) Create Uses

func (zs *Server) Create(ctx context.Context, filePath string, contents []byte) (topo.Version, error)

Create is part of the topo.Conn interface.

func (*Server) Delete Uses

func (zs *Server) Delete(ctx context.Context, filePath string, version topo.Version) error

Delete is part of the topo.Conn interface.

func (*Server) Get Uses

func (zs *Server) Get(ctx context.Context, filePath string) ([]byte, topo.Version, error)

Get is part of the topo.Conn interface.

func (*Server) ListDir Uses

func (zs *Server) ListDir(ctx context.Context, dirPath string, full bool) ([]topo.DirEntry, error)

ListDir is part of the topo.Conn interface.

func (*Server) Lock Uses

func (zs *Server) Lock(ctx context.Context, dirPath, contents string) (topo.LockDescriptor, error)

Lock is part of the topo.Conn interface.

func (*Server) NewMasterParticipation Uses

func (zs *Server) NewMasterParticipation(name, id string) (topo.MasterParticipation, error)

NewMasterParticipation is part of the topo.Server interface. We use the full path: <root path>/election/<name>

func (*Server) Update Uses

func (zs *Server) Update(ctx context.Context, filePath string, contents []byte, version topo.Version) (topo.Version, error)

Update is part of the topo.Conn interface.

func (*Server) Watch Uses

func (zs *Server) Watch(ctx context.Context, filePath string) (*topo.WatchData, <-chan *topo.WatchData, topo.CancelFunc)

Watch is part of the topo.Conn interface.

type ZKVersion Uses

type ZKVersion int32

ZKVersion is zookeeper's idea of a version. It implements topo.Version. We use the native zookeeper.Stat.Version type, int32.

func (ZKVersion) String Uses

func (v ZKVersion) String() string

String is part of the topo.Version interface.

type ZkConn Uses

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

ZkConn is a wrapper class on top of a zk.Conn. It will do a few things for us: - add the context parameter. However, we do not enforce its deadlines

necessarily.

- enforce a max concurrency of access to Zookeeper. We just don't

want to make too many calls concurrently, to not take too many resources.

- retry some calls to Zookeeper. If we were disconnected from the

server, we want to try connecting again before failing.

func Connect Uses

func Connect(addr string) *ZkConn

Connect to the Zookeeper servers specified in addr addr can be a comma separated list of servers and each server can be a DNS entry with multiple values. Connects to the endpoints in a randomized order to avoid hot spots.

func (*ZkConn) AddAuth Uses

func (c *ZkConn) AddAuth(ctx context.Context, scheme string, auth []byte) error

AddAuth is part of the Conn interface.

func (*ZkConn) Children Uses

func (c *ZkConn) Children(ctx context.Context, path string) (children []string, stat *zk.Stat, err error)

Children is part of the Conn interface.

func (*ZkConn) ChildrenW Uses

func (c *ZkConn) ChildrenW(ctx context.Context, path string) (children []string, stat *zk.Stat, watch <-chan zk.Event, err error)

ChildrenW is part of the Conn interface.

func (*ZkConn) Close Uses

func (c *ZkConn) Close() error

Close is part of the Conn interface.

func (*ZkConn) Create Uses

func (c *ZkConn) Create(ctx context.Context, path string, value []byte, flags int32, aclv []zk.ACL) (pathCreated string, err error)

Create is part of the Conn interface.

func (*ZkConn) Delete Uses

func (c *ZkConn) Delete(ctx context.Context, path string, version int32) error

Delete is part of the Conn interface.

func (*ZkConn) Exists Uses

func (c *ZkConn) Exists(ctx context.Context, path string) (exists bool, stat *zk.Stat, err error)

Exists is part of the Conn interface.

func (*ZkConn) ExistsW Uses

func (c *ZkConn) ExistsW(ctx context.Context, path string) (exists bool, stat *zk.Stat, watch <-chan zk.Event, err error)

ExistsW is part of the Conn interface.

func (*ZkConn) Get Uses

func (c *ZkConn) Get(ctx context.Context, path string) (data []byte, stat *zk.Stat, err error)

Get is part of the Conn interface.

func (*ZkConn) GetACL Uses

func (c *ZkConn) GetACL(ctx context.Context, path string) (aclv []zk.ACL, stat *zk.Stat, err error)

GetACL is part of the Conn interface.

func (*ZkConn) GetW Uses

func (c *ZkConn) GetW(ctx context.Context, path string) (data []byte, stat *zk.Stat, watch <-chan zk.Event, err error)

GetW is part of the Conn interface.

func (*ZkConn) Set Uses

func (c *ZkConn) Set(ctx context.Context, path string, value []byte, version int32) (stat *zk.Stat, err error)

Set is part of the Conn interface.

func (*ZkConn) SetACL Uses

func (c *ZkConn) SetACL(ctx context.Context, path string, aclv []zk.ACL, version int32) error

SetACL is part of the Conn interface.

Package zk2topo imports 20 packages (graph) and is imported by 2 packages. Updated 2019-06-13. Refresh now. Tools for package owners.