Package org.apache.solr.update
Class TransactionLog
java.lang.Object
org.apache.solr.update.TransactionLog
- All Implemented Interfaces:
Closeable,AutoCloseable
Log Format: List{Operation, Version, ...} ADD, VERSION, DOC DELETE, VERSION, ID_BYTES
DELETE_BY_QUERY, VERSION, String
TODO: keep two files, one for [operation, version, id] and the other for the actual document data. That way we could throw away document log files more readily while retaining the smaller operation log files longer (and we can retrieve the stored fields from the latest documents from the index).
This would require keeping all source fields stored of course.
This would also allow to not log document data for requests with commit=true in them (since we know that if the request succeeds, all docs will be committed)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classprotected static interfaceOpensTransactionLog.ChannelFastInputStreamfromFileChannel.classclassclassprotected static interfaceOpensOutputStreamfromFileChannel.static classclass -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FileChannelprotected static final TransactionLog.ChannelInputStreamOpenerprotected TransactionLog.ChannelInputStreamOpenerprotected booleanstatic final Stringprotected org.apache.solr.common.util.FastOutputStreambooleanprotected OutputStreamprotected static final TransactionLog.OutputStreamOpenerprotected AtomicIntegerprotected static final org.apache.solr.common.util.JavaBinCodec.ObjectResolverprotected Path -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedTransactionLog(Path tlogFile, Collection<String> globalStrings, boolean openExisting, TransactionLog.OutputStreamOpener outputStreamOpener, TransactionLog.ChannelInputStreamOpener channelInputStreamOpener) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddGlobalStrings(Collection<String> strings) protected voidcheckWriteHeader(TransactionLog.LogCodec codec, org.apache.solr.common.SolrInputDocument optional) voidclose()voidMove to a read-only state, closing and releasing resources while keeping the log available for readsvoiddecref()protected voidendRecord(long startRecordPosition) booleanvoidfinish(UpdateLog.SyncLevel syncLevel) voidprotected longGets the log file data size.longlonggetReader(long startingPos) Returns a reader that can be used while a log is still in use.Returns a single threaded reverse readergetSortedReader(long startingPos) voidincref()lookup(long pos) intReturns the number of records in the log (currently includes the header and an optional commit).longposition()returns the current position in the log fileprotected voidsetWrittenCount(long fileStartOffset) Sets the counter of written data in theFastOutputStreamview of the log file, to reflect that we aren't starting at the beginning.toString()booleanlongwrite(AddUpdateCommand cmd) Writes an add update command to the transaction log.longwrite(AddUpdateCommand cmd, long prevPointer) Writes an add update command to the transaction log.longlonglonglongprotected void
-
Field Details
-
END_MESSAGE
- See Also:
-
tlog
-
channel
-
os
-
fos
protected org.apache.solr.common.util.FastOutputStream fos -
channelInputStreamOpener
-
isBuffer
public boolean isBuffer -
deleteOnClose
protected volatile boolean deleteOnClose -
refcount
-
globalStringMap
-
globalStringList
-
resolver
protected static final org.apache.solr.common.util.JavaBinCodec.ObjectResolver resolver -
OUTPUT_STREAM_OPENER
-
CHANNEL_INPUT_STREAM_OPENER
-
-
Constructor Details
-
TransactionLog
protected TransactionLog(Path tlogFile, Collection<String> globalStrings, boolean openExisting, TransactionLog.OutputStreamOpener outputStreamOpener, TransactionLog.ChannelInputStreamOpener channelInputStreamOpener) -
TransactionLog
protected TransactionLog()
-
-
Method Details
-
setWrittenCount
Sets the counter of written data in theFastOutputStreamview of the log file, to reflect that we aren't starting at the beginning.- Throws:
IOException
-
getLogFileSize
Gets the log file data size.- Throws:
IOException
-
numRecords
public int numRecords()Returns the number of records in the log (currently includes the header and an optional commit). Note: currently returns 0 for reopened existing log files. -
endsWithCommit
- Throws:
IOException
-
writeData
-
addGlobalStrings
-
writeLogHeader
- Throws:
IOException
-
endRecord
- Throws:
IOException
-
checkWriteHeader
protected void checkWriteHeader(TransactionLog.LogCodec codec, org.apache.solr.common.SolrInputDocument optional) throws IOException - Throws:
IOException
-
write
Writes an add update command to the transaction log. This is not applicable for in-place updates; usewrite(AddUpdateCommand, long). (The previous pointer (applicable for in-place updates) is set to -1 while writing the command to the transaction log.)- Parameters:
cmd- The add update command to be written- Returns:
- Returns the position pointer of the written update command
- See Also:
-
write
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.- 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
-
writeDeleteByQuery
-
writeCommit
-
lookup
-
incref
public void incref() -
try_incref
public boolean try_incref() -
decref
public void decref() -
position
public long position()returns the current position in the log file -
closeOutput
public void closeOutput()Move to a read-only state, closing and releasing resources while keeping the log available for reads -
finish
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
forceClose
public void forceClose() -
toString
-
getLogSize
public long getLogSize() -
getLogSizeFromStream
public long getLogSizeFromStream()- Returns:
- the FastOutputStream size
-
getReader
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.- Throws:
IOException
-
getSortedReader
- Throws:
IOException
-
getReverseReader
Returns a single threaded reverse reader- Throws:
IOException
-