Skip to content

Distributed Map - Fundamentals of Distributed Systems @ University of Minho

Notifications You must be signed in to change notification settings

ribeiropdiogo/distributed-map

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Distributed Map

The Distributed Map consists in a Distributed Key Value store built using Java. It was built using CompletableFuture and concepts like Causal Ordering. The keys consist in long values and each key has a respective value which is an byte[]. The usage of the Distributed Map is simplified with the usage of our Distributed Map API.

API

The available API has 2 methods:

Put

This methods receives a Map<Long,byte[]> as parameter and stores the data in the respective servers.

  CompletableFuture<Void> put(Map<Long,byte[]> values)

Get

This methods receives a Collection<Long> containing keys as parameter and retrieves the data from the respective servers.

  CompletableFuture<Map<Long,byte[]>> get(Collection<Long> keys)

How It Works

The distribution of keys and values between the servers is done using a hash function, that returns the number of a server given a key. Each put or getrequest uses this hash function. Every operation is translated to a Request which is sent via AsynchronousSocketChannels to our servers. Every Request needs to contact the ClockServer in order to get a "ticket". This is used to assure some properties like causal ordering.

Usage

The first step is to setup the servers anda the ClockServer. Each server has a argument to specify it's number (-n 0, -n 1, ...) . The numbering system start with 0 and needs to be sequential. The ClockServer has no arguments.

After setting up th servers you can import the API and use the DistributedMap object as you wish:

  DistributedMap dm = new DistributedMap();
  ...
  dm.put(...);
  dm.get(...);