Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/soheshdoshi/2-phase-commit


https://github.com/soheshdoshi/2-phase-commit

Last synced: about 2 months ago
JSON representation

Awesome Lists containing this project

README

        

# Two-Phase Commit Protocol (2PC) Simulation in Python

## Explanation

### Participant Class
Simulates a participant in the 2PC protocol. It has methods to vote on the transaction and to commit or abort the transaction.

### Coordinator Class
Manages the 2PC protocol. It sends the prepare message, collects votes, and then sends either a commit or abort message based on the votes.

### simulate_2pc Function
Creates participants and a coordinator, then initiates the 2PC protocol.

## Running the Code
To run the code, simply execute the script. It will simulate the 2PC protocol with random votes from the participants.

This is a basic simulation and doesn't include network communication, persistence, or fault tolerance mechanisms. In a real-world implementation, you would need to handle these aspects to ensure the robustness and reliability of the 2PC protocol.