It uses Apache Thrift interface definition file chord.thrift, that defines several operations that DHT supports. Refer https://en.wikipedia.org/wiki/Chord_(peer-to-peer) for details.
If ten nodes are in the DHT running on 10 different ports on “128.226.117.49:9090”, ..., “128.226.117.49:9099”, and we want to write the a file “example.txt”, owned by “guest”, then the key associated with this file SHA256(“guest:example.txt”)=“ad0c...” must be written to the node associated with the next SHA-256 value in the Chord id space. According to the Chord DHT specification (shown in below figure), this node is “128.226.117.49:9093’, which has an SHA-256 hash of “c529...”.
Every time the server is started the filesystem is initialized to be empty.The server stores files in the file system,and for simplicity it uses the current working directory from where it was run. This implementation did not implement the directory structure. In addition, the server executable takes a single command-line argument specifying the port where the Thrift service will listen for remote clients. For example: ./server 9090 It uses the Thrift’s TBinaryProtocol for marshalling and unmarshalling data structures. Multiple servers can run at the same time.
$> thrift -gen java chord.thrift
In http://thrift.apache.org/tutorial, you can find example clients and servers written in many of the languages that Thrift supports.
-
writeFile() given a name, owner, and contents, the corresponding file should be written to the server. Meta information, such as the owner, version, and content hash (use the SHA-256 hash) should also be stored at the server side.
-
readFile() if a file with a given name and owner exists on the server, both the contents and meta-information should be returned. Otherwise, a SystemException should be thrown and appropriate information indicating the cause of the exception should be included in the SystemException’s message field.
-
setFingertable() sets the current node’s fingertable to the fingertable provided in the argument of the function. The init program that will call this function, but you need to correctly implement this function on the server side.
-
findSucc() given an identifier in the DHT’s key space, returns the DHT node that owns the id.
Client.java test's the Chord-based file server implementation. The test program act as a client that issues remote procedure calls to the Chord servers to download/upload files on the Servers.
- thrift -gen java chord.thrift (To generate the chord classes. It will be generated in gen-java)
- make (This will compile the program)
- ./server.sh <port_no> (This will start the server on the mentioned port)
- ./init <nodes.txt> (Specify the txt file containing server and port details to poulate the fingure table)
- make clean (Optional : This will clean compiled .class files)
- Ctrl + C (To Terminate/kill the server)
The Server implementation is in Java language. It has below two files.
- Server.java is the Server class (containing the main function) which start the server on the mentioned port
- The server is responsible to accept and serve the client request. Each request is serve on different thread.
- FileStoreHandler implements FileStore.Iface interface of thrift library to provide the implementation of 6 different server methods.
- For each server node, it stores the fingure table and the metadata information of all the files it own.
- It throws the SystemException in case the unauthorized file access request comes.
- This file is for testing the Distributed Hash Table implementation.
Starting the Server: Whenever the server starts, it prints the server details. For example: $: /server.sh 9001 Server details**** Server NodeID: 67e9a5e34ec2bf3271361f48e19422fd03b6c0c6793659c9e4e3699aee112e0f Server IP: 128.226.180.165 Server Port: 9001
