- IPv4(String)
- Port(String)
- Node ID(String): md5 hash value of IP+Port
- Proximity(Int): Ping Time for this node
- Leaf Set(Pair<Set,Set>): Set of Nodes closest to the current node in terms of NodeID
- Routing Table(vector): Nodes in the ith row have i length prefix match with the current NodeID
- Neighbourhood Set(Set): Set of Nodes closest to the current node in terms of Proximity
- HashTable: To store Key, Value pairs locally
- Database: Singleton object to store all the Node relevant data like Routing tables, etc (contains locks for mutual exclusion)
- LogHandler: Singleton object to write to Log Files (LogError/LogMsg)
- Printer: Print Output/Error to console
- Network Interface: Interface between application and network(Write to/Read From network)
Used Protocol Buffers for message serialization and de-serialization
- JoinMe: Sent when a new node joins a network
- Join: Routed through the network while a new node joins
- RoutingUpdate: Updates sent by other nodes while joining the network
- AllStateUpdate: Update sent to all the nodes in the routing tables
- AddToHashTable: To add relevant key, value pairs to the Node
- SetValue: Store Key Value pair
- GetValue: Get Value of the given key
- DeleteNode: Delete the node entry from the routing tables
- Shutdown: Shutdown the pastry network
Route ( Destination node):
- Check if the destination node is within the range of the leafsets.
- If yes then we can reach the destination in one hop.
- Suppose ‘p’ is the length of the matched prefix between destination node and current node. Also let ‘i’ be the pth value in destination node id.
- Check if, entry for pth row and ith column is not NULL.
- If it is not NULL then route to it. Check in the union of routing table, leaf set and neighbour set. Choose the most suitable node. Then route to it.
- For Left Leaf set, we will ask for the leaf entries from the leftmost leaf. If we will find an entry that’s NodeId is less than ours. We will insert it in left leaf set.
- If no relevant entry is found. Then the same procedure is repeated with the next node from the previously selected node.
- For Right Leaf set same procedure is followed except that rightmost leaf is called first.
- We will ask for the neighbour set from the last neighbour of ours. If we find a new entry than we will insert it in neighbour set. Otherwise, We will repeat the same procedure with the next node from the previously selected node.
- Suppose R[p][i] is the entry which is needed to be repaired. The algorithm will ask for the R[p][i] entries from nodes R[p][j] for all j!=i.
- If no relevant entries are found than it will ask from next row and follows the same procedure until a relevant entry is found
- All the stored data is replicated at 3 different Nodes
- When a new node joins, data relevant to that node is sent while routing
- Lazy Repair: Fix Routing table entries if unavailable node detected while routing
- Timer Repair: Check of unavailable leaf Nodes every 30 seconds
- Create a replica of current Node’s data before exiting the Pastry Network
- Log messages for each node
- port : Assigns Port to the node
- port : Assigns IP and Port to the node
- create: Creates pastry Node
- join : Buddy Node to contact for joining the Pastry Network
- put : Store the key, value pair in the network
- get : Fetching the value of the input key
- lset: print the leaf set
- nset: print the neighbourhood set
- Routetable: print routing table
- quit: graceful exit of the node from the pastry network
- shutdown: shutdown the pastry network
- hashTable: print the node’s hashtable