org.apache.solr.update
Class TransactionLog

java.lang.Object
  extended by org.apache.solr.update.TransactionLog
Direct Known Subclasses:
HdfsTransactionLog

public class TransactionLog
extends Object

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
 class TransactionLog.FSReverseReader
           
 class TransactionLog.LogCodec
           
 class TransactionLog.LogReader
           
 class TransactionLog.ReverseReader
           
 
Field Summary
protected  boolean deleteOnClose
           
static String END_MESSAGE
           
static org.slf4j.Logger log
           
 
Constructor Summary
protected TransactionLog()
           
 
Method Summary
protected  void addGlobalStrings(Collection<String> strings)
           
protected  void close()
           
 void decref()
           
protected  void endRecord(long startRecordPosition)
           
 boolean endsWithCommit()
           
 void finish(UpdateLog.SyncLevel syncLevel)
           
 void forceClose()
           
 TransactionLog.LogReader getReader(long startingPos)
          Returns a reader that can be used while a log is still in use.
 TransactionLog.ReverseReader getReverseReader()
          Returns a single threaded reverse reader
 void incref()
           
 Object lookup(long pos)
           
 int numRecords()
          Returns the number of records in the log (currently includes the header and an optional commit).
 long position()
          returns the current position in the log file
 void rollback(long pos)
           
 long snapshot()
          takes a snapshot of the current position and number of records for later possible rollback, and returns the position
 String toString()
           
 boolean try_incref()
           
 long write(AddUpdateCommand cmd, int flags)
           
 long writeCommit(CommitUpdateCommand cmd, int flags)
           
 long writeData(Object o)
           
 long writeDelete(DeleteUpdateCommand cmd, int flags)
           
 long writeDeleteByQuery(DeleteUpdateCommand cmd, int flags)
           
protected  void writeLogHeader(TransactionLog.LogCodec codec)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

public static org.slf4j.Logger log

END_MESSAGE

public static final String END_MESSAGE
See Also:
Constant Field Values

deleteOnClose

protected volatile boolean deleteOnClose
Constructor Detail

TransactionLog

protected TransactionLog()
Method Detail

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

public boolean endsWithCommit()
                       throws IOException
Throws:
IOException

snapshot

public long snapshot()
takes a snapshot of the current position and number of records for later possible rollback, and returns the position


rollback

public void rollback(long pos)
              throws IOException
Throws:
IOException

writeData

public long writeData(Object o)

addGlobalStrings

protected void addGlobalStrings(Collection<String> strings)

writeLogHeader

protected void writeLogHeader(TransactionLog.LogCodec codec)
                       throws IOException
Throws:
IOException

endRecord

protected void endRecord(long startRecordPosition)
                  throws IOException
Throws:
IOException

write

public long write(AddUpdateCommand cmd,
                  int flags)

writeDelete

public long writeDelete(DeleteUpdateCommand cmd,
                        int flags)

writeDeleteByQuery

public long writeDeleteByQuery(DeleteUpdateCommand cmd,
                               int flags)

writeCommit

public long writeCommit(CommitUpdateCommand cmd,
                        int flags)

lookup

public Object lookup(long pos)

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


finish

public void finish(UpdateLog.SyncLevel syncLevel)

close

protected void close()

forceClose

public void forceClose()

toString

public String toString()
Overrides:
toString in class Object

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.


getReverseReader

public TransactionLog.ReverseReader getReverseReader()
                                              throws IOException
Returns a single threaded reverse reader

Throws:
IOException


Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.