Skip to content

Commit b39b63e

Browse files
committed
fix checkstyle complaints
1 parent 6a52d29 commit b39b63e

File tree

2 files changed

+11
-13
lines changed
  • hadoop-common-project/hadoop-common/src

2 files changed

+11
-13
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Client.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.apache.hadoop.security.AccessControlException;
2323
import org.apache.hadoop.classification.VisibleForTesting;
2424
import org.apache.hadoop.util.Preconditions;
25-
import org.apache.hadoop.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder;
2625
import org.apache.hadoop.classification.InterfaceAudience;
2726
import org.apache.hadoop.classification.InterfaceAudience.Public;
2827
import org.apache.hadoop.classification.InterfaceStability;
@@ -376,7 +375,7 @@ private class Connection extends Thread {
376375
private IOException closeException; // close reason
377376

378377
private final Thread rpcRequestThread;
379-
private final SynchronousQueue<Pair<Call,ResponseBuffer>> rpcRequestQueue =
378+
private final SynchronousQueue<Pair<Call, ResponseBuffer>> rpcRequestQueue =
380379
new SynchronousQueue<>(true);
381380

382381
private AtomicReference<Thread> connectingThread = new AtomicReference<>();

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPC.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
import java.util.concurrent.Executors;
8989
import java.util.concurrent.Future;
9090
import java.util.concurrent.ThreadLocalRandom;
91-
import java.util.concurrent.ThreadPoolExecutor;
9291
import java.util.concurrent.TimeUnit;
9392
import java.util.concurrent.atomic.AtomicBoolean;
9493
import java.util.concurrent.atomic.AtomicInteger;
@@ -951,9 +950,9 @@ public void run() {
951950
* We use a mock SocketFactory so that we can control when the input and
952951
* output streams are frozen.
953952
*/
954-
@Test
953+
@Test(timeout=30000)
955954
public void testSlowConnection() throws Exception {
956-
final int NUM_THREADS = 5;
955+
final int numThreads = 5;
957956
SocketFactory mockFactory = Mockito.mock(SocketFactory.class);
958957
Socket mockSocket = Mockito.mock(Socket.class);
959958
Mockito.when(mockFactory.createSocket()).thenReturn(mockSocket);
@@ -997,17 +996,17 @@ public int read() throws IOException {
997996
// The connection isn't actually made until the first call.
998997
client.ping(null, newEmptyRequest());
999998
mockOutputStream.waitForFlush(1);
1000-
final long header_and_first = mockOutputStream.bytesWritten;
999+
final long headerAndFirst = mockOutputStream.bytesWritten;
10011000
client.ping(null, newEmptyRequest());
10021001
mockOutputStream.waitForFlush(2);
1003-
final long second = mockOutputStream.bytesWritten - header_and_first;
1002+
final long second = mockOutputStream.bytesWritten - headerAndFirst;
10041003
// pause the writer thread
10051004
mockOutputStream.pause();
10061005
// create a set of threads to create calls that will back up
10071006
ExecutorService pool = Executors.newCachedThreadPool();
1008-
Future<Void>[] futures = new Future[NUM_THREADS];
1007+
Future<Void>[] futures = new Future[numThreads];
10091008
final AtomicInteger doneThreads = new AtomicInteger(0);
1010-
for(int thread = 0; thread < NUM_THREADS; ++thread) {
1009+
for(int thread = 0; thread < numThreads; ++thread) {
10111010
final TestRpcService finalClient = client;
10121011
futures[thread] = pool.submit(new Callable<Void>() {
10131012
@Override
@@ -1021,7 +1020,7 @@ public Void call() throws Exception {
10211020
// wait until one of the threads has started writing
10221021
mockOutputStream.waitForWriters();
10231022
// interrupt all the threads
1024-
for(int thread=0; thread < NUM_THREADS; ++thread) {
1023+
for(int thread=0; thread < numThreads; ++thread) {
10251024
futures[thread].cancel(true);
10261025
}
10271026
mockOutputStream.resume();
@@ -1030,7 +1029,7 @@ public Void call() throws Exception {
10301029
// All the threads should have been interrupted
10311030
assertEquals(0, doneThreads.get());
10321031
// make sure that only one additional rpc request was sent
1033-
assertEquals(header_and_first + second * 2, mockOutputStream.bytesWritten);
1032+
assertEquals(headerAndFirst + second * 2, mockOutputStream.bytesWritten);
10341033
} finally {
10351034
Client.setAsynchronousMode(wasAsync);
10361035
if (client != null) {
@@ -1040,8 +1039,8 @@ public Void call() throws Exception {
10401039
}
10411040

10421041
private static final class MockOutputStream extends OutputStream {
1043-
long bytesWritten = 0;
1044-
AtomicInteger flushCount = new AtomicInteger(0);
1042+
private long bytesWritten = 0;
1043+
private AtomicInteger flushCount = new AtomicInteger(0);
10451044
private ReentrantLock lock = new ReentrantLock(true);
10461045

10471046
@Override

0 commit comments

Comments
 (0)