public class UpdateLog extends Object implements PluginInfoInitialized, SolrMetricProducer
Modifier and Type | Class and Description |
---|---|
static class |
UpdateLog.DBQ
Holds the query and the version for a DeleteByQuery command
|
static class |
UpdateLog.LogPtr |
class |
UpdateLog.RecentUpdates |
static class |
UpdateLog.RecoveryInfo |
static class |
UpdateLog.State |
static class |
UpdateLog.SyncLevel |
Modifier and Type | Field and Description |
---|---|
static int |
ADD |
protected com.codahale.metrics.Meter |
applyingBufferedOpsMeter |
protected com.codahale.metrics.Gauge<Integer> |
bufferedOpsGauge |
protected boolean |
cancelApplyBufferUpdate |
static int |
COMMIT |
protected com.codahale.metrics.Meter |
copyOverOldUpdatesMeter |
protected String |
dataDir |
protected UpdateLog.SyncLevel |
defaultSyncLevel |
static int |
DELETE |
static int |
DELETE_BY_QUERY |
protected LinkedList<UpdateLog.DBQ> |
deleteByQueries |
static int |
FLAG_GAP |
static int |
FLAGS_IDX
The index of the flags value in an entry from the transaction log.
|
protected Collection<String> |
globalStrings |
protected String |
lastDataDir |
static String |
LOG_FILENAME_PATTERN |
protected Deque<TransactionLog> |
logs |
protected Map<BytesRef,UpdateLog.LogPtr> |
map |
protected int |
maxNumLogsToKeep |
protected Long |
maxVersionFromIndex |
protected LinkedList<TransactionLog> |
newestLogsOnStartup |
protected int |
numDeletesByQueryToKeep |
protected int |
numDeletesToKeep |
protected int |
numOldRecords |
protected int |
numRecordsToKeep |
protected int |
numVersionBuckets |
protected LinkedHashMap<BytesRef,UpdateLog.LogPtr> |
oldDeletes |
static int |
OPERATION_MASK |
protected int |
operationFlags |
static int |
PREV_POINTER_IDX
The index of the previous pointer in an entry from the transaction log.
|
static int |
PREV_VERSION_IDX
The index of the previous version in an entry from the transaction log.
|
protected Map<BytesRef,UpdateLog.LogPtr> |
prevMap |
protected Map<BytesRef,UpdateLog.LogPtr> |
prevMap2 |
protected TransactionLog |
prevMapLog |
protected TransactionLog |
prevMapLog2 |
protected TransactionLog |
prevTlog |
protected UpdateLog.RecoveryInfo |
recoveryInfo |
protected com.codahale.metrics.Meter |
replayOpsMeter |
protected UpdateLog.State |
state |
static Runnable |
testing_logReplayFinishHook |
static Runnable |
testing_logReplayHook |
protected TransactionLog |
tlog |
static String |
TLOG_NAME |
protected File |
tlogDir |
protected String[] |
tlogFiles |
static int |
UPDATE_INPLACE |
static int |
VERSION_IDX
The index of the _version_ value in an entry from the transaction log.
|
protected VersionInfo |
versionInfo |
Constructor and Description |
---|
UpdateLog() |
Modifier and Type | Method and Description |
---|---|
void |
add(AddUpdateCommand cmd) |
void |
add(AddUpdateCommand cmd,
boolean clearCaches) |
protected void |
addOldLog(TransactionLog oldLog,
boolean removeOld) |
Future<UpdateLog.RecoveryInfo> |
applyBufferedUpdates()
Returns the Future to wait on, or null if no replay was needed
|
long |
applyPartialUpdates(BytesRef id,
long prevPointer,
long prevVersion,
Set<String> onlyTheseFields,
SolrDocumentBase latestPartialDoc)
Goes over backwards, following the prevPointer, to merge all partial updates into the passed doc.
|
void |
bufferUpdates() |
void |
cancelApplyBufferedUpdates() |
void |
clearLog(SolrCore core,
PluginInfo ulogPluginInfo)
Clears the logs on the file system.
|
void |
close(boolean committed) |
void |
close(boolean committed,
boolean deleteOnClose) |
static AddUpdateCommand |
convertTlogEntryToAddUpdateCommand(SolrQueryRequest req,
List entry,
int operation,
long version)
Given a entry from the transaction log containing a document, return a new AddUpdateCommand that
can be applied to ADD the document or do an UPDATE_INPLACE.
|
protected void |
copyAndSwitchToNewTlog(CommitUpdateCommand cuc) |
void |
copyOverBufferingUpdates(CommitUpdateCommand cuc)
Block updates, append a commit at current tlog,
then copy over buffer updates to new tlog and bring back ulog to active state.
|
void |
copyOverOldUpdates(CommitUpdateCommand cuc)
Block updates, append a commit at current tlog, then copy over updates to a new tlog.
|
void |
copyOverOldUpdates(long commitVersion)
Copy over updates from prevTlog or last tlog (in tlog folder) to a new tlog
|
void |
delete(DeleteUpdateCommand cmd) |
void |
deleteAll()
currently for testing only
|
void |
deleteByQuery(DeleteUpdateCommand cmd) |
static void |
deleteFile(File file) |
boolean |
dropBufferedUpdates()
Returns true if we were able to drop buffered updates and return to the ACTIVE state
|
protected void |
ensureLog() |
void |
finish(UpdateLog.SyncLevel syncLevel) |
Long |
getCurrentMaxVersion() |
List<UpdateLog.DBQ> |
getDBQNewer(long version) |
org.apache.hadoop.fs.FileSystem |
getFs() |
long |
getLastLogId() |
String |
getLogDir() |
String[] |
getLogList(File directory) |
int |
getMaxNumLogsToKeep() |
int |
getNumRecordsToKeep() |
int |
getNumVersionBuckets() |
UpdateLog.RecentUpdates |
getRecentUpdates()
The RecentUpdates object returned must be closed after use
|
int |
getStartingOperation() |
List<Long> |
getStartingVersions() |
UpdateLog.State |
getState() |
protected String |
getTlogDir(SolrCore core,
PluginInfo info) |
long |
getTotalLogsNumber() |
long |
getTotalLogsSize() |
VersionInfo |
getVersionInfo() |
boolean |
hasUncommittedChanges() |
void |
init(PluginInfo info) |
void |
init(UpdateHandler uhandler,
SolrCore core) |
void |
initializeMetrics(SolrMetricManager manager,
String registry,
String scope)
Initializes metrics specific to this producer
|
Object |
lookup(BytesRef indexedId) |
Long |
lookupVersion(BytesRef indexedId) |
protected void |
newMap() |
TransactionLog |
newTransactionLog(File tlogFile,
Collection<String> globalStrings,
boolean openExisting)
Returns a new
TransactionLog . |
protected static int |
objToInt(Object obj,
int def) |
void |
openRealtimeSearcher()
Opens a new realtime searcher and clears the id caches.
|
void |
postCommit(CommitUpdateCommand cmd) |
void |
postSoftCommit(CommitUpdateCommand cmd) |
void |
preCommit(CommitUpdateCommand cmd) |
void |
preSoftCommit(CommitUpdateCommand cmd) |
Future<UpdateLog.RecoveryInfo> |
recoverFromCurrentLog()
Replay current tlog, so all updates will be written to index.
|
Future<UpdateLog.RecoveryInfo> |
recoverFromLog() |
void |
seedBucketsWithHighestVersion(SolrIndexSearcher newSearcher) |
protected Long |
seedBucketsWithHighestVersion(SolrIndexSearcher newSearcher,
VersionInfo versions)
Used to seed all version buckets with the max value of the version field in the index.
|
String |
toString() |
public static String LOG_FILENAME_PATTERN
public static String TLOG_NAME
public static final int ADD
public static final int DELETE
public static final int DELETE_BY_QUERY
public static final int COMMIT
public static final int UPDATE_INPLACE
public static final int FLAG_GAP
public static final int OPERATION_MASK
public static final int FLAGS_IDX
public static final int VERSION_IDX
public static final int PREV_POINTER_IDX
public static final int PREV_VERSION_IDX
protected UpdateLog.State state
protected int operationFlags
protected TransactionLog tlog
protected TransactionLog prevTlog
protected final Deque<TransactionLog> logs
protected LinkedList<TransactionLog> newestLogsOnStartup
protected int numOldRecords
protected Map<BytesRef,UpdateLog.LogPtr> map
protected Map<BytesRef,UpdateLog.LogPtr> prevMap
protected Map<BytesRef,UpdateLog.LogPtr> prevMap2
protected TransactionLog prevMapLog
protected TransactionLog prevMapLog2
protected final int numDeletesToKeep
protected final int numDeletesByQueryToKeep
protected int numRecordsToKeep
protected int maxNumLogsToKeep
protected int numVersionBuckets
protected Long maxVersionFromIndex
protected LinkedHashMap<BytesRef,UpdateLog.LogPtr> oldDeletes
protected LinkedList<UpdateLog.DBQ> deleteByQueries
protected String[] tlogFiles
protected File tlogDir
protected Collection<String> globalStrings
protected String dataDir
protected String lastDataDir
protected VersionInfo versionInfo
protected UpdateLog.SyncLevel defaultSyncLevel
protected volatile boolean cancelApplyBufferUpdate
protected com.codahale.metrics.Gauge<Integer> bufferedOpsGauge
protected com.codahale.metrics.Meter applyingBufferedOpsMeter
protected com.codahale.metrics.Meter replayOpsMeter
protected com.codahale.metrics.Meter copyOverOldUpdatesMeter
public static Runnable testing_logReplayHook
public static Runnable testing_logReplayFinishHook
protected UpdateLog.RecoveryInfo recoveryInfo
public org.apache.hadoop.fs.FileSystem getFs()
public long getTotalLogsSize()
public long getTotalLogsNumber()
public VersionInfo getVersionInfo()
public int getNumRecordsToKeep()
public int getMaxNumLogsToKeep()
public int getNumVersionBuckets()
protected static int objToInt(Object obj, int def)
public void init(PluginInfo info)
init
in interface PluginInfoInitialized
public void init(UpdateHandler uhandler, SolrCore core)
public void initializeMetrics(SolrMetricManager manager, String registry, String scope)
SolrMetricProducer
initializeMetrics
in interface SolrMetricProducer
manager
- an instance of SolrMetricManager
registry
- registry name where metrics are registeredscope
- scope of the metrics (eg. handler name) to separate metrics of
instances of the same component executing in different contextspublic TransactionLog newTransactionLog(File tlogFile, Collection<String> globalStrings, boolean openExisting)
TransactionLog
. Sub-classes can override this method to
change the implementation of the transaction log.public String getLogDir()
public int getStartingOperation()
protected void addOldLog(TransactionLog oldLog, boolean removeOld)
public long getLastLogId()
public void add(AddUpdateCommand cmd)
public void add(AddUpdateCommand cmd, boolean clearCaches)
public void delete(DeleteUpdateCommand cmd)
public void deleteByQuery(DeleteUpdateCommand cmd)
public void openRealtimeSearcher()
public void deleteAll()
public List<UpdateLog.DBQ> getDBQNewer(long version)
protected void newMap()
public boolean hasUncommittedChanges()
public void preCommit(CommitUpdateCommand cmd)
public void postCommit(CommitUpdateCommand cmd)
public void preSoftCommit(CommitUpdateCommand cmd)
public void postSoftCommit(CommitUpdateCommand cmd)
public long applyPartialUpdates(BytesRef id, long prevPointer, long prevVersion, Set<String> onlyTheseFields, SolrDocumentBase latestPartialDoc)
id
- Binary representation of the unique key fieldprevPointer
- Pointer to the previous entry in the ulog, based on which the current in-place update was made.prevVersion
- Version of the previous entry in the ulog, based on which the current in-place update was made.onlyTheseFields
- When a non-null set of field names is passed in, the resolve process only attempts to populate
the given fields in this set. When this set is null, it resolves all fields.latestPartialDoc
- Partial document that is to be populatedpublic void finish(UpdateLog.SyncLevel syncLevel)
public Future<UpdateLog.RecoveryInfo> recoverFromLog()
public Future<UpdateLog.RecoveryInfo> recoverFromCurrentLog()
public void copyOverBufferingUpdates(CommitUpdateCommand cuc)
cuc
- any updates that have version larger than the version of cuc will be copied overpublic void copyOverOldUpdates(CommitUpdateCommand cuc)
cuc
- any updates that have version larger than the version of cuc will be copied overprotected void copyAndSwitchToNewTlog(CommitUpdateCommand cuc)
public void copyOverOldUpdates(long commitVersion)
commitVersion
- any updates that have version larger than the commitVersion will be copied overprotected void ensureLog()
public void close(boolean committed)
public void close(boolean committed, boolean deleteOnClose)
public UpdateLog.RecentUpdates getRecentUpdates()
public void bufferUpdates()
public boolean dropBufferedUpdates()
public Future<UpdateLog.RecoveryInfo> applyBufferedUpdates()
public UpdateLog.State getState()
public static AddUpdateCommand convertTlogEntryToAddUpdateCommand(SolrQueryRequest req, List entry, int operation, long version)
req
- The request to use as the owner of the new AddUpdateCommandentry
- Entry from the transaction log that contains the document to be addedoperation
- The value of the operation flag; this must be either ADD or UPDATE_INPLACE --
if it is UPDATE_INPLACE then the previous version will also be read from the entryversion
- Version already obtained from the entry.public void cancelApplyBufferedUpdates()
public static void deleteFile(File file)
protected String getTlogDir(SolrCore core, PluginInfo info)
public void clearLog(SolrCore core, PluginInfo ulogPluginInfo)
core
- the SolrCoreulogPluginInfo
- the init info for the UpdateHandlerpublic Long getCurrentMaxVersion()
protected Long seedBucketsWithHighestVersion(SolrIndexSearcher newSearcher, VersionInfo versions)
public void seedBucketsWithHighestVersion(SolrIndexSearcher newSearcher)
Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.