You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/07/25 22:15:21 UTC

[lucene-solr] 08/16: @318 Take another pass at this phaser.

This is an automated email from the ASF dual-hosted git repository.

markrmiller pushed a commit to branch reference_impl
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit 1102a2a161e773f4829ad264a721bd00f3018144
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Thu Jul 23 16:18:32 2020 -0500

    @318 Take another pass at this phaser.
---
 .../org/apache/solr/update/SolrCmdDistributor.java | 75 +++++++++-------------
 1 file changed, 32 insertions(+), 43 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java b/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
index fe78166..0f35a47 100644
--- a/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
+++ b/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
@@ -250,7 +250,9 @@ public class SolrCmdDistributor implements Closeable {
         return;
       }
 
-      if (!(req.cmd instanceof CommitUpdateCommand) && (!(req.cmd instanceof DeleteUpdateCommand) || (req.cmd instanceof DeleteUpdateCommand && ((DeleteUpdateCommand)req.cmd).query != null))) {
+      if (req.cmd instanceof  CommitUpdateCommand || req.cmd instanceof  DeleteUpdateCommand &&  ((DeleteUpdateCommand)req.cmd).query != null) {
+        // commit or delete by query
+      } else {
         phaser.register();
       }
 
@@ -265,56 +267,43 @@ public class SolrCmdDistributor implements Closeable {
         @Override
         public void onFailure(Throwable t) {
           log.warn("Error sending distributed update", t);
-          boolean success = false;
-          try {
-            Error error = new Error();
-            error.t = t;
-            error.req = req;
-            if (t instanceof SolrException) {
-              error.statusCode = ((SolrException) t).code();
-            }
+          arrive(req);
 
-            if (checkRetry(error)) {
-              log.info("Retrying distrib update on error: {}", t.getMessage());
-              submit(req);
-              success = true;
-            } else {
-              arrive(req);
-              allErrors.add(error);
-            }
-          } finally {
-            if (!success) {
-              arrive(req);
-            }
+          Error error = new Error();
+          error.t = t;
+          error.req = req;
+          if (t instanceof SolrException) {
+            error.statusCode = ((SolrException) t).code();
           }
+
+          if (checkRetry(error)) {
+            log.info("Retrying distrib update on error: {}", t.getMessage());
+            submit(req);
+          } else {
+            allErrors.add(error);
+          }
+
         }});
     } catch (Exception e) {
-      boolean success = false;
-     try {
-       log.warn("Error sending distributed update", e);
-       Error error = new Error();
-       error.t = e;
-       error.req = req;
-       if (e instanceof SolrException) {
-         error.statusCode = ((SolrException) e).code();
-       }
-       if (checkRetry(error)) {
-         submit(req);
-         success = true;
-       } else {
-         allErrors.add(error);
-       }
-     } finally {
-       if (!success) {
-         arrive(req);
-
-       }
-     }
+      log.warn("Error sending distributed update", e);
+      Error error = new Error();
+      error.t = e;
+      error.req = req;
+      if (e instanceof SolrException) {
+        error.statusCode = ((SolrException) e).code();
+      }
+      if (checkRetry(error)) {
+        submit(req);
+      } else {
+        allErrors.add(error);
+      }
     }
   }
 
   private void arrive(Req req) {
-    if (!(req.cmd instanceof CommitUpdateCommand) && (!(req.cmd instanceof DeleteUpdateCommand) || (req.cmd instanceof DeleteUpdateCommand && ((DeleteUpdateCommand)req.cmd).query != null))) {
+    if (req.cmd instanceof  CommitUpdateCommand || req.cmd instanceof  DeleteUpdateCommand &&  ((DeleteUpdateCommand)req.cmd).query != null) {
+      // commit or delete by query
+    } else {
       phaser.arriveAndDeregister();
     }
   }