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/02/11 17:43:03 UTC

[29/31] lucene-solr git commit: remove some core changes; add missing sync that caused stress test failure

remove some core changes; add missing sync that caused stress test failure


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

Branch: refs/heads/master
Commit: 3a47dd29bcf5d3a277a16ced687cf296c85e8996
Parents: 027bc0e
Author: Mike McCandless <mi...@apache.org>
Authored: Wed Feb 10 09:09:49 2016 -0500
Committer: Mike McCandless <mi...@apache.org>
Committed: Wed Feb 10 09:09:49 2016 -0500

----------------------------------------------------------------------
 .../lucene/store/NRTCachingDirectory.java       |  6 +-
 .../java/org/apache/lucene/util/IOUtils.java    |  3 -
 .../replicator/nrt/SimplePrimaryNode.java       | 60 ++++++++++----------
 3 files changed, 33 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/3a47dd29/lucene/core/src/java/org/apache/lucene/store/NRTCachingDirectory.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/store/NRTCachingDirectory.java b/lucene/core/src/java/org/apache/lucene/store/NRTCachingDirectory.java
index 908722f..22a9571 100644
--- a/lucene/core/src/java/org/apache/lucene/store/NRTCachingDirectory.java
+++ b/lucene/core/src/java/org/apache/lucene/store/NRTCachingDirectory.java
@@ -175,10 +175,8 @@ public class NRTCachingDirectory extends FilterDirectory implements Accountable
   @Override
   public void renameFile(String source, String dest) throws IOException {
     unCache(source);
-    try {
-      cache.deleteFile(dest);
-    } catch (FileNotFoundException fnfe) {
-      // OK -- it may not exist
+    if (cache.fileNameExists(dest)) {
+      throw new IllegalArgumentException("target file " + dest + " already exists");
     }
     in.renameFile(source, dest);
   }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/3a47dd29/lucene/core/src/java/org/apache/lucene/util/IOUtils.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/util/IOUtils.java b/lucene/core/src/java/org/apache/lucene/util/IOUtils.java
index 1a26542..ce8884c 100644
--- a/lucene/core/src/java/org/apache/lucene/util/IOUtils.java
+++ b/lucene/core/src/java/org/apache/lucene/util/IOUtils.java
@@ -107,9 +107,6 @@ public final class IOUtils {
    *          objects to call <tt>close()</tt> on
    */
   public static void closeWhileHandlingException(Closeable... objects) {
-    if (objects.length == 0) {
-      throw new IllegalArgumentException("pass at least one Closeable");
-    }
     closeWhileHandlingException(Arrays.asList(objects));
   }
   

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/3a47dd29/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/SimplePrimaryNode.java
----------------------------------------------------------------------
diff --git a/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/SimplePrimaryNode.java b/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/SimplePrimaryNode.java
index 93d20f7..3d41b32 100644
--- a/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/SimplePrimaryNode.java
+++ b/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/SimplePrimaryNode.java
@@ -679,41 +679,43 @@ class SimplePrimaryNode extends PrimaryNode {
         int replicaTCPPort = in.readVInt();
         message("new replica: " + warmingSegments.size() + " current warming merges");
         // Step through all currently warming segments and try to add this replica if it isn't there already:
-        for(MergePreCopy preCopy : warmingSegments) {
-          message("warming segment " + preCopy.files.keySet());
-          boolean found = false;
-          synchronized (preCopy.connections) {
-            for(Connection c : preCopy.connections) {
-              if (c.destTCPPort == replicaTCPPort) {
-                found = true;
-                break;
+        synchronized(warmingSegments) {
+          for(MergePreCopy preCopy : warmingSegments) {
+            message("warming segment " + preCopy.files.keySet());
+            boolean found = false;
+            synchronized (preCopy.connections) {
+              for(Connection c : preCopy.connections) {
+                if (c.destTCPPort == replicaTCPPort) {
+                  found = true;
+                  break;
+                }
               }
             }
-          }
 
-          if (found) {
-            message("this replica is already warming this segment; skipping");
-            // It's possible (maybe) that the replica started up, then a merge kicked off, and it warmed to this new replica, all before the
-            // replica sent us this command:
-            continue;
-          }
+            if (found) {
+              message("this replica is already warming this segment; skipping");
+              // It's possible (maybe) that the replica started up, then a merge kicked off, and it warmed to this new replica, all before the
+              // replica sent us this command:
+              continue;
+            }
 
-          // OK, this new replica is not already warming this segment, so attempt (could fail) to start warming now:
+            // OK, this new replica is not already warming this segment, so attempt (could fail) to start warming now:
 
-          Connection c = new Connection(replicaTCPPort);
-          if (preCopy.tryAddConnection(c) == false) {
-            // This can happen, if all other replicas just now finished warming this segment, and so we were just a bit too late.  In this
-            // case the segment will be copied over in the next nrt point sent to this replica
-            message("failed to add connection to segment warmer (too late); closing");
-            c.close();
+            Connection c = new Connection(replicaTCPPort);
+            if (preCopy.tryAddConnection(c) == false) {
+              // This can happen, if all other replicas just now finished warming this segment, and so we were just a bit too late.  In this
+              // case the segment will be copied over in the next nrt point sent to this replica
+              message("failed to add connection to segment warmer (too late); closing");
+              c.close();
+            }
+            c.out.writeByte(SimpleReplicaNode.CMD_PRE_COPY_MERGE);
+            c.out.writeVLong(primaryGen);
+            c.out.writeVInt(tcpPort);
+            SimpleServer.writeFilesMetaData(c.out, preCopy.files);
+            c.flush();
+            c.s.shutdownOutput();
+            message("successfully started warming");
           }
-          c.out.writeByte(SimpleReplicaNode.CMD_PRE_COPY_MERGE);
-          c.out.writeVLong(primaryGen);
-          c.out.writeVInt(tcpPort);
-          SimpleServer.writeFilesMetaData(c.out, preCopy.files);
-          c.flush();
-          c.s.shutdownOutput();
-          message("successfully started warming");
         }
         break;