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 |
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 |
clearLog(SolrCore core,
PluginInfo ulogPluginInfo)
Clears the logs on the file system.
|
void |
close(boolean committed) |
void |
close(boolean committed,
boolean deleteOnClose) |
void |
commitAndSwitchToNewTlog(CommitUpdateCommand cuc)
Block updates, append a commit at current tlog, then copy over updates to a new tlog.
|
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.
|
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(long commitVersion) |
void |
copyOverOldUpdates(long commitVersion,
TransactionLog oldTlog)
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
|
protected void |
deleteBufferLogs() |
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 |
ensureBufferTlog() |
protected void |
ensureLog() |
boolean |
existOldBufferLog() |
void |
finish(UpdateLog.SyncLevel syncLevel) |
String[] |
getBufferLogList(File directory) |
long |
getCurrentLogSizeFromStream() |
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
|
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 tag,
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() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
initializeMetrics
public static String LOG_FILENAME_PATTERN
public static String TLOG_NAME
public static String BUFFER_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 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 TransactionLog bufferTlog
protected TransactionLog tlog
protected TransactionLog prevTlog
protected TransactionLog prevTlogOnPrecommit
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 boolean existOldBufferLog
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
protected SolrMetricManager metricManager
protected String registryName
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 getCurrentLogSizeFromStream()
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 tag, String scope)
SolrMetricProducer
Note: for back-compatibility this method by default calls SolrMetricProducer.initializeMetrics(SolrMetricManager, String, String)
.
initializeMetrics
in interface SolrMetricProducer
manager
- an instance of SolrMetricManager
registry
- registry name where metrics are registeredtag
- symbolic tag that represents a group of related instances that
have the same life-cycle. Parent component can use the tag
when
calling SolrMetricManager.unregisterGauges(String, String)
to unregister metrics created by this instance of the producer.scope
- 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 boolean existOldBufferLog()
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 commitAndSwitchToNewTlog(CommitUpdateCommand cuc)
cuc
- any updates that have version larger than the version of cuc will be copied overpublic void copyOverOldUpdates(long commitVersion)
public void copyOverOldUpdates(long commitVersion, TransactionLog oldTlog)
commitVersion
- any updates that have version larger than the commitVersion will be copied overprotected void ensureBufferTlog()
protected void deleteBufferLogs()
protected 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 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-2018 Apache Software Foundation. All Rights Reserved.