java.lang.Object
org.apache.lucene.index.TwoPhaseCommitTool
A utility for executing 2-phase commit on several objects.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThrown byexecute(TwoPhaseCommit...)when an object fails to commit().static classThrown byexecute(TwoPhaseCommit...)when an object fails to prepareCommit(). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidexecute(TwoPhaseCommit... objects) Executes a 2-phase commit algorithm by firstTwoPhaseCommit.prepareCommit()all objects and only if all succeed, it proceeds withTwoPhaseCommit.commit().private static voidrollback(TwoPhaseCommit... objects) rollback all objects, discarding any exceptions that occur.
-
Constructor Details
-
TwoPhaseCommitTool
private TwoPhaseCommitTool()No instance
-
-
Method Details
-
rollback
rollback all objects, discarding any exceptions that occur. -
execute
public static void execute(TwoPhaseCommit... objects) throws TwoPhaseCommitTool.PrepareCommitFailException, TwoPhaseCommitTool.CommitFailException Executes a 2-phase commit algorithm by firstTwoPhaseCommit.prepareCommit()all objects and only if all succeed, it proceeds withTwoPhaseCommit.commit(). If any of the objects fail on either the preparation or actual commit, it terminates andTwoPhaseCommit.rollback()all of them.NOTE: it may happen that an object fails to commit, after few have already successfully committed. This tool will still issue a rollback instruction on them as well, but depending on the implementation, it may not have any effect.
NOTE: if any of the objects are
null, this method simply skips over them.- Throws:
TwoPhaseCommitTool.PrepareCommitFailException- if any of the objects fail toTwoPhaseCommit.prepareCommit()TwoPhaseCommitTool.CommitFailException- if any of the objects fail toTwoPhaseCommit.commit()
-