You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by sh...@apache.org on 2020/04/30 04:04:56 UTC
[incubator-ratis] branch master updated: RATIS-913. Fix remaining
(new) checkstyle violations (#74)
This is an automated email from the ASF dual-hosted git repository.
shashikant pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ratis.git
The following commit(s) were added to refs/heads/master by this push:
new 56e2073 RATIS-913. Fix remaining (new) checkstyle violations (#74)
56e2073 is described below
commit 56e2073515804cc70f64b215f971d547070ed38f
Author: Doroszlai, Attila <64...@users.noreply.github.com>
AuthorDate: Thu Apr 30 06:04:47 2020 +0200
RATIS-913. Fix remaining (new) checkstyle violations (#74)
---
dev-support/checkstyle.xml | 5 +++++
.../org/apache/ratis/retry/ExponentialBackoffRetry.java | 4 ++--
.../main/java/org/apache/ratis/util/PlatformUtils.java | 16 ++++++++--------
.../java/org/apache/ratis/grpc/server/GrpcService.java | 1 +
.../logservice/metrics/LogServiceMetricsRegistry.java | 6 +++++-
.../ratis/server/raftlog/segmented/LogSegment.java | 2 +-
6 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/dev-support/checkstyle.xml b/dev-support/checkstyle.xml
index 80e1411..f3e8f0a 100644
--- a/dev-support/checkstyle.xml
+++ b/dev-support/checkstyle.xml
@@ -55,6 +55,11 @@
<property name="fileExtensions" value="java, properties, xml"/>
+ <module name="BeforeExecutionExclusionFileFilter">
+ <!-- these files will be removed in RATIS-757 -->
+ <property name="fileNamePattern" value="nativeio/.*\.java"/>
+ </module>
+
<module name="SuppressWarningsFilter"/>
<!-- Checks that a package-info.java file exists for each package. -->
diff --git a/ratis-common/src/main/java/org/apache/ratis/retry/ExponentialBackoffRetry.java b/ratis-common/src/main/java/org/apache/ratis/retry/ExponentialBackoffRetry.java
index be7c5ed..bb2f50e 100644
--- a/ratis-common/src/main/java/org/apache/ratis/retry/ExponentialBackoffRetry.java
+++ b/ratis-common/src/main/java/org/apache/ratis/retry/ExponentialBackoffRetry.java
@@ -30,9 +30,9 @@ import java.util.concurrent.ThreadLocalRandom;
* If sleep time calculated using the progression is s then randomness is added
* in the range [s*0.5, s*1.5).
*/
-public class ExponentialBackoffRetry implements RetryPolicy {
+public final class ExponentialBackoffRetry implements RetryPolicy {
- public static class Builder {
+ public static final class Builder {
private Builder() {}
diff --git a/ratis-common/src/main/java/org/apache/ratis/util/PlatformUtils.java b/ratis-common/src/main/java/org/apache/ratis/util/PlatformUtils.java
index 6d4bf54..2bd253e 100644
--- a/ratis-common/src/main/java/org/apache/ratis/util/PlatformUtils.java
+++ b/ratis-common/src/main/java/org/apache/ratis/util/PlatformUtils.java
@@ -23,7 +23,7 @@ package org.apache.ratis.util;
/**
* Platform and architecture related utility methods.
*/
-public class PlatformUtils {
+public final class PlatformUtils {
private PlatformUtils() {
// Utility class, cannot instantiate
@@ -35,14 +35,14 @@ public class PlatformUtils {
* Get the type of the operating system, as determined from parsing
* the <code>os.name</code> property.
*/
- private static final OSType osType = getOSType();
- public static final boolean OTHER = (osType == OSType.OS_TYPE_OTHER);
- public static final boolean LINUX = (osType == OSType.OS_TYPE_LINUX);
- public static final boolean FREEBSD = (osType == OSType.OS_TYPE_FREEBSD);
- public static final boolean MAC = (osType == OSType.OS_TYPE_MAC);
- public static final boolean SOLARIS = (osType == OSType.OS_TYPE_SOLARIS);
+ private static final OSType OS_TYPE = getOSType();
+ public static final boolean OTHER = (OS_TYPE == OSType.OS_TYPE_OTHER);
+ public static final boolean LINUX = (OS_TYPE == OSType.OS_TYPE_LINUX);
+ public static final boolean FREEBSD = (OS_TYPE == OSType.OS_TYPE_FREEBSD);
+ public static final boolean MAC = (OS_TYPE == OSType.OS_TYPE_MAC);
+ public static final boolean SOLARIS = (OS_TYPE == OSType.OS_TYPE_SOLARIS);
// Helper static vars for each platform
- public static final boolean WINDOWS = (osType == OSType.OS_TYPE_WIN);
+ public static final boolean WINDOWS = (OS_TYPE == OSType.OS_TYPE_WIN);
private static OSType getOSType() {
String osName = System.getProperty("os.name");
diff --git a/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcService.java b/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcService.java
index 8032204..f4d71f2 100644
--- a/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcService.java
+++ b/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcService.java
@@ -96,6 +96,7 @@ public final class GrpcService extends RaftServerRpcWithProxy<GrpcServerProtocol
tlsConfig);
}
+ @SuppressWarnings("checkstyle:ParameterNumber") // private constructor
private GrpcService(RaftServer raftServer, Supplier<RaftPeerId> idSupplier, int port,
SizeInBytes grpcMessageSizeMax, SizeInBytes appenderBufferSize,
SizeInBytes flowControlWindow,TimeDuration requestTimeoutDuration, GrpcTlsConfig tlsConfig) {
diff --git a/ratis-logservice/src/main/java/org/apache/ratis/logservice/metrics/LogServiceMetricsRegistry.java b/ratis-logservice/src/main/java/org/apache/ratis/logservice/metrics/LogServiceMetricsRegistry.java
index 8172e40..1d2940b 100644
--- a/ratis-logservice/src/main/java/org/apache/ratis/logservice/metrics/LogServiceMetricsRegistry.java
+++ b/ratis-logservice/src/main/java/org/apache/ratis/logservice/metrics/LogServiceMetricsRegistry.java
@@ -22,7 +22,7 @@ import org.apache.ratis.metrics.MetricRegistries;
import org.apache.ratis.metrics.MetricRegistryInfo;
import org.apache.ratis.metrics.RatisMetricRegistry;
-public class LogServiceMetricsRegistry {
+public final class LogServiceMetricsRegistry {
public static final String RATIS_LOG_STATEMACHINE_METRICS = "log_statemachine";
public static final String RATIS_LOG_SERVICE_METRICS = "ratis_log_service";
public static final String RATIS_LOG_SERVICE_METRICS_DESC = "Ratis log service metrics";
@@ -58,4 +58,8 @@ public class LogServiceMetricsRegistry {
return registry;
}
+ private LogServiceMetricsRegistry() {
+ throw new UnsupportedOperationException("no instances");
+ }
+
}
diff --git a/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/LogSegment.java b/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/LogSegment.java
index ad50ba9..034e528 100644
--- a/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/LogSegment.java
+++ b/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/LogSegment.java
@@ -50,7 +50,7 @@ import java.util.function.Consumer;
*
* This class will be protected by the {@link SegmentedRaftLog}'s read-write lock.
*/
-public class LogSegment implements Comparable<Long> {
+public final class LogSegment implements Comparable<Long> {
//TODO: This class needs to be made final to address checkstyle issue. However, TestCacheEviction fails as Mockito
// cannot spy final class. This problem can be fixed when stable version of Mockito 2.x is available which provides