Skip to content

Commit 62dd798

Browse files
committed
HBASE-19763 Fixed Checkstyle errors in hbase-procedure
1 parent 268bcce commit 62dd798

36 files changed

+247
-174
lines changed

hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/AbstractProcedureScheduler.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
1918
package org.apache.hadoop.hbase.procedure2;
2019

2120
import java.util.Iterator;
21+
import java.util.concurrent.TimeUnit;
2222
import java.util.concurrent.locks.Condition;
2323
import java.util.concurrent.locks.ReentrantLock;
24-
import java.util.concurrent.TimeUnit;
2524

2625
import org.apache.yetus.audience.InterfaceAudience;
2726
import org.slf4j.Logger;
@@ -279,7 +278,6 @@ protected void wakeProcedure(final Procedure procedure) {
279278
push(procedure, /* addFront= */ true, /* notify= */false);
280279
}
281280

282-
283281
// ==========================================================================
284282
// Internal helpers
285283
// ==========================================================================

hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/BadProcedureException.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
1918
package org.apache.hadoop.hbase.procedure2;
2019

20+
import org.apache.hadoop.hbase.HBaseIOException;
2121
import org.apache.yetus.audience.InterfaceAudience;
2222
import org.apache.yetus.audience.InterfaceStability;
23-
import org.apache.hadoop.hbase.HBaseIOException;
2423

2524
@InterfaceAudience.Private
2625
@InterfaceStability.Stable

hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/LockedResource.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
1918
package org.apache.hadoop.hbase.procedure2;
2019

2120
import java.util.List;
2221

2322
import org.apache.yetus.audience.InterfaceAudience;
24-
import org.apache.hadoop.hbase.procedure2.LockedResourceType;
2523

2624
@InterfaceAudience.Private
2725
public class LockedResource {

hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/Procedure.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
1918
package org.apache.hadoop.hbase.procedure2;
2019

2120
import java.io.IOException;
@@ -209,11 +208,12 @@ protected final void skipPersistence() {
209208
* of the execution.
210209
* @param env the environment passed to the ProcedureExecutor
211210
* @return a set of sub-procedures to run or ourselves if there is more work to do or null if the
212-
* procedure is done.
213-
* @throws ProcedureYieldException the procedure will be added back to the queue and retried later.
211+
* procedure is done.
212+
* @throws ProcedureYieldException the procedure will be added back to the queue and retried
213+
* later.
214214
* @throws InterruptedException the procedure will be added back to the queue and retried later.
215-
* @throws ProcedureSuspendedException Signal to the executor that Procedure has suspended itself and
216-
* has set itself up waiting for an external event to wake it back up again.
215+
* @throws ProcedureSuspendedException Signal to the executor that Procedure has suspended itself
216+
* and has set itself up waiting for an external event to wake it back up again.
217217
*/
218218
protected abstract Procedure<TEnvironment>[] execute(TEnvironment env)
219219
throws ProcedureYieldException, ProcedureSuspendedException, InterruptedException;
@@ -468,7 +468,7 @@ protected StringBuilder toStringSimpleSB() {
468468
sb.append(getParentProcId());
469469
}
470470

471-
/**
471+
/*
472472
* TODO
473473
* Enable later when this is being used.
474474
* Currently owner not used.
@@ -710,7 +710,7 @@ protected void setResult(byte[] result) {
710710
/**
711711
* Will only be called when loading procedures from procedure store, where we need to record
712712
* whether the procedure has already held a lock. Later we will call
713-
* {@link #restoreLock(Object, ProcedureStore)} to actually acquire the lock.
713+
* {@link #restoreLock(Object)} to actually acquire the lock.
714714
*/
715715
final void lockedWhenLoading() {
716716
this.lockedWhenLoading = true;
@@ -764,7 +764,7 @@ public synchronized boolean isSuccess() {
764764

765765
/**
766766
* @return true if the procedure is finished. The Procedure may be completed successfully or
767-
* rolledback.
767+
* rolledback.
768768
*/
769769
public synchronized boolean isFinished() {
770770
return isSuccess() || state == ProcedureState.ROLLEDBACK;

hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureDeque.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@
1616
* See the License for the specific language governing permissions and
1717
* limitations under the License.
1818
*/
19-
2019
package org.apache.hadoop.hbase.procedure2;
2120

22-
import org.apache.yetus.audience.InterfaceAudience;
23-
import org.apache.hadoop.hbase.procedure2.Procedure;
24-
2521
import java.util.ArrayDeque;
2622

23+
import org.apache.yetus.audience.InterfaceAudience;
24+
2725
/**
2826
* Type class.
2927
* For conceptual purpose only. Seeing ProcedureDeque as type instead of just ArrayDeque gives

hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureException.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
1918
package org.apache.hadoop.hbase.procedure2;
2019

20+
import org.apache.hadoop.hbase.exceptions.HBaseException;
2121
import org.apache.yetus.audience.InterfaceAudience;
2222
import org.apache.yetus.audience.InterfaceStability;
23-
import org.apache.hadoop.hbase.exceptions.HBaseException;
2423

2524
@InterfaceAudience.Private
2625
@InterfaceStability.Stable

hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureExecutor.java

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -433,23 +433,21 @@ private void loadProcedures(ProcedureIterator procIter, boolean abortOnCorruptio
433433
}
434434
}
435435

436-
// add the nonce to the map
437436
if (nonceKey != null) {
438-
nonceKeysToProcIdsMap.put(nonceKey, procId);
437+
nonceKeysToProcIdsMap.put(nonceKey, procId); // add the nonce to the map
439438
}
440439
}
441440

442-
// 2. Initialize the stacks
443-
// In the old implementation, for procedures in FAILED state, we will push it into the
444-
// ProcedureScheduler directly to execute the rollback. But this does not work after we
445-
// introduce the restore lock stage.
446-
// For now, when we acquire a xlock, we will remove the queue from runQueue in scheduler, and
447-
// then when a procedure which has lock access, for example, a sub procedure of the procedure
448-
// which has the xlock, is pushed into the scheduler, we will add the queue back to let the
449-
// workers poll from it. The assumption here is that, the procedure which has the xlock should
450-
// have been polled out already, so when loading we can not add the procedure to scheduler first
451-
// and then call acquireLock, since the procedure is still in the queue, and since we will
452-
// remove the queue from runQueue, then no one can poll it out, then there is a dead lock
441+
// 2. Initialize the stacks: In the old implementation, for procedures in FAILED state, we will
442+
// push it into the ProcedureScheduler directly to execute the rollback. But this does not work
443+
// after we introduce the restore lock stage. For now, when we acquire a xlock, we will remove
444+
// the queue from runQueue in scheduler, and then when a procedure which has lock access, for
445+
// example, a sub procedure of the procedure which has the xlock, is pushed into the scheduler,
446+
// we will add the queue back to let the workers poll from it. The assumption here is that, the
447+
// procedure which has the xlock should have been polled out already, so when loading we can not
448+
// add the procedure to scheduler first and then call acquireLock, since the procedure is still
449+
// in the queue, and since we will remove the queue from runQueue, then no one can poll it out,
450+
// then there is a dead lock
453451
List<Procedure<TEnvironment>> runnableList = new ArrayList<>(runnableCount);
454452
List<Procedure<TEnvironment>> failedList = new ArrayList<>(failedCount);
455453
List<Procedure<TEnvironment>> waitingList = new ArrayList<>(waitingCount);
@@ -464,9 +462,7 @@ private void loadProcedures(ProcedureIterator procIter, boolean abortOnCorruptio
464462
@SuppressWarnings("unchecked")
465463
Procedure<TEnvironment> proc = procIter.next();
466464
assert !(proc.isFinished() && !proc.hasParent()) : "unexpected completed proc=" + proc;
467-
468465
LOG.debug("Loading {}", proc);
469-
470466
Long rootProcId = getRootProcedureId(proc);
471467
// The orphan procedures will be passed to handleCorrupted, so add an assert here
472468
assert rootProcId != null;
@@ -508,14 +504,12 @@ private void loadProcedures(ProcedureIterator procIter, boolean abortOnCorruptio
508504
// 3. Check the waiting procedures to see if some of them can be added to runnable.
509505
waitingList.forEach(proc -> {
510506
if (!proc.hasChildren()) {
511-
// Normally, WAITING procedures should be waken by its children.
512-
// But, there is a case that, all the children are successful and before
513-
// they can wake up their parent procedure, the master was killed.
514-
// So, during recovering the procedures from ProcedureWal, its children
515-
// are not loaded because of their SUCCESS state.
516-
// So we need to continue to run this WAITING procedure. But before
517-
// executing, we need to set its state to RUNNABLE, otherwise, a exception
518-
// will throw:
507+
// Normally, WAITING procedures should be waken by its children. But, there is a case that,
508+
// all the children are successful and before they can wake up their parent procedure, the
509+
// master was killed. So, during recovering the procedures from ProcedureWal, its children
510+
// are not loaded because of their SUCCESS state. So we need to continue to run this WAITING
511+
// procedure. But before executing, we need to set its state to RUNNABLE, otherwise, a
512+
// exception will throw:
519513
// Preconditions.checkArgument(procedure.getState() == ProcedureState.RUNNABLE,
520514
// "NOT RUNNABLE! " + procedure.toString());
521515
proc.setState(ProcedureState.RUNNABLE);
@@ -743,9 +737,9 @@ public boolean removeChore(ProcedureInMemoryChore<TEnvironment> chore) {
743737
// Nonce Procedure helpers
744738
// ==========================================================================
745739
/**
746-
* Create a NoneKey from the specified nonceGroup and nonce.
747-
* @param nonceGroup
748-
* @param nonce
740+
* Create a NonceKey from the specified nonceGroup and nonce.
741+
* @param nonceGroup the group to use for the {@link NonceKey}
742+
* @param nonce the nonce to use in the {@link NonceKey}
749743
* @return the generated NonceKey
750744
*/
751745
public NonceKey createNonceKey(final long nonceGroup, final long nonce) {
@@ -764,7 +758,9 @@ public NonceKey createNonceKey(final long nonceGroup, final long nonce) {
764758
* @return the procId associated with the nonce, if any otherwise an invalid procId.
765759
*/
766760
public long registerNonce(final NonceKey nonceKey) {
767-
if (nonceKey == null) return -1;
761+
if (nonceKey == null) {
762+
return -1;
763+
}
768764

769765
// check if we have already a Reserved ID for the nonce
770766
Long oldProcId = nonceKeysToProcIdsMap.get(nonceKey);
@@ -773,7 +769,9 @@ public long registerNonce(final NonceKey nonceKey) {
773769
// and the procedure submitted with the specified nonce will use this ID.
774770
final long newProcId = nextProcId();
775771
oldProcId = nonceKeysToProcIdsMap.putIfAbsent(nonceKey, newProcId);
776-
if (oldProcId == null) return -1;
772+
if (oldProcId == null) {
773+
return -1;
774+
}
777775
}
778776

779777
// we found a registered nonce, but the procedure may not have been submitted yet.
@@ -795,10 +793,14 @@ public long registerNonce(final NonceKey nonceKey) {
795793
* @param nonceKey A unique identifier for this operation from the client or process.
796794
*/
797795
public void unregisterNonceIfProcedureWasNotSubmitted(final NonceKey nonceKey) {
798-
if (nonceKey == null) return;
796+
if (nonceKey == null) {
797+
return;
798+
}
799799

800800
final Long procId = nonceKeysToProcIdsMap.get(nonceKey);
801-
if (procId == null) return;
801+
if (procId == null) {
802+
return;
803+
}
802804

803805
// if the procedure was not submitted, remove the nonce
804806
if (!(procedures.containsKey(procId) || completed.containsKey(procId))) {
@@ -1295,8 +1297,9 @@ private long nextProcId() {
12951297
if (procId < 0) {
12961298
while (!lastProcId.compareAndSet(procId, 0)) {
12971299
procId = lastProcId.get();
1298-
if (procId >= 0)
1300+
if (procId >= 0) {
12991301
break;
1302+
}
13001303
}
13011304
while (procedures.containsKey(procId)) {
13021305
procId = lastProcId.incrementAndGet();
@@ -2003,7 +2006,6 @@ protected boolean keepAlive(long lastUpdate) {
20032006
// A worker thread which can be added when core workers are stuck. Will timeout after
20042007
// keepAliveTime if there is no procedure to run.
20052008
private final class KeepAliveWorkerThread extends WorkerThread {
2006-
20072009
public KeepAliveWorkerThread(ThreadGroup group) {
20082010
super(group, "KeepAlivePEWorker-");
20092011
}

hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureScheduler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
1918
package org.apache.hadoop.hbase.procedure2;
2019

2120
import java.util.Iterator;
@@ -117,7 +116,8 @@ public interface ProcedureScheduler {
117116
List<LockedResource> getLocks();
118117

119118
/**
120-
* @return {@link LockedResource} for resource of specified type & name. null if resource is not locked.
119+
* @return {@link LockedResource} for resource of specified type & name. null if resource is not
120+
* locked.
121121
*/
122122
LockedResource getLockResource(LockedResourceType resourceType, String resourceName);
123123

hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureUtil.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,19 @@
2323
import java.lang.reflect.Modifier;
2424
import java.util.concurrent.ThreadLocalRandom;
2525
import org.apache.hadoop.hbase.HConstants;
26+
import org.apache.hadoop.hbase.util.NonceKey;
2627
import org.apache.yetus.audience.InterfaceAudience;
28+
2729
import org.apache.hbase.thirdparty.com.google.common.base.Preconditions;
2830
import org.apache.hbase.thirdparty.com.google.protobuf.Any;
2931
import org.apache.hbase.thirdparty.com.google.protobuf.Internal;
3032
import org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException;
3133
import org.apache.hbase.thirdparty.com.google.protobuf.Message;
3234
import org.apache.hbase.thirdparty.com.google.protobuf.Parser;
3335
import org.apache.hbase.thirdparty.com.google.protobuf.UnsafeByteOperations;
36+
3437
import org.apache.hadoop.hbase.shaded.protobuf.generated.LockServiceProtos;
3538
import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos;
36-
import org.apache.hadoop.hbase.util.NonceKey;
3739

3840
/**
3941
* Helper to convert to/from ProcedureProtos

hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/RemoteProcedureDispatcher.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ public void addNode(final TRemote key) {
155155
* @param key the node identifier
156156
*/
157157
public void addOperationToNode(final TRemote key, RemoteProcedure rp)
158-
throws NullTargetServerDispatchException, NoServerDispatchException, NoNodeDispatchException {
158+
throws NullTargetServerDispatchException, NoServerDispatchException,
159+
NoNodeDispatchException {
159160
if (key == null) {
160161
throw new NullTargetServerDispatchException(rp.toString());
161162
}
@@ -188,7 +189,10 @@ public void removeCompletedOperation(final TRemote key, RemoteProcedure rp) {
188189
*/
189190
public boolean removeNode(final TRemote key) {
190191
final BufferNode node = nodeMap.remove(key);
191-
if (node == null) return false;
192+
if (node == null) {
193+
return false;
194+
}
195+
192196
node.abortOperationsInQueue();
193197
return true;
194198
}
@@ -256,7 +260,6 @@ public interface RemoteProcedure<TEnv, TRemote> {
256260
default boolean storeInDispatchedQueue() {
257261
return true;
258262
}
259-
260263
}
261264

262265
/**

0 commit comments

Comments
 (0)