Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/soheshdoshi/2-phase-commit
https://github.com/soheshdoshi/2-phase-commit
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/soheshdoshi/2-phase-commit
- Owner: soheshdoshi
- Created: 2024-06-11T12:28:28.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-06-11T12:37:14.000Z (7 months ago)
- Last Synced: 2024-06-11T13:57:12.854Z (7 months ago)
- Language: Python
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.