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/03/21 01:44:12 UTC

[50/50] lucene-solr:jira/SOLR-445: SOLR-445: hardent the ToleratedUpdateError API to hide implementation details

SOLR-445: hardent the ToleratedUpdateError API to hide implementation details


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

Branch: refs/heads/jira/SOLR-445
Commit: 21c0fe690dc4e968e484ee906632a50bf0273786
Parents: 6ec8c63
Author: Chris Hostetter <ho...@apache.org>
Authored: Sun Mar 20 16:44:17 2016 -0700
Committer: Chris Hostetter <ho...@apache.org>
Committed: Sun Mar 20 16:44:17 2016 -0700

----------------------------------------------------------------------
 .../processor/TolerantUpdateProcessor.java      |  4 +--
 .../cloud/TestTolerantUpdateProcessorCloud.java | 10 +++---
 .../solr/common/ToleratedUpdateError.java       | 33 +++++++++++++-------
 .../solr/common/TestToleratedUpdateError.java   |  6 ++--
 4 files changed, 31 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/21c0fe69/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 78457bb..9f9ff5e 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
@@ -200,7 +200,7 @@ public class TolerantUpdateProcessor extends UpdateRequestProcessor {
       // if we're lucky enough to get an immediate local failure (ie: we're a leader, or some other processor
       // failed) then recording the multiple failures is a good thing -- helps us with an accurate fail
       // fast if we exceed maxErrors
-      if (CmdType.DELQ.equals(err.type)) {
+      if (CmdType.DELQ.equals(err.getType())) {
         knownDBQErrors.add(err);
       }
       
@@ -287,7 +287,7 @@ public class TolerantUpdateProcessor extends UpdateRequestProcessor {
             continue;
           }
 
-          if (CmdType.DELQ.equals(err.type)) {
+          if (CmdType.DELQ.equals(err.getType())) {
             if (knownDBQErrors.contains(err)) {
               // we've already seen this identical error, probably a dup from another shard
               continue;

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/21c0fe69/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 c47f221..41ff4af 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestTolerantUpdateProcessorCloud.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestTolerantUpdateProcessorCloud.java
@@ -562,9 +562,9 @@ public class TestTolerantUpdateProcessorCloud extends SolrCloudTestCase {
                    actualKnownErrsCount, actualKnownErrs.size());
       for (ToleratedUpdateError err : actualKnownErrs) {
         assertEquals("only expected type of error is ADD: " + err,
-                     CmdType.ADD, err.type);
+                     CmdType.ADD, err.getType());
         assertTrue("failed err msg didn't match expected value: " + err,
-                   err.errorValue.contains("bogus_val"));
+                   err.getMessage().contains("bogus_val"));
       }
     }
     assertEquals(0, client.commit().getStatus()); // need to force since update didn't finish
@@ -636,11 +636,11 @@ public class TestTolerantUpdateProcessorCloud extends SolrCloudTestCase {
                    actualKnownErrsCount, actualKnownErrs.size());
       for (ToleratedUpdateError err : actualKnownErrs) {
         assertEquals("only expected type of error is ADD: " + err,
-                     CmdType.ADD, err.type);
+                     CmdType.ADD, err.getType());
         assertTrue("failed id had unexpected prefix: " + err,
-                   err.id.startsWith(S_TWO_PRE));
+                   err.getId().startsWith(S_TWO_PRE));
         assertTrue("failed err msg didn't match expected value: " + err,
-                   err.errorValue.contains("bogus_val"));
+                   err.getMessage().contains("bogus_val"));
       }
            
     }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/21c0fe69/solr/solrj/src/java/org/apache/solr/common/ToleratedUpdateError.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/ToleratedUpdateError.java b/solr/solrj/src/java/org/apache/solr/common/ToleratedUpdateError.java
index 6da6fc5..fd8b8c7 100644
--- a/solr/solrj/src/java/org/apache/solr/common/ToleratedUpdateError.java
+++ b/solr/solrj/src/java/org/apache/solr/common/ToleratedUpdateError.java
@@ -105,22 +105,31 @@ public final class ToleratedUpdateError {
                                     metadataKey.substring(typeEnd+1), metadataVal);
   }
 
-  // nocommit: make these private & provide getter methods
-  public final CmdType type;
-  public final String id; // may be null depending on type
-  public final String errorValue; // nocommit: refactor: rename message?
+  private final CmdType type;
+  private final String id; 
+  private final String message;
   
-  public ToleratedUpdateError(CmdType type, String id, String errorValue) {
-    this.type = type;
+  public ToleratedUpdateError(CmdType type, String id, String message) {
     assert null != type;
+    this.type = type;
     
     assert null != id;
     this.id = id;
     
-    assert null != errorValue;
-    this.errorValue = errorValue;
+    assert null != message;
+    this.message = message;
   }
 
+  public CmdType getType() {
+    return type;
+  }
+  public String getId() {
+    return id;
+  }
+  public String getMessage() {
+    return message;
+  }
+  
   /**
    * returns a string suitable for use as a key in {@link SolrException#setMetadata}
    *
@@ -136,7 +145,7 @@ public final class ToleratedUpdateError {
    * @see #parseMetadataIfToleratedUpdateError
    */
   public String getMetadataValue() {
-    return errorValue.toString();
+    return message.toString();
   }
   
   /** 
@@ -148,7 +157,7 @@ public final class ToleratedUpdateError {
     SimpleOrderedMap<String> entry = new SimpleOrderedMap<String>();
     entry.add("type", type.toString());
     entry.add("id", id);
-    entry.add("message", errorValue);
+    entry.add("message", message);
     return entry;
   }
   
@@ -160,7 +169,7 @@ public final class ToleratedUpdateError {
     int h = this.getClass().hashCode();
     h = h * 31 + type.hashCode();
     h = h * 31 + id.hashCode();
-    h = h * 31 + errorValue.hashCode();
+    h = h * 31 + message.hashCode();
     return h;
   }
   
@@ -169,7 +178,7 @@ public final class ToleratedUpdateError {
       ToleratedUpdateError that = (ToleratedUpdateError)o;
       return that.type.equals(this.type)
         && that.id.equals(this.id)
-        && that.errorValue.equals(this.errorValue);
+        && that.message.equals(this.message);
     }
     return false;
   }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/21c0fe69/solr/solrj/src/test/org/apache/solr/common/TestToleratedUpdateError.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/common/TestToleratedUpdateError.java b/solr/solrj/src/test/org/apache/solr/common/TestToleratedUpdateError.java
index a76443a..aba07ae 100644
--- a/solr/solrj/src/test/org/apache/solr/common/TestToleratedUpdateError.java
+++ b/solr/solrj/src/test/org/apache/solr/common/TestToleratedUpdateError.java
@@ -155,9 +155,9 @@ public class TestToleratedUpdateError extends LuceneTestCase {
   }
   
   public void compare(ToleratedUpdateError in, ToleratedUpdateError out) {
-    assertEquals(out.type, in.type);
-    assertEquals(out.id, in.id);
-    assertEquals(out.errorValue, in.errorValue);
+    assertEquals(out.getType(), in.getType());
+    assertEquals(out.getId(), in.getId());
+    assertEquals(out.getMessage(), in.getMessage());
     
     assertEquals(out.hashCode(), in.hashCode());
     assertEquals(out.toString(), in.toString());