You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fluo.apache.org by kt...@apache.org on 2017/09/24 18:04:46 UTC
[fluo] branch master updated: Fixes #921 Ensure allocated
timestamps are valid. (#929)
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 <ad...@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" <co...@fluo.apache.org>'].