Documentation ¶
Overview ¶
This package is used to provide an implementation of the Chord network protocol.
Package chord is a generated protocol buffer package.
It is generated from these files:
net.proto
It has these top-level messages:
Vnode VnodeError VnodeListErr BoolErr FindSuccReq StringParam VnodePair ErrResponse
Index ¶
- func RegisterChordServer(s *grpc.Server, srv ChordServer)
- 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 BoolErr
- type ChordClient
- type ChordServer
- type Config
- type Delegate
- type ErrResponse
- type FindSuccReq
- type GRPCTransport
- func (cs *GRPCTransport) ClearPredecessor(target, self *Vnode) error
- func (cs *GRPCTransport) ClearPredecessorServe(ctx context.Context, in *VnodePair) (*ErrResponse, error)
- func (cs *GRPCTransport) FindSuccessors(vn *Vnode, n int, k []byte) ([]*Vnode, error)
- func (cs *GRPCTransport) FindSuccessorsServe(ctx context.Context, in *FindSuccReq) (*VnodeListErr, error)
- func (cs *GRPCTransport) GetPredecessor(vn *Vnode) (*Vnode, error)
- func (cs *GRPCTransport) GetPredecessorServe(ctx context.Context, in *Vnode) (*VnodeError, error)
- func (cs *GRPCTransport) ListVnodes(host string) ([]*Vnode, error)
- func (cs *GRPCTransport) ListVnodesServe(ctx context.Context, in *StringParam) (*VnodeListErr, error)
- func (cs *GRPCTransport) Notify(target, self *Vnode) ([]*Vnode, error)
- func (cs *GRPCTransport) NotifyServe(ctx context.Context, in *VnodePair) (*VnodeListErr, error)
- func (cs *GRPCTransport) Ping(target *Vnode) (bool, error)
- func (cs *GRPCTransport) PingServe(ctx context.Context, in *Vnode) (*BoolErr, error)
- func (cs *GRPCTransport) Register(v *Vnode, o VnodeRPC)
- func (cs *GRPCTransport) Shutdown()
- func (cs *GRPCTransport) SkipSuccessor(target, self *Vnode) error
- func (cs *GRPCTransport) SkipSuccessorServe(ctx context.Context, in *VnodePair) (*ErrResponse, error)
- func (cs *GRPCTransport) Status() map[string]interface{}
- type IDecoder
- type IEncoder
- 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 StringParam
- type Transport
- type UTPTransport
- func (t *UTPTransport) ClearPredecessor(target, self *Vnode) error
- func (t *UTPTransport) FindSuccessors(vn *Vnode, n int, k []byte) ([]*Vnode, error)
- func (t *UTPTransport) GetPredecessor(vn *Vnode) (*Vnode, error)
- func (t *UTPTransport) ListVnodes(host string) ([]*Vnode, error)
- func (t *UTPTransport) Notify(target, self *Vnode) ([]*Vnode, error)
- func (t *UTPTransport) Ping(vn *Vnode) (bool, error)
- func (t *UTPTransport) Register(v *Vnode, o VnodeRPC)
- func (t *UTPTransport) Shutdown()
- func (t *UTPTransport) SkipSuccessor(target, self *Vnode) error
- type Vnode
- type VnodeError
- type VnodeListErr
- type VnodePair
- type VnodeRPC
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterChordServer ¶
func RegisterChordServer(s *grpc.Server, srv ChordServer)
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 BoolErr ¶
type BoolErr struct { Ok bool `protobuf:"varint,1,opt,name=ok" json:"ok,omitempty"` Err string `protobuf:"bytes,2,opt,name=err" json:"err,omitempty"` }
func (*BoolErr) Descriptor ¶
func (*BoolErr) ProtoMessage ¶
func (*BoolErr) ProtoMessage()
type ChordClient ¶
type ChordClient interface { ListVnodesServe(ctx context.Context, in *StringParam, opts ...grpc.CallOption) (*VnodeListErr, error) PingServe(ctx context.Context, in *Vnode, opts ...grpc.CallOption) (*BoolErr, error) NotifyServe(ctx context.Context, in *VnodePair, opts ...grpc.CallOption) (*VnodeListErr, error) GetPredecessorServe(ctx context.Context, in *Vnode, opts ...grpc.CallOption) (*VnodeError, error) FindSuccessorsServe(ctx context.Context, in *FindSuccReq, opts ...grpc.CallOption) (*VnodeListErr, error) ClearPredecessorServe(ctx context.Context, in *VnodePair, opts ...grpc.CallOption) (*ErrResponse, error) SkipSuccessorServe(ctx context.Context, in *VnodePair, opts ...grpc.CallOption) (*ErrResponse, error) }
func NewChordClient ¶
func NewChordClient(cc *grpc.ClientConn) ChordClient
type ChordServer ¶
type ChordServer interface { ListVnodesServe(context.Context, *StringParam) (*VnodeListErr, error) PingServe(context.Context, *Vnode) (*BoolErr, error) NotifyServe(context.Context, *VnodePair) (*VnodeListErr, error) GetPredecessorServe(context.Context, *Vnode) (*VnodeError, error) FindSuccessorsServe(context.Context, *FindSuccReq) (*VnodeListErr, error) ClearPredecessorServe(context.Context, *VnodePair) (*ErrResponse, error) SkipSuccessorServe(context.Context, *VnodePair) (*ErrResponse, error) }
type Config ¶
type Config struct { Hostname string // Local host name NumVnodes int // Number of vnodes per physical node HashFunc func() hash.Hash `json:"-"` // 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 `json:"-"` // Invoked to handle ring events // contains filtered or unexported fields }
Config for Chord nodes
func DefaultConfig ¶
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 ErrResponse ¶
type ErrResponse struct {
Err string `protobuf:"bytes,1,opt,name=err" json:"err,omitempty"`
}
func (*ErrResponse) Descriptor ¶
func (*ErrResponse) Descriptor() ([]byte, []int)
func (*ErrResponse) GetErr ¶
func (m *ErrResponse) GetErr() string
func (*ErrResponse) ProtoMessage ¶
func (*ErrResponse) ProtoMessage()
func (*ErrResponse) Reset ¶
func (m *ErrResponse) Reset()
func (*ErrResponse) String ¶
func (m *ErrResponse) String() string
type FindSuccReq ¶
type FindSuccReq struct { VN *Vnode `protobuf:"bytes,1,opt,name=VN,json=vN" json:"VN,omitempty"` Count int32 `protobuf:"varint,2,opt,name=count" json:"count,omitempty"` Key []byte `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"` }
func (*FindSuccReq) Descriptor ¶
func (*FindSuccReq) Descriptor() ([]byte, []int)
func (*FindSuccReq) GetCount ¶
func (m *FindSuccReq) GetCount() int32
func (*FindSuccReq) GetKey ¶
func (m *FindSuccReq) GetKey() []byte
func (*FindSuccReq) GetVN ¶
func (m *FindSuccReq) GetVN() *Vnode
func (*FindSuccReq) ProtoMessage ¶
func (*FindSuccReq) ProtoMessage()
func (*FindSuccReq) Reset ¶
func (m *FindSuccReq) Reset()
func (*FindSuccReq) String ¶
func (m *FindSuccReq) String() string
type GRPCTransport ¶
type GRPCTransport struct {
// contains filtered or unexported fields
}
GRPCTransport used by chord
func NewGRPCTransport ¶
func NewGRPCTransport(sock net.Listener, gserver *grpc.Server, rpcTimeout, connMaxIdle time.Duration) *GRPCTransport
NewGRPCTransport creates a new grpc transport using the provided listener and grpc server.
func (*GRPCTransport) ClearPredecessor ¶
func (cs *GRPCTransport) ClearPredecessor(target, self *Vnode) error
Clears a predecessor if it matches a given vnode. Used to leave.
func (*GRPCTransport) ClearPredecessorServe ¶
func (cs *GRPCTransport) ClearPredecessorServe(ctx context.Context, in *VnodePair) (*ErrResponse, error)
func (*GRPCTransport) FindSuccessors ¶
FindSuccessors given the vnode upto n successors
func (*GRPCTransport) FindSuccessorsServe ¶
func (cs *GRPCTransport) FindSuccessorsServe(ctx context.Context, in *FindSuccReq) (*VnodeListErr, error)
func (*GRPCTransport) GetPredecessor ¶
func (cs *GRPCTransport) GetPredecessor(vn *Vnode) (*Vnode, error)
GetPredecessor requests a vnode's predecessor
func (*GRPCTransport) GetPredecessorServe ¶
func (cs *GRPCTransport) GetPredecessorServe(ctx context.Context, in *Vnode) (*VnodeError, error)
func (*GRPCTransport) ListVnodes ¶
func (cs *GRPCTransport) ListVnodes(host string) ([]*Vnode, error)
ListVnodes gets a list of the vnodes on the box
func (*GRPCTransport) ListVnodesServe ¶
func (cs *GRPCTransport) ListVnodesServe(ctx context.Context, in *StringParam) (*VnodeListErr, error)
ListVnodesServe is the server side call
func (*GRPCTransport) Notify ¶
func (cs *GRPCTransport) Notify(target, self *Vnode) ([]*Vnode, error)
Notify our successor of ourselves
func (*GRPCTransport) NotifyServe ¶
func (cs *GRPCTransport) NotifyServe(ctx context.Context, in *VnodePair) (*VnodeListErr, error)
NotifyServe the client
func (*GRPCTransport) Ping ¶
func (cs *GRPCTransport) Ping(target *Vnode) (bool, error)
Ping a Vnode, check for liveness
func (*GRPCTransport) Register ¶
func (cs *GRPCTransport) Register(v *Vnode, o VnodeRPC)
func (*GRPCTransport) SkipSuccessor ¶
func (cs *GRPCTransport) SkipSuccessor(target, self *Vnode) error
SkipSuccessor instructs a node to skip a given successor. Used to leave.
func (*GRPCTransport) SkipSuccessorServe ¶
func (cs *GRPCTransport) SkipSuccessorServe(ctx context.Context, in *VnodePair) (*ErrResponse, error)
func (*GRPCTransport) Status ¶
func (cs *GRPCTransport) Status() map[string]interface{}
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
}
Ring 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.
func (*Ring) ListVnodes ¶
ListVnodes for a given host
type StringParam ¶
type StringParam struct {
Value string `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"`
}
func (*StringParam) Descriptor ¶
func (*StringParam) Descriptor() ([]byte, []int)
func (*StringParam) GetValue ¶
func (m *StringParam) GetValue() string
func (*StringParam) ProtoMessage ¶
func (*StringParam) ProtoMessage()
func (*StringParam) Reset ¶
func (m *StringParam) Reset()
func (*StringParam) String ¶
func (m *StringParam) String() string
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) }
Transport implements the methods needed for a Chord ring
func InitLocalTransport ¶
Creates a local transport to wrap a remote transport
type UTPTransport ¶
type UTPTransport struct { RPCServe func(IEncoder, IDecoder) (interface{}, error) // contains filtered or unexported fields }
func InitUTPTransport ¶
func InitUTPTransport(layer *mux.Layer, dialTimeout, rpcTimeout, maxConnIdle time.Duration) (*UTPTransport, error)
InitUTPTransport creates a new UTP transport on the given listen address with the configured timeout duration. A RPC function can be given to implement additional rpc's. maxConnIdle is the maximum age of a connection
func (*UTPTransport) ClearPredecessor ¶
func (t *UTPTransport) ClearPredecessor(target, self *Vnode) error
ClearPredecessor clears a predecessor if it matches a given vnode. Used to leave.
func (*UTPTransport) FindSuccessors ¶
FindSuccessors for the given vnode and key upto n successors
func (*UTPTransport) GetPredecessor ¶
func (t *UTPTransport) GetPredecessor(vn *Vnode) (*Vnode, error)
GetPredecessor requests a nodes predecessor
func (*UTPTransport) ListVnodes ¶
func (t *UTPTransport) ListVnodes(host string) ([]*Vnode, error)
ListVnodes gets a list of the vnodes on the box
func (*UTPTransport) Notify ¶
func (t *UTPTransport) Notify(target, self *Vnode) ([]*Vnode, error)
Notify our successor of ourselves
func (*UTPTransport) Ping ¶
func (t *UTPTransport) Ping(vn *Vnode) (bool, error)
Ping a Vnode, check for liveness
func (*UTPTransport) Register ¶
func (t *UTPTransport) Register(v *Vnode, o VnodeRPC)
Register for an RPC callbacks
func (*UTPTransport) SkipSuccessor ¶
func (t *UTPTransport) SkipSuccessor(target, self *Vnode) error
SkipSuccessor instructs a node to skip a given successor. Used to leave.
type Vnode ¶
type Vnode struct { Id []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Host string `protobuf:"bytes,2,opt,name=host" json:"host,omitempty"` }
func (*Vnode) Descriptor ¶
func (*Vnode) ProtoMessage ¶
func (*Vnode) ProtoMessage()
type VnodeError ¶
type VnodeError struct { VN *Vnode `protobuf:"bytes,1,opt,name=VN,json=vN" json:"VN,omitempty"` Err string `protobuf:"bytes,2,opt,name=err" json:"err,omitempty"` }
func (*VnodeError) Descriptor ¶
func (*VnodeError) Descriptor() ([]byte, []int)
func (*VnodeError) GetErr ¶
func (m *VnodeError) GetErr() string
func (*VnodeError) GetVN ¶
func (m *VnodeError) GetVN() *Vnode
func (*VnodeError) ProtoMessage ¶
func (*VnodeError) ProtoMessage()
func (*VnodeError) Reset ¶
func (m *VnodeError) Reset()
func (*VnodeError) String ¶
func (m *VnodeError) String() string
type VnodeListErr ¶
type VnodeListErr struct { Err string `protobuf:"bytes,1,opt,name=err" json:"err,omitempty"` Vnodes []*Vnode `protobuf:"bytes,2,rep,name=vnodes" json:"vnodes,omitempty"` }
func (*VnodeListErr) Descriptor ¶
func (*VnodeListErr) Descriptor() ([]byte, []int)
func (*VnodeListErr) GetErr ¶
func (m *VnodeListErr) GetErr() string
func (*VnodeListErr) GetVnodes ¶
func (m *VnodeListErr) GetVnodes() []*Vnode
func (*VnodeListErr) ProtoMessage ¶
func (*VnodeListErr) ProtoMessage()
func (*VnodeListErr) Reset ¶
func (m *VnodeListErr) Reset()
func (*VnodeListErr) String ¶
func (m *VnodeListErr) String() string
type VnodePair ¶
type VnodePair struct { Target *Vnode `protobuf:"bytes,1,opt,name=target" json:"target,omitempty"` Self *Vnode `protobuf:"bytes,2,opt,name=self" json:"self,omitempty"` }
func (*VnodePair) Descriptor ¶
func (*VnodePair) ProtoMessage ¶
func (*VnodePair) ProtoMessage()