fluo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject [fluo] branch master updated: Fixes #921 Ensure allocated timestamps are valid. (#929)
Date Sun, 24 Sep 2017 18:04:46 GMT
This is an automated email from the ASF dual-hosted git repository.

kturner pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/fluo.git


The following commit(s) were added to refs/heads/master by this push:
     new 00befd8  Fixes #921 Ensure allocated timestamps are valid. (#929)
00befd8 is described below

commit 00befd8dfeebe47b2edb8105a86fc8b7b069b92d
Author: adepuravikrishna <adepuravikrishna@gmail.com>
AuthorDate: Sun Sep 24 11:04:44 2017 -0700

    Fixes #921 Ensure allocated timestamps are valid. (#929)
---
 .../java/org/apache/fluo/core/oracle/Stamp.java    |  7 ++++++
 .../org/apache/fluo/core/oracle/StampTest.java}    | 25 +++++++++++-----------
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/modules/core/src/main/java/org/apache/fluo/core/oracle/Stamp.java b/modules/core/src/main/java/org/apache/fluo/core/oracle/Stamp.java
index 1b308d6..7ec147c 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/oracle/Stamp.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/oracle/Stamp.java
@@ -15,11 +15,18 @@
 
 package org.apache.fluo.core.oracle;
 
+import com.google.common.base.Preconditions;
+import org.apache.fluo.accumulo.util.ColumnConstants;
+
 public class Stamp {
   private final long txStamp;
   private final long gcStamp;
 
   Stamp(long stamp, long gcStamp) {
+    long b = stamp & ColumnConstants.PREFIX_MASK;
+    Preconditions.checkArgument(b == 0, "timestamp prefix should be zero");
+    long c = gcStamp & ColumnConstants.PREFIX_MASK;
+    Preconditions.checkArgument(c == 0, "timestamp prefix should be zero");
     this.txStamp = stamp;
     this.gcStamp = gcStamp;
   }
diff --git a/modules/core/src/main/java/org/apache/fluo/core/oracle/Stamp.java b/modules/core/src/test/java/org/apache/fluo/core/oracle/StampTest.java
similarity index 73%
copy from modules/core/src/main/java/org/apache/fluo/core/oracle/Stamp.java
copy to modules/core/src/test/java/org/apache/fluo/core/oracle/StampTest.java
index 1b308d6..60c754d 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/oracle/Stamp.java
+++ b/modules/core/src/test/java/org/apache/fluo/core/oracle/StampTest.java
@@ -1,3 +1,4 @@
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
  * agreements. See the NOTICE file distributed with this work for additional information
regarding
@@ -12,23 +13,23 @@
  * or implied. See the License for the specific language governing permissions and limitations
under
  * the License.
  */
-
 package org.apache.fluo.core.oracle;
 
-public class Stamp {
-  private final long txStamp;
-  private final long gcStamp;
+import org.junit.Test;
 
-  Stamp(long stamp, long gcStamp) {
-    this.txStamp = stamp;
-    this.gcStamp = gcStamp;
-  }
+/**
+ * Unit test for Stamp class
+ */
+public class StampTest {
 
-  public long getTxTimestamp() {
-    return txStamp;
+  @Test(expected = IllegalArgumentException.class)
+  public void testBadStartTime() {
+    new Stamp(1L << 62, 5);
   }
 
-  public long getGcTimestamp() {
-    return gcStamp;
+  @Test(expected = IllegalArgumentException.class)
+  public void testBadGcTime() {
+    new Stamp(5, 1L << 62);
   }
+
 }

-- 
To stop receiving notification emails like this one, please contact
['"commits@fluo.apache.org" <commits@fluo.apache.org>'].

Mime
View raw message