Your task is to develop a consensus server, and ensure that the code you develop is correct. The consensus server will JeroMQ use the ZeroMQ open source messaging library, receive proposed consensus values using threads, process them, and return the decided value as a result.
You should create a new project using Maven. In order to use JeroMQ, you must include the following lines in the <dependencies> section of your [login to view URL] file:
<dependency>
<groupId>[login to view URL]</groupId>
<artifactId>jeromq</artifactId>
<version>0.5.2</version>
</dependency>
To run your project with external dependencies, you can use the following command line, where "[login to view URL]" is the name of your Java package, and "hwserver" is the name of the class you wish to execute.
mvn exec:java -Dexec.mainClass='[login to view URL]'
You should use the ZeroMQ framework to develop a multithreaded server. You may wish to consider the JeroMQ's multithreaded service code.
JeroMQ's multithreaded service code creates a "router" and a "dealer." The router binds to a TCP port, and waits for client messages. The dealer transfers received messages to "worker" threads.
Each worker thread should submit the value it received from a client, to a Consensus object. That consensus object should inherit from the abstract Consensus class. Note that there are several important differences between the Consensus class given here, and the one provided in your textbook. First, since there is no longer a 1:1 mapping between threads and calls to the decide method (a single thread might handle more than one call to decide() for different clients), each thread must provide a unique index of the client, when it calls the decide() method. Second, since the decide() method must function for an arbitrary number of threads, we now use a ConcurrentHashMap, instead of an array, for proposed.
import [login to view URL];
import java.util.concurrent.*;
abstract class Consensus {
protected ConcurrentHashMap<Integer,Object> proposed =
new ConcurrentHashMap<Integer,Object>();
public void propose(int threadIdx, Object value) {
[login to view URL]("propose Id: " + threadIdx);
[login to view URL](threadIdx, value);
}
abstract public Object decide(int threadIdx, Object val);
}
There are quite a few Consensus objects, and each has a Consensus number.
Consensus Number Object
1 reader/writer registers
2 test & set, swap, fetch & add, queue, stack
2n-2 n-register assignment
∞ memory-to-memory move and swap, queue with peek, compare & swap, sticky register
Some Consensus objects, such as stack, test & set, queue, and several others, have a corresponding data structure in Java. Others, such as sticky register, do not, and must be implemented separately. For example, sticky register can be implemented as follows.
Hi
Greetings from MDS!
I would like to bid for this challenging opportunity . I have very good experience with core java and JMS/AMQP messaging systems . i understand your requirement and capable to implement all the features mentioned.
Thanks
MDS
I have experience with ZeroMQ and a lot of experience with various different consensus protocols. I would be able to do this in one day, providing you with clean code that would get you an A. I read all of the instructions and will be able to deliver you exactly what is required for submission provided by the screenshots.