You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2016/07/11 13:24:02 UTC

lucene-solr:branch_6x: add missing succes=true in NRT replicator; remove some dead code

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x 15526e776 -> 012fb76f7


add missing succes=true in NRT replicator; remove some dead code


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/012fb76f
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/012fb76f
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/012fb76f

Branch: refs/heads/branch_6x
Commit: 012fb76f7d0987d349ce3f5e06d22be9b5cea515
Parents: 15526e7
Author: Mike McCandless <mi...@apache.org>
Authored: Mon Jul 11 09:23:11 2016 -0400
Committer: Mike McCandless <mi...@apache.org>
Committed: Mon Jul 11 09:23:33 2016 -0400

----------------------------------------------------------------------
 .../org/apache/lucene/replicator/nrt/ReplicaNode.java    |  4 +---
 .../apache/lucene/replicator/nrt/TestNRTReplication.java | 11 +++++++++++
 2 files changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/012fb76f/lucene/replicator/src/java/org/apache/lucene/replicator/nrt/ReplicaNode.java
----------------------------------------------------------------------
diff --git a/lucene/replicator/src/java/org/apache/lucene/replicator/nrt/ReplicaNode.java b/lucene/replicator/src/java/org/apache/lucene/replicator/nrt/ReplicaNode.java
index e7d40ac..1ca1519 100644
--- a/lucene/replicator/src/java/org/apache/lucene/replicator/nrt/ReplicaNode.java
+++ b/lucene/replicator/src/java/org/apache/lucene/replicator/nrt/ReplicaNode.java
@@ -97,6 +97,7 @@ public abstract class ReplicaNode extends Node {
       
       state = "init";
       deleter = new ReplicaFileDeleter(this, dir);
+      success = true;
     } catch (Throwable t) {
       message("exc on init:");
       t.printStackTrace(printStream);
@@ -219,8 +220,6 @@ public abstract class ReplicaNode extends Node {
 
           message("top: init: sync sis.version=" + job.getCopyState().version);
 
-          Collection<String> fileNamesToCopy = job.getFileNamesToCopy();
-
           // Force this copy job to finish while we wait, now.  Note that this can be very time consuming!
           // NOTE: newNRTPoint detects we are still in init (mgr is null) and does not cancel our copy if a flush happens
           try {
@@ -718,7 +717,6 @@ public abstract class ReplicaNode extends Node {
    *  files that need copying */
   public List<Map.Entry<String,FileMetaData>> getFilesToCopy(Map<String,FileMetaData> files) throws IOException {
 
-    boolean doCopyCommitFiles = false;
     List<Map.Entry<String,FileMetaData>> toCopy = new ArrayList<>();
     for (Map.Entry<String,FileMetaData> ent : files.entrySet()) {
       String fileName = ent.getKey();

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/012fb76f/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestNRTReplication.java
----------------------------------------------------------------------
diff --git a/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestNRTReplication.java b/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestNRTReplication.java
index 576186a..f98cf8d 100644
--- a/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestNRTReplication.java
+++ b/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestNRTReplication.java
@@ -30,6 +30,9 @@ import java.util.concurrent.atomic.AtomicLong;
 import java.util.regex.Pattern;
 
 import org.apache.lucene.document.Document;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.store.LockObtainFailedException;
 import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.LineFileDocs;
 import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
@@ -695,6 +698,12 @@ public class TestNRTReplication extends LuceneTestCase {
     replica.close();
   }
 
+  private void assertWriteLockHeld(Path path) throws Exception {
+    try (FSDirectory dir = FSDirectory.open(path)) {
+      expectThrows(LockObtainFailedException.class, () -> {dir.obtainLock(IndexWriter.WRITE_LOCK_NAME);});
+    }
+  }
+
   public void testCrashReplica() throws Exception {
 
     Path path1 = createTempDir("1");
@@ -703,6 +712,8 @@ public class TestNRTReplication extends LuceneTestCase {
     Path path2 = createTempDir("2");
     NodeProcess replica = startNode(primary.tcpPort, 1, path2, -1, true);
 
+    assertWriteLockHeld(path2);
+
     sendReplicasToPrimary(primary, replica);
 
     // Index 10 docs into primary: