transport

package
v0.0.0-...-17369de Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TCPPaxosRPCName is the name of the tcp RPC module.
	TCPPaxosRPCName = "go-tcp-transport"
)

Variables

View Source
var (
	// NOOPPaxosName is the module name for the NOOP transport module.
	NOOPPaxosName = "noop-test-transport"
	// ErrRequestedToFail is the error used to indicate that the error is
	// requested.
	ErrRequestedToFail = errors.New("requested to returned error")
)
View Source
var (
	// ErrBadMessage is the error returned to indicate the incoming message is
	// corrupted.
	ErrBadMessage = errors.New("invalid message")
)

Functions

func NewNOOPTransport

func NewNOOPTransport(nhConfig config.NodeHostConfig,
	requestHandler paxosio.RequestHandler) paxosio.IPaxosRPC

NewNOOPTransport creates a new NOOPTransport instance.

func NewTCPTransport

func NewTCPTransport(nhConfig config.NodeHostConfig,
	requestHandler paxosio.RequestHandler) paxosio.IPaxosRPC

NewTCPTransport creates and returns a new TCP transport module.

Types

type INodeAddressResolver

type INodeAddressResolver interface {
	Resolve(uint64, uint64) (string, string, error)
	ReverseResolve(string) []paxosio.NodeInfo
	AddRemoteAddress(uint64, uint64, string)
}

INodeAddressResolver converts the (cluster id, node id( tuple to network address

type INodeRegistry

type INodeRegistry interface {
	AddNode(groupID uint64, nodeID uint64, url string)
	RemoveNode(groupID uint64, nodeID uint64)
	RemoveGroup(groupID uint64)
	Resolve(groupID uint64, nodeID uint64) (string, string, error)
}

INodeRegistry is the local registry interface used to keep all known nodes in the multi paxos system.

type IPaxosMessageHandler

type IPaxosMessageHandler interface {
	HandleMessageBatch(batch paxospb.MessageBatch)
}

IPaxosMessageHandler is the interface required to handle incoming paxos requests.

type ITransport

type ITransport interface {
	Name() string
	// SetUnmanagedDeploymentID()
	// SetDeploymentID(uint64)
	SetMessageHandler(IPaxosMessageHandler)
	RemoveMessageHandler()
	ASyncSend(paxospb.PaxosMsg) bool
	// ASyncSendSnapshot(paxospb.PaxosMsg) bool
	Stop()
}

ITransport is the interface of the transport layer used for exchanging Paxos messages.

type Marshaler

type Marshaler interface {
	MarshalTo([]byte) (int, error)
	Size() int
}

Marshaler is the interface for types that can be Marshaled.

type NOOPConnection

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

NOOPConnection is the connection used to exchange messages between node hosts.

func (*NOOPConnection) Close

func (c *NOOPConnection) Close()

Close closes the NOOPConnection instance.

func (*NOOPConnection) SendMessageBatch

func (c *NOOPConnection) SendMessageBatch(batch paxospb.MessageBatch) error

SendMessageBatch return ErrRequestedToFail when requested.

type NOOPTransport

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

NOOPTransport is a transport module for testing purposes. It does not actually has the ability to exchange messages or snapshots between nodehosts.

func (*NOOPTransport) GetConnection

func (g *NOOPTransport) GetConnection(ctx context.Context,
	target string) (paxosio.IConnection, error)

GetConnection returns a connection.

func (*NOOPTransport) Name

func (g *NOOPTransport) Name() string

Name returns the module name.

func (*NOOPTransport) Start

func (g *NOOPTransport) Start() error

Start starts the NOOPTransport instance.

func (*NOOPTransport) Stop

func (g *NOOPTransport) Stop()

Stop stops the NOOPTransport instance.

type Nodes

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

Nodes is used to manage all known node addresses in the multi paxos system. The transport layer uses this address registry to locate nodes.

func NewNodes

func NewNodes(streamConnections uint64) *Nodes

NewNodes returns a new Nodes object.

func (*Nodes) AddNode

func (n *Nodes) AddNode(groupID uint64, nodeID uint64, url string)

AddNode add a new node.

func (*Nodes) AddRemoteAddress

func (n *Nodes) AddRemoteAddress(groupID uint64,
	nodeID uint64, address string)

AddRemoteAddress remembers the specified address obtained from the source of the incoming message.

func (*Nodes) RemoveAllPeers

func (n *Nodes) RemoveAllPeers()

RemoveAllPeers removes all remotes.

func (*Nodes) RemoveGroup

func (n *Nodes) RemoveGroup(groupID uint64)

RemoveGroup removes all nodes info associated with the specified group

func (*Nodes) RemoveNode

func (n *Nodes) RemoveNode(groupID uint64, nodeID uint64)

RemoveNode removes a remote from the node registry.

func (*Nodes) Resolve

func (n *Nodes) Resolve(groupID uint64, nodeID uint64) (string, string, error)

Resolve looks up the Addr of the specified node.

func (*Nodes) ReverseResolve

func (n *Nodes) ReverseResolve(addr string) []paxosio.NodeInfo

ReverseResolve does the reverse lookup for the specified address. A list of node raftio.NodeInfos are returned for nodes that match the specified address

type SendMessageBatchFunc

type SendMessageBatchFunc func(paxospb.MessageBatch) (paxospb.MessageBatch, bool)

SendMessageBatchFunc is a func type that is used to determine whether the specified message batch should be sent. This func is used in test only.

type TCPConnection

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

TCPConnection is the connection used for sending paxos messages to remote nodes.

func NewTCPConnection

func NewTCPConnection(conn net.Conn) *TCPConnection

NewTCPConnection creates and returns a new TCPConnection instance.

func (*TCPConnection) Close

func (c *TCPConnection) Close()

Close closes the TCPConnection instance.

func (*TCPConnection) SendMessageBatch

func (c *TCPConnection) SendMessageBatch(batch paxospb.MessageBatch) error

SendMessageBatch sends a paxos message batch to remote node.

type TCPTransport

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

TCPTransport is a TCP based RPC module for exchanging paxos messages and snapshots between NodeHost instances.

func (*TCPTransport) GetConnection

func (g *TCPTransport) GetConnection(ctx context.Context,
	target string) (paxosio.IConnection, error)

GetConnection returns a new paxosio.IConnection for sending raft messages.

func (*TCPTransport) Name

func (g *TCPTransport) Name() string

Name returns a human readable name of the TCP transport module.

func (*TCPTransport) Start

func (g *TCPTransport) Start() error

Start starts the TCP transport module.

func (*TCPTransport) Stop

func (g *TCPTransport) Stop()

Stop stops the TCP transport module.

type Transport

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

Transport is the transport layer for delivering paxos messages and snapshots.

func NewTransport

func NewTransport(nhConfig config.NodeHostConfig, ctx *server.Context,
	resolver INodeAddressResolver) *Transport

NewTransport creates a new Transport object.

func (*Transport) ASyncSend

func (t *Transport) ASyncSend(req paxospb.PaxosMsg) bool

ASyncSend sends paxos msg using RPC

func (*Transport) GetPaxosRPC

func (t *Transport) GetPaxosRPC() paxosio.IPaxosRPC

GetPaxosRPC returns the paxos RPC instance

func (*Transport) Name

func (t *Transport) Name() string

Name returns the type name of the transport module

func (*Transport) RemoveMessageHandler

func (t *Transport) RemoveMessageHandler()

RemoveMessageHandler removes the raft message handler.

func (*Transport) SetMessageHandler

func (t *Transport) SetMessageHandler(handler IPaxosMessageHandler)

SetMessageHandler sets the raft message handler.

func (*Transport) Stop

func (t *Transport) Stop()

Stop stops the Transport object

Jump to

Keyboard shortcuts

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