Package org.apache.solr.update
Class CdcrTransactionLog
- java.lang.Object
-
- org.apache.solr.update.TransactionLog
-
- org.apache.solr.update.CdcrTransactionLog
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class CdcrTransactionLog extends TransactionLog
ExtendsTransactionLog
to:- reopen automatically the output stream if its reference count reached 0. This is achieved by extending
methods
incref()
,close()
andreopenOutputStream()
. - encode the number of records in the tlog file in the last commit record. The number of records will be
decoded and reuse if the tlog file is reopened. This is achieved by extending the constructor, and the
methods
writeCommit(CommitUpdateCommand)
andgetReader(long)
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
CdcrTransactionLog.CdcrLogReader
-
Nested classes/interfaces inherited from class org.apache.solr.update.TransactionLog
TransactionLog.FSReverseReader, TransactionLog.LogCodec, TransactionLog.LogReader, TransactionLog.ReverseReader, TransactionLog.SortedLogReader
-
-
Field Summary
-
Fields inherited from class org.apache.solr.update.TransactionLog
deleteOnClose, END_MESSAGE
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
TransactionLog.LogReader
getReader(long startingPos)
Returns a reader that can be used while a log is still in use.void
incref()
int
numRecords()
Returns the number of records in the log (currently includes the header and an optional commit).boolean
try_incref()
Modified to act likeincref()
in order to be compatible withUpdateLog.recoverFromLog()
.long
write(AddUpdateCommand cmd, long prevPointer)
Writes an add update command to the transaction log.long
writeCommit(CommitUpdateCommand cmd)
long
writeDelete(DeleteUpdateCommand cmd)
long
writeDeleteByQuery(DeleteUpdateCommand cmd)
-
Methods inherited from class org.apache.solr.update.TransactionLog
addGlobalStrings, checkWriteHeader, closeOutput, decref, endRecord, endsWithCommit, finish, forceClose, getLogSize, getLogSizeFromStream, getReverseReader, getSortedReader, lookup, position, toString, write, writeData, writeLogHeader
-
-
-
-
Method Detail
-
numRecords
public int numRecords()
Returns the number of records in the log (currently includes the header and an optional commit).- Overrides:
numRecords
in classTransactionLog
-
write
public long write(AddUpdateCommand cmd, long prevPointer)
Description copied from class:TransactionLog
Writes an add update command to the transaction log. This should be called only for writing in-place updates, or else pass -1 as the prevPointer.- Overrides:
write
in classTransactionLog
- Parameters:
cmd
- The add update command to be writtenprevPointer
- The pointer in the transaction log which this update depends on (applicable for in-place updates)- Returns:
- Returns the position pointer of the written update command
-
writeDelete
public long writeDelete(DeleteUpdateCommand cmd)
- Overrides:
writeDelete
in classTransactionLog
-
writeDeleteByQuery
public long writeDeleteByQuery(DeleteUpdateCommand cmd)
- Overrides:
writeDeleteByQuery
in classTransactionLog
-
writeCommit
public long writeCommit(CommitUpdateCommand cmd)
- Overrides:
writeCommit
in classTransactionLog
-
getReader
public TransactionLog.LogReader getReader(long startingPos)
Returns a reader that can be used while a log is still in use. Currently only *one* LogReader may be outstanding, and that log may only be used from a single thread.- Overrides:
getReader
in classTransactionLog
-
incref
public void incref()
- Overrides:
incref
in classTransactionLog
-
try_incref
public boolean try_incref()
Modified to act likeincref()
in order to be compatible withUpdateLog.recoverFromLog()
. Otherwise, we would have to duplicate the methodUpdateLog.recoverFromLog()
inCdcrUpdateLog
and change the callif (!ll.try_incref()) continue;
toincref();
.- Overrides:
try_incref
in classTransactionLog
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classTransactionLog
-
-