HBASE-19809 Fix findbugs and error-prone warnings in hbase-procedure (branch-2)
This commit is contained in:
parent
7224546b1e
commit
c269e63a07
|
@ -347,10 +347,12 @@ public abstract class RemoteProcedureDispatcher<TEnv, TRemote extends Comparable
|
|||
super(key, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TRemote getKey() {
|
||||
return getObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void add(final RemoteProcedure operation) {
|
||||
if (this.operations == null) {
|
||||
this.operations = new HashSet<>();
|
||||
|
@ -364,6 +366,7 @@ public abstract class RemoteProcedureDispatcher<TEnv, TRemote extends Comparable
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void dispatch() {
|
||||
if (operations != null) {
|
||||
remoteDispatch(getKey(), operations);
|
||||
|
|
|
@ -149,6 +149,7 @@ public class ProcedureWALPrettyPrinter extends Configured implements Tool {
|
|||
* @throws IOException
|
||||
* Thrown upon file system errors etc.
|
||||
*/
|
||||
@Override
|
||||
public int run(final String[] args) throws IOException {
|
||||
// create options
|
||||
Options options = new Options();
|
||||
|
|
|
@ -81,11 +81,13 @@ public class ByteSlot extends OutputStream {
|
|||
buf[offset] = (byte)b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) {
|
||||
ensureCapacity(size + 1);
|
||||
buf[size++] = (byte)b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) {
|
||||
ensureCapacity(size + len);
|
||||
System.arraycopy(b, off, buf, size, len);
|
||||
|
|
|
@ -160,7 +160,7 @@ public class TestProcedureEvents {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean setTimeoutFailure(final TestProcEnv env) {
|
||||
protected synchronized boolean setTimeoutFailure(final TestProcEnv env) {
|
||||
int n = ntimeouts.incrementAndGet();
|
||||
LOG.info("HANDLE TIMEOUT " + this + " ntimeouts=" + n);
|
||||
setState(ProcedureState.RUNNABLE);
|
||||
|
|
|
@ -186,5 +186,5 @@ public class TestProcedureExecutor {
|
|||
}
|
||||
}
|
||||
|
||||
private class TestProcEnv { }
|
||||
private static class TestProcEnv { }
|
||||
}
|
||||
|
|
|
@ -18,14 +18,17 @@
|
|||
|
||||
package org.apache.hadoop.hbase.procedure2;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.hadoop.hbase.HBaseCommonTestingUtility;
|
||||
import org.apache.hadoop.hbase.procedure2.store.NoopProcedureStore;
|
||||
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
||||
import org.apache.hadoop.hbase.testclassification.MasterTests;
|
||||
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -33,10 +36,6 @@ import org.junit.experimental.categories.Category;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@Category({MasterTests.class, SmallTests.class})
|
||||
public class TestProcedureInMemoryChore {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TestProcedureInMemoryChore.class);
|
||||
|
@ -49,6 +48,7 @@ public class TestProcedureInMemoryChore {
|
|||
|
||||
private HBaseCommonTestingUtility htu;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Before
|
||||
public void setUp() throws IOException {
|
||||
htu = new HBaseCommonTestingUtility();
|
||||
|
|
|
@ -132,8 +132,9 @@ public class TestProcedureReplayOrder {
|
|||
public void run() {
|
||||
for (int i = 0; i < nprocPerThread; ++i) {
|
||||
try {
|
||||
procExecutor.submitProcedure((Procedure)procClazz.newInstance());
|
||||
} catch (InstantiationException|IllegalAccessException e) {
|
||||
procExecutor.submitProcedure((Procedure)
|
||||
procClazz.getDeclaredConstructor().newInstance());
|
||||
} catch (Exception e) {
|
||||
LOG.error("unable to instantiate the procedure", e);
|
||||
fail("failure during the proc.newInstance(): " + e.getMessage());
|
||||
}
|
||||
|
|
|
@ -153,6 +153,7 @@ public class TestStateMachineProcedure {
|
|||
|
||||
public static class TestSMProcedure
|
||||
extends StateMachineProcedure<TestProcEnv, TestSMProcedureState> {
|
||||
@Override
|
||||
protected Flow executeFromState(TestProcEnv env, TestSMProcedureState state) {
|
||||
LOG.info("EXEC " + state + " " + this);
|
||||
env.execCount.incrementAndGet();
|
||||
|
@ -169,25 +170,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<TestProcEnv> {
|
||||
@Override
|
||||
protected Procedure[] execute(TestProcEnv env) {
|
||||
LOG.info("EXEC " + this);
|
||||
env.execCount.incrementAndGet();
|
||||
|
@ -204,7 +210,7 @@ public class TestStateMachineProcedure {
|
|||
}
|
||||
}
|
||||
|
||||
public class TestProcEnv {
|
||||
public static class TestProcEnv {
|
||||
AtomicInteger execCount = new AtomicInteger(0);
|
||||
AtomicInteger rollbackCount = new AtomicInteger(0);
|
||||
boolean triggerChildRollback = false;
|
||||
|
|
|
@ -186,7 +186,7 @@ public class TestYieldProcedures {
|
|||
extends StateMachineProcedure<TestProcEnv, TestStateMachineProcedure.State> {
|
||||
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;
|
||||
|
|
|
@ -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<Integer> 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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue