Package org.apache.lucene.util
Class TwoPhaseCommitTool.TwoPhaseCommitWrapper
- java.lang.Object
-
- org.apache.lucene.util.TwoPhaseCommitTool.TwoPhaseCommitWrapper
-
- All Implemented Interfaces:
TwoPhaseCommit
- Enclosing class:
- TwoPhaseCommitTool
public static final class TwoPhaseCommitTool.TwoPhaseCommitWrapper extends Object implements TwoPhaseCommit
A wrapper of aTwoPhaseCommit, which delegates all calls to the wrapped object, passing the specified commitData. This object is useful for use withTwoPhaseCommitTool.execute(TwoPhaseCommit...)if one would like to store commitData as part of the commit.
-
-
Constructor Summary
Constructors Constructor Description TwoPhaseCommitWrapper(TwoPhaseCommit tpc, Map<String,String> commitData)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcommit()The second phase of a 2-phase commit.voidcommit(Map<String,String> commitData)LikeTwoPhaseCommit.commit(), but takes an additional commit data to be included w/ the commit.voidprepareCommit()The first stage of a 2-phase commit.voidprepareCommit(Map<String,String> commitData)LikeTwoPhaseCommit.commit(), but takes an additional commit data to be included w/ the commit.voidrollback()Discards any changes that have occurred since the last commit.
-
-
-
Constructor Detail
-
TwoPhaseCommitWrapper
public TwoPhaseCommitWrapper(TwoPhaseCommit tpc, Map<String,String> commitData)
-
-
Method Detail
-
prepareCommit
public void prepareCommit() throws IOExceptionDescription copied from interface:TwoPhaseCommitThe first stage of a 2-phase commit. Implementations should do as much work as possible in this method, but avoid actual committing changes. If the 2-phase commit fails,TwoPhaseCommit.rollback()is called to discard all changes since last successful commit.- Specified by:
prepareCommitin interfaceTwoPhaseCommit- Throws:
IOException
-
prepareCommit
public void prepareCommit(Map<String,String> commitData) throws IOException
Description copied from interface:TwoPhaseCommitLikeTwoPhaseCommit.commit(), but takes an additional commit data to be included w/ the commit.NOTE: some implementations may not support any custom data to be included w/ the commit and may discard it altogether. Consult the actual implementation documentation for verifying if this is supported.
- Specified by:
prepareCommitin interfaceTwoPhaseCommit- Throws:
IOException- See Also:
TwoPhaseCommit.prepareCommit()
-
commit
public void commit() throws IOExceptionDescription copied from interface:TwoPhaseCommitThe second phase of a 2-phase commit. Implementations should ideally do very little work in this method (followingTwoPhaseCommit.prepareCommit(), and after it returns, the caller can assume that the changes were successfully committed to the underlying storage.- Specified by:
commitin interfaceTwoPhaseCommit- Throws:
IOException
-
commit
public void commit(Map<String,String> commitData) throws IOException
Description copied from interface:TwoPhaseCommitLikeTwoPhaseCommit.commit(), but takes an additional commit data to be included w/ the commit.- Specified by:
commitin interfaceTwoPhaseCommit- Throws:
IOException- See Also:
TwoPhaseCommit.commit(),TwoPhaseCommit.prepareCommit(Map)
-
rollback
public void rollback() throws IOExceptionDescription copied from interface:TwoPhaseCommitDiscards any changes that have occurred since the last commit. In a 2-phase commit algorithm, where one of the objects failed toTwoPhaseCommit.commit()orTwoPhaseCommit.prepareCommit(), this method is used to roll all other objects back to their previous state.- Specified by:
rollbackin interfaceTwoPhaseCommit- Throws:
IOException
-
-