You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by jo...@apache.org on 2017/01/11 06:26:58 UTC
zeppelin git commit: ZEPPELIN-1862 Move packages related Helium into
a new module named helium-dev
Repository: zeppelin
Updated Branches:
refs/heads/master 8e6bfb45e -> e32ccf35d
ZEPPELIN-1862 Move packages related Helium into a new module named helium-dev
### What is this PR for?
Reducing zeppelin-interpreter by moving helium files into a new module
### What type of PR is it?
[Improvement]
### Todos
* [x] - Move files into a new module
### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-1862
### How should this be tested?
If you develop a new helium application, you have to depend helium-dev into your package
### Screenshots (if appropriate)
N/A
### Questions:
* Does the licenses files need update? N/A
* Is there breaking changes for older versions? N/A, AFAIK, there's no helium application for now
* Does this needs documentation? Yes, I'll make a new PR for handling it
Author: Jongyoul Lee <jo...@gmail.com>
Closes #1871 from jongyoul/ZEPPELIN-1862 and squashes the following commits:
fa3d086 [Jongyoul Lee] Fixed travis Added ASF license
14aebd1 [Jongyoul Lee] Fixed to set DevInterpreter into interpreter variable
61d9971 [Jongyoul Lee] Fixed classpath into new packages
28cf7a6 [Jongyoul Lee] Removed DevInterpreter from zeppelin-zengine
08d7c4e [Jongyoul Lee] Made new package for helium-dev Moved some classes
Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/e32ccf35
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/e32ccf35
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/e32ccf35
Branch: refs/heads/master
Commit: e32ccf35d727a47fc4b38039bf8adc86103c6352
Parents: 8e6bfb4
Author: Jongyoul Lee <jo...@gmail.com>
Authored: Mon Jan 9 00:44:56 2017 +0900
Committer: Jongyoul Lee <jo...@apache.org>
Committed: Wed Jan 11 15:26:48 2017 +0900
----------------------------------------------------------------------
.travis.yml | 10 +-
docs/development/writingzeppelinapplication.md | 4 +-
helium-dev/pom.xml | 89 ++++++++++
.../apache/zeppelin/helium/DevInterpreter.java | 123 +++++++++++++
.../helium/ZeppelinApplicationDevServer.java | 172 ++++++++++++++++++
.../zeppelin/helium/ZeppelinDevServer.java | 136 ++++++++++++++
.../src/main/resources/interpreter-setting.json | 19 ++
pom.xml | 7 +
.../zeppelin-example-clock/pom.xml | 8 +-
.../zeppelin/example/app/clock/Clock.java | 2 +-
.../zeppelin-example-horizontalbar/pom.xml | 6 +
.../app/horizontalbar/HorizontalBar.java | 2 +-
.../apache/zeppelin/interpreter/Constants.java | 2 +
.../interpreter/dev/DevInterpreter.java | 122 -------------
.../dev/ZeppelinApplicationDevServer.java | 175 -------------------
.../interpreter/dev/ZeppelinDevServer.java | 137 ---------------
.../remote/RemoteInterpreterServer.java | 21 +--
.../interpreter/InterpreterFactory.java | 27 ---
18 files changed, 578 insertions(+), 484 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e32ccf35/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 89ca600..1e046c4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -42,19 +42,19 @@ matrix:
# Test all modules with spark 2.0.2 and scala 2.11
- jdk: "oraclejdk7"
- env: SCALA_VER="2.11" SPARK_VER="2.0.2" HADOOP_VER="2.6" PROFILE="-Pspark-2.0 -Phadoop-2.6 -Ppyspark -Psparkr -Pscalding -Pexamples -Pscala-2.11" BUILD_FLAG="package -Pbuild-distr -DskipRat" TEST_FLAG="verify -Pusing-packaged-distr -DskipRat" TEST_PROJECTS=""
+ env: SCALA_VER="2.11" SPARK_VER="2.0.2" HADOOP_VER="2.6" PROFILE="-Pspark-2.0 -Phadoop-2.6 -Ppyspark -Psparkr -Pscalding -Phelium-dev -Pexamples -Pscala-2.11" BUILD_FLAG="package -Pbuild-distr -DskipRat" TEST_FLAG="verify -Pusing-packaged-distr -DskipRat" TEST_PROJECTS=""
# Test all modules with spark 2.1.0 and scala 2.11
- jdk: "oraclejdk7"
- env: SCALA_VER="2.11" SPARK_VER="2.1.0" HADOOP_VER="2.6" PROFILE="-Pspark-2.0 -Phadoop-2.6 -Ppyspark -Psparkr -Pscalding -Pexamples -Pscala-2.11" BUILD_FLAG="package -Pbuild-distr -DskipRat" TEST_FLAG="verify -Pusing-packaged-distr -DskipRat" TEST_PROJECTS=""
+ env: SCALA_VER="2.11" SPARK_VER="2.1.0" HADOOP_VER="2.6" PROFILE="-Pspark-2.0 -Phadoop-2.6 -Ppyspark -Psparkr -Pscalding -Phelium-dev -Pexamples -Pscala-2.11" BUILD_FLAG="package -Pbuild-distr -DskipRat" TEST_FLAG="verify -Pusing-packaged-distr -DskipRat" TEST_PROJECTS=""
# Test all modules with scala 2.10
- jdk: "oraclejdk7"
- env: SCALA_VER="2.10" SPARK_VER="1.6.3" HADOOP_VER="2.6" PROFILE="-Pspark-1.6 -Pr -Phadoop-2.6 -Ppyspark -Psparkr -Pscalding -Pbeam -Pexamples -Pscala-2.10" BUILD_FLAG="package -Pbuild-distr -DskipRat" TEST_FLAG="verify -Pusing-packaged-distr -DskipRat" TEST_PROJECTS=""
+ env: SCALA_VER="2.10" SPARK_VER="1.6.3" HADOOP_VER="2.6" PROFILE="-Pspark-1.6 -Pr -Phadoop-2.6 -Ppyspark -Psparkr -Pscalding -Pbeam -Phelium-dev -Pexamples -Pscala-2.10" BUILD_FLAG="package -Pbuild-distr -DskipRat" TEST_FLAG="verify -Pusing-packaged-distr -DskipRat" TEST_PROJECTS=""
# Test all modules with scala 2.11
- jdk: "oraclejdk7"
- env: SCALA_VER="2.11" SPARK_VER="1.6.3" HADOOP_VER="2.6" PROFILE="-Pspark-1.6 -Pr -Phadoop-2.6 -Ppyspark -Psparkr -Pscalding -Pexamples -Pscala-2.11" BUILD_FLAG="package -Pbuild-distr -DskipRat" TEST_FLAG="verify -Pusing-packaged-distr -DskipRat" TEST_PROJECTS=""
+ env: SCALA_VER="2.11" SPARK_VER="1.6.3" HADOOP_VER="2.6" PROFILE="-Pspark-1.6 -Pr -Phadoop-2.6 -Ppyspark -Psparkr -Pscalding -Phelium-dev -Pexamples -Pscala-2.11" BUILD_FLAG="package -Pbuild-distr -DskipRat" TEST_FLAG="verify -Pusing-packaged-distr -DskipRat" TEST_PROJECTS=""
# Test spark module for 1.5.2
- jdk: "oraclejdk7"
@@ -66,7 +66,7 @@ matrix:
# Test selenium with spark module for 1.6.3
- jdk: "oraclejdk7"
- env: TEST_SELENIUM="true" SCALA_VER="2.10" SPARK_VER="1.6.3" HADOOP_VER="2.6" PROFILE="-Pspark-1.6 -Phadoop-2.6 -Ppyspark -Pexamples" BUILD_FLAG="package -DskipTests -DskipRat" TEST_FLAG="verify -DskipRat" TEST_PROJECTS="-pl zeppelin-interpreter,zeppelin-zengine,zeppelin-server,zeppelin-display,spark-dependencies,spark -Dtest=org.apache.zeppelin.AbstractFunctionalSuite -DfailIfNoTests=false"
+ env: TEST_SELENIUM="true" SCALA_VER="2.10" SPARK_VER="1.6.3" HADOOP_VER="2.6" PROFILE="-Pspark-1.6 -Phadoop-2.6 -Ppyspark -Phelium-dev -Pexamples" BUILD_FLAG="package -DskipTests -DskipRat" TEST_FLAG="verify -DskipRat" TEST_PROJECTS="-pl zeppelin-interpreter,zeppelin-zengine,zeppelin-server,zeppelin-display,spark-dependencies,spark -Dtest=org.apache.zeppelin.AbstractFunctionalSuite -DfailIfNoTests=false"
# Test python/pyspark with python 2
- jdk: "oraclejdk7"
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e32ccf35/docs/development/writingzeppelinapplication.md
----------------------------------------------------------------------
diff --git a/docs/development/writingzeppelinapplication.md b/docs/development/writingzeppelinapplication.md
index e99bbcb..7048cb3 100644
--- a/docs/development/writingzeppelinapplication.md
+++ b/docs/development/writingzeppelinapplication.md
@@ -60,7 +60,7 @@ You can check example applications under [./zeppelin-examples](https://github.co
In the development mode, you can run your Application in your IDE as a normal java application and see the result inside of Zeppelin notebook.
-`org.apache.zeppelin.interpreter.dev.ZeppelinApplicationDevServer` can run Zeppelin Application in development mode.
+`org.apache.zeppelin.helium.ZeppelinApplicationDevServer` can run Zeppelin Application in development mode.
```java
@@ -73,7 +73,7 @@ public static void main(String[] args) throws Exception {
// run application in devlopment mode with given resource
// in this case, Clock.class.getName() will be the application class name
- ZeppelinApplicationDevServer devServer = new ZeppelinApplicationDevServer(
+ org.apache.zeppelin.helium.ZeppelinApplicationDevServer devServer = new org.apache.zeppelin.helium.ZeppelinApplicationDevServer(
Clock.class.getName(), pool.getAll());
// start development mode
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e32ccf35/helium-dev/pom.xml
----------------------------------------------------------------------
diff --git a/helium-dev/pom.xml b/helium-dev/pom.xml
new file mode 100644
index 0000000..938007d
--- /dev/null
+++ b/helium-dev/pom.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.zeppelin</groupId>
+ <artifactId>zeppelin</artifactId>
+ <version>0.7.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.zeppelin</groupId>
+ <artifactId>helium-dev</artifactId>
+ <version>0.7.0-SNAPSHOT</version>
+ <name>Zeppelin: Helium development interpreter</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.zeppelin</groupId>
+ <artifactId>zeppelin-interpreter</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/../../interpreter/helium-dev</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>false</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ <includeScope>runtime</includeScope>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-artifact</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/../../interpreter/helium-dev</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>false</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ <includeScope>runtime</includeScope>
+ <artifactItems>
+ <artifactItem>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>${project.artifactId}</artifactId>
+ <version>${project.version}</version>
+ <type>${project.packaging}</type>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e32ccf35/helium-dev/src/main/java/org/apache/zeppelin/helium/DevInterpreter.java
----------------------------------------------------------------------
diff --git a/helium-dev/src/main/java/org/apache/zeppelin/helium/DevInterpreter.java b/helium-dev/src/main/java/org/apache/zeppelin/helium/DevInterpreter.java
new file mode 100644
index 0000000..d1007c4
--- /dev/null
+++ b/helium-dev/src/main/java/org/apache/zeppelin/helium/DevInterpreter.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.zeppelin.helium;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.zeppelin.interpreter.Interpreter;
+import org.apache.zeppelin.interpreter.InterpreterContext;
+import org.apache.zeppelin.interpreter.InterpreterContextRunner;
+import org.apache.zeppelin.interpreter.InterpreterException;
+import org.apache.zeppelin.interpreter.InterpreterPropertyBuilder;
+import org.apache.zeppelin.interpreter.InterpreterResult;
+import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
+
+/**
+ * Dummy interpreter to support development mode for Zeppelin app
+ */
+public class DevInterpreter extends Interpreter {
+ static {
+ Interpreter.register(
+ "dev",
+ "dev",
+ DevInterpreter.class.getName(),
+ new InterpreterPropertyBuilder().build());
+ }
+
+ private InterpreterEvent interpreterEvent;
+ private InterpreterContext context;
+
+ public static boolean isInterpreterName(String replName) {
+ return replName.equals("dev");
+ }
+
+ /**
+ * event handler for org.apache.zeppelin.helium.ZeppelinApplicationDevServer
+ */
+ public static interface InterpreterEvent {
+ public InterpreterResult interpret(String st, InterpreterContext context);
+ }
+
+ public DevInterpreter(Properties property) {
+ super(property);
+ }
+
+ public DevInterpreter(Properties property, InterpreterEvent interpreterEvent) {
+ super(property);
+ this.interpreterEvent = interpreterEvent;
+ }
+
+ @Override
+ public void open() {
+ }
+
+ @Override
+ public void close() {
+ }
+
+ public void rerun() {
+ for (InterpreterContextRunner r : context.getRunners()) {
+ if (context.getParagraphId().equals(r.getParagraphId())) {
+ r.run();
+ }
+ }
+ }
+
+ @Override
+ public InterpreterResult interpret(String st, InterpreterContext context) {
+ this.context = context;
+ try {
+ return interpreterEvent.interpret(st, context);
+ } catch (Exception e) {
+ throw new InterpreterException(e);
+ }
+ }
+
+ @Override
+ public void cancel(InterpreterContext context) {
+ }
+
+ @Override
+ public FormType getFormType() {
+ return FormType.NATIVE;
+ }
+
+ @Override
+ public int getProgress(InterpreterContext context) {
+ return 0;
+ }
+
+ @Override
+ public List<InterpreterCompletion> completion(String buf, int cursor) {
+ return new LinkedList<>();
+ }
+
+ public InterpreterContext getLastInterpretContext() {
+ return context;
+ }
+
+ public void setInterpreterEvent(InterpreterEvent event) {
+ this.interpreterEvent = event;
+ }
+
+ public InterpreterEvent getInterpreterEvent() {
+ return interpreterEvent;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e32ccf35/helium-dev/src/main/java/org/apache/zeppelin/helium/ZeppelinApplicationDevServer.java
----------------------------------------------------------------------
diff --git a/helium-dev/src/main/java/org/apache/zeppelin/helium/ZeppelinApplicationDevServer.java b/helium-dev/src/main/java/org/apache/zeppelin/helium/ZeppelinApplicationDevServer.java
new file mode 100644
index 0000000..6b6d7cc
--- /dev/null
+++ b/helium-dev/src/main/java/org/apache/zeppelin/helium/ZeppelinApplicationDevServer.java
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.zeppelin.helium;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+
+import com.google.gson.Gson;
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.PatternLayout;
+import org.apache.zeppelin.interpreter.*;
+import org.apache.zeppelin.interpreter.InterpreterResult.Code;
+import org.apache.zeppelin.interpreter.remote.RemoteInterpreterEventClient;
+import org.apache.zeppelin.resource.ResourceSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Run this server for development mode.
+ */
+public class ZeppelinApplicationDevServer extends ZeppelinDevServer {
+ final Logger logger = LoggerFactory.getLogger(ZeppelinApplicationDevServer.class);
+
+ private final String className;
+ private final ResourceSet resourceSet;
+ private Application app;
+ private InterpreterOutput out;
+
+ public ZeppelinApplicationDevServer(final String className, ResourceSet resourceSet) throws
+ Exception {
+ this(Constants.ZEPPELIN_INTERPRETER_DEFAUlT_PORT, className, resourceSet);
+ }
+
+ public ZeppelinApplicationDevServer(int port, String className, ResourceSet resourceSet) throws
+ Exception {
+ super(port);
+ this.className = className;
+ this.resourceSet = resourceSet;
+ setLogger();
+ };
+
+ void setLogger() {
+ ConsoleAppender console = new ConsoleAppender(); //create appender
+ //configure the appender
+ String PATTERN = "%d [%p|%c|%C{1}] %m%n";
+ console.setLayout(new PatternLayout(PATTERN));
+ console.setThreshold(Level.DEBUG);
+ console.activateOptions();
+ //add appender to any Logger (here is root)
+ org.apache.log4j.Logger.getRootLogger().addAppender(console);
+ }
+
+
+ @Override
+ public InterpreterResult interpret(String st, InterpreterContext context) {
+ if (app == null) {
+ logger.info("Create instance " + className);
+ try {
+ Class<?> appClass = ClassLoader.getSystemClassLoader().loadClass(className);
+ Constructor<?> constructor = appClass.getConstructor(ApplicationContext.class);
+
+ // classPath will be ..../target/classes in dev mode most cases
+ String classPath = appClass.getProtectionDomain().getCodeSource().getLocation().getPath();
+
+ context.out.addResourceSearchPath(classPath + "../../src/main/resources/");
+ context.out.addResourceSearchPath(classPath + "../../src/test/resources/");
+
+ ApplicationContext appContext = getApplicationContext(context);
+ app = (Application) constructor.newInstance(appContext);
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ return new InterpreterResult(Code.ERROR, e.getMessage());
+ }
+ }
+
+ try {
+ logger.info("Run " + className);
+ app.context().out.clear();
+ app.context().out.setType(InterpreterResult.Type.ANGULAR);
+ transferTableResultDataToFrontend();
+ app.run(resourceSet);
+ } catch (IOException | ApplicationException e) {
+ logger.error(e.getMessage(), e);
+ return new InterpreterResult(Code.ERROR, e.getMessage());
+ }
+ return new InterpreterResult(Code.SUCCESS, "");
+ }
+
+ private void transferTableResultDataToFrontend() throws IOException {
+ ResourceSet results = resourceSet.filterByClassname(InterpreterResult.class.getName());
+ if (results.size() == 0) {
+ return;
+ }
+
+ InterpreterResultMessage result = (InterpreterResultMessage) results.get(0).get();
+ Gson gson = new Gson();
+ String resultJson = gson.toJson(result);
+ StringBuffer transferResult = new StringBuffer();
+ transferResult.append("$z.result = " + resultJson + ";\n");
+
+ if (result.getType() == InterpreterResult.Type.TABLE) {
+ transferResult.append("$z.scope.loadTableData($z.result);\n");
+ }
+
+ transferResult.append("$z.scope._devmodeResult = $z.result;\n");
+ app.printStringAsJavascript(transferResult.toString());
+ }
+
+ ApplicationContext getApplicationContext(InterpreterContext interpreterContext) {
+ return new ApplicationContext(
+ interpreterContext.getNoteId(),
+ interpreterContext.getParagraphId(),
+ "app_" + this.hashCode(),
+ new HeliumAppAngularObjectRegistry(
+ interpreterContext.getAngularObjectRegistry(),
+ interpreterContext.getNoteId(),
+ interpreterContext.getParagraphId()),
+ interpreterContext.out);
+ }
+
+ @Override
+ protected InterpreterOutput createInterpreterOutput(
+ final String noteId, final String paragraphId) {
+ if (out == null) {
+ final RemoteInterpreterEventClient eventClient = getEventClient();
+ try {
+ out = new InterpreterOutput(new InterpreterOutputListener() {
+ @Override
+ public void onUpdateAll(InterpreterOutput out) {
+
+ }
+
+ @Override
+ public void onAppend(int index, InterpreterResultMessageOutput out, byte[] line) {
+ eventClient.onInterpreterOutputAppend(noteId, paragraphId, index, new String(line));
+ }
+
+ @Override
+ public void onUpdate(int index, InterpreterResultMessageOutput out) {
+ try {
+ eventClient.onInterpreterOutputUpdate(noteId, paragraphId,
+ index, out.getType(), new String(out.toByteArray()));
+ } catch (IOException e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+
+ }, this);
+ } catch (IOException e) {
+ return null;
+ }
+ }
+
+ return out;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e32ccf35/helium-dev/src/main/java/org/apache/zeppelin/helium/ZeppelinDevServer.java
----------------------------------------------------------------------
diff --git a/helium-dev/src/main/java/org/apache/zeppelin/helium/ZeppelinDevServer.java b/helium-dev/src/main/java/org/apache/zeppelin/helium/ZeppelinDevServer.java
new file mode 100644
index 0000000..21ce283
--- /dev/null
+++ b/helium-dev/src/main/java/org/apache/zeppelin/helium/ZeppelinDevServer.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.zeppelin.helium;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+
+import org.apache.thrift.TException;
+import org.apache.zeppelin.helium.DevInterpreter.InterpreterEvent;
+import org.apache.zeppelin.interpreter.*;
+import org.apache.zeppelin.interpreter.remote.RemoteInterpreterEventClient;
+import org.apache.zeppelin.interpreter.remote.RemoteInterpreterServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Interpreter development server
+ */
+public class ZeppelinDevServer extends
+ RemoteInterpreterServer implements InterpreterEvent, InterpreterOutputChangeListener {
+ private static final Logger logger = LoggerFactory.getLogger(ZeppelinDevServer.class);
+
+ private DevInterpreter interpreter = null;
+ private InterpreterOutput out;
+ public ZeppelinDevServer(int port) throws TException {
+ super(port);
+ }
+
+ @Override
+ protected Interpreter getInterpreter(String sessionKey, String className) throws TException {
+ synchronized (this) {
+ InterpreterGroup interpreterGroup = getInterpreterGroup();
+ if (interpreterGroup == null || interpreterGroup.isEmpty()) {
+ createInterpreter(
+ "dev",
+ sessionKey,
+ DevInterpreter.class.getName(),
+ new HashMap<String, String>(),
+ "anonymous");
+ notify();
+ }
+ }
+
+ Interpreter intp = super.getInterpreter(sessionKey, className);
+ interpreter = (DevInterpreter) (
+ ((LazyOpenInterpreter) intp).getInnerInterpreter());
+ interpreter.setInterpreterEvent(this);
+ return super.getInterpreter(sessionKey, className);
+ }
+
+ @Override
+ protected InterpreterOutput createInterpreterOutput(
+ final String noteId, final String paragraphId) {
+ if (out == null) {
+ final RemoteInterpreterEventClient eventClient = getEventClient();
+ try {
+ out = new InterpreterOutput(new InterpreterOutputListener() {
+ @Override
+ public void onUpdateAll(InterpreterOutput out) {
+
+ }
+
+ @Override
+ public void onAppend(int index, InterpreterResultMessageOutput out, byte[] line) {
+ eventClient.onInterpreterOutputAppend(noteId, paragraphId, index, new String(line));
+ }
+
+ @Override
+ public void onUpdate(int index, InterpreterResultMessageOutput out) {
+ try {
+ eventClient.onInterpreterOutputUpdate(noteId, paragraphId,
+ index, out.getType(), new String(out.toByteArray()));
+ } catch (IOException e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+ }, this);
+ } catch (IOException e) {
+ return null;
+ }
+ }
+
+ out.clear();
+ return out;
+ }
+
+ @Override
+ public void fileChanged(File file) {
+ refresh();
+ }
+
+ @Override
+ public InterpreterResult interpret(String st, InterpreterContext context) {
+ waitForConnected();
+ return new InterpreterResult(InterpreterResult.Code.SUCCESS, "");
+ }
+
+ public void refresh() {
+ interpreter.rerun();
+ }
+
+ /**
+ * Wait until %dev paragraph is executed and connected to this process
+ */
+ public void waitForConnected() {
+ synchronized (this) {
+ while (!isConnected()) {
+ try {
+ this.wait(10 * 1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ public boolean isConnected() {
+ return !(interpreter == null || interpreter.getLastInterpretContext() == null);
+ }
+}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e32ccf35/helium-dev/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/helium-dev/src/main/resources/interpreter-setting.json b/helium-dev/src/main/resources/interpreter-setting.json
new file mode 100644
index 0000000..b3a7010
--- /dev/null
+++ b/helium-dev/src/main/resources/interpreter-setting.json
@@ -0,0 +1,19 @@
+[
+ {
+ "group": "dev",
+ "name": "dev",
+ "className": "org.apache.zeppelin.helium.DevInterpreter",
+ "properties": {
+ "port": {
+ "envName": "PORT",
+ "propertyName": "port",
+ "defaultValue": "jdbc:postgresql://localhost:5432/",
+ "description": "The URL for JDBC."
+ }
+ },
+ "editor": {
+ "language": "helium",
+ "editOnDblClick": false
+ }
+ }
+]
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e32ccf35/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d0eb7a7..dcd359b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -727,6 +727,13 @@
</profile>
<profile>
+ <id>helium-dev</id>
+ <modules>
+ <module>helium-dev</module>
+ </modules>
+ </profile>
+
+ <profile>
<id>build-distr</id>
<activation>
<activeByDefault>false</activeByDefault>
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e32ccf35/zeppelin-examples/zeppelin-example-clock/pom.xml
----------------------------------------------------------------------
diff --git a/zeppelin-examples/zeppelin-example-clock/pom.xml b/zeppelin-examples/zeppelin-example-clock/pom.xml
index 5bd3ff4..82f744c 100644
--- a/zeppelin-examples/zeppelin-example-clock/pom.xml
+++ b/zeppelin-examples/zeppelin-example-clock/pom.xml
@@ -34,10 +34,16 @@
<dependencies>
<dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>org.apache.zeppelin</groupId>
<artifactId>zeppelin-interpreter</artifactId>
<version>${project.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.zeppelin</groupId>
+ <artifactId>helium-dev</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e32ccf35/zeppelin-examples/zeppelin-example-clock/src/main/java/org/apache/zeppelin/example/app/clock/Clock.java
----------------------------------------------------------------------
diff --git a/zeppelin-examples/zeppelin-example-clock/src/main/java/org/apache/zeppelin/example/app/clock/Clock.java b/zeppelin-examples/zeppelin-example-clock/src/main/java/org/apache/zeppelin/example/app/clock/Clock.java
index 632b35f..bee8cf1 100644
--- a/zeppelin-examples/zeppelin-example-clock/src/main/java/org/apache/zeppelin/example/app/clock/Clock.java
+++ b/zeppelin-examples/zeppelin-example-clock/src/main/java/org/apache/zeppelin/example/app/clock/Clock.java
@@ -19,7 +19,7 @@ package org.apache.zeppelin.example.app.clock;
import org.apache.zeppelin.helium.Application;
import org.apache.zeppelin.helium.ApplicationContext;
import org.apache.zeppelin.helium.ApplicationException;
-import org.apache.zeppelin.interpreter.dev.ZeppelinApplicationDevServer;
+import org.apache.zeppelin.helium.ZeppelinApplicationDevServer;
import org.apache.zeppelin.resource.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e32ccf35/zeppelin-examples/zeppelin-example-horizontalbar/pom.xml
----------------------------------------------------------------------
diff --git a/zeppelin-examples/zeppelin-example-horizontalbar/pom.xml b/zeppelin-examples/zeppelin-example-horizontalbar/pom.xml
index 6305a2e..8784d79 100644
--- a/zeppelin-examples/zeppelin-example-horizontalbar/pom.xml
+++ b/zeppelin-examples/zeppelin-example-horizontalbar/pom.xml
@@ -38,6 +38,12 @@
<artifactId>zeppelin-interpreter</artifactId>
<version>${project.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>helium-dev</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e32ccf35/zeppelin-examples/zeppelin-example-horizontalbar/src/main/java/org/apache/zeppelin/example/app/horizontalbar/HorizontalBar.java
----------------------------------------------------------------------
diff --git a/zeppelin-examples/zeppelin-example-horizontalbar/src/main/java/org/apache/zeppelin/example/app/horizontalbar/HorizontalBar.java b/zeppelin-examples/zeppelin-example-horizontalbar/src/main/java/org/apache/zeppelin/example/app/horizontalbar/HorizontalBar.java
index fa209f6..6637821 100644
--- a/zeppelin-examples/zeppelin-example-horizontalbar/src/main/java/org/apache/zeppelin/example/app/horizontalbar/HorizontalBar.java
+++ b/zeppelin-examples/zeppelin-example-horizontalbar/src/main/java/org/apache/zeppelin/example/app/horizontalbar/HorizontalBar.java
@@ -20,8 +20,8 @@ import org.apache.commons.io.IOUtils;
import org.apache.zeppelin.helium.Application;
import org.apache.zeppelin.helium.ApplicationContext;
import org.apache.zeppelin.helium.ApplicationException;
+import org.apache.zeppelin.helium.ZeppelinApplicationDevServer;
import org.apache.zeppelin.interpreter.InterpreterResult;
-import org.apache.zeppelin.interpreter.dev.ZeppelinApplicationDevServer;
import org.apache.zeppelin.resource.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e32ccf35/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/Constants.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/Constants.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/Constants.java
index 0ab94ac..d5679a3 100644
--- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/Constants.java
+++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/Constants.java
@@ -28,4 +28,6 @@ public class Constants {
public static final String EXISTING_PROCESS = "existing_process";
+ public static final int ZEPPELIN_INTERPRETER_DEFAUlT_PORT = 29914;
+
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e32ccf35/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/dev/DevInterpreter.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/dev/DevInterpreter.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/dev/DevInterpreter.java
deleted file mode 100644
index eb21d58..0000000
--- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/dev/DevInterpreter.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.zeppelin.interpreter.dev;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.zeppelin.interpreter.Interpreter;
-import org.apache.zeppelin.interpreter.InterpreterContext;
-import org.apache.zeppelin.interpreter.InterpreterContextRunner;
-import org.apache.zeppelin.interpreter.InterpreterException;
-import org.apache.zeppelin.interpreter.InterpreterPropertyBuilder;
-import org.apache.zeppelin.interpreter.InterpreterResult;
-import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
-
-/**
- * Dummy interpreter to support development mode for Zeppelin app
- */
-public class DevInterpreter extends Interpreter {
- static {
- Interpreter.register(
- "dev",
- "dev",
- DevInterpreter.class.getName(),
- new InterpreterPropertyBuilder().build());
- }
-
- private InterpreterEvent interpreterEvent;
- private InterpreterContext context;
-
- public static boolean isInterpreterName(String replName) {
- return replName.equals("dev");
- }
-
- /**
- * event handler for ZeppelinApplicationDevServer
- */
- public static interface InterpreterEvent {
- public InterpreterResult interpret(String st, InterpreterContext context);
- }
-
- public DevInterpreter(Properties property) {
- super(property);
- }
-
- public DevInterpreter(Properties property, InterpreterEvent interpreterEvent) {
- super(property);
- this.interpreterEvent = interpreterEvent;
- }
-
- @Override
- public void open() {
- }
-
- @Override
- public void close() {
- }
-
- public void rerun() {
- for (InterpreterContextRunner r : context.getRunners()) {
- if (context.getParagraphId().equals(r.getParagraphId())) {
- r.run();
- }
- }
- }
-
- @Override
- public InterpreterResult interpret(String st, InterpreterContext context) {
- this.context = context;
- try {
- return interpreterEvent.interpret(st, context);
- } catch (Exception e) {
- throw new InterpreterException(e);
- }
- }
-
- @Override
- public void cancel(InterpreterContext context) {
- }
-
- @Override
- public FormType getFormType() {
- return FormType.NATIVE;
- }
-
- @Override
- public int getProgress(InterpreterContext context) {
- return 0;
- }
-
- @Override
- public List<InterpreterCompletion> completion(String buf, int cursor) {
- return new LinkedList<>();
- }
-
- public InterpreterContext getLastInterpretContext() {
- return context;
- }
-
- public void setInterpreterEvent(InterpreterEvent event) {
- this.interpreterEvent = event;
- }
-
- public InterpreterEvent getInterpreterEvent() {
- return interpreterEvent;
- }
-}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e32ccf35/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/dev/ZeppelinApplicationDevServer.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/dev/ZeppelinApplicationDevServer.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/dev/ZeppelinApplicationDevServer.java
deleted file mode 100644
index 5e61389..0000000
--- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/dev/ZeppelinApplicationDevServer.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.zeppelin.interpreter.dev;
-
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-
-import com.google.gson.Gson;
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.Level;
-import org.apache.log4j.PatternLayout;
-import org.apache.zeppelin.helium.*;
-import org.apache.zeppelin.interpreter.*;
-import org.apache.zeppelin.interpreter.InterpreterResult.Code;
-import org.apache.zeppelin.interpreter.remote.RemoteInterpreterEventClient;
-import org.apache.zeppelin.resource.ResourceSet;
-import org.apache.zeppelin.resource.WellKnownResourceName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Run this server for development mode.
- */
-public class ZeppelinApplicationDevServer extends ZeppelinDevServer {
- final Logger logger = LoggerFactory.getLogger(ZeppelinApplicationDevServer.class);
-
- private final String className;
- private final ResourceSet resourceSet;
- private Application app;
- private InterpreterOutput out;
-
- public ZeppelinApplicationDevServer(final String className, ResourceSet resourceSet) throws
- Exception {
- this(ZeppelinDevServer.DEFAULT_TEST_INTERPRETER_PORT, className, resourceSet);
- }
-
- public ZeppelinApplicationDevServer(int port, String className, ResourceSet resourceSet) throws
- Exception {
- super(port);
- this.className = className;
- this.resourceSet = resourceSet;
- setLogger();
- };
-
- void setLogger() {
- ConsoleAppender console = new ConsoleAppender(); //create appender
- //configure the appender
- String PATTERN = "%d [%p|%c|%C{1}] %m%n";
- console.setLayout(new PatternLayout(PATTERN));
- console.setThreshold(Level.DEBUG);
- console.activateOptions();
- //add appender to any Logger (here is root)
- org.apache.log4j.Logger.getRootLogger().addAppender(console);
- }
-
-
- @Override
- public InterpreterResult interpret(String st, InterpreterContext context) {
- if (app == null) {
- logger.info("Create instance " + className);
- try {
- Class<?> appClass = ClassLoader.getSystemClassLoader().loadClass(className);
- Constructor<?> constructor = appClass.getConstructor(ApplicationContext.class);
-
- // classPath will be ..../target/classes in dev mode most cases
- String classPath = appClass.getProtectionDomain().getCodeSource().getLocation().getPath();
-
- context.out.addResourceSearchPath(classPath + "../../src/main/resources/");
- context.out.addResourceSearchPath(classPath + "../../src/test/resources/");
-
- ApplicationContext appContext = getApplicationContext(context);
- app = (Application) constructor.newInstance(appContext);
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- return new InterpreterResult(Code.ERROR, e.getMessage());
- }
- }
-
- try {
- logger.info("Run " + className);
- app.context().out.clear();
- app.context().out.setType(InterpreterResult.Type.ANGULAR);
- transferTableResultDataToFrontend();
- app.run(resourceSet);
- } catch (IOException | ApplicationException e) {
- logger.error(e.getMessage(), e);
- return new InterpreterResult(Code.ERROR, e.getMessage());
- }
- return new InterpreterResult(Code.SUCCESS, "");
- }
-
- private void transferTableResultDataToFrontend() throws IOException {
- ResourceSet results = resourceSet.filterByClassname(InterpreterResult.class.getName());
- if (results.size() == 0) {
- return;
- }
-
- InterpreterResultMessage result = (InterpreterResultMessage) results.get(0).get();
- Gson gson = new Gson();
- String resultJson = gson.toJson(result);
- StringBuffer transferResult = new StringBuffer();
- transferResult.append("$z.result = " + resultJson + ";\n");
-
- if (result.getType() == InterpreterResult.Type.TABLE) {
- transferResult.append("$z.scope.loadTableData($z.result);\n");
- }
-
- transferResult.append("$z.scope._devmodeResult = $z.result;\n");
- app.printStringAsJavascript(transferResult.toString());
- }
-
- ApplicationContext getApplicationContext(InterpreterContext interpreterContext) {
- return new ApplicationContext(
- interpreterContext.getNoteId(),
- interpreterContext.getParagraphId(),
- "app_" + this.hashCode(),
- new HeliumAppAngularObjectRegistry(
- interpreterContext.getAngularObjectRegistry(),
- interpreterContext.getNoteId(),
- interpreterContext.getParagraphId()),
- interpreterContext.out);
- }
-
- @Override
- protected InterpreterOutput createInterpreterOutput(
- final String noteId, final String paragraphId) {
- if (out == null) {
- final RemoteInterpreterEventClient eventClient = getEventClient();
- try {
- out = new InterpreterOutput(new InterpreterOutputListener() {
- @Override
- public void onUpdateAll(InterpreterOutput out) {
-
- }
-
- @Override
- public void onAppend(int index, InterpreterResultMessageOutput out, byte[] line) {
- eventClient.onInterpreterOutputAppend(noteId, paragraphId, index, new String(line));
- }
-
- @Override
- public void onUpdate(int index, InterpreterResultMessageOutput out) {
- try {
- eventClient.onInterpreterOutputUpdate(noteId, paragraphId,
- index, out.getType(), new String(out.toByteArray()));
- } catch (IOException e) {
- logger.error(e.getMessage(), e);
- }
- }
-
- }, this);
- } catch (IOException e) {
- return null;
- }
- }
-
- return out;
- }
-}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e32ccf35/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/dev/ZeppelinDevServer.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/dev/ZeppelinDevServer.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/dev/ZeppelinDevServer.java
deleted file mode 100644
index 4c2fd0c..0000000
--- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/dev/ZeppelinDevServer.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.zeppelin.interpreter.dev;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Properties;
-
-import org.apache.thrift.TException;
-import org.apache.zeppelin.interpreter.*;
-import org.apache.zeppelin.interpreter.dev.DevInterpreter.InterpreterEvent;
-import org.apache.zeppelin.interpreter.remote.RemoteInterpreterEventClient;
-import org.apache.zeppelin.interpreter.remote.RemoteInterpreterServer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Interpreter development server
- */
-public class ZeppelinDevServer extends
- RemoteInterpreterServer implements InterpreterEvent, InterpreterOutputChangeListener {
- final Logger logger = LoggerFactory.getLogger(ZeppelinDevServer.class);
- public static final int DEFAULT_TEST_INTERPRETER_PORT = 29914;
-
- DevInterpreter interpreter = null;
- InterpreterOutput out;
- public ZeppelinDevServer(int port) throws TException {
- super(port);
- }
-
- @Override
- protected Interpreter getInterpreter(String sessionKey, String className) throws TException {
- synchronized (this) {
- InterpreterGroup interpreterGroup = getInterpreterGroup();
- if (interpreterGroup == null) {
- createInterpreter(
- "dev",
- sessionKey,
- DevInterpreter.class.getName(),
- new HashMap<String, String>(),
- "anonymous");
-
- Interpreter intp = super.getInterpreter(sessionKey, className);
- interpreter = (DevInterpreter) (
- ((LazyOpenInterpreter) intp).getInnerInterpreter());
- interpreter.setInterpreterEvent(this);
- notify();
- }
- }
- return super.getInterpreter(sessionKey, className);
- }
-
- @Override
- protected InterpreterOutput createInterpreterOutput(
- final String noteId, final String paragraphId) {
- if (out == null) {
- final RemoteInterpreterEventClient eventClient = getEventClient();
- try {
- out = new InterpreterOutput(new InterpreterOutputListener() {
- @Override
- public void onUpdateAll(InterpreterOutput out) {
-
- }
-
- @Override
- public void onAppend(int index, InterpreterResultMessageOutput out, byte[] line) {
- eventClient.onInterpreterOutputAppend(noteId, paragraphId, index, new String(line));
- }
-
- @Override
- public void onUpdate(int index, InterpreterResultMessageOutput out) {
- try {
- eventClient.onInterpreterOutputUpdate(noteId, paragraphId,
- index, out.getType(), new String(out.toByteArray()));
- } catch (IOException e) {
- logger.error(e.getMessage(), e);
- }
- }
- }, this);
- } catch (IOException e) {
- return null;
- }
- }
-
- out.clear();
- return out;
- }
-
- @Override
- public void fileChanged(File file) {
- refresh();
- }
-
- @Override
- public InterpreterResult interpret(String st, InterpreterContext context) {
- waitForConnected();
- return new InterpreterResult(InterpreterResult.Code.SUCCESS, "");
- }
-
- public void refresh() {
- interpreter.rerun();
- }
-
- /**
- * Wait until %dev paragraph is executed and connected to this process
- */
- public void waitForConnected() {
- synchronized (this) {
- while (!isConnected()) {
- try {
- this.wait(10 * 1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- }
-
- public boolean isConnected() {
- return !(interpreter == null || interpreter.getLastInterpretContext() == null);
- }
-}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e32ccf35/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 6baed82..4bd3603 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
@@ -17,16 +17,12 @@
package org.apache.zeppelin.interpreter.remote;
-
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.nio.ByteBuffer;
-import java.rmi.server.RemoteServer;
import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeoutException;
import org.apache.thrift.TException;
import org.apache.thrift.server.TThreadPoolServer;
@@ -39,7 +35,6 @@ import org.apache.zeppelin.interpreter.*;
import org.apache.zeppelin.interpreter.InterpreterHookRegistry.HookType;
import org.apache.zeppelin.interpreter.InterpreterHookListener;
import org.apache.zeppelin.interpreter.InterpreterResult.Code;
-import org.apache.zeppelin.interpreter.dev.ZeppelinDevServer;
import org.apache.zeppelin.interpreter.thrift.*;
import org.apache.zeppelin.resource.*;
import org.apache.zeppelin.scheduler.Job;
@@ -144,7 +139,7 @@ public class RemoteInterpreterServer
public static void main(String[] args)
throws TTransportException, InterruptedException {
- int port = ZeppelinDevServer.DEFAULT_TEST_INTERPRETER_PORT;
+ int port = Constants.ZEPPELIN_INTERPRETER_DEFAUlT_PORT;
if (args.length > 0) {
port = Integer.parseInt(args[0]);
}
@@ -442,7 +437,7 @@ public class RemoteInterpreterServer
public void onPreExecute(String script) {
String cmdDev = interpreter.getHook(noteId, HookType.PRE_EXEC_DEV);
String cmdUser = interpreter.getHook(noteId, HookType.PRE_EXEC);
-
+
// User defined hook should be executed before dev hook
List<String> cmds = Arrays.asList(cmdDev, cmdUser);
for (String cmd : cmds) {
@@ -450,15 +445,15 @@ public class RemoteInterpreterServer
script = cmd + '\n' + script;
}
}
-
+
InterpretJob.this.script = script;
}
-
+
@Override
public void onPostExecute(String script) {
String cmdDev = interpreter.getHook(noteId, HookType.POST_EXEC_DEV);
String cmdUser = interpreter.getHook(noteId, HookType.POST_EXEC);
-
+
// User defined hook should be executed after dev hook
List<String> cmds = Arrays.asList(cmdUser, cmdDev);
for (String cmd : cmds) {
@@ -466,7 +461,7 @@ public class RemoteInterpreterServer
script += '\n' + cmd;
}
}
-
+
InterpretJob.this.script = script;
}
};
@@ -478,7 +473,7 @@ public class RemoteInterpreterServer
protected Object jobRun() throws Throwable {
try {
InterpreterContext.set(context);
-
+
// Open the interpreter instance prior to calling interpret().
// This is necessary because the earliest we can register a hook
// is from within the open() method.
@@ -486,7 +481,7 @@ public class RemoteInterpreterServer
if (!lazy.isOpen()) {
lazy.open();
}
-
+
// Add hooks to script from registry.
// Global scope first, followed by notebook scope
processInterpreterHooks(null);
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e32ccf35/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java
index 71eeeac..8a89170 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java
@@ -74,8 +74,6 @@ import org.apache.zeppelin.display.AngularObjectRegistry;
import org.apache.zeppelin.display.AngularObjectRegistryListener;
import org.apache.zeppelin.helium.ApplicationEventListener;
import org.apache.zeppelin.interpreter.Interpreter.RegisteredInterpreter;
-import org.apache.zeppelin.interpreter.dev.DevInterpreter;
-import org.apache.zeppelin.interpreter.dev.ZeppelinDevServer;
import org.apache.zeppelin.interpreter.remote.RemoteAngularObjectRegistry;
import org.apache.zeppelin.interpreter.remote.RemoteInterpreter;
import org.apache.zeppelin.interpreter.remote.RemoteInterpreterProcessListener;
@@ -1372,11 +1370,6 @@ public class InterpreterFactory implements InterpreterGroupFactory {
}
}
- // dev interpreter
- if (DevInterpreter.isInterpreterName(replName)) {
- return getDevInterpreter();
- }
-
return null;
}
@@ -1453,24 +1446,4 @@ public class InterpreterFactory implements InterpreterGroupFactory {
}
return editor;
}
-
- private Interpreter getDevInterpreter() {
- if (devInterpreter == null) {
- InterpreterOption option = new InterpreterOption();
- option.setRemote(true);
-
- InterpreterGroup interpreterGroup = createInterpreterGroup("dev", option);
-
- devInterpreter = connectToRemoteRepl("dev", DevInterpreter.class.getName(), "localhost",
- ZeppelinDevServer.DEFAULT_TEST_INTERPRETER_PORT, new Properties(), "dev", "anonymous",
- false);
-
- LinkedList<Interpreter> intpList = new LinkedList<>();
- intpList.add(devInterpreter);
- interpreterGroup.put("dev", intpList);
-
- devInterpreter.setInterpreterGroup(interpreterGroup);
- }
- return devInterpreter;
- }
}