Documentation
¶
Index ¶
- func Between(key, a, b []byte) bool
- func BetweenRightIncl(key, a, b []byte) bool
- func BytesToUint64(b []byte) uint64
- func CompareSuccessorLists(a, b []*chordpb.Node) bool
- func Contains(list []*chordpb.Node, node *chordpb.Node) bool
- func Distance(a, b uint64, n int) uint64
- func GetHash(key string) []byte
- func GetLocationOnRing(id []byte) float64
- func GetPeerID(key string, m int) []byte
- func NewFingerTable(n *Node, m int) fingerTable
- func PrintNode(n *chordpb.Node, hex bool, label string)
- func PrintReplicaGroupMembership(n *Node)
- func PrintSuccessorList(n *Node)
- func Uint64ToBytes(i uint64) []byte
- type Config
- type Node
- func (n *Node) CheckPredecessor(context context.Context, empty *chordpb.Empty) (*chordpb.Empty, error)
- func (n *Node) CheckPredecessorRPC(other *chordpb.Node) (*chordpb.Empty, error)
- func (n *Node) FindSuccessor(context context.Context, peerID *chordpb.PeerID) (*chordpb.Node, error)
- func (n *Node) FindSuccessorRPC(other *chordpb.Node, id []byte) (*chordpb.Node, error)
- func (n *Node) Get(context context.Context, key *chordpb.Key) (*chordpb.Value, error)
- func (n *Node) GetKeys(context context.Context, id *chordpb.PeerID) (*chordpb.KVs, error)
- func (n *Node) GetKeysRPC(other *chordpb.Node, id []byte) (*chordpb.KVs, error)
- func (n *Node) GetPredecessor(context context.Context, empty *chordpb.Empty) (*chordpb.Node, error)
- func (n *Node) GetPredecessorRPC(other *chordpb.Node) (*chordpb.Node, error)
- func (n *Node) GetRPC(other *chordpb.Node, key string) (*chordpb.Value, error)
- func (n *Node) GetSuccessorList(context context.Context, empty *chordpb.Empty) (*chordpb.SuccessorList, error)
- func (n *Node) GetSuccessorListRPC(other *chordpb.Node) (*chordpb.SuccessorList, error)
- func (n *Node) Locate(context context.Context, key *chordpb.Key) (*chordpb.Node, error)
- func (n *Node) LocateRPC(other *chordpb.Node, key string) (*chordpb.Node, error)
- func (n *Node) Notify(context context.Context, node *chordpb.Node) (*chordpb.Empty, error)
- func (n *Node) NotifyRPC(other *chordpb.Node) error
- func (n *Node) PrintFingerTable(hex bool)
- func (n *Node) Put(context context.Context, kv *chordpb.KV) (*chordpb.Empty, error)
- func (n *Node) PutRPC(other *chordpb.Node, key string, value []byte) (*chordpb.Empty, error)
- func (n *Node) RecvCoordinatorMsg(context context.Context, msg *chordpb.CoordinatorMsg) (*chordpb.Empty, error)
- func (n *Node) RecvCoordinatorMsgRPC(other *chordpb.Node, newLeaderId []byte, oldLeaderId []byte) error
- func (n *Node) RemoveReplicas(context context.Context, replicaMsg *chordpb.ReplicaMsg) (*chordpb.Empty, error)
- func (n *Node) RemoveReplicasRPC(other *chordpb.Node, req *chordpb.ReplicaMsg) error
- func (n *Node) SendReplicas(context context.Context, replicaMsg *chordpb.ReplicaMsg) (*chordpb.Empty, error)
- func (n *Node) SendReplicasRPC(other *chordpb.Node, req *chordpb.ReplicaMsg) error
- type ReplicaGroup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BetweenRightIncl ¶
Function: BetweenRightIncl * * Description: * Check if a key is between a and b, right inclusive.
func BytesToUint64 ¶
func CompareSuccessorLists ¶
returns true if same, false if different
func GetLocationOnRing ¶
Function: GetLocationOnRing * * Description: * Given an input id, return the location on the * Chord ring as a percent. Useful for debugging or * testing purposes. Assumes id is a multiple of 8 bits.
func GetPeerID ¶
Function: GetPeerID * * Description: * Given an input string (usually ip:port), return * the peer ID. The peer ID is a SHA-1 hash truncated * to m bits. There are 2^m -1 possible peer IDs. * m must be a multiple of 8.
func NewFingerTable ¶
Function: NewFingerTable * * Description: * Create a new finger table for a node. Initially all entries * will contain n.
func PrintNode ¶
Function: PrintNode * * Description: * Print basic info about a chordpb.Node to stdout. Can either print out * the node's id in hex or decimal.
func PrintReplicaGroupMembership ¶
func PrintReplicaGroupMembership(n *Node)
func PrintSuccessorList ¶
func PrintSuccessorList(n *Node)
Function: PrintSuccessorList * * Description: * Print out a node's successor list *
func Uint64ToBytes ¶
Types ¶
type Config ¶
type Config struct { KeySize int Addr string Port uint32 Timeout int // in ms ServerOpts []grpc.ServerOption DialOpts []grpc.DialOption StabilizeInterval int // in ms FixFingerInterval int // in ms CheckPredecessorInterval int // in ms SuccessorListSize int Logging bool }
func DefaultConfig ¶
func SetDefaultGrpcOpts ¶
type Node ¶
Node implements the Chord GRPC Server interface
func CreateChord ¶
Function: CreateChord * * Description: * Create a new Chord ring and return the first node * in the ring.
func JoinChord ¶
Function: JoinChord * * Description: * Join an existing Chord ring. addr and port specify * an existing node in the Chord ring. Returns a newly * created node with its successor set.
func (*Node) CheckPredecessor ¶
func (n *Node) CheckPredecessor(context context.Context, empty *chordpb.Empty) (*chordpb.Empty, error)
Function: CheckPredecessor * * Description: * Implementation of CheckPredecessor RPC. Simply return an empty response, confirming * the liveliness of a node.
func (*Node) CheckPredecessorRPC ¶
Function: CheckPredecessorRPC * * Description: * Invoke a CheckPredecessor RPC on node "other," asking if that node is still alive
func (*Node) FindSuccessor ¶
func (n *Node) FindSuccessor(context context.Context, peerID *chordpb.PeerID) (*chordpb.Node, error)
Function: FindSuccessor * * Description: * Implementation of FindSuccessor RPC. Returns the successor of peerID. * If peerID is between our id and our successor's id, then return our successor. * Otherwise, check our finger table and forward the request to the closest preceding node.
func (*Node) FindSuccessorRPC ¶
Function: FindSuccessorRPC * * Description: * Invoke a FindSuccessor RPC on node "other," asking for the successor of a given id.
func (*Node) GetKeys ¶
Function: GetKeys * * Description: * Implementation of GetKeys RPC. The caller of this RPC is requesting keys for which it * it responsible for along the chord ring. We simply check our own datastore for keys * that the other node is responsible for and send it.
func (*Node) GetKeysRPC ¶
func (*Node) GetPredecessor ¶
Function: GetPredecessor * * Description: * Implementation of GetPredecessor RPC. Returns the node's current predecessor
func (*Node) GetPredecessorRPC ¶
Function: GetPredecessorRPC * * Description: * Invoke a GetPredecessor RPC on node "other," asking for it's current predecessor.
func (*Node) GetSuccessorList ¶
func (n *Node) GetSuccessorList(context context.Context, empty *chordpb.Empty) (*chordpb.SuccessorList, error)
Function: GetSuccessorList * * Description: * Return a node's successor list
func (*Node) GetSuccessorListRPC ¶
Function: GetSuccessorListRPC * * Description: * Get another node's successor list
func (*Node) Notify ¶
Function: Notify * * Description: * Implementation of Notify RPC. A Node is notifying us that it believes it is our predecessor. * Check if this is true based on our predecessor/successor knowledge and update.
func (*Node) NotifyRPC ¶
Function: NotifyRPC * * Description: * Invoke a Notify RPC on node "other," telling it that we believe we are its predecessor
func (*Node) PrintFingerTable ¶
Function: PrintFingerTable * * Description: * Print the entire finger table for a node. Can either print out the * node ids in hex or decimal.
func (*Node) RecvCoordinatorMsg ¶
func (n *Node) RecvCoordinatorMsg(context context.Context, msg *chordpb.CoordinatorMsg) (*chordpb.Empty, error)
Function: ReceiveCoordinatorMsg * * Description: * Implementation of RecvCoordinatorMsg RPC. Other nodes will send us coordinator messages. * This is a modified form of the Bully algorithm for leader election. When we receive a * coordinator msg from another node it means we are a member of their successor list. * We immediately recognize that we are apart of its replica group and take the necessary actions, * like creating a new replica group object internally, removing replica groups we are * no longer a member of etc.
func (*Node) RecvCoordinatorMsgRPC ¶
func (*Node) RemoveReplicas ¶
func (n *Node) RemoveReplicas(context context.Context, replicaMsg *chordpb.ReplicaMsg) (*chordpb.Empty, error)
Function: RemoveReplicas * * Description: * Implementation of RemoveReplicas RPC. A leader is informing us that certain keys do not belong * in this replica group anymore. Remove the specified keys from the leaders replica group internally
func (*Node) RemoveReplicasRPC ¶
func (*Node) SendReplicas ¶
func (n *Node) SendReplicas(context context.Context, replicaMsg *chordpb.ReplicaMsg) (*chordpb.Empty, error)
Function: SendReplicas * * Description: * Implementation of SendReplicas RPC. A leader is sending us kv replicas. Add them to the leaders * replica group internally.
func (*Node) SendReplicasRPC ¶
type ReplicaGroup ¶
type ReplicaGroup struct {
// contains filtered or unexported fields
}