Project Overview This Java project simulates the Paxos consensus algorithm through a mock council election scenario. It demonstrates how multiple nodes (members) in a distributed system can agree on a single value, despite the presence of network delays, failures, and concurrent operations. This project is ideal for understanding the fundamental mechanics of the Paxos protocol in distributed computing.
Description: This is the main driver class for the simulation. It sets up the simulation environment, initializes all council members, and executes various test scenarios to demonstrate how the Paxos algorithm handles simultaneous proposals, immediate responses, and varied response scenarios including artificial delays and member failures. Functionality: Initializes member instances with unique identifiers and network ports. Simulates three primary test scenarios: simultaneous proposals, immediate unanimous responses, and responses with varied delays or failures. Manages the lifecycle of the simulation including the setup, execution of test cases, and orderly shutdown of member instances.
Description: Represents a council member in the Paxos election. Each member can act as a proposer, acceptor, and learner, which are roles defined within the Paxos protocol to facilitate the consensus process. Functionality: Handles incoming network connections and messages related to the Paxos protocol phases: prepare, promise, accept request, and accepted. Maintains internal state to track the highest proposal numbers seen and accepted, as well as the value associated with those proposals. Manages network communications to send and receive Paxos-related messages to and from other members. Can simulate network delays and failures to test the robustness of the consensus process under adverse conditions.
Description: Defines the structure of messages exchanged between members during the Paxos consensus process. Each message type corresponds to a step in the Paxos protocol. Functionality: Encapsulates data fields such as message type, proposal number, proposer ID, and the value being proposed or accepted. Provides serialization capabilities to facilitate easy transmission of messages over network sockets.
Prerequisites Java Development Kit (JDK): Ensure you have JDK installed on your system. You can download it from Oracle's website or other JDK providers like AdoptOpenJDK. Eclipse IDE: Install Eclipse IDE for Java Developers from Eclipse Downloads. Make sure it includes support for Maven; most Java bundles include this by default. Maven: Eclipse's embedded Maven should suffice, but you can also install Maven separately on your system if required. Importing the Project into Eclipse Open Eclipse and select a workspace. Import the Maven project: Go to File > Import... Select Existing Maven Projects under the Maven folder. Click Next. Browse to the root directory of your Maven project where the pom.xml file is located. Ensure that the pom.xml file is selected, then click Finish. Running the Project Through Eclipse Run the project directly from Eclipse:
Right-click on the project in the Project Explorer. Go to Run As > Maven build... In the Goals field, type clean install to clean and build the project. Click Run to execute the build. This will compile the code, run any tests, and package the application (if applicable). Running a specific class with a main method:
Right-click on the class in the Project Explorer. Go to Run As > Java Application. Using Maven Commands in Eclipse Open the Maven Console in Eclipse: Go to Window > Show View > Console. Click the Open Console drop-down in the Console view. Select Maven Console. Run Maven commands: Right-click on the project in the Project Explorer. Select Run As > Maven build... Enter any Maven commands (e.g., clean, compile, test, package) in the Goals field. Click Run. Command Line Usage You can also run Maven commands directly from the command line outside of Eclipse:
cd /path/to/your/project
mvn clean
mvn compile
mvn test
mvn package
mvn install
Detailed logs of the simulation can be viewed in the terminal to understand the step-by-step execution of the Paxos protocol.
For detailed review, the main method output screenshots and printouts from testing code are provided within the project directory.
1] Chatgpt :: Utilized ChatGPT-4 for consultation on multiple queries including: Verification of grammar correctness and comments. coding and Debugging assistance for code. Maven configurations and established best practices in software development.
2] Stack Overflow :: In the development of this project, Stack Overflow served as an essential resource for addressing specific programming challenges and troubleshooting errors encountered during implementation.
3] Github :: Code samples and libraries hosted on GitHub were leveraged to adopt best practices and integrate reliable, community-vetted patterns into our application.
4] Youtube :: YouTube was utilized for accessing detailed video tutorials and expert guidance that helped clarify complex programming concepts and implementation strategies.
5] In-depth explanations and technical insights on the Paxos algorithm were sourced from Rutgers University's course materials, available at https://people.cs.rutgers.edu/~pxk/417/notes/paxos.html.
6] Conceptual understanding and implementation details of the Paxos algorithm were enhanced by the articles available on Geeks for Geeks.