From 8874b64716b6a2e6d257dec51ac046eaefbf4c69 Mon Sep 17 00:00:00 2001 From: Toshihiro Suzuki Date: Sun, 8 Sep 2019 00:55:24 +0900 Subject: [PATCH] HBASE-11062 hbtop (addendum - fix error-prone errors) Signed-off-by: Duo Zhang --- .../main/java/org/apache/hadoop/hbase/hbtop/HBTop.java | 2 +- .../hbase/hbtop/mode/RegionServerModeStrategy.java | 1 - .../hadoop/hbase/hbtop/mode/TableModeStrategy.java | 1 - .../hbase/hbtop/screen/field/FieldScreenView.java | 8 ++++++++ .../hadoop/hbase/hbtop/screen/mode/ModeScreenView.java | 8 ++++++++ .../hbtop/screen/top/FilterDisplayModeScreenView.java | 5 ++--- .../hadoop/hbase/hbtop/screen/top/TopScreenView.java | 6 ++++++ .../hbase/hbtop/terminal/impl/KeyPressGenerator.java | 10 +++++++--- 8 files changed, 32 insertions(+), 9 deletions(-) diff --git a/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/HBTop.java b/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/HBTop.java index d657a370651..34c83f5989f 100644 --- a/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/HBTop.java +++ b/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/HBTop.java @@ -84,7 +84,7 @@ public class HBTop extends Configured implements Tool { if (delay < 1) { LOGGER.warn("Delay set too low or invalid, using default"); } else { - initialRefreshDelay = delay * 1000; + initialRefreshDelay = delay * 1000L; } } diff --git a/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/mode/RegionServerModeStrategy.java b/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/mode/RegionServerModeStrategy.java index 58380f665ae..d64f713da6a 100644 --- a/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/mode/RegionServerModeStrategy.java +++ b/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/mode/RegionServerModeStrategy.java @@ -24,7 +24,6 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; - import org.apache.hadoop.hbase.ClusterMetrics; import org.apache.hadoop.hbase.ServerMetrics; import org.apache.hadoop.hbase.hbtop.Record; diff --git a/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/mode/TableModeStrategy.java b/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/mode/TableModeStrategy.java index fb8d66d74e5..1da074fc918 100644 --- a/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/mode/TableModeStrategy.java +++ b/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/mode/TableModeStrategy.java @@ -21,7 +21,6 @@ import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; - import org.apache.hadoop.hbase.ClusterMetrics; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.hbtop.Record; diff --git a/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/screen/field/FieldScreenView.java b/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/screen/field/FieldScreenView.java index 0d9c6b98fec..92fdfda1e07 100644 --- a/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/screen/field/FieldScreenView.java +++ b/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/screen/field/FieldScreenView.java @@ -85,6 +85,10 @@ public class FieldScreenView extends AbstractScreenView { case Enter: fieldScreenPresenter.turnOffMoveMode(); return this; + + default: + // Do nothing + break; } if (keyPress.getType() != KeyPress.Type.Character) { @@ -104,6 +108,10 @@ public class FieldScreenView extends AbstractScreenView { case 'q': return fieldScreenPresenter.transitionToNextScreen(); + + default: + // Do nothing + break; } return this; diff --git a/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/screen/mode/ModeScreenView.java b/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/screen/mode/ModeScreenView.java index f3be127a954..bda9853028b 100644 --- a/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/screen/mode/ModeScreenView.java +++ b/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/screen/mode/ModeScreenView.java @@ -78,6 +78,10 @@ public class ModeScreenView extends AbstractScreenView { case End: modeScreenPresenter.pageDown(); return this; + + default: + // Do nothing + break; } if (keyPress.getType() != KeyPress.Type.Character) { @@ -88,6 +92,10 @@ public class ModeScreenView extends AbstractScreenView { switch (keyPress.getCharacter()) { case 'q': return modeScreenPresenter.transitionToNextScreen(false); + + default: + // Do nothing + break; } return this; diff --git a/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/screen/top/FilterDisplayModeScreenView.java b/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/screen/top/FilterDisplayModeScreenView.java index c186d73ca36..e85a4b7df42 100644 --- a/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/screen/top/FilterDisplayModeScreenView.java +++ b/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/screen/top/FilterDisplayModeScreenView.java @@ -54,9 +54,8 @@ public class FilterDisplayModeScreenView extends AbstractScreenView { @Override public ScreenView handleKeyPress(KeyPress keyPress) { - switch (keyPress.getType()) { - case Enter: - return filterDisplayModeScreenPresenter.returnToNextScreen(); + if (keyPress.getType() == KeyPress.Type.Enter) { + return filterDisplayModeScreenPresenter.returnToNextScreen(); } return this; } diff --git a/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/screen/top/TopScreenView.java b/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/screen/top/TopScreenView.java index 0f52b378202..9a2917701cb 100644 --- a/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/screen/top/TopScreenView.java +++ b/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/screen/top/TopScreenView.java @@ -115,6 +115,10 @@ public class TopScreenView extends AbstractScreenView { case Escape: return null; + + default: + // Do nothing + break; } if (keyPress.getType() != KeyPress.Type.Character) { @@ -178,12 +182,14 @@ public class TopScreenView extends AbstractScreenView { return this; } + @Override public TerminalSize getTerminalSize() { TerminalSize terminalSize = super.getTerminalSize(); updatePageSize(terminalSize); return terminalSize; } + @Override public TerminalSize doResizeIfNecessary() { TerminalSize terminalSize = super.doResizeIfNecessary(); if (terminalSize == null) { diff --git a/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/terminal/impl/KeyPressGenerator.java b/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/terminal/impl/KeyPressGenerator.java index 29122cbda0a..a20222c3eb5 100644 --- a/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/terminal/impl/KeyPressGenerator.java +++ b/hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/terminal/impl/KeyPressGenerator.java @@ -75,8 +75,8 @@ public class KeyPressGenerator { } public void start() { - executorService.submit(this::readerThread); - executorService.submit(this::generatorThread); + executorService.execute(this::readerThread); + executorService.execute(this::generatorThread); } private void initState() { @@ -158,6 +158,10 @@ public class KeyPressGenerator { case '\t': offer(new KeyPress(KeyPress.Type.Tab, '\t', false, false, false)); continue; + + default: + // Do nothing + break; } if (ch < 32) { @@ -248,7 +252,7 @@ public class KeyPressGenerator { return false; } Character.UnicodeBlock block = Character.UnicodeBlock.of(ch); - return block != null && block != Character.UnicodeBlock.SPECIALS; + return block != null && !block.equals(Character.UnicodeBlock.SPECIALS); } private void ctrlAltAndCharacter(char ch) {