Package org.apache.lucene.util
Interface TwoPhaseCommit
-
- All Known Subinterfaces:
TaxonomyWriter
- All Known Implementing Classes:
DirectoryTaxonomyWriter,IndexWriter,TwoPhaseCommitTool.TwoPhaseCommitWrapper
public interface TwoPhaseCommitAn interface for implementations that support 2-phase commit. You can useTwoPhaseCommitToolto execute a 2-phase commit algorithm over severalTwoPhaseCommits.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcommit()The second phase of a 2-phase commit.voidcommit(Map<String,String> commitData)Likecommit(), 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)Likecommit(), but takes an additional commit data to be included w/ the commit.voidrollback()Discards any changes that have occurred since the last commit.
-
-
-
Method Detail
-
prepareCommit
void prepareCommit() throws IOExceptionThe 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,rollback()is called to discard all changes since last successful commit.- Throws:
IOException
-
prepareCommit
void prepareCommit(Map<String,String> commitData) throws IOException
Likecommit(), 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.
- Throws:
IOException- See Also:
prepareCommit()
-
commit
void commit() throws IOExceptionThe second phase of a 2-phase commit. Implementations should ideally do very little work in this method (followingprepareCommit(), and after it returns, the caller can assume that the changes were successfully committed to the underlying storage.- Throws:
IOException
-
commit
void commit(Map<String,String> commitData) throws IOException
Likecommit(), but takes an additional commit data to be included w/ the commit.- Throws:
IOException- See Also:
commit(),prepareCommit(Map)
-
rollback
void rollback() throws IOExceptionDiscards any changes that have occurred since the last commit. In a 2-phase commit algorithm, where one of the objects failed tocommit()orprepareCommit(), this method is used to roll all other objects back to their previous state.- Throws:
IOException
-
-