This is an implementation of Bully Algoritm using Java RMI. The implementation assumes a node to be a server implementation in Java RMI.
1 Move to your project directory
$ cd [path to your directory]
2 Compile the source files. Replace destDir with your directory path
$ javac -d destDir BullyInterface.java Node1.java Node2.java Node3.java Node4.java
3 If no error message, Start the rmi registry
$ start rmiregistry
4 Start the nodes. Replace destDir with the path of your Directory
start java -classpath destDir -Djava.rmi.server.codebase=file:classDir/ bully.algorithm.Node1
start java -classpath destDir -Djava.rmi.server.codebase=file:classDir/ bully.algorithm.Node2
start java -classpath destDir -Djava.rmi.server.codebase=file:classDir/ bully.algorithm.Node3
start java -classpath destDir -Djava.rmi.server.codebase=file:classDir/ bully.algorithm.Node4
When a node is initiated it gives some output as well as start a fresh election.
When on the node terminal window press ctrl + C to terminate a node.
Note : Dont close the terminal window of a node by pressing the close button. This will generate errors