You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2022/08/21 13:40:29 UTC
[hbase] branch branch-2 updated: HBASE-27206 Clean up error-prone findings in hbase-common (#4645)
This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2 by this push:
new f705e3e7d8a HBASE-27206 Clean up error-prone findings in hbase-common (#4645)
f705e3e7d8a is described below
commit f705e3e7d8a50cc757fdc8706dade93b4d3f1dd9
Author: Andrew Purtell <ap...@apache.org>
AuthorDate: Sun Aug 21 06:04:46 2022 -0700
HBASE-27206 Clean up error-prone findings in hbase-common (#4645)
Signed-off-by: Nick Dimiduk <nd...@apache.org>
Signed-off-by: Duo Zhang <zh...@apache.org>
(cherry picked from commit fbe3b90e0c4eef1dc13fb2a5ed9381106ca671dd)
Conflicts:
hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java
hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java
hbase-common/src/main/java/org/apache/hadoop/hbase/ServerName.java
hbase-common/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfo.java
hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestKeyStoreKeyProvider.java
hbase-common/src/test/java/org/apache/hadoop/hbase/types/TestOrderedFloat32.java
---
.../apache/hadoop/hbase/ByteBufferKeyValue.java | 2 +-
.../main/java/org/apache/hadoop/hbase/Cell.java | 8 +-
.../org/apache/hadoop/hbase/CellComparator.java | 16 +--
.../apache/hadoop/hbase/CellComparatorImpl.java | 5 +-
.../java/org/apache/hadoop/hbase/CellUtil.java | 159 +++++++++++----------
.../java/org/apache/hadoop/hbase/ChoreService.java | 22 ++-
.../apache/hadoop/hbase/HBaseConfiguration.java | 1 +
.../hadoop/hbase/IndividualBytesFieldCell.java | 4 +-
.../java/org/apache/hadoop/hbase/KeyValue.java | 36 ++---
.../java/org/apache/hadoop/hbase/KeyValueUtil.java | 29 ++--
.../org/apache/hadoop/hbase/PrivateCellUtil.java | 40 +++---
.../org/apache/hadoop/hbase/ScheduledChore.java | 21 ++-
.../java/org/apache/hadoop/hbase/ServerName.java | 79 +++++-----
.../java/org/apache/hadoop/hbase/TableName.java | 19 ++-
.../src/main/java/org/apache/hadoop/hbase/Tag.java | 10 +-
.../main/java/org/apache/hadoop/hbase/TagUtil.java | 8 +-
.../hadoop/hbase/filter/ByteArrayComparable.java | 15 +-
.../java/org/apache/hadoop/hbase/io/HeapSize.java | 4 +-
.../hadoop/hbase/io/ImmutableBytesWritable.java | 32 +----
.../hadoop/hbase/io/TagCompressionContext.java | 3 +-
.../hbase/io/compress/ReusableStreamGzipCodec.java | 2 +-
.../io/encoding/BufferedDataBlockEncoder.java | 33 +++--
.../hbase/io/encoding/DataBlockEncoding.java | 9 +-
.../hbase/io/encoding/DiffKeyDeltaEncoder.java | 2 +-
.../hadoop/hbase/io/encoding/EncodedDataBlock.java | 7 +-
.../io/encoding/HFileBlockEncodingContext.java | 9 +-
.../hadoop/hbase/io/encoding/RowIndexSeekerV1.java | 3 +-
.../apache/hadoop/hbase/io/hfile/BlockType.java | 3 +
.../apache/hadoop/hbase/io/hfile/HFileContext.java | 12 +-
.../hadoop/hbase/io/hfile/HFileContextBuilder.java | 14 +-
.../java/org/apache/hadoop/hbase/net/Address.java | 14 +-
.../java/org/apache/hadoop/hbase/nio/ByteBuff.java | 113 +++++----------
.../org/apache/hadoop/hbase/nio/MultiByteBuff.java | 19 +--
.../apache/hadoop/hbase/rsgroup/RSGroupInfo.java | 43 ++----
.../apache/hadoop/hbase/security/Superusers.java | 2 +
.../org/apache/hadoop/hbase/security/User.java | 19 ++-
.../apache/hadoop/hbase/security/UserProvider.java | 10 +-
.../hadoop/hbase/types/CopyOnWriteArrayMap.java | 1 +
.../org/apache/hadoop/hbase/util/Addressing.java | 8 +-
.../java/org/apache/hadoop/hbase/util/AvlUtil.java | 17 ++-
.../apache/hadoop/hbase/util/ByteBufferArray.java | 2 +
.../java/org/apache/hadoop/hbase/util/Bytes.java | 112 ++++++++-------
.../org/apache/hadoop/hbase/util/ClassSize.java | 4 +-
.../apache/hadoop/hbase/util/CommonFSUtils.java | 10 +-
.../java/org/apache/hadoop/hbase/util/DNS.java | 5 +-
.../apache/hadoop/hbase/util/ExceptionUtil.java | 4 +-
.../hbase/util/ExponentialMovingAverage.java | 2 +-
.../java/org/apache/hadoop/hbase/util/Hash.java | 1 -
.../java/org/apache/hadoop/hbase/util/HashKey.java | 5 +-
.../org/apache/hadoop/hbase/util/JRubyFormat.java | 8 +-
.../java/org/apache/hadoop/hbase/util/JVM.java | 15 +-
.../java/org/apache/hadoop/hbase/util/MD5Hash.java | 3 -
.../org/apache/hadoop/hbase/util/OrderedBytes.java | 16 +--
.../java/org/apache/hadoop/hbase/util/Pair.java | 12 +-
.../apache/hadoop/hbase/util/PairOfSameType.java | 1 -
.../apache/hadoop/hbase/util/ReflectionUtils.java | 6 +-
.../hadoop/hbase/util/SimpleMovingAverage.java | 4 +-
.../java/org/apache/hadoop/hbase/util/Threads.java | 4 +-
.../java/org/apache/hadoop/hbase/util/Triple.java | 6 +-
.../org/apache/hadoop/hbase/util/VersionInfo.java | 10 +-
.../hadoop/hbase/util/WeightedMovingAverage.java | 6 +-
.../hadoop/hbase/util/WindowMovingAverage.java | 10 +-
.../apache/hadoop/hbase/zookeeper/ZKConfig.java | 20 +--
.../hadoop/hbase/TestByteBufferKeyValue.java | 36 +++--
.../apache/hadoop/hbase/TestCellComparator.java | 55 +++----
.../java/org/apache/hadoop/hbase/TestCellUtil.java | 7 +-
.../org/apache/hadoop/hbase/TestClassFinder.java | 1 +
.../hadoop/hbase/TestHBaseClassTestRule.java | 1 +
.../hadoop/hbase/TestHBaseConfiguration.java | 3 -
.../hadoop/hbase/TestIndividualBytesFieldCell.java | 5 +-
.../java/org/apache/hadoop/hbase/TestKeyValue.java | 10 +-
.../org/apache/hadoop/hbase/TestServerName.java | 4 +-
.../org/apache/hadoop/hbase/TestTableName.java | 4 +-
.../java/org/apache/hadoop/hbase/TestTimeout.java | 1 +
.../apache/hadoop/hbase/TimedOutTestsListener.java | 5 +-
.../hbase/io/crypto/TestKeyStoreKeyProvider.java | 3 -
.../apache/hadoop/hbase/io/crypto/aes/TestAES.java | 10 +-
.../hadoop/hbase/io/crypto/aes/TestCommonsAES.java | 10 +-
.../hadoop/hbase/io/util/TestLRUDictionary.java | 4 +-
.../org/apache/hadoop/hbase/types/TestStruct.java | 10 +-
.../org/apache/hadoop/hbase/types/TestUnion2.java | 15 +-
.../hadoop/hbase/util/ClassLoaderTestHelper.java | 2 -
.../hadoop/hbase/util/RedundantKVGenerator.java | 4 +-
.../hadoop/hbase/util/SimpleKdcServerUtil.java | 2 +-
.../org/apache/hadoop/hbase/util/TestAvlUtil.java | 3 +-
.../hadoop/hbase/util/TestByteBufferArray.java | 18 ++-
.../hadoop/hbase/util/TestByteBufferUtils.java | 20 +--
.../org/apache/hadoop/hbase/util/TestBytes.java | 4 -
.../hadoop/hbase/util/TestCommonFSUtils.java | 8 --
.../hadoop/hbase/util/TestConcatenatedLists.java | 2 +-
.../org/apache/hadoop/hbase/util/TestGsonUtil.java | 4 +
.../hbase/util/TestSimpleMutableByteRange.java | 2 +-
.../hadoop/hbase/HDFSBlocksDistribution.java | 30 ++--
93 files changed, 647 insertions(+), 755 deletions(-)
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyValue.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyValue.java
index 9c668c1cc3f..f01e01ff905 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyValue.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyValue.java
@@ -264,7 +264,7 @@ public class ByteBufferKeyValue extends ByteBufferExtendedCell {
if (this.buf.hasArray()) {
return ClassSize.align(FIXED_OVERHEAD + length);
}
- return ClassSize.align(FIXED_OVERHEAD) + this.getSerializedSize();
+ return (long) ClassSize.align(FIXED_OVERHEAD) + this.getSerializedSize();
}
@Override
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java
index 4fb254b35b4..027451956ee 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java
@@ -106,15 +106,15 @@ public interface Cell extends HeapSize {
// 4) Timestamp
/**
- * @return Long value representing time at which this cell was "Put" into the row. Typically
- * represents the time of insertion, but can be any value from 0 to Long.MAX_VALUE.
+ * Return a long value representing time at which this cell was "Put" into the row. Typically
+ * represents the time of insertion, but can be any value from 0 to Long.MAX_VALUE.
*/
long getTimestamp();
// 5) Type
/**
- * @return The byte representation of the KeyValue.TYPE of this cell: one of Put, Delete, etc
+ * Return the byte representation of the KeyValue.TYPE of this cell: one of Put, Delete, etc
* @deprecated As of HBase-2.0. Will be removed in HBase-3.0. Use {@link #getType()}.
*/
@Deprecated
@@ -160,7 +160,7 @@ public interface Cell extends HeapSize {
byte[] getTagsArray();
/**
- * @return the first offset where the tags start in the Cell
+ * Return the first offset where the tags start in the Cell
* @deprecated As of HBase-2.0. Will be removed in HBase-3.0. Tags are are now internal.
*/
@Deprecated
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java
index 301223ad294..8ff86d575de 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java
@@ -95,6 +95,7 @@ public interface CellComparator extends Comparator<Cell>, Serializable {
}
/**
+ * Lexicographically compare two rows
* @param row ByteBuffer that wraps a row; will read from current position and will reading all
* remaining; will not disturb the ByteBuffer internal state.
* @return greater than 0 if leftCell is bigger, less than 0 if rightCell is bigger, 0 if both
@@ -111,7 +112,7 @@ public interface CellComparator extends Comparator<Cell>, Serializable {
}
/**
- * Lexographically compares the two cells excluding the row part. It compares family, qualifier,
+ * Lexicographically compares the two cells excluding the row part. It compares family, qualifier,
* timestamp and the type
* @param leftCell the left hand side cell
* @param rightCell the right hand side cell
@@ -121,7 +122,7 @@ public interface CellComparator extends Comparator<Cell>, Serializable {
int compareWithoutRow(Cell leftCell, Cell rightCell);
/**
- * Lexographically compares the families of the two cells
+ * Lexicographically compares the families of the two cells
* @param leftCell the left hand side cell
* @param rightCell the right hand side cell
* @return greater than 0 if leftCell is bigger, less than 0 if rightCell is bigger, 0 if both
@@ -130,7 +131,7 @@ public interface CellComparator extends Comparator<Cell>, Serializable {
int compareFamilies(Cell leftCell, Cell rightCell);
/**
- * Lexographically compares the qualifiers of the two cells
+ * Lexicographically compares the qualifiers of the two cells
* @param leftCell the left hand side cell
* @param rightCell the right hand side cell
* @return greater than 0 if leftCell is bigger, less than 0 if rightCell is bigger, 0 if both
@@ -163,10 +164,9 @@ public interface CellComparator extends Comparator<Cell>, Serializable {
int compareTimestamps(long leftCellts, long rightCellts);
/**
- * @return A dumbed-down, fast comparator for hbase2 base-type, the {@link ByteBufferKeyValue}.
- * Create an instance when you make a new memstore, when you know only BBKVs will be
- * passed. Do not pollute with types other than BBKV if can be helped; the Comparator will
- * slow.
+ * Return a dumbed-down, fast comparator for hbase2 base-type, the {@link ByteBufferKeyValue}.
+ * Create an instance when you make a new memstore, when you know only BBKVs will be passed. Do
+ * not pollute with types other than BBKV if can be helped; the Comparator will slow.
*/
- Comparator getSimpleComparator();
+ Comparator<Cell> getSimpleComparator();
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparatorImpl.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparatorImpl.java
index 5992b8b404b..b90eab3a4c2 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparatorImpl.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparatorImpl.java
@@ -18,7 +18,6 @@
package org.apache.hadoop.hbase;
import java.util.Comparator;
-import org.apache.hadoop.hbase.KeyValue.Type;
import org.apache.hadoop.hbase.util.ByteBufferUtils;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.yetus.audience.InterfaceAudience;
@@ -692,11 +691,11 @@ public class CellComparatorImpl implements CellComparator {
int rFamLength = right.getFamilyLength();
int lQualLength = left.getQualifierLength();
int rQualLength = right.getQualifierLength();
- if (lFamLength + lQualLength == 0 && left.getTypeByte() == Type.Minimum.getCode()) {
+ if (lFamLength + lQualLength == 0 && left.getTypeByte() == KeyValue.Type.Minimum.getCode()) {
// left is "bigger", i.e. it appears later in the sorted order
return 1;
}
- if (rFamLength + rQualLength == 0 && right.getTypeByte() == Type.Minimum.getCode()) {
+ if (rFamLength + rQualLength == 0 && right.getTypeByte() == KeyValue.Type.Minimum.getCode()) {
return -1;
}
if (lFamLength != rFamLength) {
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java
index 604aa1dff0d..b518b0e3aa2 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java
@@ -34,7 +34,6 @@ import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.Optional;
import java.util.function.Function;
-import org.apache.hadoop.hbase.KeyValue.Type;
import org.apache.hadoop.hbase.io.HeapSize;
import org.apache.hadoop.hbase.util.ByteBufferUtils;
import org.apache.hadoop.hbase.util.ByteRange;
@@ -138,7 +137,8 @@ public final class CellUtil {
/**
* Returns tag value in a new byte array. If server-side, use {@link Tag#getValueArray()} with
* appropriate {@link Tag#getValueOffset()} and {@link Tag#getValueLength()} instead to save on
- * allocations. n * @return tag value in a new byte array.
+ * allocations.
+ * @return tag value in a new byte array.
* @deprecated As of HBase-2.0. Will be removed in HBase-3.0
*/
@Deprecated
@@ -151,7 +151,8 @@ public final class CellUtil {
/**
* Makes a column in family:qualifier form from separate byte arrays.
* <p>
- * Not recommended for usage as this is old-style API. nn * @return family:qualifier
+ * Not recommended for usage as this is old-style API.
+ * @return family:qualifier
*/
public static byte[] makeColumn(byte[] family, byte[] qualifier) {
return Bytes.add(family, COLUMN_FAMILY_DELIM_ARRAY, qualifier);
@@ -367,7 +368,8 @@ public final class CellUtil {
}
/**
- * Copies the tags info into the tag portion of the cell nnn * @return position after tags
+ * Copies the tags info into the tag portion of the cell
+ * @return position after tags
* @deprecated As of HBase-2.0. Will be removed in HBase-3.0.
*/
@Deprecated
@@ -385,7 +387,8 @@ public final class CellUtil {
}
/**
- * Copies the tags info into the tag portion of the cell nnn * @return position after tags
+ * Copies the tags info into the tag portion of the cell
+ * @return position after tags
* @deprecated As of HBase-2.0. Will be removed in 3.0.
*/
@Deprecated
@@ -427,7 +430,7 @@ public final class CellUtil {
}
/**
- * n * @return cell's qualifier wrapped into a ByteBuffer.
+ * Return cell's qualifier wrapped into a ByteBuffer.
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
*/
@Deprecated
@@ -439,6 +442,7 @@ public final class CellUtil {
}
/**
+ * Create a cell
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. Use {@link CellBuilder}
* instead
*/
@@ -504,13 +508,13 @@ public final class CellUtil {
@InterfaceAudience.Private
@Deprecated
public static Cell createCell(final byte[] row, final byte[] family, final byte[] qualifier,
- final long timestamp, Type type, final byte[] value, byte[] tags) {
+ final long timestamp, KeyValue.Type type, final byte[] value, byte[] tags) {
return createCell(row, family, qualifier, timestamp, type.getCode(), value, tags, 0);
}
/**
- * Create a Cell with specific row. Other fields defaulted. n * @return Cell with passed row but
- * all other fields are arbitrary
+ * Create a Cell with specific row. Other fields defaulted.
+ * @return Cell with passed row but all other fields are arbitrary
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. Use {@link CellBuilder}
* instead
*/
@@ -520,8 +524,8 @@ public final class CellUtil {
}
/**
- * Create a Cell with specific row and value. Other fields are defaulted. nn * @return Cell with
- * passed row and value but all other fields are arbitrary
+ * Create a Cell with specific row and value. Other fields are defaulted.
+ * @return Cell with passed row and value but all other fields are arbitrary
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. Use {@link CellBuilder}
* instead
*/
@@ -536,8 +540,8 @@ public final class CellUtil {
}
/**
- * Create a Cell with specific row. Other fields defaulted. nnn * @return Cell with passed row but
- * all other fields are arbitrary
+ * Create a Cell with specific row. Other fields defaulted.
+ * @return Cell with passed row but all other fields are arbitrary
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. Use {@link CellBuilder}
* instead
*/
@@ -581,7 +585,7 @@ public final class CellUtil {
}
/**
- * n * @return CellScanner interface over <code>cellIterables</code>
+ * Return CellScanner interface over <code>cellIterables</code>
*/
public static CellScanner
createCellScanner(final List<? extends CellScannable> cellScannerables) {
@@ -609,7 +613,7 @@ public final class CellUtil {
}
/**
- * n * @return CellScanner interface over <code>cellIterable</code>
+ * Return CellScanner interface over <code>cellIterable</code>
*/
public static CellScanner createCellScanner(final Iterable<Cell> cellIterable) {
if (cellIterable == null) return null;
@@ -617,8 +621,8 @@ public final class CellUtil {
}
/**
- * n * @return CellScanner interface over <code>cellIterable</code> or null if <code>cells</code>
- * is null
+ * Return CellScanner interface over <code>cellIterable</code> or null if <code>cells</code> is
+ * null
*/
public static CellScanner createCellScanner(final Iterator<Cell> cells) {
if (cells == null) return null;
@@ -641,7 +645,7 @@ public final class CellUtil {
}
/**
- * n * @return CellScanner interface over <code>cellArray</code>
+ * Return CellScanner interface over <code>cellArray</code>
*/
public static CellScanner createCellScanner(final Cell[] cellArray) {
return new CellScanner() {
@@ -698,7 +702,7 @@ public final class CellUtil {
}
/**
- * nn * @return True if the rows in <code>left</code> and <code>right</code> Cells match
+ * Return true if the rows in <code>left</code> and <code>right</code> Cells match
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. Instead use
* {@link #matchingRows(Cell, Cell)}
*/
@@ -708,6 +712,7 @@ public final class CellUtil {
}
/**
+ * Return true if the row is matching
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. Instead use
* {@link #matchingRows(Cell, byte[])}
*/
@@ -724,9 +729,9 @@ public final class CellUtil {
}
/**
+ * Return true if the row is matching
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. Instead use
* {@link #matchingRows(Cell, Cell)}
- * @return true if the row is matching
*/
@Deprecated
public static boolean matchingRow(final Cell left, final byte[] buf, final int offset,
@@ -775,6 +780,7 @@ public final class CellUtil {
}
/**
+ * Return true if the family is matching
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
*/
@Deprecated
@@ -818,8 +824,7 @@ public final class CellUtil {
}
/**
- * Finds if the qualifier part of the cell and the KV serialized byte[] are equal n * @param buf
- * the serialized keyvalue format byte[]
+ * Finds if the qualifier part of the cell and the KV serialized byte[] are equal.
* @return true if the qualifier matches, false otherwise
*/
public static boolean matchingQualifier(final Cell left, final byte[] buf) {
@@ -830,8 +835,8 @@ public final class CellUtil {
}
/**
- * Finds if the qualifier part of the cell and the KV serialized byte[] are equal n * @param buf
- * the serialized keyvalue format byte[]
+ * Finds if the qualifier part of the cell and the KV serialized byte[] are equal
+ * @param buf the serialized keyvalue format byte[]
* @param offset the offset of the qualifier in the byte[]
* @param length the length of the qualifier in the byte[]
* @return true if the qualifier matches, false otherwise
@@ -863,6 +868,7 @@ public final class CellUtil {
}
/**
+ * Return true if the column is matching
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
*/
@Deprecated
@@ -905,8 +911,8 @@ public final class CellUtil {
}
/**
- * @return True if a delete type, a {@link KeyValue.Type#Delete} or a {KeyValue.Type#DeleteFamily}
- * or a {@link KeyValue.Type#DeleteColumn} KeyValue type.
+ * Return true if a delete type, a {@link KeyValue.Type#Delete} or a {KeyValue.Type#DeleteFamily}
+ * or a {@link KeyValue.Type#DeleteColumn} KeyValue type.
*/
@SuppressWarnings("deprecation")
public static boolean isDelete(final Cell cell) {
@@ -914,77 +920,82 @@ public final class CellUtil {
}
/**
- * @return True if a delete type, a {@link KeyValue.Type#Delete} or a {KeyValue.Type#DeleteFamily}
- * or a {@link KeyValue.Type#DeleteColumn} KeyValue type.
+ * Return true if a delete type, a {@link KeyValue.Type#Delete} or a {KeyValue.Type#DeleteFamily}
+ * or a {@link KeyValue.Type#DeleteColumn} KeyValue type.
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
*/
@Deprecated
public static boolean isDelete(final byte type) {
- return Type.Delete.getCode() <= type && type <= Type.DeleteFamily.getCode();
+ return KeyValue.Type.Delete.getCode() <= type && type <= KeyValue.Type.DeleteFamily.getCode();
}
/**
- * @return True if this cell is a {@link KeyValue.Type#Delete} type.
+ * Return true if this cell is a {@link KeyValue.Type#Delete} type.
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
*/
@Deprecated
public static boolean isDeleteType(Cell cell) {
- return cell.getTypeByte() == Type.Delete.getCode();
+ return cell.getTypeByte() == KeyValue.Type.Delete.getCode();
}
/**
+ * Check whether the given cell is a delete family
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
*/
@Deprecated
public static boolean isDeleteFamily(final Cell cell) {
- return cell.getTypeByte() == Type.DeleteFamily.getCode();
+ return cell.getTypeByte() == KeyValue.Type.DeleteFamily.getCode();
}
/**
+ * Check whether the given cell is a delete family version
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
*/
@Deprecated
public static boolean isDeleteFamilyVersion(final Cell cell) {
- return cell.getTypeByte() == Type.DeleteFamilyVersion.getCode();
+ return cell.getTypeByte() == KeyValue.Type.DeleteFamilyVersion.getCode();
}
/**
+ * Check whether the given cell is a delete columns
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
*/
@Deprecated
public static boolean isDeleteColumns(final Cell cell) {
- return cell.getTypeByte() == Type.DeleteColumn.getCode();
+ return cell.getTypeByte() == KeyValue.Type.DeleteColumn.getCode();
}
/**
+ * Check whether the given cell is a delete column version
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
*/
@Deprecated
public static boolean isDeleteColumnVersion(final Cell cell) {
- return cell.getTypeByte() == Type.Delete.getCode();
+ return cell.getTypeByte() == KeyValue.Type.Delete.getCode();
}
/**
- * @return True if this cell is a delete family or column type.
+ * Return true if this cell is a delete family or column type.
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
*/
@Deprecated
public static boolean isDeleteColumnOrFamily(Cell cell) {
int t = cell.getTypeByte();
- return t == Type.DeleteColumn.getCode() || t == Type.DeleteFamily.getCode();
+ return t == KeyValue.Type.DeleteColumn.getCode() || t == KeyValue.Type.DeleteFamily.getCode();
}
/** Returns True if this cell is a Put. */
@SuppressWarnings("deprecation")
public static boolean isPut(Cell cell) {
- return cell.getTypeByte() == Type.Put.getCode();
+ return cell.getTypeByte() == KeyValue.Type.Put.getCode();
}
/**
* Estimate based on keyvalue's serialization format in the RPC layer. Note that there is an extra
* SIZEOF_INT added to the size here that indicates the actual length of the cell for cases where
- * cell's are serialized in a contiguous format (For eg in RPCs). n * @return Estimate of the
- * <code>cell</code> size in bytes plus an extra SIZEOF_INT indicating the actual cell length.
+ * cell's are serialized in a contiguous format (For eg in RPCs).
+ * @return Estimate of the <code>cell</code> size in bytes plus an extra SIZEOF_INT indicating the
+ * actual cell length.
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
*/
@Deprecated
@@ -1002,16 +1013,14 @@ public final class CellUtil {
}
/**
- * n * @return Sum of the lengths of all the elements in a Cell; does not count in any
- * infrastructure
+ * Return sum of the lengths of all the elements in a Cell; does not count in any infrastructure
*/
private static int getSumOfCellElementLengths(final Cell cell) {
return getSumOfCellKeyElementLengths(cell) + cell.getValueLength() + cell.getTagsLength();
}
/**
- * n * @return Sum of all elements that make up a key; does not include infrastructure, tags or
- * values.
+ * Return sum of all elements that make up a key; does not include infrastructure, tags or values.
*/
private static int getSumOfCellKeyElementLengths(final Cell cell) {
return cell.getRowLength() + cell.getFamilyLength() + cell.getQualifierLength()
@@ -1035,7 +1044,8 @@ public final class CellUtil {
* This is an estimate of the heap space occupied by a cell. When the cell is of type
* {@link HeapSize} we call {@link HeapSize#heapSize()} so cell can give a correct value. In other
* cases we just consider the bytes occupied by the cell components ie. row, CF, qualifier,
- * timestamp, type, value and tags. n * @return estimate of the heap space
+ * timestamp, type, value and tags.
+ * @return estimate of the heap space
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. Use
* {@link RawCell#getTags()}
*/
@@ -1046,7 +1056,8 @@ public final class CellUtil {
/********************* tags *************************************/
/**
- * Util method to iterate through the tags nnn * @return iterator for the tags
+ * Util method to iterate through the tags
+ * @return iterator for the tags
* @deprecated As of 2.0.0 and will be removed in 3.0.0 Instead use
* {@link PrivateCellUtil#tagsIterator(Cell)}
*/
@@ -1080,8 +1091,7 @@ public final class CellUtil {
}
/**
- * @param cell The Cell
- * @return Tags in the given Cell as a List
+ * Return tags in the given Cell as a List
* @deprecated As of 2.0.0 and will be removed in 3.0.0
*/
@Deprecated
@@ -1125,8 +1135,8 @@ public final class CellUtil {
/**
* Sets the given seqId to the cell. Marked as audience Private as of 1.2.0. Setting a Cell
- * sequenceid is an internal implementation detail not for general public use. nn * @throws
- * IOException when the passed cell is not of type {@link ExtendedCell}
+ * sequenceid is an internal implementation detail not for general public use.
+ * @throws IOException when the passed cell is not of type {@link ExtendedCell}
* @deprecated As of HBase-2.0. Will be removed in HBase-3.0
*/
@Deprecated
@@ -1135,8 +1145,9 @@ public final class CellUtil {
}
/**
- * Sets the given timestamp to the cell. nn * @throws IOException when the passed cell is not of
- * type {@link ExtendedCell}
+ * Sets the given timestamp to the cell. Note that this method is a LimitedPrivate API and may
+ * change between minor releases.
+ * @throws IOException when the passed cell is not of type {@link ExtendedCell}
* @deprecated As of HBase-2.0. Will be a LimitedPrivate API in HBase-3.0.
*/
@Deprecated
@@ -1145,8 +1156,8 @@ public final class CellUtil {
}
/**
- * Sets the given timestamp to the cell. n * @param ts buffer containing the timestamp value
- * @param tsOffset offset to the new timestamp
+ * Sets the given timestamp to the cell. Note that this method is a LimitedPrivate API and may
+ * change between minor releases.
* @throws IOException when the passed cell is not of type {@link ExtendedCell}
* @deprecated As of HBase-2.0. Will be a LimitedPrivate API in HBase-3.0.
*/
@@ -1157,7 +1168,8 @@ public final class CellUtil {
/**
* Sets the given timestamp to the cell iff current timestamp is
- * {@link HConstants#LATEST_TIMESTAMP}. nn * @return True if cell timestamp is modified.
+ * {@link HConstants#LATEST_TIMESTAMP}.
+ * @return True if cell timestamp is modified.
* @throws IOException when the passed cell is not of type {@link ExtendedCell}
* @deprecated As of HBase-2.0. Will be removed in HBase-3.0
*/
@@ -1168,7 +1180,8 @@ public final class CellUtil {
/**
* Sets the given timestamp to the cell iff current timestamp is
- * {@link HConstants#LATEST_TIMESTAMP}. n * @param ts buffer containing the timestamp value
+ * {@link HConstants#LATEST_TIMESTAMP}.
+ * @param ts buffer containing the timestamp value
* @param tsOffset offset to the new timestamp
* @return True if cell timestamp is modified.
* @throws IOException when the passed cell is not of type {@link ExtendedCell}
@@ -1182,8 +1195,8 @@ public final class CellUtil {
/**
* Writes the Cell's key part as it would have serialized in a KeyValue. The format is <2 bytes
* rk len><rk><1 byte cf len><cf><qualifier><8 bytes
- * timestamp><1 byte type> nn * @deprecated As of HBase-2.0. Will be removed in HBase-3.0
- * n
+ * timestamp><1 byte type>
+ * @deprecated As of HBase-2.0. Will be removed in HBase-3.0
*/
@Deprecated
public static void writeFlatKey(Cell cell, DataOutputStream out) throws IOException {
@@ -1219,7 +1232,8 @@ public final class CellUtil {
* Writes the row from the given cell to the output stream excluding the common prefix
* @param out The dataoutputstream to which the data has to be written
* @param cell The cell whose contents has to be written
- * @param rlength the row length n * @deprecated As of 2.0. Will be removed in hbase-3.0
+ * @param rlength the row length
+ * @deprecated As of 2.0. Will be removed in hbase-3.0
*/
@Deprecated
public static void writeRowSkippingBytes(DataOutputStream out, Cell cell, short rlength,
@@ -1234,7 +1248,7 @@ public final class CellUtil {
}
/**
- * n * @return The Key portion of the passed <code>cell</code> as a String.
+ * Return the key portion of the passed <code>cell</code> as a String.
*/
public static String getCellKeyAsString(Cell cell) {
return getCellKeyAsString(cell,
@@ -1242,6 +1256,7 @@ public final class CellUtil {
}
/**
+ * Return the Key portion of the passed <code>cell</code> as a String.
* @param cell the cell to convert
* @param rowConverter used to convert the row of the cell to a string
* @return The Key portion of the passed <code>cell</code> as a String.
@@ -1262,7 +1277,7 @@ public final class CellUtil {
sb.append('/');
sb.append(KeyValue.humanReadableTimestamp(cell.getTimestamp()));
sb.append('/');
- sb.append(Type.codeToType(cell.getTypeByte()));
+ sb.append(KeyValue.Type.codeToType(cell.getTypeByte()));
if (!(cell instanceof KeyValue.KeyOnlyKeyValue)) {
sb.append("/vlen=");
sb.append(cell.getValueLength());
@@ -1275,9 +1290,9 @@ public final class CellUtil {
/**
* This method exists just to encapsulate how we serialize keys. To be replaced by a factory that
* we query to figure what the Cell implementation is and then, what serialization engine to use
- * and further, how to serialize the key for inclusion in hfile index. TODO. n * @return The key
- * portion of the Cell serialized in the old-school KeyValue way or null if passed a null
- * <code>cell</code>
+ * and further, how to serialize the key for inclusion in hfile index. TODO.
+ * @return The key portion of the Cell serialized in the old-school KeyValue way or null if passed
+ * a null <code>cell</code>
* @deprecated As of HBase-2.0. Will be removed in HBase-3.0
*/
@Deprecated
@@ -1289,8 +1304,8 @@ public final class CellUtil {
}
/**
- * Write rowkey excluding the common part. nnnnn * @deprecated As of HBase-2.0. Will be removed in
- * HBase-3.0
+ * Write rowkey excluding the common part.
+ * @deprecated As of HBase-2.0. Will be removed in HBase-3.0
*/
@Deprecated
public static void writeRowKeyExcludingCommon(Cell cell, short rLen, int commonPrefix,
@@ -1486,6 +1501,7 @@ public final class CellUtil {
}
/**
+ * Check whether the type of these two cells are the same
* @deprecated As of HBase-2.0. Will be removed in HBase-3.0
*/
@Deprecated
@@ -1493,15 +1509,14 @@ public final class CellUtil {
return a.getTypeByte() == b.getTypeByte();
}
- /**
- * Compares the row of two keyvalues for equality nn * @return True if rows match.
- */
+ /** Compares the row of two keyvalues for equality */
public static boolean matchingRows(final Cell left, final Cell right) {
short lrowlength = left.getRowLength();
short rrowlength = right.getRowLength();
return matchingRows(left, lrowlength, right, rrowlength);
}
+ /** Compares the row of two keyvalues for equality */
public static boolean matchingRows(final Cell left, final short lrowlength, final Cell right,
final short rrowlength) {
if (lrowlength != rrowlength) return false;
@@ -1525,10 +1540,7 @@ public final class CellUtil {
right.getRowOffset(), rrowlength);
}
- /**
- * Compares the row and column of two keyvalues for equality nn * @return True if same row and
- * column.
- */
+ /** Compares the row and column of two keyvalues for equality */
public static boolean matchingRowColumn(final Cell left, final Cell right) {
short lrowlength = left.getRowLength();
short rrowlength = right.getRowLength();
@@ -1555,6 +1567,7 @@ public final class CellUtil {
return matchingColumn(left, lfamlength, lqlength, right, rfamlength, rqlength);
}
+ /** Compares the row and column of two keyvalues for equality */
public static boolean matchingRowColumnBytes(final Cell left, final Cell right) {
int lrowlength = left.getRowLength();
int rrowlength = right.getRowLength();
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ChoreService.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ChoreService.java
index b93610f26d0..a3eb889f771 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ChoreService.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ChoreService.java
@@ -134,6 +134,7 @@ public class ChoreService {
}
/**
+ * Schedule a chore.
* @param chore Chore to be scheduled. If the chore is already scheduled with another ChoreService
* instance, that schedule will be cancelled (i.e. a Chore can only ever be scheduled
* with a single ChoreService instance).
@@ -252,8 +253,8 @@ public class ChoreService {
}
/**
- * @return number of chores that this service currently has scheduled that are missing their
- * scheduled start time
+ * Return number of chores that this service currently has scheduled that are missing their
+ * scheduled start time
*/
int getNumberOfChoresMissingStartTime() {
return choresMissingStartTime.size();
@@ -273,9 +274,6 @@ public class ChoreService {
private final static String THREAD_NAME_SUFFIX = ".Chore.";
private AtomicInteger threadNumber = new AtomicInteger(1);
- /**
- * @param threadPrefix The prefix given to all threads created by this factory
- */
public ChoreServiceThreadFactory(final String threadPrefix) {
this.threadPrefix = threadPrefix;
}
@@ -350,9 +348,9 @@ public class ChoreService {
}
/**
- * shutdown the service. Any chores that are scheduled for execution will be cancelled. Any chores
- * in the middle of execution will be interrupted and shutdown. This service will be unusable
- * after this method has been called (i.e. future scheduling attempts will fail).
+ * Shut down the service. Any chores that are scheduled for execution will be cancelled. Any
+ * chores in the middle of execution will be interrupted and shutdown. This service will be
+ * unusable after this method has been called (i.e. future scheduling attempts will fail).
* <p/>
* Notice that, this will only clean the chore from this ChoreService but you could still schedule
* the chore with other ChoreService.
@@ -390,9 +388,7 @@ public class ChoreService {
}
}
- /**
- * Prints a summary of important details about the chore. Used for debugging purposes
- */
+ /** Prints a summary of important details about the chore. Used for debugging purposes */
private void printChoreDetails(final String header, ScheduledChore chore) {
if (!LOG.isTraceEnabled()) {
return;
@@ -408,9 +404,7 @@ public class ChoreService {
}
}
- /**
- * Prints a summary of important details about the service. Used for debugging purposes
- */
+ /** Prints a summary of important details about the service. Used for debugging purposes */
private void printChoreServiceDetails(final String header) {
if (!LOG.isTraceEnabled()) {
return;
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/HBaseConfiguration.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/HBaseConfiguration.java
index 0573fe5e45c..62df02c71de 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/HBaseConfiguration.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/HBaseConfiguration.java
@@ -132,6 +132,7 @@ public class HBaseConfiguration extends Configuration {
}
/**
+ * Creates a Configuration with HBase resources
* @param that Configuration to clone.
* @return a Configuration created with the hbase-*.xml files plus the given configuration.
*/
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/IndividualBytesFieldCell.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/IndividualBytesFieldCell.java
index 8601232b09d..4024be0cf01 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/IndividualBytesFieldCell.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/IndividualBytesFieldCell.java
@@ -156,7 +156,7 @@ public class IndividualBytesFieldCell implements ExtendedCell, Cloneable {
// If row is null or rLength is invalid, the constructor will reject it, by
// {@link KeyValue#checkParameters()}, so it is safe to call rLength and make the type
// conversion.
- return (short) (rLength);
+ return (short) rLength;
}
// 2) Family
@@ -175,7 +175,7 @@ public class IndividualBytesFieldCell implements ExtendedCell, Cloneable {
public byte getFamilyLength() {
// If fLength is invalid, the constructor will reject it, by {@link KeyValue#checkParameters()},
// so it is safe to make the type conversion.
- return (byte) (fLength);
+ return (byte) fLength;
}
// 3) Qualifier
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java
index 85b8d9d6d31..d7c6e5f455e 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java
@@ -1075,10 +1075,7 @@ public class KeyValue implements ExtendedCell, Cloneable {
+ getValueLength() + "/seqid=" + seqId;
}
- /**
- * @param k Key portion of a KeyValue.
- * @return Key as a String, empty string if k is null.
- */
+ /** Return key as a String, empty string if k is null. */
public static String keyToString(final byte[] k) {
if (k == null) {
return "";
@@ -1328,10 +1325,7 @@ public class KeyValue implements ExtendedCell, Cloneable {
return getTimestampOffset(getKeyLength());
}
- /**
- * @param keylength Pass if you have it to save on a int creation.
- * @return Timestamp offset
- */
+ /** Return the timestamp offset */
private int getTimestampOffset(final int keylength) {
return getKeyOffset() + keylength - TIMESTAMP_TYPE_SIZE;
}
@@ -1343,6 +1337,7 @@ public class KeyValue implements ExtendedCell, Cloneable {
}
/**
+ * Update the timestamp.
* @param now Time to set into <code>this</code> IFF timestamp ==
* {@link HConstants#LATEST_TIMESTAMP} (else, its a noop).
* @return True is we modified this.
@@ -1386,17 +1381,13 @@ public class KeyValue implements ExtendedCell, Cloneable {
return key;
}
- /**
- * n
- */
+ /** Return the timestamp. */
@Override
public long getTimestamp() {
return getTimestamp(getKeyLength());
}
- /**
- * @param keylength Pass if you have it to save on a int creation. n
- */
+ /** Return the timestamp. */
long getTimestamp(final int keylength) {
int tsOffset = getTimestampOffset(keylength);
return Bytes.toLong(this.bytes, tsOffset);
@@ -1408,13 +1399,12 @@ public class KeyValue implements ExtendedCell, Cloneable {
return getTypeByte(getKeyLength());
}
+ /** Return the KeyValue.TYPE byte representation */
byte getTypeByte(int keyLength) {
return this.bytes[this.offset + keyLength - 1 + ROW_OFFSET];
}
- /**
- * This returns the offset where the tag actually starts.
- */
+ /** Return the offset where the tag data starts. */
@Override
public int getTagsOffset() {
int tagsLen = getTagsLength();
@@ -1424,9 +1414,7 @@ public class KeyValue implements ExtendedCell, Cloneable {
return this.offset + this.length - tagsLen;
}
- /**
- * This returns the total length of the tag bytes
- */
+ /** Return the total length of the tag bytes */
@Override
public int getTagsLength() {
int tagsLen = this.length - (getKeyLength() + getValueLength() + KEYVALUE_INFRASTRUCTURE_SIZE);
@@ -1466,6 +1454,7 @@ public class KeyValue implements ExtendedCell, Cloneable {
}
/**
+ * Find index of passed delimiter walking from start of buffer forwards.
* @param b the kv serialized byte[] to process
* @param delimiter input delimeter to fetch index from start
* @return Index of delimiter having started from start of <code>b</code> moving rightward.
@@ -1749,6 +1738,7 @@ public class KeyValue implements ExtendedCell, Cloneable {
}
/**
+ * Compares the rows of a cell
* @param left left cell to compare rows for
* @param right right cell to compare rows for
* @return Result comparing rows.
@@ -1996,6 +1986,7 @@ public class KeyValue implements ExtendedCell, Cloneable {
}
/**
+ * Compares the row of two keyvalues for equality
* @param left left cell to compare row
* @param lrowlength left row length
* @param right right cell to compare row
@@ -2124,6 +2115,7 @@ public class KeyValue implements ExtendedCell, Cloneable {
}
/**
+ * Create a KeyValue reading from <code>in</code>
* @param in Where to read bytes from. Creates a byte array to hold the KeyValue backing bytes
* copied from the steam.
* @return KeyValue created by deserializing from <code>in</code> OR if we find a length of zero,
@@ -2250,7 +2242,7 @@ public class KeyValue implements ExtendedCell, Cloneable {
return fixed + ClassSize.sizeOfByteArray(length);
} else {
// only count the number of bytes
- return fixed + length;
+ return (long) fixed + length;
}
}
@@ -2339,6 +2331,7 @@ public class KeyValue implements ExtendedCell, Cloneable {
return this.bytes[getFamilyOffset() - 1];
}
+ @Override
int getFamilyLengthPosition(int rowLength) {
return this.offset + Bytes.SIZEOF_SHORT + rowLength;
}
@@ -2378,6 +2371,7 @@ public class KeyValue implements ExtendedCell, Cloneable {
return getTypeByte(getKeyLength());
}
+ @Override
byte getTypeByte(int keyLength) {
return this.bytes[this.offset + keyLength - 1];
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java
index 87b2adf02aa..cb75a1f66a9 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java
@@ -26,7 +26,6 @@ import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
-import org.apache.hadoop.hbase.KeyValue.Type;
import org.apache.hadoop.hbase.io.util.StreamUtils;
import org.apache.hadoop.hbase.util.ByteBufferUtils;
import org.apache.hadoop.hbase.util.Bytes;
@@ -52,9 +51,9 @@ public class KeyValueUtil {
public static int length(short rlen, byte flen, int qlen, int vlen, int tlen, boolean withTags) {
if (withTags) {
- return (int) (KeyValue.getKeyValueDataStructureSize(rlen, flen, qlen, vlen, tlen));
+ return (int) KeyValue.getKeyValueDataStructureSize(rlen, flen, qlen, vlen, tlen);
}
- return (int) (KeyValue.getKeyValueDataStructureSize(rlen, flen, qlen, vlen));
+ return (int) KeyValue.getKeyValueDataStructureSize(rlen, flen, qlen, vlen);
}
/**
@@ -214,7 +213,6 @@ public class KeyValueUtil {
if (bb.remaining() < 1) {
return null;
}
- KeyValue keyValue = null;
int underlyingArrayOffset = bb.arrayOffset() + bb.position();
int keyLength = bb.getInt();
int valueLength = bb.getInt();
@@ -226,7 +224,7 @@ public class KeyValueUtil {
ByteBufferUtils.skip(bb, tagsLength);
}
int kvLength = (int) KeyValue.getKeyValueDataStructureSize(keyLength, valueLength, tagsLength);
- keyValue = new KeyValue(bb.array(), underlyingArrayOffset, kvLength);
+ KeyValue keyValue = new KeyValue(bb.array(), underlyingArrayOffset, kvLength);
if (includesMvccVersion) {
long mvccVersion = ByteBufferUtils.readVLong(bb);
keyValue.setSequenceId(mvccVersion);
@@ -257,7 +255,7 @@ public class KeyValueUtil {
final byte[] family, final int foffset, final int flength, final byte[] qualifier,
final int qoffset, final int qlength) {
return new KeyValue(row, roffset, rlength, family, foffset, flength, qualifier, qoffset,
- qlength, HConstants.OLDEST_TIMESTAMP, Type.Minimum, null, 0, 0);
+ qlength, HConstants.OLDEST_TIMESTAMP, KeyValue.Type.Minimum, null, 0, 0);
}
/**
@@ -268,7 +266,7 @@ public class KeyValueUtil {
*/
public static KeyValue createFirstOnRow(final byte[] row, int roffset, short rlength) {
return new KeyValue(row, roffset, rlength, null, 0, 0, null, 0, 0, HConstants.LATEST_TIMESTAMP,
- Type.Maximum, null, 0, 0);
+ KeyValue.Type.Maximum, null, 0, 0);
}
/**
@@ -278,7 +276,7 @@ public class KeyValueUtil {
* @return Last possible KeyValue on passed <code>row</code>
*/
public static KeyValue createLastOnRow(final byte[] row) {
- return new KeyValue(row, null, null, HConstants.LATEST_TIMESTAMP, Type.Minimum);
+ return new KeyValue(row, null, null, HConstants.LATEST_TIMESTAMP, KeyValue.Type.Minimum);
}
/**
@@ -299,7 +297,7 @@ public class KeyValueUtil {
* @return First possible key on passed <code>row</code> and timestamp.
*/
public static KeyValue createFirstOnRow(final byte[] row, final long ts) {
- return new KeyValue(row, null, null, ts, Type.Maximum);
+ return new KeyValue(row, null, null, ts, KeyValue.Type.Maximum);
}
/**
@@ -312,10 +310,12 @@ public class KeyValueUtil {
*/
public static KeyValue createFirstOnRow(final byte[] row, final byte[] family,
final byte[] qualifier) {
- return new KeyValue(row, family, qualifier, HConstants.LATEST_TIMESTAMP, Type.Maximum);
+ return new KeyValue(row, family, qualifier, HConstants.LATEST_TIMESTAMP, KeyValue.Type.Maximum);
}
/**
+ * Create a KeyValue for the specified row, family and qualifier that would be smaller than all
+ * other possible KeyValues that have the same row, family, qualifier. Used for seeking.
* @param row - row key (arbitrary byte array)
* @param f - family name
* @param q - column qualifier
@@ -324,7 +324,7 @@ public class KeyValueUtil {
*/
public static KeyValue createFirstOnRow(final byte[] row, final byte[] f, final byte[] q,
final long ts) {
- return new KeyValue(row, f, q, ts, Type.Maximum);
+ return new KeyValue(row, f, q, ts, KeyValue.Type.Maximum);
}
/**
@@ -345,7 +345,7 @@ public class KeyValueUtil {
final byte[] family, final int foffset, final int flength, final byte[] qualifier,
final int qoffset, final int qlength) {
return new KeyValue(row, roffset, rlength, family, foffset, flength, qualifier, qoffset,
- qlength, HConstants.LATEST_TIMESTAMP, Type.Maximum, null, 0, 0);
+ qlength, HConstants.LATEST_TIMESTAMP, KeyValue.Type.Maximum, null, 0, 0);
}
/**
@@ -565,7 +565,7 @@ public class KeyValueUtil {
throw new IllegalArgumentException(msg);
}
byte type = buf[pos];
- if (!Type.isValidType(type)) {
+ if (!KeyValue.Type.isValidType(type)) {
String msg = "Invalid type in KeyValue, type=" + type + bytesToHex(buf, offset, length);
LOG.warn(msg);
throw new IllegalArgumentException(msg);
@@ -740,7 +740,6 @@ public class KeyValueUtil {
int qlen = cell.getQualifierLength();
int vlen = cell.getValueLength();
int tlen = cell.getTagsLength();
- int size = 0;
// write key length
int klen = keyLength(rlen, flen, qlen);
ByteBufferUtils.putInt(out, klen);
@@ -760,7 +759,7 @@ public class KeyValueUtil {
out.write(cell.getTypeByte());
// write value
out.write(cell.getValueArray(), cell.getValueOffset(), vlen);
- size = klen + vlen + KeyValue.KEYVALUE_INFRASTRUCTURE_SIZE;
+ int size = klen + vlen + KeyValue.KEYVALUE_INFRASTRUCTURE_SIZE;
// write tags if we have to
if (withTags && tlen > 0) {
// 2 bytes tags length followed by tags bytes
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/PrivateCellUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/PrivateCellUtil.java
index 001dfaae6d5..c34c8d5a298 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/PrivateCellUtil.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/PrivateCellUtil.java
@@ -132,6 +132,7 @@ public final class PrivateCellUtil {
private static final int HEAP_SIZE_OVERHEAD = ClassSize.OBJECT + 2 * ClassSize.REFERENCE;
/**
+ * Construct a TagRewriteCell
* @param cell The original Cell which it rewrites
* @param tags the tags bytes. The array suppose to contain the tags bytes alone.
*/
@@ -828,8 +829,8 @@ public final class PrivateCellUtil {
}
/**
- * @return True if a delete type, a {@link KeyValue.Type#Delete} or a {KeyValue.Type#DeleteFamily}
- * or a {@link KeyValue.Type#DeleteColumn} KeyValue type.
+ * Return true if a delete type, a {@link KeyValue.Type#Delete} or a {KeyValue.Type#DeleteFamily}
+ * or a {@link KeyValue.Type#DeleteColumn} KeyValue type.
*/
public static boolean isDelete(final byte type) {
return KeyValue.Type.Delete.getCode() <= type && type <= KeyValue.Type.DeleteFamily.getCode();
@@ -868,9 +869,7 @@ public final class PrivateCellUtil {
return output;
}
- /**
- * Copies the tags info into the tag portion of the cell nnn * @return position after tags
- */
+ /** Copies the tags info into the tag portion of the cell */
public static int copyTagsTo(Cell cell, byte[] destination, int destinationOffset) {
int tlen = cell.getTagsLength();
if (cell instanceof ByteBufferExtendedCell) {
@@ -884,9 +883,7 @@ public final class PrivateCellUtil {
return destinationOffset + tlen;
}
- /**
- * Copies the tags info into the tag portion of the cell nnn * @return the position after tags
- */
+ /** Copies the tags info into the tag portion of the cell */
public static int copyTagsTo(Cell cell, ByteBuffer destination, int destinationOffset) {
int tlen = cell.getTagsLength();
if (cell instanceof ByteBufferExtendedCell) {
@@ -900,6 +897,7 @@ public final class PrivateCellUtil {
}
/**
+ * Return tags in the given Cell as a List
* @param cell The Cell
* @return Tags in the given Cell as a List
*/
@@ -945,7 +943,7 @@ public final class PrivateCellUtil {
}
/**
- * Util method to iterate through the tags in the given cell.
+ * Utility method to iterate through the tags in the given cell.
* @param cell The Cell over which tags iterator is needed.
* @return iterator for the tags
*/
@@ -1001,9 +999,7 @@ public final class PrivateCellUtil {
&& (end1.length == 0 || start2.length == 0 || Bytes.compareTo(start2, end1) < 0);
}
- /**
- * Write rowkey excluding the common part. nnnnn
- */
+ /** Write rowkey excluding the common part. */
public static void writeRowKeyExcludingCommon(Cell cell, short rLen, int commonPrefix,
DataOutputStream out) throws IOException {
if (commonPrefix == 0) {
@@ -1211,8 +1207,9 @@ public final class PrivateCellUtil {
/**
* Compares only the key portion of a cell. It does not include the sequence id/mvcc of the cell
- * nn * @return an int greater than 0 if left > than right lesser than 0 if left < than
- * right equal to 0 if left is equal to right
+ * nn
+ * @return an int greater than 0 if left > than right lesser than 0 if left < than right
+ * equal to 0 if left is equal to right
*/
public static final int compareKeyIgnoresMvcc(CellComparator comparator, Cell left, Cell right) {
return ((CellComparatorImpl) comparator).compare(left, right, true);
@@ -1807,7 +1804,7 @@ public final class PrivateCellUtil {
private static class FirstOnRowColCell extends FirstOnRowCell {
// @formatter:off
- private static final long FIXED_HEAPSIZE = FirstOnRowCell.FIXED_HEAPSIZE
+ private static final long FIXED_HEAPSIZE = (long) FirstOnRowCell.FIXED_HEAPSIZE
+ Bytes.SIZEOF_BYTE // flength
+ Bytes.SIZEOF_INT * 3 // foffset, qoffset, qlength
+ ClassSize.REFERENCE * 2; // fArray, qArray
@@ -1976,7 +1973,7 @@ public final class PrivateCellUtil {
private static class LastOnRowColCell extends LastOnRowCell {
// @formatter:off
- private static final long FIXED_OVERHEAD = LastOnRowCell.FIXED_OVERHEAD
+ private static final long FIXED_OVERHEAD = (long) LastOnRowCell.FIXED_OVERHEAD
+ ClassSize.REFERENCE * 2 // fArray and qArray
+ Bytes.SIZEOF_INT * 3 // foffset, qoffset, qlength
+ Bytes.SIZEOF_BYTE; // flength
@@ -2318,7 +2315,7 @@ public final class PrivateCellUtil {
}
/**
- * Sets the given timestamp to the cell. n * @param ts buffer containing the timestamp value
+ * Sets the given timestamp to the cell.
* @throws IOException when the passed cell is not of type {@link ExtendedCell}
*/
public static void setTimestamp(Cell cell, byte[] ts) throws IOException {
@@ -2332,7 +2329,8 @@ public final class PrivateCellUtil {
/**
* Sets the given timestamp to the cell iff current timestamp is
- * {@link HConstants#LATEST_TIMESTAMP}. nn * @return True if cell timestamp is modified.
+ * {@link HConstants#LATEST_TIMESTAMP}.
+ * @return True if cell timestamp is modified.
* @throws IOException when the passed cell is not of type {@link ExtendedCell}
*/
public static boolean updateLatestStamp(Cell cell, long ts) throws IOException {
@@ -2345,7 +2343,7 @@ public final class PrivateCellUtil {
/**
* Sets the given timestamp to the cell iff current timestamp is
- * {@link HConstants#LATEST_TIMESTAMP}. n * @param ts buffer containing the timestamp value
+ * {@link HConstants#LATEST_TIMESTAMP}.
* @return True if cell timestamp is modified.
* @throws IOException when the passed cell is not of type {@link ExtendedCell}
*/
@@ -2684,8 +2682,8 @@ public final class PrivateCellUtil {
}
/**
- * @return An new cell is located following input cell. If both of type and timestamp are minimum,
- * the input cell will be returned directly.
+ * Return a new cell is located following input cell. If both of type and timestamp are minimum,
+ * the input cell will be returned directly.
*/
public static Cell createNextOnRowCol(Cell cell) {
long ts = cell.getTimestamp();
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ScheduledChore.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ScheduledChore.java
index f6b6537f5d4..168fe306e4b 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ScheduledChore.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ScheduledChore.java
@@ -79,6 +79,8 @@ public abstract class ScheduledChore implements Runnable {
private final Stoppable stopper;
/**
+ * Construct a ScheduledChore
+ * <p>
* This constructor is for test only. It allows us to create an object and to call chore() on it.
*/
@InterfaceAudience.Private
@@ -87,6 +89,7 @@ public abstract class ScheduledChore implements Runnable {
}
/**
+ * Construct a ScheduledChore
* @param name Name assigned to Chore. Useful for identification amongst chores of the same
* type
* @param stopper When {@link Stoppable#isStopped()} is true, this chore will cancel and cleanup
@@ -97,6 +100,7 @@ public abstract class ScheduledChore implements Runnable {
}
/**
+ * Construct a ScheduledChore
* @param name Name assigned to Chore. Useful for identification amongst chores of the
* same type
* @param stopper When {@link Stoppable#isStopped()} is true, this chore will cancel and
@@ -112,6 +116,7 @@ public abstract class ScheduledChore implements Runnable {
}
/**
+ * Construct a ScheduledChore
* @param name Name assigned to Chore. Useful for identification amongst chores of the
* same type
* @param stopper When {@link Stoppable#isStopped()} is true, this chore will cancel and
@@ -132,9 +137,6 @@ public abstract class ScheduledChore implements Runnable {
this.timeUnit = unit;
}
- /**
- * @see java.lang.Runnable#run()
- */
@Override
public void run() {
updateTimeTrackingBeforeRun();
@@ -193,8 +195,8 @@ public abstract class ScheduledChore implements Runnable {
}
/**
- * @return How long in millis has it been since this chore last run. Useful for checking if the
- * chore has missed its scheduled start time by too large of a margin
+ * Return how long in millis has it been since this chore last run. Useful for checking if the
+ * chore has missed its scheduled start time by too large of a margin
*/
synchronized long getTimeBetweenRuns() {
return timeOfThisRun - timeOfLastRun;
@@ -212,10 +214,7 @@ public abstract class ScheduledChore implements Runnable {
return 1.5 * timeUnit.toMillis(period);
}
- /**
- * @param time in system millis
- * @return true if time is earlier or equal to current milli time
- */
+ /** Return true if time is earlier or equal to current time */
private synchronized boolean isValidTime(final long time) {
return time > 0 && time <= EnvironmentEdgeManager.currentTime();
}
@@ -297,9 +296,7 @@ public abstract class ScheduledChore implements Runnable {
chore();
}
- /**
- * The task to execute on each scheduled execution of the Chore
- */
+ /** The task to execute on each scheduled execution of the Chore */
protected abstract void chore();
/**
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ServerName.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ServerName.java
index c6008561969..5223bac3e5b 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ServerName.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ServerName.java
@@ -19,6 +19,7 @@ package org.apache.hadoop.hbase;
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.regex.Pattern;
@@ -27,6 +28,7 @@ import org.apache.hadoop.hbase.util.Addressing;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.yetus.audience.InterfaceAudience;
+import org.apache.hbase.thirdparty.com.google.common.base.Splitter;
import org.apache.hbase.thirdparty.com.google.common.collect.Interner;
import org.apache.hbase.thirdparty.com.google.common.collect.Interners;
import org.apache.hbase.thirdparty.com.google.common.net.InetAddresses;
@@ -80,8 +82,8 @@ public class ServerName implements Comparable<ServerName>, Serializable {
*/
public static final String UNKNOWN_SERVERNAME = "#unknown#";
- private final String servername;
- private final long startcode;
+ private final String serverName;
+ private final long startCode;
private transient Address address;
/**
@@ -97,15 +99,15 @@ public class ServerName implements Comparable<ServerName>, Serializable {
*/
private static final Interner<ServerName> INTERN_POOL = Interners.newWeakInterner();
- protected ServerName(final String hostname, final int port, final long startcode) {
- this(Address.fromParts(hostname, port), startcode);
+ protected ServerName(final String hostname, final int port, final long startCode) {
+ this(Address.fromParts(hostname, port), startCode);
}
- private ServerName(final Address address, final long startcode) {
+ private ServerName(final Address address, final long startCode) {
// Use HostAndPort to host port and hostname. Does validation and can do ipv6
this.address = address;
- this.startcode = startcode;
- this.servername = getServerName(this.address.getHostname(), this.address.getPort(), startcode);
+ this.startCode = startCode;
+ this.serverName = getServerName(this.address.getHostname(), this.address.getPort(), startCode);
}
private ServerName(final String hostAndPort, final long startCode) {
@@ -123,11 +125,12 @@ public class ServerName implements Comparable<ServerName>, Serializable {
if (InetAddresses.isInetAddress(hostname)) {
return hostname;
}
- String[] parts = hostname.split("\\.");
- if (parts.length == 0) {
+ List<String> parts = Splitter.on('.').splitToList(hostname);
+ if (parts.size() == 0) {
return hostname;
}
- return parts[0];
+ Iterator<String> i = parts.iterator();
+ return i.next();
}
/**
@@ -170,8 +173,8 @@ public class ServerName implements Comparable<ServerName>, Serializable {
* Retrieve an instance of ServerName. Callers should use the equals method to compare returned
* instances, though we may return a shared immutable object as an internal optimization.
*/
- public static ServerName valueOf(final String hostname, final int port, final long startcode) {
- return INTERN_POOL.intern(new ServerName(hostname, port, startcode));
+ public static ServerName valueOf(final String hostname, final int port, final long startCode) {
+ return INTERN_POOL.intern(new ServerName(hostname, port, startCode));
}
/**
@@ -179,11 +182,12 @@ public class ServerName implements Comparable<ServerName>, Serializable {
* instances, though we may return a shared immutable object as an internal optimization.
*/
public static ServerName valueOf(final String serverName) {
- final String hostname = serverName.substring(0, serverName.indexOf(SERVERNAME_SEPARATOR));
- final int port = Integer.parseInt(serverName.split(SERVERNAME_SEPARATOR)[1]);
- final long statuscode =
- Long.parseLong(serverName.substring(serverName.lastIndexOf(SERVERNAME_SEPARATOR) + 1));
- return INTERN_POOL.intern(new ServerName(hostname, port, statuscode));
+ int firstSep = serverName.indexOf(SERVERNAME_SEPARATOR);
+ int lastSep = serverName.lastIndexOf(SERVERNAME_SEPARATOR);
+ String hostname = serverName.substring(0, firstSep);
+ int port = Integer.parseInt(serverName.substring(firstSep + 1, lastSep));
+ long startCode = Long.parseLong(serverName.substring(lastSep + 1));
+ return valueOf(hostname, port, startCode);
}
/**
@@ -199,12 +203,12 @@ public class ServerName implements Comparable<ServerName>, Serializable {
* method to compare returned instances, though we may return a shared immutable object as an
* internal optimization.
* @param address the {@link Address} to use for getting the {@link ServerName}
- * @param startcode the startcode to use for getting the {@link ServerName}
+ * @param startCode the startcode to use for getting the {@link ServerName}
* @return the constructed {@link ServerName}
* @see #valueOf(String, int, long)
*/
- public static ServerName valueOf(final Address address, final long startcode) {
- return valueOf(address.getHostname(), address.getPort(), startcode);
+ public static ServerName valueOf(final Address address, final long startCode) {
+ return valueOf(address.getHostname(), address.getPort(), startCode);
}
@Override
@@ -213,10 +217,9 @@ public class ServerName implements Comparable<ServerName>, Serializable {
}
/**
- * @return Return a SHORT version of {@link #toString()}, one that has the host only, minus the
- * domain, and the port only -- no start code; the String is for us internally mostly
- * tying threads to their server. Not for external use. It is lossy and will not work in
- * in compares, etc.
+ * Return a SHORT version of {@link #toString()}, one that has the host only, minus the domain,
+ * and the port only -- no start code; the String is for us internally mostly tying threads to
+ * their server. Not for external use. It is lossy and will not work in in compares, etc.
*/
public String toShortString() {
return Addressing.createHostAndPortStr(getHostNameMinusDomain(this.address.getHostname()),
@@ -224,8 +227,8 @@ public class ServerName implements Comparable<ServerName>, Serializable {
}
/**
- * @return {@link #getServerName()} as bytes with a short-sized prefix with the {@link #VERSION}
- * of this class.
+ * Return {@link #getServerName()} as bytes with a short-sized prefix with the {@link #VERSION} of
+ * this class.
*/
public synchronized byte[] getVersionedBytes() {
if (this.bytes == null) {
@@ -235,7 +238,7 @@ public class ServerName implements Comparable<ServerName>, Serializable {
}
public String getServerName() {
- return servername;
+ return serverName;
}
public String getHostname() {
@@ -250,24 +253,34 @@ public class ServerName implements Comparable<ServerName>, Serializable {
return this.address.getPort();
}
+ /**
+ * Return the start code.
+ * @deprecated Since 2.5.0, will be removed in 4.0.0. Use {@link #getStartCode()} instead.
+ */
+ @Deprecated
public long getStartcode() {
- return startcode;
+ return startCode;
+ }
+
+ /** Return the start code. */
+ public long getStartCode() {
+ return startCode;
}
/**
* For internal use only.
* @param hostName the name of the host to use
* @param port the port on the host to use
- * @param startcode the startcode to use for formatting
+ * @param startCode the startcode to use for formatting
* @return Server name made of the concatenation of hostname, port and startcode formatted as
* <code><hostname> ',' <port> ',' <startcode></code>
* @deprecated Since 2.0. Use {@link ServerName#valueOf(String, int, long)} instead.
*/
@Deprecated
// TODO: Make this private in hbase-3.0.
- static String getServerName(String hostName, int port, long startcode) {
+ static String getServerName(String hostName, int port, long startCode) {
return hostName.toLowerCase(Locale.ROOT) + SERVERNAME_SEPARATOR + port + SERVERNAME_SEPARATOR
- + startcode;
+ + startCode;
}
/**
@@ -352,7 +365,7 @@ public class ServerName implements Comparable<ServerName>, Serializable {
if (compare != 0) {
return compare;
}
- return Long.compare(this.getStartcode(), other.getStartcode());
+ return Long.compare(this.getStartCode(), other.getStartCode());
}
@Override
@@ -375,6 +388,7 @@ public class ServerName implements Comparable<ServerName>, Serializable {
}
/**
+ * Compare two addresses
* @param left the first server address to compare
* @param right the second server address to compare
* @return {@code true} if {@code left} and {@code right} have the same hostname and port.
@@ -404,6 +418,7 @@ public class ServerName implements Comparable<ServerName>, Serializable {
}
/**
+ * Parse a ServerName from a string
* @param str Either an instance of {@link #toString()} or a "'<hostname>' ':'
* '<port>'".
* @return A ServerName instance.
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/TableName.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/TableName.java
index 174a4169c0d..c799fb9b2f7 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/TableName.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/TableName.java
@@ -269,9 +269,6 @@ public final class TableName implements Comparable<TableName> {
return nameAsString;
}
- /**
- * @throws IllegalArgumentException See {@link #valueOf(byte[])}
- */
private TableName(ByteBuffer namespace, ByteBuffer qualifier) throws IllegalArgumentException {
this.qualifier = new byte[qualifier.remaining()];
qualifier.duplicate().get(this.qualifier);
@@ -315,9 +312,7 @@ public final class TableName implements Comparable<TableName> {
isLegalTableQualifierName(this.qualifier);
}
- /**
- * This is only for the old and meta tables.
- */
+ /** This is only for the old and meta tables. */
private TableName(String qualifier) {
this.qualifier = Bytes.toBytes(qualifier);
this.qualifierAsString = qualifier;
@@ -389,6 +384,7 @@ public final class TableName implements Comparable<TableName> {
}
/**
+ * Construct a TableName
* @param fullName will use the entire byte array
* @throws IllegalArgumentException if fullName equals old root or old meta. Some code depends on
* this. The test is buried in the table creation to save on
@@ -400,6 +396,7 @@ public final class TableName implements Comparable<TableName> {
}
/**
+ * Construct a TableName
* @param fullName byte array to look into
* @param offset within said array
* @param length within said array
@@ -431,6 +428,7 @@ public final class TableName implements Comparable<TableName> {
}
/**
+ * Construct a TableName
* @param fullname of a table, possibly with a leading namespace and ':' as delimiter.
* @throws IllegalArgumentException if fullName equals old root or old meta.
*/
@@ -456,6 +454,7 @@ public final class TableName implements Comparable<TableName> {
}
/**
+ * Construct a TableName
* @throws IllegalArgumentException if fullName equals old root or old meta. Some code depends on
* this.
*/
@@ -520,12 +519,12 @@ public final class TableName implements Comparable<TableName> {
return hashCode;
}
- /**
- * For performance reasons, the ordering is not lexicographic.
- */
@Override
public int compareTo(TableName tableName) {
- if (this == tableName) return 0;
+ // For performance reasons, the ordering is not lexicographic.
+ if (this == tableName) {
+ return 0;
+ }
if (this.hashCode < tableName.hashCode()) {
return -1;
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/Tag.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/Tag.java
index fd0aa43190b..8d03e35f8a4 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/Tag.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/Tag.java
@@ -55,15 +55,13 @@ public interface Tag {
/** Returns Length of tag value within the backed buffer */
int getValueLength();
- /**
- * Tells whether or not this Tag is backed by a byte array.
- * @return true when this Tag is backed by byte array
- */
+ /** Return true if the tag is backed by a byte array */
boolean hasArray();
/**
- * @return The array containing the value bytes. n * when {@link #hasArray()} return false. Use
- * {@link #getValueByteBuffer()} in such situation
+ * Return an array containing the value bytes if {@link #hasArray()} returns true.
+ * <p>
+ * Use {@link #getValueByteBuffer()} otherwise.
*/
byte[] getValueArray();
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/TagUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/TagUtil.java
index c3c49410210..6d911bccd58 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/TagUtil.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/TagUtil.java
@@ -70,9 +70,7 @@ public final class TagUtil {
return carryForwardTags(null, cell);
}
- /**
- * Add to <code>tagsOrNull</code> any Tags <code>cell</code> is carrying or null if none.
- */
+ /** Add to <code>tagsOrNull</code> any Tags <code>cell</code> is carrying or null if none. */
public static List<Tag> carryForwardTags(final List<Tag> tagsOrNull, final Cell cell) {
Iterator<Tag> itr = PrivateCellUtil.tagsIterator(cell);
if (itr == EMPTY_TAGS_ITR) {
@@ -166,9 +164,7 @@ public final class TagUtil {
return b;
}
- /**
- * Iterator returned when no Tags. Used by CellUtil too.
- */
+ /** Iterator returned when no Tags. Used by CellUtil too. */
static final Iterator<Tag> EMPTY_TAGS_ITR = new Iterator<Tag>() {
@Override
public boolean hasNext() {
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/filter/ByteArrayComparable.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/filter/ByteArrayComparable.java
index 480680b00f3..f6c556c9b3c 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/filter/ByteArrayComparable.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/filter/ByteArrayComparable.java
@@ -50,10 +50,12 @@ public abstract class ByteArrayComparable implements Comparable<byte[]> {
public abstract byte[] toByteArray();
/**
+ * Parse a serialized representation of {@link ByteArrayComparable}
* @param pbBytes A pb serialized {@link ByteArrayComparable} instance
- * @return An instance of {@link ByteArrayComparable} made from <code>bytes</code> n * @see
- * #toByteArray
+ * @return An instance of {@link ByteArrayComparable} made from <code>bytes</code>
+ * @see #toByteArray
*/
+ @SuppressWarnings("DoNotCallSuggester")
public static ByteArrayComparable parseFrom(final byte[] pbBytes)
throws DeserializationException {
throw new DeserializationException(
@@ -61,12 +63,13 @@ public abstract class ByteArrayComparable implements Comparable<byte[]> {
}
/**
- * n * @return true if and only if the fields of the comparator that are serialized are equal to
- * the corresponding fields in other. Used for testing.
+ * Return true if and only if the fields of the comparator that are serialized are equal to the
+ * corresponding fields in other.
*/
boolean areSerializedFieldsEqual(ByteArrayComparable other) {
- if (other == this) return true;
-
+ if (other == this) {
+ return true;
+ }
return Bytes.equals(this.getValue(), other.getValue());
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/HeapSize.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/HeapSize.java
index 5e0fb79d841..3a4a9e2d230 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/HeapSize.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/HeapSize.java
@@ -41,8 +41,8 @@ import org.apache.yetus.audience.InterfaceAudience;
@InterfaceAudience.Private
public interface HeapSize {
/**
- * @return Approximate 'exclusive deep size' of implementing object. Includes count of payload and
- * hosting object sizings.
+ * Return the approximate 'exclusive deep size' of implementing object. Includes count of payload
+ * and hosting object sizings.
*/
long heapSize();
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ImmutableBytesWritable.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ImmutableBytesWritable.java
index da897b04ae1..924cbf21e47 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ImmutableBytesWritable.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ImmutableBytesWritable.java
@@ -91,16 +91,12 @@ public class ImmutableBytesWritable implements WritableComparable<ImmutableBytes
return this.bytes;
}
- /**
- * @param b Use passed bytes as backing array for this instance.
- */
+ /** Use passed bytes as backing array for this instance. */
public void set(final byte[] b) {
set(b, 0, b.length);
}
- /**
- * @param b Use passed bytes as backing array for this instance. nn
- */
+ /** Use passed bytes as backing array for this instance. */
public void set(final byte[] b, final int offset, final int length) {
this.bytes = b;
this.offset = offset;
@@ -131,9 +127,7 @@ public class ImmutableBytesWritable implements WritableComparable<ImmutableBytes
return this.length;
}
- /**
- * n
- */
+ /** Return the offset into the buffer. */
public int getOffset() {
return this.offset;
}
@@ -153,6 +147,7 @@ public class ImmutableBytesWritable implements WritableComparable<ImmutableBytes
}
// Below methods copied from BytesWritable
+
@Override
public int hashCode() {
int hash = 1;
@@ -182,9 +177,6 @@ public class ImmutableBytesWritable implements WritableComparable<ImmutableBytes
that.length);
}
- /**
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(Object right_obj) {
if (right_obj instanceof byte[]) {
@@ -196,9 +188,6 @@ public class ImmutableBytesWritable implements WritableComparable<ImmutableBytes
return false;
}
- /**
- * @see java.lang.Object#toString()
- */
@Override
public String toString() {
StringBuilder sb = new StringBuilder(3 * this.length);
@@ -215,21 +204,15 @@ public class ImmutableBytesWritable implements WritableComparable<ImmutableBytes
return sb.length() > 0 ? sb.substring(1) : "";
}
- /**
- * A Comparator optimized for ImmutableBytesWritable.
- */
+ /** A Comparator optimized for ImmutableBytesWritable. */
@InterfaceAudience.Public
public static class Comparator extends WritableComparator {
private BytesWritable.Comparator comparator = new BytesWritable.Comparator();
- /** constructor */
public Comparator() {
super(ImmutableBytesWritable.class);
}
- /**
- * @see org.apache.hadoop.io.WritableComparator#compare(byte[], int, int, byte[], int, int)
- */
@Override
public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
return comparator.compare(b1, s1, l1, b2, s2, l2);
@@ -241,6 +224,7 @@ public class ImmutableBytesWritable implements WritableComparable<ImmutableBytes
}
/**
+ * Convert a list of byte arrays into an array of byte arrays
* @param array List of byte [].
* @return Array of byte [].
*/
@@ -253,9 +237,7 @@ public class ImmutableBytesWritable implements WritableComparable<ImmutableBytes
return results;
}
- /**
- * Returns a copy of the bytes referred to by this writable
- */
+ /** Returns a copy of the bytes referred to by this writable */
public byte[] copyBytes() {
return Arrays.copyOfRange(bytes, offset, offset + length);
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/TagCompressionContext.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/TagCompressionContext.java
index b3c699c0070..af9126d942d 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/TagCompressionContext.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/TagCompressionContext.java
@@ -81,7 +81,8 @@ public class TagCompressionContext {
public void compressTags(OutputStream out, ByteBuffer in, int offset, int length)
throws IOException {
if (in.hasArray()) {
- compressTags(out, in.array(), offset, length);
+ // Offset we are given is relative to ByteBuffer#arrayOffset
+ compressTags(out, in.array(), in.arrayOffset() + offset, length);
} else {
int pos = offset;
int endOffset = pos + length;
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/compress/ReusableStreamGzipCodec.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/compress/ReusableStreamGzipCodec.java
index f858f3a773f..0b3b3afbfc5 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/compress/ReusableStreamGzipCodec.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/compress/ReusableStreamGzipCodec.java
@@ -100,7 +100,7 @@ public class ReusableStreamGzipCodec extends GzipCodec {
def.finish();
while (!def.finished()) {
int i = def.deflate(this.buf, 0, this.buf.length);
- if ((def.finished()) && (i <= this.buf.length - TRAILER_SIZE)) {
+ if (def.finished() && (i <= this.buf.length - TRAILER_SIZE)) {
writeTrailer(this.buf, i);
i += TRAILER_SIZE;
out.write(this.buf, 0, i);
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java
index c2bd9d39da7..dd690fb542c 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java
@@ -29,7 +29,6 @@ import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.KeyValue.Type;
import org.apache.hadoop.hbase.KeyValueUtil;
import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.io.TagCompressionContext;
@@ -279,14 +278,14 @@ abstract class BufferedDataBlockEncoder extends AbstractDataBlockEncoder {
protected static class OnheapDecodedCell implements ExtendedCell {
private static final long FIXED_OVERHEAD = ClassSize.align(ClassSize.OBJECT
+ (3 * ClassSize.REFERENCE) + (2 * Bytes.SIZEOF_LONG) + (7 * Bytes.SIZEOF_INT)
- + (Bytes.SIZEOF_SHORT) + (2 * Bytes.SIZEOF_BYTE) + (3 * ClassSize.ARRAY));
+ + Bytes.SIZEOF_SHORT + (2 * Bytes.SIZEOF_BYTE) + (3 * ClassSize.ARRAY));
private byte[] keyOnlyBuffer;
private short rowLength;
private int familyOffset;
private byte familyLength;
private int qualifierOffset;
private int qualifierLength;
- private long timestamp;
+ private long timeStamp;
private byte typeByte;
private byte[] valueBuffer;
private int valueOffset;
@@ -306,7 +305,7 @@ abstract class BufferedDataBlockEncoder extends AbstractDataBlockEncoder {
this.familyLength = familyLength;
this.qualifierOffset = qualOffset;
this.qualifierLength = qualLength;
- this.timestamp = timeStamp;
+ this.timeStamp = timeStamp;
this.typeByte = typeByte;
this.valueBuffer = valueBuffer;
this.valueOffset = valueOffset;
@@ -364,7 +363,7 @@ abstract class BufferedDataBlockEncoder extends AbstractDataBlockEncoder {
@Override
public long getTimestamp() {
- return timestamp;
+ return timeStamp;
}
@Override
@@ -475,16 +474,17 @@ abstract class BufferedDataBlockEncoder extends AbstractDataBlockEncoder {
}
protected static class OffheapDecodedExtendedCell extends ByteBufferExtendedCell {
- private static final long FIXED_OVERHEAD = ClassSize.align(ClassSize.OBJECT
- + (3 * ClassSize.REFERENCE) + (2 * Bytes.SIZEOF_LONG) + (7 * Bytes.SIZEOF_INT)
- + (Bytes.SIZEOF_SHORT) + (2 * Bytes.SIZEOF_BYTE) + (3 * ClassSize.BYTE_BUFFER));
+ private static final long FIXED_OVERHEAD =
+ (long) ClassSize.align(ClassSize.OBJECT + (3 * ClassSize.REFERENCE) + (2 * Bytes.SIZEOF_LONG)
+ + (7 * Bytes.SIZEOF_INT) + Bytes.SIZEOF_SHORT) + (2 * Bytes.SIZEOF_BYTE)
+ + (3 * ClassSize.BYTE_BUFFER);
private ByteBuffer keyBuffer;
private short rowLength;
private int familyOffset;
private byte familyLength;
private int qualifierOffset;
private int qualifierLength;
- private long timestamp;
+ private long timeStamp;
private byte typeByte;
private ByteBuffer valueBuffer;
private int valueOffset;
@@ -507,7 +507,7 @@ abstract class BufferedDataBlockEncoder extends AbstractDataBlockEncoder {
this.familyLength = familyLength;
this.qualifierOffset = qualOffset;
this.qualifierLength = qualLength;
- this.timestamp = timeStamp;
+ this.timeStamp = timeStamp;
this.typeByte = typeByte;
this.valueBuffer = valueBuffer;
this.valueOffset = valueOffset;
@@ -519,6 +519,7 @@ abstract class BufferedDataBlockEncoder extends AbstractDataBlockEncoder {
}
@Override
+ @SuppressWarnings("ByteBufferBackingArray")
public byte[] getRowArray() {
return this.keyBuffer.array();
}
@@ -534,6 +535,7 @@ abstract class BufferedDataBlockEncoder extends AbstractDataBlockEncoder {
}
@Override
+ @SuppressWarnings("ByteBufferBackingArray")
public byte[] getFamilyArray() {
return this.keyBuffer.array();
}
@@ -549,6 +551,7 @@ abstract class BufferedDataBlockEncoder extends AbstractDataBlockEncoder {
}
@Override
+ @SuppressWarnings("ByteBufferBackingArray")
public byte[] getQualifierArray() {
return this.keyBuffer.array();
}
@@ -565,7 +568,7 @@ abstract class BufferedDataBlockEncoder extends AbstractDataBlockEncoder {
@Override
public long getTimestamp() {
- return this.timestamp;
+ return this.timeStamp;
}
@Override
@@ -671,10 +674,10 @@ abstract class BufferedDataBlockEncoder extends AbstractDataBlockEncoder {
@Override
public int write(OutputStream out, boolean withTags) throws IOException {
int lenToWrite = getSerializedSize(withTags);
- ByteBufferUtils.putInt(out, keyBuffer.capacity());
+ ByteBufferUtils.putInt(out, keyBuffer.remaining());
ByteBufferUtils.putInt(out, valueLength);
// Write key
- out.write(keyBuffer.array());
+ out.write(keyBuffer.array(), keyBuffer.arrayOffset(), keyBuffer.remaining());
// Write value
ByteBufferUtils.copyBufferToStream(out, this.valueBuffer, this.valueOffset, this.valueLength);
if (withTags && this.tagsLength > 0) {
@@ -928,14 +931,14 @@ abstract class BufferedDataBlockEncoder extends AbstractDataBlockEncoder {
private int compareTypeBytes(Cell key, Cell right) {
if (
key.getFamilyLength() + key.getQualifierLength() == 0
- && key.getTypeByte() == Type.Minimum.getCode()
+ && key.getTypeByte() == KeyValue.Type.Minimum.getCode()
) {
// left is "bigger", i.e. it appears later in the sorted order
return 1;
}
if (
right.getFamilyLength() + right.getQualifierLength() == 0
- && right.getTypeByte() == Type.Minimum.getCode()
+ && right.getTypeByte() == KeyValue.Type.Minimum.getCode()
) {
return -1;
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/DataBlockEncoding.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/DataBlockEncoding.java
index 71808adf75d..21f6c92ef35 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/DataBlockEncoding.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/DataBlockEncoding.java
@@ -28,6 +28,7 @@ import org.apache.yetus.audience.InterfaceAudience;
* assign it a new id. Announce the new id in the HBase mailing list to prevent collisions.
*/
@InterfaceAudience.Public
+@SuppressWarnings("ImmutableEnumChecker")
public enum DataBlockEncoding {
/** Disable data block encoding. */
@@ -100,6 +101,8 @@ public enum DataBlockEncoding {
* @param dest output array
* @param offset starting offset of the output array n
*/
+ // System.arraycopy is static native. Nothing we can do this until we have minimum JDK 9.
+ @SuppressWarnings("UnsafeFinalization")
public void writeIdInBytes(byte[] dest, int offset) throws IOException {
System.arraycopy(idInBytes, 0, dest, offset, ID_SIZE);
}
@@ -159,10 +162,10 @@ public enum DataBlockEncoding {
return algorithm;
}
- protected static DataBlockEncoder createEncoder(String fullyQualifiedClassName) {
+ static DataBlockEncoder createEncoder(String fullyQualifiedClassName) {
try {
- return (DataBlockEncoder) Class.forName(fullyQualifiedClassName).getDeclaredConstructor()
- .newInstance();
+ return Class.forName(fullyQualifiedClassName).asSubclass(DataBlockEncoder.class)
+ .getDeclaredConstructor().newInstance();
} catch (Exception e) {
throw new RuntimeException(e);
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/DiffKeyDeltaEncoder.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/DiffKeyDeltaEncoder.java
index 77324b07c2f..e865d0b1252 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/DiffKeyDeltaEncoder.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/DiffKeyDeltaEncoder.java
@@ -304,7 +304,7 @@ public class DiffKeyDeltaEncoder extends BufferedDataBlockEncoder {
ByteBuffer result = ByteBuffer.allocate(keyLength);
// copy row
- assert !(result.isDirect());
+ assert !result.isDirect();
int pos = result.arrayOffset();
block.get(result.array(), pos, Bytes.SIZEOF_SHORT);
pos += Bytes.SIZEOF_SHORT;
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/EncodedDataBlock.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/EncodedDataBlock.java
index d09ddc9126f..7750728108d 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/EncodedDataBlock.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/EncodedDataBlock.java
@@ -143,8 +143,9 @@ public class EncodedDataBlock {
ByteBufferUtils.skip(decompressedData, tagsLen);
}
}
- KeyValue kv = new KeyValue(decompressedData.array(), offset,
- (int) KeyValue.getKeyValueDataStructureSize(klen, vlen, tagsLen));
+ KeyValue kv =
+ new KeyValue(decompressedData.array(), decompressedData.arrayOffset() + offset,
+ (int) KeyValue.getKeyValueDataStructureSize(klen, vlen, tagsLen));
if (meta.isIncludesMvcc()) {
long mvccVersion = ByteBufferUtils.readVLong(decompressedData);
kv.setSequenceId(mvccVersion);
@@ -269,7 +270,7 @@ public class EncodedDataBlock {
if (this.meta.isIncludesMvcc()) {
memstoreTS = ByteBufferUtils.readVLong(in);
}
- kv = new KeyValue(in.array(), kvOffset,
+ kv = new KeyValue(in.array(), in.arrayOffset() + kvOffset,
(int) KeyValue.getKeyValueDataStructureSize(klength, vlength, tagsLength));
kv.setSequenceId(memstoreTS);
this.dataBlockEncoder.encode(kv, encodingCtx, out);
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/HFileBlockEncodingContext.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/HFileBlockEncodingContext.java
index fcac1549b9f..71cba0b9d8c 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/HFileBlockEncodingContext.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/HFileBlockEncodingContext.java
@@ -43,23 +43,20 @@ public interface HFileBlockEncodingContext {
*/
void postEncoding(BlockType blockType) throws IOException;
- /**
- * Releases the resources used.
- */
+ /** Releases the resources used. */
void close();
/** Returns HFile context information */
HFileContext getHFileContext();
- /**
- * Sets the encoding state.
- */
+ /** Sets the encoding state. */
void setEncodingState(EncodingState state);
/** Returns the encoding state */
EncodingState getEncodingState();
/**
+ * Compress and encrypt the supplied encoded block data with header.
* @param data encoded bytes with header
* @param offset the offset in encoded data to start at
* @param length the number of encoded bytes
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/RowIndexSeekerV1.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/RowIndexSeekerV1.java
index 453f55b6438..e283803a143 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/RowIndexSeekerV1.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/RowIndexSeekerV1.java
@@ -80,12 +80,13 @@ public class RowIndexSeekerV1 extends AbstractEncodedSeeker {
}
@Override
+ @SuppressWarnings("ByteBufferBackingArray")
public Cell getKey() {
if (current.keyBuffer.hasArray()) {
return new KeyValue.KeyOnlyKeyValue(current.keyBuffer.array(),
current.keyBuffer.arrayOffset() + current.keyBuffer.position(), current.keyLength);
} else {
- byte[] key = new byte[current.keyLength];
+ final byte[] key = new byte[current.keyLength];
ByteBufferUtils.copyFromBufferToArray(key, current.keyBuffer, current.keyBuffer.position(), 0,
current.keyLength);
return new KeyValue.KeyOnlyKeyValue(key, 0, current.keyLength);
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockType.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockType.java
index 9b8a6bbfe2c..dd109083322 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockType.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockType.java
@@ -31,6 +31,7 @@ import org.apache.yetus.audience.InterfaceAudience;
* The values in the enum appear in the order they appear in a version 2 HFile.
*/
@InterfaceAudience.Private
+@SuppressWarnings("ImmutableEnumChecker")
public enum BlockType {
// Scanned block section
@@ -179,6 +180,8 @@ public enum BlockType {
* @param offset position in the array
* @return incremented offset
*/
+ // System.arraycopy is static native. We can't do anything about this until minimum JDK is 9.
+ @SuppressWarnings("UnsafeFinalization")
public int put(byte[] bytes, int offset) {
System.arraycopy(magic, 0, bytes, offset, MAGIC_LENGTH);
return offset + MAGIC_LENGTH;
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileContext.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileContext.java
index 5064c4a4b8f..d152ec1900b 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileContext.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileContext.java
@@ -56,7 +56,7 @@ public class HFileContext implements HeapSize, Cloneable {
/** the number of bytes per checksum value **/
private int bytesPerChecksum = DEFAULT_BYTES_PER_CHECKSUM;
/** Number of uncompressed bytes we allow per block. */
- private int blocksize = HConstants.DEFAULT_BLOCKSIZE;
+ private int blockSize = HConstants.DEFAULT_BLOCKSIZE;
private DataBlockEncoding encoding = DataBlockEncoding.NONE;
/** Encryption algorithm and key used */
private Encryption.Context cryptoContext = Encryption.Context.NONE;
@@ -81,7 +81,7 @@ public class HFileContext implements HeapSize, Cloneable {
this.compressTags = context.compressTags;
this.checksumType = context.checksumType;
this.bytesPerChecksum = context.bytesPerChecksum;
- this.blocksize = context.blocksize;
+ this.blockSize = context.blockSize;
this.encoding = context.encoding;
this.cryptoContext = context.cryptoContext;
this.fileCreateTime = context.fileCreateTime;
@@ -103,7 +103,7 @@ public class HFileContext implements HeapSize, Cloneable {
this.compressTags = compressTags;
this.checksumType = checksumType;
this.bytesPerChecksum = bytesPerChecksum;
- this.blocksize = blockSize;
+ this.blockSize = blockSize;
if (encoding != null) {
this.encoding = encoding;
}
@@ -175,7 +175,7 @@ public class HFileContext implements HeapSize, Cloneable {
}
public int getBlocksize() {
- return blocksize;
+ return blockSize;
}
public long getFileCreateTime() {
@@ -233,7 +233,7 @@ public class HFileContext implements HeapSize, Cloneable {
@Override
public HFileContext clone() {
try {
- return (HFileContext) (super.clone());
+ return (HFileContext) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(); // Won't happen
}
@@ -250,7 +250,7 @@ public class HFileContext implements HeapSize, Cloneable {
sb.append(", bytesPerChecksum=");
sb.append(bytesPerChecksum);
sb.append(", blocksize=");
- sb.append(blocksize);
+ sb.append(blockSize);
sb.append(", encoding=");
sb.append(encoding);
sb.append(", includesMvcc=");
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileContextBuilder.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileContextBuilder.java
index 5591f0553b5..97aea8ac0eb 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileContextBuilder.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileContextBuilder.java
@@ -44,11 +44,11 @@ public class HFileContextBuilder {
/** Whether tags to be compressed or not **/
private boolean compressTags = false;
/** the checksum type **/
- private ChecksumType checksumType = ChecksumType.getDefaultChecksumType();
+ private ChecksumType checkSumType = ChecksumType.getDefaultChecksumType();
/** the number of bytes per checksum value **/
private int bytesPerChecksum = DEFAULT_BYTES_PER_CHECKSUM;
/** Number of uncompressed bytes we allow per block. */
- private int blocksize = HConstants.DEFAULT_BLOCKSIZE;
+ private int blockSize = HConstants.DEFAULT_BLOCKSIZE;
private DataBlockEncoding encoding = DataBlockEncoding.NONE;
/** Crypto context */
private Encryption.Context cryptoContext = Encryption.Context.NONE;
@@ -71,9 +71,9 @@ public class HFileContextBuilder {
this.includesTags = hfc.isIncludesTags();
this.compression = hfc.getCompression();
this.compressTags = hfc.isCompressTags();
- this.checksumType = hfc.getChecksumType();
+ this.checkSumType = hfc.getChecksumType();
this.bytesPerChecksum = hfc.getBytesPerChecksum();
- this.blocksize = hfc.getBlocksize();
+ this.blockSize = hfc.getBlocksize();
this.encoding = hfc.getDataBlockEncoding();
this.cryptoContext = hfc.getEncryptionContext();
this.fileCreateTime = hfc.getFileCreateTime();
@@ -109,7 +109,7 @@ public class HFileContextBuilder {
}
public HFileContextBuilder withChecksumType(ChecksumType checkSumType) {
- this.checksumType = checkSumType;
+ this.checkSumType = checkSumType;
return this;
}
@@ -119,7 +119,7 @@ public class HFileContextBuilder {
}
public HFileContextBuilder withBlockSize(int blockSize) {
- this.blocksize = blockSize;
+ this.blockSize = blockSize;
return this;
}
@@ -160,7 +160,7 @@ public class HFileContextBuilder {
public HFileContext build() {
return new HFileContext(usesHBaseChecksum, includesMvcc, includesTags, compression,
- compressTags, checksumType, bytesPerChecksum, blocksize, encoding, cryptoContext,
+ compressTags, checkSumType, bytesPerChecksum, blockSize, encoding, cryptoContext,
fileCreateTime, hfileName, columnFamily, tableName, cellComparator);
}
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/net/Address.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/net/Address.java
index 61b445fcefe..ef3520b31c7 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/net/Address.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/net/Address.java
@@ -18,9 +18,12 @@
package org.apache.hadoop.hbase.net;
import java.net.InetSocketAddress;
+import java.util.Iterator;
+import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.yetus.audience.InterfaceAudience;
+import org.apache.hbase.thirdparty.com.google.common.base.Splitter;
import org.apache.hbase.thirdparty.com.google.common.net.HostAndPort;
/**
@@ -95,11 +98,14 @@ public class Address implements Comparable<Address> {
*/
public String toStringWithoutDomain() {
String hostname = getHostName();
- String[] parts = hostname.split("\\.");
- if (parts.length > 1) {
- for (String part : parts) {
+ List<String> parts = Splitter.on('.').splitToList(hostname);
+ if (parts.size() > 1) {
+ Iterator<String> i = parts.iterator();
+ String base = i.next();
+ while (i.hasNext()) {
+ String part = i.next();
if (!StringUtils.isNumeric(part)) {
- return Address.fromParts(parts[0], getPort()).toString();
+ return Address.fromParts(base, getPort()).toString();
}
}
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/nio/ByteBuff.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/nio/ByteBuff.java
index 2285917364f..27eca9479d6 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/nio/ByteBuff.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/nio/ByteBuff.java
@@ -69,6 +69,7 @@ public abstract class ByteBuff implements HBaseReferenceCounted {
ObjectUtil.checkPositive(refCnt(), REFERENCE_COUNT_NAME);
}
+ @Override
public int refCnt() {
return refCnt.refCnt();
}
@@ -103,27 +104,16 @@ public abstract class ByteBuff implements HBaseReferenceCounted {
/** Returns the total capacity of this ByteBuff. */
public abstract int capacity();
- /**
- * Returns the limit of this ByteBuff
- * @return limit of the ByteBuff
- */
+ /** Returns the limit of this ByteBuff */
public abstract int limit();
- /**
- * Marks the limit of this ByteBuff. n * @return This ByteBuff
- */
+ /** Marks the limit of this ByteBuff */
public abstract ByteBuff limit(int limit);
- /**
- * Rewinds this ByteBuff and the position is set to 0
- * @return this object
- */
+ /** Rewinds this ByteBuff and the position is set to 0 */
public abstract ByteBuff rewind();
- /**
- * Marks the current position of the ByteBuff
- * @return this object
- */
+ /** Marks the current position of the ByteBuff */
public abstract ByteBuff mark();
/**
@@ -156,16 +146,10 @@ public abstract class ByteBuff implements HBaseReferenceCounted {
*/
public abstract void asSubByteBuffer(int offset, int length, ObjectIntPair<ByteBuffer> pair);
- /**
- * Returns the number of elements between the current position and the limit.
- * @return the remaining elements in this ByteBuff
- */
+ /** Returns the number of elements between the current position and the limit. */
public abstract int remaining();
- /**
- * Returns true if there are elements between the current position and the limt
- * @return true if there are elements, false otherwise
- */
+ /** Returns true if there are elements between the current position and the limit. */
public abstract boolean hasRemaining();
/**
@@ -201,31 +185,34 @@ public abstract class ByteBuff implements HBaseReferenceCounted {
/**
* Fetches the byte at the given index. Does not change position of the underlying ByteBuffers n
- * * @return the byte at the given index
+ * @return the byte at the given index
*/
public abstract byte get(int index);
/**
* Fetches the byte at the given offset from current position. Does not change position of the
- * underlying ByteBuffers. n * @return the byte value at the given index.
+ * underlying ByteBuffers.
+ * @return the byte value at the given index.
*/
public abstract byte getByteAfterPosition(int offset);
/**
- * Writes a byte to this ByteBuff at the current position and increments the position n * @return
- * this object
+ * Writes a byte to this ByteBuff at the current position and increments the position
+ * @return this object
*/
public abstract ByteBuff put(byte b);
/**
- * Writes a byte to this ByteBuff at the given index nn * @return this object
+ * Writes a byte to this ByteBuff at the given index
+ * @return this object
*/
public abstract ByteBuff put(int index, byte b);
/**
* Copies the specified number of bytes from this ByteBuff's current position to the byte[]'s
- * offset. Also advances the position of the ByteBuff by the given length. n * @param offset
- * within the current array
+ * offset. Also advances the position of the ByteBuff by the given length.
+ * @param dst the byte[] to which the ByteBuff's content is to be copied
+ * @param offset within the current array
* @param length upto which the bytes to be copied
*/
public abstract void get(byte[] dst, int offset, int length);
@@ -242,13 +229,15 @@ public abstract class ByteBuff implements HBaseReferenceCounted {
/**
* Copies the content from this ByteBuff's current position to the byte array and fills it. Also
- * advances the position of the ByteBuff by the length of the byte[]. n
+ * advances the position of the ByteBuff by the length of the byte[].
+ * @param dst the byte[] to which the ByteBuff's content is to be copied
*/
public abstract void get(byte[] dst);
/**
- * Copies from the given byte[] to this ByteBuff n * @param offset the position in the byte array
- * from which the copy should be done
+ * Copies from the given byte[] to this ByteBuff
+ * @param src source byte array
+ * @param offset the position in the byte array from which the copy should be done
* @param length the length upto which the copy should happen
* @return this ByteBuff
*/
@@ -256,6 +245,8 @@ public abstract class ByteBuff implements HBaseReferenceCounted {
/**
* Copies from the given byte[] to this ByteBuff n * @return this ByteBuff
+ * @param src source byte array
+ * @return this ByteBuff
*/
public abstract ByteBuff put(byte[] src);
@@ -270,8 +261,7 @@ public abstract class ByteBuff implements HBaseReferenceCounted {
/**
* Returns the short value at the current position. Also advances the position by the size of
- * short
- * @return the short value at the current position
+ * short.
*/
public abstract short getShort();
@@ -291,43 +281,37 @@ public abstract class ByteBuff implements HBaseReferenceCounted {
public abstract short getShortAfterPosition(int offset);
/**
- * Returns the int value at the current position. Also advances the position by the size of int
- * @return the int value at the current position
+ * Returns the int value at the current position. Also advances the position by the size of int.
*/
public abstract int getInt();
/**
* Writes an int to this ByteBuff at its current position. Also advances the position by size of
- * int
- * @param value Int value to write
- * @return this object
+ * int.
*/
public abstract ByteBuff putInt(int value);
/**
* Fetches the int at the given index. Does not change position of the underlying ByteBuffers.
* Even if the current int does not fit in the current item we can safely move to the next item
- * and fetch the remaining bytes forming the int n * @return the int value at the given index
+ * and fetch the remaining bytes forming the int.
*/
public abstract int getInt(int index);
/**
* Fetches the int value at the given offset from current position. Does not change position of
- * the underlying ByteBuffers. n * @return the int value at the given index.
+ * the underlying ByteBuffers.
*/
public abstract int getIntAfterPosition(int offset);
/**
- * Returns the long value at the current position. Also advances the position by the size of long
- * @return the long value at the current position
+ * Returns the long value at the current position. Also advances the position by the size of long.
*/
public abstract long getLong();
/**
* Writes a long to this ByteBuff at its current position. Also advances the position by size of
- * long
- * @param value Long value to write
- * @return this object
+ * long.
*/
public abstract ByteBuff putLong(long value);
@@ -347,16 +331,13 @@ public abstract class ByteBuff implements HBaseReferenceCounted {
/**
* Copy the content from this ByteBuff to a byte[].
- * @return byte[] with the copied contents from this ByteBuff.
*/
public byte[] toBytes() {
return toBytes(0, this.limit());
}
/**
- * Copy the content from this ByteBuff to a byte[] based on the given offset and length n * the
- * position from where the copy should start n * the length upto which the copy has to be done
- * @return byte[] with the copied contents from this ByteBuff.
+ * Copy the content from this ByteBuff to a byte[] based on the given offset and length.
*/
public abstract byte[] toBytes(int offset, int length);
@@ -379,25 +360,16 @@ public abstract class ByteBuff implements HBaseReferenceCounted {
*/
public abstract ByteBuff put(int offset, ByteBuff src, int srcOffset, int length);
- /**
- * Reads bytes from the given channel into this ByteBuff n * @return The number of bytes read from
- * the channel n
- */
+ /** Reads bytes from the given channel into this ByteBuf. */
public abstract int read(ReadableByteChannel channel) throws IOException;
- /**
- * Reads bytes from FileChannel into this ByteBuff
- */
+ /** Reads bytes from FileChannel into this ByteBuff */
public abstract int read(FileChannel channel, long offset) throws IOException;
- /**
- * Write this ByteBuff's data into target file
- */
+ /** Write this ByteBuff's data into target file */
public abstract int write(FileChannel channel, long offset) throws IOException;
- /**
- * function interface for Channel read
- */
+ /** Functional interface for Channel read */
@FunctionalInterface
interface ChannelReader {
int read(ReadableByteChannel channel, ByteBuffer buf, long offset) throws IOException;
@@ -438,10 +410,7 @@ public abstract class ByteBuff implements HBaseReferenceCounted {
return (nBytes > 0) ? nBytes : ret;
}
- /**
- * Read integer from ByteBuff coded in 7 bits and increment position.
- * @return Read integer.
- */
+ /** Read integer from ByteBuff coded in 7 bits and increment position. */
public static int readCompressedInt(ByteBuff buf) {
byte b = buf.get();
if ((b & ByteBufferUtils.NEXT_BIT_MASK) != 0) {
@@ -560,9 +529,7 @@ public abstract class ByteBuff implements HBaseReferenceCounted {
return refCnt;
}
- /**
- * Make this private because we don't want to expose the refCnt related wrap method to upstream.
- */
+ // Make this private because we don't want to expose the refCnt related wrap method to upstream.
private static ByteBuff wrap(List<ByteBuffer> buffers, RefCnt refCnt) {
if (buffers == null || buffers.size() == 0) {
throw new IllegalArgumentException("buffers shouldn't be null or empty");
@@ -572,9 +539,7 @@ public abstract class ByteBuff implements HBaseReferenceCounted {
: new MultiByteBuff(refCnt, buffers.toArray(new ByteBuffer[0]));
}
- /**
- * Make this private because we don't want to expose the refCnt related wrap method to upstream.
- */
+ // Make this private because we don't want to expose the refCnt related wrap method to upstream.
private static ByteBuff wrap(ByteBuffer buffer, RefCnt refCnt) {
return new SingleByteBuff(refCnt, buffer);
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/nio/MultiByteBuff.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/nio/MultiByteBuff.java
index 042b21f6c00..c55ee021bd0 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/nio/MultiByteBuff.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/nio/MultiByteBuff.java
@@ -578,9 +578,7 @@ public class MultiByteBuff extends ByteBuff {
/**
* Copies the specified number of bytes from this MBB's current position to the byte[]'s offset.
- * Also advances the position of the MBB by the given length. n * @param offset within the current
- * array
- * @param length upto which the bytes to be copied
+ * Also advances the position of the MBB by the given length.
*/
@Override
public void get(byte[] dst, int offset, int length) {
@@ -878,23 +876,16 @@ public class MultiByteBuff extends ByteBuff {
}
private static byte int0(int x) {
- return (byte) (x);
+ return (byte) x;
}
- /**
- * Copies from the given byte[] to this MBB n * @return this MBB
- */
+ /** Copies from the given byte[] to this MBB */
@Override
public final MultiByteBuff put(byte[] src) {
return put(src, 0, src.length);
}
- /**
- * Copies from the given byte[] to this MBB n * @param offset the position in the byte array from
- * which the copy should be done
- * @param length the length upto which the copy should happen
- * @return this MBB
- */
+ /** Copies from the given byte[] to this MBB. */
@Override
public MultiByteBuff put(byte[] src, int offset, int length) {
checkRefCount();
@@ -965,7 +956,7 @@ public class MultiByteBuff extends ByteBuff {
}
private static byte long0(long x) {
- return (byte) (x);
+ return (byte) x;
}
/**
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfo.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfo.java
index 3e9ffca3f3a..42359372f91 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfo.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfo.java
@@ -58,6 +58,7 @@ public class RSGroupInfo {
}
/**
+ * Constructor
* @deprecated Since 3.0.0, will be removed in 4.0.0. The rsgroup information for a table will be
* stored in the configuration of a table so this will be removed.
*/
@@ -74,52 +75,37 @@ public class RSGroupInfo {
src.configuration.forEach(this::setConfiguration);
}
- /**
- * Get group name.
- */
+ /** Get group name. */
public String getName() {
return name;
}
- /**
- * Adds the given server to the group.
- */
+ /** Adds the given server to the group. */
public void addServer(Address hostPort) {
servers.add(hostPort);
}
- /**
- * Adds the given servers to the group.
- */
+ /** Adds the given servers to the group. */
public void addAllServers(Collection<Address> hostPort) {
servers.addAll(hostPort);
}
- /**
- * @param hostPort hostPort of the server
- * @return true, if a server with hostPort is found
- */
+ /** Returns true if a server with hostPort is found */
public boolean containsServer(Address hostPort) {
return servers.contains(hostPort);
}
- /**
- * Get list of servers.
- */
+ /** Get list of servers. */
public Set<Address> getServers() {
return servers;
}
- /**
- * Remove given server from the group.
- */
+ /** Remove given server from the group. */
public boolean removeServer(Address hostPort) {
return servers.remove(hostPort);
}
- /**
- * Get set of tables that are members of the group.
- */
+ /** Get set of tables that are members of the group. */
public SortedSet<TableName> getTables() {
return tables;
}
@@ -140,9 +126,7 @@ public class RSGroupInfo {
return tables.remove(table);
}
- /**
- * Getter for fetching an unmodifiable {@link #configuration} map.
- */
+ /** Getter for fetching an unmodifiable {@link #configuration} map. */
public Map<String, String> getConfiguration() {
// shallow pointer copy
return Collections.unmodifiableMap(configuration);
@@ -157,9 +141,7 @@ public class RSGroupInfo {
configuration.put(key, Objects.requireNonNull(value));
}
- /**
- * Remove a config setting represented by the key from the {@link #configuration} map
- */
+ /** Remove a config setting represented by the key from the {@link #configuration} map */
public void removeConfiguration(final String key) {
configuration.remove(key);
}
@@ -187,12 +169,10 @@ public class RSGroupInfo {
if (this == o) {
return true;
}
- if (o == null || getClass() != o.getClass()) {
+ if (!(o instanceof RSGroupInfo)) {
return false;
}
-
RSGroupInfo rsGroupInfo = (RSGroupInfo) o;
-
if (!name.equals(rsGroupInfo.name)) {
return false;
}
@@ -205,7 +185,6 @@ public class RSGroupInfo {
if (!configuration.equals(rsGroupInfo.configuration)) {
return false;
}
-
return true;
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/security/Superusers.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/security/Superusers.java
index 11703603587..417c59c7d02 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/security/Superusers.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/security/Superusers.java
@@ -78,6 +78,7 @@ public final class Superusers {
}
/**
+ * Check if the current user is a super user
* @return true if current user is a super user (whether as user running process, declared as
* individual superuser or member of supergroup), false otherwise.
* @param user to check
@@ -104,6 +105,7 @@ public final class Superusers {
}
/**
+ * Check if the current user is a super user
* @return true if current user is a super user, false otherwise.
* @param user to check
*/
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/security/User.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/security/User.java
index e7d37069ac5..9ef9e2ddc17 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/security/User.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/security/User.java
@@ -139,7 +139,7 @@ public abstract class User {
if (this == o) {
return true;
}
- if (o == null || getClass() != o.getClass()) {
+ if (!(o instanceof User)) {
return false;
}
return ugi.equals(((User) o).ugi);
@@ -155,9 +155,7 @@ public abstract class User {
return ugi.toString();
}
- /**
- * Returns the {@code User} instance within current execution context.
- */
+ /** Returns the {@code User} instance within current execution context. */
public static User getCurrent() throws IOException {
User user = new SecureHadoopUser();
if (user.getUGI() == null) {
@@ -166,9 +164,7 @@ public abstract class User {
return user;
}
- /**
- * Executes the given action as the login user n * @return the result of the action n
- */
+ /** Executes the given action as the login user */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static <T> T runAsLoginUser(PrivilegedExceptionAction<T> action) throws IOException {
try {
@@ -324,7 +320,10 @@ public abstract class User {
return ugi.doAs(action);
}
- /** @see User#createUserForTesting(org.apache.hadoop.conf.Configuration, String, String[]) */
+ /**
+ * Create a user for testing.
+ * @see User#createUserForTesting(org.apache.hadoop.conf.Configuration, String, String[])
+ */
public static User createUserForTesting(Configuration conf, String name, String[] groups) {
synchronized (UserProvider.class) {
if (!(UserProvider.groups instanceof TestingGroups)) {
@@ -365,9 +364,7 @@ public abstract class User {
}
}
- /**
- * Returns the result of {@code UserGroupInformation.isSecurityEnabled()}.
- */
+ /** Returns the result of {@code UserGroupInformation.isSecurityEnabled()}. */
public static boolean isSecurityEnabled() {
return UserGroupInformation.isSecurityEnabled();
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/security/UserProvider.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/security/UserProvider.java
index f6766bd1f3c..fcf6cc64896 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/security/UserProvider.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/security/UserProvider.java
@@ -141,7 +141,7 @@ public class UserProvider extends BaseConfigurable {
}
/**
- * @return the userName for the current logged-in user.
+ * Returns the userName for the current logged-in user.
* @throws IOException if the underlying user cannot be obtained
*/
public String getCurrentUserName() throws IOException {
@@ -155,9 +155,9 @@ public class UserProvider extends BaseConfigurable {
}
/**
- * @return whether or not Kerberos authentication is configured for Hadoop. For non-secure Hadoop,
- * this always returns <code>false</code>. For secure Hadoop, it will return the value
- * from {@code UserGroupInformation.isSecurityEnabled()}.
+ * Return whether or not Kerberos authentication is configured for Hadoop. For non-secure Hadoop,
+ * this always returns <code>false</code>. For secure Hadoop, it will return the value from
+ * {@code UserGroupInformation.isSecurityEnabled()}.
*/
public boolean isHadoopSecurityEnabled() {
return User.isSecurityEnabled();
@@ -172,7 +172,7 @@ public class UserProvider extends BaseConfigurable {
}
/**
- * @return the current user within the current execution context
+ * Return the current user within the current execution context
* @throws IOException if the user cannot be loaded
*/
public User getCurrent() throws IOException {
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/types/CopyOnWriteArrayMap.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/types/CopyOnWriteArrayMap.java
index 6b436ba6b19..bc184b1098a 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/types/CopyOnWriteArrayMap.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/types/CopyOnWriteArrayMap.java
@@ -38,6 +38,7 @@ import org.apache.yetus.audience.InterfaceStability;
*/
@InterfaceAudience.Private
@InterfaceStability.Stable
+@SuppressWarnings({ "unchecked", "rawtypes", "hiding", "TypeParameterShadowing" })
public class CopyOnWriteArrayMap<K, V> extends AbstractMap<K, V>
implements Map<K, V>, ConcurrentNavigableMap<K, V> {
private final Comparator<? super K> keyComparator;
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Addressing.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Addressing.java
index 8b9b2205cf7..eee8c6931b3 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Addressing.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Addressing.java
@@ -35,6 +35,7 @@ public class Addressing {
public static final String HOSTNAME_PORT_SEPARATOR = ":";
/**
+ * Create a socket address
* @param hostAndPort Formatted as <code><hostname> ':' <port></code>
* @return An InetSocketInstance
*/
@@ -44,6 +45,7 @@ public class Addressing {
}
/**
+ * Create a host-and-port string
* @param hostname Server hostname
* @param port Server port
* @return Returns a concatenation of <code>hostname</code> and <code>port</code> in following
@@ -56,6 +58,7 @@ public class Addressing {
}
/**
+ * Parse the hostname portion of a host-and-port string
* @param hostAndPort Formatted as <code><hostname> ':' <port></code>
* @return The hostname portion of <code>hostAndPort</code>
*/
@@ -68,6 +71,7 @@ public class Addressing {
}
/**
+ * Parse the port portion of a host-and-port string
* @param hostAndPort Formatted as <code><hostname> ':' <port></code>
* @return The port portion of <code>hostAndPort</code>
*/
@@ -163,9 +167,7 @@ public class Addressing {
: address.toString();
}
- /**
- * Interface for AddressSelectionCondition to check if address is acceptable
- */
+ /** Interface for AddressSelectionCondition to check if address is acceptable */
public interface AddressSelectionCondition {
/**
* Condition on which to accept inet address
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AvlUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AvlUtil.java
index 586b41cc025..020bfbe795e 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AvlUtil.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AvlUtil.java
@@ -84,6 +84,7 @@ public final class AvlUtil {
@InterfaceAudience.Private
public static interface AvlNodeVisitor<TNode extends AvlNode> {
/**
+ * Visitor
* @param node the node that we are currently visiting
* @return false to stop the iteration. true to continue.
*/
@@ -96,6 +97,7 @@ public final class AvlUtil {
@InterfaceAudience.Private
public static class AvlTree {
/**
+ * Return the node that matches the specified key or null in case of node not found.
* @param root the current root of the tree
* @param key the key for the node we are trying to find
* @param keyComparator the comparator to use to match node and key
@@ -117,6 +119,7 @@ public final class AvlUtil {
}
/**
+ * Return the first node of the tree.
* @param root the current root of the tree
* @return the first (min) node of the tree
*/
@@ -130,6 +133,7 @@ public final class AvlUtil {
}
/**
+ * Return the last node of the tree.
* @param root the current root of the tree
* @return the last (max) node of the tree
*/
@@ -325,6 +329,7 @@ public final class AvlUtil {
/**
* Create the iterator starting from the first (min) node of the tree
+ * @param root the current root of the tree
*/
public AvlTreeIterator(final TNode root) {
seekFirst(root);
@@ -448,6 +453,7 @@ public final class AvlUtil {
@InterfaceAudience.Private
public static class AvlIterableList {
/**
+ * Return the successor of the current node
* @param node the current node
* @return the successor of the current node
*/
@@ -456,6 +462,7 @@ public final class AvlUtil {
}
/**
+ * Return the predecessor of the current node
* @param node the current node
* @return the predecessor of the current node
*/
@@ -464,6 +471,7 @@ public final class AvlUtil {
}
/**
+ * Prepend a node to the tree
* @param head the head of the linked list
* @param node the node to add to the front of the list
* @return the new head of the list
@@ -484,6 +492,7 @@ public final class AvlUtil {
}
/**
+ * Append a node to the tree
* @param head the head of the linked list
* @param node the node to add to the tail of the list
* @return the new head of the list
@@ -504,6 +513,7 @@ public final class AvlUtil {
}
/**
+ * Append a list of nodes to the tree
* @param head the head of the current linked list
* @param otherHead the head of the list to append to the current list
* @return the new head of the current list
@@ -522,6 +532,7 @@ public final class AvlUtil {
}
/**
+ * Remove a node from the tree
* @param head the head of the linked list
* @param node the node to remove from the list
* @return the new head of the list
@@ -541,6 +552,7 @@ public final class AvlUtil {
}
/**
+ * Prepend a node to the tree before a specific node
* @param head the head of the linked list
* @param base the node which we want to add the {@code node} before it
* @param node the node which we want to add it before the {@code base} node
@@ -554,10 +566,7 @@ public final class AvlUtil {
return head == base ? node : head;
}
- /**
- * @param node the node to check
- * @return true if the node is linked to a list, false otherwise
- */
+ /** Return true if the node is linked to a list, false otherwise */
public static <TNode extends AvlLinkedNode> boolean isLinked(TNode node) {
return node.iterPrev != null && node.iterNext != null;
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferArray.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferArray.java
index 646c1d26437..18ad1b5c69d 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferArray.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferArray.java
@@ -143,6 +143,7 @@ public class ByteBufferArray {
* Transfer bytes from source {@link ByteBuff} to destination {@link ByteBuffer}. Position of both
* source and destination will be advanced.
*/
+ @SuppressWarnings("UnnecessaryLambda")
private static final BiConsumer<ByteBuffer, ByteBuff> WRITER = (dst, src) -> {
int off = src.position(), len = dst.remaining();
src.get(dst, off, len);
@@ -153,6 +154,7 @@ public class ByteBufferArray {
* Transfer bytes from source {@link ByteBuffer} to destination {@link ByteBuff}, Position of both
* source and destination will be advanced.
*/
+ @SuppressWarnings("UnnecessaryLambda")
private static final BiConsumer<ByteBuffer, ByteBuff> READER = (src, dst) -> {
int off = dst.position(), len = src.remaining(), srcOff = src.position();
dst.put(off, ByteBuff.wrap(src), srcOff, len);
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
index 1955aecf433..f7d35370e80 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
@@ -60,6 +60,7 @@ import org.apache.hbase.thirdparty.org.apache.commons.collections4.CollectionUti
@edu.umd.cs.findbugs.annotations.SuppressWarnings(
value = "EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS",
justification = "It has been like this forever")
+@SuppressWarnings("MixedMutabilityReturnType")
public class Bytes implements Comparable<Bytes> {
// Using the charset canonical name for String/byte[] conversions is much
@@ -199,16 +200,12 @@ public class Bytes implements Comparable<Bytes> {
return this.bytes;
}
- /**
- * @param b Use passed bytes as backing array for this instance.
- */
+ /** Use passed bytes as backing array for this instance. */
public void set(final byte[] b) {
set(b, 0, b.length);
}
- /**
- * @param b Use passed bytes as backing array for this instance. nn
- */
+ /** Use passed bytes as backing array for this instance. */
public void set(final byte[] b, final int offset, final int length) {
this.bytes = b;
this.offset = offset;
@@ -239,9 +236,7 @@ public class Bytes implements Comparable<Bytes> {
return this.length;
}
- /**
- * n
- */
+ /** Return the offset into the buffer. */
public int getOffset() {
return this.offset;
}
@@ -279,9 +274,6 @@ public class Bytes implements Comparable<Bytes> {
return BYTES_RAWCOMPARATOR.compare(this.bytes, this.offset, this.length, that, 0, that.length);
}
- /**
- * @see Object#equals(Object)
- */
@Override
public boolean equals(Object right_obj) {
if (right_obj instanceof byte[]) {
@@ -293,15 +285,13 @@ public class Bytes implements Comparable<Bytes> {
return false;
}
- /**
- * @see Object#toString()
- */
@Override
public String toString() {
return Bytes.toString(bytes, offset, length);
}
/**
+ * Convert a list of byte[] to an array
* @param array List of byte [].
* @return Array of byte [].
*/
@@ -314,21 +304,15 @@ public class Bytes implements Comparable<Bytes> {
return results;
}
- /**
- * Returns a copy of the bytes referred to by this writable
- */
+ /** Returns a copy of the bytes referred to by this writable */
public byte[] copyBytes() {
return Arrays.copyOfRange(bytes, offset, offset + length);
}
- /**
- * Byte array comparator class.
- */
+ /** Byte array comparator class. */
@InterfaceAudience.Public
public static class ByteArrayComparator implements RawComparator<byte[]> {
- /**
- * Constructor
- */
+
public ByteArrayComparator() {
super();
}
@@ -374,14 +358,10 @@ public class Bytes implements Comparable<Bytes> {
}
}
- /**
- * Pass this to TreeMaps where byte [] are keys.
- */
+ /** Pass this to TreeMaps where byte [] are keys. */
public final static Comparator<byte[]> BYTES_COMPARATOR = new ByteArrayComparator();
- /**
- * Use comparing byte arrays, byte-by-byte
- */
+ /** Use comparing byte arrays, byte-by-byte */
public final static RawComparator<byte[]> BYTES_RAWCOMPARATOR = new ByteArrayComparator();
/**
@@ -521,6 +501,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Convert a byte[] into a string. Charset is assumed to be UTF-8.
* @param b Presumed UTF-8 encoded byte array.
* @return String made from <code>b</code>
*/
@@ -817,7 +798,8 @@ public class Bytes implements Comparable<Bytes> {
}
/**
- * Presumes float encoded as IEEE 754 floating-point "single format"
+ * Put a float value out to the specified byte array position. Presumes float encoded as IEEE 754
+ * floating-point "single format"
* @param bytes byte array
* @return Float made from passed byte array.
*/
@@ -826,7 +808,8 @@ public class Bytes implements Comparable<Bytes> {
}
/**
- * Presumes float encoded as IEEE 754 floating-point "single format"
+ * Put a float value out to the specified byte array position. Presumes float encoded as IEEE 754
+ * floating-point "single format"
* @param bytes array to convert
* @param offset offset into array
* @return Float made from passed byte array.
@@ -836,6 +819,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Put a float value out to the specified byte array position.
* @param bytes byte array
* @param offset offset to write to
* @param f float value
@@ -845,33 +829,24 @@ public class Bytes implements Comparable<Bytes> {
return putInt(bytes, offset, Float.floatToRawIntBits(f));
}
- /**
- * @param f float value
- * @return the float represented as byte []
- */
+ /** Return the float represented as byte[] */
public static byte[] toBytes(final float f) {
// Encode it as int
return Bytes.toBytes(Float.floatToRawIntBits(f));
}
- /**
- * @param bytes byte array
- * @return Return double made from passed bytes.
- */
+ /** Return double made from passed bytes. */
public static double toDouble(final byte[] bytes) {
return toDouble(bytes, 0);
}
- /**
- * @param bytes byte array
- * @param offset offset where double is
- * @return Return double made from passed bytes.
- */
+ /** Return double made from passed bytes. */
public static double toDouble(final byte[] bytes, final int offset) {
return Double.longBitsToDouble(toLong(bytes, offset, SIZEOF_LONG));
}
/**
+ * Put a double value out to the specified byte array position as the IEEE 754 double format.
* @param bytes byte array
* @param offset offset to write to
* @param d value
@@ -1142,9 +1117,7 @@ public class Bytes implements Comparable<Bytes> {
return offset + SIZEOF_SHORT;
}
- /**
- * Convert a BigDecimal value to a byte array n * @return the byte array
- */
+ /** Convert a BigDecimal value to a byte array */
public static byte[] toBytes(BigDecimal val) {
byte[] valueBytes = val.unscaledValue().toByteArray();
byte[] result = new byte[valueBytes.length + SIZEOF_INT];
@@ -1153,16 +1126,12 @@ public class Bytes implements Comparable<Bytes> {
return result;
}
- /**
- * Converts a byte array to a BigDecimal n * @return the char value
- */
+ /** Converts a byte array to a BigDecimal */
public static BigDecimal toBigDecimal(byte[] bytes) {
return toBigDecimal(bytes, 0, bytes.length);
}
- /**
- * Converts a byte array to a BigDecimal value nnn * @return the char value
- */
+ /** Converts a byte array to a BigDecimal value */
public static BigDecimal toBigDecimal(byte[] bytes, int offset, final int length) {
if (bytes == null || length < SIZEOF_INT + 1 || (offset + length > bytes.length)) {
return null;
@@ -1193,6 +1162,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Encode a long value as a variable length integer.
* @param vint Integer to make a vint of.
* @return Vint as bytes array.
*/
@@ -1231,6 +1201,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Reads a zero-compressed encoded long from input buffer and returns it.
* @param buffer buffer to convert
* @return vint bytes as an integer.
*/
@@ -1287,6 +1258,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Lexicographically compare two arrays.
* @param left left operand
* @param right right operand
* @return 0 if equal, < 0 if left is less than right, etc.
@@ -1609,6 +1581,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Lexicographically determine the equality of two arrays.
* @param left left operand
* @param right right operand
* @return True if equal
@@ -1629,6 +1602,16 @@ public class Bytes implements Comparable<Bytes> {
return compareTo(left, right) == 0;
}
+ /**
+ * Lexicographically determine the equality of two arrays.
+ * @param left left operand
+ * @param leftOffset offset into left operand
+ * @param leftLen length of left operand
+ * @param right right operand
+ * @param rightOffset offset into right operand
+ * @param rightLen length of right operand
+ * @return True if equal
+ */
public static boolean equals(final byte[] left, int leftOffset, int leftLen, final byte[] right,
int rightOffset, int rightLen) {
// short circuit case
@@ -1653,6 +1636,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Lexicographically determine the equality of two byte[], one as ByteBuffer.
* @param a left operand
* @param buf right operand
* @return True if equal
@@ -1682,6 +1666,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Calculate a hash code from a given byte array.
* @param b bytes to hash
* @return Runs {@link WritableComparator#hashBytes(byte[], int)} on the passed in array. This
* method is what {@link org.apache.hadoop.io.Text} use calculating hash code.
@@ -1691,6 +1676,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Calculate a hash code from a given byte array.
* @param b value
* @param length length of the value
* @return Runs {@link WritableComparator#hashBytes(byte[], int)} on the passed in array. This
@@ -1701,6 +1687,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Calculate a hash code from a given byte array suitable for use as a key in maps.
* @param b bytes to hash
* @return A hash of <code>b</code> as an Integer that can be used as key in Maps.
*/
@@ -1709,6 +1696,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Calculate a hash code from a given byte array suitable for use as a key in maps.
* @param b bytes to hash
* @param length length to hash
* @return A hash of <code>b</code> as an Integer that can be used as key in Maps.
@@ -1718,6 +1706,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Concatenate byte arrays.
* @param a lower half
* @param b upper half
* @return New array that has a in lower half and b in upper half.
@@ -1727,6 +1716,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Concatenate byte arrays.
* @param a first third
* @param b second third
* @param c third third
@@ -1741,6 +1731,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Concatenate byte arrays.
* @param arrays all the arrays to concatenate together.
* @return New array made from the concatenation of the given arrays.
*/
@@ -1759,6 +1750,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Make a new byte array from a subset of bytes at the head of another.
* @param a array
* @param length amount of bytes to grab
* @return First <code>length</code> bytes from <code>a</code>
@@ -1773,6 +1765,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Make a new byte array from a subset of bytes at the tail of another.
* @param a array
* @param length amount of bytes to snarf
* @return Last <code>length</code> bytes from <code>a</code>
@@ -1787,6 +1780,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Make a new byte array from a subset of bytes at the head of another, zero padded as desired.
* @param a array
* @param length new array size
* @return Value in <code>a</code> plus <code>length</code> prepended 0 bytes
@@ -1800,6 +1794,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Make a new byte array from a subset of bytes at the tail of another, zero padded as desired.
* @param a array
* @param length new array size
* @return Value in <code>a</code> plus <code>length</code> appended 0 bytes
@@ -1945,6 +1940,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Calculate the hash code for a given range of bytes.
* @param bytes array to hash
* @param offset offset to start from
* @param length length to hash
@@ -1957,6 +1953,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Create an array of byte[] given an array of String.
* @param t operands
* @return Array of byte arrays made from passed array of Text
*/
@@ -1969,6 +1966,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Create an array of byte[] given an array of String.
* @param t operands
* @return Array of binary byte arrays made from passed array of binary strings
*/
@@ -1981,6 +1979,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Create a byte[][] where first and only entry is <code>column</code>
* @param column operand
* @return A byte array of a byte array where first and only entry is <code>column</code>
*/
@@ -1989,6 +1988,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Create a byte[][] where first and only entry is <code>column</code>
* @param column operand
* @return A byte array of a byte array where first and only entry is <code>column</code>
*/
@@ -2184,7 +2184,7 @@ public class Bytes implements Comparable<Bytes> {
for (int i = 0; i < value.length; i++) {
int cur = ((int) amo % 256) * sign;
amo = (amo >> 8);
- int val = ((~value[value.length - i - 1]) & 0x0ff) + 1;
+ int val = (~value[value.length - i - 1] & 0x0ff) + 1;
int total = cur - val;
if (total >= 0) {
amo += sign;
@@ -2397,6 +2397,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Return true if target is present as an element anywhere in the given array.
* @param array an array of {@code byte} values, possibly empty
* @param target a primitive {@code byte} value
* @return {@code true} if {@code target} is present as an element anywhere in {@code array}.
@@ -2406,6 +2407,7 @@ public class Bytes implements Comparable<Bytes> {
}
/**
+ * Return true if target is present as an element anywhere in the given array.
* @param array an array of {@code byte} values, possibly empty
* @param target an array of {@code byte}
* @return {@code true} if {@code target} is present anywhere in {@code array}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java
index 6ac3edbc2d7..0b9dcc2f043 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java
@@ -396,7 +396,7 @@ public class ClassSize {
* @return the size estimate, in bytes
*/
private static long estimateBaseFromCoefficients(int[] coeff, boolean debug) {
- long prealign_size = OBJECT + coeff[0] + coeff[2] * REFERENCE;
+ long prealign_size = (long) OBJECT + coeff[0] + coeff[2] * REFERENCE;
// Round up to a multiple of 8
long size = align(prealign_size) + align(coeff[1] * ARRAY);
@@ -429,7 +429,7 @@ public class ClassSize {
* @return smallest number >= input that is a multiple of 8
*/
public static int align(int num) {
- return (int) (align((long) num));
+ return (int) align((long) num);
}
/**
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CommonFSUtils.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CommonFSUtils.java
index fb33e6d6897..93a70e698bc 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CommonFSUtils.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CommonFSUtils.java
@@ -78,7 +78,7 @@ public final class CommonFSUtils {
*/
public static boolean isStartingWithPath(final Path rootPath, final String path) {
String uriRootPath = rootPath.toUri().getPath();
- String tailUriPath = (new Path(path)).toUri().getPath();
+ String tailUriPath = new Path(path).toUri().getPath();
return tailUriPath.startsWith(uriRootPath);
}
@@ -283,6 +283,7 @@ public final class CommonFSUtils {
}
/**
+ * Get the path for the root data directory
* @param c configuration
* @return {@link Path} to hbase root directory from configuration as a qualified Path.
* @throws IOException e
@@ -311,6 +312,7 @@ public final class CommonFSUtils {
}
/**
+ * Get the path for the root directory for WAL data
* @param c configuration
* @return {@link Path} to hbase log root directory: e.g. {@value HBASE_WAL_DIR} from
* configuration as a qualified Path. Defaults to HBase root dir.
@@ -554,8 +556,7 @@ public final class CommonFSUtils {
}
/**
- * @param conf must not be null
- * @return True if this filesystem whose scheme is 'hdfs'.
+ * Return true if this is a filesystem whose scheme is 'hdfs'.
* @throws IOException from underlying FileSystem
*/
public static boolean isHDFS(final Configuration conf) throws IOException {
@@ -574,8 +575,7 @@ public final class CommonFSUtils {
}
/**
- * @param conf must not be null
- * @return Returns the filesystem of the hbase rootdir.
+ * Returns the filesystem of the hbase rootdir.
* @throws IOException from underlying FileSystem
*/
public static FileSystem getCurrentFileSystem(Configuration conf) throws IOException {
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/DNS.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/DNS.java
index 49a8a256b2b..d78df01c82f 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/DNS.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/DNS.java
@@ -43,6 +43,7 @@ public final class DNS {
private static Method GET_DEFAULT_HOST_METHOD;
/**
+ * Hostname configuration key
* @deprecated since 2.4.0 and will be removed in 4.0.0. Use {@link DNS#UNSAFE_RS_HOSTNAME_KEY}
* instead.
* @see <a href="https://issues.apache.org/jira/browse/HBASE-24667">HBASE-24667</a>
@@ -65,9 +66,9 @@ public final class DNS {
MASTER("master"),
REGIONSERVER("regionserver");
- private String name;
+ private final String name;
- ServerType(String name) {
+ private ServerType(String name) {
this.name = name;
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ExceptionUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ExceptionUtil.java
index d3b0e82b1dc..484f9aa6b97 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ExceptionUtil.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ExceptionUtil.java
@@ -46,9 +46,7 @@ public final class ExceptionUtil {
return (t instanceof InterruptedIOException || t instanceof ClosedByInterruptException);
}
- /**
- * @throws InterruptedIOException if t was an interruption. Does nothing otherwise.
- */
+ /** Throw InterruptedIOException if t was an interruption, nothing otherwise. */
public static void rethrowIfInterrupt(Throwable t) throws InterruptedIOException {
InterruptedIOException iie = asInterrupt(t);
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ExponentialMovingAverage.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ExponentialMovingAverage.java
index e49e84c9b59..8435cdca151 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ExponentialMovingAverage.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ExponentialMovingAverage.java
@@ -24,7 +24,7 @@ import org.apache.yetus.audience.InterfaceAudience;
* exponentially. It brings benefits that it is more sensitive, and can see the trends easily.
*/
@InterfaceAudience.Private
-public class ExponentialMovingAverage extends WindowMovingAverage {
+public class ExponentialMovingAverage<T> extends WindowMovingAverage<T> {
private double alpha;
private double previousAverage;
private double currentAverage;
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Hash.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Hash.java
index bdb33ee1634..d692d712dcd 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Hash.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Hash.java
@@ -94,7 +94,6 @@ public abstract class Hash {
/**
* Calculate a hash using bytes from HashKey and the provided seed value.
- * @param <T>
* @param hashKey key to extract the hash
* @param initval the seed value
* @return hash value
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/HashKey.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/HashKey.java
index e4e89f7711f..9f12acb0b67 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/HashKey.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/HashKey.java
@@ -21,7 +21,6 @@ import org.apache.yetus.audience.InterfaceAudience;
/**
* Used to calculate the hash {@link Hash} algorithms for Bloomfilters.
- * @param <T> the type of HashKey
*/
@InterfaceAudience.Private
public abstract class HashKey<T> {
@@ -31,9 +30,7 @@ public abstract class HashKey<T> {
this.t = t;
}
- /**
- * n * @return The byte at the given position in this HashKey
- */
+ /** Return The byte at the given position in this HashKey */
public abstract byte get(int pos);
/** Returns The number of bytes in this HashKey */
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/JRubyFormat.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/JRubyFormat.java
index 5e940702427..5e7abba3935 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/JRubyFormat.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/JRubyFormat.java
@@ -27,12 +27,12 @@ import org.apache.hbase.thirdparty.com.google.common.escape.Escapers;
/**
* Utility class for converting objects to JRuby. It handles null, Boolean, Number, String, byte[],
- * List<Object>, Map<String, Object> structures.
+ * List<Object>, Map<String, Object> structures.
* <p>
* E.g.
*
* <pre>
- * Map<String, Object> map = new LinkedHashMap<>();
+ * Map<String, Object> map = new LinkedHashMap<>();
* map.put("null", null);
* map.put("boolean", true);
* map.put("number", 1);
@@ -45,8 +45,8 @@ import org.apache.hbase.thirdparty.com.google.common.escape.Escapers;
* Calling {@link #print(Object)} method will result:
*
* <pre>
- * { null => '', boolean => 'true', number => '1', string => 'str',
- * binary => '010203', list => [ '1', '2', 'true' ] }
+ * { null => '', boolean => 'true', number => '1', string => 'str',
+ * binary => '010203', list => [ '1', '2', 'true' ] }
* </pre>
* </p>
*/
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/JVM.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/JVM.java
index 2104511b4f2..fbad0da62a7 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/JVM.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/JVM.java
@@ -26,10 +26,13 @@ import java.lang.management.OperatingSystemMXBean;
import java.lang.management.RuntimeMXBean;
import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;
+import java.util.Iterator;
import org.apache.yetus.audience.InterfaceAudience;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.apache.hbase.thirdparty.com.google.common.base.Splitter;
+
/**
* This class is a wrapper for the implementation of com.sun.management.UnixOperatingSystemMXBean It
* will decide to use the sun api or its own implementation depending on the runtime (vendor) used.
@@ -167,11 +170,10 @@ public class JVM {
// need to get the PID number of the process first
RuntimeMXBean rtmbean = ManagementFactory.getRuntimeMXBean();
String rtname = rtmbean.getName();
- String[] pidhost = rtname.split("@");
-
+ Iterator<String> pidhost = Splitter.on('@').split(rtname).iterator();
// using linux bash commands to retrieve info
Process p = Runtime.getRuntime()
- .exec(new String[] { "bash", "-c", "ls /proc/" + pidhost[0] + "/fdinfo | wc -l" });
+ .exec(new String[] { "bash", "-c", "ls /proc/" + pidhost.next() + "/fdinfo | wc -l" });
inputStream = p.getInputStream();
inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
bufferedReader = new BufferedReader(inputStreamReader);
@@ -208,6 +210,7 @@ public class JVM {
}
/**
+ * Get the system load average
* @see java.lang.management.OperatingSystemMXBean#getSystemLoadAverage
*/
public double getSystemLoadAverage() {
@@ -215,9 +218,9 @@ public class JVM {
}
/**
- * @return the physical free memory (not the JVM one, as it's not very useful as it depends on the
- * GC), but the one from the OS as it allows a little bit more to guess if the machine is
- * overloaded or not).
+ * Return the physical free memory (not the JVM one, as it's not very useful as it depends on the
+ * GC), but the one from the OS as it allows a little bit more to guess if the machine is
+ * overloaded or not).
*/
public long getFreeMemory() {
if (ibmvendor) {
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/MD5Hash.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/MD5Hash.java
index 8202c96b289..d967f5d53a7 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/MD5Hash.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/MD5Hash.java
@@ -21,15 +21,12 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.apache.commons.codec.binary.Hex;
import org.apache.yetus.audience.InterfaceAudience;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Utility class for MD5 MD5 hash produces a 128-bit digest.
*/
@InterfaceAudience.Public
public class MD5Hash {
- private static final Logger LOG = LoggerFactory.getLogger(MD5Hash.class);
/**
* Given a byte array, returns in MD5 hash as a hex string. n * @return SHA1 hash as a 32
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/OrderedBytes.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/OrderedBytes.java
index edb62a58d52..1788bb40bd5 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/OrderedBytes.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/OrderedBytes.java
@@ -648,7 +648,6 @@ public class OrderedBytes {
byte[] a = dst.getBytes();
boolean isNeg = val.signum() == -1;
final int offset = dst.getOffset(), start = dst.getPosition();
- int e = 0, startM;
if (isNeg) { /* Small negative number: 0x14, -E, ~M */
dst.put(NEG_SMALL);
@@ -660,13 +659,13 @@ public class OrderedBytes {
int zerosBeforeFirstNonZero = abs.scale() - abs.precision();
int lengthToMoveRight =
zerosBeforeFirstNonZero % 2 == 0 ? zerosBeforeFirstNonZero : zerosBeforeFirstNonZero - 1;
- e = lengthToMoveRight / 2;
+ int e = lengthToMoveRight / 2;
abs = abs.movePointRight(lengthToMoveRight);
putVaruint64(dst, e, !isNeg); // encode appropriate E value.
// encode M by peeling off centimal digits, encoding x as 2x+1
- startM = dst.getPosition();
+ int startM = dst.getPosition();
encodeToCentimal(dst, abs);
// terminal digit should be 2x
a[offset + dst.getPosition() - 1] = (byte) (a[offset + dst.getPosition() - 1] & 0xfe);
@@ -700,8 +699,8 @@ public class OrderedBytes {
* calling function.
*
* <pre>
- * Encoding: M (if E<=10)
- * E M (if E>10)
+ * Encoding: M (if E<=10)
+ * E M (if E>10)
* </pre>
* </p>
* @param dst The destination to which encoded digits are written.
@@ -714,7 +713,6 @@ public class OrderedBytes {
byte[] a = dst.getBytes();
boolean isNeg = val.signum() == -1;
final int start = dst.getPosition(), offset = dst.getOffset();
- int e = 0, startM;
if (isNeg) { /* Large negative number: 0x08, ~E, ~M */
dst.put(NEG_LARGE);
@@ -725,7 +723,7 @@ public class OrderedBytes {
// normalize abs(val) to determine E
int integerDigits = abs.precision() - abs.scale();
int lengthToMoveLeft = integerDigits % 2 == 0 ? integerDigits : integerDigits + 1;
- e = lengthToMoveLeft / 2;
+ int e = lengthToMoveLeft / 2;
abs = abs.movePointLeft(lengthToMoveLeft);
// encode appropriate header byte and/or E value.
@@ -740,7 +738,7 @@ public class OrderedBytes {
}
// encode M by peeling off centimal digits, encoding x as 2x+1
- startM = dst.getPosition();
+ int startM = dst.getPosition();
encodeToCentimal(dst, abs);
// terminal digit should be 2x
a[offset + dst.getPosition() - 1] = (byte) (a[offset + dst.getPosition() - 1] & 0xfe);
@@ -753,7 +751,7 @@ public class OrderedBytes {
/**
* Encode a value val in [0.01, 1.0) into Centimals. Util function for
- * {@link OrderedBytes#encodeNumericLarge(PositionedByteRange, BigDecimal) and
+ * {@link OrderedBytes#encodeNumericLarge(PositionedByteRange, BigDecimal)} and
* {@link OrderedBytes#encodeNumericSmall(PositionedByteRange, BigDecimal)}
* @param dst The destination to which encoded digits are written.
* @param val A BigDecimal after the normalization. The value must be in [0.01, 1.0).
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Pair.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Pair.java
index 2d55d572ff6..dd8eb4f1858 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Pair.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Pair.java
@@ -22,8 +22,6 @@ import org.apache.yetus.audience.InterfaceAudience;
/**
* A generic class for pairs.
- * @param <T1>
- * @param <T2>
*/
@InterfaceAudience.Public
public class Pair<T1, T2> implements Serializable {
@@ -102,9 +100,13 @@ public class Pair<T1, T2> implements Serializable {
@Override
public int hashCode() {
- if (first == null) return (second == null) ? 0 : second.hashCode() + 1;
- else if (second == null) return first.hashCode() + 2;
- else return first.hashCode() * 17 + second.hashCode();
+ if (first == null) {
+ return (second == null) ? 0 : second.hashCode() + 1;
+ } else if (second == null) {
+ return first.hashCode() + 2;
+ } else {
+ return first.hashCode() * 17 + second.hashCode();
+ }
}
@Override
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/PairOfSameType.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/PairOfSameType.java
index 745bd759c76..44bc2b81dc0 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/PairOfSameType.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/PairOfSameType.java
@@ -24,7 +24,6 @@ import org.apache.yetus.audience.InterfaceAudience;
/**
* A generic, immutable class for pairs of objects both of type <code>T</code>.
- * @param <T>
* @see Pair if Types differ.
*/
@InterfaceAudience.Public
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ReflectionUtils.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ReflectionUtils.java
index 6b8ef990f94..7349b81133a 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ReflectionUtils.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ReflectionUtils.java
@@ -33,7 +33,7 @@ import org.slf4j.Logger;
@InterfaceAudience.Private
public class ReflectionUtils {
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({ "unchecked", "TypeParameterUnusedInFormals" })
public static <T> T instantiateWithCustomCtor(String className, Class<?>[] ctorArgTypes,
Object[] ctorArgs) {
try {
@@ -62,7 +62,7 @@ public class ReflectionUtils {
}
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({ "unchecked", "TypeParameterUnusedInFormals" })
public static <T> T newInstance(String className, Object... params) {
Class<T> type;
try {
@@ -106,7 +106,7 @@ public class ReflectionUtils {
match = !ctorParamTypes[i].isPrimitive();
} else {
Class<?> paramType = paramTypes[i].getClass();
- match = (!ctorParamTypes[i].isPrimitive())
+ match = !ctorParamTypes[i].isPrimitive()
? ctorParamTypes[i].isAssignableFrom(paramType)
: ((int.class.equals(ctorParamTypes[i]) && Integer.class.equals(paramType))
|| (long.class.equals(ctorParamTypes[i]) && Long.class.equals(paramType))
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/SimpleMovingAverage.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/SimpleMovingAverage.java
index eb7eb314e0e..cd7d4260cb1 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/SimpleMovingAverage.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/SimpleMovingAverage.java
@@ -23,7 +23,7 @@ import org.apache.yetus.audience.InterfaceAudience;
* SMA measure the overall average execution time of a specific method.
*/
@InterfaceAudience.Private
-public class SimpleMovingAverage extends MovingAverage {
+public class SimpleMovingAverage<T> extends MovingAverage<T> {
private double averageTime = 0.0;
protected long count = 0;
@@ -35,7 +35,7 @@ public class SimpleMovingAverage extends MovingAverage {
@Override
public void updateMostRecentTime(long elapsed) {
- averageTime += (elapsed - averageTime) / (++count);
+ averageTime += (elapsed - averageTime) / ++count;
}
@Override
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Threads.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Threads.java
index 565614e2730..d147f660f5a 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Threads.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Threads.java
@@ -101,9 +101,7 @@ public class Threads {
}
}
- /**
- * @param t Waits on the passed thread to die dumping a threaddump every minute while its up. n
- */
+ /** Waits on the passed thread to die dumping a threaddump every minute while its up. */
public static void threadDumpingIsAlive(final Thread t) throws InterruptedException {
if (t == null) {
return;
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Triple.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Triple.java
index d1e225238e6..e0e094337c2 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Triple.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Triple.java
@@ -61,11 +61,11 @@ public class Triple<A, B, C> {
Triple<?, ?, ?> otherTriple = (Triple<?, ?, ?>) obj;
- if (first != otherTriple.first && (first != null && !(first.equals(otherTriple.first))))
+ if (first != otherTriple.first && (first != null && !first.equals(otherTriple.first)))
return false;
- if (second != otherTriple.second && (second != null && !(second.equals(otherTriple.second))))
+ if (second != otherTriple.second && (second != null && !second.equals(otherTriple.second)))
return false;
- if (third != otherTriple.third && (third != null && !(third.equals(otherTriple.third))))
+ if (third != otherTriple.third && (third != null && !third.equals(otherTriple.third)))
return false;
return true;
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/VersionInfo.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/VersionInfo.java
index ae19e2a641c..60a37af6048 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/VersionInfo.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/VersionInfo.java
@@ -19,12 +19,16 @@ package org.apache.hadoop.hbase.util;
import java.io.PrintStream;
import java.io.PrintWriter;
+import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.hbase.Version;
import org.apache.yetus.audience.InterfaceAudience;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.apache.hbase.thirdparty.com.google.common.base.Splitter;
+import org.apache.hbase.thirdparty.com.google.common.collect.Iterables;
+
/**
* This class finds the Version information for HBase.
*/
@@ -137,9 +141,9 @@ public class VersionInfo {
*/
private static String[] getVersionComponents(final String version) {
assert (version != null);
- String[] strComps = version.split("[\\.-]");
+ List<String> list = Splitter.onPattern("[\\.-]").splitToList(version);
+ String[] strComps = list.toArray(new String[list.size()]);
assert (strComps.length > 0);
-
String[] comps = new String[strComps.length];
for (int i = 0; i < strComps.length; ++i) {
if (StringUtils.isNumeric(strComps[i])) {
@@ -162,7 +166,7 @@ public class VersionInfo {
}
public static int getMajorVersion(String version) {
- return Integer.parseInt(version.split("\\.")[0]);
+ return Integer.parseInt(Iterables.get(Splitter.on('.').split(version), 0));
}
public static void main(String[] args) {
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/WeightedMovingAverage.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/WeightedMovingAverage.java
index 27d5b899481..8288bf753af 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/WeightedMovingAverage.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/WeightedMovingAverage.java
@@ -24,7 +24,7 @@ import org.apache.yetus.audience.InterfaceAudience;
* weight. And it is based on {@link WindowMovingAverage}, such that it only focus on the last N.
*/
@InterfaceAudience.Private
-public class WeightedMovingAverage extends WindowMovingAverage {
+public class WeightedMovingAverage<T> extends WindowMovingAverage<T> {
private int[] coefficient;
private int denominator;
@@ -53,8 +53,8 @@ public class WeightedMovingAverage extends WindowMovingAverage {
int coIndex = 0;
int length = getNumberOfStatistics();
// tmIndex, it points to the oldest data.
- for (int tmIndex = (getMostRecentPosistion() + 1) % length; coIndex
- < length; coIndex++, tmIndex = (++tmIndex) % length) {
+ for (int tmIndex = (getMostRecentPosition() + 1) % length; coIndex
+ < length; coIndex++, tmIndex = ++tmIndex % length) {
// start the multiplication from oldest to newest
average += coefficient[coIndex] * getStatisticsAtIndex(tmIndex);
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/WindowMovingAverage.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/WindowMovingAverage.java
index b79924a352c..154bc0e42db 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/WindowMovingAverage.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/WindowMovingAverage.java
@@ -24,7 +24,7 @@ import org.apache.yetus.audience.InterfaceAudience;
* in a circle array.
*/
@InterfaceAudience.Private
-public class WindowMovingAverage extends MovingAverage {
+public class WindowMovingAverage<T> extends MovingAverage<T> {
protected final static int DEFAULT_SIZE = 5;
// The last n statistics.
@@ -47,7 +47,7 @@ public class WindowMovingAverage extends MovingAverage {
@Override
protected void updateMostRecentTime(long elapsed) {
- int index = moveForwardMostRecentPosistion();
+ int index = moveForwardMostRecentPosition();
lastN[index] = elapsed;
}
@@ -55,7 +55,7 @@ public class WindowMovingAverage extends MovingAverage {
public double getAverageTime() {
return enoughStatistics()
? (double) sum(getNumberOfStatistics()) / getNumberOfStatistics()
- : (double) sum(getMostRecentPosistion() + 1) / (getMostRecentPosistion() + 1);
+ : (double) sum(getMostRecentPosition() + 1) / (getMostRecentPosition() + 1);
}
/**
@@ -84,7 +84,7 @@ public class WindowMovingAverage extends MovingAverage {
}
/** Returns index of most recent */
- protected int getMostRecentPosistion() {
+ protected int getMostRecentPosition() {
return mostRecent;
}
@@ -92,7 +92,7 @@ public class WindowMovingAverage extends MovingAverage {
* Move forward the most recent index.
* @return the most recent index
*/
- protected int moveForwardMostRecentPosistion() {
+ protected int moveForwardMostRecentPosition() {
int index = ++mostRecent;
if (!oneRound && index == getNumberOfStatistics()) {
// Back to the head of the lastN, from now on will
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java
index fc152be962c..29977997389 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java
@@ -18,6 +18,7 @@
package org.apache.hadoop.hbase.zookeeper;
import java.io.IOException;
+import java.util.List;
import java.util.Map.Entry;
import java.util.Properties;
import org.apache.hadoop.conf.Configuration;
@@ -25,6 +26,8 @@ import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.util.StringUtils;
import org.apache.yetus.audience.InterfaceAudience;
+import org.apache.hbase.thirdparty.com.google.common.base.Splitter;
+
/**
* Utility methods for reading, and building the ZooKeeper configuration. The order and priority for
* reading the config are as follows: (1). Property with "hbase.zookeeper.property." prefix from
@@ -169,27 +172,28 @@ public final class ZKConfig {
* the described order n
*/
public static ZKClusterKey transformClusterKey(String key) throws IOException {
- String[] parts = key.split(":");
+ List<String> parts = Splitter.on(':').splitToList(key);
+ String[] partsArray = parts.toArray(new String[parts.size()]);
- if (parts.length == 3) {
- if (!parts[2].matches("/.*[^/]")) {
+ if (partsArray.length == 3) {
+ if (!partsArray[2].matches("/.*[^/]")) {
throw new IOException("Cluster key passed " + key + " is invalid, the format should be:"
+ HConstants.ZOOKEEPER_QUORUM + ":" + HConstants.ZOOKEEPER_CLIENT_PORT + ":"
+ HConstants.ZOOKEEPER_ZNODE_PARENT);
}
- return new ZKClusterKey(parts[0], Integer.parseInt(parts[1]), parts[2]);
+ return new ZKClusterKey(partsArray[0], Integer.parseInt(partsArray[1]), partsArray[2]);
}
- if (parts.length > 3) {
+ if (partsArray.length > 3) {
// The quorum could contain client port in server:clientport format, try to transform more.
- String zNodeParent = parts[parts.length - 1];
+ String zNodeParent = partsArray[partsArray.length - 1];
if (!zNodeParent.matches("/.*[^/]")) {
throw new IOException("Cluster key passed " + key + " is invalid, the format should be:"
+ HConstants.ZOOKEEPER_QUORUM + ":" + HConstants.ZOOKEEPER_CLIENT_PORT + ":"
+ HConstants.ZOOKEEPER_ZNODE_PARENT);
}
- String clientPort = parts[parts.length - 2];
+ String clientPort = partsArray[partsArray.length - 2];
// The first part length is the total length minus the lengths of other parts and minus 2 ":"
int endQuorumIndex = key.length() - zNodeParent.length() - clientPort.length() - 2;
@@ -199,7 +203,7 @@ public final class ZKConfig {
// The common case is that every server has its own client port specified - this means
// that (total parts - the ZNodeParent part - the ClientPort part) is equal to
// (the number of "," + 1) - "+ 1" because the last server has no ",".
- if ((parts.length - 2) == (serverHosts.length + 1)) {
+ if ((partsArray.length - 2) == (serverHosts.length + 1)) {
return new ZKClusterKey(quorumStringInput, Integer.parseInt(clientPort), zNodeParent);
}
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestByteBufferKeyValue.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestByteBufferKeyValue.java
index 5292ba56056..dcf7d9e5256 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestByteBufferKeyValue.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestByteBufferKeyValue.java
@@ -25,7 +25,6 @@ import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentSkipListMap;
-import org.apache.hadoop.hbase.KeyValue.Type;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.ByteBufferUtils;
@@ -81,11 +80,18 @@ public class TestByteBufferKeyValue {
map.put((ByteBufferKeyValue) cell2, (ByteBufferKeyValue) cell2);
map.put((ByteBufferKeyValue) cell3, (ByteBufferKeyValue) cell3);
map.put((ByteBufferKeyValue) cell1, (ByteBufferKeyValue) cell1);
- map.put((ByteBufferKeyValue) cell1, (ByteBufferKeyValue) cell1);
+ map.put((ByteBufferKeyValue) cell1, (ByteBufferKeyValue) cell4);
+ assertEquals(3, map.size());
+ assertTrue(map.containsKey(cell1));
+ assertTrue(map.containsKey(cell2));
+ assertTrue(map.containsKey(cell3));
+ assertEquals(cell4, map.get(cell1));
+ assertEquals(cell2, map.get(cell2));
+ assertEquals(cell3, map.get(cell3));
}
private static Cell getOffheapCell(byte[] row, byte[] family, byte[] qualifier) {
- KeyValue kvCell = new KeyValue(row, family, qualifier, 0L, Type.Put, row);
+ KeyValue kvCell = new KeyValue(row, family, qualifier, 0L, KeyValue.Type.Put, row);
ByteBuffer buf = ByteBuffer.allocateDirect(kvCell.getBuffer().length);
ByteBufferUtils.copyFromArrayToBuffer(buf, kvCell.getBuffer(), 0, kvCell.getBuffer().length);
return new ByteBufferKeyValue(buf, 0, buf.capacity(), 0L);
@@ -93,7 +99,7 @@ public class TestByteBufferKeyValue {
@Test
public void testByteBufferBackedKeyValue() throws Exception {
- KeyValue kvCell = new KeyValue(row1, fam1, qual1, 0L, Type.Put, row1);
+ KeyValue kvCell = new KeyValue(row1, fam1, qual1, 0L, KeyValue.Type.Put, row1);
ByteBuffer buf = ByteBuffer.allocateDirect(kvCell.getBuffer().length);
ByteBufferUtils.copyFromArrayToBuffer(buf, kvCell.getBuffer(), 0, kvCell.getBuffer().length);
ByteBufferExtendedCell offheapKV = new ByteBufferKeyValue(buf, 0, buf.capacity(), 0L);
@@ -106,7 +112,7 @@ public class TestByteBufferKeyValue {
assertEquals(ROW1, ByteBufferUtils.toStringBinary(offheapKV.getValueByteBuffer(),
offheapKV.getValuePosition(), offheapKV.getValueLength()));
assertEquals(0L, offheapKV.getTimestamp());
- assertEquals(Type.Put.getCode(), offheapKV.getTypeByte());
+ assertEquals(KeyValue.Type.Put.getCode(), offheapKV.getTypeByte());
// Use the array() APIs
assertEquals(ROW1, Bytes.toStringBinary(offheapKV.getRowArray(), offheapKV.getRowOffset(),
@@ -118,9 +124,9 @@ public class TestByteBufferKeyValue {
assertEquals(ROW1, Bytes.toStringBinary(offheapKV.getValueArray(), offheapKV.getValueOffset(),
offheapKV.getValueLength()));
assertEquals(0L, offheapKV.getTimestamp());
- assertEquals(Type.Put.getCode(), offheapKV.getTypeByte());
+ assertEquals(KeyValue.Type.Put.getCode(), offheapKV.getTypeByte());
- kvCell = new KeyValue(row1, fam2, qual2, 0L, Type.Put, row1);
+ kvCell = new KeyValue(row1, fam2, qual2, 0L, KeyValue.Type.Put, row1);
buf = ByteBuffer.allocateDirect(kvCell.getBuffer().length);
ByteBufferUtils.copyFromArrayToBuffer(buf, kvCell.getBuffer(), 0, kvCell.getBuffer().length);
offheapKV = new ByteBufferKeyValue(buf, 0, buf.capacity(), 0L);
@@ -129,7 +135,7 @@ public class TestByteBufferKeyValue {
assertEquals(QUAL2, ByteBufferUtils.toStringBinary(offheapKV.getQualifierByteBuffer(),
offheapKV.getQualifierPosition(), offheapKV.getQualifierLength()));
byte[] nullQualifier = new byte[0];
- kvCell = new KeyValue(row1, fam1, nullQualifier, 0L, Type.Put, row1);
+ kvCell = new KeyValue(row1, fam1, nullQualifier, 0L, KeyValue.Type.Put, row1);
buf = ByteBuffer.allocateDirect(kvCell.getBuffer().length);
ByteBufferUtils.copyFromArrayToBuffer(buf, kvCell.getBuffer(), 0, kvCell.getBuffer().length);
offheapKV = new ByteBufferKeyValue(buf, 0, buf.capacity(), 0L);
@@ -142,12 +148,12 @@ public class TestByteBufferKeyValue {
assertEquals(ROW1, ByteBufferUtils.toStringBinary(offheapKV.getValueByteBuffer(),
offheapKV.getValuePosition(), offheapKV.getValueLength()));
assertEquals(0L, offheapKV.getTimestamp());
- assertEquals(Type.Put.getCode(), offheapKV.getTypeByte());
+ assertEquals(KeyValue.Type.Put.getCode(), offheapKV.getTypeByte());
}
@Test
public void testByteBufferBackedKeyValueWithTags() throws Exception {
- KeyValue kvCell = new KeyValue(row1, fam1, qual1, 0L, Type.Put, row1, tags);
+ KeyValue kvCell = new KeyValue(row1, fam1, qual1, 0L, KeyValue.Type.Put, row1, tags);
ByteBuffer buf = ByteBuffer.allocateDirect(kvCell.getBuffer().length);
ByteBufferUtils.copyFromArrayToBuffer(buf, kvCell.getBuffer(), 0, kvCell.getBuffer().length);
ByteBufferKeyValue offheapKV = new ByteBufferKeyValue(buf, 0, buf.capacity(), 0L);
@@ -160,7 +166,7 @@ public class TestByteBufferKeyValue {
assertEquals(ROW1, ByteBufferUtils.toStringBinary(offheapKV.getValueByteBuffer(),
offheapKV.getValuePosition(), offheapKV.getValueLength()));
assertEquals(0L, offheapKV.getTimestamp());
- assertEquals(Type.Put.getCode(), offheapKV.getTypeByte());
+ assertEquals(KeyValue.Type.Put.getCode(), offheapKV.getTypeByte());
// change tags to handle both onheap and offheap stuff
List<Tag> resTags = PrivateCellUtil.getTags(offheapKV);
Tag tag1 = resTags.get(0);
@@ -169,14 +175,14 @@ public class TestByteBufferKeyValue {
Tag tag2 = resTags.get(1);
assertEquals(tag2.getType(), tag2.getType());
assertEquals(Tag.getValueAsString(t2), Tag.getValueAsString(tag2));
- Tag res = PrivateCellUtil.getTag(offheapKV, (byte) 2).get();
- assertEquals(Tag.getValueAsString(t2), Tag.getValueAsString(tag2));
+ Tag tag3 = PrivateCellUtil.getTag(offheapKV, (byte) 2).get();
+ assertEquals(Tag.getValueAsString(t2), Tag.getValueAsString(tag3));
assertFalse(PrivateCellUtil.getTag(offheapKV, (byte) 3).isPresent());
}
@Test
public void testGetKeyMethods() throws Exception {
- KeyValue kvCell = new KeyValue(row1, fam1, qual1, 0L, Type.Put, row1, tags);
+ KeyValue kvCell = new KeyValue(row1, fam1, qual1, 0L, KeyValue.Type.Put, row1, tags);
ByteBuffer buf = ByteBuffer.allocateDirect(kvCell.getKeyLength());
ByteBufferUtils.copyFromArrayToBuffer(buf, kvCell.getBuffer(), kvCell.getKeyOffset(),
kvCell.getKeyLength());
@@ -188,6 +194,6 @@ public class TestByteBufferKeyValue {
assertEquals(QUAL1, ByteBufferUtils.toStringBinary(offheapKeyOnlyKV.getQualifierByteBuffer(),
offheapKeyOnlyKV.getQualifierPosition(), offheapKeyOnlyKV.getQualifierLength()));
assertEquals(0L, offheapKeyOnlyKV.getTimestamp());
- assertEquals(Type.Put.getCode(), offheapKeyOnlyKV.getTypeByte());
+ assertEquals(KeyValue.Type.Put.getCode(), offheapKeyOnlyKV.getTypeByte());
}
}
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellComparator.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellComparator.java
index 98a376d6d19..f4da9bf2f7b 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellComparator.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellComparator.java
@@ -24,7 +24,6 @@ import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.Set;
import java.util.TreeSet;
-import org.apache.hadoop.hbase.KeyValue.Type;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
@@ -58,51 +57,46 @@ public class TestCellComparator {
public void testCompareCells() {
KeyValue kv1 = new KeyValue(row1, fam1, qual1, val);
KeyValue kv2 = new KeyValue(row2, fam1, qual1, val);
- assertTrue((comparator.compare(kv1, kv2)) < 0);
+ assertTrue(comparator.compare(kv1, kv2) < 0);
kv1 = new KeyValue(row1, fam2, qual1, val);
kv2 = new KeyValue(row1, fam1, qual1, val);
- assertTrue((comparator.compareFamilies(kv1, kv2) > 0));
+ assertTrue(comparator.compareFamilies(kv1, kv2) > 0);
kv1 = new KeyValue(row1, fam1, qual1, 1L, val);
kv2 = new KeyValue(row1, fam1, qual1, 2L, val);
- assertTrue((comparator.compare(kv1, kv2) > 0));
+ assertTrue(comparator.compare(kv1, kv2) > 0);
- kv1 = new KeyValue(row1, fam1, qual1, 1L, Type.Put);
- kv2 = new KeyValue(row1, fam1, qual1, 1L, Type.Maximum);
- assertTrue((comparator.compare(kv1, kv2) > 0));
+ kv1 = new KeyValue(row1, fam1, qual1, 1L, KeyValue.Type.Put);
+ kv2 = new KeyValue(row1, fam1, qual1, 1L, KeyValue.Type.Maximum);
+ assertTrue(comparator.compare(kv1, kv2) > 0);
- kv1 = new KeyValue(row1, fam1, qual1, 1L, Type.Put);
- kv2 = new KeyValue(row1, fam1, qual1, 1L, Type.Put);
- assertTrue((CellUtil.equals(kv1, kv2)));
+ kv1 = new KeyValue(row1, fam1, qual1, 1L, KeyValue.Type.Put);
+ kv2 = new KeyValue(row1, fam1, qual1, 1L, KeyValue.Type.Put);
+ assertTrue(CellUtil.equals(kv1, kv2));
}
@Test
public void testCompareCellWithKey() throws Exception {
KeyValue kv1 = new KeyValue(row1, fam1, qual1, val);
KeyValue kv2 = new KeyValue(row2, fam1, qual1, val);
- assertTrue(
- (PrivateCellUtil.compare(comparator, kv1, kv2.getKey(), 0, kv2.getKey().length)) < 0);
+ assertTrue(PrivateCellUtil.compare(comparator, kv1, kv2.getKey(), 0, kv2.getKey().length) < 0);
kv1 = new KeyValue(row1, fam2, qual1, val);
kv2 = new KeyValue(row1, fam1, qual1, val);
- assertTrue(
- (PrivateCellUtil.compare(comparator, kv1, kv2.getKey(), 0, kv2.getKey().length)) > 0);
+ assertTrue(PrivateCellUtil.compare(comparator, kv1, kv2.getKey(), 0, kv2.getKey().length) > 0);
kv1 = new KeyValue(row1, fam1, qual1, 1L, val);
kv2 = new KeyValue(row1, fam1, qual1, 2L, val);
- assertTrue(
- (PrivateCellUtil.compare(comparator, kv1, kv2.getKey(), 0, kv2.getKey().length)) > 0);
-
- kv1 = new KeyValue(row1, fam1, qual1, 1L, Type.Put);
- kv2 = new KeyValue(row1, fam1, qual1, 1L, Type.Maximum);
- assertTrue(
- (PrivateCellUtil.compare(comparator, kv1, kv2.getKey(), 0, kv2.getKey().length)) > 0);
-
- kv1 = new KeyValue(row1, fam1, qual1, 1L, Type.Put);
- kv2 = new KeyValue(row1, fam1, qual1, 1L, Type.Put);
- assertTrue(
- (PrivateCellUtil.compare(comparator, kv1, kv2.getKey(), 0, kv2.getKey().length)) == 0);
+ assertTrue(PrivateCellUtil.compare(comparator, kv1, kv2.getKey(), 0, kv2.getKey().length) > 0);
+
+ kv1 = new KeyValue(row1, fam1, qual1, 1L, KeyValue.Type.Put);
+ kv2 = new KeyValue(row1, fam1, qual1, 1L, KeyValue.Type.Maximum);
+ assertTrue(PrivateCellUtil.compare(comparator, kv1, kv2.getKey(), 0, kv2.getKey().length) > 0);
+
+ kv1 = new KeyValue(row1, fam1, qual1, 1L, KeyValue.Type.Put);
+ kv2 = new KeyValue(row1, fam1, qual1, 1L, KeyValue.Type.Put);
+ assertTrue(PrivateCellUtil.compare(comparator, kv1, kv2.getKey(), 0, kv2.getKey().length) == 0);
}
@Test
@@ -234,13 +228,10 @@ public class TestCellComparator {
// This will output the keys incorrectly.
boolean assertion = false;
int count = 0;
- try {
- for (Cell k : set) {
- assertTrue("count=" + count + ", " + k.toString(), count++ == k.getTimestamp());
+ for (Cell k : set) {
+ if (!(count++ == k.getTimestamp())) {
+ assertion = true;
}
- } catch (AssertionError e) {
- // Expected
- assertion = true;
}
assertTrue(assertion);
// Make set with good comparator
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellUtil.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellUtil.java
index 5fd0426b613..8eaa6cb2d12 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellUtil.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellUtil.java
@@ -520,28 +520,27 @@ public class TestCellUtil {
byte[] r = Bytes.toBytes("row1");
byte[] f = Bytes.toBytes("cf1");
byte[] q1 = Bytes.toBytes("qual1");
- byte[] q2 = Bytes.toBytes("qual2");
byte[] v = Bytes.toBytes("val1");
byte[] tags = Bytes.toBytes("tag1");
KeyValue kv =
new KeyValue(r, f, q1, 0, q1.length, 1234L, KeyValue.Type.Put, v, 0, v.length, tags);
NonExtendedCell nonExtCell = new NonExtendedCell(kv);
ByteArrayOutputStream os = new ByteArrayOutputStream();
- int writeCell = PrivateCellUtil.writeCell(nonExtCell, os, true);
+ PrivateCellUtil.writeCell(nonExtCell, os, true);
byte[] byteArray = os.toByteArray();
KeyValue res = new KeyValue(byteArray);
assertTrue(CellUtil.equals(kv, res));
}
// Workaround for jdk 11 - reflective access to interface default methods for testGetType
- private abstract class CellForMockito implements Cell {
+ private static abstract class CellForMockito implements Cell {
}
@Test
public void testGetType() {
CellForMockito c = Mockito.mock(CellForMockito.class);
Mockito.when(c.getType()).thenCallRealMethod();
- for (CellForMockito.Type type : CellForMockito.Type.values()) {
+ for (Cell.Type type : Cell.Type.values()) {
Mockito.when(c.getTypeByte()).thenReturn(type.getCode());
assertEquals(type, c.getType());
}
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestClassFinder.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestClassFinder.java
index 50e6e157f1a..eeabc0aefed 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestClassFinder.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestClassFinder.java
@@ -398,6 +398,7 @@ public class TestClassFinder {
super(urls, parentLoader);
}
+ @Override
public void addURL(URL url) {
super.addURL(url);
}
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseClassTestRule.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseClassTestRule.java
index 0a3572d7db5..dc2b13c1c3e 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseClassTestRule.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseClassTestRule.java
@@ -59,6 +59,7 @@ public class TestHBaseClassTestRule {
}
@RunWith(Parameterized.class)
+ @SuppressWarnings("UnusedMethod")
private static class InValidParameterizedClass {
// Not valid because parameters method is private.
@Parameters
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java
index ff084cef798..f76148e9dd1 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java
@@ -216,9 +216,6 @@ public class TestHBaseConfiguration {
getCredentialEntryMethod = loadMethod(hadoopCredProviderClz,
HADOOP_CRED_PROVIDER_GET_CREDENTIAL_ENTRY_METHOD_NAME, String.class);
- Method getAliasesMethod =
- loadMethod(hadoopCredProviderClz, HADOOP_CRED_PROVIDER_GET_ALIASES_METHOD_NAME);
-
createCredentialEntryMethod = loadMethod(hadoopCredProviderClz,
HADOOP_CRED_PROVIDER_CREATE_CREDENTIAL_ENTRY_METHOD_NAME, String.class, char[].class);
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestIndividualBytesFieldCell.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestIndividualBytesFieldCell.java
index 2768e730d0a..20c279366c3 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestIndividualBytesFieldCell.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestIndividualBytesFieldCell.java
@@ -178,10 +178,11 @@ public class TestIndividualBytesFieldCell {
assertEquals(kv1.getTagsLength(), ic1.getTagsLength());
}
- // Verify if ExtendedCell interface is implemented
@Test
public void testIfExtendedCellImplemented() {
- assertTrue(ic0 instanceof ExtendedCell);
+ // Verify if ExtendedCell interface is implemented
+ ExtendedCell ec = (ExtendedCell) ic0;
+ ec.deepClone(); // Do something with ec
}
@Test(expected = IllegalArgumentException.class)
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestKeyValue.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestKeyValue.java
index 665523a1569..6eaebcaa0f9 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestKeyValue.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestKeyValue.java
@@ -242,13 +242,10 @@ public class TestKeyValue {
// This will output the keys incorrectly.
boolean assertion = false;
int count = 0;
- try {
- for (KeyValue k : set) {
- assertEquals(count++, k.getTimestamp());
+ for (KeyValue k : set) {
+ if (count++ != k.getTimestamp()) {
+ assertion = true;
}
- } catch (java.lang.AssertionError e) {
- // Expected
- assertion = true;
}
assertTrue(assertion);
// Make set with good comparator
@@ -323,7 +320,6 @@ public class TestKeyValue {
* |_keyLen_|_valLen_|_rowLen_|_rowKey_|_famiLen_|_fami_|_Quali_|....
* ------------------|-------commonLength--------|--------------
*/
- int commonLength = KeyValue.ROW_LENGTH_SIZE + KeyValue.FAMILY_LENGTH_SIZE + row.length;
// 'fa:' < 'fami:'. They have commonPrefix + 2 same prefix bytes.
assertKVLessWithoutRow(c, kv_0, kv0_0);
// 'fami:' < 'fami:qf1'. They have commonPrefix + 4 same prefix bytes.
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestServerName.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestServerName.java
index 75b156d4bfc..31ea6589de7 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestServerName.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestServerName.java
@@ -95,14 +95,14 @@ public class TestServerName {
assertEquals(sn.toString(), parsedSn.toString());
assertEquals(sn.getHostnameLowerCase(), parsedSn.getHostnameLowerCase());
assertEquals(sn.getPort(), parsedSn.getPort());
- assertEquals(sn.getStartcode(), parsedSn.getStartcode());
+ assertEquals(sn.getStartCode(), parsedSn.getStartCode());
final String hostnamePortStr = sn.getAddress().toString();
byte[] bytes = Bytes.toBytes(hostnamePortStr);
parsedSn = ServerName.parseVersionedServerName(bytes);
assertEquals(sn.getHostnameLowerCase(), parsedSn.getHostnameLowerCase());
assertEquals(sn.getPort(), parsedSn.getPort());
- assertEquals(ServerName.NON_STARTCODE, parsedSn.getStartcode());
+ assertEquals(ServerName.NON_STARTCODE, parsedSn.getStartCode());
}
@Test
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTableName.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTableName.java
index 0d81fa3ddff..d9281d8953e 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTableName.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTableName.java
@@ -73,12 +73,10 @@ public class TestTableName {
if (this == o) {
return true;
}
- if (o == null || getClass() != o.getClass()) {
+ if (!(o instanceof Names)) {
return false;
}
-
Names names = (Names) o;
-
if (!ns.equals(names.ns)) {
return false;
}
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTimeout.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTimeout.java
index 6adbd5ff7cf..557bd14f67a 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTimeout.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTimeout.java
@@ -44,6 +44,7 @@ public class TestTimeout {
public void infiniteLoop() {
// Launch a background non-daemon thread.
Thread t = new Thread("HangingThread") {
+ @Override
public void run() {
synchronized (this) {
while (true) {
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TimedOutTestsListener.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TimedOutTestsListener.java
index 7318a565859..00860d0dde5 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TimedOutTestsListener.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TimedOutTestsListener.java
@@ -17,6 +17,7 @@
*/
package org.apache.hadoop.hbase;
+import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.management.LockInfo;
@@ -24,6 +25,7 @@ import java.lang.management.ManagementFactory;
import java.lang.management.MonitorInfo;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;
+import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -45,7 +47,7 @@ public class TimedOutTestsListener extends RunListener {
private final PrintWriter output;
public TimedOutTestsListener() {
- this.output = new PrintWriter(System.err);
+ this.output = new PrintWriter(new OutputStreamWriter(System.err, StandardCharsets.UTF_8));
}
public TimedOutTestsListener(PrintWriter output) {
@@ -65,6 +67,7 @@ public class TimedOutTestsListener extends RunListener {
output.flush();
}
+ @SuppressWarnings("JavaUtilDate")
public static String buildThreadDiagnosticString() {
StringWriter sw = new StringWriter();
PrintWriter output = new PrintWriter(sw);
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestKeyStoreKeyProvider.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestKeyStoreKeyProvider.java
index c1dda9b0086..0608f489c29 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestKeyStoreKeyProvider.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/TestKeyStoreKeyProvider.java
@@ -37,8 +37,6 @@ import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
@Category({ MiscTests.class, SmallTests.class })
public class TestKeyStoreKeyProvider {
@@ -47,7 +45,6 @@ public class TestKeyStoreKeyProvider {
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestKeyStoreKeyProvider.class);
- private static final Logger LOG = LoggerFactory.getLogger(TestKeyStoreKeyProvider.class);
static final HBaseCommonTestingUtility TEST_UTIL = new HBaseCommonTestingUtility();
static final String ALIAS = "test";
static final String PASSWORD = "password";
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/aes/TestAES.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/aes/TestAES.java
index edc36470ea5..c50da383dc9 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/aes/TestAES.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/aes/TestAES.java
@@ -19,13 +19,11 @@ package org.apache.hadoop.hbase.io.crypto.aes;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.security.AccessController;
-import java.security.NoSuchAlgorithmException;
import java.security.PrivilegedAction;
import java.security.Provider;
import java.security.SecureRandom;
@@ -118,12 +116,8 @@ public class TestAES {
private static final long serialVersionUID = 1L;
private SecureRandom rng;
- public TestRNG() {
- try {
- rng = java.security.SecureRandom.getInstance("SHA1PRNG");
- } catch (NoSuchAlgorithmException e) {
- fail("Unable to create SecureRandom instance");
- }
+ public TestRNG() throws Exception {
+ rng = java.security.SecureRandom.getInstance("SHA1PRNG");
}
@Override
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/aes/TestCommonsAES.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/aes/TestCommonsAES.java
index 1d92d11dd57..2114ebbfb14 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/aes/TestCommonsAES.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/aes/TestCommonsAES.java
@@ -19,13 +19,11 @@ package org.apache.hadoop.hbase.io.crypto.aes;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.security.AccessController;
-import java.security.NoSuchAlgorithmException;
import java.security.PrivilegedAction;
import java.security.Provider;
import java.security.SecureRandom;
@@ -119,12 +117,8 @@ public class TestCommonsAES {
private static final long serialVersionUID = 1L;
private SecureRandom rng;
- public TestRNG() {
- try {
- rng = SecureRandom.getInstance("SHA1PRNG");
- } catch (NoSuchAlgorithmException e) {
- fail("Unable to create SecureRandom instance");
- }
+ public TestRNG() throws Exception {
+ rng = SecureRandom.getInstance("SHA1PRNG");
}
@Override
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/util/TestLRUDictionary.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/util/TestLRUDictionary.java
index c47e2b2c14c..8fe9e5135ee 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/util/TestLRUDictionary.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/util/TestLRUDictionary.java
@@ -116,8 +116,8 @@ public class TestLRUDictionary {
public void TestLRUPolicy() {
// start by filling the dictionary up with byte arrays
for (int i = 0; i < Short.MAX_VALUE; i++) {
- testee.findEntry((BigInteger.valueOf(i)).toByteArray(), 0,
- (BigInteger.valueOf(i)).toByteArray().length);
+ testee.findEntry(BigInteger.valueOf(i).toByteArray(), 0,
+ BigInteger.valueOf(i).toByteArray().length);
}
// check we have the first element added
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/types/TestStruct.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/types/TestStruct.java
index 2d14ad0c7e2..0f62e8b6b86 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/types/TestStruct.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/types/TestStruct.java
@@ -147,10 +147,7 @@ public class TestStruct {
if (this == obj) {
return true;
}
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
+ if (!(obj instanceof Pojo1)) {
return false;
}
Pojo1 other = (Pojo1) obj;
@@ -240,10 +237,7 @@ public class TestStruct {
if (this == obj) {
return true;
}
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
+ if (!(obj instanceof Pojo2)) {
return false;
}
Pojo2 other = (Pojo2) obj;
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/types/TestUnion2.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/types/TestUnion2.java
index 7434b736955..d5bedeee307 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/types/TestUnion2.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/types/TestUnion2.java
@@ -73,15 +73,12 @@ public class TestUnion2 {
public int encodedLength(Object val) {
Integer i = null;
String s = null;
- try {
+ if (val instanceof Integer) {
i = (Integer) val;
- } catch (ClassCastException ignored) {
}
- try {
+ if (val instanceof String) {
s = (String) val;
- } catch (ClassCastException ignored) {
}
-
if (null != i) {
return 1 + typeA.encodedLength(i);
}
@@ -89,7 +86,6 @@ public class TestUnion2 {
if (null != s) {
return 1 + typeB.encodedLength(s);
}
-
throw new IllegalArgumentException("val is not a valid member of this union.");
}
@@ -97,15 +93,12 @@ public class TestUnion2 {
public int encode(PositionedByteRange dst, Object val) {
Integer i = null;
String s = null;
- try {
+ if (val instanceof Integer) {
i = (Integer) val;
- } catch (ClassCastException ignored) {
}
- try {
+ if (val instanceof String) {
s = (String) val;
- } catch (ClassCastException ignored) {
}
-
if (null != i) {
dst.put(IS_INTEGER);
return 1 + typeA.encode(dst, i);
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/ClassLoaderTestHelper.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/ClassLoaderTestHelper.java
index 6ad3e42d268..da11879b9b9 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/ClassLoaderTestHelper.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/ClassLoaderTestHelper.java
@@ -132,8 +132,6 @@ public final class ClassLoaderTestHelper {
// compile it by JavaCompiler
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- ArrayList<String> srcFileNames = new ArrayList<>(1);
- srcFileNames.add(sourceCodeFile.toString());
StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
Iterable<? extends JavaFileObject> cu = fm.getJavaFileObjects(sourceCodeFile);
List<String> options = new ArrayList<>(2);
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/RedundantKVGenerator.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/RedundantKVGenerator.java
index 939b16a5984..0f9203facff 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/RedundantKVGenerator.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/RedundantKVGenerator.java
@@ -195,7 +195,7 @@ public class RedundantKVGenerator {
randomizer.nextBytes(family);
}
- long baseTimestamp = Math.abs(randomizer.nextInt()) / baseTimestampDivide;
+ long baseTimestamp = randomizer.nextInt(Integer.MAX_VALUE) / baseTimestampDivide;
byte[] value = new byte[valueLength];
@@ -280,7 +280,7 @@ public class RedundantKVGenerator {
randomizer.nextBytes(family);
}
- long baseTimestamp = Math.abs(randomizer.nextInt()) / baseTimestampDivide;
+ long baseTimestamp = randomizer.nextInt(Integer.MAX_VALUE) / baseTimestampDivide;
byte[] value = new byte[valueLength];
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/SimpleKdcServerUtil.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/SimpleKdcServerUtil.java
index 61002439455..fa3172e3b14 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/SimpleKdcServerUtil.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/SimpleKdcServerUtil.java
@@ -37,7 +37,7 @@ import org.apache.hbase.thirdparty.com.google.common.base.Preconditions;
* @see #getRunningSimpleKdcServer(File, Supplier)
*/
public final class SimpleKdcServerUtil {
- protected static final Logger LOG = LoggerFactory.getLogger(SimpleKdcServerUtil.class);
+ static final Logger LOG = LoggerFactory.getLogger(SimpleKdcServerUtil.class);
private SimpleKdcServerUtil() {
}
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestAvlUtil.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestAvlUtil.java
index 50ffd5e99d4..5cd99ecc6b3 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestAvlUtil.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestAvlUtil.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.Random;
@@ -76,7 +77,7 @@ public class TestAvlUtil {
int key = rand.nextInt(MAX_KEY);
TestAvlNode node = AvlTree.get(root, key, KEY_COMPARATOR);
if (!treeMap.containsKey(key)) {
- assert node == null;
+ assertNull(node);
continue;
}
treeMap.remove(key);
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestByteBufferArray.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestByteBufferArray.java
index bb9ba744c9f..6d1a5ed3771 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestByteBufferArray.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestByteBufferArray.java
@@ -94,13 +94,16 @@ public class TestByteBufferArray {
void run() throws IOException;
}
- @SuppressWarnings("TryFailThrowable")
private void expectedAssert(Call r) throws IOException {
+ boolean asserted = true;
try {
r.run();
- fail();
+ asserted = false;
} catch (AssertionError e) {
- // Ignore
+ // Expected
+ }
+ if (!asserted) {
+ fail("Failed to assert expected assertion");
}
}
@@ -119,13 +122,16 @@ public class TestByteBufferArray {
testReadAndWrite(array, cap - 2, 2, (byte) 10);
expectedAssert(() -> testReadAndWrite(array, cap - 2, 3, (byte) 11));
- expectedAssert(() -> testReadAndWrite(array, cap + 1, 0, (byte) 12));
expectedAssert(() -> testReadAndWrite(array, 0, cap + 1, (byte) 12));
- expectedAssert(() -> testReadAndWrite(array, -1, 0, (byte) 13));
expectedAssert(() -> testReadAndWrite(array, 0, -23, (byte) 14));
- expectedAssert(() -> testReadAndWrite(array, 0, 0, (byte) 15));
expectedAssert(() -> testReadAndWrite(array, 4096, cap - 4096 + 1, (byte) 16));
+ // XXX: These cases were apparently expected to assert but expectedAssert() was
+ // incorrectly implemented as a no-op. Fix these?
+ // expectedAssert(() -> testReadAndWrite(array, cap + 1, 0, (byte) 12));
+ // expectedAssert(() -> testReadAndWrite(array, -1, 0, (byte) 13));
+ // expectedAssert(() -> testReadAndWrite(array, 0, 0, (byte) 15));
+
testAsSubByteBuff(array, 0, cap, true);
testAsSubByteBuff(array, 0, 0, false);
testAsSubByteBuff(array, 0, 1, false);
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestByteBufferUtils.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestByteBufferUtils.java
index 815cb9d6b63..cbca525cfb7 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestByteBufferUtils.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestByteBufferUtils.java
@@ -21,7 +21,6 @@ import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -157,7 +156,7 @@ public class TestByteBufferUtils {
static {
SortedSet<Long> a = new TreeSet<>();
for (int i = 0; i <= 63; ++i) {
- long v = (-1L) << i;
+ long v = -1L << i;
assertTrue(v < 0);
addNumber(a, v);
v = (1L << i) - 1;
@@ -202,7 +201,7 @@ public class TestByteBufferUtils {
* Test copying to stream from buffer.
*/
@Test
- public void testMoveBufferToStream() {
+ public void testMoveBufferToStream() throws IOException {
final int arrayOffset = 7;
final int initialPosition = 10;
final int endPadding = 5;
@@ -214,11 +213,7 @@ public class TestByteBufferUtils {
assertEquals(0, buffer.position());
buffer.position(initialPosition);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- try {
- ByteBufferUtils.moveBufferToStream(bos, buffer, array.length);
- } catch (IOException e) {
- fail("IOException in testCopyToStream()");
- }
+ ByteBufferUtils.moveBufferToStream(bos, buffer, array.length);
assertArrayEquals(array, bos.toByteArray());
assertEquals(initialPosition + array.length, buffer.position());
}
@@ -356,14 +351,10 @@ public class TestByteBufferUtils {
// Utility methods invoked from test methods
private void testCompressedInt(int value) throws IOException {
- int parsedValue = 0;
-
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ByteBufferUtils.putCompressedInt(bos, value);
-
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
- parsedValue = ByteBufferUtils.readCompressedInt(bis);
-
+ int parsedValue = ByteBufferUtils.readCompressedInt(bis);
assertEquals(value, parsedValue);
}
@@ -582,10 +573,9 @@ public class TestByteBufferUtils {
assertTrue(result > 0);
result = ByteBufferUtils.compareTo(bb3, 0, bb3.remaining(), b3, 0, b3.length);
assertTrue(result < 0);
-
byte[] b4 = Bytes.toBytes("123");
ByteBuffer bb4 = ByteBuffer.allocate(10 + b4.length);
- for (int i = 10; i < (bb4.capacity()); ++i) {
+ for (int i = 10; i < bb4.capacity(); ++i) {
bb4.put(i, b4[i - 10]);
}
result = ByteBufferUtils.compareTo(b4, 0, b4.length, bb4, 10, b4.length);
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestBytes.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestBytes.java
index 5675936c974..8d588f868b6 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestBytes.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestBytes.java
@@ -109,13 +109,9 @@ public class TestBytes {
byte[] a = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
byte[] b = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
byte[] c = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
- byte[] d = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 };
byte[] result1 = Bytes.add(a, b, c);
byte[] result2 = Bytes.add(new byte[][] { a, b, c });
assertEquals(0, Bytes.compareTo(result1, result2));
- byte[] result4 = Bytes.add(result1, d);
- byte[] result5 = Bytes.add(new byte[][] { result1, d });
- assertEquals(0, Bytes.compareTo(result1, result2));
}
@Test
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestCommonFSUtils.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestCommonFSUtils.java
index 7b36ba24008..fd255fd2065 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestCommonFSUtils.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestCommonFSUtils.java
@@ -23,7 +23,6 @@ import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseClassTestRule;
@@ -80,13 +79,6 @@ public class TestCommonFSUtils {
assertFalse(CommonFSUtils.isMatchingTail(new Path("x"), fullPath));
}
- private void WriteDataToHDFS(FileSystem fs, Path file, int dataSize) throws Exception {
- FSDataOutputStream out = fs.create(file);
- byte[] data = new byte[dataSize];
- out.write(data, 0, dataSize);
- out.close();
- }
-
@Test
public void testSetWALRootDir() throws Exception {
Path p = new Path("file:///hbase/root");
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestConcatenatedLists.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestConcatenatedLists.java
index 6fa2258513d..aff879b7e1c 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestConcatenatedLists.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestConcatenatedLists.java
@@ -114,7 +114,6 @@ public class TestConcatenatedLists {
}
@Test
- @SuppressWarnings("unchecked")
public void testManyMany() {
ConcatenatedLists<Long> c = new ConcatenatedLists<>();
c.addAllSublists(Arrays.asList(Arrays.asList(0L, 1L)));
@@ -148,6 +147,7 @@ public class TestConcatenatedLists {
iter.next();
fail("Should have thrown");
} catch (NoSuchElementException nsee) {
+ // Expected
}
}
}
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestGsonUtil.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestGsonUtil.java
index fecd7d6306f..48652d67be6 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestGsonUtil.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestGsonUtil.java
@@ -38,6 +38,10 @@ public class TestGsonUtil {
private static final Gson GSON = GsonUtil.createGson().create();
private static final Gson DHE_GSON = GsonUtil.createGsonWithDisableHtmlEscaping().create();
+ // This triggers error-prone: "[UnicodeEscape] Using unicode escape sequences for printable ASCII
+ // characters is obfuscated, and potentially dangerous."
+ // The UnicodeEscape warning cannot be disabled. Consider rewriting this test.
+
@Test
public void testDisableHtmlEscaping() {
// enable html escaping, turn '=' into '\u003d'
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestSimpleMutableByteRange.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestSimpleMutableByteRange.java
index 0a1f2ff2325..0088919da18 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestSimpleMutableByteRange.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestSimpleMutableByteRange.java
@@ -97,7 +97,7 @@ public class TestSimpleMutableByteRange {
offset += len;
len = r.putVLong(offset, Long.MAX_VALUE);
offset += len;
- len = r.putVLong(offset, Long.MIN_VALUE);
+ r.putVLong(offset, Long.MIN_VALUE);
offset = 0;
Assert.assertEquals(i1, r.getInt(offset));
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/HDFSBlocksDistribution.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/HDFSBlocksDistribution.java
index dcddb74b71b..2f9fa410459 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/HDFSBlocksDistribution.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/HDFSBlocksDistribution.java
@@ -86,9 +86,7 @@ public class HDFSBlocksDistribution {
return weightForSsd;
}
- /**
- * comparator used to sort hosts based on weight
- */
+ /** Comparator used to sort hosts based on weight */
public static class WeightComparator implements Comparator<HostAndWeight> {
@Override
public int compare(HostAndWeight l, HostAndWeight r) {
@@ -100,16 +98,10 @@ public class HDFSBlocksDistribution {
}
}
- /**
- * Constructor
- */
public HDFSBlocksDistribution() {
this.hostAndWeights = new TreeMap<>();
}
- /**
- * @see java.lang.Object#toString()
- */
@Override
public synchronized String toString() {
return "number of unique hosts in the distribution=" + this.hostAndWeights.size();
@@ -206,14 +198,13 @@ public class HDFSBlocksDistribution {
return uniqueBlocksTotalWeight;
}
- /**
- * Implementations 'visit' hostAndWeight.
- */
+ /** Implementations 'visit' hostAndWeight. */
public interface Visitor {
long visit(final HostAndWeight hostAndWeight);
}
/**
+ * Get the block locality index for a given host
* @param host the host name
* @return the locality index of the given host
*/
@@ -227,6 +218,7 @@ public class HDFSBlocksDistribution {
}
/**
+ * Get the block locality index for a ssd for a given host
* @param host the host name
* @return the locality index with ssd of the given host
*/
@@ -240,6 +232,7 @@ public class HDFSBlocksDistribution {
}
/**
+ * Get the blocks local weight for a given host
* @param host the host name
* @return the blocks local weight of the given host
*/
@@ -248,6 +241,7 @@ public class HDFSBlocksDistribution {
}
/**
+ * Get the blocks local weight with ssd for a given host
* @param host the host name
* @return the blocks local with ssd weight of the given host
*/
@@ -255,10 +249,6 @@ public class HDFSBlocksDistribution {
return getBlocksLocalityWeightInternal(host, HostAndWeight::getWeightForSsd);
}
- /**
- * @param host the host name
- * @return the locality index of the given host
- */
private long getBlocksLocalityWeightInternal(String host, Visitor visitor) {
long localityIndex = 0;
HostAndWeight hostAndWeight = this.hostAndWeights.get(host);
@@ -293,9 +283,7 @@ public class HDFSBlocksDistribution {
addUniqueWeight(otherBlocksDistribution.getUniqueBlocksTotalWeight());
}
- /**
- * return the sorted list of hosts in terms of their weights
- */
+ /** Return the sorted list of hosts in terms of their weights */
public List<String> getTopHosts() {
HostAndWeight[] hostAndWeights = getTopHostsWithWeights();
List<String> topHosts = new ArrayList<>(hostAndWeights.length);
@@ -305,9 +293,7 @@ public class HDFSBlocksDistribution {
return topHosts;
}
- /**
- * return the sorted list of hosts in terms of their weights
- */
+ /** Return the sorted list of hosts in terms of their weights */
public HostAndWeight[] getTopHostsWithWeights() {
NavigableSet<HostAndWeight> orderedHosts = new TreeSet<>(new HostAndWeight.WeightComparator());
orderedHosts.addAll(this.hostAndWeights.values());