HBASE-19239 Fix findbugs and error-prone issues
Fixes for hbase-procedure
This commit is contained in:
parent
f856cbf414
commit
5b7411290b
|
@ -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);
|
||||
|
|
|
@ -146,6 +146,7 @@ public class TestChildProcedures {
|
|||
public static class TestRootProcedure extends SequentialProcedure<TestProcEnv> {
|
||||
public TestRootProcedure() {}
|
||||
|
||||
@Override
|
||||
public Procedure[] execute(TestProcEnv env) {
|
||||
if (env.toggleKillBeforeStoreUpdate) {
|
||||
ProcedureTestingUtility.toggleKillBeforeStoreUpdate(procExecutor);
|
||||
|
@ -153,6 +154,7 @@ public class TestChildProcedures {
|
|||
return new Procedure[] { new TestChildProcedure(), new TestChildProcedure() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rollback(TestProcEnv env) {
|
||||
}
|
||||
|
||||
|
@ -165,6 +167,7 @@ public class TestChildProcedures {
|
|||
public static class TestChildProcedure extends SequentialProcedure<TestProcEnv> {
|
||||
public TestChildProcedure() {}
|
||||
|
||||
@Override
|
||||
public Procedure[] execute(TestProcEnv env) {
|
||||
if (env.toggleKillBeforeStoreUpdate) {
|
||||
ProcedureTestingUtility.toggleKillBeforeStoreUpdate(procExecutor);
|
||||
|
@ -175,6 +178,7 @@ public class TestChildProcedures {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rollback(TestProcEnv env) {
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
@ -49,6 +48,7 @@ public class TestProcedureInMemoryChore {
|
|||
|
||||
private HBaseCommonTestingUtility htu;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Before
|
||||
public void setUp() throws IOException {
|
||||
htu = new HBaseCommonTestingUtility();
|
||||
|
|
|
@ -133,8 +133,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());
|
||||
}
|
||||
|
|
|
@ -193,7 +193,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;
|
||||
|
@ -358,7 +358,8 @@ public class TestYieldProcedures {
|
|||
|
||||
public TestRunQueue() {}
|
||||
|
||||
public void addFront(final Procedure proc) {
|
||||
@Override
|
||||
public void addFront(final Procedure proc) {
|
||||
addFrontCalls++;
|
||||
super.addFront(proc);
|
||||
}
|
||||
|
|
|
@ -72,7 +72,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
|
||||
|
@ -85,7 +85,7 @@ public class ProcedureWALLoaderPerformanceEvaluation extends AbstractHBaseTool {
|
|||
if (procIter.isNextCompleted()) {
|
||||
ProcedureInfo proc = procIter.nextAsProcedureInfo();
|
||||
} else {
|
||||
Procedure proc = procIter.nextAsProcedure();
|
||||
Procedure<?> proc = procIter.nextAsProcedure();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public class ProcedureWALLoaderPerformanceEvaluation extends AbstractHBaseTool {
|
|||
@Override
|
||||
public void handleCorrupted(ProcedureIterator procIter) throws IOException {
|
||||
while (procIter.hasNext()) {
|
||||
Procedure proc = procIter.nextAsProcedure();
|
||||
Procedure<?> proc = procIter.nextAsProcedure();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -171,8 +171,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) {
|
||||
|
|
|
@ -237,7 +237,7 @@ public class ProcedureWALPerformanceEvaluation extends AbstractHBaseTool {
|
|||
}
|
||||
}
|
||||
|
||||
public class NoSyncWalProcedureStore extends WALProcedureStore {
|
||||
public static class NoSyncWalProcedureStore extends WALProcedureStore {
|
||||
public NoSyncWalProcedureStore(final Configuration conf, final FileSystem fs,
|
||||
final Path logDir) {
|
||||
super(conf, fs, logDir, new WALProcedureStore.LeaseRecovery() {
|
||||
|
|
|
@ -53,6 +53,7 @@ public class TestTimeoutBlockingQueue {
|
|||
return timeout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("(%03d, %03d)", seqId, timeout);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue