HBASE-23625 Reduced number of Checkstyle violations in hbase-common
Signed-off-by: stack <stack@apache.org>
This commit is contained in:
parent
e32dbe8ed2
commit
e0eb98c963
|
@ -15,7 +15,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hadoop.hbase;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -56,7 +55,7 @@ public interface CellScanner {
|
|||
/**
|
||||
* Advance the scanner 1 cell.
|
||||
* @return true if the next cell is found and {@link #current()} will return a valid Cell
|
||||
* @throws IOException
|
||||
* @throws IOException if advancing the scanner fails
|
||||
*/
|
||||
boolean advance() throws IOException;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hadoop.hbase;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
@ -25,12 +24,14 @@ import org.apache.yetus.audience.InterfaceAudience;
|
|||
|
||||
@InterfaceAudience.Private
|
||||
public class IndividualBytesFieldCell implements ExtendedCell, Cloneable {
|
||||
|
||||
private static final long FIXED_OVERHEAD = ClassSize.align( // do alignment(padding gap)
|
||||
ClassSize.OBJECT // object header
|
||||
+ KeyValue.TIMESTAMP_TYPE_SIZE // timestamp and type
|
||||
+ Bytes.SIZEOF_LONG // sequence id
|
||||
+ 5 * ClassSize.REFERENCE); // references to all byte arrays: row, family, qualifier, value, tags
|
||||
// do alignment(padding gap)
|
||||
private static final long FIXED_OVERHEAD = ClassSize.align(ClassSize.OBJECT // object header
|
||||
// timestamp and type
|
||||
+ KeyValue.TIMESTAMP_TYPE_SIZE
|
||||
// sequence id
|
||||
+ Bytes.SIZEOF_LONG
|
||||
// references to all byte arrays: row, family, qualifier, value, tags
|
||||
+ 5 * ClassSize.REFERENCE);
|
||||
|
||||
// The following fields are backed by individual byte arrays
|
||||
private final byte[] row;
|
||||
|
@ -54,13 +55,8 @@ public class IndividualBytesFieldCell implements ExtendedCell, Cloneable {
|
|||
private final byte type; // A byte, rather than org.apache.hadoop.hbase.KeyValue.Type
|
||||
private long seqId;
|
||||
|
||||
public IndividualBytesFieldCell(byte[] row, byte[] family, byte[] qualifier,
|
||||
long timestamp, KeyValue.Type type, byte[] value) {
|
||||
this(row, family, qualifier, timestamp, type, 0L /* sequence id */, value, null /* tags */);
|
||||
}
|
||||
|
||||
public IndividualBytesFieldCell(byte[] row, byte[] family, byte[] qualifier,
|
||||
long timestamp, KeyValue.Type type, long seqId, byte[] value, byte[] tags) {
|
||||
public IndividualBytesFieldCell(byte[] row, byte[] family, byte[] qualifier, long timestamp,
|
||||
KeyValue.Type type, long seqId, byte[] value, byte[] tags) {
|
||||
this(row, 0, ArrayUtils.getLength(row),
|
||||
family, 0, ArrayUtils.getLength(family),
|
||||
qualifier, 0, ArrayUtils.getLength(qualifier),
|
||||
|
@ -69,13 +65,10 @@ public class IndividualBytesFieldCell implements ExtendedCell, Cloneable {
|
|||
tags, 0, ArrayUtils.getLength(tags));
|
||||
}
|
||||
|
||||
public IndividualBytesFieldCell(byte[] row, int rOffset, int rLength,
|
||||
byte[] family, int fOffset, int fLength,
|
||||
byte[] qualifier, int qOffset, int qLength,
|
||||
long timestamp, KeyValue.Type type, long seqId,
|
||||
byte[] value, int vOffset, int vLength,
|
||||
byte[] tags, int tagsOffset, int tagsLength) {
|
||||
|
||||
public IndividualBytesFieldCell(byte[] row, int rOffset, int rLength, byte[] family, int fOffset,
|
||||
int fLength, byte[] qualifier, int qOffset, int qLength, long timestamp, KeyValue.Type type,
|
||||
long seqId, byte[] value, int vOffset, int vLength, byte[] tags, int tagsOffset,
|
||||
int tagsLength) {
|
||||
// Check row, family, qualifier and value
|
||||
KeyValue.checkParameters(row, rLength, // row and row length
|
||||
family, fLength, // family and family length
|
||||
|
@ -119,10 +112,12 @@ public class IndividualBytesFieldCell implements ExtendedCell, Cloneable {
|
|||
|
||||
private void checkArrayBounds(byte[] bytes, int offset, int length) {
|
||||
if (offset < 0 || length < 0) {
|
||||
throw new IllegalArgumentException("Negative number! offset=" + offset + "and length=" + length);
|
||||
throw new IllegalArgumentException("Negative number! offset=" + offset + "and length="
|
||||
+ length);
|
||||
}
|
||||
if (bytes == null && (offset != 0 || length != 0)) {
|
||||
throw new IllegalArgumentException("Null bytes array but offset=" + offset + "and length=" + length);
|
||||
throw new IllegalArgumentException("Null bytes array but offset=" + offset + "and length="
|
||||
+ length);
|
||||
}
|
||||
if (bytes != null && bytes.length < offset + length) {
|
||||
throw new IllegalArgumentException("Out of bounds! bytes.length=" + bytes.length
|
||||
|
@ -131,7 +126,7 @@ public class IndividualBytesFieldCell implements ExtendedCell, Cloneable {
|
|||
}
|
||||
|
||||
private long heapOverhead() {
|
||||
return FIXED_OVERHEAD
|
||||
return FIXED_OVERHEAD
|
||||
+ ClassSize.ARRAY // row , can not be null
|
||||
+ ((family == null) ? 0 : ClassSize.ARRAY) // family , can be null
|
||||
+ ((qualifier == null) ? 0 : ClassSize.ARRAY) // qualifier, can be null
|
||||
|
@ -152,13 +147,14 @@ public class IndividualBytesFieldCell implements ExtendedCell, Cloneable {
|
|||
|
||||
@Override
|
||||
public int getRowOffset() {
|
||||
return rOffset;
|
||||
}
|
||||
return rOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getRowLength() {
|
||||
// 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.
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
@ -255,7 +251,8 @@ public class IndividualBytesFieldCell implements ExtendedCell, Cloneable {
|
|||
*/
|
||||
@Override
|
||||
public long heapSize() {
|
||||
// Size of array headers are already included into overhead, so do not need to include it for each byte array
|
||||
// Size of array headers are already included into overhead, so do not need to include it for
|
||||
// each byte array
|
||||
return heapOverhead() // overhead, with array headers included
|
||||
+ ClassSize.align(getRowLength()) // row
|
||||
+ ClassSize.align(getFamilyLength()) // family
|
||||
|
|
|
@ -59,7 +59,6 @@ import org.apache.yetus.audience.InterfaceStability;
|
|||
@InterfaceAudience.Private
|
||||
@InterfaceStability.Evolving
|
||||
public abstract class AbstractByteRange implements ByteRange {
|
||||
|
||||
public static final int UNSET_HASH_VALUE = -1;
|
||||
|
||||
// Note to maintainers: Do not make these final, as the intention is to
|
||||
|
@ -95,9 +94,6 @@ public abstract class AbstractByteRange implements ByteRange {
|
|||
return bytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract ByteRange unset();
|
||||
|
||||
@Override
|
||||
public ByteRange set(int capacity) {
|
||||
return set(new byte[capacity]);
|
||||
|
@ -105,8 +101,10 @@ public abstract class AbstractByteRange implements ByteRange {
|
|||
|
||||
@Override
|
||||
public ByteRange set(byte[] bytes) {
|
||||
if (null == bytes)
|
||||
if (null == bytes) {
|
||||
return unset();
|
||||
}
|
||||
|
||||
clearHashCache();
|
||||
this.bytes = bytes;
|
||||
this.offset = 0;
|
||||
|
@ -116,8 +114,10 @@ public abstract class AbstractByteRange implements ByteRange {
|
|||
|
||||
@Override
|
||||
public ByteRange set(byte[] bytes, int offset, int length) {
|
||||
if (null == bytes)
|
||||
if (null == bytes) {
|
||||
return unset();
|
||||
}
|
||||
|
||||
clearHashCache();
|
||||
this.bytes = bytes;
|
||||
this.offset = offset;
|
||||
|
@ -172,15 +172,19 @@ public abstract class AbstractByteRange implements ByteRange {
|
|||
|
||||
@Override
|
||||
public ByteRange get(int index, byte[] dst) {
|
||||
if (0 == dst.length)
|
||||
if (0 == dst.length) {
|
||||
return this;
|
||||
}
|
||||
|
||||
return get(index, dst, 0, dst.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteRange get(int index, byte[] dst, int offset, int length) {
|
||||
if (0 == length)
|
||||
if (0 == length) {
|
||||
return this;
|
||||
}
|
||||
|
||||
System.arraycopy(this.bytes, this.offset + index, dst, offset, length);
|
||||
return this;
|
||||
}
|
||||
|
@ -243,27 +247,6 @@ public abstract class AbstractByteRange implements ByteRange {
|
|||
return rPos + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract ByteRange put(int index, byte val);
|
||||
|
||||
@Override
|
||||
public abstract ByteRange put(int index, byte[] val);
|
||||
|
||||
@Override
|
||||
public abstract ByteRange put(int index, byte[] val, int offset, int length);
|
||||
|
||||
@Override
|
||||
public abstract ByteRange putInt(int index, int val);
|
||||
|
||||
@Override
|
||||
public abstract ByteRange putLong(int index, long val);
|
||||
|
||||
@Override
|
||||
public abstract ByteRange putShort(int index, short val);
|
||||
|
||||
@Override
|
||||
public abstract int putVLong(int index, long val);
|
||||
|
||||
//
|
||||
// methods for duplicating the current instance
|
||||
//
|
||||
|
|
|
@ -17,12 +17,9 @@
|
|||
*/
|
||||
package org.apache.hadoop.hbase.util;
|
||||
|
||||
|
||||
import org.apache.yetus.audience.InterfaceAudience;
|
||||
import org.apache.yetus.audience.InterfaceStability;
|
||||
|
||||
import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;
|
||||
|
||||
/**
|
||||
* Extends the basic {@link SimpleByteRange} implementation with position
|
||||
* support. {@code position} is considered transient, not fundamental to the
|
||||
|
@ -48,9 +45,6 @@ public abstract class AbstractPositionedByteRange extends AbstractByteRange impl
|
|||
|
||||
protected int limit = 0;
|
||||
|
||||
@Override
|
||||
public abstract PositionedByteRange unset();
|
||||
|
||||
@Override
|
||||
public PositionedByteRange set(int capacity) {
|
||||
this.position = 0;
|
||||
|
@ -134,77 +128,24 @@ public abstract class AbstractPositionedByteRange extends AbstractByteRange impl
|
|||
|
||||
@Override
|
||||
public PositionedByteRange get(byte[] dst) {
|
||||
if (0 == dst.length)
|
||||
if (0 == dst.length) {
|
||||
return this;
|
||||
return this.get(dst, 0, dst.length); // be clear we're calling self, not
|
||||
// super
|
||||
}
|
||||
|
||||
return this.get(dst, 0, dst.length); // be clear we're calling self, not super
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedByteRange get(byte[] dst, int offset, int length) {
|
||||
if (0 == length)
|
||||
if (0 == length) {
|
||||
return this;
|
||||
}
|
||||
|
||||
super.get(this.position, dst, offset, length);
|
||||
this.position += length;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract PositionedByteRange put(byte val);
|
||||
|
||||
@Override
|
||||
public abstract PositionedByteRange put(byte[] val);
|
||||
|
||||
@Override
|
||||
public abstract PositionedByteRange put(byte[] val, int offset, int length);
|
||||
|
||||
@Override
|
||||
public abstract PositionedByteRange putInt(int index, int val);
|
||||
|
||||
@Override
|
||||
public abstract PositionedByteRange putLong(int index, long val);
|
||||
|
||||
@Override
|
||||
public abstract PositionedByteRange putShort(int index, short val);
|
||||
|
||||
@Override
|
||||
public abstract PositionedByteRange putInt(int val);
|
||||
|
||||
@Override
|
||||
public abstract PositionedByteRange putLong(long val);
|
||||
|
||||
@Override
|
||||
public abstract PositionedByteRange putShort(short val);
|
||||
|
||||
@Override
|
||||
public abstract int putVLong(int index, long val);
|
||||
|
||||
@Override
|
||||
public abstract int putVLong(long val);
|
||||
/**
|
||||
* Similar to {@link java.nio.ByteBuffer#flip()}. Sets length to position, position to
|
||||
* offset.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
PositionedByteRange flip() {
|
||||
clearHashCache();
|
||||
length = position;
|
||||
position = offset;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to {@link java.nio.ByteBuffer#clear()}. Sets position to 0, length to
|
||||
* capacity.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
PositionedByteRange clear() {
|
||||
clearHashCache();
|
||||
position = 0;
|
||||
length = bytes.length - offset;
|
||||
return this;
|
||||
}
|
||||
|
||||
// java boilerplate
|
||||
|
||||
@Override
|
||||
|
@ -247,24 +188,6 @@ public abstract class AbstractPositionedByteRange extends AbstractByteRange impl
|
|||
return p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract PositionedByteRange put(int index, byte val);
|
||||
|
||||
@Override
|
||||
public abstract PositionedByteRange put(int index, byte[] val);
|
||||
|
||||
@Override
|
||||
public abstract PositionedByteRange put(int index, byte[] val, int offset, int length);
|
||||
|
||||
@Override
|
||||
public abstract PositionedByteRange deepCopy();
|
||||
|
||||
@Override
|
||||
public abstract PositionedByteRange shallowCopy();
|
||||
|
||||
@Override
|
||||
public abstract PositionedByteRange shallowCopySubRange(int innerOffset, int copyLength);
|
||||
|
||||
@Override
|
||||
public PositionedByteRange setLimit(int limit) {
|
||||
this.limit = limit;
|
||||
|
|
|
@ -25,7 +25,10 @@ import org.apache.yetus.audience.InterfaceAudience;
|
|||
* Utilities related to atomic operations.
|
||||
*/
|
||||
@InterfaceAudience.Private
|
||||
public class AtomicUtils {
|
||||
public final class AtomicUtils {
|
||||
private AtomicUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a AtomicLong which is supposed to maintain the minimum values. This method is not
|
||||
* synchronized but is thread-safe.
|
||||
|
@ -59,5 +62,4 @@ public class AtomicUtils {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -57,8 +57,7 @@ import org.slf4j.LoggerFactory;
|
|||
*/
|
||||
@InterfaceAudience.Private
|
||||
public class DynamicClassLoader extends ClassLoaderBase {
|
||||
private static final Logger LOG =
|
||||
LoggerFactory.getLogger(DynamicClassLoader.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DynamicClassLoader.class);
|
||||
|
||||
// Dynamic jars are put under ${hbase.local.dir}/jars/
|
||||
private static final String DYNAMIC_JARS_DIR = File.separator
|
||||
|
@ -90,8 +89,7 @@ public class DynamicClassLoader extends ClassLoaderBase {
|
|||
* @param conf the configuration for the cluster.
|
||||
* @param parent the parent ClassLoader to set.
|
||||
*/
|
||||
public DynamicClassLoader(
|
||||
final Configuration conf, final ClassLoader parent) {
|
||||
public DynamicClassLoader(final Configuration conf, final ClassLoader parent) {
|
||||
super(parent);
|
||||
|
||||
// Save off the user's original configuration value for the DynamicClassLoader
|
||||
|
@ -158,38 +156,40 @@ public class DynamicClassLoader extends ClassLoaderBase {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private Class<?> tryRefreshClass(String name)
|
||||
throws ClassNotFoundException {
|
||||
private Class<?> tryRefreshClass(String name) throws ClassNotFoundException {
|
||||
synchronized (getClassLoadingLock(name)) {
|
||||
// Check whether the class has already been loaded:
|
||||
Class<?> clasz = findLoadedClass(name);
|
||||
if (clasz != null) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Class " + name + " already loaded");
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Finding class: " + name);
|
||||
}
|
||||
clasz = findClass(name);
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
// Load new jar files if any
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Loading new jar files, if any");
|
||||
}
|
||||
loadNewJars();
|
||||
// Check whether the class has already been loaded:
|
||||
Class<?> clasz = findLoadedClass(name);
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Finding class again: " + name);
|
||||
}
|
||||
clasz = findClass(name);
|
||||
}
|
||||
if (clasz != null) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Class {} already loaded", name);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Finding class: {}", name);
|
||||
}
|
||||
|
||||
clasz = findClass(name);
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
// Load new jar files if any
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Loading new jar files, if any");
|
||||
}
|
||||
|
||||
loadNewJars();
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Finding class again: {}", name);
|
||||
}
|
||||
|
||||
clasz = findClass(name);
|
||||
}
|
||||
return clasz;
|
||||
}
|
||||
|
||||
return clasz;
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void loadNewJars() {
|
||||
|
@ -202,7 +202,7 @@ public class DynamicClassLoader extends ClassLoaderBase {
|
|||
continue;
|
||||
}
|
||||
if (file.isFile() && fileName.endsWith(".jar")) {
|
||||
jarModifiedTime.put(fileName, Long.valueOf(file.lastModified()));
|
||||
jarModifiedTime.put(fileName, file.lastModified());
|
||||
try {
|
||||
URL url = file.toURI().toURL();
|
||||
addURL(url);
|
||||
|
@ -228,19 +228,22 @@ public class DynamicClassLoader extends ClassLoaderBase {
|
|||
}
|
||||
|
||||
for (FileStatus status: statuses) {
|
||||
if (status.isDirectory()) continue; // No recursive lookup
|
||||
if (status.isDirectory()) {
|
||||
continue; // No recursive lookup
|
||||
}
|
||||
|
||||
Path path = status.getPath();
|
||||
String fileName = path.getName();
|
||||
if (!fileName.endsWith(".jar")) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Ignored non-jar file " + fileName);
|
||||
LOG.debug("Ignored non-jar file {}", fileName);
|
||||
}
|
||||
continue; // Ignore non-jar files
|
||||
}
|
||||
Long cachedLastModificationTime = jarModifiedTime.get(fileName);
|
||||
if (cachedLastModificationTime != null) {
|
||||
long lastModified = status.getModificationTime();
|
||||
if (lastModified < cachedLastModificationTime.longValue()) {
|
||||
if (lastModified < cachedLastModificationTime) {
|
||||
// There could be some race, for example, someone uploads
|
||||
// a new one right in the middle the old one is copied to
|
||||
// local. We can check the size as well. But it is still
|
||||
|
@ -255,7 +258,7 @@ public class DynamicClassLoader extends ClassLoaderBase {
|
|||
// Copy it to local
|
||||
File dst = new File(localDir, fileName);
|
||||
remoteDirFs.copyToLocalFile(path, new Path(dst.getPath()));
|
||||
jarModifiedTime.put(fileName, Long.valueOf(dst.lastModified()));
|
||||
jarModifiedTime.put(fileName, dst.lastModified());
|
||||
URL url = dst.toURI().toURL();
|
||||
addURL(url);
|
||||
} catch (IOException ioe) {
|
||||
|
|
|
@ -34,14 +34,22 @@ import org.apache.yetus.audience.InterfaceAudience;
|
|||
* interruption, so we have to distinguish the case. This pattern is unfortunately common.
|
||||
*/
|
||||
@InterfaceAudience.Private
|
||||
public class ExceptionUtil {
|
||||
public final class ExceptionUtil {
|
||||
private ExceptionUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the throwable comes an interruption, false otherwise.
|
||||
*/
|
||||
public static boolean isInterrupt(Throwable t) {
|
||||
if (t instanceof InterruptedException) return true;
|
||||
if (t instanceof SocketTimeoutException) return false;
|
||||
if (t instanceof InterruptedException) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (t instanceof SocketTimeoutException) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (t instanceof InterruptedIOException || t instanceof ClosedByInterruptException);
|
||||
}
|
||||
|
||||
|
@ -50,16 +58,23 @@ public class ExceptionUtil {
|
|||
*/
|
||||
public static void rethrowIfInterrupt(Throwable t) throws InterruptedIOException {
|
||||
InterruptedIOException iie = asInterrupt(t);
|
||||
if (iie != null) throw iie;
|
||||
|
||||
if (iie != null) {
|
||||
throw iie;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an InterruptedIOException if t was an interruption, null otherwise
|
||||
*/
|
||||
public static InterruptedIOException asInterrupt(Throwable t) {
|
||||
if (t instanceof SocketTimeoutException) return null;
|
||||
if (t instanceof SocketTimeoutException) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (t instanceof InterruptedIOException) return (InterruptedIOException) t;
|
||||
if (t instanceof InterruptedIOException) {
|
||||
return (InterruptedIOException) t;
|
||||
}
|
||||
|
||||
if (t instanceof InterruptedException || t instanceof ClosedByInterruptException) {
|
||||
InterruptedIOException iie =
|
||||
|
@ -70,7 +85,4 @@ public class ExceptionUtil {
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
private ExceptionUtil() {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hadoop.hbase.util;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
@ -30,9 +29,12 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@InterfaceAudience.Private
|
||||
public class Methods {
|
||||
public final class Methods {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Methods.class);
|
||||
|
||||
private Methods() {
|
||||
}
|
||||
|
||||
public static <T> Object call(Class<T> clazz, T instance, String methodName,
|
||||
Class[] types, Object[] args) throws Exception {
|
||||
try {
|
||||
|
|
|
@ -42,7 +42,7 @@ public class Sleeper {
|
|||
/**
|
||||
* @param sleep sleep time in milliseconds
|
||||
* @param stopper When {@link Stoppable#isStopped()} is true, this thread will
|
||||
* cleanup and exit cleanly.
|
||||
* cleanup and exit cleanly.
|
||||
*/
|
||||
public Sleeper(final int sleep, final Stoppable stopper) {
|
||||
this.period = sleep;
|
||||
|
@ -77,16 +77,18 @@ public class Sleeper {
|
|||
long woke = -1;
|
||||
try {
|
||||
synchronized (sleepLock) {
|
||||
if (triggerWake) break;
|
||||
if (triggerWake) {
|
||||
break;
|
||||
}
|
||||
|
||||
sleepLock.wait(currentSleepTime);
|
||||
}
|
||||
woke = System.currentTimeMillis();
|
||||
long slept = woke - now;
|
||||
if (slept - this.period > MINIMAL_DELTA_FOR_LOGGING) {
|
||||
LOG.warn("We slept " + slept + "ms instead of " + this.period +
|
||||
"ms, this is likely due to a long " +
|
||||
LOG.warn("We slept {}ms instead of {}ms, this is likely due to a long " +
|
||||
"garbage collecting pause and it's usually bad, see " +
|
||||
"http://hbase.apache.org/book.html#trouble.rs.runtime.zkexpired");
|
||||
"http://hbase.apache.org/book.html#trouble.rs.runtime.zkexpired", slept, this.period);
|
||||
}
|
||||
} catch(InterruptedException iex) {
|
||||
// We we interrupted because we're meant to stop? If not, just
|
||||
|
|
|
@ -25,9 +25,12 @@ import org.apache.yetus.audience.InterfaceAudience;
|
|||
* Utility for Strings.
|
||||
*/
|
||||
@InterfaceAudience.Private
|
||||
public class Strings {
|
||||
public final static String DEFAULT_SEPARATOR = "=";
|
||||
public final static String DEFAULT_KEYVALUE_SEPARATOR = ", ";
|
||||
public final class Strings {
|
||||
public static final String DEFAULT_SEPARATOR = "=";
|
||||
public static final String DEFAULT_KEYVALUE_SEPARATOR = ", ";
|
||||
|
||||
private Strings() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Append to a StringBuilder a key/value.
|
||||
|
@ -68,11 +71,12 @@ public class Strings {
|
|||
* host.example.com
|
||||
* @param dnPtr a domain name pointer (PTR) string.
|
||||
* @return Sanitized hostname with last period stripped off.
|
||||
*
|
||||
*/
|
||||
public static String domainNamePointerToHostName(String dnPtr) {
|
||||
if (dnPtr == null)
|
||||
if (dnPtr == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return dnPtr.endsWith(".") ? dnPtr.substring(0, dnPtr.length()-1) : dnPtr;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue