chord

package module
v0.0.0-...-142159a Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2021 License: MIT Imports: 14 Imported by: 0

README

dht-chord

Distributed Hash Table based on Chord protocol

A distributed hash table (DHT) is a distributed system that provides a lookup service similar to a hash table: key-value pairs are stored in a DHT, and any participating node can efficiently retrieve the value associated with a given key. The main advantage of a DHT is that nodes can be added or removed with minimum work around re-distributing keys, this allows a DHT to scale to extremely large numbers of nodes and to handle continual node arrivals, departures, and failures.

- Distributed hash table

Chord is a protocol and algorithm for a peer-to-peer distributed hash table. Chord specifies how keys are assigned to nodes, and how a node can discover the value for a given key by first locating the node responsible for that key.

- Chord (peer-to-peer)

Sources

Video Demonstartion

https://user-images.githubusercontent.com/41361833/146183544-26b6f074-0714-4754-93c3-6b7ba5f6304b.mp4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnableToListen    = errors.New("error: rpc server unable to listen on specified addr:port")
	ErrUnableToDial      = errors.New("error: unable to dial the address of rpc server")
	ErrFailedToReach     = errors.New("error: unable to reach rpc server")
	ErrNodeAlreadyExists = errors.New("error: node with same id already exists")
	ErrNoKeyValuePair    = errors.New("error: key value pair not found")
	ErrNilPredecessor    = errors.New("error: predecessor does not exists")
)

Functions

This section is empty.

Types

type Finger

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

Each ith finger represents the node which is atleast at a distance of 2^(i - 1) from current node

type Node

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

Node is an individual entity/worker/machine in the chord network.

func (*Node) Stop

func (node *Node) Stop()

This method is called when node is leaving the chord network. It does the following tasks

1.transfers its keys to its successor
2.connect its predecessor and successor to
  each other

type RPCNode

type RPCNode struct {
	// promoted anonymous field
	*Node
}

This structure houses rpc methods of Node

func CreateNewNode

func CreateNewNode(address string, joinNodeAddr string) (*RPCNode, error)

func (*RPCNode) Check

func (node *RPCNode) Check(arg *string, reply *string) error

Function to check if RPC server is responding

func (*RPCNode) GetId

func (node *RPCNode) GetId(_ *string, id *[]byte) error

Return the id of the node

func (*RPCNode) GetPredecessor

func (node *RPCNode) GetPredecessor(_ *string, reply *string) error

Returns predecessor of the node

func (*RPCNode) GetValue

func (node *RPCNode) GetValue(key *string, value *string) error

Returns the value associated with following key if the node has the pair in its store else returns an error

func (*RPCNode) Notify

func (node *RPCNode) Notify(predAddr *string, _ *string) error

Check if node pointed by predAddr is the correct/best predecessor

func (*RPCNode) Retrieve

func (node *RPCNode) Retrieve(key *string, value *string) error

Retrieve a key-value pair from chord network

func (*RPCNode) Save

func (node *RPCNode) Save(arr []string, storeNode *string) error

func (*RPCNode) SetData

func (node *RPCNode) SetData(data *map[string]string, _ *string) error

Saves data into node's store

func (*RPCNode) SetPredecessor

func (node *RPCNode) SetPredecessor(predAddr *string, _ *string) error

manually set predecessor of node

func (*RPCNode) SetSuccessor

func (node *RPCNode) SetSuccessor(successorAddr *string, _ *string) error

manually set successor of node

func (*RPCNode) Successor

func (node *RPCNode) Successor(id []byte, rpcAddr *string) error

Successor method find the successor of given id. Successor node of id N is the first node whose id is either equal to N or follows N (in clockwise fashnion).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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