HBASE-19609 Fixed Checkstyle errors in hbase-metrics and enabled Checkstyle to fail on violations

This commit is contained in:
Jan Hentschel 2017-12-24 13:27:25 +01:00
parent 2468f30029
commit b9f44bcfe7
12 changed files with 32 additions and 26 deletions

View File

@ -68,6 +68,22 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>checkstyle</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<failOnViolation>true</failOnViolation>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -19,8 +19,8 @@ package org.apache.hadoop.hbase.metrics.impl;
import java.util.concurrent.atomic.LongAdder;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.metrics.Counter;
import org.apache.yetus.audience.InterfaceAudience;
/**
* Custom implementation of {@link org.apache.hadoop.hbase.metrics.Counter} using LongAdder.

View File

@ -17,12 +17,12 @@
*/
package org.apache.hadoop.hbase.metrics.impl;
import com.codahale.metrics.Meter;
import java.util.Objects;
import org.apache.yetus.audience.InterfaceAudience;
import com.codahale.metrics.Meter;
/**
* Dropwizard metrics implementation of {@link org.apache.hadoop.hbase.metrics.Meter}.
*/

View File

@ -22,10 +22,10 @@ import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.LongAdder;
import java.util.stream.Stream;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;
import org.apache.hadoop.hbase.metrics.Snapshot;
import org.apache.hadoop.hbase.util.AtomicUtils;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;
/**
* FastLongHistogram is a thread-safe class that estimate distribution of data and computes the

View File

@ -16,13 +16,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase.metrics.impl;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.metrics.Histogram;
import org.apache.hadoop.hbase.metrics.Snapshot;
import org.apache.yetus.audience.InterfaceAudience;
/**
* Custom histogram implementation based on FastLongHistogram. Dropwizard-based histograms are

View File

@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase.metrics.impl;
import java.util.Collection;
@ -25,11 +23,11 @@ import java.util.Collections;
import java.util.Optional;
import java.util.Set;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.metrics.MetricRegistries;
import org.apache.hadoop.hbase.metrics.MetricRegistry;
import org.apache.hadoop.hbase.metrics.MetricRegistryFactory;
import org.apache.hadoop.hbase.metrics.MetricRegistryInfo;
import org.apache.yetus.audience.InterfaceAudience;
/**
* Implementation of MetricRegistries that does ref-counting.

View File

@ -16,14 +16,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase.metrics.impl;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.metrics.MetricRegistry;
import org.apache.hadoop.hbase.metrics.MetricRegistryFactory;
import org.apache.hadoop.hbase.metrics.MetricRegistryInfo;
import org.apache.yetus.audience.InterfaceAudience;
@InterfaceAudience.Private
public class MetricRegistryFactoryImpl implements MetricRegistryFactory {

View File

@ -22,7 +22,6 @@ import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.metrics.Counter;
import org.apache.hadoop.hbase.metrics.Gauge;
import org.apache.hadoop.hbase.metrics.Histogram;
@ -33,6 +32,7 @@ import org.apache.hadoop.hbase.metrics.MetricRegistryInfo;
import org.apache.hadoop.hbase.metrics.MetricSet;
import org.apache.hadoop.hbase.metrics.Timer;
import org.apache.hadoop.hbase.util.CollectionUtils;
import org.apache.yetus.audience.InterfaceAudience;
/**
* Custom implementation of {@link MetricRegistry}.

View File

@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase.metrics.impl;
import java.util.Collection;
@ -69,7 +67,7 @@ class RefCountingMap<K, V> {
* @return the value associated with the specified key or null if key is removed from map.
*/
V remove(K k) {
Payload<V> p = map.computeIfPresent(k, (k1, v) -> --v.refCount <= 0 ? null : v );
Payload<V> p = map.computeIfPresent(k, (k1, v) -> --v.refCount <= 0 ? null : v);
return p == null ? null : p.v;
}

View File

@ -19,8 +19,8 @@ package org.apache.hadoop.hbase.metrics.impl;
import java.util.concurrent.TimeUnit;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.metrics.Timer;
import org.apache.yetus.audience.InterfaceAudience;
/**
* Custom implementation of {@link Timer}.

View File

@ -17,14 +17,14 @@
*/
package org.apache.hadoop.hbase.metrics.impl;
import com.codahale.metrics.Meter;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.mockito.Mockito;
import com.codahale.metrics.Meter;
/**
* Test class for {@link DropwizardMeter}.
*/

View File

@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase.metrics.impl;
import static org.junit.Assert.assertEquals;
@ -135,7 +133,7 @@ public class TestRefCountingMap {
Set<String> keys = map.keySet();
assertEquals(3, keys.size());
Lists.newArrayList("foo", "bar", "baz").stream().forEach( v -> assertTrue(keys.contains(v)));
Lists.newArrayList("foo", "bar", "baz").stream().forEach(v -> assertTrue(keys.contains(v)));
}
@Test
@ -148,7 +146,7 @@ public class TestRefCountingMap {
Collection<String> values = map.values();
assertEquals(3, values.size());
Lists.newArrayList("foovalue", "foovalue3", "foovalue4").stream().forEach(
v -> assertTrue(values.contains(v)));
Lists.newArrayList("foovalue", "foovalue3", "foovalue4").stream()
.forEach(v -> assertTrue(values.contains(v)));
}
}