HBASE-16176 Bug fixes/improvements on HBASE-15650 Remove
TimeRangeTracker as point of contention when many threads reading a StoreFile Fixes HBASE-16074 ITBLL fails, reports lost big or tiny families broken scanning because of a side effect of a clean up in HBASE-15650 to make TimeRange construction consistent exposed a latent issue in TimeRange#compare. See HBASE-16074 for more detail. Also change HFile Writer constructor so we pass in the TimeRangeTracker, if one, on construction rather than set later (the flag and reference were not volatile so could have made for issues in concurrent case). And make sure the construction of a TimeRange from a TimeRangeTracer on open of an HFile Reader never makes a bad minimum value, one that would preclude us reading any values from a file (set min to 0) M hbase-common/src/main/java/org/apache/hadoop/hbase/io/TimeRange.java Call through to next constructor (if minStamp was 0, we'd skip setting allTime=true). Add asserts that timestamps are not < 0 cos it messes us up if they are (we already were checking for < 0 on construction but assert passed in timestamps are not < 0). M hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java Add constructor override that takes a TimeRangeTracker (set when flushing but not when compacting) M hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java Add override creating an HFile in tmp that takes a TimeRangeTracker M hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java Add override for HFile Writer that takes a TimeRangeTracker Take it on construction instead of having it passed by a setter later (flags and reference set by the setter were not volatile... could have been prob in concurrent case) M hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/TimeRangeTracker.java Log WARN if bad initial TimeRange value (and then 'fix' it) M hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestTimeRangeTracker.java A few tests to prove serialization works as expected and that we'll get a bad min if not constructed properly. M hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java Handle OLDEST_TIMESTAMP explictly. Don't expect TimeRange to do it. M hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestQueryMatcher.java Refactor from junit3 to junit4 and add test for this weird case.
This commit is contained in:
parent
3c39cbd92c
commit
496fd9837a
|
@ -203,6 +203,4 @@ public abstract class Query extends OperationWithAttributes {
|
||||||
public Map<byte[], TimeRange> getColumnFamilyTimeRange() {
|
public Map<byte[], TimeRange> getColumnFamilyTimeRange() {
|
||||||
return this.colFamTimeRangeMap;
|
return this.colFamTimeRangeMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -544,7 +544,12 @@ public final class HConstants {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Timestamp to use when we want to refer to the oldest cell.
|
* Timestamp to use when we want to refer to the oldest cell.
|
||||||
|
* Special! Used in fake Cells only. Should never be the timestamp on an actual Cell returned to
|
||||||
|
* a client.
|
||||||
|
* @deprecated Should not be public since hbase-1.3.0. For internal use only. Move internal to
|
||||||
|
* Scanners flagged as special timestamp value never to be returned as timestamp on a Cell.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static final long OLDEST_TIMESTAMP = Long.MIN_VALUE;
|
public static final long OLDEST_TIMESTAMP = Long.MIN_VALUE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -237,7 +237,7 @@ public class KeyValueUtil {
|
||||||
/**
|
/**
|
||||||
* Create a KeyValue for the specified row, family and qualifier that would be
|
* Create a KeyValue for the specified row, family and qualifier that would be
|
||||||
* larger than or equal to all other possible KeyValues that have the same
|
* larger than or equal to all other possible KeyValues that have the same
|
||||||
* row, family, qualifier. Used for reseeking.
|
* row, family, qualifier. Used for reseeking. Should NEVER be returned to a client.
|
||||||
*
|
*
|
||||||
* @param row
|
* @param row
|
||||||
* row key
|
* row key
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* or more contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -26,57 +25,86 @@ import org.apache.hadoop.hbase.classification.InterfaceStability;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an interval of version timestamps.
|
* Represents an interval of version timestamps. Presumes timestamps between
|
||||||
|
* {@link #INITIAL_MIN_TIMESTAMP} and {@link #INITIAL_MAX_TIMESTAMP} only. Gets freaked out if
|
||||||
|
* passed a timestamp that is < {@link #INITIAL_MIN_TIMESTAMP},
|
||||||
* <p>
|
* <p>
|
||||||
* Evaluated according to minStamp <= timestamp < maxStamp
|
* Evaluated according to minStamp <= timestamp < maxStamp
|
||||||
* or [minStamp,maxStamp) in interval notation.
|
* or [minStamp,maxStamp) in interval notation.
|
||||||
* <p>
|
* <p>
|
||||||
* Only used internally; should not be accessed directly by clients.
|
* Only used internally; should not be accessed directly by clients.
|
||||||
|
*<p>Immutable. Thread-safe.
|
||||||
*/
|
*/
|
||||||
@InterfaceAudience.Public
|
@InterfaceAudience.Public
|
||||||
@InterfaceStability.Stable
|
@InterfaceStability.Stable
|
||||||
public class TimeRange {
|
public class TimeRange {
|
||||||
static final long INITIAL_MIN_TIMESTAMP = 0l;
|
public static final long INITIAL_MIN_TIMESTAMP = 0L;
|
||||||
private static final long MIN_TIME = INITIAL_MIN_TIMESTAMP;
|
public static final long INITIAL_MAX_TIMESTAMP = Long.MAX_VALUE;
|
||||||
static final long INITIAL_MAX_TIMESTAMP = Long.MAX_VALUE;
|
private final long minStamp;
|
||||||
static final long MAX_TIME = INITIAL_MAX_TIMESTAMP;
|
private final long maxStamp;
|
||||||
private long minStamp = MIN_TIME;
|
|
||||||
private long maxStamp = MAX_TIME;
|
|
||||||
private final boolean allTime;
|
private final boolean allTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
* Represents interval [0, Long.MAX_VALUE) (allTime)
|
* Represents interval [0, Long.MAX_VALUE) (allTime)
|
||||||
|
* @deprecated This is made @InterfaceAudience.Private in the 2.0 line and above
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public TimeRange() {
|
public TimeRange() {
|
||||||
allTime = true;
|
this(INITIAL_MIN_TIMESTAMP, INITIAL_MAX_TIMESTAMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents interval [minStamp, Long.MAX_VALUE)
|
* Represents interval [minStamp, Long.MAX_VALUE)
|
||||||
* @param minStamp the minimum timestamp value, inclusive
|
* @param minStamp the minimum timestamp value, inclusive
|
||||||
|
* @deprecated This is made @InterfaceAudience.Private in the 2.0 line and above
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public TimeRange(long minStamp) {
|
public TimeRange(long minStamp) {
|
||||||
this.minStamp = minStamp;
|
this(minStamp, INITIAL_MAX_TIMESTAMP);
|
||||||
this.allTime = this.minStamp == MIN_TIME;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents interval [minStamp, Long.MAX_VALUE)
|
* Represents interval [minStamp, Long.MAX_VALUE)
|
||||||
* @param minStamp the minimum timestamp value, inclusive
|
* @param minStamp the minimum timestamp value, inclusive
|
||||||
|
* @deprecated This is made @InterfaceAudience.Private in the 2.0 line and above
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public TimeRange(byte [] minStamp) {
|
public TimeRange(byte [] minStamp) {
|
||||||
this.minStamp = Bytes.toLong(minStamp);
|
this(Bytes.toLong(minStamp));
|
||||||
this.allTime = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents interval [minStamp, maxStamp)
|
* Represents interval [minStamp, maxStamp)
|
||||||
* @param minStamp the minimum timestamp, inclusive
|
* @param minStamp the minimum timestamp, inclusive
|
||||||
* @param maxStamp the maximum timestamp, exclusive
|
* @param maxStamp the maximum timestamp, exclusive
|
||||||
* @throws IllegalArgumentException
|
* @deprecated This is made @InterfaceAudience.Private in the 2.0 line and above
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public TimeRange(byte [] minStamp, byte [] maxStamp) {
|
||||||
|
this(Bytes.toLong(minStamp), Bytes.toLong(maxStamp));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents interval [minStamp, maxStamp)
|
||||||
|
* @param minStamp the minimum timestamp, inclusive
|
||||||
|
* @param maxStamp the maximum timestamp, exclusive
|
||||||
|
* @throws IllegalArgumentException if either <0,
|
||||||
|
* @deprecated This is made @InterfaceAudience.Private in the 2.0 line and above
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public TimeRange(long minStamp, long maxStamp) {
|
public TimeRange(long minStamp, long maxStamp) {
|
||||||
|
check(minStamp, maxStamp);
|
||||||
|
this.minStamp = minStamp;
|
||||||
|
this.maxStamp = maxStamp;
|
||||||
|
this.allTime = isAllTime(minStamp, maxStamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isAllTime(long minStamp, long maxStamp) {
|
||||||
|
return minStamp == INITIAL_MIN_TIMESTAMP && maxStamp == INITIAL_MAX_TIMESTAMP;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void check(long minStamp, long maxStamp) {
|
||||||
if (minStamp < 0 || maxStamp < 0) {
|
if (minStamp < 0 || maxStamp < 0) {
|
||||||
throw new IllegalArgumentException("Timestamp cannot be negative. minStamp:" + minStamp
|
throw new IllegalArgumentException("Timestamp cannot be negative. minStamp:" + minStamp
|
||||||
+ ", maxStamp:" + maxStamp);
|
+ ", maxStamp:" + maxStamp);
|
||||||
|
@ -84,20 +112,6 @@ public class TimeRange {
|
||||||
if (maxStamp < minStamp) {
|
if (maxStamp < minStamp) {
|
||||||
throw new IllegalArgumentException("maxStamp is smaller than minStamp");
|
throw new IllegalArgumentException("maxStamp is smaller than minStamp");
|
||||||
}
|
}
|
||||||
this.minStamp = minStamp;
|
|
||||||
this.maxStamp = maxStamp;
|
|
||||||
this.allTime = this.minStamp == MIN_TIME && this.maxStamp == MAX_TIME;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents interval [minStamp, maxStamp)
|
|
||||||
* @param minStamp the minimum timestamp, inclusive
|
|
||||||
* @param maxStamp the maximum timestamp, exclusive
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
public TimeRange(byte [] minStamp, byte [] maxStamp)
|
|
||||||
throws IOException {
|
|
||||||
this(Bytes.toLong(minStamp), Bytes.toLong(maxStamp));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -125,14 +139,15 @@ public class TimeRange {
|
||||||
/**
|
/**
|
||||||
* Check if the specified timestamp is within this TimeRange.
|
* Check if the specified timestamp is within this TimeRange.
|
||||||
* <p>
|
* <p>
|
||||||
* Returns true if within interval [minStamp, maxStamp), false
|
* Returns true if within interval [minStamp, maxStamp), false if not.
|
||||||
* if not.
|
|
||||||
* @param bytes timestamp to check
|
* @param bytes timestamp to check
|
||||||
* @param offset offset into the bytes
|
* @param offset offset into the bytes
|
||||||
* @return true if within TimeRange, false if not
|
* @return true if within TimeRange, false if not
|
||||||
*/
|
*/
|
||||||
public boolean withinTimeRange(byte [] bytes, int offset) {
|
public boolean withinTimeRange(byte [] bytes, int offset) {
|
||||||
if(allTime) return true;
|
if (allTime) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return withinTimeRange(Bytes.toLong(bytes, offset));
|
return withinTimeRange(Bytes.toLong(bytes, offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +160,7 @@ public class TimeRange {
|
||||||
* @return true if within TimeRange, false if not
|
* @return true if within TimeRange, false if not
|
||||||
*/
|
*/
|
||||||
public boolean withinTimeRange(long timestamp) {
|
public boolean withinTimeRange(long timestamp) {
|
||||||
|
assert timestamp >= 0;
|
||||||
if (this.allTime) {
|
if (this.allTime) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -163,6 +179,7 @@ public class TimeRange {
|
||||||
if (this.allTime) {
|
if (this.allTime) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
assert tr.getMin() >= 0;
|
||||||
return getMin() < tr.getMax() && getMax() >= tr.getMin();
|
return getMin() < tr.getMax() && getMax() >= tr.getMin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,27 +192,29 @@ public class TimeRange {
|
||||||
* @return true if within TimeRange, false if not
|
* @return true if within TimeRange, false if not
|
||||||
*/
|
*/
|
||||||
public boolean withinOrAfterTimeRange(long timestamp) {
|
public boolean withinOrAfterTimeRange(long timestamp) {
|
||||||
if(allTime) return true;
|
assert timestamp >= 0;
|
||||||
|
if (allTime) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
// check if >= minStamp
|
// check if >= minStamp
|
||||||
return (timestamp >= minStamp);
|
return timestamp >= minStamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare the timestamp to timerange
|
* Compare the timestamp to timerange.
|
||||||
* @param timestamp
|
|
||||||
* @return -1 if timestamp is less than timerange,
|
* @return -1 if timestamp is less than timerange,
|
||||||
* 0 if timestamp is within timerange,
|
* 0 if timestamp is within timerange,
|
||||||
* 1 if timestamp is greater than timerange
|
* 1 if timestamp is greater than timerange
|
||||||
*/
|
*/
|
||||||
public int compare(long timestamp) {
|
public int compare(long timestamp) {
|
||||||
if (allTime) return 0;
|
assert timestamp >= 0;
|
||||||
if (timestamp < minStamp) {
|
if (this.allTime) {
|
||||||
return -1;
|
|
||||||
} else if (timestamp >= maxStamp) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (timestamp < minStamp) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return timestamp >= maxStamp? 1: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -99,7 +99,7 @@ public class DefaultMobStoreFlusher extends DefaultStoreFlusher {
|
||||||
public List<Path> flushSnapshot(MemStoreSnapshot snapshot, long cacheFlushId,
|
public List<Path> flushSnapshot(MemStoreSnapshot snapshot, long cacheFlushId,
|
||||||
MonitoredTask status, ThroughputController throughputController) throws IOException {
|
MonitoredTask status, ThroughputController throughputController) throws IOException {
|
||||||
ArrayList<Path> result = new ArrayList<Path>();
|
ArrayList<Path> result = new ArrayList<Path>();
|
||||||
int cellsCount = snapshot.getCellsCount();
|
long cellsCount = snapshot.getCellsCount();
|
||||||
if (cellsCount == 0) return result; // don't flush if there are no entries
|
if (cellsCount == 0) return result; // don't flush if there are no entries
|
||||||
|
|
||||||
// Use a store scanner to find which rows to flush.
|
// Use a store scanner to find which rows to flush.
|
||||||
|
@ -116,8 +116,7 @@ public class DefaultMobStoreFlusher extends DefaultStoreFlusher {
|
||||||
status.setStatus("Flushing " + store + ": creating writer");
|
status.setStatus("Flushing " + store + ": creating writer");
|
||||||
// Write the map out to the disk
|
// Write the map out to the disk
|
||||||
writer = store.createWriterInTmp(cellsCount, store.getFamily().getCompression(),
|
writer = store.createWriterInTmp(cellsCount, store.getFamily().getCompression(),
|
||||||
false, true, true);
|
false, true, true, false/*default for dropbehind*/, snapshot.getTimeRangeTracker());
|
||||||
writer.setTimeRangeTracker(snapshot.getTimeRangeTracker());
|
|
||||||
try {
|
try {
|
||||||
// It's a mob store, flush the cells in a mob way. This is the difference of flushing
|
// It's a mob store, flush the cells in a mob way. This is the difference of flushing
|
||||||
// between a normal and a mob store.
|
// between a normal and a mob store.
|
||||||
|
|
|
@ -68,8 +68,8 @@ public class DefaultStoreFlusher extends StoreFlusher {
|
||||||
/* isCompaction = */ false,
|
/* isCompaction = */ false,
|
||||||
/* includeMVCCReadpoint = */ true,
|
/* includeMVCCReadpoint = */ true,
|
||||||
/* includesTags = */ snapshot.isTagsPresent(),
|
/* includesTags = */ snapshot.isTagsPresent(),
|
||||||
/* shouldDropBehind = */ false);
|
/* shouldDropBehind = */ false,
|
||||||
writer.setTimeRangeTracker(snapshot.getTimeRangeTracker());
|
snapshot.getTimeRangeTracker());
|
||||||
IOException e = null;
|
IOException e = null;
|
||||||
try {
|
try {
|
||||||
performFlush(scanner, writer, smallestReadPoint, throughputController);
|
performFlush(scanner, writer, smallestReadPoint, throughputController);
|
||||||
|
|
|
@ -957,6 +957,23 @@ public class HStore implements Store {
|
||||||
public StoreFileWriter createWriterInTmp(long maxKeyCount, Compression.Algorithm compression,
|
public StoreFileWriter createWriterInTmp(long maxKeyCount, Compression.Algorithm compression,
|
||||||
boolean isCompaction, boolean includeMVCCReadpoint, boolean includesTag,
|
boolean isCompaction, boolean includeMVCCReadpoint, boolean includesTag,
|
||||||
boolean shouldDropBehind)
|
boolean shouldDropBehind)
|
||||||
|
throws IOException {
|
||||||
|
return createWriterInTmp(maxKeyCount, compression, isCompaction, includeMVCCReadpoint,
|
||||||
|
includesTag, shouldDropBehind, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @param maxKeyCount
|
||||||
|
* @param compression Compression algorithm to use
|
||||||
|
* @param isCompaction whether we are creating a new file in a compaction
|
||||||
|
* @param includesMVCCReadPoint - whether to include MVCC or not
|
||||||
|
* @param includesTag - includesTag or not
|
||||||
|
* @return Writer for a new StoreFile in the tmp dir.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public StoreFileWriter createWriterInTmp(long maxKeyCount, Compression.Algorithm compression,
|
||||||
|
boolean isCompaction, boolean includeMVCCReadpoint, boolean includesTag,
|
||||||
|
boolean shouldDropBehind, final TimeRangeTracker trt)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final CacheConfig writerCacheConf;
|
final CacheConfig writerCacheConf;
|
||||||
if (isCompaction) {
|
if (isCompaction) {
|
||||||
|
@ -973,7 +990,7 @@ public class HStore implements Store {
|
||||||
}
|
}
|
||||||
HFileContext hFileContext = createFileContext(compression, includeMVCCReadpoint, includesTag,
|
HFileContext hFileContext = createFileContext(compression, includeMVCCReadpoint, includesTag,
|
||||||
cryptoContext);
|
cryptoContext);
|
||||||
StoreFileWriter w = new StoreFileWriter.Builder(conf, writerCacheConf,
|
StoreFileWriter.Builder builder = new StoreFileWriter.Builder(conf, writerCacheConf,
|
||||||
this.getFileSystem())
|
this.getFileSystem())
|
||||||
.withFilePath(fs.createTempName())
|
.withFilePath(fs.createTempName())
|
||||||
.withComparator(comparator)
|
.withComparator(comparator)
|
||||||
|
@ -981,9 +998,11 @@ public class HStore implements Store {
|
||||||
.withMaxKeyCount(maxKeyCount)
|
.withMaxKeyCount(maxKeyCount)
|
||||||
.withFavoredNodes(favoredNodes)
|
.withFavoredNodes(favoredNodes)
|
||||||
.withFileContext(hFileContext)
|
.withFileContext(hFileContext)
|
||||||
.withShouldDropCacheBehind(shouldDropBehind)
|
.withShouldDropCacheBehind(shouldDropBehind);
|
||||||
.build();
|
if (trt != null) {
|
||||||
return w;
|
builder.withTimeRangeTracker(trt);
|
||||||
|
}
|
||||||
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private HFileContext createFileContext(Compression.Algorithm compression,
|
private HFileContext createFileContext(Compression.Algorithm compression,
|
||||||
|
|
|
@ -404,7 +404,16 @@ public class ScanQueryMatcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int timestampComparison = tr.compare(timestamp);
|
// NOTE: Cryptic stuff!
|
||||||
|
// if the timestamp is HConstants.OLDEST_TIMESTAMP, then this is a fake cell made to prime a
|
||||||
|
// Scanner; See KeyValueUTil#createLastOnRow. This Cell should never end up returning out of
|
||||||
|
// here a matchcode of INCLUDE else we will return to the client a fake Cell. If we call
|
||||||
|
// TimeRange, it will return 0 because it doesn't deal in OLDEST_TIMESTAMP and we will fall
|
||||||
|
// into the later code where we could return a matchcode of INCLUDE. See HBASE-16074 "ITBLL
|
||||||
|
// fails, reports lost big or tiny families" for a horror story. Check here for
|
||||||
|
// OLDEST_TIMESTAMP. TimeRange#compare is about more generic timestamps, between 0L and
|
||||||
|
// Long.MAX_LONG. It doesn't do OLDEST_TIMESTAMP weird handling.
|
||||||
|
int timestampComparison = timestamp == HConstants.OLDEST_TIMESTAMP? -1: tr.compare(timestamp);
|
||||||
if (timestampComparison >= 1) {
|
if (timestampComparison >= 1) {
|
||||||
return MatchCode.SKIP;
|
return MatchCode.SKIP;
|
||||||
} else if (timestampComparison <= -1) {
|
} else if (timestampComparison <= -1) {
|
||||||
|
|
|
@ -189,8 +189,24 @@ public interface Store extends HeapSize, StoreConfigInformation, PropagatingConf
|
||||||
boolean shouldDropBehind
|
boolean shouldDropBehind
|
||||||
) throws IOException;
|
) throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param maxKeyCount
|
||||||
|
* @param compression Compression algorithm to use
|
||||||
|
* @param isCompaction whether we are creating a new file in a compaction
|
||||||
|
* @param includeMVCCReadpoint whether we should out the MVCC readpoint
|
||||||
|
* @param shouldDropBehind should the writer drop caches behind writes
|
||||||
|
* @param trt Ready-made timetracker to use.
|
||||||
|
* @return Writer for a new StoreFile in the tmp dir.
|
||||||
|
*/
|
||||||
|
StoreFileWriter createWriterInTmp(
|
||||||
|
long maxKeyCount,
|
||||||
|
Compression.Algorithm compression,
|
||||||
|
boolean isCompaction,
|
||||||
|
boolean includeMVCCReadpoint,
|
||||||
|
boolean includesTags,
|
||||||
|
boolean shouldDropBehind,
|
||||||
|
final TimeRangeTracker trt
|
||||||
|
) throws IOException;
|
||||||
|
|
||||||
// Compaction oriented methods
|
// Compaction oriented methods
|
||||||
|
|
||||||
|
|
|
@ -198,7 +198,6 @@ public class StoreFile {
|
||||||
this(fs, new StoreFileInfo(conf, fs, p), conf, cacheConf, cfBloomType);
|
this(fs, new StoreFileInfo(conf, fs, p), conf, cacheConf, cfBloomType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor, loads a reader and it's indices, etc. May allocate a
|
* Constructor, loads a reader and it's indices, etc. May allocate a
|
||||||
* substantial amount of ram depending on the underlying files (10-20MB?).
|
* substantial amount of ram depending on the underlying files (10-20MB?).
|
||||||
|
|
|
@ -639,7 +639,7 @@ public class StoreFileReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getMaxTimestamp() {
|
public long getMaxTimestamp() {
|
||||||
return timeRange == null ? Long.MAX_VALUE : timeRange.getMax();
|
return timeRange == null ? TimeRange.INITIAL_MAX_TIMESTAMP: timeRange.getMax();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isSkipResetSeqId() {
|
boolean isSkipResetSeqId() {
|
||||||
|
|
|
@ -62,7 +62,6 @@ public class StoreFileWriter implements Compactor.CellSink {
|
||||||
private Cell lastDeleteFamilyCell = null;
|
private Cell lastDeleteFamilyCell = null;
|
||||||
private long deleteFamilyCnt = 0;
|
private long deleteFamilyCnt = 0;
|
||||||
|
|
||||||
TimeRangeTracker timeRangeTracker = new TimeRangeTracker();
|
|
||||||
/**
|
/**
|
||||||
* timeRangeTrackerSet is used to figure if we were passed a filled-out TimeRangeTracker or not.
|
* timeRangeTrackerSet is used to figure if we were passed a filled-out TimeRangeTracker or not.
|
||||||
* When flushing a memstore, we set the TimeRangeTracker that it accumulated during updates to
|
* When flushing a memstore, we set the TimeRangeTracker that it accumulated during updates to
|
||||||
|
@ -70,7 +69,8 @@ public class StoreFileWriter implements Compactor.CellSink {
|
||||||
* recalculate the timeRangeTracker bounds; it was done already as part of add-to-memstore.
|
* recalculate the timeRangeTracker bounds; it was done already as part of add-to-memstore.
|
||||||
* A completed TimeRangeTracker is not set in cases of compactions when it is recalculated.
|
* A completed TimeRangeTracker is not set in cases of compactions when it is recalculated.
|
||||||
*/
|
*/
|
||||||
boolean timeRangeTrackerSet = false;
|
private final boolean timeRangeTrackerSet;
|
||||||
|
final TimeRangeTracker timeRangeTracker;
|
||||||
|
|
||||||
protected HFile.Writer writer;
|
protected HFile.Writer writer;
|
||||||
private KeyValue.KeyOnlyKeyValue lastBloomKeyOnlyKV = null;
|
private KeyValue.KeyOnlyKeyValue lastBloomKeyOnlyKV = null;
|
||||||
|
@ -91,6 +91,36 @@ public class StoreFileWriter implements Compactor.CellSink {
|
||||||
final CellComparator comparator, BloomType bloomType, long maxKeys,
|
final CellComparator comparator, BloomType bloomType, long maxKeys,
|
||||||
InetSocketAddress[] favoredNodes, HFileContext fileContext)
|
InetSocketAddress[] favoredNodes, HFileContext fileContext)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
this(fs, path, conf, cacheConf, comparator, bloomType, maxKeys, favoredNodes, fileContext,
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an HFile.Writer that also write helpful meta data.
|
||||||
|
* @param fs file system to write to
|
||||||
|
* @param path file name to create
|
||||||
|
* @param conf user configuration
|
||||||
|
* @param comparator key comparator
|
||||||
|
* @param bloomType bloom filter setting
|
||||||
|
* @param maxKeys the expected maximum number of keys to be added. Was used
|
||||||
|
* for Bloom filter size in {@link HFile} format version 1.
|
||||||
|
* @param favoredNodes
|
||||||
|
* @param fileContext - The HFile context
|
||||||
|
* @param trt Ready-made timetracker to use.
|
||||||
|
* @throws IOException problem writing to FS
|
||||||
|
*/
|
||||||
|
private StoreFileWriter(FileSystem fs, Path path,
|
||||||
|
final Configuration conf,
|
||||||
|
CacheConfig cacheConf,
|
||||||
|
final CellComparator comparator, BloomType bloomType, long maxKeys,
|
||||||
|
InetSocketAddress[] favoredNodes, HFileContext fileContext,
|
||||||
|
final TimeRangeTracker trt)
|
||||||
|
throws IOException {
|
||||||
|
// If passed a TimeRangeTracker, use it. Set timeRangeTrackerSet so we don't destroy it.
|
||||||
|
// TODO: put the state of the TRT on the TRT; i.e. make a read-only version (TimeRange) when
|
||||||
|
// it no longer writable.
|
||||||
|
this.timeRangeTrackerSet = trt != null;
|
||||||
|
this.timeRangeTracker = this.timeRangeTrackerSet? trt: new TimeRangeTracker();
|
||||||
writer = HFile.getWriterFactory(conf, cacheConf)
|
writer = HFile.getWriterFactory(conf, cacheConf)
|
||||||
.withPath(fs, path)
|
.withPath(fs, path)
|
||||||
.withComparator(comparator)
|
.withComparator(comparator)
|
||||||
|
@ -170,19 +200,6 @@ public class StoreFileWriter implements Compactor.CellSink {
|
||||||
appendFileInfo(StoreFile.EARLIEST_PUT_TS, Bytes.toBytes(earliestPutTs));
|
appendFileInfo(StoreFile.EARLIEST_PUT_TS, Bytes.toBytes(earliestPutTs));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set TimeRangeTracker.
|
|
||||||
* Called when flushing to pass us a pre-calculated TimeRangeTracker, one made during updates
|
|
||||||
* to memstore so we don't have to make one ourselves as Cells get appended. Call before first
|
|
||||||
* append. If this method is not called, we will calculate our own range of the Cells that
|
|
||||||
* comprise this StoreFile (and write them on the end as metadata). It is good to have this stuff
|
|
||||||
* passed because it is expensive to make.
|
|
||||||
*/
|
|
||||||
public void setTimeRangeTracker(final TimeRangeTracker trt) {
|
|
||||||
this.timeRangeTracker = trt;
|
|
||||||
timeRangeTrackerSet = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Record the earlest Put timestamp.
|
* Record the earlest Put timestamp.
|
||||||
*
|
*
|
||||||
|
@ -413,6 +430,7 @@ public class StoreFileWriter implements Compactor.CellSink {
|
||||||
private Path filePath;
|
private Path filePath;
|
||||||
private InetSocketAddress[] favoredNodes;
|
private InetSocketAddress[] favoredNodes;
|
||||||
private HFileContext fileContext;
|
private HFileContext fileContext;
|
||||||
|
private TimeRangeTracker trt;
|
||||||
|
|
||||||
public Builder(Configuration conf, CacheConfig cacheConf,
|
public Builder(Configuration conf, CacheConfig cacheConf,
|
||||||
FileSystem fs) {
|
FileSystem fs) {
|
||||||
|
@ -421,6 +439,17 @@ public class StoreFileWriter implements Compactor.CellSink {
|
||||||
this.fs = fs;
|
this.fs = fs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param trt A premade TimeRangeTracker to use rather than build one per append (building one
|
||||||
|
* of these is expensive so good to pass one in if you have one).
|
||||||
|
* @return this (for chained invocation)
|
||||||
|
*/
|
||||||
|
public Builder withTimeRangeTracker(final TimeRangeTracker trt) {
|
||||||
|
Preconditions.checkNotNull(trt);
|
||||||
|
this.trt = trt;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use either this method or {@link #withFilePath}, but not both.
|
* Use either this method or {@link #withFilePath}, but not both.
|
||||||
* @param dir Path to column family directory. The directory is created if
|
* @param dir Path to column family directory. The directory is created if
|
||||||
|
@ -514,7 +543,7 @@ public class StoreFileWriter implements Compactor.CellSink {
|
||||||
comparator = CellComparator.COMPARATOR;
|
comparator = CellComparator.COMPARATOR;
|
||||||
}
|
}
|
||||||
return new StoreFileWriter(fs, filePath,
|
return new StoreFileWriter(fs, filePath,
|
||||||
conf, cacheConf, comparator, bloomType, maxKeyCount, favoredNodes, fileContext);
|
conf, cacheConf, comparator, bloomType, maxKeyCount, favoredNodes, fileContext, trt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -402,8 +402,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
|
||||||
|
|
||||||
// We can only exclude store files based on TTL if minVersions is set to 0.
|
// We can only exclude store files based on TTL if minVersions is set to 0.
|
||||||
// Otherwise, we might have to return KVs that have technically expired.
|
// Otherwise, we might have to return KVs that have technically expired.
|
||||||
long expiredTimestampCutoff = minVersions == 0 ? oldestUnexpiredTS :
|
long expiredTimestampCutoff = minVersions == 0 ? oldestUnexpiredTS: Long.MIN_VALUE;
|
||||||
Long.MIN_VALUE;
|
|
||||||
|
|
||||||
// include only those scan files which pass all filters
|
// include only those scan files which pass all filters
|
||||||
for (KeyValueScanner kvs : allScanners) {
|
for (KeyValueScanner kvs : allScanners) {
|
||||||
|
|
|
@ -114,8 +114,8 @@ public class StripeStoreFlusher extends StoreFlusher {
|
||||||
/* isCompaction = */ false,
|
/* isCompaction = */ false,
|
||||||
/* includeMVCCReadpoint = */ true,
|
/* includeMVCCReadpoint = */ true,
|
||||||
/* includesTags = */ true,
|
/* includesTags = */ true,
|
||||||
/* shouldDropBehind = */ false);
|
/* shouldDropBehind = */ false,
|
||||||
writer.setTimeRangeTracker(tracker);
|
tracker);
|
||||||
return writer;
|
return writer;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.apache.hadoop.hbase.util.Writables;
|
||||||
import org.apache.hadoop.io.Writable;
|
import org.apache.hadoop.io.Writable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores minimum and maximum timestamp values. Both timestamps are inclusive.
|
* Stores minimum and maximum timestamp values.
|
||||||
* Use this class at write-time ONLY. Too much synchronization to use at read time
|
* Use this class at write-time ONLY. Too much synchronization to use at read time
|
||||||
* (TODO: there are two scenarios writing, once when lots of concurrency as part of memstore
|
* (TODO: there are two scenarios writing, once when lots of concurrency as part of memstore
|
||||||
* updates but then later we can make one as part of a compaction when there is only one thread
|
* updates but then later we can make one as part of a compaction when there is only one thread
|
||||||
|
@ -45,8 +45,8 @@ import org.apache.hadoop.io.Writable;
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public class TimeRangeTracker implements Writable {
|
public class TimeRangeTracker implements Writable {
|
||||||
static final long INITIAL_MIN_TIMESTAMP = Long.MAX_VALUE;
|
static final long INITIAL_MIN_TIMESTAMP = Long.MAX_VALUE;
|
||||||
|
static final long INITIAL_MAX_TIMESTAMP = -1L;
|
||||||
long minimumTimestamp = INITIAL_MIN_TIMESTAMP;
|
long minimumTimestamp = INITIAL_MIN_TIMESTAMP;
|
||||||
static final long INITIAL_MAX_TIMESTAMP = -1;
|
|
||||||
long maximumTimestamp = INITIAL_MAX_TIMESTAMP;
|
long maximumTimestamp = INITIAL_MAX_TIMESTAMP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -125,7 +125,7 @@ public class TimeRangeTracker implements Writable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the range has any overlap with TimeRange
|
* Check if the range has ANY overlap with TimeRange
|
||||||
* @param tr TimeRange
|
* @param tr TimeRange
|
||||||
* @return True if there is overlap, false otherwise
|
* @return True if there is overlap, false otherwise
|
||||||
*/
|
*/
|
||||||
|
@ -185,21 +185,18 @@ public class TimeRangeTracker implements Writable {
|
||||||
return trt == null? null: trt.toTimeRange();
|
return trt == null? null: trt.toTimeRange();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isFreshInstance() {
|
|
||||||
return getMin() == INITIAL_MIN_TIMESTAMP && getMax() == INITIAL_MAX_TIMESTAMP;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Make a TimeRange from current state of <code>this</code>.
|
* @return Make a TimeRange from current state of <code>this</code>.
|
||||||
*/
|
*/
|
||||||
TimeRange toTimeRange() {
|
TimeRange toTimeRange() {
|
||||||
long min = getMin();
|
long min = getMin();
|
||||||
long max = getMax();
|
long max = getMax();
|
||||||
// Check for the case where the TimeRangeTracker is fresh. In that case it has
|
// Initial TimeRangeTracker timestamps are the opposite of what you want for a TimeRange. Fix!
|
||||||
// initial values that are antithetical to a TimeRange... Return an uninitialized TimeRange
|
if (min == INITIAL_MIN_TIMESTAMP) {
|
||||||
// if passed an uninitialized TimeRangeTracker.
|
min = TimeRange.INITIAL_MIN_TIMESTAMP;
|
||||||
if (isFreshInstance()) {
|
}
|
||||||
return new TimeRange();
|
if (max == INITIAL_MAX_TIMESTAMP) {
|
||||||
|
max = TimeRange.INITIAL_MAX_TIMESTAMP;
|
||||||
}
|
}
|
||||||
return new TimeRange(min, max);
|
return new TimeRange(min, max);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@ package org.apache.hadoop.hbase.regionserver;
|
||||||
|
|
||||||
import static org.apache.hadoop.hbase.regionserver.ScanQueryMatcher.MatchCode.INCLUDE;
|
import static org.apache.hadoop.hbase.regionserver.ScanQueryMatcher.MatchCode.INCLUDE;
|
||||||
import static org.apache.hadoop.hbase.regionserver.ScanQueryMatcher.MatchCode.SKIP;
|
import static org.apache.hadoop.hbase.regionserver.ScanQueryMatcher.MatchCode.SKIP;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -28,14 +30,17 @@ import java.util.List;
|
||||||
import java.util.NavigableSet;
|
import java.util.NavigableSet;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.CellComparator;
|
import org.apache.hadoop.hbase.CellComparator;
|
||||||
import org.apache.hadoop.hbase.HBaseTestCase;
|
import org.apache.hadoop.hbase.CellUtil;
|
||||||
|
import org.apache.hadoop.hbase.HBaseConfiguration;
|
||||||
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
import org.apache.hadoop.hbase.Cell;
|
||||||
import org.apache.hadoop.hbase.HConstants;
|
import org.apache.hadoop.hbase.HConstants;
|
||||||
import org.apache.hadoop.hbase.KeepDeletedCells;
|
import org.apache.hadoop.hbase.KeepDeletedCells;
|
||||||
import org.apache.hadoop.hbase.KeyValue;
|
import org.apache.hadoop.hbase.KeyValue;
|
||||||
import org.apache.hadoop.hbase.KeyValueUtil;
|
import org.apache.hadoop.hbase.KeyValueUtil;
|
||||||
import org.apache.hadoop.hbase.KeyValue.Type;
|
import org.apache.hadoop.hbase.KeyValue.Type;
|
||||||
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
|
|
||||||
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
||||||
|
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
|
||||||
import org.apache.hadoop.hbase.client.Get;
|
import org.apache.hadoop.hbase.client.Get;
|
||||||
import org.apache.hadoop.hbase.client.Scan;
|
import org.apache.hadoop.hbase.client.Scan;
|
||||||
import org.apache.hadoop.hbase.regionserver.ScanQueryMatcher.MatchCode;
|
import org.apache.hadoop.hbase.regionserver.ScanQueryMatcher.MatchCode;
|
||||||
|
@ -46,8 +51,9 @@ import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
|
|
||||||
@Category({RegionServerTests.class, SmallTests.class})
|
@Category({RegionServerTests.class, SmallTests.class})
|
||||||
public class TestQueryMatcher extends HBaseTestCase {
|
public class TestQueryMatcher {
|
||||||
private static final boolean PRINT = false;
|
private static final boolean PRINT = false;
|
||||||
|
private Configuration conf;
|
||||||
|
|
||||||
private byte[] row1;
|
private byte[] row1;
|
||||||
private byte[] row2;
|
private byte[] row2;
|
||||||
|
@ -70,7 +76,7 @@ public class TestQueryMatcher extends HBaseTestCase {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
this.conf = HBaseConfiguration.create();
|
||||||
row1 = Bytes.toBytes("row1");
|
row1 = Bytes.toBytes("row1");
|
||||||
row2 = Bytes.toBytes("row2");
|
row2 = Bytes.toBytes("row2");
|
||||||
row3 = Bytes.toBytes("row3");
|
row3 = Bytes.toBytes("row3");
|
||||||
|
@ -130,6 +136,25 @@ public class TestQueryMatcher extends HBaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a cryptic test. It is checking that we don't include a fake cell, one that has a
|
||||||
|
* timestamp of {@link HConstants#OLDEST_TIMESTAMP}. See HBASE-16074 for background.
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testNeverIncludeFakeCell() throws IOException {
|
||||||
|
long now = EnvironmentEdgeManager.currentTime();
|
||||||
|
// Do with fam2 which has a col2 qualifier.
|
||||||
|
ScanQueryMatcher qm = new ScanQueryMatcher(scan,
|
||||||
|
new ScanInfo(this.conf, fam2, 10, 1, ttl, KeepDeletedCells.FALSE, 0, rowComparator),
|
||||||
|
get.getFamilyMap().get(fam2), now - ttl, now);
|
||||||
|
Cell kv = new KeyValue(row1, fam2, col2, 1, data);
|
||||||
|
Cell cell = CellUtil.createLastOnRowCol(kv);
|
||||||
|
qm.setToNewRow(kv);
|
||||||
|
MatchCode code = qm.match(cell);
|
||||||
|
assertFalse(code.compareTo(MatchCode.SEEK_NEXT_COL) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMatch_ExplicitColumns()
|
public void testMatch_ExplicitColumns()
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
@ -251,7 +276,6 @@ public class TestQueryMatcher extends HBaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify that {@link ScanQueryMatcher} only skips expired KeyValue
|
* Verify that {@link ScanQueryMatcher} only skips expired KeyValue
|
||||||
* instances and does not exit early from the row (skipping
|
* instances and does not exit early from the row (skipping
|
||||||
|
@ -356,4 +380,3 @@ public class TestQueryMatcher extends HBaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,11 @@ package org.apache.hadoop.hbase.regionserver;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.io.TimeRange;
|
import org.apache.hadoop.hbase.io.TimeRange;
|
||||||
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
||||||
|
import org.apache.hadoop.hbase.util.Writables;
|
||||||
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
|
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
|
@ -31,6 +33,42 @@ import java.io.IOException;
|
||||||
|
|
||||||
@Category({RegionServerTests.class, SmallTests.class})
|
@Category({RegionServerTests.class, SmallTests.class})
|
||||||
public class TestTimeRangeTracker {
|
public class TestTimeRangeTracker {
|
||||||
|
@Test
|
||||||
|
public void testExtreme() {
|
||||||
|
TimeRange tr = new TimeRange();
|
||||||
|
assertTrue(tr.includesTimeRange(new TimeRange()));
|
||||||
|
TimeRangeTracker trt = new TimeRangeTracker();
|
||||||
|
assertFalse(trt.includesTimeRange(new TimeRange()));
|
||||||
|
trt.includeTimestamp(1);
|
||||||
|
trt.includeTimestamp(10);
|
||||||
|
assertTrue(trt.includesTimeRange(new TimeRange()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTimeRangeInitialized() {
|
||||||
|
TimeRangeTracker src = new TimeRangeTracker();
|
||||||
|
TimeRange tr = new TimeRange(System.currentTimeMillis());
|
||||||
|
assertFalse(src.includesTimeRange(tr));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTimeRangeTrackerNullIsSameAsTimeRangeNull() throws IOException {
|
||||||
|
TimeRangeTracker src = new TimeRangeTracker(1, 2);
|
||||||
|
byte [] bytes = Writables.getBytes(src);
|
||||||
|
TimeRange tgt = TimeRangeTracker.getTimeRange(bytes);
|
||||||
|
assertEquals(src.getMin(), tgt.getMin());
|
||||||
|
assertEquals(src.getMax(), tgt.getMax());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSerialization() throws IOException {
|
||||||
|
TimeRangeTracker src = new TimeRangeTracker(1, 2);
|
||||||
|
TimeRangeTracker tgt = new TimeRangeTracker();
|
||||||
|
Writables.copyWritable(src, tgt);
|
||||||
|
assertEquals(src.getMin(), tgt.getMin());
|
||||||
|
assertEquals(src.getMax(), tgt.getMax());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAlwaysDecrementingSetsMaximum() {
|
public void testAlwaysDecrementingSetsMaximum() {
|
||||||
TimeRangeTracker trr = new TimeRangeTracker();
|
TimeRangeTracker trr = new TimeRangeTracker();
|
||||||
|
|
Loading…
Reference in New Issue