[FLINK-6827] Activate checkstyle for runtime/webmonitor This closes #4054.
Project: http://git-wip-us.apache.org/repos/asf/flink/repo Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/156d5e6b Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/156d5e6b Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/156d5e6b Branch: refs/heads/master Commit: 156d5e6be8b19dd6380285c9b68f49bdc3c6f058 Parents: 9d9732b Author: zentol <[email protected]> Authored: Wed May 31 17:00:57 2017 +0200 Committer: zentol <[email protected]> Committed: Fri Jun 2 22:22:30 2017 +0200 ---------------------------------------------------------------------- flink-runtime/pom.xml | 1 - .../flink/runtime/webmonitor/WebMonitor.java | 6 ++-- .../runtime/webmonitor/WebMonitorUtils.java | 38 ++++++++++---------- .../webmonitor/history/ArchivedJson.java | 9 ++--- .../webmonitor/history/JsonArchivist.java | 7 ++-- .../webmonitor/history/ArchivedJsonTest.java | 4 +++ 6 files changed, 34 insertions(+), 31 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flink/blob/156d5e6b/flink-runtime/pom.xml ---------------------------------------------------------------------- diff --git a/flink-runtime/pom.xml b/flink-runtime/pom.xml index 7ce3de5..e570d3b 100644 --- a/flink-runtime/pom.xml +++ b/flink-runtime/pom.xml @@ -457,7 +457,6 @@ under the License. **/runtime/taskmanager/**, **/runtime/testutils/**, **/runtime/util/**, - **/runtime/webmonitor/**, **/runtime/zookeeper/**, **/runtime/* </excludes> http://git-wip-us.apache.org/repos/asf/flink/blob/156d5e6b/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/WebMonitor.java ---------------------------------------------------------------------- diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/WebMonitor.java b/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/WebMonitor.java index 63e2cc8..47cdb84 100644 --- a/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/WebMonitor.java +++ b/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/WebMonitor.java @@ -25,18 +25,18 @@ public interface WebMonitor { /** * Starts the web monitor. - * + * * @throws Exception This method may forward exceptions, if it cannot bring up the web monitor. */ void start(String jobManagerAkkaUrl) throws Exception; /** * Stops the web server. - * + * * @throws Exception This method may forward exceptions, if it cannot properly stop the web monitor. */ void stop() throws Exception; - + /** * Gets the port that the web server actually binds to. If port 0 was given in * the configuration, then a random free port will be picked. This method can http://git-wip-us.apache.org/repos/asf/flink/blob/156d5e6b/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/WebMonitorUtils.java ---------------------------------------------------------------------- diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/WebMonitorUtils.java b/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/WebMonitorUtils.java index 3853b21..12c2d8e 100644 --- a/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/WebMonitorUtils.java +++ b/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/WebMonitorUtils.java @@ -18,13 +18,6 @@ package org.apache.flink.runtime.webmonitor; -import akka.actor.ActorSystem; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; - -import java.net.URI; import org.apache.flink.configuration.Configuration; import org.apache.flink.configuration.JobManagerOptions; import org.apache.flink.core.fs.Path; @@ -39,6 +32,10 @@ import org.apache.flink.runtime.leaderretrieval.LeaderRetrievalService; import org.apache.flink.runtime.messages.webmonitor.JobDetails; import org.apache.flink.runtime.webmonitor.history.JsonArchivist; +import akka.actor.ActorSystem; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,6 +43,7 @@ import java.io.File; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.net.URI; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -60,7 +58,7 @@ public final class WebMonitorUtils { private static final Logger LOG = LoggerFactory.getLogger(WebMonitorUtils.class); /** - * Singleton to hold the log and stdout file + * Singleton to hold the log and stdout file. */ public static class LogFileLocation { @@ -71,7 +69,6 @@ public final class WebMonitorUtils { this.logFile = logFile; this.stdOutFile = stdOutFile; } - /** * Finds the Flink log directory using log.file Java property that is set during startup. @@ -79,12 +76,12 @@ public final class WebMonitorUtils { public static LogFileLocation find(Configuration config) { final String logEnv = "log.file"; String logFilePath = System.getProperty(logEnv); - + if (logFilePath == null) { LOG.warn("Log file environment variable '{}' is not set.", logEnv); logFilePath = config.getString(JobManagerOptions.WEB_LOG_PATH); } - + // not configured, cannot serve log files if (logFilePath == null || logFilePath.length() < 4) { LOG.warn("JobManager log files are unavailable in the web dashboard. " + @@ -92,17 +89,18 @@ public final class WebMonitorUtils { logEnv, JobManagerOptions.WEB_LOG_PATH.key()); return new LogFileLocation(null, null); } - + String outFilePath = logFilePath.substring(0, logFilePath.length() - 3).concat("out"); LOG.info("Determined location of JobManager log file: {}", logFilePath); LOG.info("Determined location of JobManager stdout file: {}", outFilePath); - + return new LogFileLocation(resolveFileLocation(logFilePath), resolveFileLocation(outFilePath)); } /** - * Verify log file location + * Verify log file location. + * * @param logFilePath Path to log file * @return File or null if not a valid log file */ @@ -115,8 +113,8 @@ public final class WebMonitorUtils { /** * Starts the web runtime monitor. Because the actual implementation of the runtime monitor is * in another project, we load the runtime monitor dynamically. - * <p> - * Because failure to start the web runtime monitor is not considered fatal, this method does + * + * <p>Because failure to start the web runtime monitor is not considered fatal, this method does * not throw any exceptions, but only logs them. * * @param config The configuration for the runtime monitor. @@ -132,7 +130,7 @@ public final class WebMonitorUtils { try { String classname = "org.apache.flink.runtime.webmonitor.WebRuntimeMonitor"; Class<? extends WebMonitor> clazz = Class.forName(classname).asSubclass(WebMonitor.class); - + Constructor<? extends WebMonitor> constructor = clazz.getConstructor(Configuration.class, LeaderRetrievalService.class, BlobView.class, @@ -179,7 +177,7 @@ public final class WebMonitorUtils { Map<String, String> map = new HashMap<>(); ObjectMapper m = new ObjectMapper(); ArrayNode array = (ArrayNode) m.readTree(jsonString); - + Iterator<JsonNode> elements = array.elements(); while (elements.hasNext()) { JsonNode node = elements.next(); @@ -187,7 +185,7 @@ public final class WebMonitorUtils { String value = node.get("value").asText(); map.put(key, value); } - + return map; } catch (Exception e) { @@ -230,7 +228,7 @@ public final class WebMonitorUtils { * @param archiveDirUri The URI to check and normalize. * @return A normalized URI as a Path. * - * @throws IllegalArgumentException Thrown, if the URI misses scheme or path. + * @throws IllegalArgumentException Thrown, if the URI misses scheme or path. */ public static Path validateAndNormalizeUri(URI archiveDirUri) { final String scheme = archiveDirUri.getScheme(); http://git-wip-us.apache.org/repos/asf/flink/blob/156d5e6b/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/history/ArchivedJson.java ---------------------------------------------------------------------- diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/history/ArchivedJson.java b/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/history/ArchivedJson.java index 2e72f1a..23e7676 100644 --- a/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/history/ArchivedJson.java +++ b/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/history/ArchivedJson.java @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.flink.runtime.webmonitor.history; import org.apache.flink.runtime.jobmanager.MemoryArchivist; @@ -22,15 +23,15 @@ import org.apache.flink.util.Preconditions; /** * A simple container for a handler's JSON response and the REST URLs for which the response would've been returned. - * - * These are created by {@link JsonArchivist}s, and used by the {@link MemoryArchivist} to create a directory structure + * + * <p>These are created by {@link JsonArchivist}s, and used by the {@link MemoryArchivist} to create a directory structure * resembling the REST API. */ public class ArchivedJson { private final String path; private final String json; - + public ArchivedJson(String path, String json) { this.path = Preconditions.checkNotNull(path); this.json = Preconditions.checkNotNull(json); @@ -56,6 +57,6 @@ public class ArchivedJson { @Override public String toString() { - return path +":" + json; + return path + ":" + json; } } http://git-wip-us.apache.org/repos/asf/flink/blob/156d5e6b/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/history/JsonArchivist.java ---------------------------------------------------------------------- diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/history/JsonArchivist.java b/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/history/JsonArchivist.java index a87cc47..c0a54c6 100644 --- a/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/history/JsonArchivist.java +++ b/flink-runtime/src/main/java/org/apache/flink/runtime/webmonitor/history/JsonArchivist.java @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.flink.runtime.webmonitor.history; import org.apache.flink.runtime.executiongraph.AccessExecutionGraph; @@ -24,8 +25,8 @@ import java.util.Collection; /** * Interface for all classes that want to participate in the archiving of job-related json responses. - * - * Note that all JsonArchivists that are to be used for the history server must be added + * + * <p>Note that all JsonArchivists that are to be used for the history server must be added * to {@link WebRuntimeMonitor#getArchivers()}. */ public interface JsonArchivist { @@ -34,7 +35,7 @@ public interface JsonArchivist { * Returns a {@link Collection} of {@link ArchivedJson}s containing JSON responses and their respective REST URL * for a given job. * - * The collection should contain one entry for every response that could be generated for the given + * <p>The collection should contain one entry for every response that could be generated for the given * job, for example one entry for each task. The REST URLs should be unique and must not contain placeholders. * * @param graph AccessExecutionGraph for which the responses should be generated http://git-wip-us.apache.org/repos/asf/flink/blob/156d5e6b/flink-runtime/src/test/java/org/apache/flink/runtime/webmonitor/history/ArchivedJsonTest.java ---------------------------------------------------------------------- diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/webmonitor/history/ArchivedJsonTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/webmonitor/history/ArchivedJsonTest.java index c3883bc..57ebbc9 100644 --- a/flink-runtime/src/test/java/org/apache/flink/runtime/webmonitor/history/ArchivedJsonTest.java +++ b/flink-runtime/src/test/java/org/apache/flink/runtime/webmonitor/history/ArchivedJsonTest.java @@ -15,11 +15,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.flink.runtime.webmonitor.history; import org.junit.Assert; import org.junit.Test; +/** + * Tests for the {@link ArchivedJson}. + */ public class ArchivedJsonTest { @Test
