Three-phase commit can avoid some blocking failures only under strong timing and communication assumptions. During a network partition, participants on different sides may time out from different phases and make conflicting local decisions.
Design a ThreePhaseCommitPartitionAnalyzer class:
ThreePhaseCommitPartitionAnalyzer() creates a stateless analyzer.String analyze(String[] participantStates) returns the outcome after every participant applies the exercise's local timeout rule.
Each participant is in one of five states when communication is lost:
"precommit" or "committed" ends in commit."initial", "ready", or "aborted" ends in abort.
Return exactly:
"UNANIMOUS_COMMIT" if every participant ends committed."UNANIMOUS_ABORT" if every participant ends aborted."SPLIT_DECISION" if at least one participant commits and at least one aborts.
This is intentionally a local-timeout model: partitioned participants cannot exchange state before deciding.
Example 1:
Input:
Output:
Explanation: Every participant has reached or passed precommit, so every participant chooses commit.
Example 2:
Input:
Output:
Explanation: The ready participant locally aborts, while the precommit participant locally commits. Atomicity is lost.
Constraints
1 <= participantStates.length <= 200participantStates[i] is "initial", "ready", "precommit", "committed", or "aborted".- Return the classification strings exactly as written.
- At most
100 calls are made to analyze, and calls are independent.