Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

File Server : Chord-Distributed-Hash-Table


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.


Overview:

Example:

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...”.

screen shot 2017-10-22 at 12 26 02 pm

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.

1. Compile the interface definition file

$> 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.

2. Extending the server-side method stubs generated by Thrift

  1. 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.

  2. 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.

  3. 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.

  4. findSucc() given an identifier in the DHT’s key space, returns the DHT node that owns the id.

3. Run the initializer program

$> chmod +x init $> ./init nodex.txt The file (node.txt) should contain a list of IP addresses and ports, in the format “:”, of all of the running DHT nodes. For example, if four DHT nodes are running on remote01.cs.binghamton.edu port 9090, 9091, 9092, and 9093, then nodes.txt should contain: 128.226.180.163:9090 128.226.180.163:9091 128.226.180.163:9092 128.226.180.163:9093 The initializer program will print an error message if any of the specified DHT nodes is not available.

4. Test the File Server:

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.


Instructions to execute.

  1. thrift -gen java chord.thrift (To generate the chord classes. It will be generated in gen-java)
  2. make (This will compile the program)
  3. ./server.sh <port_no> (This will start the server on the mentioned port)
  4. ./init <nodes.txt> (Specify the txt file containing server and port details to poulate the fingure table)
  5. make clean (Optional : This will clean compiled .class files)
  6. Ctrl + C (To Terminate/kill the server)

Note: Client file for testing is not provided with this assignment.

Brief Description:

The Server implementation is in Java language. It has below two files.

Server.Java (present in java/src/)

  1. Server.java is the Server class (containing the main function) which start the server on the mentioned port
  2. The server is responsible to accept and serve the client request. Each request is serve on different thread.

FileStoreHandler.java (present in java/src)

  1. FileStoreHandler implements FileStore.Iface interface of thrift library to provide the implementation of 6 different server methods.
  2. For each server node, it stores the fingure table and the metadata information of all the files it own.
  3. It throws the SystemException in case the unauthorized file access request comes.

Client.java (present in java/src/)

  1. This file is for testing the Distributed Hash Table implementation.

Sample Input/Output:

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

Note: After the input is executed the file gets downloaded as client side.


About

A simple file server implementation based on distributed hash table (DHT) protocol with an architecture similar to the Chord system.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages