You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2016/02/25 02:58:05 UTC

[45/50] [abbrv] lucene-solr git commit: SOLR-445: prune out bogus (ie: technically infeasible to be accurate) 'numAdds' code

SOLR-445: prune out bogus (ie: technically infeasible to be accurate) 'numAdds' 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/2e5c5b02
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/2e5c5b02
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/2e5c5b02

Branch: refs/heads/jira/SOLR-445
Commit: 2e5c5b022ed2f185b95c745ccdbd0a142e3b5794
Parents: bc5dfee
Author: Chris Hostetter <ho...@apache.org>
Authored: Tue Feb 23 15:07:09 2016 -0700
Committer: Chris Hostetter <ho...@apache.org>
Committed: Tue Feb 23 15:07:09 2016 -0700

----------------------------------------------------------------------
 .../processor/TolerantUpdateProcessor.java      | 17 ++-----------
 .../DistribTolerantUpdateProcessorTest.java     |  2 --
 .../cloud/TestTolerantUpdateProcessorCloud.java | 26 ++++++--------------
 .../processor/TolerantUpdateProcessorTest.java  |  4 +--
 4 files changed, 10 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/2e5c5b02/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessor.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessor.java
index 8b10ee9..75a8f60 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessor.java
@@ -91,11 +91,6 @@ public class TolerantUpdateProcessor extends UpdateRequestProcessor {
   private int numErrors = 0; // nocmmit: why isn't thisjust errors.size() ? ? ? ? 
   
   /**
-   * Number of documents successfully added. 
-   */
-  private int numAdds = 0;
-  
-  /**
    * Map of errors that occurred in this batch, keyed by unique key. The value is also a Map so that
    * for each error the output is a key value pair.
    */
@@ -130,7 +125,6 @@ public class TolerantUpdateProcessor extends UpdateRequestProcessor {
       id = cmd.getIndexedId();
       
       super.processAdd(cmd);
-      numAdds++;
 
     } catch (Throwable t) { // nocommit: OOM trap
       firstErrTracker.caught(t);
@@ -229,9 +223,6 @@ public class TolerantUpdateProcessor extends UpdateRequestProcessor {
             } catch (NumberFormatException nfe) {
               log.error("Ignoring invalid numErrors reported from remote shard: " + val, nfe);
             }
-          } else if (key.equals(ERR_META_PREFIX + "numAdds")) {
-            // nocommit: nothing very useful we can do with (remote) numAdds?
-            // nocommit: perhaps do some kind of "numAddsConfirmed" ?
           } else {
             log.error("found remote error metadata using our prefix but not a key we expect: " + key, remoteErr);
             assert false;
@@ -251,10 +242,9 @@ public class TolerantUpdateProcessor extends UpdateRequestProcessor {
       assert 0 == numErrors;
       header.add("numErrors", 0);
     }
-    header.add("numAdds", numAdds);
 
     // annotate any error that might be thrown (or was already thrown)
-    firstErrTracker.annotate(numAdds, numErrors, errors);
+    firstErrTracker.annotate(numErrors, errors);
 
     // decide if we have hit a situation where we know an error needs to be thrown.
     
@@ -351,8 +341,7 @@ public class TolerantUpdateProcessor extends UpdateRequestProcessor {
      * Annotates the first exception (which may already have been thrown, or be thrown in the future) with 
      * the metadata from this update processor.  For use in {@link TolerantUpdateProcessor#finish}
      */
-    public void annotate(int numAdds, int numErrors, SimpleOrderedMap<SimpleOrderedMap<String>> errors) {
-      // nocommit: eliminate numAdds?
+    public void annotate(int numErrors, SimpleOrderedMap<SimpleOrderedMap<String>> errors) {
       // nocommit: eliminate numErrors?
 
       if (null == first) {
@@ -373,8 +362,6 @@ public class TolerantUpdateProcessor extends UpdateRequestProcessor {
       for (int i = 0; i < errors.size(); i++) {
         errMetadata.add(ERR_META_PREFIX + "id-" + errors.getName(i), errors.getVal(i).get("message"));
       }
-      // nocommit: useless? remove?
-      errMetadata.add(ERR_META_PREFIX + "numAdds", ""+numAdds);
     }
     
     

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/2e5c5b02/solr/core/src/test/org/apache/solr/cloud/DistribTolerantUpdateProcessorTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/DistribTolerantUpdateProcessorTest.java b/solr/core/src/test/org/apache/solr/cloud/DistribTolerantUpdateProcessorTest.java
index 4dc3043..a307382 100644
--- a/solr/core/src/test/org/apache/solr/cloud/DistribTolerantUpdateProcessorTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/DistribTolerantUpdateProcessorTest.java
@@ -116,8 +116,6 @@ public class DistribTolerantUpdateProcessorTest extends AbstractFullDistribZkTes
     assertNotNull("Null errors in response: " + response.toString(), errors);
     assertEquals("Wrong numErrors in response: " + response.toString(),
                  numErrors, response.getResponseHeader().get("numErrors"));
-    assertEquals("numAdds doesn't make sense given input vs numErrors: " + response.toString(),
-                 docs.length - numErrors, response.getResponseHeader().get("numAdds"));
     for (String id : ids) {
       assertNotNull("Id " + id + " not found in errors list: " + response.toString(), errors.get(id));
     }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/2e5c5b02/solr/core/src/test/org/apache/solr/cloud/TestTolerantUpdateProcessorCloud.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestTolerantUpdateProcessorCloud.java b/solr/core/src/test/org/apache/solr/cloud/TestTolerantUpdateProcessorCloud.java
index 598d0f3..7a2bced 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestTolerantUpdateProcessorCloud.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestTolerantUpdateProcessorCloud.java
@@ -303,7 +303,7 @@ public class TestTolerantUpdateProcessorCloud extends LuceneTestCase {
                  doc(f("id", S_ONE_PRE + "666"), f("foo_i", "1976"))).process(client);
     
     assertEquals(0, rsp.getStatus());
-    assertUpdateTolerantErrors("single shard, 1st doc should fail", rsp, 1, S_ONE_PRE + "42");
+    assertUpdateTolerantErrors("single shard, 1st doc should fail", rsp, S_ONE_PRE + "42");
     assertEquals(0, client.commit().getStatus());
     assertQueryDocIds(client, false, S_ONE_PRE + "42");
     assertQueryDocIds(client, true, S_ONE_PRE + "666");
@@ -316,7 +316,7 @@ public class TestTolerantUpdateProcessorCloud extends LuceneTestCase {
                  doc(f("id", S_ONE_PRE + "77"), f("foo_i", "bogus_val"))).process(client);
     
     assertEquals(0, rsp.getStatus());
-    assertUpdateTolerantErrors("single shard, 2nd doc should fail", rsp, 1, S_ONE_PRE + "77");
+    assertUpdateTolerantErrors("single shard, 2nd doc should fail", rsp, S_ONE_PRE + "77");
     assertQueryDocIds(client, false, S_ONE_PRE + "77");
     assertQueryDocIds(client, true, S_ONE_PRE + "666", S_ONE_PRE + "55");
 
@@ -331,7 +331,7 @@ public class TestTolerantUpdateProcessorCloud extends LuceneTestCase {
                  doc(f("id", S_TWO_PRE + "666"), f("foo_i", "1976"))).process(client);
     
     assertEquals(0, rsp.getStatus());
-    assertUpdateTolerantErrors("two shards, 1st doc should fail", rsp, 1, S_ONE_PRE + "42");
+    assertUpdateTolerantErrors("two shards, 1st doc should fail", rsp, S_ONE_PRE + "42");
     assertEquals(0, client.commit().getStatus());
     assertQueryDocIds(client, false, S_ONE_PRE + "42");
     assertQueryDocIds(client, true, S_TWO_PRE + "666");
@@ -344,7 +344,7 @@ public class TestTolerantUpdateProcessorCloud extends LuceneTestCase {
                  doc(f("id", S_TWO_PRE + "77"), f("foo_i", "bogus_val"))).process(client);
     
     assertEquals(0, rsp.getStatus());
-    assertUpdateTolerantErrors("two shards, 2nd doc should fail", rsp, 1, S_TWO_PRE + "77");
+    assertUpdateTolerantErrors("two shards, 2nd doc should fail", rsp, S_TWO_PRE + "77");
     assertQueryDocIds(client, false, S_TWO_PRE + "77");
     assertQueryDocIds(client, true, S_TWO_PRE + "666", S_ONE_PRE + "55");
 
@@ -369,7 +369,7 @@ public class TestTolerantUpdateProcessorCloud extends LuceneTestCase {
                  doc(f("id", S_TWO_PRE + "26"))).process(client);
     
     assertEquals(0, rsp.getStatus());
-    assertUpdateTolerantErrors("many docs, 1 from each shard should fail", rsp, 10,
+    assertUpdateTolerantErrors("many docs, 1 from each shard should fail", rsp,
                                S_ONE_PRE + "15",
                                S_TWO_PRE + "22");
     assertQueryDocIds(client, false, S_TWO_PRE + "22", S_ONE_PRE + "15");
@@ -422,7 +422,7 @@ public class TestTolerantUpdateProcessorCloud extends LuceneTestCase {
                    400, e.code());
 
       // nocommit: is there a way to inspect the response body anyway?
-      // nocommit: look for the correct "numAdds" and "errors" ?  .... check e's metatata
+      // nocommit: look for the correct "errors" ?  .... check e's metatata
     }
     assertEquals(0, client.commit().getStatus()); // need to force since update didn't finish
     assertQueryDocIds(client, false
@@ -475,7 +475,7 @@ public class TestTolerantUpdateProcessorCloud extends LuceneTestCase {
                    400, e.code());
 
       // nocommit: is there a way to inspect the response body anyway?
-      // nocommit: look for the correct "numAdds" and "errors" ?  .... check e's metatata
+      // nocommit: look for the correct "errors" ?  .... check e's metatata
     }
     assertEquals(0, client.commit().getStatus()); // need to force since update didn't finish
     assertQueryDocIds(client, true
@@ -499,20 +499,8 @@ public class TestTolerantUpdateProcessorCloud extends LuceneTestCase {
   // nocommit: refactor into multiple methods, some of which can check tolerant deletions as well?
   public static void assertUpdateTolerantErrors(String assertionMsgPrefix,
                                                 UpdateResponse response,
-                                                int numAddsExpected,
                                                 String... errorIdsExpected) {
 
-    // nocommit: numAdds seems virtually impossible to get right in distrib/async mode...
-    // nocommit: for now make no assertions about it
-    //
-    // nocommit: perhaps it should be numAddsAttempted and we should assert numAddsAttempted < maxNumAddsExpected
-    // nocommit: ...at least that way we can assert that requests failed fast when we expected them too?
-    // nocommit: (even that's hard to be sure when we have the same test logic being used on diff clients  -- fail fast to S1 leader will be slow async failure to S2 leader)
-    //
-    //
-    // assertEquals(assertionMsgPrefix + ": numAdds: " + response.toString(),
-    //              numAddsExpected, response.getResponseHeader().get("numAdds"));
-    
     @SuppressWarnings("unchecked")
     SimpleOrderedMap<Object> errors = (SimpleOrderedMap<Object>) response.getResponseHeader().get("errors");
     assertNotNull(assertionMsgPrefix + ": Null errors: " + response.toString(), errors);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/2e5c5b02/solr/core/src/test/org/apache/solr/update/processor/TolerantUpdateProcessorTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/update/processor/TolerantUpdateProcessorTest.java b/solr/core/src/test/org/apache/solr/update/processor/TolerantUpdateProcessorTest.java
index 15116cd..8599df8 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/TolerantUpdateProcessorTest.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/TolerantUpdateProcessorTest.java
@@ -294,7 +294,6 @@ public class TolerantUpdateProcessorTest extends UpdateProcessorTestBase {
     response = update("tolerant-chain-max-errors-10", builder.toString());
     assertNull(BaseTestHarness.validateXPath(response, "//int[@name='status']=0",
         "//int[@name='numErrors']=10",
-        "//int[@name='numAdds']=10",
         "not(//lst[@name='errors']/lst[@name='0'])",
         "//lst[@name='errors']/lst[@name='1']",
         "not(//lst[@name='errors']/lst[@name='2'])",
@@ -338,7 +337,6 @@ public class TolerantUpdateProcessorTest extends UpdateProcessorTestBase {
     SimpleOrderedMap<Object> errors = (SimpleOrderedMap<Object>) response.getResponseHeader().get("errors");
     assertNotNull(errors);
     assertEquals(numErrors, response.getResponseHeader().get("numErrors"));
-    assertEquals(docs.size() - numErrors, response.getResponseHeader().get("numAdds"));
     
     for(String id:ids) {
       assertNotNull("Id " + id + " not found in errors list", errors.get(id));
@@ -378,4 +376,4 @@ public class TolerantUpdateProcessorTest extends UpdateProcessorTestBase {
     return rsp;
   }
   
-}
\ No newline at end of file
+}