util

package
v0.0.0-...-8fd8902 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 2 more Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BatchCallHTTP

func BatchCallHTTP(nodes []*PegasusNode, request HTTPRequestFunc, args Arguments) map[string]*Result

func CallHTTPGet

func CallHTTPGet(url string) (string, error)

func FormatDate

func FormatDate(date int64) string

func GetNodeStats

func GetNodeStats(perfClient *aggregate.PerfClient) (map[string]*aggregate.NodeStat, error)

GetNodeStats returns a mapping of [node address => node stats]

func GetPartitionStat

func GetPartitionStat(perfSession *aggregate.PerfSession, counter string) map[string]float64

func SortStructsByField

func SortStructsByField(structs []interface{}, key string)

func Str2Gpid

func Str2Gpid(gpid string) (*base.Gpid, error)

Types

type Arguments

type Arguments struct {
	Name  string
	Value string
}

type HTTPRequestFunc

type HTTPRequestFunc func(addr string, args Arguments) (string, error)

type PegasusNode

type PegasusNode struct {
	IP net.IP

	Port int

	Hostname string

	Type session.NodeType
	// contains filtered or unexported fields
}

PegasusNode is a representation of MetaServer and ReplicaServer. Compared to session.NodeSession, it extends with more detailed information.

func NewNodeFromTCPAddr

func NewNodeFromTCPAddr(addr string, ntype session.NodeType) *PegasusNode

NewNodeFromTCPAddr creates a node from tcp address. NOTE:

  • Will not initialize TCP connection unless needed.
  • Should not be called too frequently because it costs 1 DNS resolution.

func (*PegasusNode) CombinedAddr

func (n *PegasusNode) CombinedAddr() string

CombinedAddr returns a string combining with tcp address and hostname.

func (*PegasusNode) RPCAddress

func (n *PegasusNode) RPCAddress() *base.RPCAddress

func (*PegasusNode) Replica

func (n *PegasusNode) Replica() *session.ReplicaSession

Replica returns a ReplicaSession if this node is a ReplicaServer. Will initialize the TCP connection.

func (*PegasusNode) Session

func (n *PegasusNode) Session() session.NodeSession

Session returns a tcp session to the node. Will initialize the TCP connection.

func (*PegasusNode) String

func (n *PegasusNode) String() string

func (*PegasusNode) TCPAddr

func (n *PegasusNode) TCPAddr() string

TCPAddr returns the tcp address of the node

type PegasusNodeManager

type PegasusNodeManager struct {
	// filled on initialization, won't be updated after that.
	MetaAddresses []string
	// contains filtered or unexported fields
}

PegasusNodeManager manages the sessions of all types of Pegasus node.

func NewPegasusNodeManager

func NewPegasusNodeManager(metaAddrs []string, replicaAddrs []string) *PegasusNodeManager

NewPegasusNodeManager creates a PegasusNodeManager.

func (*PegasusNodeManager) GetAllNodes

func (m *PegasusNodeManager) GetAllNodes(ntype session.NodeType) []*PegasusNode

GetAllNodes returns all nodes that matches the type. The result could be inconsistent with the latest cluster state. Please use MetaManager.ListNodes whenever possible.

func (*PegasusNodeManager) GetNode

func (m *PegasusNodeManager) GetNode(addr string, ntype session.NodeType) (*PegasusNode, error)

GetNode returns the specified node if it exists.

func (*PegasusNodeManager) GetPerfSession

func (m *PegasusNodeManager) GetPerfSession(addr string, ntype session.NodeType) *aggregate.PerfSession

func (*PegasusNodeManager) MustGetReplica

func (m *PegasusNodeManager) MustGetReplica(addr string) *PegasusNode

MustGetReplica returns a replica node even if it doens't exist before. User should assure the validity of the given info.

type Result

type Result struct {
	Resp string
	Err  error
}

Jump to

Keyboard shortcuts

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