Skip to content

Commit a8244d2

Browse files
committed
fix checkstyle warnings
1 parent e99b971 commit a8244d2

File tree

6 files changed

+71
-56
lines changed

6 files changed

+71
-56
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,8 @@ public void run() {
607607
shipEdits(entryBatch);
608608
manager.releaseBufferQuota(entryBatch.getHeapSizeExcludeBulkLoad());
609609
if (!entryBatch.hasMoreEntries()) {
610-
LOG.debug("Finished recovering queue for group " + walGroupId + " of peer " + peerClusterZnode);
610+
LOG.debug("Finished recovering queue for group "
611+
+ walGroupId + " of peer " + peerClusterZnode);
611612
metrics.incrCompletedRecoveryQueue();
612613
setWorkerState(WorkerState.FINISHED);
613614
}

hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceWALReaderThread.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,10 @@ public void run() {
131131
Threads.sleep(sleepForRetries);
132132
continue;
133133
}
134-
WALEntryBatch batch = new WALEntryBatch(replicationBatchCountCapacity, replicationBatchSizeCapacity);
134+
WALEntryBatch batch =
135+
new WALEntryBatch(replicationBatchCountCapacity, replicationBatchSizeCapacity);
135136
boolean hasNext;
136-
while (hasNext = entryStream.hasNext()) {
137+
while ((hasNext = entryStream.hasNext()) != true) {
137138
Entry entry = entryStream.next();
138139
entry = filterEntry(entry);
139140
if (entry != null) {
@@ -150,7 +151,8 @@ public void run() {
150151
}
151152

152153
if (LOG.isTraceEnabled()) {
153-
LOG.trace(String.format("Read %s WAL entries eligible for replication", batch.getNbEntries()));
154+
LOG.trace(String.format("Read %s WAL entries eligible for replication",
155+
batch.getNbEntries()));
154156
}
155157

156158
updateBatch(entryStream, batch, hasNext);
@@ -193,7 +195,7 @@ private boolean isShippable(WALEntryBatch batch) {
193195

194196
private boolean checkIfWALRolled(WALEntryBatch batch) {
195197
return currentPath == null && batch.lastWalPath != null
196-
|| currentPath != null && !currentPath.equals(batch.lastWalPath);
198+
|| currentPath != null && !currentPath.equals(batch.lastWalPath);
197199
}
198200

199201
private void resetStream(WALEntryStream stream) throws IOException {
@@ -280,7 +282,8 @@ static class WALEntryBatch {
280282
private long heapSizeExcludeBulkLoad;
281283

282284
/**
283-
* @param maxNbEntries
285+
* @param maxNbEntries the number of entries a batch can have
286+
* @param maxSizeBytes max (heap) size of each batch
284287
*/
285288
private WALEntryBatch(int maxNbEntries, long maxSizeBytes) {
286289
this.walEntries = new ArrayList<>(maxNbEntries);

hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
import org.apache.hadoop.hbase.wal.WAL;
6969
import org.apache.hadoop.hbase.wal.WALFactory;
7070
import org.apache.hadoop.hbase.wal.WALKey;
71-
import org.apache.hadoop.hbase.wal.WALProvider;
7271
import org.apache.hadoop.mapreduce.Job;
7372
import org.junit.Before;
7473
import org.junit.Test;
@@ -832,7 +831,8 @@ public void testEmptyWALRecovery() throws Exception {
832831
Path currentWalPath = DefaultWALProvider.getCurrentFileName(wal);
833832
String walGroupId = DefaultWALProvider.getWALPrefixFromWALName(currentWalPath.getName());
834833
Path emptyWalPath = new Path(currentWalPath.getParent(), walGroupId + "." + ts);
835-
WALFactory.createWALWriter(utility1.getTestFileSystem(), emptyWalPath, utility1.getConfiguration()).close();
834+
WALFactory.createWALWriter(utility1.getTestFileSystem(),
835+
emptyWalPath, utility1.getConfiguration()).close();
836836
emptyWalPaths.add(emptyWalPath);
837837
}
838838

hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSource.java

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,33 @@
1616
* See the License for the specific language governing permissions and
1717
* limitations under the License.
1818
*/
19+
1920
package org.apache.hadoop.hbase.replication;
2021

22+
import static org.apache.hadoop.hbase.replication.TestReplicationEndpoint.ReplicationEndpointForTest;
23+
import static org.hamcrest.CoreMatchers.is;
24+
import static org.hamcrest.MatcherAssert.assertThat;
2125
import static org.junit.Assert.assertEquals;
2226
import static org.junit.Assert.assertNotNull;
2327
import static org.junit.Assert.assertNull;
28+
import static org.junit.Assert.assertTrue;
29+
import static org.mockito.Matchers.anyBoolean;
30+
import static org.mockito.Matchers.anyString;
31+
import static org.mockito.Mockito.mock;
32+
import static org.mockito.Mockito.verify;
33+
import static org.mockito.Mockito.when;
34+
import static org.mockito.internal.verification.VerificationModeFactory.times;
2435

2536
import java.io.IOException;
37+
import java.util.Collections;
38+
import java.util.List;
39+
import java.util.Map;
40+
import java.util.NavigableMap;
41+
import java.util.TreeMap;
42+
import java.util.UUID;
2643
import java.util.concurrent.ExecutorService;
2744
import java.util.concurrent.Executors;
2845
import java.util.concurrent.Future;
29-
import java.util.concurrent.atomic.AtomicLong;
3046

3147
import org.apache.commons.logging.Log;
3248
import org.apache.commons.logging.LogFactory;
@@ -63,26 +79,8 @@
6379
import org.junit.BeforeClass;
6480
import org.junit.Test;
6581
import org.junit.experimental.categories.Category;
66-
import org.mockito.Mockito;
6782
import org.mockito.ArgumentCaptor;
68-
69-
import java.util.Collections;
70-
import java.util.List;
71-
import java.util.Map;
72-
import java.util.NavigableMap;
73-
import java.util.TreeMap;
74-
import java.util.UUID;
75-
76-
import static org.apache.hadoop.hbase.replication.TestReplicationEndpoint.ReplicationEndpointForTest;
77-
import static org.hamcrest.CoreMatchers.is;
78-
import static org.hamcrest.MatcherAssert.assertThat;
79-
import static org.junit.Assert.assertTrue;
80-
import static org.mockito.Matchers.anyBoolean;
81-
import static org.mockito.Matchers.anyString;
82-
import static org.mockito.Mockito.mock;
83-
import static org.mockito.Mockito.verify;
84-
import static org.mockito.Mockito.when;
85-
import static org.mockito.internal.verification.VerificationModeFactory.times;
83+
import org.mockito.Mockito;
8684

8785
@Category(MediumTests.class)
8886
public class TestReplicationSource {
@@ -114,8 +112,12 @@ public static void setUpBeforeClass() throws Exception {
114112

115113
@Before
116114
public void setup() throws IOException {
117-
if (!FS.exists(logDir)) FS.mkdirs(logDir);
118-
if (!FS.exists(oldLogDir)) FS.mkdirs(oldLogDir);
115+
if (!FS.exists(logDir)) {
116+
FS.mkdirs(logDir);
117+
}
118+
if (!FS.exists(oldLogDir)) {
119+
FS.mkdirs(oldLogDir);
120+
}
119121

120122
ReplicationEndpointForTest.contructedCount.set(0);
121123
ReplicationEndpointForTest.startedCount.set(0);
@@ -126,8 +128,12 @@ public void setup() throws IOException {
126128

127129
@After
128130
public void tearDown() throws IOException {
129-
if (FS.exists(oldLogDir)) FS.delete(oldLogDir, true);
130-
if (FS.exists(logDir)) FS.delete(logDir, true);
131+
if (FS.exists(oldLogDir)) {
132+
FS.delete(oldLogDir, true);
133+
}
134+
if (FS.exists(logDir)) {
135+
FS.delete(logDir, true);
136+
}
131137
}
132138

133139
@AfterClass
@@ -224,8 +230,9 @@ public boolean evaluate() throws Exception {
224230

225231
}
226232

227-
private void appendEntries(WALProvider.Writer writer, int numEntries, boolean closeAfterAppends) throws IOException {
228-
for(int i = 0; i < numEntries; i++) {
233+
private void appendEntries(WALProvider.Writer writer, int numEntries, boolean closeAfterAppends)
234+
throws IOException {
235+
for (int i = 0; i < numEntries; i++) {
229236
byte[] b = Bytes.toBytes(Integer.toString(i));
230237
KeyValue kv = new KeyValue(b,b,b);
231238
WALEdit edit = new WALEdit();
@@ -255,7 +262,7 @@ private long getPosition(WALFactory wals, Path log2, int numEntries) throws IOEx
255262
return reader.getPosition();
256263
}
257264

258-
private static class Mocks {
265+
private static final class Mocks {
259266
private final ReplicationSourceManager manager = mock(ReplicationSourceManager.class);
260267
private final ReplicationQueues queues = mock(ReplicationQueues.class);
261268
private final ReplicationPeers peers = mock(ReplicationPeers.class);
@@ -268,7 +275,8 @@ private Mocks() {
268275
when(context.getReplicationPeer()).thenReturn(peer);
269276
}
270277

271-
ReplicationSource createReplicationSourceWithMocks(ReplicationEndpoint endpoint) throws IOException {
278+
ReplicationSource createReplicationSourceWithMocks(ReplicationEndpoint endpoint)
279+
throws IOException {
272280
final ReplicationSource source = new ReplicationSource();
273281
endpoint.init(context);
274282
source.init(conf, FS, manager, queues, peers, mock(Stoppable.class),
@@ -317,7 +325,8 @@ public WALEntryFilter getWALEntryfilter() {
317325
ArgumentCaptor<Path> pathCaptor = ArgumentCaptor.forClass(Path.class);
318326
ArgumentCaptor<Long> positionCaptor = ArgumentCaptor.forClass(Long.class);
319327
verify(mocks.manager, times(1))
320-
.logPositionAndCleanOldLogs(pathCaptor.capture(), anyString(), positionCaptor.capture(), anyBoolean(), anyBoolean());
328+
.logPositionAndCleanOldLogs(pathCaptor.capture(), anyString(), positionCaptor.capture(),
329+
anyBoolean(), anyBoolean());
321330
assertTrue(endpoint.lastEntries.size() == 5);
322331
assertThat(pathCaptor.getValue(), is(log2));
323332
assertThat(positionCaptor.getValue(), is(pos));
@@ -352,7 +361,8 @@ public void testSetLogPositionAndRemoveOldWALsEvenIfEmptyWALsRolled() throws Exc
352361
ArgumentCaptor<Long> positionCaptor = ArgumentCaptor.forClass(Long.class);
353362

354363
verify(mocks.manager, times(1))
355-
.logPositionAndCleanOldLogs(pathCaptor.capture(), anyString(), positionCaptor.capture(), anyBoolean(), anyBoolean());
364+
.logPositionAndCleanOldLogs(pathCaptor.capture(), anyString(), positionCaptor.capture(),
365+
anyBoolean(), anyBoolean());
356366
assertThat(pathCaptor.getValue(), is(log2));
357367
assertThat(positionCaptor.getValue(), is(startPos));
358368
}
@@ -362,7 +372,8 @@ public void testSetLogPositionAndRemoveOldWALsEvenIfNoCfsReplicated() throws Exc
362372
Mocks mocks = new Mocks();
363373
// set table cfs to filter all cells out
364374
final TableName replicatedTable = TableName.valueOf("replicated_table");
365-
final Map<TableName, List<String>> cfs = Collections.singletonMap(replicatedTable, Collections.<String>emptyList());
375+
final Map<TableName, List<String>> cfs =
376+
Collections.singletonMap(replicatedTable, Collections.<String>emptyList());
366377
when(mocks.peer.getTableCFs()).thenReturn(cfs);
367378

368379
WALFactory wals = new WALFactory(TEST_UTIL.getConfiguration(), null, "test");
@@ -391,17 +402,17 @@ public void testSetLogPositionAndRemoveOldWALsEvenIfNoCfsReplicated() throws Exc
391402
ArgumentCaptor<Path> pathCaptor = ArgumentCaptor.forClass(Path.class);
392403
ArgumentCaptor<Long> positionCaptor = ArgumentCaptor.forClass(Long.class);
393404

394-
// all old wals should be removed by updating wal position, even if no cfs replicated doesn't exist
405+
// all old wals should be removed by updating wal position, even if all cells are filtered out.
395406
verify(mocks.manager, times(1))
396-
.logPositionAndCleanOldLogs(pathCaptor.capture(), anyString(), positionCaptor.capture(), anyBoolean(), anyBoolean());
407+
.logPositionAndCleanOldLogs(pathCaptor.capture(), anyString(), positionCaptor.capture(),
408+
anyBoolean(), anyBoolean());
397409
assertThat(pathCaptor.getValue(), is(log2));
398410
assertThat(positionCaptor.getValue(), is(pos));
399411
}
400412

401413
/**
402414
* Tests that recovered queues are preserved on a regionserver shutdown.
403415
* See HBASE-18192
404-
* @throws Exception
405416
*/
406417
@Test
407418
public void testServerShutdownRecoveredQueue() throws Exception {

hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestGlobalReplicationThrottler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
package org.apache.hadoop.hbase.replication.regionserver;
2121

2222
import java.io.IOException;
23-
import java.util.concurrent.atomic.AtomicLong;
2423

2524
import org.apache.commons.logging.Log;
2625
import org.apache.commons.logging.LogFactory;

hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestWALEntryStream.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import java.util.concurrent.Executors;
4343
import java.util.concurrent.Future;
4444
import java.util.concurrent.PriorityBlockingQueue;
45-
import java.util.concurrent.atomic.AtomicLong;
4645

4746
import org.apache.hadoop.conf.Configuration;
4847
import org.apache.hadoop.fs.FileSystem;
@@ -360,8 +359,9 @@ public void testReplicationSourceWALReaderThread() throws Exception {
360359

361360
// start up a batcher
362361
ReplicationSourceManager mockSourceManager = Mockito.mock(ReplicationSourceManager.class);
363-
ReplicationSourceWALReaderThread batcher = new ReplicationSourceWALReaderThread(mockSourceManager, getQueueInfo(),walQueue, 0,
364-
fs, conf, getDummyFilter(), new MetricsSource("1"));
362+
ReplicationSourceWALReaderThread batcher =
363+
new ReplicationSourceWALReaderThread(mockSourceManager, getQueueInfo(),walQueue, 0,
364+
fs, conf, getDummyFilter(), new MetricsSource("1"));
365365
Path walPath = walQueue.peek();
366366
batcher.start();
367367
WALEntryBatch entryBatch = batcher.take();
@@ -386,8 +386,8 @@ public void testReplicationSourceWALReaderThreadRecoveredQueue() throws Exceptio
386386
appendEntriesToLog(2);
387387

388388
long position;
389-
try (WALEntryStream entryStream =
390-
new WALEntryStream(new PriorityBlockingQueue<>(walQueue), fs, conf, new MetricsSource("1"))) {
389+
try (WALEntryStream entryStream = new WALEntryStream(new PriorityBlockingQueue<>(walQueue),
390+
fs, conf, new MetricsSource("1"))) {
391391
entryStream.next();
392392
entryStream.next();
393393
entryStream.next();
@@ -397,8 +397,9 @@ public void testReplicationSourceWALReaderThreadRecoveredQueue() throws Exceptio
397397
}
398398

399399
ReplicationSourceManager mockSourceManager = mock(ReplicationSourceManager.class);
400-
ReplicationSourceWALReaderThread reader = new ReplicationSourceWALReaderThread(mockSourceManager,
401-
getQueueInfo("1-1"), walQueue, 0, fs, conf, getDummyFilter(), new MetricsSource("1"));
400+
ReplicationSourceWALReaderThread reader =
401+
new ReplicationSourceWALReaderThread(mockSourceManager, getQueueInfo("1-1"),
402+
walQueue, 0, fs, conf, getDummyFilter(), new MetricsSource("1"));
402403
Path walPath = walQueue.toArray(new Path[2])[1];
403404
reader.start();
404405
WALEntryBatch entryBatch = reader.take();
@@ -433,7 +434,7 @@ public void testWALKeySerialization() throws Exception {
433434
for (Map.Entry<String, byte[]> entry : deserializedKey.getExtendedAttributes().entrySet()) {
434435
assertArrayEquals(key.getExtendedAttribute(entry.getKey()), entry.getValue());
435436
}
436-
}
437+
}
437438

438439
@Test
439440
public void testReplicationSourceWALReaderThreadWithFilter() throws Exception {
@@ -448,8 +449,9 @@ public void testReplicationSourceWALReaderThreadWithFilter() throws Exception {
448449

449450
Path firstWAL = walQueue.peek();
450451
ReplicationSourceManager mockSourceManager = mock(ReplicationSourceManager.class);
451-
final ReplicationSourceWALReaderThread reader = new ReplicationSourceWALReaderThread(mockSourceManager,
452-
getQueueInfo(), walQueue, 0, fs, conf, filter, new MetricsSource("1"));
452+
final ReplicationSourceWALReaderThread reader =
453+
new ReplicationSourceWALReaderThread(mockSourceManager, getQueueInfo(), walQueue,
454+
0, fs, conf, filter, new MetricsSource("1"));
453455
reader.start();
454456

455457
// reader won't put any batch, even if EOF reached.
@@ -470,8 +472,8 @@ public WALEntryBatch call() throws Exception {
470472
WALEntryBatch entryBatch = reader.take();
471473

472474
Path lastWAL= walQueue.peek();
473-
WALEntryStream entryStream =
474-
new WALEntryStream(new PriorityBlockingQueue<>(walQueue), fs, conf, new MetricsSource("1"));
475+
WALEntryStream entryStream = new WALEntryStream(new PriorityBlockingQueue<>(walQueue),
476+
fs, conf, new MetricsSource("1"));
475477
entryStream.hasNext();
476478
long positionToBeLogged = entryStream.getPosition();
477479

@@ -564,5 +566,4 @@ public void preLogRoll(Path oldPath, Path newPath) throws IOException {
564566
currentPath = newPath;
565567
}
566568
}
567-
568569
}

0 commit comments

Comments
 (0)