ZEPPELIN-3138. checkstyle for zeppelin-interpreter ### What is this PR for? Code Style improvement
### What type of PR is it? [Improvement] ### Todos * [ ] - Task ### What is the Jira issue? * https://issues.apache.org/jira/browse/ZEPPELIN-3138 ### 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: Jeff Zhang <zjf...@apache.org> Closes #2753 from zjffdu/ZEPPELIN-3138 and squashes the following commits: c777161 [Jeff Zhang] ZEPPELIN-3138. checkstyle for zeppelin-interpreter Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/7fbb5985 Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/7fbb5985 Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/7fbb5985 Branch: refs/heads/master Commit: 7fbb5985ffd13dbdb76e708fcf8f5705b2df0a54 Parents: ed1947b Author: Jeff Zhang <zjf...@apache.org> Authored: Tue Jan 30 10:19:41 2018 +0800 Committer: Jeff Zhang <zjf...@apache.org> Committed: Wed Jan 31 19:44:43 2018 +0800 ---------------------------------------------------------------------- _tools/checkstyle.xml | 12 +- zeppelin-interpreter/pom.xml | 9 + .../zeppelin/conf/ZeppelinConfiguration.java | 2 +- .../apache/zeppelin/dep/DependencyResolver.java | 3 +- .../zeppelin/display/AngularObjectListener.java | 2 +- .../zeppelin/display/AngularObjectRegistry.java | 1 - .../display/AngularObjectRegistryListener.java | 6 +- .../java/org/apache/zeppelin/display/Input.java | 14 +- .../display/RuntimeTypeAdapterFactory.java | 8 +- .../apache/zeppelin/display/ui/CheckBox.java | 3 - .../org/apache/zeppelin/helium/Application.java | 1 - .../zeppelin/helium/ApplicationContext.java | 1 - .../helium/ApplicationEventListener.java | 8 +- .../zeppelin/helium/ApplicationLoader.java | 8 +- .../apache/zeppelin/helium/HeliumPackage.java | 6 +- .../zeppelin/interpreter/Interpreter.java | 23 +- .../interpreter/InterpreterHookListener.java | 4 +- .../InterpreterOutputChangeListener.java | 2 +- .../interpreter/InterpreterOutputListener.java | 6 +- .../zeppelin/interpreter/InterpreterResult.java | 12 +- .../InterpreterResultMessageOutput.java | 7 +- .../InterpreterResultMessageOutputListener.java | 4 +- .../interpreter/WrappedInterpreter.java | 2 +- .../remote/RemoteEventClientWrapper.java | 4 +- .../remote/RemoteInterpreterContextRunner.java | 1 - .../remote/RemoteInterpreterEventClient.java | 7 +- .../remote/RemoteInterpreterServer.java | 63 +++--- .../zeppelin/resource/LocalResourcePool.java | 7 +- .../org/apache/zeppelin/resource/Resource.java | 23 +- .../apache/zeppelin/resource/ResourcePool.java | 16 +- .../resource/ResourcePoolConnector.java | 8 +- .../apache/zeppelin/scheduler/JobListener.java | 6 +- .../zeppelin/scheduler/JobProgressPoller.java | 4 +- .../zeppelin/scheduler/ParallelScheduler.java | 2 +- .../apache/zeppelin/scheduler/Scheduler.java | 12 +- .../zeppelin/scheduler/SchedulerListener.java | 4 +- .../apache/zeppelin/tabledata/ColumnDef.java | 2 +- .../apache/zeppelin/tabledata/TableData.java | 4 +- .../java/org/apache/zeppelin/util/IdHashes.java | 4 +- .../zeppelin/dep/DependencyResolverTest.java | 22 +- .../display/AngularObjectRegistryTest.java | 18 +- .../zeppelin/display/AngularObjectTest.java | 71 +++--- .../org/apache/zeppelin/display/GUITest.java | 6 - .../org/apache/zeppelin/display/InputTest.java | 216 ++++++++++--------- .../zeppelin/helium/ApplicationLoaderTest.java | 7 +- .../zeppelin/helium/HeliumPackageTest.java | 6 +- .../zeppelin/helium/MockApplication1.java | 1 - .../interpreter/InterpreterContextTest.java | 8 +- .../InterpreterHookRegistryTest.java | 16 +- .../InterpreterOutputChangeWatcherTest.java | 32 +-- .../interpreter/InterpreterOutputTest.java | 11 +- .../interpreter/InterpreterResultTest.java | 87 +++++--- .../zeppelin/interpreter/InterpreterTest.java | 10 +- .../interpreter/LazyOpenInterpreterTest.java | 11 +- .../remote/RemoteInterpreterServerTest.java | 34 +-- .../remote/RemoteInterpreterUtilsTest.java | 12 +- .../resource/LocalResourcePoolTest.java | 5 +- .../zeppelin/scheduler/FIFOSchedulerTest.java | 132 ++++++------ .../scheduler/ParallelSchedulerTest.java | 67 +++--- .../apache/zeppelin/scheduler/SleepingJob.java | 114 +++++----- .../src/test/resources/log4j.properties | 2 +- 61 files changed, 658 insertions(+), 541 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/_tools/checkstyle.xml ---------------------------------------------------------------------- diff --git a/_tools/checkstyle.xml b/_tools/checkstyle.xml index d7eaaf9..aa53d30 100644 --- a/_tools/checkstyle.xml +++ b/_tools/checkstyle.xml @@ -58,9 +58,10 @@ limitations under the License. <!-- Checks for redundant import statements. --> <property name="severity" value="error"/> </module> - <module name="ImportOrder"> Checks for out of order import statements - <property name="severity" value="warning"/> <property name="groups" value="com.google,junit,net,org,java,javax,*,org.apache.zeppelin"/> - This ensures that static imports go first <property name="option" value="top"/> + <module name="ImportOrder"> + <property name="severity" value="warning"/> + <property name="groups" value="com.google,junit,net,org,java,javax,*,org.apache.zeppelin"/> + <property name="option" value="top"/> <property name="tokens" value="STATIC_IMPORT, IMPORT"/> </module> <!-- JAVADOC CHECKS --> @@ -78,11 +79,6 @@ limitations under the License. <property name="allowUndeclaredRTE" value="true"/> </module> - <module name="JavadocType"> - <property name="scope" value="protected"/> - <property name="severity" value="error"/> - </module> - <module name="JavadocStyle"> <property name="severity" value="warning"/> </module> http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/pom.xml ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/pom.xml b/zeppelin-interpreter/pom.xml index da31f78..80864f9 100644 --- a/zeppelin-interpreter/pom.xml +++ b/zeppelin-interpreter/pom.xml @@ -239,6 +239,15 @@ </dependencies> <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <configuration> + <skip>false</skip> + </configuration> + </plugin> + </plugins> <pluginManagement> <plugins> <plugin> http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java index 17e3e5b..a107320 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java @@ -603,7 +603,7 @@ public class ZeppelinConfiguration extends XMLConfiguration { /** * Wrapper class. */ - public static enum ConfVars { + public enum ConfVars { ZEPPELIN_HOME("zeppelin.home", "./"), ZEPPELIN_ADDR("zeppelin.server.addr", "0.0.0.0"), ZEPPELIN_PORT("zeppelin.server.port", 8080), http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/DependencyResolver.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/DependencyResolver.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/DependencyResolver.java index c3ecdee..495c69b 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/DependencyResolver.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/DependencyResolver.java @@ -156,7 +156,8 @@ public class DependencyResolver extends AbstractDependencyResolver { */ @Override public List<ArtifactResult> getArtifactsWithDep(String dependency, - Collection<String> excludes) throws RepositoryException { + Collection<String> excludes) + throws RepositoryException { Artifact artifact = new DefaultArtifact(dependency); DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE); PatternExclusionsDependencyFilter exclusionFilter = http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectListener.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectListener.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectListener.java index 880e487..20f34af 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectListener.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectListener.java @@ -21,5 +21,5 @@ package org.apache.zeppelin.display; * */ public interface AngularObjectListener { - public void updated(AngularObject updatedObject); + void updated(AngularObject updatedObject); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectRegistry.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectRegistry.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectRegistry.java index a993992..930ed7c 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectRegistry.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectRegistry.java @@ -17,7 +17,6 @@ package org.apache.zeppelin.display; -import java.util.Collection; import java.util.HashMap; import java.util.LinkedList; import java.util.List; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectRegistryListener.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectRegistryListener.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectRegistryListener.java index 103336d..081bb43 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectRegistryListener.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectRegistryListener.java @@ -22,7 +22,7 @@ package org.apache.zeppelin.display; * */ public interface AngularObjectRegistryListener { - public void onAdd(String interpreterGroupId, AngularObject object); - public void onUpdate(String interpreterGroupId, AngularObject object); - public void onRemove(String interpreterGroupId, String name, String noteId, String paragraphId); + void onAdd(String interpreterGroupId, AngularObject object); + void onUpdate(String interpreterGroupId, AngularObject object); + void onRemove(String interpreterGroupId, String name, String noteId, String paragraphId); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/Input.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/Input.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/Input.java index a6860de..51e27d2 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/Input.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/Input.java @@ -18,12 +18,20 @@ package org.apache.zeppelin.display; import org.apache.commons.lang.StringUtils; -import org.apache.zeppelin.common.JsonSerializable; -import org.apache.zeppelin.display.ui.*; +import org.apache.zeppelin.display.ui.CheckBox; +import org.apache.zeppelin.display.ui.OptionInput; import org.apache.zeppelin.display.ui.OptionInput.ParamOption; +import org.apache.zeppelin.display.ui.Select; +import org.apache.zeppelin.display.ui.TextBox; import java.io.Serializable; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/RuntimeTypeAdapterFactory.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/RuntimeTypeAdapterFactory.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/RuntimeTypeAdapterFactory.java index da05caa..65b4f6b 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/RuntimeTypeAdapterFactory.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/RuntimeTypeAdapterFactory.java @@ -17,7 +17,13 @@ package org.apache.zeppelin.display; -import com.google.gson.*; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; import com.google.gson.internal.Streams; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/CheckBox.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/CheckBox.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/CheckBox.java index f9b4650..02a0ff4 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/CheckBox.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/CheckBox.java @@ -18,10 +18,7 @@ package org.apache.zeppelin.display.ui; -import java.awt.*; -import java.util.Arrays; import java.util.Collection; -import java.util.Collections; /** * Html Checkbox http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/Application.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/Application.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/Application.java index 2918998..d138595 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/Application.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/Application.java @@ -17,7 +17,6 @@ package org.apache.zeppelin.helium; import org.apache.zeppelin.annotation.Experimental; -import org.apache.zeppelin.interpreter.InterpreterContext; import org.apache.zeppelin.resource.ResourceSet; import java.io.IOException; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationContext.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationContext.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationContext.java index e0ea94c..8d3f67e 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationContext.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationContext.java @@ -16,7 +16,6 @@ */ package org.apache.zeppelin.helium; -import org.apache.zeppelin.display.AngularObjectRegistry; import org.apache.zeppelin.interpreter.InterpreterOutput; /** http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationEventListener.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationEventListener.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationEventListener.java index eda907a..ca971f5 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationEventListener.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationEventListener.java @@ -22,11 +22,11 @@ import org.apache.zeppelin.interpreter.InterpreterResult; * Event from HeliumApplication running on remote interpreter process */ public interface ApplicationEventListener { - public void onOutputAppend( + void onOutputAppend( String noteId, String paragraphId, int index, String appId, String output); - public void onOutputUpdated( + void onOutputUpdated( String noteId, String paragraphId, int index, String appId, InterpreterResult.Type type, String output); - public void onLoad(String noteId, String paragraphId, String appId, HeliumPackage pkg); - public void onStatusChange(String noteId, String paragraphId, String appId, String status); + void onLoad(String noteId, String paragraphId, String appId, HeliumPackage pkg); + void onStatusChange(String noteId, String paragraphId, String appId, String status); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationLoader.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationLoader.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationLoader.java index ddd061c..241273a 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationLoader.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationLoader.java @@ -28,7 +28,11 @@ import java.io.File; import java.lang.reflect.Constructor; import java.net.URL; import java.net.URLClassLoader; -import java.util.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; /** * Load application @@ -55,7 +59,7 @@ public class ApplicationLoader { String noteId; String paragraphId; - public RunningApplication(HeliumPackage packageInfo, String noteId, String paragraphId) { + RunningApplication(HeliumPackage packageInfo, String noteId, String paragraphId) { this.packageInfo = packageInfo; this.noteId = noteId; this.paragraphId = paragraphId; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/HeliumPackage.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/HeliumPackage.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/HeliumPackage.java index 759b991..e9995c1 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/HeliumPackage.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/HeliumPackage.java @@ -19,7 +19,6 @@ package org.apache.zeppelin.helium; import com.google.gson.Gson; import org.apache.zeppelin.annotation.Experimental; import org.apache.zeppelin.common.JsonSerializable; -import org.apache.zeppelin.dep.Repository; import java.util.Map; @@ -35,8 +34,9 @@ public class HeliumPackage implements JsonSerializable { private String description; // description private String artifact; // artifact name e.g) groupId:artifactId:versionId private String className; // entry point - private String [][] resources; // resource classnames that requires - // [[ .. and .. and .. ] or [ .. and .. and ..] ..] + // resource classnames that requires [[ .. and .. and .. ] or [ .. and .. and ..] ..] + private String [][] resources; + private String license; private String icon; private String published; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/Interpreter.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/Interpreter.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/Interpreter.java index 386de41..52cc161 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/Interpreter.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/Interpreter.java @@ -18,26 +18,25 @@ package org.apache.zeppelin.interpreter; -import java.lang.reflect.Field; -import java.net.URL; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; - import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.reflect.FieldUtils; import org.apache.zeppelin.annotation.Experimental; import org.apache.zeppelin.annotation.ZeppelinApi; -import org.apache.zeppelin.interpreter.launcher.InterpreterLauncher; import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; import org.apache.zeppelin.scheduler.Scheduler; import org.apache.zeppelin.scheduler.SchedulerFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.lang.reflect.Field; +import java.net.URL; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + /** * Interface for interpreters. * If you want to implement new Zeppelin interpreter, extend this class @@ -371,7 +370,7 @@ public abstract class Interpreter { /** * Type of interpreter. */ - public static enum FormType { + public enum FormType { NATIVE, SIMPLE, NONE } @@ -458,7 +457,7 @@ public abstract class Interpreter { /** * Type of Scheduling. */ - public static enum SchedulingMode { + public enum SchedulingMode { FIFO, PARALLEL } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterHookListener.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterHookListener.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterHookListener.java index c70212c..d0dbad1 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterHookListener.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterHookListener.java @@ -24,10 +24,10 @@ public interface InterpreterHookListener { /** * Prepends pre-execute hook code to the script that will be interpreted */ - public void onPreExecute(String script); + void onPreExecute(String script); /** * Appends post-execute hook code to the script that will be interpreted */ - public void onPostExecute(String script); + void onPostExecute(String script); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterOutputChangeListener.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterOutputChangeListener.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterOutputChangeListener.java index a639e0c..44bcd7c 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterOutputChangeListener.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterOutputChangeListener.java @@ -22,6 +22,6 @@ import java.io.File; * InterpreterOutputChangeListener */ public interface InterpreterOutputChangeListener { - public void fileChanged(File file); + void fileChanged(File file); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterOutputListener.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterOutputListener.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterOutputListener.java index 42f6cfa..a176ef2 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterOutputListener.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterOutputListener.java @@ -23,7 +23,7 @@ public interface InterpreterOutputListener { /** * update all message outputs */ - public void onUpdateAll(InterpreterOutput out); + void onUpdateAll(InterpreterOutput out); /** * called when newline is detected @@ -31,12 +31,12 @@ public interface InterpreterOutputListener { * @param out * @param line */ - public void onAppend(int index, InterpreterResultMessageOutput out, byte[] line); + void onAppend(int index, InterpreterResultMessageOutput out, byte[] line); /** * when entire output is updated. eg) after detecting new display system * @param index * @param out */ - public void onUpdate(int index, InterpreterResultMessageOutput out); + void onUpdate(int index, InterpreterResultMessageOutput out); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterResult.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterResult.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterResult.java index b08a97e..255b21e 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterResult.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterResult.java @@ -17,15 +17,15 @@ package org.apache.zeppelin.interpreter; -import java.io.IOException; -import java.io.Serializable; - import com.google.gson.Gson; import org.apache.zeppelin.common.JsonSerializable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.*; +import java.io.IOException; +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; /** * Interpreter result template. @@ -37,7 +37,7 @@ public class InterpreterResult implements Serializable, JsonSerializable { /** * Type of result after code execution. */ - public static enum Code { + public enum Code { SUCCESS, INCOMPLETE, ERROR, @@ -47,7 +47,7 @@ public class InterpreterResult implements Serializable, JsonSerializable { /** * Type of Data. */ - public static enum Type { + public enum Type { TEXT, HTML, ANGULAR, http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterResultMessageOutput.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterResultMessageOutput.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterResultMessageOutput.java index 41e1fd0..da31364 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterResultMessageOutput.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterResultMessageOutput.java @@ -19,7 +19,12 @@ package org.apache.zeppelin.interpreter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.*; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.net.URL; import java.util.LinkedList; import java.util.List; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterResultMessageOutputListener.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterResultMessageOutputListener.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterResultMessageOutputListener.java index ba5acf9..7f14a3e 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterResultMessageOutputListener.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterResultMessageOutputListener.java @@ -24,10 +24,10 @@ public interface InterpreterResultMessageOutputListener { * called when newline is detected * @param line */ - public void onAppend(InterpreterResultMessageOutput out, byte[] line); + void onAppend(InterpreterResultMessageOutput out, byte[] line); /** * when entire output is updated. eg) after detecting new display system */ - public void onUpdate(InterpreterResultMessageOutput out); + void onUpdate(InterpreterResultMessageOutput out); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/WrappedInterpreter.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/WrappedInterpreter.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/WrappedInterpreter.java index a12a9aa..040b546 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/WrappedInterpreter.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/WrappedInterpreter.java @@ -21,5 +21,5 @@ package org.apache.zeppelin.interpreter; * WrappedInterpreter */ public interface WrappedInterpreter { - public Interpreter getInnerInterpreter(); + Interpreter getInnerInterpreter(); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteEventClientWrapper.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteEventClientWrapper.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteEventClientWrapper.java index bf36cd6..e43365c 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteEventClientWrapper.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteEventClientWrapper.java @@ -10,9 +10,9 @@ import java.util.Map; */ public interface RemoteEventClientWrapper { - public void onMetaInfosReceived(Map<String, String> infos); + void onMetaInfosReceived(Map<String, String> infos); - public void onParaInfosReceived(String noteId, String paragraphId, + void onParaInfosReceived(String noteId, String paragraphId, Map<String, String> infos); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterContextRunner.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterContextRunner.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterContextRunner.java index 74b8db6..c0b1251 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterContextRunner.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterContextRunner.java @@ -18,7 +18,6 @@ package org.apache.zeppelin.interpreter.remote; import org.apache.zeppelin.interpreter.InterpreterContextRunner; -import org.apache.zeppelin.interpreter.InterpreterException; /** * http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterEventClient.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterEventClient.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterEventClient.java index 5f8ccb7..9ca8a32 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterEventClient.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterEventClient.java @@ -25,7 +25,11 @@ import org.apache.zeppelin.interpreter.RemoteZeppelinServerResource; import org.apache.zeppelin.interpreter.thrift.RemoteInterpreterEvent; import org.apache.zeppelin.interpreter.thrift.RemoteInterpreterEventType; import org.apache.zeppelin.interpreter.thrift.ZeppelinServerResourceParagraphRunner; -import org.apache.zeppelin.resource.*; +import org.apache.zeppelin.resource.RemoteResource; +import org.apache.zeppelin.resource.Resource; +import org.apache.zeppelin.resource.ResourceId; +import org.apache.zeppelin.resource.ResourcePoolConnector; +import org.apache.zeppelin.resource.ResourceSet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -356,6 +360,7 @@ public class RemoteInterpreterEventClient implements ResourcePoolConnector { try { eventQueue.wait(1000); } catch (InterruptedException e) { + // ignore exception } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServer.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServer.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServer.java index c2a578c..fca8449 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServer.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServer.java @@ -97,8 +97,8 @@ import java.util.concurrent.ConcurrentMap; * Accepting thrift connections from ZeppelinServer. */ public class RemoteInterpreterServer - extends Thread - implements RemoteInterpreterService.Iface, AngularObjectRegistryListener { + extends Thread + implements RemoteInterpreterService.Iface, AngularObjectRegistryListener { Logger logger = LoggerFactory.getLogger(RemoteInterpreterServer.class); InterpreterGroup interpreterGroup; @@ -171,6 +171,7 @@ public class RemoteInterpreterServer if (null != callbackHost && !isTest) { new Thread(new Runnable() { boolean interrupted = false; + @Override public void run() { while (!interrupted && !server.isServing()) { @@ -300,7 +301,7 @@ public class RemoteInterpreterServer setSystemProperty(p); Constructor<Interpreter> constructor = - replClass.getConstructor(new Class[] {Properties.class}); + replClass.getConstructor(new Class[]{Properties.class}); Interpreter repl = constructor.newInstance(p); repl.setClassloaderUrls(new URL[]{}); logger.info("Instantiate interpreter {}", className); @@ -417,7 +418,8 @@ public class RemoteInterpreterServer @Override public RemoteInterpreterResult interpret(String noteId, String className, String st, - RemoteInterpreterContext interpreterContext) throws TException { + RemoteInterpreterContext interpreterContext) + throws TException { if (logger.isDebugEnabled()) { logger.debug("st:\n{}", st); } @@ -527,7 +529,7 @@ public class RemoteInterpreterServer private Map<String, Object> infos; private Object results; - public InterpretJob( + InterpretJob( String jobId, String jobName, JobListener listener, @@ -716,7 +718,10 @@ public class RemoteInterpreterServer @Override public List<InterpreterCompletion> completion(String sessionId, - String className, String buf, int cursor, RemoteInterpreterContext remoteInterpreterContext) + String className, + String buf, + int cursor, + RemoteInterpreterContext remoteInterpreterContext) throws TException { Interpreter intp = getInterpreter(sessionId, className); try { @@ -733,7 +738,7 @@ public class RemoteInterpreterServer private InterpreterContext convert(RemoteInterpreterContext ric, InterpreterOutput output) { List<InterpreterContextRunner> contextRunners = new LinkedList<>(); List<InterpreterContextRunner> runners = gson.fromJson(ric.getRunners(), - new TypeToken<List<RemoteInterpreterContextRunner>>() { + new TypeToken<List<RemoteInterpreterContextRunner>>() { }.getType()); for (InterpreterContextRunner r : runners) { @@ -748,7 +753,8 @@ public class RemoteInterpreterServer ric.getParagraphText(), AuthenticationInfo.fromJson(ric.getAuthenticationInfo()), (Map<String, Object>) gson.fromJson(ric.getConfig(), - new TypeToken<Map<String, Object>>() {}.getType()), + new TypeToken<Map<String, Object>>() { + }.getType()), GUI.fromJson(ric.getGui()), GUI.fromJson(ric.getNoteGui()), interpreterGroup.getAngularObjectRegistry(), @@ -798,7 +804,7 @@ public class RemoteInterpreterServer Logger logger = LoggerFactory.getLogger(ParagraphRunner.class); private transient RemoteInterpreterServer server; - public ParagraphRunner(RemoteInterpreterServer server, String noteId, String paragraphId) { + ParagraphRunner(RemoteInterpreterServer server, String noteId, String paragraphId) { super(noteId, paragraphId); this.server = server; } @@ -809,13 +815,14 @@ public class RemoteInterpreterServer } } - static class ZeppelinRemoteWorksController implements RemoteWorksController{ + static class ZeppelinRemoteWorksController implements RemoteWorksController { Logger logger = LoggerFactory.getLogger(ZeppelinRemoteWorksController.class); private final long DEFAULT_TIMEOUT_VALUE = 300000; private final Map<String, Object> remoteWorksResponsePool; private RemoteInterpreterServer server; - public ZeppelinRemoteWorksController( + + ZeppelinRemoteWorksController( RemoteInterpreterServer server, Map<String, Object> remoteWorksResponsePool) { this.remoteWorksResponsePool = remoteWorksResponsePool; this.server = server; @@ -882,7 +889,7 @@ public class RemoteInterpreterServer } private RemoteInterpreterResult convert(InterpreterResult result, - Map<String, Object> config, GUI gui, GUI noteGui) { + Map<String, Object> config, GUI gui, GUI noteGui) { List<RemoteInterpreterResultMessage> msg = new LinkedList<>(); for (InterpreterResultMessage m : result.message()) { @@ -930,7 +937,6 @@ public class RemoteInterpreterServer } - @Override public void onAdd(String interpreterGroupId, AngularObject object) { eventClient.angularObjectAdd(object); @@ -949,6 +955,7 @@ public class RemoteInterpreterServer /** * Poll event from RemoteInterpreterEventPoller + * * @return * @throws TException */ @@ -959,8 +966,9 @@ public class RemoteInterpreterServer /** * called when object is updated in client (web) side. + * * @param name - * @param noteId noteId where the update issues + * @param noteId noteId where the update issues * @param paragraphId paragraphId where the update issues * @param object * @throws TException @@ -998,8 +1006,8 @@ public class RemoteInterpreterServer if (value == null) { try { value = gson.fromJson(object, - new TypeToken<Map<String, Object>>() { - }.getType()); + new TypeToken<Map<String, Object>>() { + }.getType()); } catch (Exception e) { // it's not a generic json object, too. okay, proceed to threat as a string type logger.debug(e.getMessage(), e); @@ -1050,7 +1058,7 @@ public class RemoteInterpreterServer @Override public void angularObjectRemove(String name, String noteId, String paragraphId) throws - TException { + TException { AngularObjectRegistry registry = interpreterGroup.getAngularObjectRegistry(); registry.remove(name, noteId, paragraphId, false); } @@ -1062,8 +1070,9 @@ public class RemoteInterpreterServer /** * Get payload of resource from remote + * * @param resourceId json serialized ResourceId - * @param object java serialized of the object + * @param object java serialized of the object * @throws TException */ @Override @@ -1158,8 +1167,9 @@ public class RemoteInterpreterServer /** * Get payload of resource from remote + * * @param invokeResourceMethodEventMessage json serialized InvokeResourcemethodEventMessage - * @param object java serialized of the object + * @param object java serialized of the object * @throws TException */ @Override @@ -1184,8 +1194,9 @@ public class RemoteInterpreterServer public void angularRegistryPush(String registryAsString) throws TException { try { Map<String, Map<String, AngularObject>> deserializedRegistry = gson - .fromJson(registryAsString, - new TypeToken<Map<String, Map<String, AngularObject>>>() { }.getType()); + .fromJson(registryAsString, + new TypeToken<Map<String, Map<String, AngularObject>>>() { + }.getType()); interpreterGroup.getAngularObjectRegistry().setRegistry(deserializedRegistry); } catch (Exception e) { logger.info("Exception in RemoteInterpreterServer while angularRegistryPush, nolock", e); @@ -1193,8 +1204,8 @@ public class RemoteInterpreterServer } protected InterpreterOutput createAppOutput(final String noteId, - final String paragraphId, - final String appId) { + final String paragraphId, + final String appId) { return new InterpreterOutput(new InterpreterOutputListener() { @Override public void onUpdateAll(InterpreterOutput out) { @@ -1322,7 +1333,7 @@ public class RemoteInterpreterServer public final String noteId; public final String paragraphId; - public RunningApplication(HeliumPackage pkg, + RunningApplication(HeliumPackage pkg, Application app, String noteId, String paragraphId) { @@ -1331,5 +1342,7 @@ public class RemoteInterpreterServer this.noteId = noteId; this.paragraphId = paragraphId; } - }; + } + + ; } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/resource/LocalResourcePool.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/resource/LocalResourcePool.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/resource/LocalResourcePool.java index 5a0193c..7ae2273 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/resource/LocalResourcePool.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/resource/LocalResourcePool.java @@ -16,7 +16,9 @@ */ package org.apache.zeppelin.resource; -import java.util.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; /** * ResourcePool @@ -35,6 +37,7 @@ public class LocalResourcePool implements ResourcePool { /** * Get unique id of this resource pool + * * @return */ @Override @@ -44,6 +47,7 @@ public class LocalResourcePool implements ResourcePool { /** * Get resource + * * @return null if resource not found */ @Override @@ -65,6 +69,7 @@ public class LocalResourcePool implements ResourcePool { /** * Put resource into the pull + * * @param * @param object object to put into the resource */ http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/resource/Resource.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/resource/Resource.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/resource/Resource.java index b57d46b..ec95ffb 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/resource/Resource.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/resource/Resource.java @@ -21,7 +21,12 @@ import org.apache.zeppelin.common.JsonSerializable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.*; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; import java.lang.reflect.Method; import java.nio.ByteBuffer; @@ -109,13 +114,14 @@ public class Resource implements JsonSerializable { /** * Call a method of the object that this resource holds + * * @param methodName name of method to call * @param paramTypes method parameter types - * @param params method parameter values + * @param params method parameter values * @return return value of the method */ public Object invokeMethod( - String methodName, Class [] paramTypes, Object [] params) { + String methodName, Class[] paramTypes, Object[] params) { if (r != null) { try { Method method = r.getClass().getMethod( @@ -124,7 +130,7 @@ public class Resource implements JsonSerializable { method.setAccessible(true); Object ret = method.invoke(r, params); return ret; - } catch (Exception e) { + } catch (Exception e) { logException(e); return null; } @@ -135,14 +141,15 @@ public class Resource implements JsonSerializable { /** * Call a method of the object that this resource holds and save return value as a resource - * @param methodName name of method to call - * @param paramTypes method parameter types - * @param params method parameter values + * + * @param methodName name of method to call + * @param paramTypes method parameter types + * @param params method parameter values * @param returnResourceName name of resource that return value will be saved * @return Resource that holds return value */ public Resource invokeMethod( - String methodName, Class [] paramTypes, Object [] params, String returnResourceName) { + String methodName, Class[] paramTypes, Object[] params, String returnResourceName) { if (r != null) { try { Method method = r.getClass().getMethod( http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/resource/ResourcePool.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/resource/ResourcePool.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/resource/ResourcePool.java index a1c28de..12b4d7a 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/resource/ResourcePool.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/resource/ResourcePool.java @@ -24,14 +24,14 @@ public interface ResourcePool { * Get unique id of the resource pool * @return */ - public String id(); + String id(); /** * Get resource from name * @param name Resource name * @return null if resource not found */ - public Resource get(String name); + Resource get(String name); /** * Get resource from name @@ -40,20 +40,20 @@ public interface ResourcePool { * @param name Resource name * @return null if resource not found */ - public Resource get(String noteId, String paragraphId, String name); + Resource get(String noteId, String paragraphId, String name); /** * Get all resources * @return */ - public ResourceSet getAll(); + ResourceSet getAll(); /** * Put an object into resource pool * @param name * @param object */ - public void put(String name, Object object); + void put(String name, Object object); /** * Put an object into resource pool @@ -65,14 +65,14 @@ public interface ResourcePool { * @param name * @param object */ - public void put(String noteId, String paragraphId, String name, Object object); + void put(String noteId, String paragraphId, String name, Object object); /** * Remove object * @param name Resource name to remove * @return removed Resource. null if resource not found */ - public Resource remove(String name); + Resource remove(String name); /** * Remove object @@ -81,5 +81,5 @@ public interface ResourcePool { * @param name Resource name to remove * @return removed Resource. null if resource not found */ - public Resource remove(String noteId, String paragraphId, String name); + Resource remove(String noteId, String paragraphId, String name); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/resource/ResourcePoolConnector.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/resource/ResourcePoolConnector.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/resource/ResourcePoolConnector.java index f270d92..169229b 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/resource/ResourcePoolConnector.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/resource/ResourcePoolConnector.java @@ -24,19 +24,19 @@ public interface ResourcePoolConnector { * Get list of resources from all other resource pools in remote processes * @return */ - public ResourceSet getAllResources(); + ResourceSet getAllResources(); /** * Read remote object * @return */ - public Object readResource(ResourceId id); + Object readResource(ResourceId id); /** * Invoke method of Resource and get return * @return */ - public Object invokeMethod( + Object invokeMethod( ResourceId id, String methodName, Class[] paramTypes, @@ -45,7 +45,7 @@ public interface ResourcePoolConnector { /** * Invoke method, put result into resource pool and return */ - public Resource invokeMethod( + Resource invokeMethod( ResourceId id, String methodName, Class[] paramTypes, http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/JobListener.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/JobListener.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/JobListener.java index 9ee2746..3042941 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/JobListener.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/JobListener.java @@ -21,9 +21,9 @@ package org.apache.zeppelin.scheduler; * TODO(moon) : add description. */ public interface JobListener { - public void onProgressUpdate(Job job, int progress); + void onProgressUpdate(Job job, int progress); - public void beforeStatusChange(Job job, Job.Status before, Job.Status after); + void beforeStatusChange(Job job, Job.Status before, Job.Status after); - public void afterStatusChange(Job job, Job.Status before, Job.Status after); + void afterStatusChange(Job job, Job.Status before, Job.Status after); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/JobProgressPoller.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/JobProgressPoller.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/JobProgressPoller.java index 8b8cda0..3d6ce12 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/JobProgressPoller.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/JobProgressPoller.java @@ -60,6 +60,8 @@ public class JobProgressPoller extends Thread { } Thread.sleep(intervalMs); } - } catch (InterruptedException ignored) {} + } catch (InterruptedException ignored) { + // just ignore this exception + } } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/ParallelScheduler.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/ParallelScheduler.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/ParallelScheduler.java index 36a67e3..6f67cd7 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/ParallelScheduler.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/ParallelScheduler.java @@ -136,7 +136,7 @@ public class ParallelScheduler implements Scheduler { private Scheduler scheduler; private Job job; - public JobRunner(Scheduler scheduler, Job job) { + JobRunner(Scheduler scheduler, Job job) { this.scheduler = scheduler; this.job = job; } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/Scheduler.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/Scheduler.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/Scheduler.java index 90d4397..3055727 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/Scheduler.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/Scheduler.java @@ -23,15 +23,15 @@ import java.util.Collection; * Interface for scheduler */ public interface Scheduler extends Runnable { - public String getName(); + String getName(); - public Collection<Job> getJobsWaiting(); + Collection<Job> getJobsWaiting(); - public Collection<Job> getJobsRunning(); + Collection<Job> getJobsRunning(); - public void submit(Job job); + void submit(Job job); - public Job removeFromWaitingQueue(String jobId); + Job removeFromWaitingQueue(String jobId); - public void stop(); + void stop(); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/SchedulerListener.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/SchedulerListener.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/SchedulerListener.java index 79232e6..9a6b3ed 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/SchedulerListener.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/SchedulerListener.java @@ -21,7 +21,7 @@ package org.apache.zeppelin.scheduler; * TODO(moon) : add description. */ public interface SchedulerListener { - public void jobStarted(Scheduler scheduler, Job job); + void jobStarted(Scheduler scheduler, Job job); - public void jobFinished(Scheduler scheduler, Job job); + void jobFinished(Scheduler scheduler, Job job); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/tabledata/ColumnDef.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/tabledata/ColumnDef.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/tabledata/ColumnDef.java index 75afc18..a2fac20 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/tabledata/ColumnDef.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/tabledata/ColumnDef.java @@ -25,7 +25,7 @@ public class ColumnDef implements Serializable { /** * Type */ - public static enum TYPE { + public enum TYPE { STRING, LONG, INT http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/tabledata/TableData.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/tabledata/TableData.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/tabledata/TableData.java index 6e34f47..ed254c5 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/tabledata/TableData.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/tabledata/TableData.java @@ -26,12 +26,12 @@ public interface TableData { * Get column definitions * @return */ - public ColumnDef [] columns(); + ColumnDef [] columns(); /** * Get row iterator * @param * @return */ - public Iterator<Row> rows(); + Iterator<Row> rows(); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/main/java/org/apache/zeppelin/util/IdHashes.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/util/IdHashes.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/util/IdHashes.java index 052aaef..9d4e10f 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/util/IdHashes.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/util/IdHashes.java @@ -27,8 +27,8 @@ import java.security.SecureRandom; */ public class IdHashes { private static final char[] DICTIONARY = new char[] {'1', '2', '3', '4', '5', '6', '7', '8', '9', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', - 'W', 'X', 'Y', 'Z'}; + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', + 'W', 'X', 'Y', 'Z'}; /** * encodes the given string into the base of the dictionary provided in the constructor. http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/test/java/org/apache/zeppelin/dep/DependencyResolverTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/dep/DependencyResolverTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/dep/DependencyResolverTest.java index 876e8e7..7ccc7df 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/dep/DependencyResolverTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/dep/DependencyResolverTest.java @@ -17,12 +17,6 @@ package org.apache.zeppelin.dep; -import static org.junit.Assert.assertEquals; - -import java.io.File; -import java.io.FileNotFoundException; -import java.util.Collections; - import org.apache.commons.io.FileUtils; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -31,6 +25,12 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonatype.aether.RepositoryException; +import java.io.File; +import java.io.FileNotFoundException; +import java.util.Collections; + +import static org.junit.Assert.assertEquals; + public class DependencyResolverTest { private static DependencyResolver resolver; private static String testPath; @@ -42,12 +42,13 @@ public class DependencyResolverTest { @BeforeClass public static void setUp() throws Exception { - tmpDir = new File(System.getProperty("java.io.tmpdir")+"/ZeppelinLTest_"+System.currentTimeMillis()); + tmpDir = new File(System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + + System.currentTimeMillis()); testPath = tmpDir.getAbsolutePath() + "/test-repo"; testCopyPath = new File(tmpDir, "test-copy-repo"); resolver = new DependencyResolver(testPath); } - + @AfterClass public static void tearDown() throws Exception { FileUtils.deleteDirectory(tmpDir); @@ -85,7 +86,8 @@ public class DependencyResolverTest { FileUtils.cleanDirectory(testCopyPath); // load from added repository - resolver.addRepo("sonatype", "https://oss.sonatype.org/content/repositories/agimatec-releases/", false); + resolver.addRepo("sonatype", + "https://oss.sonatype.org/content/repositories/agimatec-releases/", false); resolver.load("com.agimatec:agimatec-validation:0.9.3", testCopyPath); assertEquals(testCopyPath.list().length, 8); @@ -103,4 +105,4 @@ public class DependencyResolverTest { resolver.load("one.two:1.0", testCopyPath); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/AngularObjectRegistryTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/AngularObjectRegistryTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/AngularObjectRegistryTest.java index 2d0436f..aefc484 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/AngularObjectRegistryTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/AngularObjectRegistryTest.java @@ -17,13 +17,12 @@ package org.apache.zeppelin.display; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import org.junit.Test; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; public class AngularObjectRegistryTest { @@ -47,10 +46,13 @@ public class AngularObjectRegistryTest { } @Override - public void onRemove(String interpreterGroupId, String name, String noteId, String paragraphId) { + public void onRemove(String interpreterGroupId, + String name, + String noteId, + String paragraphId) { onRemove.incrementAndGet(); } - }); + }); registry.add("name1", "value1", "note1", null); assertEquals(1, registry.getAll("note1", null).size()); @@ -65,12 +67,12 @@ public class AngularObjectRegistryTest { assertEquals(1, onRemove.get()); assertEquals(null, registry.get("name1", "note1", null)); - + // namespace registry.add("name1", "value11", "note2", null); assertEquals("value11", registry.get("name1", "note2", null).get()); assertEquals(null, registry.get("name1", "note1", null)); - + // null namespace registry.add("name1", "global1", null, null); assertEquals("global1", registry.get("name1", null, null).get()); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/AngularObjectTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/AngularObjectTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/AngularObjectTest.java index 924c5d4..0196526 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/AngularObjectTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/AngularObjectTest.java @@ -17,61 +17,61 @@ package org.apache.zeppelin.display; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; +import org.apache.zeppelin.interpreter.InterpreterContext; +import org.junit.Test; import java.util.concurrent.atomic.AtomicInteger; -import org.apache.zeppelin.interpreter.InterpreterContext; -import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; public class AngularObjectTest { @Test public void testEquals() { assertEquals( - new AngularObject("name", "value", "note1", null, null), - new AngularObject("name", "value", "note1", null, null) + new AngularObject("name", "value", "note1", null, null), + new AngularObject("name", "value", "note1", null, null) ); assertEquals( - new AngularObject("name", "value", "note1", "paragraph1", null), - new AngularObject("name", "value", "note1", "paragraph1", null) + new AngularObject("name", "value", "note1", "paragraph1", null), + new AngularObject("name", "value", "note1", "paragraph1", null) ); assertEquals( - new AngularObject("name", "value", null, null, null), - new AngularObject("name", "value", null, null, null) + new AngularObject("name", "value", null, null, null), + new AngularObject("name", "value", null, null, null) ); assertEquals( - new AngularObject("name", "value1", null, null, null), - new AngularObject("name", "value2", null, null, null) + new AngularObject("name", "value1", null, null, null), + new AngularObject("name", "value2", null, null, null) ); assertNotSame( - new AngularObject("name1", "value", null, null, null), - new AngularObject("name2", "value", null, null, null) + new AngularObject("name1", "value", null, null, null), + new AngularObject("name2", "value", null, null, null) ); assertNotSame( - new AngularObject("name1", "value", "note1", null, null), - new AngularObject("name2", "value", "note2", null, null) + new AngularObject("name1", "value", "note1", null, null), + new AngularObject("name2", "value", "note2", null, null) ); assertNotSame( - new AngularObject("name1", "value", "note", null, null), - new AngularObject("name2", "value", null, null, null) + new AngularObject("name1", "value", "note", null, null), + new AngularObject("name2", "value", null, null, null) ); assertNotSame( - new AngularObject("name", "value", "note", "paragraph1", null), - new AngularObject("name", "value", "note", "paragraph2", null) + new AngularObject("name", "value", "note", "paragraph1", null), + new AngularObject("name", "value", "note", "paragraph2", null) ); assertNotSame( - new AngularObject("name", "value", "note1", null, null), - new AngularObject("name", "value", "note1", "paragraph1", null) + new AngularObject("name", "value", "note1", null, null), + new AngularObject("name", "value", "note1", "paragraph1", null) ); @@ -80,14 +80,14 @@ public class AngularObjectTest { @Test public void testListener() { final AtomicInteger updated = new AtomicInteger(0); - AngularObject ao = new AngularObject("name", "value", "note1", null, new AngularObjectListener() { + AngularObject ao = new AngularObject("name", "value", "note1", null, + new AngularObjectListener() { - @Override - public void updated(AngularObject updatedObject) { - updated.incrementAndGet(); - } - - }); + @Override + public void updated(AngularObject updatedObject) { + updated.incrementAndGet(); + } + }); assertEquals(0, updated.get()); ao.set("newValue"); @@ -106,12 +106,13 @@ public class AngularObjectTest { public void testWatcher() throws InterruptedException { final AtomicInteger updated = new AtomicInteger(0); final AtomicInteger onWatch = new AtomicInteger(0); - AngularObject ao = new AngularObject("name", "value", "note1", null, new AngularObjectListener() { - @Override - public void updated(AngularObject updatedObject) { - updated.incrementAndGet(); - } - }); + AngularObject ao = new AngularObject("name", "value", "note1", null, + new AngularObjectListener() { + @Override + public void updated(AngularObject updatedObject) { + updated.incrementAndGet(); + } + }); ao.addWatcher(new AngularObjectWatcher(null) { @Override http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/GUITest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/GUITest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/GUITest.java index 15af2e6..7d369b8 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/GUITest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/GUITest.java @@ -17,22 +17,16 @@ package org.apache.zeppelin.display; -import org.apache.commons.io.IOUtils; import org.apache.zeppelin.display.ui.CheckBox; import org.apache.zeppelin.display.ui.OptionInput.ParamOption; import org.apache.zeppelin.display.ui.Select; import org.apache.zeppelin.display.ui.TextBox; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/InputTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/InputTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/InputTest.java index d3d5a00..a9252b9 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/InputTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/InputTest.java @@ -17,9 +17,6 @@ package org.apache.zeppelin.display; -import java.util.HashMap; -import java.util.Map; - import org.apache.zeppelin.display.ui.CheckBox; import org.apache.zeppelin.display.ui.OptionInput.ParamOption; import org.apache.zeppelin.display.ui.Select; @@ -28,112 +25,123 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import java.util.HashMap; +import java.util.Map; + import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class InputTest { - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testFormExtraction() { - // textbox form - String script = "${input_form=}"; - Map<String, Input> forms = Input.extractSimpleQueryForm(script, false); - assertEquals(1, forms.size()); - Input form = forms.get("input_form"); - assertEquals("input_form", form.name); - assertNull(form.displayName); - assertEquals("", form.defaultValue); - assertTrue(form instanceof TextBox); - - // textbox form with display name & default value - script = "${input_form(Input Form)=xxx}"; - forms = Input.extractSimpleQueryForm(script, false); - form = forms.get("input_form"); - assertEquals("xxx", form.defaultValue); - assertTrue(form instanceof TextBox); - - // selection form - script = "${select_form(Selection Form)=op1,op1|op2(Option 2)|op3}"; - form = Input.extractSimpleQueryForm(script, false).get("select_form"); - assertEquals("select_form", form.name); - assertEquals("op1", form.defaultValue); - assertTrue(form instanceof Select); - assertArrayEquals(new ParamOption[]{new ParamOption("op1", null), - new ParamOption("op2", "Option 2"), new ParamOption("op3", null)}, - ((Select) form).getOptions()); - - // checkbox form - script = "${checkbox:checkbox_form=op1,op1|op2|op3}"; - form = Input.extractSimpleQueryForm(script, false).get("checkbox_form"); - assertEquals("checkbox_form", form.name); - assertTrue(form instanceof CheckBox); - - assertArrayEquals(new Object[]{"op1"}, (Object[]) form.defaultValue); - assertArrayEquals(new ParamOption[]{new ParamOption("op1", null), - new ParamOption("op2", null), new ParamOption("op3", null)}, - ((CheckBox) form).getOptions()); - - // checkbox form with multiple default checks - script = "${checkbox:checkbox_form(Checkbox Form)=op1|op3,op1(Option 1)|op2|op3}"; - form = Input.extractSimpleQueryForm(script, false).get("checkbox_form"); - assertEquals("checkbox_form", form.name); - assertEquals("Checkbox Form", form.displayName); - assertTrue(form instanceof CheckBox); - assertArrayEquals(new Object[]{"op1", "op3"}, (Object[]) form.defaultValue); - assertArrayEquals(new ParamOption[]{new ParamOption("op1", "Option 1"), - new ParamOption("op2", null), new ParamOption("op3", null)}, - ((CheckBox) form).getOptions()); - - // checkbox form with no default check - script = "${checkbox:checkbox_form(Checkbox Form)=,op1(Option 1)|op2(Option 2)|op3(Option 3)}"; - form = Input.extractSimpleQueryForm(script, false).get("checkbox_form"); - assertEquals("checkbox_form", form.name); - assertEquals("Checkbox Form", form.displayName); - assertTrue(form instanceof CheckBox); - assertArrayEquals(new Object[]{}, (Object[]) form.defaultValue); - assertArrayEquals(new ParamOption[]{new ParamOption("op1", "Option 1"), - new ParamOption("op2", "Option 2"), new ParamOption("op3", "Option 3")}, - ((CheckBox) form).getOptions()); - } - - - @Test - public void testFormSubstitution() { - // test form substitution without new forms - String script = "INPUT=${input_form=}SELECTED=${select_form(Selection Form)=,s_op1|s_op2|s_op3}\n" + - "CHECKED=${checkbox:checkbox_form=c_op1|c_op2,c_op1|c_op2|c_op3}"; - Map<String, Object> params = new HashMap<>(); - params.put("input_form", "some_input"); - params.put("select_form", "s_op2"); - params.put("checkbox_form", new String[]{"c_op1", "c_op3"}); - String replaced = Input.getSimpleQuery(params, script, false); - assertEquals("INPUT=some_inputSELECTED=s_op2\nCHECKED=c_op1,c_op3", replaced); - - // test form substitution with new forms - script = "INPUT=${input_form=}SELECTED=${select_form(Selection Form)=,s_op1|s_op2|s_op3}\n" + - "CHECKED=${checkbox:checkbox_form=c_op1|c_op2,c_op1|c_op2|c_op3}\n" + - "NEW_CHECKED=${checkbox( and ):new_check=nc_a|nc_c,nc_a|nc_b|nc_c}"; - replaced = Input.getSimpleQuery(params, script, false); - assertEquals("INPUT=some_inputSELECTED=s_op2\nCHECKED=c_op1,c_op3\n" + - "NEW_CHECKED=nc_a and nc_c", replaced); - - // test form substitution with obsoleted values - script = "INPUT=${input_form=}SELECTED=${select_form(Selection Form)=,s_op1|s_op2|s_op3}\n" + - "CHECKED=${checkbox:checkbox_form=c_op1|c_op2,c_op1|c_op2|c_op3_new}\n" + - "NEW_CHECKED=${checkbox( and ):new_check=nc_a|nc_c,nc_a|nc_b|nc_c}"; - replaced = Input.getSimpleQuery(params, script, false); - assertEquals("INPUT=some_inputSELECTED=s_op2\nCHECKED=c_op1\n" + - "NEW_CHECKED=nc_a and nc_c", replaced); - } + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testFormExtraction() { + // textbox form + String script = "${input_form=}"; + Map<String, Input> forms = Input.extractSimpleQueryForm(script, false); + assertEquals(1, forms.size()); + Input form = forms.get("input_form"); + assertEquals("input_form", form.name); + assertNull(form.displayName); + assertEquals("", form.defaultValue); + assertTrue(form instanceof TextBox); + + // textbox form with display name & default value + script = "${input_form(Input Form)=xxx}"; + forms = Input.extractSimpleQueryForm(script, false); + form = forms.get("input_form"); + assertEquals("xxx", form.defaultValue); + assertTrue(form instanceof TextBox); + + // selection form + script = "${select_form(Selection Form)=op1,op1|op2(Option 2)|op3}"; + form = Input.extractSimpleQueryForm(script, false).get("select_form"); + assertEquals("select_form", form.name); + assertEquals("op1", form.defaultValue); + assertTrue(form instanceof Select); + assertArrayEquals(new ParamOption[]{ + new ParamOption("op1", null), + new ParamOption("op2", "Option 2"), + new ParamOption("op3", null)}, + ((Select) form).getOptions()); + + // checkbox form + script = "${checkbox:checkbox_form=op1,op1|op2|op3}"; + form = Input.extractSimpleQueryForm(script, false).get("checkbox_form"); + assertEquals("checkbox_form", form.name); + assertTrue(form instanceof CheckBox); + + assertArrayEquals(new Object[]{"op1"}, (Object[]) form.defaultValue); + assertArrayEquals(new ParamOption[]{ + new ParamOption("op1", null), + new ParamOption("op2", null), + new ParamOption("op3", null)}, + ((CheckBox) form).getOptions()); + + // checkbox form with multiple default checks + script = "${checkbox:checkbox_form(Checkbox Form)=op1|op3,op1(Option 1)|op2|op3}"; + form = Input.extractSimpleQueryForm(script, false).get("checkbox_form"); + assertEquals("checkbox_form", form.name); + assertEquals("Checkbox Form", form.displayName); + assertTrue(form instanceof CheckBox); + assertArrayEquals(new Object[]{"op1", "op3"}, (Object[]) form.defaultValue); + assertArrayEquals(new ParamOption[]{ + new ParamOption("op1", "Option 1"), + new ParamOption("op2", null), + new ParamOption("op3", null)}, + ((CheckBox) form).getOptions()); + + // checkbox form with no default check + script = "${checkbox:checkbox_form(Checkbox Form)=,op1(Option 1)|op2(Option 2)|op3(Option 3)}"; + form = Input.extractSimpleQueryForm(script, false).get("checkbox_form"); + assertEquals("checkbox_form", form.name); + assertEquals("Checkbox Form", form.displayName); + assertTrue(form instanceof CheckBox); + assertArrayEquals(new Object[]{}, (Object[]) form.defaultValue); + assertArrayEquals(new ParamOption[]{ + new ParamOption("op1", "Option 1"), + new ParamOption("op2", "Option 2"), + new ParamOption("op3", "Option 3")}, + ((CheckBox) form).getOptions()); + } + + + @Test + public void testFormSubstitution() { + // test form substitution without new forms + String script = "INPUT=${input_form=}SELECTED=${select_form(Selection Form)=" + + ",s_op1|s_op2|s_op3}\nCHECKED=${checkbox:checkbox_form=c_op1|c_op2,c_op1|c_op2|c_op3}"; + Map<String, Object> params = new HashMap<>(); + params.put("input_form", "some_input"); + params.put("select_form", "s_op2"); + params.put("checkbox_form", new String[]{"c_op1", "c_op3"}); + String replaced = Input.getSimpleQuery(params, script, false); + assertEquals("INPUT=some_inputSELECTED=s_op2\nCHECKED=c_op1,c_op3", replaced); + + // test form substitution with new forms + script = "INPUT=${input_form=}SELECTED=${select_form(Selection Form)=,s_op1|s_op2|s_op3}\n" + + "CHECKED=${checkbox:checkbox_form=c_op1|c_op2,c_op1|c_op2|c_op3}\n" + + "NEW_CHECKED=${checkbox( and ):new_check=nc_a|nc_c,nc_a|nc_b|nc_c}"; + replaced = Input.getSimpleQuery(params, script, false); + assertEquals("INPUT=some_inputSELECTED=s_op2\nCHECKED=c_op1,c_op3\n" + + "NEW_CHECKED=nc_a and nc_c", replaced); + + // test form substitution with obsoleted values + script = "INPUT=${input_form=}SELECTED=${select_form(Selection Form)=,s_op1|s_op2|s_op3}\n" + + "CHECKED=${checkbox:checkbox_form=c_op1|c_op2,c_op1|c_op2|c_op3_new}\n" + + "NEW_CHECKED=${checkbox( and ):new_check=nc_a|nc_c,nc_a|nc_b|nc_c}"; + replaced = Input.getSimpleQuery(params, script, false); + assertEquals("INPUT=some_inputSELECTED=s_op2\nCHECKED=c_op1\n" + + "NEW_CHECKED=nc_a and nc_c", replaced); + } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/ApplicationLoaderTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/ApplicationLoaderTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/ApplicationLoaderTest.java index acb4d7f..490c911 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/ApplicationLoaderTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/ApplicationLoaderTest.java @@ -28,14 +28,17 @@ import org.junit.Test; import java.io.File; import java.io.IOException; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class ApplicationLoaderTest { private File tmpDir; @Before public void setUp() { - tmpDir = new File(System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + System.currentTimeMillis()); + tmpDir = new File(System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + + System.currentTimeMillis()); tmpDir.mkdirs(); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/HeliumPackageTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/HeliumPackageTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/HeliumPackageTest.java index ad427e9..e810742 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/HeliumPackageTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/HeliumPackageTest.java @@ -21,7 +21,7 @@ import org.junit.Test; import java.util.Map; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; public class HeliumPackageTest { @@ -71,10 +71,10 @@ public class HeliumPackageTest { Map<String, Object> config = p.getConfig(); Map<String, Object> accessToken = (Map<String, Object>) config.get("access-token"); - assertEquals((String) accessToken.get("type"),"string"); + assertEquals((String) accessToken.get("type"), "string"); assertEquals((String) accessToken.get("description"), "access token for Google Translation API"); assertEquals((String) accessToken.get("defaultValue"), "EXAMPLE-TOKEN"); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/MockApplication1.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/MockApplication1.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/MockApplication1.java index df3afef..c962d84 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/MockApplication1.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/MockApplication1.java @@ -16,7 +16,6 @@ */ package org.apache.zeppelin.helium; -import org.apache.zeppelin.interpreter.InterpreterContext; import org.apache.zeppelin.resource.ResourceSet; /** http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7fbb5985/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterContextTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterContextTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterContextTest.java index 70e2cba..8ad4841 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterContextTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterContextTest.java @@ -17,17 +17,19 @@ package org.apache.zeppelin.interpreter; -import static org.junit.Assert.*; - import org.junit.Test; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + public class InterpreterContextTest { @Test public void testThreadLocal() { assertNull(InterpreterContext.get()); - InterpreterContext.set(new InterpreterContext(null, null, null, null, null, null, null, null, null, null, null, null, null)); + InterpreterContext.set(new InterpreterContext(null, null, null, null, null, null, null, null, + null, null, null, null, null)); assertNotNull(InterpreterContext.get()); InterpreterContext.remove();