From 0561312bc489ee96416a0bb2035d7713516eb222 Mon Sep 17 00:00:00 2001 From: Peter Somogyi Date: Wed, 17 Jan 2018 09:47:59 +0100 Subject: [PATCH] HBASE-19809 Fix findbugs and error-prone warnings in hbase-procedure (branch-2) --- .../hbase/procedure2/RemoteProcedureDispatcher.java | 3 +++ .../store/wal/ProcedureWALPrettyPrinter.java | 1 + .../apache/hadoop/hbase/procedure2/util/ByteSlot.java | 2 ++ .../hadoop/hbase/procedure2/TestProcedureEvents.java | 2 +- .../hadoop/hbase/procedure2/TestProcedureExecutor.java | 2 +- .../hbase/procedure2/TestProcedureInMemoryChore.java | 10 +++++----- .../hbase/procedure2/TestProcedureReplayOrder.java | 5 +++-- .../hbase/procedure2/TestStateMachineProcedure.java | 8 +++++++- .../hadoop/hbase/procedure2/TestYieldProcedures.java | 2 +- .../wal/ProcedureWALLoaderPerformanceEvaluation.java | 5 ++--- .../store/wal/ProcedureWALPerformanceEvaluation.java | 2 +- 11 files changed, 27 insertions(+), 15 deletions(-) diff --git a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/RemoteProcedureDispatcher.java b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/RemoteProcedureDispatcher.java index 71932b85009..72a2ebba79f 100644 --- a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/RemoteProcedureDispatcher.java +++ b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/RemoteProcedureDispatcher.java @@ -331,10 +331,12 @@ public abstract class RemoteProcedureDispatcher(); @@ -348,6 +350,7 @@ public abstract class RemoteProcedureDispatcher { + @Override protected Flow executeFromState(TestProcEnv env, TestSMProcedureState state) { LOG.info("EXEC " + state + " " + this); env.execCount.incrementAndGet(); @@ -168,25 +169,30 @@ public class TestStateMachineProcedure { return Flow.HAS_MORE_STATE; } + @Override protected void rollbackState(TestProcEnv env, TestSMProcedureState state) { LOG.info("ROLLBACK " + state + " " + this); env.rollbackCount.incrementAndGet(); } + @Override protected TestSMProcedureState getState(int stateId) { return TestSMProcedureState.values()[stateId]; } + @Override protected int getStateId(TestSMProcedureState state) { return state.ordinal(); } + @Override protected TestSMProcedureState getInitialState() { return TestSMProcedureState.STEP_1; } } public static class SimpleChildProcedure extends NoopProcedure { + @Override protected Procedure[] execute(TestProcEnv env) { LOG.info("EXEC " + this); env.execCount.incrementAndGet(); @@ -203,7 +209,7 @@ public class TestStateMachineProcedure { } } - public class TestProcEnv { + public static class TestProcEnv { AtomicInteger execCount = new AtomicInteger(0); AtomicInteger rollbackCount = new AtomicInteger(0); boolean triggerChildRollback = false; diff --git a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestYieldProcedures.java b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestYieldProcedures.java index 202353526aa..e6fc4bbd8a5 100644 --- a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestYieldProcedures.java +++ b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/TestYieldProcedures.java @@ -186,7 +186,7 @@ public class TestYieldProcedures { extends StateMachineProcedure { enum State { STATE_1, STATE_2, STATE_3 } - public class ExecutionInfo { + public static class ExecutionInfo { private final boolean rollback; private final long timestamp; private final State step; diff --git a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALLoaderPerformanceEvaluation.java b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALLoaderPerformanceEvaluation.java index 503850d3aa9..3c908fd0084 100644 --- a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALLoaderPerformanceEvaluation.java +++ b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALLoaderPerformanceEvaluation.java @@ -70,7 +70,7 @@ public class ProcedureWALLoaderPerformanceEvaluation extends AbstractHBaseTool { private WALProcedureStore store; static byte[] serializedState; - private class LoadCounter implements ProcedureStore.ProcedureLoader { + private static class LoadCounter implements ProcedureStore.ProcedureLoader { public LoadCounter() {} @Override @@ -165,8 +165,7 @@ public class ProcedureWALLoaderPerformanceEvaluation extends AbstractHBaseTool { private void writeWals() throws IOException { List procStates = shuffleProcWriteSequence(); TestProcedure[] procs = new TestProcedure[numProcs + 1]; // 0 is not used. - int numProcsPerWal = numWals > 0 ? (int)Math.ceil(procStates.size() / numWals) - : Integer.MAX_VALUE; + int numProcsPerWal = numWals > 0 ? procStates.size() / numWals : Integer.MAX_VALUE; long startTime = currentTimeMillis(); long lastTime = startTime; for (int i = 0; i < procStates.size(); ++i) { diff --git a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALPerformanceEvaluation.java b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALPerformanceEvaluation.java index 1a7fc800c09..12ed930fcce 100644 --- a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALPerformanceEvaluation.java +++ b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/ProcedureWALPerformanceEvaluation.java @@ -243,7 +243,7 @@ public class ProcedureWALPerformanceEvaluation extends AbstractHBaseTool { } } - private class NoSyncWalProcedureStore extends WALProcedureStore { + private static class NoSyncWalProcedureStore extends WALProcedureStore { public NoSyncWalProcedureStore(final Configuration conf, final Path logDir) throws IOException { super(conf, logDir, null, new WALProcedureStore.LeaseRecovery() { @Override