flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ches...@apache.org
Subject [7/7] flink git commit: [FLINK-6826] [runtime] Activate checkstyle for runtime/net
Date Tue, 04 Jul 2017 12:35:30 GMT
[FLINK-6826] [runtime] Activate checkstyle for runtime/net

This closes #4065.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/85853eda
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/85853eda
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/85853eda

Branch: refs/heads/master
Commit: 85853edab3e76ec83790f1b9c8f51bd2f6afe087
Parents: c59537e
Author: zentol <chesnay@apache.org>
Authored: Fri Jun 2 23:25:16 2017 +0200
Committer: zentol <chesnay@apache.org>
Committed: Tue Jul 4 12:33:33 2017 +0200

----------------------------------------------------------------------
 flink-runtime/pom.xml                           |  1 -
 .../flink/runtime/net/ConnectionUtils.java      | 57 ++++++++++----------
 .../org/apache/flink/runtime/net/SSLUtils.java  | 15 +++---
 .../flink/runtime/net/ConnectionUtilsTest.java  | 17 +++---
 .../apache/flink/runtime/net/SSLUtilsTest.java  | 26 ++++-----
 5 files changed, 59 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/85853eda/flink-runtime/pom.xml
----------------------------------------------------------------------
diff --git a/flink-runtime/pom.xml b/flink-runtime/pom.xml
index 1fff305..a21f753 100644
--- a/flink-runtime/pom.xml
+++ b/flink-runtime/pom.xml
@@ -447,7 +447,6 @@ under the License.
 						**/runtime/memory/**,
 						**/runtime/messages/**,
 						**/runtime/minicluster/**,
-						**/runtime/net/**,
 						**/runtime/operators/**,
 						**/runtime/plugable/**,
 						**/runtime/query/**,

http://git-wip-us.apache.org/repos/asf/flink/blob/85853eda/flink-runtime/src/main/java/org/apache/flink/runtime/net/ConnectionUtils.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/net/ConnectionUtils.java
b/flink-runtime/src/main/java/org/apache/flink/runtime/net/ConnectionUtils.java
index 75a7ebe..673d27c 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/net/ConnectionUtils.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/net/ConnectionUtils.java
@@ -18,6 +18,13 @@
 
 package org.apache.flink.runtime.net;
 
+import org.apache.flink.runtime.akka.AkkaUtils;
+import org.apache.flink.runtime.leaderretrieval.LeaderRetrievalException;
+import org.apache.flink.runtime.leaderretrieval.LeaderRetrievalListener;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.io.IOException;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
@@ -32,25 +39,17 @@ import java.util.List;
 import java.util.UUID;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.flink.runtime.akka.AkkaUtils;
-import org.apache.flink.runtime.leaderretrieval.LeaderRetrievalException;
-import org.apache.flink.runtime.leaderretrieval.LeaderRetrievalListener;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import scala.concurrent.duration.FiniteDuration;
 
-
 /**
  * Utilities to determine the network interface and address that should be used to bind the
  * TaskManager communication to.
- * 
+ *
  * <p>Implementation note: This class uses {@code System.nanoTime()} to measure elapsed
time, because
  * that is not susceptible to clock changes.
  */
 public class ConnectionUtils {
-	
+
 	private static final Logger LOG = LoggerFactory.getLogger(ConnectionUtils.class);
 
 	private static final long MIN_SLEEP_TIME = 50;
@@ -61,15 +60,15 @@ public class ConnectionUtils {
 	 * There is only a state transition if the current state failed to determine the address.
 	 */
 	private enum AddressDetectionState {
-		/** Connect from interface returned by InetAddress.getLocalHost() **/
+		/** Connect from interface returned by InetAddress.getLocalHost(). **/
 		LOCAL_HOST(200),
 		/** Detect own IP address based on the target IP address. Look for common prefix */
 		ADDRESS(50),
-		/** Try to connect on all Interfaces and all their addresses with a low timeout */
+		/** Try to connect on all Interfaces and all their addresses with a low timeout. */
 		FAST_CONNECT(50),
-		/** Try to connect on all Interfaces and all their addresses with a long timeout */
+		/** Try to connect on all Interfaces and all their addresses with a long timeout. */
 		SLOW_CONNECT(1000),
-		/** Choose any non-loopback address */
+		/** Choose any non-loopback address. */
 		HEURISTIC(0);
 
 		private final int timeout;
@@ -90,11 +89,11 @@ public class ConnectionUtils {
 	 * given target, so it only succeeds if the target socket address actually accepts
 	 * connections. The method tries various strategies multiple times and uses an exponential
 	 * backoff timer between tries.
-	 * <p>
-	 * If no connection attempt was successful after the given maximum time, the method
+	 *
+	 * <p>If no connection attempt was successful after the given maximum time, the method
 	 * will choose some address based on heuristics (excluding link-local and loopback addresses.)
-	 * <p>
-	 * This method will initially not log on info level (to not flood the log while the
+	 *
+	 * <p>This method will initially not log on info level (to not flood the log while
the
 	 * backoff time is still very low). It will start logging after a certain time
 	 * has passes.
 	 *
@@ -104,8 +103,7 @@ public class ConnectionUtils {
 	 * @param startLoggingAfter The time after which the method will log on INFO level.
 	 */
 	public static InetAddress findConnectingAddress(InetSocketAddress targetAddress,
-							long maxWaitMillis, long startLoggingAfter) throws IOException
-	{
+							long maxWaitMillis, long startLoggingAfter) throws IOException {
 		if (targetAddress == null) {
 			throw new NullPointerException("targetAddress must not be null");
 		}
@@ -188,11 +186,11 @@ public class ConnectionUtils {
 	 */
 	private static InetAddress tryLocalHostBeforeReturning(
 				InetAddress preliminaryResult, SocketAddress targetAddress, boolean logging) throws IOException
{
-		
+
 		InetAddress localhostName = InetAddress.getLocalHost();
-		
+
 		if (preliminaryResult.equals(localhostName)) {
-			// preliminary result is equal to the local host name 
+			// preliminary result is equal to the local host name
 			return preliminaryResult;
 		}
 		else if (tryToConnect(localhostName, targetAddress, AddressDetectionState.SLOW_CONNECT.getTimeout(),
logging)) {
@@ -209,7 +207,7 @@ public class ConnectionUtils {
 
 	/**
 	 * Try to find a local address which allows as to connect to the targetAddress using the
given
-	 * strategy
+	 * strategy.
 	 *
 	 * @param strategy Depending on the strategy, the method will enumerate all interfaces,
trying to connect
 	 *                 to the target address
@@ -220,8 +218,7 @@ public class ConnectionUtils {
 	 */
 	private static InetAddress findAddressUsingStrategy(AddressDetectionState strategy,
 														InetSocketAddress targetAddress,
-														boolean logging) throws IOException
-	{
+														boolean logging) throws IOException {
 		// try LOCAL_HOST strategy independent of the network interfaces
 		if (strategy == AddressDetectionState.LOCAL_HOST) {
 			InetAddress localhostName;
@@ -316,8 +313,7 @@ public class ConnectionUtils {
 	 * @throws IOException Thrown if the socket cleanup fails.
 	 */
 	private static boolean tryToConnect(InetAddress fromAddress, SocketAddress toSocket,
-										int timeout, boolean logFailed) throws IOException
-	{
+										int timeout, boolean logFailed) throws IOException {
 		if (LOG.isDebugEnabled()) {
 			LOG.debug("Trying to connect to (" + toSocket + ") from local address " + fromAddress
 					+ " with timeout " + timeout);
@@ -341,6 +337,9 @@ public class ConnectionUtils {
 		}
 	}
 
+	/**
+	 * A {@link LeaderRetrievalListener} that allows retrieving an {@link InetAddress} for the
current leader.
+	 */
 	public static class LeaderConnectingAddressListener implements LeaderRetrievalListener {
 
 		private static final FiniteDuration defaultLoggingDelay = new FiniteDuration(400, TimeUnit.MILLISECONDS);
@@ -351,7 +350,7 @@ public class ConnectionUtils {
 			NEWLY_RETRIEVED
 		}
 
-		final private Object retrievalLock = new Object();
+		private final Object retrievalLock = new Object();
 
 		private String akkaURL;
 		private LeaderRetrievalState retrievalState = LeaderRetrievalState.NOT_RETRIEVED;

http://git-wip-us.apache.org/repos/asf/flink/blob/85853eda/flink-runtime/src/main/java/org/apache/flink/runtime/net/SSLUtils.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/net/SSLUtils.java b/flink-runtime/src/main/java/org/apache/flink/runtime/net/SSLUtils.java
index 015b3d6..663d221 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/net/SSLUtils.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/net/SSLUtils.java
@@ -31,6 +31,7 @@ import javax.net.ssl.SSLEngine;
 import javax.net.ssl.SSLParameters;
 import javax.net.ssl.SSLServerSocket;
 import javax.net.ssl.TrustManagerFactory;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.net.ServerSocket;
@@ -38,13 +39,13 @@ import java.security.KeyStore;
 import java.util.Arrays;
 
 /**
- * Common utilities to manage SSL transport settings
+ * Common utilities to manage SSL transport settings.
  */
 public class SSLUtils {
 	private static final Logger LOG = LoggerFactory.getLogger(SSLUtils.class);
 
 	/**
-	 * Retrieves the global ssl flag from configuration
+	 * Retrieves the global ssl flag from configuration.
 	 *
 	 * @param sslConfig
 	 *        The application configuration
@@ -58,7 +59,7 @@ public class SSLUtils {
 	}
 
 	/**
-	 * Sets SSl version and cipher suites for SSLServerSocket
+	 * Sets SSl version and cipher suites for SSLServerSocket.
 	 * @param socket
 	 *        Socket to be handled
 	 * @param config
@@ -81,7 +82,7 @@ public class SSLUtils {
 	}
 
 	/**
-	 * Sets SSL version and cipher suites for SSLEngine
+	 * Sets SSL version and cipher suites for SSLEngine.
 	 * @param engine
 	 *        SSLEngine to be handled
 	 * @param config
@@ -93,7 +94,7 @@ public class SSLUtils {
 	}
 
 	/**
-	 * Sets SSL options to verify peer's hostname in the certificate
+	 * Sets SSL options to verify peer's hostname in the certificate.
 	 *
 	 * @param sslConfig
 	 *        The application configuration
@@ -112,7 +113,7 @@ public class SSLUtils {
 	}
 
 	/**
-	 * Creates the SSL Context for the client if SSL is configured
+	 * Creates the SSL Context for the client if SSL is configured.
 	 *
 	 * @param sslConfig
 	 *        The application configuration
@@ -160,7 +161,7 @@ public class SSLUtils {
 	}
 
 	/**
-	 * Creates the SSL Context for the server if SSL is configured
+	 * Creates the SSL Context for the server if SSL is configured.
 	 *
 	 * @param sslConfig
 	 *        The application configuration

http://git-wip-us.apache.org/repos/asf/flink/blob/85853eda/flink-runtime/src/test/java/org/apache/flink/runtime/net/ConnectionUtilsTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/net/ConnectionUtilsTest.java
b/flink-runtime/src/test/java/org/apache/flink/runtime/net/ConnectionUtilsTest.java
index b5c2819..d7c4baa 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/net/ConnectionUtilsTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/net/ConnectionUtilsTest.java
@@ -15,14 +15,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.flink.runtime.net;
 
-import java.io.IOException;
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.ServerSocket;
-import java.net.UnknownHostException;
+package org.apache.flink.runtime.net;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -31,6 +25,13 @@ import org.powermock.api.mockito.PowerMockito;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
 
+import java.io.IOException;
+import java.net.Inet4Address;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.net.UnknownHostException;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -48,7 +49,7 @@ public class ConnectionUtilsTest {
 			// the "blocker" server socket simply does not accept connections
 			// this address is consequently "unreachable"
 			InetSocketAddress unreachable = new InetSocketAddress("localhost", blocker.getLocalPort());
-			
+
 			final long start = System.nanoTime();
 			InetAddress add = ConnectionUtils.findConnectingAddress(unreachable, 2000, 400);
 

http://git-wip-us.apache.org/repos/asf/flink/blob/85853eda/flink-runtime/src/test/java/org/apache/flink/runtime/net/SSLUtilsTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/net/SSLUtilsTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/net/SSLUtilsTest.java
index a3c2b7b..87d0ccc 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/net/SSLUtilsTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/net/SSLUtilsTest.java
@@ -15,26 +15,28 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.apache.flink.runtime.net;
 
 import org.apache.flink.configuration.Configuration;
 import org.apache.flink.configuration.SecurityOptions;
+
 import org.junit.Assert;
 import org.junit.Test;
 
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLEngine;
 import javax.net.ssl.SSLServerSocket;
+
 import java.net.ServerSocket;
-import java.util.Random;
 
-/*
- * Tests for the SSL utilities
+/**
+ * Tests for the {@link SSLUtils}.
  */
 public class SSLUtilsTest {
 
 	/**
-	 * Tests if SSL Client Context is created given a valid SSL configuration
+	 * Tests if SSL Client Context is created given a valid SSL configuration.
 	 */
 	@Test
 	public void testCreateSSLClientContext() throws Exception {
@@ -49,7 +51,7 @@ public class SSLUtilsTest {
 	}
 
 	/**
-	 * Tests if SSL Client Context is not created if SSL is not configured
+	 * Tests if SSL Client Context is not created if SSL is not configured.
 	 */
 	@Test
 	public void testCreateSSLClientContextWithSSLDisabled() throws Exception {
@@ -62,7 +64,7 @@ public class SSLUtilsTest {
 	}
 
 	/**
-	 * Tests if SSL Client Context creation fails with bad SSL configuration
+	 * Tests if SSL Client Context creation fails with bad SSL configuration.
 	 */
 	@Test
 	public void testCreateSSLClientContextMisconfiguration() {
@@ -81,7 +83,7 @@ public class SSLUtilsTest {
 	}
 
 	/**
-	 * Tests if SSL Server Context is created given a valid SSL configuration
+	 * Tests if SSL Server Context is created given a valid SSL configuration.
 	 */
 	@Test
 	public void testCreateSSLServerContext() throws Exception {
@@ -97,7 +99,7 @@ public class SSLUtilsTest {
 	}
 
 	/**
-	 * Tests if SSL Server Context is not created if SSL is disabled
+	 * Tests if SSL Server Context is not created if SSL is disabled.
 	 */
 	@Test
 	public void testCreateSSLServerContextWithSSLDisabled() throws Exception {
@@ -110,7 +112,7 @@ public class SSLUtilsTest {
 	}
 
 	/**
-	 * Tests if SSL Server Context creation fails with bad SSL configuration
+	 * Tests if SSL Server Context creation fails with bad SSL configuration.
 	 */
 	@Test
 	public void testCreateSSLServerContextMisconfiguration() {
@@ -130,7 +132,7 @@ public class SSLUtilsTest {
 	}
 
 	/**
-	 * Tests if SSL Server Context creation fails with bad SSL configuration
+	 * Tests if SSL Server Context creation fails with bad SSL configuration.
 	 */
 	@Test
 	public void testCreateSSLServerContextWithMultiProtocols() {
@@ -151,7 +153,7 @@ public class SSLUtilsTest {
 	}
 
 	/**
-	 * Tests if SSLUtils set the right ssl version and cipher suites for SSLServerSocket
+	 * Tests if SSLUtils set the right ssl version and cipher suites for SSLServerSocket.
 	 */
 	@Test
 	public void testSetSSLVersionAndCipherSuitesForSSLServerSocket() throws Exception {
@@ -192,7 +194,7 @@ public class SSLUtilsTest {
 	}
 
 	/**
-	 * Tests if SSLUtils set the right ssl version and cipher suites for SSLEngine
+	 * Tests if SSLUtils set the right ssl version and cipher suites for SSLEngine.
 	 */
 	@Test
 	public void testSetSSLVersionAndCipherSuitesForSSLEngine() throws Exception {


Mime
View raw message