Repository: incubator-zeppelin Updated Branches: refs/heads/master 09bc8a36a -> 411b61210
[ZEPPELIN-809] Add annotation to public API ### What is this PR for? Implement ZeppelinApi Experimental annotations and apply them in the public api. Also mark deprecated global scope angular object methods ### What type of PR is it? Feature ### Todos * [x] - Implement ZeppelinApi, Experimental annotations * [x] - Apply annotation to public Api * [x] - Mark deprecated global scope angular object related methods ### What is the Jira issue? https://issues.apache.org/jira/browse/ZEPPELIN-809 ### Questions: * Does the licenses files need update? no * Is there breaking changes for older versions? no * Does this needs documentation? no Author: Lee moon soo <[email protected]> Closes #940 from Leemoonsoo/ZEPPELIN-809 and squashes the following commits: 0927f55 [Lee moon soo] Add @ZeppelinApi to restapi endpoint 96734a6 [Lee moon soo] Correction 6a1e4d8 [Lee moon soo] Remove unnecessary annotation 989dd86 [Lee moon soo] Add annotation impl 50cfed8 [Lee moon soo] Add @ZeppelinApi @Experimental annotation and apply. Mark @deprecated for global scope angular displaysystem method Project: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/commit/411b6121 Tree: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/tree/411b6121 Diff: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/diff/411b6121 Branch: refs/heads/master Commit: 411b61210d9f2999a0ed56bad8c3c03617f35a5e Parents: 09bc8a3 Author: Lee moon soo <[email protected]> Authored: Thu Jun 2 10:01:27 2016 -0700 Committer: Lee moon soo <[email protected]> Committed: Sat Jun 4 10:16:25 2016 -0700 ---------------------------------------------------------------------- .../apache/zeppelin/spark/ZeppelinContext.java | 42 +++++++++++++++++++- .../display/angular/AbstractAngularElem.scala | 16 ++++++++ .../display/angular/AbstractAngularModel.scala | 12 +++++- .../zeppelin/annotation/Experimental.java | 32 +++++++++++++++ .../apache/zeppelin/annotation/ZeppelinApi.java | 31 +++++++++++++++ .../zeppelin/interpreter/Interpreter.java | 15 +++++++ .../interpreter/InterpreterContext.java | 2 + .../zeppelin/rest/ConfigurationsRestApi.java | 3 ++ .../zeppelin/rest/InterpreterRestApi.java | 10 +++++ .../org/apache/zeppelin/rest/LoginRestApi.java | 3 ++ .../apache/zeppelin/rest/NotebookRestApi.java | 25 ++++++++++++ .../apache/zeppelin/rest/SecurityRestApi.java | 2 + .../apache/zeppelin/rest/ZeppelinRestApi.java | 2 + .../zeppelin/notebook/repo/NotebookRepo.java | 13 +++--- 14 files changed, 200 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/411b6121/spark/src/main/java/org/apache/zeppelin/spark/ZeppelinContext.java ---------------------------------------------------------------------- diff --git a/spark/src/main/java/org/apache/zeppelin/spark/ZeppelinContext.java b/spark/src/main/java/org/apache/zeppelin/spark/ZeppelinContext.java index b525e93..bd8f0a1 100644 --- a/spark/src/main/java/org/apache/zeppelin/spark/ZeppelinContext.java +++ b/spark/src/main/java/org/apache/zeppelin/spark/ZeppelinContext.java @@ -32,6 +32,7 @@ import org.apache.spark.SparkContext; import org.apache.spark.sql.SQLContext; import org.apache.spark.sql.catalyst.expressions.Attribute; import org.apache.spark.sql.hive.HiveContext; +import org.apache.zeppelin.annotation.ZeppelinApi; import org.apache.zeppelin.display.AngularObject; import org.apache.zeppelin.display.AngularObjectRegistry; import org.apache.zeppelin.display.AngularObjectWatcher; @@ -72,23 +73,28 @@ public class ZeppelinContext { public HiveContext hiveContext; private GUI gui; + @ZeppelinApi public Object input(String name) { return input(name, ""); } + @ZeppelinApi public Object input(String name, Object defaultValue) { return gui.input(name, defaultValue); } + @ZeppelinApi public Object select(String name, scala.collection.Iterable<Tuple2<Object, String>> options) { return select(name, "", options); } + @ZeppelinApi public Object select(String name, Object defaultValue, scala.collection.Iterable<Tuple2<Object, String>> options) { return gui.select(name, defaultValue, tuplesToParamOptions(options)); } + @ZeppelinApi public scala.collection.Iterable<Object> checkbox(String name, scala.collection.Iterable<Tuple2<Object, String>> options) { List<Object> allChecked = new LinkedList<Object>(); @@ -98,6 +104,7 @@ public class ZeppelinContext { return checkbox(name, collectionAsScalaIterable(allChecked), options); } + @ZeppelinApi public scala.collection.Iterable<Object> checkbox(String name, scala.collection.Iterable<Object> defaultChecked, scala.collection.Iterable<Tuple2<Object, String>> options) { @@ -143,6 +150,7 @@ public class ZeppelinContext { * show DataFrame or SchemaRDD * @param o DataFrame or SchemaRDD object */ + @ZeppelinApi public void show(Object o) { show(o, maxResult); } @@ -152,6 +160,8 @@ public class ZeppelinContext { * @param o DataFrame or SchemaRDD object * @param maxResult maximum number of rows to display */ + + @ZeppelinApi public void show(Object o, int maxResult) { Class cls = null; try { @@ -267,6 +277,7 @@ public class ZeppelinContext { * Run paragraph by id * @param id */ + @ZeppelinApi public void run(String id) { run(id, interpreterContext); } @@ -276,6 +287,7 @@ public class ZeppelinContext { * @param id * @param context */ + @ZeppelinApi public void run(String id, InterpreterContext context) { if (id.equals(context.getParagraphId())) { throw new InterpreterException("Can not run current Paragraph"); @@ -295,6 +307,7 @@ public class ZeppelinContext { * Run paragraph at idx * @param idx */ + @ZeppelinApi public void run(int idx) { run(idx, interpreterContext); } @@ -317,6 +330,7 @@ public class ZeppelinContext { runner.run(); } + @ZeppelinApi public void run(List<Object> paragraphIdOrIdx) { run(paragraphIdOrIdx, interpreterContext); } @@ -325,6 +339,7 @@ public class ZeppelinContext { * Run paragraphs * @param paragraphIdOrIdx list of paragraph id or idx */ + @ZeppelinApi public void run(List<Object> paragraphIdOrIdx, InterpreterContext context) { for (Object idOrIdx : paragraphIdOrIdx) { if (idOrIdx instanceof String) { @@ -339,6 +354,7 @@ public class ZeppelinContext { } } + @ZeppelinApi public void runAll() { runAll(interpreterContext); } @@ -346,6 +362,7 @@ public class ZeppelinContext { /** * Run all paragraphs. except this. */ + @ZeppelinApi public void runAll(InterpreterContext context) { for (InterpreterContextRunner r : context.getRunners()) { if (r.getParagraphId().equals(context.getParagraphId())) { @@ -356,6 +373,7 @@ public class ZeppelinContext { } } + @ZeppelinApi public List<String> listParagraphs() { List<String> paragraphs = new LinkedList<String>(); @@ -389,6 +407,7 @@ public class ZeppelinContext { * @param name variable name * @return value */ + @ZeppelinApi public Object angular(String name) { AngularObject ao = getAngularObject(name, interpreterContext); if (ao == null) { @@ -403,6 +422,7 @@ public class ZeppelinContext { * @param name variable name * @return value */ + @Deprecated public Object angularGlobal(String name) { AngularObjectRegistry registry = interpreterContext.getAngularObjectRegistry(); AngularObject ao = registry.get(name, null, null); @@ -419,6 +439,7 @@ public class ZeppelinContext { * @param name name of the variable * @param o value */ + @ZeppelinApi public void angularBind(String name, Object o) { angularBind(name, o, interpreterContext.getNoteId()); } @@ -429,6 +450,7 @@ public class ZeppelinContext { * @param name name of the variable * @param o value */ + @Deprecated public void angularBindGlobal(String name, Object o) { angularBind(name, o, (String) null); } @@ -440,6 +462,7 @@ public class ZeppelinContext { * @param o value * @param watcher watcher of the variable */ + @ZeppelinApi public void angularBind(String name, Object o, AngularObjectWatcher watcher) { angularBind(name, o, interpreterContext.getNoteId(), watcher); } @@ -451,6 +474,7 @@ public class ZeppelinContext { * @param o value * @param watcher watcher of the variable */ + @Deprecated public void angularBindGlobal(String name, Object o, AngularObjectWatcher watcher) { angularBind(name, o, null, watcher); } @@ -460,6 +484,7 @@ public class ZeppelinContext { * @param name name of the variable * @param watcher watcher */ + @ZeppelinApi public void angularWatch(String name, AngularObjectWatcher watcher) { angularWatch(name, interpreterContext.getNoteId(), watcher); } @@ -469,27 +494,31 @@ public class ZeppelinContext { * @param name name of the variable * @param watcher watcher */ + @Deprecated public void angularWatchGlobal(String name, AngularObjectWatcher watcher) { angularWatch(name, null, watcher); } - + @ZeppelinApi public void angularWatch(String name, final scala.Function2<Object, Object, Unit> func) { angularWatch(name, interpreterContext.getNoteId(), func); } + @Deprecated public void angularWatchGlobal(String name, final scala.Function2<Object, Object, Unit> func) { angularWatch(name, null, func); } + @ZeppelinApi public void angularWatch( String name, final scala.Function3<Object, Object, InterpreterContext, Unit> func) { angularWatch(name, interpreterContext.getNoteId(), func); } + @Deprecated public void angularWatchGlobal( String name, final scala.Function3<Object, Object, InterpreterContext, Unit> func) { @@ -501,6 +530,7 @@ public class ZeppelinContext { * @param name * @param watcher */ + @ZeppelinApi public void angularUnwatch(String name, AngularObjectWatcher watcher) { angularUnwatch(name, interpreterContext.getNoteId(), watcher); } @@ -510,6 +540,7 @@ public class ZeppelinContext { * @param name * @param watcher */ + @Deprecated public void angularUnwatchGlobal(String name, AngularObjectWatcher watcher) { angularUnwatch(name, null, watcher); } @@ -519,6 +550,7 @@ public class ZeppelinContext { * Remove all watchers for the angular variable (local) * @param name */ + @ZeppelinApi public void angularUnwatch(String name) { angularUnwatch(name, interpreterContext.getNoteId()); } @@ -527,6 +559,7 @@ public class ZeppelinContext { * Remove all watchers for the angular variable (global) * @param name */ + @Deprecated public void angularUnwatchGlobal(String name) { angularUnwatch(name, (String) null); } @@ -535,6 +568,7 @@ public class ZeppelinContext { * Remove angular variable and all the watchers. * @param name */ + @ZeppelinApi public void angularUnbind(String name) { String noteId = interpreterContext.getNoteId(); angularUnbind(name, noteId); @@ -544,6 +578,7 @@ public class ZeppelinContext { * Remove angular variable and all the watchers. * @param name */ + @Deprecated public void angularUnbindGlobal(String name) { angularUnbind(name, null); } @@ -661,6 +696,7 @@ public class ZeppelinContext { * @param name * @param value */ + @ZeppelinApi public void put(String name, Object value) { ResourcePool resourcePool = interpreterContext.getResourcePool(); resourcePool.put(name, value); @@ -672,6 +708,7 @@ public class ZeppelinContext { * @param name * @return null if resource not found */ + @ZeppelinApi public Object get(String name) { ResourcePool resourcePool = interpreterContext.getResourcePool(); Resource resource = resourcePool.get(name); @@ -686,6 +723,7 @@ public class ZeppelinContext { * Remove object from resourcePool * @param name */ + @ZeppelinApi public void remove(String name) { ResourcePool resourcePool = interpreterContext.getResourcePool(); resourcePool.remove(name); @@ -696,6 +734,7 @@ public class ZeppelinContext { * @param name * @return */ + @ZeppelinApi public boolean containsKey(String name) { ResourcePool resourcePool = interpreterContext.getResourcePool(); Resource resource = resourcePool.get(name); @@ -705,6 +744,7 @@ public class ZeppelinContext { /** * Get all resources */ + @ZeppelinApi public ResourceSet getAll() { ResourcePool resourcePool = interpreterContext.getResourcePool(); return resourcePool.getAll(); http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/411b6121/zeppelin-display/src/main/scala/org/apache/zeppelin/display/angular/AbstractAngularElem.scala ---------------------------------------------------------------------- diff --git a/zeppelin-display/src/main/scala/org/apache/zeppelin/display/angular/AbstractAngularElem.scala b/zeppelin-display/src/main/scala/org/apache/zeppelin/display/angular/AbstractAngularElem.scala index 80e3699..cb6a567 100644 --- a/zeppelin-display/src/main/scala/org/apache/zeppelin/display/angular/AbstractAngularElem.scala +++ b/zeppelin-display/src/main/scala/org/apache/zeppelin/display/angular/AbstractAngularElem.scala @@ -18,6 +18,7 @@ package org.apache.zeppelin.display.angular import java.io.PrintStream +import org.apache.zeppelin.annotation.ZeppelinApi import org.apache.zeppelin.display.{AngularObjectWatcher, AngularObject} import org.apache.zeppelin.interpreter.{InterpreterResult, InterpreterContext} @@ -41,28 +42,34 @@ abstract class AbstractAngularElem(val interpreterContext: InterpreterContext, /** * On click element + * * @param callback * @return */ + @ZeppelinApi def onClick(callback: () => Unit): AbstractAngularElem = { onEvent("ng-click", callback) } /** * On + * * @param callback * @return */ + @ZeppelinApi def onChange(callback: () => Unit): AbstractAngularElem = { onEvent("ng-change", callback) } /** * Bind angularObject to ng-model directive + * * @param name name of angularObject * @param value initialValue * @return */ + @ZeppelinApi def model(name: String, value: Any): AbstractAngularElem = { val registry = interpreterContext.getAngularObjectRegistry @@ -82,6 +89,7 @@ abstract class AbstractAngularElem(val interpreterContext: InterpreterContext, } + @ZeppelinApi def model(name: String): AbstractAngularElem = { val registry = interpreterContext.getAngularObjectRegistry @@ -99,8 +107,10 @@ abstract class AbstractAngularElem(val interpreterContext: InterpreterContext, /** * Retrieve value of model + * * @return */ + @ZeppelinApi def model(): Any = { if (angularObjects.contains(modelName)) { angularObjects(modelName).get() @@ -114,6 +124,7 @@ abstract class AbstractAngularElem(val interpreterContext: InterpreterContext, * @param eventName angular directive like ng-click, ng-change, etc. * @return */ + @ZeppelinApi def onEvent(eventName: String, callback: () => Unit): AbstractAngularElem = { val registry = interpreterContext.getAngularObjectRegistry @@ -151,12 +162,14 @@ abstract class AbstractAngularElem(val interpreterContext: InterpreterContext, * disassociate this element and it's child from front-end * by removing angularobject */ + @ZeppelinApi def disassociate() = { remove(this) } /** * Remove all angularObject recursively + * * @param node */ private def remove(node: Node): Unit = { @@ -172,8 +185,10 @@ abstract class AbstractAngularElem(val interpreterContext: InterpreterContext, /** * Print into provided print stream + * * @return */ + @ZeppelinApi def display(out: java.io.PrintStream): Unit = { out.print(this.toString) out.flush() @@ -182,6 +197,7 @@ abstract class AbstractAngularElem(val interpreterContext: InterpreterContext, /** * Print into InterpreterOutput */ + @ZeppelinApi def display(): Unit = { val out = interpreterContext.out out.setType(InterpreterResult.Type.ANGULAR) http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/411b6121/zeppelin-display/src/main/scala/org/apache/zeppelin/display/angular/AbstractAngularModel.scala ---------------------------------------------------------------------- diff --git a/zeppelin-display/src/main/scala/org/apache/zeppelin/display/angular/AbstractAngularModel.scala b/zeppelin-display/src/main/scala/org/apache/zeppelin/display/angular/AbstractAngularModel.scala index ff50438..de9b2b3 100644 --- a/zeppelin-display/src/main/scala/org/apache/zeppelin/display/angular/AbstractAngularModel.scala +++ b/zeppelin-display/src/main/scala/org/apache/zeppelin/display/angular/AbstractAngularModel.scala @@ -16,6 +16,7 @@ */ package org.apache.zeppelin.display.angular +import org.apache.zeppelin.annotation.ZeppelinApi import org.apache.zeppelin.display.AngularObject import org.apache.zeppelin.interpreter.InterpreterContext @@ -29,9 +30,11 @@ abstract class AbstractAngularModel(name: String) { /** * Create AngularModel with initial Value + * * @param name name of model * @param newValue value */ + @ZeppelinApi def this(name: String, newValue: Any) = { this(name) value(newValue) @@ -42,16 +45,20 @@ abstract class AbstractAngularModel(name: String) { /** * Get value of the model + * * @return */ + @ZeppelinApi def apply(): Any = { value() } /** * Get value of the model + * * @return */ + @ZeppelinApi def value(): Any = { val angularObject = getAngularObject() if (angularObject == null) { @@ -61,7 +68,7 @@ abstract class AbstractAngularModel(name: String) { } } - + @ZeppelinApi def apply(newValue: Any): Unit = { value(newValue) } @@ -69,8 +76,10 @@ abstract class AbstractAngularModel(name: String) { /** * Set value of the model + * * @param newValue */ + @ZeppelinApi def value(newValue: Any): Unit = { var angularObject = getAngularObject() if (angularObject == null) { @@ -82,6 +91,7 @@ abstract class AbstractAngularModel(name: String) { angularObject.get() } + @ZeppelinApi def remove(): Any = { val angularObject = getAngularObject() http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/411b6121/zeppelin-interpreter/src/main/java/org/apache/zeppelin/annotation/Experimental.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/annotation/Experimental.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/annotation/Experimental.java new file mode 100644 index 0000000..c21ea43 --- /dev/null +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/annotation/Experimental.java @@ -0,0 +1,32 @@ +/* + * 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.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Experimental API + * Might change or be removed at anytime, or be adopted as ZeppelinApi + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, + ElementType.CONSTRUCTOR, ElementType.LOCAL_VARIABLE, ElementType.PACKAGE}) +public @interface Experimental { +} http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/411b6121/zeppelin-interpreter/src/main/java/org/apache/zeppelin/annotation/ZeppelinApi.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/annotation/ZeppelinApi.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/annotation/ZeppelinApi.java new file mode 100644 index 0000000..e4a45ee --- /dev/null +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/annotation/ZeppelinApi.java @@ -0,0 +1,31 @@ +/* + * 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.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * APIs exposed to extends pluggable components or exposed to enduser + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, + ElementType.CONSTRUCTOR, ElementType.LOCAL_VARIABLE, ElementType.PACKAGE}) +public @interface ZeppelinApi { +} http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/411b6121/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 62155ee..1f91938 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 @@ -26,6 +26,7 @@ import java.util.Map; import java.util.Properties; import com.google.gson.annotations.SerializedName; +import org.apache.zeppelin.annotation.ZeppelinApi; import org.apache.zeppelin.scheduler.Scheduler; import org.apache.zeppelin.scheduler.SchedulerFactory; import org.slf4j.Logger; @@ -49,12 +50,14 @@ public abstract class Interpreter { * Opens interpreter. You may want to place your initialize routine here. * open() is called only once */ + @ZeppelinApi public abstract void open(); /** * Closes interpreter. You may want to free your resources up here. * close() is called only once */ + @ZeppelinApi public abstract void close(); /** @@ -64,6 +67,7 @@ public abstract class Interpreter { * @param context * @return */ + @ZeppelinApi public abstract InterpreterResult interpret(String st, InterpreterContext context); /** @@ -71,6 +75,7 @@ public abstract class Interpreter { * * @param context */ + @ZeppelinApi public abstract void cancel(InterpreterContext context); /** @@ -80,6 +85,7 @@ public abstract class Interpreter { * @return FormType.SIMPLE enables simple pattern replacement (eg. Hello ${name=world}), * FormType.NATIVE handles form in API */ + @ZeppelinApi public abstract FormType getFormType(); /** @@ -88,6 +94,7 @@ public abstract class Interpreter { * @param context * @return number between 0-100 */ + @ZeppelinApi public abstract int getProgress(InterpreterContext context); /** @@ -98,6 +105,7 @@ public abstract class Interpreter { * @param cursor cursor position in statements * @return list of possible completion. Return empty list if there're nothing to return. */ + @ZeppelinApi public abstract List<String> completion(String buf, int cursor); /** @@ -114,6 +122,7 @@ public abstract class Interpreter { * This method can be called multiple times and have to return the same instance. * Can not return null. */ + @ZeppelinApi public Scheduler getScheduler() { return SchedulerFactory.singleton().createOrGetFIFOScheduler("interpreter_" + this.hashCode()); } @@ -121,6 +130,7 @@ public abstract class Interpreter { /** * Called when interpreter is no longer used. */ + @ZeppelinApi public void destroy() { } @@ -129,6 +139,7 @@ public abstract class Interpreter { private URL [] classloaderUrls; protected Properties property; + @ZeppelinApi public Interpreter(Properties property) { logger.debug("Properties: {}", property); this.property = property; @@ -138,6 +149,7 @@ public abstract class Interpreter { this.property = property; } + @ZeppelinApi public Properties getProperty() { Properties p = new Properties(); p.putAll(property); @@ -159,6 +171,7 @@ public abstract class Interpreter { return p; } + @ZeppelinApi public String getProperty(String key) { logger.debug("key: {}, value: {}", key, getProperty().getProperty(key)); @@ -174,6 +187,7 @@ public abstract class Interpreter { this.interpreterGroup = interpreterGroup; } + @ZeppelinApi public InterpreterGroup getInterpreterGroup() { return this.interpreterGroup; } @@ -186,6 +200,7 @@ public abstract class Interpreter { this.classloaderUrls = classloaderUrls; } + @ZeppelinApi public Interpreter getInterpreterInTheSameSessionByClassName(String className) { synchronized (interpreterGroup) { for (List<Interpreter> interpreters : interpreterGroup.values()) { http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/411b6121/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterContext.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterContext.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterContext.java index 72c7dea..21ca2e6 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterContext.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterContext.java @@ -20,6 +20,7 @@ package org.apache.zeppelin.interpreter; import java.util.List; import java.util.Map; +import org.apache.zeppelin.annotation.ZeppelinApi; import org.apache.zeppelin.display.AngularObjectRegistry; import org.apache.zeppelin.user.AuthenticationInfo; import org.apache.zeppelin.display.GUI; @@ -31,6 +32,7 @@ import org.apache.zeppelin.resource.ResourcePool; public class InterpreterContext { private static final ThreadLocal<InterpreterContext> threadIC = new ThreadLocal<InterpreterContext>(); + public final InterpreterOutput out; public static InterpreterContext get() { http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/411b6121/zeppelin-server/src/main/java/org/apache/zeppelin/rest/ConfigurationsRestApi.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/ConfigurationsRestApi.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/ConfigurationsRestApi.java index 43ecd70..68cffed 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/ConfigurationsRestApi.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/ConfigurationsRestApi.java @@ -17,6 +17,7 @@ package org.apache.zeppelin.rest; +import org.apache.zeppelin.annotation.ZeppelinApi; import org.apache.zeppelin.conf.ZeppelinConfiguration; import org.apache.zeppelin.notebook.Notebook; import org.apache.zeppelin.server.JsonResponse; @@ -46,6 +47,7 @@ public class ConfigurationsRestApi { @GET @Path("all") + @ZeppelinApi public Response getAll() { ZeppelinConfiguration conf = notebook.getConf(); @@ -67,6 +69,7 @@ public class ConfigurationsRestApi { @GET @Path("prefix/{prefix}") + @ZeppelinApi public Response getByPrefix(@PathParam("prefix") final String prefix) { ZeppelinConfiguration conf = notebook.getConf(); http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/411b6121/zeppelin-server/src/main/java/org/apache/zeppelin/rest/InterpreterRestApi.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/InterpreterRestApi.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/InterpreterRestApi.java index 6430973..9af0a60 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/InterpreterRestApi.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/InterpreterRestApi.java @@ -33,6 +33,7 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import org.apache.commons.lang.exception.ExceptionUtils; +import org.apache.zeppelin.annotation.ZeppelinApi; import org.apache.zeppelin.dep.Repository; import org.apache.zeppelin.interpreter.*; import org.apache.zeppelin.interpreter.Interpreter.RegisteredInterpreter; @@ -73,6 +74,7 @@ public class InterpreterRestApi { */ @GET @Path("setting") + @ZeppelinApi public Response listSettings() { List<InterpreterSetting> interpreterSettings = null; interpreterSettings = interpreterFactory.get(); @@ -88,6 +90,7 @@ public class InterpreterRestApi { */ @POST @Path("setting") + @ZeppelinApi public Response newSettings(String message) { try { NewInterpreterSettingRequest request = gson.fromJson(message, @@ -118,6 +121,7 @@ public class InterpreterRestApi { @PUT @Path("setting/{settingId}") + @ZeppelinApi public Response updateSetting(String message, @PathParam("settingId") String settingId) { logger.info("Update interpreterSetting {}", settingId); @@ -149,6 +153,7 @@ public class InterpreterRestApi { */ @DELETE @Path("setting/{settingId}") + @ZeppelinApi public Response removeSetting(@PathParam("settingId") String settingId) throws IOException { logger.info("Remove interpreterSetting {}", settingId); interpreterFactory.remove(settingId); @@ -160,6 +165,7 @@ public class InterpreterRestApi { */ @PUT @Path("setting/restart/{settingId}") + @ZeppelinApi public Response restartSetting(@PathParam("settingId") String settingId) { logger.info("Restart interpreterSetting {}", settingId); try { @@ -180,6 +186,7 @@ public class InterpreterRestApi { * List all available interpreters by group */ @GET + @ZeppelinApi public Response listInterpreter(String message) { Map<String, RegisteredInterpreter> m = Interpreter.registeredInterpreters; return new JsonResponse(Status.OK, "", m).build(); @@ -191,6 +198,7 @@ public class InterpreterRestApi { */ @GET @Path("repository") + @ZeppelinApi public Response listRepositories() { List<RemoteRepository> interpreterRepositories = null; interpreterRepositories = interpreterFactory.getRepositories(); @@ -204,6 +212,7 @@ public class InterpreterRestApi { */ @POST @Path("repository") + @ZeppelinApi public Response addRepository(String message) { try { Repository request = gson.fromJson(message, Repository.class); @@ -228,6 +237,7 @@ public class InterpreterRestApi { */ @DELETE @Path("repository/{repoId}") + @ZeppelinApi public Response removeRepository(@PathParam("repoId") String repoId) { logger.info("Remove repository {}", repoId); try { http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/411b6121/zeppelin-server/src/main/java/org/apache/zeppelin/rest/LoginRestApi.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/LoginRestApi.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/LoginRestApi.java index 0069d47..0b9c9a6 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/LoginRestApi.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/LoginRestApi.java @@ -19,6 +19,7 @@ package org.apache.zeppelin.rest; import org.apache.shiro.authc.*; import org.apache.shiro.session.Session; import org.apache.shiro.subject.Subject; +import org.apache.zeppelin.annotation.ZeppelinApi; import org.apache.zeppelin.server.JsonResponse; import org.apache.zeppelin.ticket.TicketContainer; import org.apache.zeppelin.utils.SecurityUtils; @@ -60,6 +61,7 @@ public class LoginRestApi { * @return 200 response */ @POST + @ZeppelinApi public Response postLogin(@FormParam("userName") String userName, @FormParam("password") String password) { JsonResponse response = null; @@ -113,6 +115,7 @@ public class LoginRestApi { @POST @Path("logout") + @ZeppelinApi public Response logout() { JsonResponse response; http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/411b6121/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java index 89e84ee..6c50ee4 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java @@ -32,6 +32,7 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import org.apache.commons.lang3.StringUtils; +import org.apache.zeppelin.annotation.ZeppelinApi; import org.apache.zeppelin.interpreter.InterpreterSetting; import org.apache.zeppelin.notebook.Note; import org.apache.zeppelin.notebook.Notebook; @@ -83,6 +84,7 @@ public class NotebookRestApi { */ @GET @Path("{noteId}/permissions") + @ZeppelinApi public Response getNotePermissions(@PathParam("noteId") String noteId) { Note note = notebook.getNote(noteId); HashMap<String, Set<String>> permissionsMap = new HashMap(); @@ -106,6 +108,7 @@ public class NotebookRestApi { */ @PUT @Path("{noteId}/permissions") + @ZeppelinApi public Response putNotePermissions(@PathParam("noteId") String noteId, String req) throws IOException { HashMap<String, HashSet> permMap = gson.fromJson(req, @@ -166,6 +169,7 @@ public class NotebookRestApi { */ @PUT @Path("interpreter/bind/{noteId}") + @ZeppelinApi public Response bind(@PathParam("noteId") String noteId, String req) throws IOException { List<String> settingIdList = gson.fromJson(req, new TypeToken<List<String>>(){}.getType()); notebook.bindInterpretersToNote(noteId, settingIdList); @@ -177,6 +181,7 @@ public class NotebookRestApi { */ @GET @Path("interpreter/bind/{noteId}") + @ZeppelinApi public Response bind(@PathParam("noteId") String noteId) { List<InterpreterSettingListForNoteBind> settingList = new LinkedList<InterpreterSettingListForNoteBind>(); @@ -217,6 +222,7 @@ public class NotebookRestApi { @GET @Path("/") + @ZeppelinApi public Response getNotebookList() throws IOException { List<Map<String, String>> notesInfo = notebookServer.generateNotebooksInfo(false); return new JsonResponse<>(Status.OK, "", notesInfo ).build(); @@ -224,6 +230,7 @@ public class NotebookRestApi { @GET @Path("{notebookId}") + @ZeppelinApi public Response getNotebook(@PathParam("notebookId") String notebookId) throws IOException { Note note = notebook.getNote(notebookId); if (note == null) { @@ -242,6 +249,7 @@ public class NotebookRestApi { */ @GET @Path("export/{id}") + @ZeppelinApi public Response exportNoteBook(@PathParam("id") String noteId) throws IOException { String exportJson = notebook.exportNote(noteId); return new JsonResponse(Status.OK, "", exportJson).build(); @@ -256,6 +264,7 @@ public class NotebookRestApi { */ @POST @Path("import") + @ZeppelinApi public Response importNotebook(String req) throws IOException { Note newNote = notebook.importNote(req, null); return new JsonResponse<>(Status.CREATED, "", newNote.getId()).build(); @@ -269,6 +278,7 @@ public class NotebookRestApi { */ @POST @Path("/") + @ZeppelinApi public Response createNote(String message) throws IOException { LOG.info("Create new notebook by JSON {}" , message); NewNotebookRequest request = gson.fromJson(message, @@ -302,6 +312,7 @@ public class NotebookRestApi { */ @DELETE @Path("{notebookId}") + @ZeppelinApi public Response deleteNote(@PathParam("notebookId") String notebookId) throws IOException { LOG.info("Delete notebook {} ", notebookId); if (!(notebookId.isEmpty())) { @@ -322,6 +333,7 @@ public class NotebookRestApi { */ @POST @Path("{notebookId}") + @ZeppelinApi public Response cloneNote(@PathParam("notebookId") String notebookId, String message) throws IOException, CloneNotSupportedException, IllegalArgumentException { LOG.info("clone notebook by JSON {}" , message); @@ -342,6 +354,7 @@ public class NotebookRestApi { */ @POST @Path("{notebookId}/paragraph") + @ZeppelinApi public Response insertParagraph(@PathParam("notebookId") String notebookId, String message) throws IOException { LOG.info("insert paragraph {} {}", notebookId, message); @@ -376,6 +389,7 @@ public class NotebookRestApi { */ @GET @Path("{notebookId}/paragraph/{paragraphId}") + @ZeppelinApi public Response getParagraph(@PathParam("notebookId") String notebookId, @PathParam("paragraphId") String paragraphId) throws IOException { LOG.info("get paragraph {} {}", notebookId, paragraphId); @@ -401,6 +415,7 @@ public class NotebookRestApi { */ @POST @Path("{notebookId}/paragraph/{paragraphId}/move/{newIndex}") + @ZeppelinApi public Response moveParagraph(@PathParam("notebookId") String notebookId, @PathParam("paragraphId") String paragraphId, @PathParam("newIndex") String newIndex) throws IOException { @@ -436,6 +451,7 @@ public class NotebookRestApi { */ @DELETE @Path("{notebookId}/paragraph/{paragraphId}") + @ZeppelinApi public Response deleteParagraph(@PathParam("notebookId") String notebookId, @PathParam("paragraphId") String paragraphId) throws IOException { LOG.info("delete paragraph {} {}", notebookId, paragraphId); @@ -465,6 +481,7 @@ public class NotebookRestApi { */ @POST @Path("job/{notebookId}") + @ZeppelinApi public Response runNoteJobs(@PathParam("notebookId") String notebookId) throws IOException, IllegalArgumentException { LOG.info("run notebook jobs {} ", notebookId); @@ -485,6 +502,7 @@ public class NotebookRestApi { */ @DELETE @Path("job/{notebookId}") + @ZeppelinApi public Response stopNoteJobs(@PathParam("notebookId") String notebookId) throws IOException, IllegalArgumentException { LOG.info("stop notebook jobs {} ", notebookId); @@ -509,6 +527,7 @@ public class NotebookRestApi { */ @GET @Path("job/{notebookId}") + @ZeppelinApi public Response getNoteJobStatus(@PathParam("notebookId") String notebookId) throws IOException, IllegalArgumentException { LOG.info("get notebook job status."); @@ -531,6 +550,7 @@ public class NotebookRestApi { */ @POST @Path("job/{notebookId}/{paragraphId}") + @ZeppelinApi public Response runParagraph(@PathParam("notebookId") String notebookId, @PathParam("paragraphId") String paragraphId, String message) throws @@ -570,6 +590,7 @@ public class NotebookRestApi { */ @DELETE @Path("job/{notebookId}/{paragraphId}") + @ZeppelinApi public Response stopParagraph(@PathParam("notebookId") String notebookId, @PathParam("paragraphId") String paragraphId) throws IOException, IllegalArgumentException { @@ -595,6 +616,7 @@ public class NotebookRestApi { */ @POST @Path("cron/{notebookId}") + @ZeppelinApi public Response registerCronJob(@PathParam("notebookId") String notebookId, String message) throws IOException, IllegalArgumentException { LOG.info("Register cron job note={} request cron msg={}", notebookId, message); @@ -627,6 +649,7 @@ public class NotebookRestApi { */ @DELETE @Path("cron/{notebookId}") + @ZeppelinApi public Response removeCronJob(@PathParam("notebookId") String notebookId) throws IOException, IllegalArgumentException { LOG.info("Remove cron job note {}", notebookId); @@ -652,6 +675,7 @@ public class NotebookRestApi { */ @GET @Path("cron/{notebookId}") + @ZeppelinApi public Response getCronJob(@PathParam("notebookId") String notebookId) throws IOException, IllegalArgumentException { LOG.info("Get cron job note {}", notebookId); @@ -669,6 +693,7 @@ public class NotebookRestApi { */ @GET @Path("search") + @ZeppelinApi public Response search(@QueryParam("q") String queryTerm) { LOG.info("Searching notebooks for: {}", queryTerm); String principal = SecurityUtils.getPrincipal(); http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/411b6121/zeppelin-server/src/main/java/org/apache/zeppelin/rest/SecurityRestApi.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/SecurityRestApi.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/SecurityRestApi.java index 905eb2b..342cb00 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/SecurityRestApi.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/SecurityRestApi.java @@ -17,6 +17,7 @@ package org.apache.zeppelin.rest; +import org.apache.zeppelin.annotation.ZeppelinApi; import org.apache.zeppelin.conf.ZeppelinConfiguration; import org.apache.zeppelin.server.JsonResponse; import org.apache.zeppelin.ticket.TicketContainer; @@ -58,6 +59,7 @@ public class SecurityRestApi { */ @GET @Path("ticket") + @ZeppelinApi public Response ticket() { ZeppelinConfiguration conf = ZeppelinConfiguration.create(); String principal = SecurityUtils.getPrincipal(); http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/411b6121/zeppelin-server/src/main/java/org/apache/zeppelin/rest/ZeppelinRestApi.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/ZeppelinRestApi.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/ZeppelinRestApi.java index ca42e34..9d9f551 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/ZeppelinRestApi.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/ZeppelinRestApi.java @@ -17,6 +17,7 @@ package org.apache.zeppelin.rest; +import org.apache.zeppelin.annotation.ZeppelinApi; import org.apache.zeppelin.server.JsonResponse; import org.apache.zeppelin.util.Util; @@ -47,6 +48,7 @@ public class ZeppelinRestApi { @GET @Path("version") + @ZeppelinApi public Response getVersion() { return new JsonResponse<>(Response.Status.OK, "Zeppelin version", Util.getVersion()).build(); } http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/411b6121/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepo.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepo.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepo.java index d135032..7608892 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepo.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepo.java @@ -20,6 +20,7 @@ package org.apache.zeppelin.notebook.repo; import java.io.IOException; import java.util.List; +import org.apache.zeppelin.annotation.ZeppelinApi; import org.apache.zeppelin.notebook.Note; import org.apache.zeppelin.notebook.NoteInfo; @@ -27,18 +28,18 @@ import org.apache.zeppelin.notebook.NoteInfo; * Notebook repository (persistence layer) abstraction */ public interface NotebookRepo { - public List<NoteInfo> list() throws IOException; - public Note get(String noteId) throws IOException; - public void save(Note note) throws IOException; - public void remove(String noteId) throws IOException; + @ZeppelinApi public List<NoteInfo> list() throws IOException; + @ZeppelinApi public Note get(String noteId) throws IOException; + @ZeppelinApi public void save(Note note) throws IOException; + @ZeppelinApi public void remove(String noteId) throws IOException; /** * Release any underlying resources */ - public void close(); + @ZeppelinApi public void close(); /** * chekpoint (versioning) for notebooks (optional) */ - public void checkpoint(String noteId, String checkPointName) throws IOException; + @ZeppelinApi public void checkpoint(String noteId, String checkPointName) throws IOException; }
