accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [4/6] git commit: ACCUMULO-378 Make the MockReplicaSystem a bit more honest and only set full replication when closed and inf length
Date Tue, 27 May 2014 04:04:20 GMT
ACCUMULO-378 Make the MockReplicaSystem a bit more honest and only set full replication when
closed and inf length


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

Branch: refs/heads/ACCUMULO-378
Commit: 3b727cf94f4341d39adf07dcbd62361b7d4a0de3
Parents: 3605275
Author: Josh Elser <elserj@apache.org>
Authored: Mon May 26 13:48:21 2014 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Mon May 26 13:48:21 2014 -0400

----------------------------------------------------------------------
 .../test/replication/MockReplicaSystem.java     | 25 +++++++++++++++-----
 1 file changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/3b727cf9/test/src/main/java/org/apache/accumulo/test/replication/MockReplicaSystem.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/MockReplicaSystem.java
b/test/src/main/java/org/apache/accumulo/test/replication/MockReplicaSystem.java
index fa6ca2f..ac44f97 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/MockReplicaSystem.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/MockReplicaSystem.java
@@ -19,6 +19,7 @@ package org.apache.accumulo.test.replication;
 import org.apache.accumulo.core.client.replication.ReplicaSystem;
 import org.apache.accumulo.core.replication.ReplicationTarget;
 import org.apache.accumulo.core.replication.proto.Replication.Status;
+import org.apache.commons.lang.StringUtils;
 import org.apache.hadoop.fs.Path;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -37,11 +38,18 @@ public class MockReplicaSystem implements ReplicaSystem {
 
   @Override
   public Status replicate(Path p, Status status, ReplicationTarget target) {
-    Status.Builder builder = Status.newBuilder(status);
-    if (status.getInfiniteEnd()) {
-      builder.setBegin(Long.MAX_VALUE);
+    Status newStatus;
+    if (status.getClosed() && status.getInfiniteEnd()) {
+      Status.Builder builder = Status.newBuilder(status);
+      if (status.getInfiniteEnd()) {
+        builder.setBegin(Long.MAX_VALUE);
+      } else {
+        builder.setBegin(status.getEnd());
+      }
+      newStatus = builder.build();
     } else {
-      builder.setBegin(status.getEnd());
+      log.info("{} with status {} is not closed and with infinite length, ignoring");
+      newStatus = status;
     }
 
     try {
@@ -52,13 +60,18 @@ public class MockReplicaSystem implements ReplicaSystem {
       return status;
     }
 
-    Status newStatus = builder.build();
-    log.info("Received {} returned {}", TextFormat.shortDebugString(status), TextFormat.shortDebugString(newStatus));
+    log.info("Received {}, returned {}", TextFormat.shortDebugString(status), TextFormat.shortDebugString(newStatus));
+
     return newStatus;
   }
 
   @Override
   public void configure(String configuration) {
+    if (StringUtils.isBlank(configuration)) {
+      log.debug("No configuration, using default sleep of {}", sleep);
+      return;
+    }
+
     try {
       sleep = Long.parseLong(configuration);
     } catch (NumberFormatException e) {


Mime
View raw message