You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by bh...@apache.org on 2014/04/23 17:10:08 UTC
[01/10] git commit: ACCUMULO-2523 TabletTime.maxMetadataTime NPE if
both arguments are null
Repository: accumulo
Updated Branches:
refs/heads/1.4.6-SNAPSHOT 92c41719b -> 80f8afb10
refs/heads/1.5.2-SNAPSHOT fd1ac9981 -> 700bcf545
refs/heads/1.6.0-SNAPSHOT 9fa4e0f98 -> 782975a1b
refs/heads/master 7548cb712 -> 62bdba0f3
ACCUMULO-2523 TabletTime.maxMetadataTime NPE if both arguments are null
Signed-off-by: Bill Havanki <bh...@cloudera.com>
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/80f8afb1
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/80f8afb1
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/80f8afb1
Branch: refs/heads/1.4.6-SNAPSHOT
Commit: 80f8afb10c69bf337ffd7301e21f729c1c0ce27b
Parents: 92c4171
Author: al.krinker@gmail.com <al...@gmail.com>
Authored: Tue Apr 22 19:04:42 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Wed Apr 23 11:08:35 2014 -0400
----------------------------------------------------------------------
.../java/org/apache/accumulo/server/tabletserver/TabletTime.java | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/80f8afb1/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java b/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
index 255572d..3ba8445 100644
--- a/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
+++ b/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
@@ -78,6 +78,10 @@ public abstract class TabletTime {
}
public static String maxMetadataTime(String mv1, String mv2) {
+ if (mv1 == null && mv2 == null) {
+ return null;
+ }
+
if (mv1 == null) {
checkType(mv2);
return mv2;
[02/10] git commit: ACCUMULO-2523 TabletTime.maxMetadataTime NPE if
both arguments are null
Posted by bh...@apache.org.
ACCUMULO-2523 TabletTime.maxMetadataTime NPE if both arguments are null
Signed-off-by: Bill Havanki <bh...@cloudera.com>
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/80f8afb1
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/80f8afb1
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/80f8afb1
Branch: refs/heads/1.5.2-SNAPSHOT
Commit: 80f8afb10c69bf337ffd7301e21f729c1c0ce27b
Parents: 92c4171
Author: al.krinker@gmail.com <al...@gmail.com>
Authored: Tue Apr 22 19:04:42 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Wed Apr 23 11:08:35 2014 -0400
----------------------------------------------------------------------
.../java/org/apache/accumulo/server/tabletserver/TabletTime.java | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/80f8afb1/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java b/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
index 255572d..3ba8445 100644
--- a/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
+++ b/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
@@ -78,6 +78,10 @@ public abstract class TabletTime {
}
public static String maxMetadataTime(String mv1, String mv2) {
+ if (mv1 == null && mv2 == null) {
+ return null;
+ }
+
if (mv1 == null) {
checkType(mv2);
return mv2;
[09/10] git commit: Merge branch '1.5.2-SNAPSHOT' into 1.6.0-SNAPSHOT
Posted by bh...@apache.org.
Merge branch '1.5.2-SNAPSHOT' into 1.6.0-SNAPSHOT
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/782975a1
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/782975a1
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/782975a1
Branch: refs/heads/master
Commit: 782975a1b898ff33dac66103a70b60a875e1754c
Parents: 9fa4e0f 700bcf5
Author: Bill Havanki <bh...@cloudera.com>
Authored: Wed Apr 23 11:09:34 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Wed Apr 23 11:09:34 2014 -0400
----------------------------------------------------------------------
.../main/java/org/apache/accumulo/server/tablets/TabletTime.java | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/782975a1/server/base/src/main/java/org/apache/accumulo/server/tablets/TabletTime.java
----------------------------------------------------------------------
diff --cc server/base/src/main/java/org/apache/accumulo/server/tablets/TabletTime.java
index bd4ceae,0000000..7f6dcf7
mode 100644,000000..100644
--- a/server/base/src/main/java/org/apache/accumulo/server/tablets/TabletTime.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/tablets/TabletTime.java
@@@ -1,228 -1,0 +1,232 @@@
+/*
+ * 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 copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.server.tablets;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.accumulo.core.client.admin.TimeType;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.server.data.ServerMutation;
+import org.apache.accumulo.server.util.time.RelativeTime;
+
+public abstract class TabletTime {
+ public static final char LOGICAL_TIME_ID = 'L';
+ public static final char MILLIS_TIME_ID = 'M';
+
+ public static char getTimeID(TimeType timeType) {
+ switch (timeType) {
+ case LOGICAL:
+ return LOGICAL_TIME_ID;
+ case MILLIS:
+ return MILLIS_TIME_ID;
+ }
+
+ throw new IllegalArgumentException("Unknown time type " + timeType);
+ }
+
+ public abstract void useMaxTimeFromWALog(long time);
+
+ public abstract String getMetadataValue(long time);
+
+ public abstract String getMetadataValue();
+
+ // abstract long setUpdateTimes(Mutation mutation);
+ public abstract long setUpdateTimes(List<Mutation> mutations);
+
+ public abstract long getTime();
+
+ public abstract long getAndUpdateTime();
+
+ protected void setSystemTimes(Mutation mutation, long lastCommitTime) {
+ ServerMutation m = (ServerMutation) mutation;
+ m.setSystemTimestamp(lastCommitTime);
+ }
+
+ public static TabletTime getInstance(String metadataValue) {
+ if (metadataValue.charAt(0) == LOGICAL_TIME_ID) {
+ return new LogicalTime(Long.parseLong(metadataValue.substring(1)));
+ } else if (metadataValue.charAt(0) == MILLIS_TIME_ID) {
+ return new MillisTime(Long.parseLong(metadataValue.substring(1)));
+ }
+
+ throw new IllegalArgumentException("Time type unknown : " + metadataValue);
+
+ }
+
+ public static String maxMetadataTime(String mv1, String mv2) {
++ if (mv1 == null && mv2 == null) {
++ return null;
++ }
++
+ if (mv1 == null) {
+ checkType(mv2);
+ return mv2;
+ }
+
+ if (mv2 == null) {
+ checkType(mv1);
+ return mv1;
+ }
+
+ if (mv1.charAt(0) != mv2.charAt(0))
+ throw new IllegalArgumentException("Time types differ " + mv1 + " " + mv2);
+ checkType(mv1);
+
+ long t1 = Long.parseLong(mv1.substring(1));
+ long t2 = Long.parseLong(mv2.substring(1));
+
+ if (t1 < t2)
+ return mv2;
+ else
+ return mv1;
+
+ }
+
+ private static void checkType(String mv1) {
+ if (mv1.charAt(0) != LOGICAL_TIME_ID && mv1.charAt(0) != MILLIS_TIME_ID)
+ throw new IllegalArgumentException("Invalid time type " + mv1);
+ }
+
+ static class MillisTime extends TabletTime {
+
+ private long lastTime;
+ private long lastUpdateTime = 0;
+
+ public MillisTime(long time) {
+ this.lastTime = time;
+ }
+
+ @Override
+ public String getMetadataValue(long time) {
+ return MILLIS_TIME_ID + "" + time;
+ }
+
+ @Override
+ public String getMetadataValue() {
+ return getMetadataValue(lastTime);
+ }
+
+ @Override
+ public void useMaxTimeFromWALog(long time) {
+ if (time > lastTime)
+ lastTime = time;
+ }
+
+ @Override
+ public long setUpdateTimes(List<Mutation> mutations) {
+
+ long currTime = RelativeTime.currentTimeMillis();
+
+ synchronized (this) {
+ if (mutations.size() == 0)
+ return lastTime;
+
+ currTime = updateTime(currTime);
+ }
+
+ for (Mutation mutation : mutations)
+ setSystemTimes(mutation, currTime);
+
+ return currTime;
+ }
+
+ private long updateTime(long currTime) {
+ if (currTime < lastTime) {
+ if (currTime - lastUpdateTime > 0) {
+ // not in same millisecond as last call
+ // to this method so move ahead slowly
+ lastTime++;
+ }
+
+ lastUpdateTime = currTime;
+
+ currTime = lastTime;
+ } else {
+ lastTime = currTime;
+ }
+ return currTime;
+ }
+
+ @Override
+ public long getTime() {
+ return lastTime;
+ }
+
+ @Override
+ public long getAndUpdateTime() {
+ long currTime = RelativeTime.currentTimeMillis();
+
+ synchronized (this) {
+ currTime = updateTime(currTime);
+ }
+
+ return currTime;
+ }
+
+ }
+
+ static class LogicalTime extends TabletTime {
+ AtomicLong nextTime;
+
+ private LogicalTime(Long time) {
+ this.nextTime = new AtomicLong(time.longValue() + 1);
+ }
+
+ @Override
+ public void useMaxTimeFromWALog(long time) {
+ time++;
+
+ if (this.nextTime.get() < time) {
+ this.nextTime.set(time);
+ }
+ }
+
+ @Override
+ public String getMetadataValue() {
+ return getMetadataValue(getTime());
+ }
+
+ @Override
+ public String getMetadataValue(long time) {
+ return LOGICAL_TIME_ID + "" + time;
+ }
+
+ @Override
+ public long setUpdateTimes(List<Mutation> mutations) {
+ if (mutations.size() == 0)
+ return getTime();
+
+ long time = nextTime.getAndAdd(mutations.size());
+ for (Mutation mutation : mutations)
+ setSystemTimes(mutation, time++);
+
+ return time - 1;
+ }
+
+ @Override
+ public long getTime() {
+ return nextTime.get() - 1;
+ }
+
+ @Override
+ public long getAndUpdateTime() {
+ return nextTime.getAndIncrement();
+ }
+ }
+
+}
[07/10] git commit: Merge branch '1.4.6-SNAPSHOT' into 1.5.2-SNAPSHOT
Posted by bh...@apache.org.
Merge branch '1.4.6-SNAPSHOT' into 1.5.2-SNAPSHOT
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/700bcf54
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/700bcf54
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/700bcf54
Branch: refs/heads/master
Commit: 700bcf5458880bd30542786d5ec8ddbbd4a8f0e3
Parents: fd1ac99 80f8afb
Author: Bill Havanki <bh...@cloudera.com>
Authored: Wed Apr 23 11:09:03 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Wed Apr 23 11:09:03 2014 -0400
----------------------------------------------------------------------
.../java/org/apache/accumulo/server/tabletserver/TabletTime.java | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/700bcf54/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
----------------------------------------------------------------------
diff --cc server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
index c7cfc59,0000000..aebd33f
mode 100644,000000..100644
--- a/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
+++ b/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
@@@ -1,224 -1,0 +1,228 @@@
+/*
+ * 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 copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.server.tabletserver;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.accumulo.core.client.admin.TimeType;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.server.data.ServerMutation;
+import org.apache.accumulo.server.util.time.RelativeTime;
+
+public abstract class TabletTime {
+ public static final char LOGICAL_TIME_ID = 'L';
+ public static final char MILLIS_TIME_ID = 'M';
+
+ public static char getTimeID(TimeType timeType) {
+ switch (timeType) {
+ case LOGICAL:
+ return LOGICAL_TIME_ID;
+ case MILLIS:
+ return MILLIS_TIME_ID;
+ }
+
+ throw new IllegalArgumentException("Unknown time type " + timeType);
+ }
+
+ abstract void useMaxTimeFromWALog(long time);
+
+ abstract String getMetadataValue(long time);
+
+ abstract String getMetadataValue();
+
+ // abstract long setUpdateTimes(Mutation mutation);
+ abstract long setUpdateTimes(List<Mutation> mutations);
+
+ abstract long getTime();
+
+ abstract long getAndUpdateTime();
+
+ protected void setSystemTimes(Mutation mutation, long lastCommitTime) {
+ ServerMutation m = (ServerMutation)mutation;
+ m.setSystemTimestamp(lastCommitTime);
+ }
+
+ static TabletTime getInstance(String metadataValue) {
+ if (metadataValue.charAt(0) == LOGICAL_TIME_ID) {
+ return new LogicalTime(Long.parseLong(metadataValue.substring(1)));
+ } else if (metadataValue.charAt(0) == MILLIS_TIME_ID) {
+ return new MillisTime(Long.parseLong(metadataValue.substring(1)));
+ }
+
+ throw new IllegalArgumentException("Time type unknown : " + metadataValue);
+
+ }
+
+ public static String maxMetadataTime(String mv1, String mv2) {
++ if (mv1 == null && mv2 == null) {
++ return null;
++ }
++
+ if (mv1 == null) {
+ checkType(mv2);
+ return mv2;
+ }
+
+ if (mv2 == null) {
+ checkType(mv1);
+ return mv1;
+ }
+
+ if (mv1.charAt(0) != mv2.charAt(0)) throw new IllegalArgumentException("Time types differ " + mv1 + " " + mv2);
+ checkType(mv1);
+
+ long t1 = Long.parseLong(mv1.substring(1));
+ long t2 = Long.parseLong(mv2.substring(1));
+
+ if (t1 < t2) return mv2;
+ else return mv1;
+
+ }
+
+ private static void checkType(String mv1) {
+ if (mv1.charAt(0) != LOGICAL_TIME_ID && mv1.charAt(0) != MILLIS_TIME_ID) throw new IllegalArgumentException("Invalid time type " + mv1);
+ }
+
+ static class MillisTime extends TabletTime {
+
+ private long lastTime;
+ private long lastUpdateTime = 0;
+
+ public MillisTime(long time) {
+ this.lastTime = time;
+ }
+
+ @Override
+ String getMetadataValue(long time) {
+ return MILLIS_TIME_ID + "" + time;
+ }
+
+ @Override
+ public String getMetadataValue() {
+ return getMetadataValue(lastTime);
+ }
+
+ @Override
+ void useMaxTimeFromWALog(long time) {
+ if (time > lastTime)
+ lastTime = time;
+ }
+
+ @Override
+ long setUpdateTimes(List<Mutation> mutations) {
+
+ long currTime = RelativeTime.currentTimeMillis();
+
+ synchronized (this) {
+ if (mutations.size() == 0)
+ return lastTime;
+
+ currTime = updateTime(currTime);
+ }
+
+ for (Mutation mutation : mutations)
+ setSystemTimes(mutation, currTime);
+
+ return currTime;
+ }
+
+ private long updateTime(long currTime) {
+ if (currTime < lastTime) {
+ if (currTime - lastUpdateTime > 0) {
+ // not in same millisecond as last call
+ // to this method so move ahead slowly
+ lastTime++;
+ }
+
+ lastUpdateTime = currTime;
+
+ currTime = lastTime;
+ } else {
+ lastTime = currTime;
+ }
+ return currTime;
+ }
+
+ @Override
+ long getTime() {
+ return lastTime;
+ }
+
+ @Override
+ long getAndUpdateTime() {
+ long currTime = RelativeTime.currentTimeMillis();
+
+ synchronized (this) {
+ currTime = updateTime(currTime);
+ }
+
+ return currTime;
+ }
+
+ }
+
+ static class LogicalTime extends TabletTime {
+ AtomicLong nextTime;
+
+ private LogicalTime(Long time) {
+ this.nextTime = new AtomicLong(time.longValue() + 1);
+ }
+
+ @Override
+ void useMaxTimeFromWALog(long time) {
+ time++;
+
+ if (this.nextTime.get() < time) {
+ this.nextTime.set(time);
+ }
+ }
+
+ @Override
+ public String getMetadataValue() {
+ return getMetadataValue(getTime());
+ }
+
+ @Override
+ public String getMetadataValue(long time) {
+ return LOGICAL_TIME_ID + "" + time;
+ }
+
+ @Override
+ long setUpdateTimes(List<Mutation> mutations) {
+ if (mutations.size() == 0)
+ return getTime();
+
+ long time = nextTime.getAndAdd(mutations.size());
+ for (Mutation mutation : mutations)
+ setSystemTimes(mutation, time++);
+
+ return time - 1;
+ }
+
+ @Override
+ long getTime() {
+ return nextTime.get() - 1;
+ }
+
+ @Override
+ long getAndUpdateTime() {
+ return nextTime.getAndIncrement();
+ }
+ }
+
+}
[03/10] git commit: ACCUMULO-2523 TabletTime.maxMetadataTime NPE if
both arguments are null
Posted by bh...@apache.org.
ACCUMULO-2523 TabletTime.maxMetadataTime NPE if both arguments are null
Signed-off-by: Bill Havanki <bh...@cloudera.com>
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/80f8afb1
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/80f8afb1
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/80f8afb1
Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 80f8afb10c69bf337ffd7301e21f729c1c0ce27b
Parents: 92c4171
Author: al.krinker@gmail.com <al...@gmail.com>
Authored: Tue Apr 22 19:04:42 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Wed Apr 23 11:08:35 2014 -0400
----------------------------------------------------------------------
.../java/org/apache/accumulo/server/tabletserver/TabletTime.java | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/80f8afb1/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java b/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
index 255572d..3ba8445 100644
--- a/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
+++ b/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
@@ -78,6 +78,10 @@ public abstract class TabletTime {
}
public static String maxMetadataTime(String mv1, String mv2) {
+ if (mv1 == null && mv2 == null) {
+ return null;
+ }
+
if (mv1 == null) {
checkType(mv2);
return mv2;
[06/10] git commit: Merge branch '1.4.6-SNAPSHOT' into 1.5.2-SNAPSHOT
Posted by bh...@apache.org.
Merge branch '1.4.6-SNAPSHOT' into 1.5.2-SNAPSHOT
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/700bcf54
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/700bcf54
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/700bcf54
Branch: refs/heads/1.5.2-SNAPSHOT
Commit: 700bcf5458880bd30542786d5ec8ddbbd4a8f0e3
Parents: fd1ac99 80f8afb
Author: Bill Havanki <bh...@cloudera.com>
Authored: Wed Apr 23 11:09:03 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Wed Apr 23 11:09:03 2014 -0400
----------------------------------------------------------------------
.../java/org/apache/accumulo/server/tabletserver/TabletTime.java | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/700bcf54/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
----------------------------------------------------------------------
diff --cc server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
index c7cfc59,0000000..aebd33f
mode 100644,000000..100644
--- a/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
+++ b/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
@@@ -1,224 -1,0 +1,228 @@@
+/*
+ * 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 copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.server.tabletserver;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.accumulo.core.client.admin.TimeType;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.server.data.ServerMutation;
+import org.apache.accumulo.server.util.time.RelativeTime;
+
+public abstract class TabletTime {
+ public static final char LOGICAL_TIME_ID = 'L';
+ public static final char MILLIS_TIME_ID = 'M';
+
+ public static char getTimeID(TimeType timeType) {
+ switch (timeType) {
+ case LOGICAL:
+ return LOGICAL_TIME_ID;
+ case MILLIS:
+ return MILLIS_TIME_ID;
+ }
+
+ throw new IllegalArgumentException("Unknown time type " + timeType);
+ }
+
+ abstract void useMaxTimeFromWALog(long time);
+
+ abstract String getMetadataValue(long time);
+
+ abstract String getMetadataValue();
+
+ // abstract long setUpdateTimes(Mutation mutation);
+ abstract long setUpdateTimes(List<Mutation> mutations);
+
+ abstract long getTime();
+
+ abstract long getAndUpdateTime();
+
+ protected void setSystemTimes(Mutation mutation, long lastCommitTime) {
+ ServerMutation m = (ServerMutation)mutation;
+ m.setSystemTimestamp(lastCommitTime);
+ }
+
+ static TabletTime getInstance(String metadataValue) {
+ if (metadataValue.charAt(0) == LOGICAL_TIME_ID) {
+ return new LogicalTime(Long.parseLong(metadataValue.substring(1)));
+ } else if (metadataValue.charAt(0) == MILLIS_TIME_ID) {
+ return new MillisTime(Long.parseLong(metadataValue.substring(1)));
+ }
+
+ throw new IllegalArgumentException("Time type unknown : " + metadataValue);
+
+ }
+
+ public static String maxMetadataTime(String mv1, String mv2) {
++ if (mv1 == null && mv2 == null) {
++ return null;
++ }
++
+ if (mv1 == null) {
+ checkType(mv2);
+ return mv2;
+ }
+
+ if (mv2 == null) {
+ checkType(mv1);
+ return mv1;
+ }
+
+ if (mv1.charAt(0) != mv2.charAt(0)) throw new IllegalArgumentException("Time types differ " + mv1 + " " + mv2);
+ checkType(mv1);
+
+ long t1 = Long.parseLong(mv1.substring(1));
+ long t2 = Long.parseLong(mv2.substring(1));
+
+ if (t1 < t2) return mv2;
+ else return mv1;
+
+ }
+
+ private static void checkType(String mv1) {
+ if (mv1.charAt(0) != LOGICAL_TIME_ID && mv1.charAt(0) != MILLIS_TIME_ID) throw new IllegalArgumentException("Invalid time type " + mv1);
+ }
+
+ static class MillisTime extends TabletTime {
+
+ private long lastTime;
+ private long lastUpdateTime = 0;
+
+ public MillisTime(long time) {
+ this.lastTime = time;
+ }
+
+ @Override
+ String getMetadataValue(long time) {
+ return MILLIS_TIME_ID + "" + time;
+ }
+
+ @Override
+ public String getMetadataValue() {
+ return getMetadataValue(lastTime);
+ }
+
+ @Override
+ void useMaxTimeFromWALog(long time) {
+ if (time > lastTime)
+ lastTime = time;
+ }
+
+ @Override
+ long setUpdateTimes(List<Mutation> mutations) {
+
+ long currTime = RelativeTime.currentTimeMillis();
+
+ synchronized (this) {
+ if (mutations.size() == 0)
+ return lastTime;
+
+ currTime = updateTime(currTime);
+ }
+
+ for (Mutation mutation : mutations)
+ setSystemTimes(mutation, currTime);
+
+ return currTime;
+ }
+
+ private long updateTime(long currTime) {
+ if (currTime < lastTime) {
+ if (currTime - lastUpdateTime > 0) {
+ // not in same millisecond as last call
+ // to this method so move ahead slowly
+ lastTime++;
+ }
+
+ lastUpdateTime = currTime;
+
+ currTime = lastTime;
+ } else {
+ lastTime = currTime;
+ }
+ return currTime;
+ }
+
+ @Override
+ long getTime() {
+ return lastTime;
+ }
+
+ @Override
+ long getAndUpdateTime() {
+ long currTime = RelativeTime.currentTimeMillis();
+
+ synchronized (this) {
+ currTime = updateTime(currTime);
+ }
+
+ return currTime;
+ }
+
+ }
+
+ static class LogicalTime extends TabletTime {
+ AtomicLong nextTime;
+
+ private LogicalTime(Long time) {
+ this.nextTime = new AtomicLong(time.longValue() + 1);
+ }
+
+ @Override
+ void useMaxTimeFromWALog(long time) {
+ time++;
+
+ if (this.nextTime.get() < time) {
+ this.nextTime.set(time);
+ }
+ }
+
+ @Override
+ public String getMetadataValue() {
+ return getMetadataValue(getTime());
+ }
+
+ @Override
+ public String getMetadataValue(long time) {
+ return LOGICAL_TIME_ID + "" + time;
+ }
+
+ @Override
+ long setUpdateTimes(List<Mutation> mutations) {
+ if (mutations.size() == 0)
+ return getTime();
+
+ long time = nextTime.getAndAdd(mutations.size());
+ for (Mutation mutation : mutations)
+ setSystemTimes(mutation, time++);
+
+ return time - 1;
+ }
+
+ @Override
+ long getTime() {
+ return nextTime.get() - 1;
+ }
+
+ @Override
+ long getAndUpdateTime() {
+ return nextTime.getAndIncrement();
+ }
+ }
+
+}
[10/10] git commit: Merge branch '1.6.0-SNAPSHOT'
Posted by bh...@apache.org.
Merge branch '1.6.0-SNAPSHOT'
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/62bdba0f
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/62bdba0f
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/62bdba0f
Branch: refs/heads/master
Commit: 62bdba0f335b6ad4fbeb4e5deb1e436718600d0b
Parents: 7548cb7 782975a
Author: Bill Havanki <bh...@cloudera.com>
Authored: Wed Apr 23 11:10:01 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Wed Apr 23 11:10:01 2014 -0400
----------------------------------------------------------------------
.../main/java/org/apache/accumulo/server/tablets/TabletTime.java | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
[04/10] git commit: ACCUMULO-2523 TabletTime.maxMetadataTime NPE if
both arguments are null
Posted by bh...@apache.org.
ACCUMULO-2523 TabletTime.maxMetadataTime NPE if both arguments are null
Signed-off-by: Bill Havanki <bh...@cloudera.com>
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/80f8afb1
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/80f8afb1
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/80f8afb1
Branch: refs/heads/master
Commit: 80f8afb10c69bf337ffd7301e21f729c1c0ce27b
Parents: 92c4171
Author: al.krinker@gmail.com <al...@gmail.com>
Authored: Tue Apr 22 19:04:42 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Wed Apr 23 11:08:35 2014 -0400
----------------------------------------------------------------------
.../java/org/apache/accumulo/server/tabletserver/TabletTime.java | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/80f8afb1/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java b/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
index 255572d..3ba8445 100644
--- a/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
+++ b/src/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
@@ -78,6 +78,10 @@ public abstract class TabletTime {
}
public static String maxMetadataTime(String mv1, String mv2) {
+ if (mv1 == null && mv2 == null) {
+ return null;
+ }
+
if (mv1 == null) {
checkType(mv2);
return mv2;
[05/10] git commit: Merge branch '1.4.6-SNAPSHOT' into 1.5.2-SNAPSHOT
Posted by bh...@apache.org.
Merge branch '1.4.6-SNAPSHOT' into 1.5.2-SNAPSHOT
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/700bcf54
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/700bcf54
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/700bcf54
Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 700bcf5458880bd30542786d5ec8ddbbd4a8f0e3
Parents: fd1ac99 80f8afb
Author: Bill Havanki <bh...@cloudera.com>
Authored: Wed Apr 23 11:09:03 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Wed Apr 23 11:09:03 2014 -0400
----------------------------------------------------------------------
.../java/org/apache/accumulo/server/tabletserver/TabletTime.java | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/700bcf54/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
----------------------------------------------------------------------
diff --cc server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
index c7cfc59,0000000..aebd33f
mode 100644,000000..100644
--- a/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
+++ b/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletTime.java
@@@ -1,224 -1,0 +1,228 @@@
+/*
+ * 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 copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.server.tabletserver;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.accumulo.core.client.admin.TimeType;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.server.data.ServerMutation;
+import org.apache.accumulo.server.util.time.RelativeTime;
+
+public abstract class TabletTime {
+ public static final char LOGICAL_TIME_ID = 'L';
+ public static final char MILLIS_TIME_ID = 'M';
+
+ public static char getTimeID(TimeType timeType) {
+ switch (timeType) {
+ case LOGICAL:
+ return LOGICAL_TIME_ID;
+ case MILLIS:
+ return MILLIS_TIME_ID;
+ }
+
+ throw new IllegalArgumentException("Unknown time type " + timeType);
+ }
+
+ abstract void useMaxTimeFromWALog(long time);
+
+ abstract String getMetadataValue(long time);
+
+ abstract String getMetadataValue();
+
+ // abstract long setUpdateTimes(Mutation mutation);
+ abstract long setUpdateTimes(List<Mutation> mutations);
+
+ abstract long getTime();
+
+ abstract long getAndUpdateTime();
+
+ protected void setSystemTimes(Mutation mutation, long lastCommitTime) {
+ ServerMutation m = (ServerMutation)mutation;
+ m.setSystemTimestamp(lastCommitTime);
+ }
+
+ static TabletTime getInstance(String metadataValue) {
+ if (metadataValue.charAt(0) == LOGICAL_TIME_ID) {
+ return new LogicalTime(Long.parseLong(metadataValue.substring(1)));
+ } else if (metadataValue.charAt(0) == MILLIS_TIME_ID) {
+ return new MillisTime(Long.parseLong(metadataValue.substring(1)));
+ }
+
+ throw new IllegalArgumentException("Time type unknown : " + metadataValue);
+
+ }
+
+ public static String maxMetadataTime(String mv1, String mv2) {
++ if (mv1 == null && mv2 == null) {
++ return null;
++ }
++
+ if (mv1 == null) {
+ checkType(mv2);
+ return mv2;
+ }
+
+ if (mv2 == null) {
+ checkType(mv1);
+ return mv1;
+ }
+
+ if (mv1.charAt(0) != mv2.charAt(0)) throw new IllegalArgumentException("Time types differ " + mv1 + " " + mv2);
+ checkType(mv1);
+
+ long t1 = Long.parseLong(mv1.substring(1));
+ long t2 = Long.parseLong(mv2.substring(1));
+
+ if (t1 < t2) return mv2;
+ else return mv1;
+
+ }
+
+ private static void checkType(String mv1) {
+ if (mv1.charAt(0) != LOGICAL_TIME_ID && mv1.charAt(0) != MILLIS_TIME_ID) throw new IllegalArgumentException("Invalid time type " + mv1);
+ }
+
+ static class MillisTime extends TabletTime {
+
+ private long lastTime;
+ private long lastUpdateTime = 0;
+
+ public MillisTime(long time) {
+ this.lastTime = time;
+ }
+
+ @Override
+ String getMetadataValue(long time) {
+ return MILLIS_TIME_ID + "" + time;
+ }
+
+ @Override
+ public String getMetadataValue() {
+ return getMetadataValue(lastTime);
+ }
+
+ @Override
+ void useMaxTimeFromWALog(long time) {
+ if (time > lastTime)
+ lastTime = time;
+ }
+
+ @Override
+ long setUpdateTimes(List<Mutation> mutations) {
+
+ long currTime = RelativeTime.currentTimeMillis();
+
+ synchronized (this) {
+ if (mutations.size() == 0)
+ return lastTime;
+
+ currTime = updateTime(currTime);
+ }
+
+ for (Mutation mutation : mutations)
+ setSystemTimes(mutation, currTime);
+
+ return currTime;
+ }
+
+ private long updateTime(long currTime) {
+ if (currTime < lastTime) {
+ if (currTime - lastUpdateTime > 0) {
+ // not in same millisecond as last call
+ // to this method so move ahead slowly
+ lastTime++;
+ }
+
+ lastUpdateTime = currTime;
+
+ currTime = lastTime;
+ } else {
+ lastTime = currTime;
+ }
+ return currTime;
+ }
+
+ @Override
+ long getTime() {
+ return lastTime;
+ }
+
+ @Override
+ long getAndUpdateTime() {
+ long currTime = RelativeTime.currentTimeMillis();
+
+ synchronized (this) {
+ currTime = updateTime(currTime);
+ }
+
+ return currTime;
+ }
+
+ }
+
+ static class LogicalTime extends TabletTime {
+ AtomicLong nextTime;
+
+ private LogicalTime(Long time) {
+ this.nextTime = new AtomicLong(time.longValue() + 1);
+ }
+
+ @Override
+ void useMaxTimeFromWALog(long time) {
+ time++;
+
+ if (this.nextTime.get() < time) {
+ this.nextTime.set(time);
+ }
+ }
+
+ @Override
+ public String getMetadataValue() {
+ return getMetadataValue(getTime());
+ }
+
+ @Override
+ public String getMetadataValue(long time) {
+ return LOGICAL_TIME_ID + "" + time;
+ }
+
+ @Override
+ long setUpdateTimes(List<Mutation> mutations) {
+ if (mutations.size() == 0)
+ return getTime();
+
+ long time = nextTime.getAndAdd(mutations.size());
+ for (Mutation mutation : mutations)
+ setSystemTimes(mutation, time++);
+
+ return time - 1;
+ }
+
+ @Override
+ long getTime() {
+ return nextTime.get() - 1;
+ }
+
+ @Override
+ long getAndUpdateTime() {
+ return nextTime.getAndIncrement();
+ }
+ }
+
+}
[08/10] git commit: Merge branch '1.5.2-SNAPSHOT' into 1.6.0-SNAPSHOT
Posted by bh...@apache.org.
Merge branch '1.5.2-SNAPSHOT' into 1.6.0-SNAPSHOT
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/782975a1
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/782975a1
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/782975a1
Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 782975a1b898ff33dac66103a70b60a875e1754c
Parents: 9fa4e0f 700bcf5
Author: Bill Havanki <bh...@cloudera.com>
Authored: Wed Apr 23 11:09:34 2014 -0400
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Wed Apr 23 11:09:34 2014 -0400
----------------------------------------------------------------------
.../main/java/org/apache/accumulo/server/tablets/TabletTime.java | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/782975a1/server/base/src/main/java/org/apache/accumulo/server/tablets/TabletTime.java
----------------------------------------------------------------------
diff --cc server/base/src/main/java/org/apache/accumulo/server/tablets/TabletTime.java
index bd4ceae,0000000..7f6dcf7
mode 100644,000000..100644
--- a/server/base/src/main/java/org/apache/accumulo/server/tablets/TabletTime.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/tablets/TabletTime.java
@@@ -1,228 -1,0 +1,232 @@@
+/*
+ * 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 copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.server.tablets;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.accumulo.core.client.admin.TimeType;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.server.data.ServerMutation;
+import org.apache.accumulo.server.util.time.RelativeTime;
+
+public abstract class TabletTime {
+ public static final char LOGICAL_TIME_ID = 'L';
+ public static final char MILLIS_TIME_ID = 'M';
+
+ public static char getTimeID(TimeType timeType) {
+ switch (timeType) {
+ case LOGICAL:
+ return LOGICAL_TIME_ID;
+ case MILLIS:
+ return MILLIS_TIME_ID;
+ }
+
+ throw new IllegalArgumentException("Unknown time type " + timeType);
+ }
+
+ public abstract void useMaxTimeFromWALog(long time);
+
+ public abstract String getMetadataValue(long time);
+
+ public abstract String getMetadataValue();
+
+ // abstract long setUpdateTimes(Mutation mutation);
+ public abstract long setUpdateTimes(List<Mutation> mutations);
+
+ public abstract long getTime();
+
+ public abstract long getAndUpdateTime();
+
+ protected void setSystemTimes(Mutation mutation, long lastCommitTime) {
+ ServerMutation m = (ServerMutation) mutation;
+ m.setSystemTimestamp(lastCommitTime);
+ }
+
+ public static TabletTime getInstance(String metadataValue) {
+ if (metadataValue.charAt(0) == LOGICAL_TIME_ID) {
+ return new LogicalTime(Long.parseLong(metadataValue.substring(1)));
+ } else if (metadataValue.charAt(0) == MILLIS_TIME_ID) {
+ return new MillisTime(Long.parseLong(metadataValue.substring(1)));
+ }
+
+ throw new IllegalArgumentException("Time type unknown : " + metadataValue);
+
+ }
+
+ public static String maxMetadataTime(String mv1, String mv2) {
++ if (mv1 == null && mv2 == null) {
++ return null;
++ }
++
+ if (mv1 == null) {
+ checkType(mv2);
+ return mv2;
+ }
+
+ if (mv2 == null) {
+ checkType(mv1);
+ return mv1;
+ }
+
+ if (mv1.charAt(0) != mv2.charAt(0))
+ throw new IllegalArgumentException("Time types differ " + mv1 + " " + mv2);
+ checkType(mv1);
+
+ long t1 = Long.parseLong(mv1.substring(1));
+ long t2 = Long.parseLong(mv2.substring(1));
+
+ if (t1 < t2)
+ return mv2;
+ else
+ return mv1;
+
+ }
+
+ private static void checkType(String mv1) {
+ if (mv1.charAt(0) != LOGICAL_TIME_ID && mv1.charAt(0) != MILLIS_TIME_ID)
+ throw new IllegalArgumentException("Invalid time type " + mv1);
+ }
+
+ static class MillisTime extends TabletTime {
+
+ private long lastTime;
+ private long lastUpdateTime = 0;
+
+ public MillisTime(long time) {
+ this.lastTime = time;
+ }
+
+ @Override
+ public String getMetadataValue(long time) {
+ return MILLIS_TIME_ID + "" + time;
+ }
+
+ @Override
+ public String getMetadataValue() {
+ return getMetadataValue(lastTime);
+ }
+
+ @Override
+ public void useMaxTimeFromWALog(long time) {
+ if (time > lastTime)
+ lastTime = time;
+ }
+
+ @Override
+ public long setUpdateTimes(List<Mutation> mutations) {
+
+ long currTime = RelativeTime.currentTimeMillis();
+
+ synchronized (this) {
+ if (mutations.size() == 0)
+ return lastTime;
+
+ currTime = updateTime(currTime);
+ }
+
+ for (Mutation mutation : mutations)
+ setSystemTimes(mutation, currTime);
+
+ return currTime;
+ }
+
+ private long updateTime(long currTime) {
+ if (currTime < lastTime) {
+ if (currTime - lastUpdateTime > 0) {
+ // not in same millisecond as last call
+ // to this method so move ahead slowly
+ lastTime++;
+ }
+
+ lastUpdateTime = currTime;
+
+ currTime = lastTime;
+ } else {
+ lastTime = currTime;
+ }
+ return currTime;
+ }
+
+ @Override
+ public long getTime() {
+ return lastTime;
+ }
+
+ @Override
+ public long getAndUpdateTime() {
+ long currTime = RelativeTime.currentTimeMillis();
+
+ synchronized (this) {
+ currTime = updateTime(currTime);
+ }
+
+ return currTime;
+ }
+
+ }
+
+ static class LogicalTime extends TabletTime {
+ AtomicLong nextTime;
+
+ private LogicalTime(Long time) {
+ this.nextTime = new AtomicLong(time.longValue() + 1);
+ }
+
+ @Override
+ public void useMaxTimeFromWALog(long time) {
+ time++;
+
+ if (this.nextTime.get() < time) {
+ this.nextTime.set(time);
+ }
+ }
+
+ @Override
+ public String getMetadataValue() {
+ return getMetadataValue(getTime());
+ }
+
+ @Override
+ public String getMetadataValue(long time) {
+ return LOGICAL_TIME_ID + "" + time;
+ }
+
+ @Override
+ public long setUpdateTimes(List<Mutation> mutations) {
+ if (mutations.size() == 0)
+ return getTime();
+
+ long time = nextTime.getAndAdd(mutations.size());
+ for (Mutation mutation : mutations)
+ setSystemTimes(mutation, time++);
+
+ return time - 1;
+ }
+
+ @Override
+ public long getTime() {
+ return nextTime.get() - 1;
+ }
+
+ @Override
+ public long getAndUpdateTime() {
+ return nextTime.getAndIncrement();
+ }
+ }
+
+}