You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by zj...@apache.org on 2018/02/28 03:29:39 UTC

zeppelin git commit: ZEPPELIN-3154. Fixed Checkstyle errors and warnings in flink module

Repository: zeppelin
Updated Branches:
  refs/heads/master 500b74b19 -> 65b797c22


ZEPPELIN-3154. Fixed Checkstyle errors and warnings in flink module

### What is this PR for?
Fixed the Checkstyle errors and warnings in the flink module.

### What type of PR is it?
Improvement

### Todos
* [ ] - Task

### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-3154

### How should this be tested?
* CI pass

### Screenshots (if appropriate)

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

Author: Jan Hentschel <ja...@ultratendency.com>

Closes #2795 from HorizonNet/ZEPPELIN-3154 and squashes the following commits:

f70e93d [Jan Hentschel] ZEPPELIN-3154. Fixed Checkstyle errors and warnings in flink module


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/65b797c2
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/65b797c2
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/65b797c2

Branch: refs/heads/master
Commit: 65b797c22eadebb9a18575e91fdcfe33722762c8
Parents: 500b74b
Author: Jan Hentschel <ja...@ultratendency.com>
Authored: Tue Feb 13 12:21:21 2018 +0100
Committer: Jeff Zhang <zj...@apache.org>
Committed: Wed Feb 28 11:29:31 2018 +0800

----------------------------------------------------------------------
 flink/pom.xml                                   | 253 ++++++++++---------
 .../apache/zeppelin/flink/FlinkInterpreter.java |  37 +--
 .../zeppelin/flink/FlinkInterpreterTest.java    |  22 +-
 3 files changed, 164 insertions(+), 148 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/65b797c2/flink/pom.xml
----------------------------------------------------------------------
diff --git a/flink/pom.xml b/flink/pom.xml
index 455092d..70c076d 100644
--- a/flink/pom.xml
+++ b/flink/pom.xml
@@ -154,142 +154,149 @@
 
       <!-- Scala Compiler -->
       <plugin>
-	<groupId>net.alchim31.maven</groupId>
-	<artifactId>scala-maven-plugin</artifactId>
-	<version>${plugin.scalamaven.version}</version>
-	<executions>
-	  <!-- Run scala compiler in the process-resources phase, so that dependencies on
-	       scala classes can be resolved later in the (Java) compile phase -->
-	  <execution>
-	    <id>scala-compile-first</id>
-	    <phase>process-resources</phase>
-	    <goals>
-	      <goal>compile</goal>
-	    </goals>
-	  </execution>
-          
-	  <!-- Run scala compiler in the process-test-resources phase, so that dependencies on
-	       scala classes can be resolved later in the (Java) test-compile phase -->
-	  <execution>
-	    <id>scala-test-compile</id>
-	    <phase>process-test-resources</phase>
-	    <goals>
-	      <goal>testCompile</goal>
-	    </goals>
-	  </execution>
-	</executions>
-	<configuration>
-	  <jvmArgs>
-	    <jvmArg>-Xms128m</jvmArg>
-	    <jvmArg>-Xmx512m</jvmArg>
-	  </jvmArgs>
-	  <compilerPlugins combine.children="append">
-	    <compilerPlugin>
-	      <groupId>org.scalamacros</groupId>
-	      <artifactId>paradise_${scala.version}</artifactId>
-	      <version>${scala.macros.version}</version>
-	    </compilerPlugin>
-	  </compilerPlugins>
-	</configuration>
+        <groupId>net.alchim31.maven</groupId>
+        <artifactId>scala-maven-plugin</artifactId>
+        <version>${plugin.scalamaven.version}</version>
+        <executions>
+          <!-- Run scala compiler in the process-resources phase, so that dependencies on
+               scala classes can be resolved later in the (Java) compile phase -->
+          <execution>
+            <id>scala-compile-first</id>
+            <phase>process-resources</phase>
+            <goals>
+              <goal>compile</goal>
+            </goals>
+          </execution>
+
+          <!-- Run scala compiler in the process-test-resources phase, so that dependencies on
+               scala classes can be resolved later in the (Java) test-compile phase -->
+          <execution>
+            <id>scala-test-compile</id>
+            <phase>process-test-resources</phase>
+            <goals>
+              <goal>testCompile</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <jvmArgs>
+            <jvmArg>-Xms128m</jvmArg>
+            <jvmArg>-Xmx512m</jvmArg>
+          </jvmArgs>
+          <compilerPlugins combine.children="append">
+            <compilerPlugin>
+              <groupId>org.scalamacros</groupId>
+              <artifactId>paradise_${scala.version}</artifactId>
+              <version>${scala.macros.version}</version>
+            </compilerPlugin>
+          </compilerPlugins>
+        </configuration>
       </plugin>
 
       <!-- Eclipse Integration -->
       <plugin>
-	<groupId>org.apache.maven.plugins</groupId>
-	<artifactId>maven-eclipse-plugin</artifactId>
-	<version>${plugin.eclipse.version}</version>
-	<configuration>
-	  <downloadSources>true</downloadSources>
-	  <projectnatures>
-	    <projectnature>org.scala-ide.sdt.core.scalanature</projectnature>
-	    <projectnature>org.eclipse.jdt.core.javanature</projectnature>
-	  </projectnatures>
-	  <buildcommands>
-	    <buildcommand>org.scala-ide.sdt.core.scalabuilder</buildcommand>
-	  </buildcommands>
-	  <classpathContainers>
-	    <classpathContainer>org.scala-ide.sdt.launching.SCALA_CONTAINER</classpathContainer>
-	    <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
-	  </classpathContainers>
-	  <!-- excludes>
-	    <exclude>org.scala-lang:scala-library</exclude>
-	    <exclude>org.scala-lang:scala-compiler</exclude>
-	  </excludes -->
-	  <sourceIncludes>
-	    <sourceInclude>**/*.scala</sourceInclude>
-	    <sourceInclude>**/*.java</sourceInclude>
-	  </sourceIncludes>
-	</configuration>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-eclipse-plugin</artifactId>
+        <version>${plugin.eclipse.version}</version>
+        <configuration>
+          <downloadSources>true</downloadSources>
+          <projectnatures>
+            <projectnature>org.scala-ide.sdt.core.scalanature</projectnature>
+            <projectnature>org.eclipse.jdt.core.javanature</projectnature>
+          </projectnatures>
+          <buildcommands>
+            <buildcommand>org.scala-ide.sdt.core.scalabuilder</buildcommand>
+          </buildcommands>
+          <classpathContainers>
+            <classpathContainer>org.scala-ide.sdt.launching.SCALA_CONTAINER</classpathContainer>
+            <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
+          </classpathContainers>
+          <!-- excludes>
+            <exclude>org.scala-lang:scala-library</exclude>
+            <exclude>org.scala-lang:scala-compiler</exclude>
+          </excludes -->
+          <sourceIncludes>
+            <sourceInclude>**/*.scala</sourceInclude>
+            <sourceInclude>**/*.java</sourceInclude>
+          </sourceIncludes>
+        </configuration>
       </plugin>
 
       <!-- Adding scala source directories to build path -->
       <plugin>
-	<groupId>org.codehaus.mojo</groupId>
-	<artifactId>build-helper-maven-plugin</artifactId>
-	<version>${plugin.buildhelper.version}</version>
-	<executions>
-	  <!-- Add src/main/scala to eclipse build path -->
-	  <execution>
-	    <id>add-source</id>
-	    <phase>generate-sources</phase>
-	    <goals>
-	      <goal>add-source</goal>
-	    </goals>
-	    <configuration>
-	      <sources>
-		<source>src/main/scala</source>
-	      </sources>
-	    </configuration>
-	  </execution>
-	  <!-- Add src/test/scala to eclipse build path -->
-	  <execution>
-	    <id>add-test-source</id>
-	    <phase>generate-test-sources</phase>
-	    <goals>
-	      <goal>add-test-source</goal>
-	    </goals>
-	    <configuration>
-	      <sources>
-		<source>src/test/scala</source>
-	      </sources>
-	    </configuration>
-	  </execution>
-	</executions>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <version>${plugin.buildhelper.version}</version>
+        <executions>
+          <!-- Add src/main/scala to eclipse build path -->
+          <execution>
+            <id>add-source</id>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>add-source</goal>
+            </goals>
+            <configuration>
+              <sources>
+            <source>src/main/scala</source>
+              </sources>
+            </configuration>
+          </execution>
+          <!-- Add src/test/scala to eclipse build path -->
+          <execution>
+            <id>add-test-source</id>
+            <phase>generate-test-sources</phase>
+            <goals>
+              <goal>add-test-source</goal>
+            </goals>
+            <configuration>
+              <sources>
+            <source>src/test/scala</source>
+              </sources>
+            </configuration>
+          </execution>
+        </executions>
       </plugin>
 
       <plugin>
-	<groupId>org.scalastyle</groupId>
-	<artifactId>scalastyle-maven-plugin</artifactId>
-	<version>${plugin.scalastyle.version}</version>
-	<executions>
-	  <execution>
-	    <goals>
-	      <goal>check</goal>
-	    </goals>
-	  </execution>
-	</executions>
-	<configuration>
-	  <verbose>false</verbose>
-	  <failOnViolation>true</failOnViolation>
-	  <includeTestSourceDirectory>true</includeTestSourceDirectory>
-	  <failOnWarning>false</failOnWarning>
-	  <sourceDirectory>${basedir}/src/main/scala</sourceDirectory>
-	  <testSourceDirectory>${basedir}/src/test/scala</testSourceDirectory>
-	  <configLocation>${project.basedir}/../_tools/scalastyle.xml</configLocation>
-	  <outputFile>${project.basedir}/target/scalastyle-output.xml</outputFile>
-	  <outputEncoding>UTF-8</outputEncoding>
-	</configuration>
+        <groupId>org.scalastyle</groupId>
+        <artifactId>scalastyle-maven-plugin</artifactId>
+        <version>${plugin.scalastyle.version}</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>check</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <verbose>false</verbose>
+          <failOnViolation>true</failOnViolation>
+          <includeTestSourceDirectory>true</includeTestSourceDirectory>
+          <failOnWarning>false</failOnWarning>
+          <sourceDirectory>${basedir}/src/main/scala</sourceDirectory>
+          <testSourceDirectory>${basedir}/src/test/scala</testSourceDirectory>
+          <configLocation>${project.basedir}/../_tools/scalastyle.xml</configLocation>
+          <outputFile>${project.basedir}/target/scalastyle-output.xml</outputFile>
+          <outputEncoding>UTF-8</outputEncoding>
+        </configuration>
       </plugin>
 
-        <plugin>
-            <artifactId>maven-enforcer-plugin</artifactId>
-        </plugin>
-        <plugin>
-            <artifactId>maven-dependency-plugin</artifactId>
-        </plugin>
-        <plugin>
-            <artifactId>maven-resources-plugin</artifactId>
-        </plugin>
+      <plugin>
+        <artifactId>maven-enforcer-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <artifactId>maven-dependency-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <artifactId>maven-resources-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <configuration>
+          <skip>false</skip>
+        </configuration>
+      </plugin>
 
     </plugins>
   </build>

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/65b797c2/flink/src/main/java/org/apache/zeppelin/flink/FlinkInterpreter.java
----------------------------------------------------------------------
diff --git a/flink/src/main/java/org/apache/zeppelin/flink/FlinkInterpreter.java b/flink/src/main/java/org/apache/zeppelin/flink/FlinkInterpreter.java
index 19c77de..9d66437 100644
--- a/flink/src/main/java/org/apache/zeppelin/flink/FlinkInterpreter.java
+++ b/flink/src/main/java/org/apache/zeppelin/flink/FlinkInterpreter.java
@@ -17,15 +17,6 @@
  */
 package org.apache.zeppelin.flink;
 
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.*;
-
 import org.apache.flink.api.common.JobID;
 import org.apache.flink.api.scala.FlinkILoop;
 import org.apache.flink.configuration.Configuration;
@@ -33,15 +24,21 @@ import org.apache.flink.runtime.akka.AkkaUtils;
 import org.apache.flink.runtime.instance.ActorGateway;
 import org.apache.flink.runtime.messages.JobManagerMessages;
 import org.apache.flink.runtime.minicluster.LocalFlinkMiniCluster;
-import org.apache.zeppelin.interpreter.Interpreter;
-import org.apache.zeppelin.interpreter.InterpreterContext;
-import org.apache.zeppelin.interpreter.InterpreterResult;
-import org.apache.zeppelin.interpreter.InterpreterResult.Code;
-import org.apache.zeppelin.interpreter.InterpreterUtils;
-import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
 import scala.Console;
 import scala.Some;
 import scala.collection.JavaConversions;
@@ -54,8 +51,15 @@ import scala.tools.nsc.settings.MutableSettings;
 import scala.tools.nsc.settings.MutableSettings.BooleanSetting;
 import scala.tools.nsc.settings.MutableSettings.PathSetting;
 
+import org.apache.zeppelin.interpreter.Interpreter;
+import org.apache.zeppelin.interpreter.InterpreterContext;
+import org.apache.zeppelin.interpreter.InterpreterResult;
+import org.apache.zeppelin.interpreter.InterpreterResult.Code;
+import org.apache.zeppelin.interpreter.InterpreterUtils;
+import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
+
 /**
- * Interpreter for Apache Flink (http://flink.apache.org)
+ * Interpreter for Apache Flink (http://flink.apache.org).
  */
 public class FlinkInterpreter extends Interpreter {
   Logger logger = LoggerFactory.getLogger(FlinkInterpreter.class);
@@ -116,7 +120,6 @@ public class FlinkInterpreter extends Interpreter {
 
     org.apache.flink.api.scala.ExecutionEnvironment benv =
             flinkIloop.scalaBenv();
-            //new ExecutionEnvironment(remoteBenv)
     org.apache.flink.streaming.api.scala.StreamExecutionEnvironment senv =
             flinkIloop.scalaSenv();
 

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/65b797c2/flink/src/test/java/org/apache/zeppelin/flink/FlinkInterpreterTest.java
----------------------------------------------------------------------
diff --git a/flink/src/test/java/org/apache/zeppelin/flink/FlinkInterpreterTest.java b/flink/src/test/java/org/apache/zeppelin/flink/FlinkInterpreterTest.java
index c9cb1f6..a95db39 100644
--- a/flink/src/test/java/org/apache/zeppelin/flink/FlinkInterpreterTest.java
+++ b/flink/src/test/java/org/apache/zeppelin/flink/FlinkInterpreterTest.java
@@ -20,15 +20,16 @@ package org.apache.zeppelin.flink;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
 import java.util.Arrays;
 import java.util.Properties;
 
 import org.apache.zeppelin.interpreter.InterpreterContext;
 import org.apache.zeppelin.interpreter.InterpreterResult;
 import org.apache.zeppelin.interpreter.InterpreterResult.Code;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
 
 public class FlinkInterpreterTest {
 
@@ -40,7 +41,8 @@ public class FlinkInterpreterTest {
     Properties p = new Properties();
     flink = new FlinkInterpreter(p);
     flink.open();
-    context = new InterpreterContext(null, null, null, null, null, null, null, null, null, null, null, null, null);
+    context = new InterpreterContext(null, null, null, null, null, null, null, null, null, null,
+            null, null, null);
   }
 
   @AfterClass
@@ -50,17 +52,20 @@ public class FlinkInterpreterTest {
 
   @Test
   public void testNextLineInvocation() {
-    assertEquals(InterpreterResult.Code.SUCCESS, flink.interpret("\"123\"\n.toInt", context).code());
+    assertEquals(InterpreterResult.Code.SUCCESS, flink.interpret("\"123\"\n.toInt", context)
+            .code());
   }
 
   @Test
   public void testNextLineComments() {
-    assertEquals(InterpreterResult.Code.SUCCESS, flink.interpret("\"123\"\n/*comment here\n*/.toInt", context).code());
+    assertEquals(InterpreterResult.Code.SUCCESS,
+            flink.interpret("\"123\"\n/*comment here\n*/.toInt", context).code());
   }
 
   @Test
   public void testNextLineCompanionObject() {
-    String code = "class Counter {\nvar value: Long = 0\n}\n // comment\n\n object Counter {\n def apply(x: Long) = new Counter()\n}";
+    String code = "class Counter {\nvar value: Long = 0\n}\n // comment\n\n object Counter " +
+            "{\n def apply(x: Long) = new Counter()\n}";
     assertEquals(InterpreterResult.Code.SUCCESS, flink.interpret(code, context).code());
   }
 
@@ -81,7 +86,8 @@ public class FlinkInterpreterTest {
   @Test
   public void testWordCount() {
     flink.interpret("val text = benv.fromElements(\"To be or not to be\")", context);
-    flink.interpret("val counts = text.flatMap { _.toLowerCase.split(\" \") }.map { (_, 1) }.groupBy(0).sum(1)", context);
+    flink.interpret("val counts = text.flatMap { _.toLowerCase.split(\" \") }" +
+            ".map { (_, 1) }.groupBy(0).sum(1)", context);
     InterpreterResult result = flink.interpret("counts.print()", context);
     assertEquals(Code.SUCCESS, result.code());