forked from googleapis/java-bigtable-hbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f08c09
commit a0fd796
Showing
37 changed files
with
545 additions
and
44 deletions.
There are no files selected for viewing
76 changes: 38 additions & 38 deletions
76
...ion-tests/src/test/java/com/google/cloud/bigtable/hbase/mirroring/TestMirroringTable.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...n/java/com/google/cloud/bigtable/mirroring/hbase1_x/utils/timestamper/MonotonicTimer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed 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 com.google.cloud.bigtable.mirroring.hbase1_x.utils.timestamper; | ||
|
||
import com.google.common.base.Stopwatch; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
* {@code System#currentTimeMillis()} is not monotonic and using it as a source for {@link | ||
* org.apache.hadoop.hbase.client.Mutation} timestamps can result in confusion and unexpected | ||
* reordering of written versions. | ||
* | ||
* <p>This class provides a monotonically increasing value that is related to wall time. | ||
* | ||
* <p>Guava's {@link Stopwatch} is monotonic because it uses {@link System#nanoTime()} to measure | ||
* passed time. | ||
*/ | ||
public class MonotonicTimer { | ||
private final long startingTimestampMillis; | ||
private final Stopwatch stopwatch; | ||
|
||
public MonotonicTimer() { | ||
this.startingTimestampMillis = System.currentTimeMillis(); | ||
this.stopwatch = Stopwatch.createStarted(); | ||
} | ||
|
||
public long getCurrentTimeMillis() { | ||
return this.startingTimestampMillis + this.stopwatch.elapsed(TimeUnit.MILLISECONDS); | ||
} | ||
} |
Oops, something went wrong.