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 void
commit()
The second phase of a 2-phase commit.void
commit(Map<String,String> commitData)
LikeTwoPhaseCommit.commit()
, but takes an additional commit data to be included w/ the commit.void
prepareCommit()
The first stage of a 2-phase commit.void
prepareCommit(Map<String,String> commitData)
LikeTwoPhaseCommit.commit()
, but takes an additional commit data to be included w/ the commit.void
rollback()
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 IOException
Description copied from interface:TwoPhaseCommit
The 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:
prepareCommit
in interfaceTwoPhaseCommit
- Throws:
IOException
-
prepareCommit
public void prepareCommit(Map<String,String> commitData) throws IOException
Description copied from interface:TwoPhaseCommit
LikeTwoPhaseCommit.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:
prepareCommit
in interfaceTwoPhaseCommit
- Throws:
IOException
- See Also:
TwoPhaseCommit.prepareCommit()
-
commit
public void commit() throws IOException
Description copied from interface:TwoPhaseCommit
The 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:
commit
in interfaceTwoPhaseCommit
- Throws:
IOException
-
commit
public void commit(Map<String,String> commitData) throws IOException
Description copied from interface:TwoPhaseCommit
LikeTwoPhaseCommit.commit()
, but takes an additional commit data to be included w/ the commit.- Specified by:
commit
in interfaceTwoPhaseCommit
- Throws:
IOException
- See Also:
TwoPhaseCommit.commit()
,TwoPhaseCommit.prepareCommit(Map)
-
rollback
public void rollback() throws IOException
Description copied from interface:TwoPhaseCommit
Discards 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:
rollback
in interfaceTwoPhaseCommit
- Throws:
IOException
-
-