Skip to content

Commit 890f7c4

Browse files
committed
HADOOP-16830. Checkstyles and findbugs
Change-Id: I5f64704a82a196fd8ff66cbde10d4970722e1fd7
1 parent c9f620c commit 890f7c4

File tree

9 files changed

+32
-20
lines changed

9 files changed

+32
-20
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/IOStatisticsSnapshot.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public IOStatisticsSnapshot(IOStatistics source) {
111111
/**
112112
* Create the maps.
113113
*/
114-
private void createMaps() {
114+
private synchronized void createMaps() {
115115
counters = new ConcurrentHashMap<>();
116116
gauges = new ConcurrentHashMap<>();
117117
minimums = new ConcurrentHashMap<>();

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/StoreStatisticNames.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,12 @@ public final class StoreStatisticNames {
253253

254254

255255
/**
256-
* The name of the statistic collected for executor aquisition if
256+
* The name of the statistic collected for executor acquisition if
257257
* a duration tracker factory is passed in to the constructor.
258258
* {@value}.
259259
*/
260-
public static String ACTION_EXECUTOR_ACQUIRED = "action_executor_acquired";
260+
public static final String ACTION_EXECUTOR_ACQUIRED =
261+
"action_executor_acquired";
261262

262263
/**
263264
* An HTTP HEAD request was made: {@value}.

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/impl/IOStatisticsBinding.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.io.Serializable;
2222
import java.util.Iterator;
2323
import java.util.Map;
24-
import java.util.TreeMap;
2524
import java.util.concurrent.ConcurrentHashMap;
2625
import java.util.concurrent.atomic.AtomicLong;
2726
import java.util.function.BiFunction;

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/impl/IOStatisticsStoreImpl.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,11 @@ public synchronized boolean aggregate(
257257
Map<String, Long> sourceCounters = source.counters();
258258
counterMap.entrySet().
259259
forEach(e -> {
260-
Long sourceValue = lookupQuietly(sourceCounters, e.getKey());
261-
if (sourceValue != null) {
262-
e.getValue().addAndGet(sourceValue);
263-
}
264-
});
260+
Long sourceValue = lookupQuietly(sourceCounters, e.getKey());
261+
if (sourceValue != null) {
262+
e.getValue().addAndGet(sourceValue);
263+
}
264+
});
265265
// gauge: add positive values only
266266
Map<String, Long> sourceGauges = source.gauges();
267267
gaugeMap.entrySet().forEach(e -> {

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/statistics/impl/StubDurationTrackerFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
* This is a stub factory which always returns no-op duration
2626
* trackers. Allows for code to always be handed a factory.
2727
*/
28-
public final class StubDurationTrackerFactory implements DurationTrackerFactory {
28+
public final class StubDurationTrackerFactory
29+
implements DurationTrackerFactory {
2930

3031
/**
3132
* Single instance.

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/functional/RemoteIterators.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ private MaybeClose(Object o) {
568568
}
569569

570570
/**
571-
* Construct -close the object if it is closeable and close==true
571+
* Construct -close the object if it is closeable and close==true.
572572
* @param o object to close.
573573
* @param close should close?
574574
*/

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/AbstractContractStreamIOStatisticsTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.apache.hadoop.fs.FileSystem;
3232
import org.apache.hadoop.fs.Path;
3333
import org.apache.hadoop.fs.statistics.IOStatistics;
34-
import org.apache.hadoop.fs.statistics.IOStatisticsLogging;
3534

3635
import static org.apache.hadoop.fs.contract.ContractTestUtils.dataset;
3736
import static org.apache.hadoop.fs.statistics.IOStatisticAssertions.extractStatistics;

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/statistics/TestIOStatisticsSnapshot.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,16 @@ public void testJsonRoundTrip() throws Throwable {
115115
String json = serializer.toJson(snapshot);
116116
LOG.info("serialized form\n{}", json);
117117
IOStatisticsSnapshot deser = serializer.fromJson(json);
118+
verifyDeserializedInstance(deser);
119+
}
120+
121+
/**
122+
* Verify the deserialized instance's data
123+
* matches the expected values.
124+
* @param deser deserialized vlaue.
125+
*/
126+
public void verifyDeserializedInstance(
127+
final IOStatistics deser) {
118128
LOG.info("deserialized {}", deser);
119129
verifyCounterStatisticValue(deser, "c1", 0L);
120130
verifyGaugeStatisticValue(deser, "g1", 1L);
@@ -127,7 +137,9 @@ public void testJsonRoundTrip() throws Throwable {
127137

128138
@Test
129139
public void testJavaRoundTrip() throws Throwable {
130-
IOStatisticsSnapshot deser = (IOStatisticsSnapshot) IOStatisticAssertions.javaRoundTrip(snapshot);
140+
verifyDeserializedInstance(
141+
IOStatisticAssertions.javaRoundTrip(
142+
snapshot));
131143

132144

133145
}

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/functional/TestRemoteIterators.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,27 @@ public class TestRemoteIterators extends AbstractHadoopTestBase {
5454
private static final Logger LOG = LoggerFactory.getLogger(
5555
TestRemoteIterators.class);
5656

57-
private static final String[] data = {"a", "b", "c"};
57+
private static final String[] DATA = {"a", "b", "c"};
5858

5959
/** Counter for lambda-expressions. */
6060
private int counter;
6161

6262
@Test
6363
public void testIterateArray() throws Throwable {
64-
verifySize(remoteIteratorFromArray(data), data.length,
64+
verifySize(remoteIteratorFromArray(DATA), DATA.length,
6565
(s) -> LOG.info(s));
6666
}
6767

6868
@Test
6969
public void testIterateArrayMapped() throws Throwable {
7070
verifySize(
7171
mappingRemoteIterator(
72-
remoteIteratorFromArray(data),
72+
remoteIteratorFromArray(DATA),
7373
(d) -> {
7474
counter += d.length();
7575
return d;
7676
}),
77-
data.length,
77+
DATA.length,
7878
this::log);
7979
assertCounterValue(3);
8080
}
@@ -335,7 +335,7 @@ public IOStatistics getIOStatistics() {
335335
/**
336336
* Iterator which counts down.
337337
*/
338-
private static class CountdownRemoteIterator extends CloseCounter
338+
private static final class CountdownRemoteIterator extends CloseCounter
339339
implements RemoteIterator<Integer> {
340340

341341
private int limit;
@@ -365,7 +365,7 @@ public String toString() {
365365
/**
366366
* Iterator which counts down.
367367
*/
368-
private static class CountdownIterator extends CloseCounter
368+
private static final class CountdownIterator extends CloseCounter
369369
implements Iterator<Integer> {
370370

371371
private int limit;
@@ -396,7 +396,7 @@ public String toString() {
396396
* Iterable for countdown iterators.
397397
* Once closed, calls to iterator() raise an exception.
398398
*/
399-
private static class CountdownIterable extends CloseCounter
399+
private static final class CountdownIterable extends CloseCounter
400400
implements Iterable<Integer> {
401401

402402
private int limit;

0 commit comments

Comments
 (0)