accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [10/50] [abbrv] git commit: ACCUMULO-2819 Update StatusCombiner to handle fileClosed properly
Date Wed, 21 May 2014 01:59:29 GMT
ACCUMULO-2819 Update StatusCombiner to handle fileClosed properly


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/8921e322
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/8921e322
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/8921e322

Branch: refs/heads/ACCUMULO-378
Commit: 8921e3221947a8fb82b7f61b97e3eec4ee228f89
Parents: 934f1ee
Author: Josh Elser <elserj@apache.org>
Authored: Fri May 16 12:08:20 2014 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Fri May 16 12:08:20 2014 -0400

----------------------------------------------------------------------
 .../server/replication/StatusCombiner.java      | 10 ++++++++
 .../server/replication/StatusCombinerTest.java  | 26 ++++++++++++++++++++
 2 files changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/8921e322/server/base/src/main/java/org/apache/accumulo/server/replication/StatusCombiner.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/replication/StatusCombiner.java
b/server/base/src/main/java/org/apache/accumulo/server/replication/StatusCombiner.java
index a75ceb4..694664e 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/replication/StatusCombiner.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/replication/StatusCombiner.java
@@ -134,6 +134,16 @@ public class StatusCombiner extends TypedValueCombiner<Status>
{
 
     // persist the infinite end
     combined.setInfiniteEnd(combined.getInfiniteEnd() | status.getInfiniteEnd());
+
+    // only set the closedTime if the new status has it defined
+    if (status.hasClosedTime()) {
+      // choose the minimum (earliest) closedTime seen
+      if (combined.hasClosedTime()) {
+        combined.setClosedTime(Math.min(combined.getClosedTime(), status.getClosedTime()));
+      } else {
+        combined.setClosedTime(status.getClosedTime());
+      }
+    }
   }
 
   private String builderToString(Builder builder) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8921e322/server/base/src/test/java/org/apache/accumulo/server/replication/StatusCombinerTest.java
----------------------------------------------------------------------
diff --git a/server/base/src/test/java/org/apache/accumulo/server/replication/StatusCombinerTest.java
b/server/base/src/test/java/org/apache/accumulo/server/replication/StatusCombinerTest.java
index 8b8b72c..d74e2c6 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/replication/StatusCombinerTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/replication/StatusCombinerTest.java
@@ -222,4 +222,30 @@ public class StatusCombinerTest {
 
     Assert.assertEquals(order1, permutation);
   }
+
+  @Test
+  public void fileClosedTimePropagated() {
+    Status stat1 = Status.newBuilder().setBegin(10).setEnd(20).setClosed(true).setInfiniteEnd(false).setClosedTime(50).build();
+    Status stat2 = Status.newBuilder().setBegin(10).setEnd(20).setClosed(true).setInfiniteEnd(false).build();
+
+    Status combined = combiner.typedReduce(key, Arrays.asList(stat1, stat2).iterator());
+
+    Assert.assertEquals(stat1, combined);
+  }
+
+  @Test
+  public void fileClosedTimeChoosesEarliestIgnoringDefault() {
+    Status stat1 = Status.newBuilder().setBegin(10).setEnd(20).setClosed(true).setInfiniteEnd(false).setClosedTime(50).build();
+    Status stat2 = Status.newBuilder().setBegin(10).setEnd(20).setClosed(true).setInfiniteEnd(false).setClosedTime(100).build();
+
+    Status combined = combiner.typedReduce(key, Arrays.asList(stat1, stat2).iterator());
+
+    Assert.assertEquals(stat1, combined);
+
+    Status stat3 = Status.newBuilder().setBegin(10).setEnd(20).setClosed(true).setInfiniteEnd(false).setClosedTime(100).build();
+
+    Status combined2 = combiner.typedReduce(key, Arrays.asList(combined, stat3).iterator());
+
+    Assert.assertEquals(combined, combined2);
+  }
 }


Mime
View raw message