Documentation
¶
Overview ¶
This package is used to provide an implementation of the Chord network protocol.
Index ¶
- type BlackholeTransport
- func (*BlackholeTransport) ClearPredecessor(target, self *Vnode) error
- func (*BlackholeTransport) FindSuccessors(vn *Vnode, n int, key []byte) ([]*Vnode, error)
- func (*BlackholeTransport) GetPredecessor(vn *Vnode) (*Vnode, error)
- func (*BlackholeTransport) ListVnodes(host string) ([]*Vnode, error)
- func (*BlackholeTransport) Notify(vn, self *Vnode) ([]*Vnode, error)
- func (*BlackholeTransport) Ping(vn *Vnode) (bool, error)
- func (*BlackholeTransport) Register(v *Vnode, o VnodeRPC)
- func (*BlackholeTransport) SkipSuccessor(target, self *Vnode) error
- type Config
- type Delegate
- type LocalTransport
- func (lt *LocalTransport) ClearPredecessor(target, self *Vnode) error
- func (lt *LocalTransport) Deregister(v *Vnode)
- func (lt *LocalTransport) FindSuccessors(vn *Vnode, n int, key []byte) ([]*Vnode, error)
- func (lt *LocalTransport) GetPredecessor(vn *Vnode) (*Vnode, error)
- func (lt *LocalTransport) ListVnodes(host string) ([]*Vnode, error)
- func (lt *LocalTransport) Notify(vn, self *Vnode) ([]*Vnode, error)
- func (lt *LocalTransport) Ping(vn *Vnode) (bool, error)
- func (lt *LocalTransport) Register(v *Vnode, o VnodeRPC)
- func (lt *LocalTransport) SkipSuccessor(target, self *Vnode) error
- type Ring
- type TCPTransport
- func (t *TCPTransport) ClearPredecessor(target, self *Vnode) error
- func (t *TCPTransport) FindSuccessors(vn *Vnode, n int, k []byte) ([]*Vnode, error)
- func (t *TCPTransport) GetPredecessor(vn *Vnode) (*Vnode, error)
- func (t *TCPTransport) ListVnodes(host string) ([]*Vnode, error)
- func (t *TCPTransport) Notify(target, self *Vnode) ([]*Vnode, error)
- func (t *TCPTransport) Ping(vn *Vnode) (bool, error)
- func (t *TCPTransport) Register(v *Vnode, o VnodeRPC)
- func (t *TCPTransport) Shutdown()
- func (t *TCPTransport) SkipSuccessor(target, self *Vnode) error
- type Transport
- type Vnode
- type VnodeRPC
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlackholeTransport ¶
type BlackholeTransport struct {
}
BlackholeTransport is used to provide an implemenation of the Transport that does not actually do anything. Any operation will result in an error.
func (*BlackholeTransport) ClearPredecessor ¶
func (*BlackholeTransport) ClearPredecessor(target, self *Vnode) error
func (*BlackholeTransport) FindSuccessors ¶
func (*BlackholeTransport) GetPredecessor ¶
func (*BlackholeTransport) GetPredecessor(vn *Vnode) (*Vnode, error)
func (*BlackholeTransport) ListVnodes ¶
func (*BlackholeTransport) ListVnodes(host string) ([]*Vnode, error)
func (*BlackholeTransport) Notify ¶
func (*BlackholeTransport) Notify(vn, self *Vnode) ([]*Vnode, error)
func (*BlackholeTransport) Register ¶
func (*BlackholeTransport) Register(v *Vnode, o VnodeRPC)
func (*BlackholeTransport) SkipSuccessor ¶
func (*BlackholeTransport) SkipSuccessor(target, self *Vnode) error
type Config ¶
type Config struct {
Hostname string // Local host name
NumVnodes int // Number of vnodes per physical node
HashFunc func() hash.Hash // Hash function to use
StabilizeMin time.Duration // Minimum stabilization time
StabilizeMax time.Duration // Maximum stabilization time
NumSuccessors int // Number of successors to maintain
Delegate Delegate // Invoked to handle ring events
// contains filtered or unexported fields
}
Configuration for Chord nodes
func DefaultConfig ¶
Returns the default Ring configuration
type Delegate ¶
type Delegate interface {
NewPredecessor(local, remoteNew, remotePrev *Vnode)
Leaving(local, pred, succ *Vnode)
PredecessorLeaving(local, remote *Vnode)
SuccessorLeaving(local, remote *Vnode)
Shutdown()
}
Delegate to notify on ring events
type LocalTransport ¶
type LocalTransport struct {
// contains filtered or unexported fields
}
LocalTransport is used to provides fast routing to Vnodes running locally using direct method calls. For any non-local vnodes, the request is passed on to another transport.
func (*LocalTransport) ClearPredecessor ¶
func (lt *LocalTransport) ClearPredecessor(target, self *Vnode) error
func (*LocalTransport) Deregister ¶
func (lt *LocalTransport) Deregister(v *Vnode)
func (*LocalTransport) FindSuccessors ¶
func (*LocalTransport) GetPredecessor ¶
func (lt *LocalTransport) GetPredecessor(vn *Vnode) (*Vnode, error)
func (*LocalTransport) ListVnodes ¶
func (lt *LocalTransport) ListVnodes(host string) ([]*Vnode, error)
func (*LocalTransport) Register ¶
func (lt *LocalTransport) Register(v *Vnode, o VnodeRPC)
func (*LocalTransport) SkipSuccessor ¶
func (lt *LocalTransport) SkipSuccessor(target, self *Vnode) error
type Ring ¶
type Ring struct {
// contains filtered or unexported fields
}
Stores the state required for a Chord ring
func (*Ring) Less ¶
Less returns whether the vnode with index i should sort before the vnode with index j.
type TCPTransport ¶
type TCPTransport struct {
// contains filtered or unexported fields
}
TCPTransport provides a TCP based Chord transport layer. This allows Chord to be implemented over a network, instead of only using the LocalTransport. It is meant to be a simple implementation, optimizing for simplicity instead of performance. Messages are sent with a header frame, followed by a body frame. All data is encoded using the GOB format for simplicity.
Internally, there is 1 Goroutine listening for inbound connections, 1 Goroutine PER inbound connection.
func InitTCPTransport ¶
func InitTCPTransport(listen string, timeout time.Duration) (*TCPTransport, error)
Creates a new TCP transport on the given listen address with the configured timeout duration.
func (*TCPTransport) ClearPredecessor ¶
func (t *TCPTransport) ClearPredecessor(target, self *Vnode) error
Clears a predecessor if it matches a given vnode. Used to leave.
func (*TCPTransport) FindSuccessors ¶
Find a successor
func (*TCPTransport) GetPredecessor ¶
func (t *TCPTransport) GetPredecessor(vn *Vnode) (*Vnode, error)
Request a nodes predecessor
func (*TCPTransport) ListVnodes ¶
func (t *TCPTransport) ListVnodes(host string) ([]*Vnode, error)
Gets a list of the vnodes on the box
func (*TCPTransport) Notify ¶
func (t *TCPTransport) Notify(target, self *Vnode) ([]*Vnode, error)
Notify our successor of ourselves
func (*TCPTransport) Ping ¶
func (t *TCPTransport) Ping(vn *Vnode) (bool, error)
Ping a Vnode, check for liveness
func (*TCPTransport) Register ¶
func (t *TCPTransport) Register(v *Vnode, o VnodeRPC)
Register for an RPC callbacks
func (*TCPTransport) SkipSuccessor ¶
func (t *TCPTransport) SkipSuccessor(target, self *Vnode) error
Instructs a node to skip a given successor. Used to leave.
type Transport ¶
type Transport interface {
// Gets a list of the vnodes on the box
ListVnodes(string) ([]*Vnode, error)
// Ping a Vnode, check for liveness
Ping(*Vnode) (bool, error)
// Request a nodes predecessor
GetPredecessor(*Vnode) (*Vnode, error)
// Notify our successor of ourselves
Notify(target, self *Vnode) ([]*Vnode, error)
// Find a successor
FindSuccessors(*Vnode, int, []byte) ([]*Vnode, error)
// Clears a predecessor if it matches a given vnode. Used to leave.
ClearPredecessor(target, self *Vnode) error
// Instructs a node to skip a given successor. Used to leave.
SkipSuccessor(target, self *Vnode) error
// Register for an RPC callbacks
Register(*Vnode, VnodeRPC)
}
Implements the methods needed for a Chord ring
func InitLocalTransport ¶
Creates a local transport to wrap a remote transport