HBASE-27236 Clean up error-prone warnings in hbase-hbtop (#4649)
Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
parent
0c4263a18b
commit
234cdf7b69
|
@ -36,6 +36,7 @@ import org.apache.yetus.audience.InterfaceAudience;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import org.apache.hbase.thirdparty.com.google.common.base.Splitter;
|
||||||
import org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine;
|
import org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.hbase.thirdparty.org.apache.commons.cli.DefaultParser;
|
import org.apache.hbase.thirdparty.org.apache.commons.cli.DefaultParser;
|
||||||
import org.apache.hbase.thirdparty.org.apache.commons.cli.HelpFormatter;
|
import org.apache.hbase.thirdparty.org.apache.commons.cli.HelpFormatter;
|
||||||
|
@ -119,6 +120,7 @@ public class HBTop extends Configured implements Tool {
|
||||||
try {
|
try {
|
||||||
delay = Integer.parseInt(commandLine.getOptionValue("delay"));
|
delay = Integer.parseInt(commandLine.getOptionValue("delay"));
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
|
// Deliberately ignored, we handle the issue below.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delay < 1) {
|
if (delay < 1) {
|
||||||
|
@ -163,7 +165,7 @@ public class HBTop extends Configured implements Tool {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commandLine.hasOption("fields")) {
|
if (commandLine.hasOption("fields")) {
|
||||||
String[] fields = commandLine.getOptionValue("fields").split(",");
|
Iterable<String> fields = Splitter.on(',').split(commandLine.getOptionValue("fields"));
|
||||||
initialFields = new ArrayList<>();
|
initialFields = new ArrayList<>();
|
||||||
for (String field : fields) {
|
for (String field : fields) {
|
||||||
Optional<FieldInfo> fieldInfo = initialMode.getFieldInfos().stream()
|
Optional<FieldInfo> fieldInfo = initialMode.getFieldInfos().stream()
|
||||||
|
@ -177,7 +179,7 @@ public class HBTop extends Configured implements Tool {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commandLine.hasOption("filters")) {
|
if (commandLine.hasOption("filters")) {
|
||||||
String[] filters = commandLine.getOptionValue("filters").split(",");
|
Iterable<String> filters = Splitter.on(',').split(commandLine.getOptionValue("filters"));
|
||||||
List<Field> fields = initialMode.getFieldInfos().stream().map(FieldInfo::getField)
|
List<Field> fields = initialMode.getFieldInfos().stream().map(FieldInfo::getField)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
for (String filter : filters) {
|
for (String filter : filters) {
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.yetus.audience.InterfaceAudience;
|
||||||
* Represents a display mode in the top screen.
|
* Represents a display mode in the top screen.
|
||||||
*/
|
*/
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
|
@SuppressWarnings("ImmutableEnumChecker")
|
||||||
public enum Mode {
|
public enum Mode {
|
||||||
NAMESPACE("Namespace", "Record per Namespace", new NamespaceModeStrategy()),
|
NAMESPACE("Namespace", "Record per Namespace", new NamespaceModeStrategy()),
|
||||||
TABLE("Table", "Record per Table", new TableModeStrategy()),
|
TABLE("Table", "Record per Table", new TableModeStrategy()),
|
||||||
|
|
|
@ -115,6 +115,7 @@ public final class RegionModeStrategy implements ModeStrategy {
|
||||||
elements.length == 4 ? Integer.valueOf(Bytes.toString(elements[3])).toString() : "";
|
elements.length == 4 ? Integer.valueOf(Bytes.toString(elements[3])).toString() : "";
|
||||||
region = RegionInfo.encodeRegionName(regionMetrics.getRegionName());
|
region = RegionInfo.encodeRegionName(regionMetrics.getRegionName());
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
|
// Exception deliberately ignored
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.put(Field.NAMESPACE, namespaceName);
|
builder.put(Field.NAMESPACE, namespaceName);
|
||||||
|
|
|
@ -61,6 +61,7 @@ public interface TerminalPrinter {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("AnnotateFormatMethod")
|
||||||
default TerminalPrinter printFormat(String format, Object... args) {
|
default TerminalPrinter printFormat(String format, Object... args) {
|
||||||
print(String.format(format, args));
|
print(String.format(format, args));
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -112,7 +112,10 @@ public class KeyPressGenerator {
|
||||||
} else {
|
} else {
|
||||||
Thread.sleep(20);
|
Thread.sleep(20);
|
||||||
}
|
}
|
||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException e) {
|
||||||
|
// Restore interrupt status
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
done = true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.error("Caught an exception", e);
|
LOGGER.error("Caught an exception", e);
|
||||||
done = true;
|
done = true;
|
||||||
|
|
|
@ -213,7 +213,9 @@ public class TerminalImpl implements Terminal {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
process.waitFor();
|
process.waitFor();
|
||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException e) {
|
||||||
|
// Restore interrupt status
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
int exitValue = process.exitValue();
|
int exitValue = process.exitValue();
|
||||||
|
|
|
@ -114,6 +114,7 @@ public final class TestUtils {
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("JavaUtilDate")
|
||||||
private static RegionMetrics createRegionMetrics(String regionName, long readRequestCount,
|
private static RegionMetrics createRegionMetrics(String regionName, long readRequestCount,
|
||||||
long filteredReadRequestCount, long writeRequestCount, Size storeFileSize,
|
long filteredReadRequestCount, long writeRequestCount, Size storeFileSize,
|
||||||
Size uncompressedStoreFileSize, int storeFileCount, Size memStoreSize, float locality,
|
Size uncompressedStoreFileSize, int storeFileCount, Size memStoreSize, float locality,
|
||||||
|
|
Loading…
Reference in New Issue