You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by yo...@apache.org on 2011/12/02 05:09:51 UTC
svn commit: r1209357 - in /lucene/dev/branches/solrcloud/solr:
core/src/java/org/apache/solr/update/FSUpdateLog.java
core/src/java/org/apache/solr/update/TransactionLog.java
core/src/java/org/apache/solr/update/UpdateLog.java testlogging.properties
Author: yonik
Date: Fri Dec 2 04:09:50 2011
New Revision: 1209357
URL: http://svn.apache.org/viewvc?rev=1209357&view=rev
Log:
support for replaying from middle of tlog
Modified:
lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/FSUpdateLog.java
lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/TransactionLog.java
lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/UpdateLog.java
lucene/dev/branches/solrcloud/solr/testlogging.properties
Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/FSUpdateLog.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/FSUpdateLog.java?rev=1209357&r1=1209356&r2=1209357&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/FSUpdateLog.java (original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/FSUpdateLog.java Fri Dec 2 04:09:50 2011
@@ -560,10 +560,6 @@ public class FSUpdateLog extends UpdateL
assert state == State.ACTIVE;
recoveryInfo = new RecoveryInfo();
- // TODO: currently we don't keep track of where we are in an existing
- // transaction log (if there have already been updates) and
- // we start at the beginning when we replay.
-
// block all updates to eliminate race conditions
// reading state and acting on it in the update processor
versionInfo.blockUpdates();
@@ -572,6 +568,11 @@ public class FSUpdateLog extends UpdateL
log.info("Starting to buffer updates. " + this);
}
+ // since we blocked updates, this synchronization shouldn't strictly be necessary.
+ synchronized (this) {
+ recoveryInfo.positionOfStart = tlog == null ? 0 : tlog.position();
+ }
+
state = State.BUFFERING;
} finally {
versionInfo.unblockUpdates();
@@ -647,7 +648,7 @@ public class FSUpdateLog extends UpdateL
uhandler.core.log.warn("Starting log replay " + tlogReader);
- tlogReader = translog.getReader();
+ tlogReader = translog.getReader(recoveryInfo.positionOfStart);
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(DistributedUpdateProcessor.SEEN_LEADER, true);
Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/TransactionLog.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/TransactionLog.java?rev=1209357&r1=1209356&r2=1209357&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/TransactionLog.java (original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/TransactionLog.java Fri Dec 2 04:09:50 2011
@@ -141,7 +141,7 @@ public class TransactionLog {
TransactionLog(File tlogFile, Collection<String> globalStrings, boolean openExisting) {
try {
if (debug) {
- log.debug("New TransactionLog file=" + tlogFile + ", exists=" + tlogFile.exists() + ", size="+tlogFile.length() + ", openExisting=" + openExisting);
+ log.debug("New TransactionLog file=" + tlogFile + ", exists=" + tlogFile.exists() + ", size=" + tlogFile.length() + ", openExisting=" + openExisting);
}
this.tlogFile = tlogFile;
@@ -362,6 +362,13 @@ public class TransactionLog {
}
}
+ /** returns the current position in the log file */
+ public long position() {
+ synchronized (this) {
+ return fos.size();
+ }
+ }
+
public void finish(UpdateLog.SyncLevel syncLevel) {
if (syncLevel == UpdateLog.SyncLevel.NONE) return;
try {
@@ -404,18 +411,19 @@ public class TransactionLog {
/** 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. */
- public LogReader getReader() {
- return new LogReader();
+ public LogReader getReader(long startingPos) {
+ return new LogReader(startingPos);
}
public class LogReader {
- ChannelFastInputStream fis = new ChannelFastInputStream(channel, 0);
+ ChannelFastInputStream fis;
private LogCodec codec = new LogCodec();
- public LogReader() {
+ public LogReader(long startingPos) {
incref();
+ fis = new ChannelFastInputStream(channel, startingPos);
}
/** Returns the next object from the log, or null if none available.
Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/UpdateLog.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/UpdateLog.java?rev=1209357&r1=1209356&r2=1209357&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/UpdateLog.java (original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/UpdateLog.java Fri Dec 2 04:09:50 2011
@@ -58,6 +58,8 @@ public abstract class UpdateLog implemen
public static class RecoveryInfo {
+ public long positionOfStart;
+
public int adds;
public int deletes;
public int deleteByQuery;
Modified: lucene/dev/branches/solrcloud/solr/testlogging.properties
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/testlogging.properties?rev=1209357&r1=1209356&r2=1209357&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/testlogging.properties (original)
+++ lucene/dev/branches/solrcloud/solr/testlogging.properties Fri Dec 2 04:09:50 2011
@@ -1,4 +1,4 @@
handlers=java.util.logging.ConsoleHandler
-.level=SEVERE
+.level=INFO
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter