diff --git a/flink/src/test/java/org/apache/zeppelin/flink/FlinkInterpreterTest.java b/flink/src/test/java/org/apache/zeppelin/flink/FlinkInterpreterTest.java index 5a915424b95..30c7be7d67a 100644 --- a/flink/src/test/java/org/apache/zeppelin/flink/FlinkInterpreterTest.java +++ b/flink/src/test/java/org/apache/zeppelin/flink/FlinkInterpreterTest.java @@ -40,7 +40,7 @@ public static void setUp() { Properties p = new Properties(); flink = new FlinkInterpreter(p); flink.open(); - context = new InterpreterContext(null, null, null, null, null, null, null, null, null, null); + context = new InterpreterContext(null, null, null, null, null, null, null, null, null, null, null); } @AfterClass diff --git a/hive/src/test/java/org/apache/zeppelin/hive/HiveInterpreterTest.java b/hive/src/test/java/org/apache/zeppelin/hive/HiveInterpreterTest.java index bc4ec31ab46..cbec104fba9 100644 --- a/hive/src/test/java/org/apache/zeppelin/hive/HiveInterpreterTest.java +++ b/hive/src/test/java/org/apache/zeppelin/hive/HiveInterpreterTest.java @@ -106,7 +106,7 @@ public void testForMapPrefix() throws SQLException, IOException { String sqlQuery = "(fake) select * from test_table"; - InterpreterResult interpreterResult = t.interpret(sqlQuery, new InterpreterContext("", "1", "","", null,null,null,null,null,null)); + InterpreterResult interpreterResult = t.interpret(sqlQuery, new InterpreterContext("", "1", "", "", null, null, null, null, null, null, null)); // if prefix not found return ERROR and Prefix not found. assertEquals(InterpreterResult.Code.ERROR, interpreterResult.code()); @@ -125,9 +125,9 @@ public void readTest() throws IOException { HiveInterpreter t = new HiveInterpreter(properties); t.open(); - assertTrue(t.interpret("show databases", new InterpreterContext("", "1", "","", null,null,null,null,null,null)).message().contains("SCHEMA_NAME")); + assertTrue(t.interpret("show databases", new InterpreterContext("", "1", "", "", null, null, null, null, null, null, null)).message().contains("SCHEMA_NAME")); assertEquals("ID\tNAME\na\ta_name\nb\tb_name\n", - t.interpret("select * from test_table", new InterpreterContext("", "1", "","", null,null,null,null,null,null)).message()); + t.interpret("select * from test_table", new InterpreterContext("", "1", "", "", null, null, null, null, null, null, null)).message()); } @Test @@ -147,7 +147,7 @@ public void readTestWithConfiguration() throws IOException { t.open(); assertEquals("ID\tNAME\na\ta_name\nb\tb_name\n", - t.interpret("(h2)\n select * from test_table", new InterpreterContext("", "1", "","", null,null,null,null,null,null)).message()); + t.interpret("(h2)\n select * from test_table", new InterpreterContext("", "1", "", "", null, null, null, null, null, null, null)).message()); } @Test @@ -163,13 +163,13 @@ public void jdbcRestart() throws IOException, SQLException, ClassNotFoundExcepti t.open(); InterpreterResult interpreterResult = - t.interpret("select * from test_table", new InterpreterContext("", "1", "","", null,null,null,null,null,null)); + t.interpret("select * from test_table", new InterpreterContext("", "1", "", "", null, null, null, null, null, null, null)); assertEquals("ID\tNAME\na\ta_name\nb\tb_name\n", interpreterResult.message()); t.getConnection("default").close(); interpreterResult = - t.interpret("select * from test_table", new InterpreterContext("", "1", "","", null,null,null,null,null,null)); + t.interpret("select * from test_table", new InterpreterContext("", "1", "", "", null, null, null, null, null, null, null)); assertEquals("ID\tNAME\na\ta_name\nb\tb_name\n", interpreterResult.message()); } @@ -185,7 +185,7 @@ public void test() throws IOException { HiveInterpreter t = new HiveInterpreter(properties); t.open(); - InterpreterContext interpreterContext = new InterpreterContext(null, "a", null, null, null, null, null, null, null, null); + InterpreterContext interpreterContext = new InterpreterContext(null, "a", null, null, null, null, null, null, null, null, null); //simple select test InterpreterResult result = t.interpret("select * from test_table", interpreterContext); diff --git a/ignite/src/test/java/org/apache/zeppelin/ignite/IgniteInterpreterTest.java b/ignite/src/test/java/org/apache/zeppelin/ignite/IgniteInterpreterTest.java index 5976e217b33..f1517631c0b 100644 --- a/ignite/src/test/java/org/apache/zeppelin/ignite/IgniteInterpreterTest.java +++ b/ignite/src/test/java/org/apache/zeppelin/ignite/IgniteInterpreterTest.java @@ -40,7 +40,7 @@ public class IgniteInterpreterTest { private static final String HOST = "127.0.0.1:47500..47509"; private static final InterpreterContext INTP_CONTEXT = - new InterpreterContext(null, null, null, null, null, null, null, null, null, null); + new InterpreterContext(null, null, null, null, null, null, null, null, null, null, null); private IgniteInterpreter intp; private Ignite ignite; diff --git a/ignite/src/test/java/org/apache/zeppelin/ignite/IgniteSqlInterpreterTest.java b/ignite/src/test/java/org/apache/zeppelin/ignite/IgniteSqlInterpreterTest.java index 7f665236130..9076c360dd6 100644 --- a/ignite/src/test/java/org/apache/zeppelin/ignite/IgniteSqlInterpreterTest.java +++ b/ignite/src/test/java/org/apache/zeppelin/ignite/IgniteSqlInterpreterTest.java @@ -44,7 +44,7 @@ public class IgniteSqlInterpreterTest { private static final String HOST = "127.0.0.1:47500..47509"; private static final InterpreterContext INTP_CONTEXT = - new InterpreterContext(null, null, null, null, null, null, null, null, null, null); + new InterpreterContext(null, null, null, null, null, null, null, null, null, null, null); private Ignite ignite; private IgniteSqlInterpreter intp; diff --git a/jdbc/src/test/java/org/apache/zeppelin/jdbc/JDBCInterpreterTest.java b/jdbc/src/test/java/org/apache/zeppelin/jdbc/JDBCInterpreterTest.java index 18e8b331f2e..593d968bbb4 100644 --- a/jdbc/src/test/java/org/apache/zeppelin/jdbc/JDBCInterpreterTest.java +++ b/jdbc/src/test/java/org/apache/zeppelin/jdbc/JDBCInterpreterTest.java @@ -107,7 +107,7 @@ public void testForMapPrefix() throws SQLException, IOException { String sqlQuery = "(fake) select * from test_table"; - InterpreterResult interpreterResult = t.interpret(sqlQuery, new InterpreterContext("", "1", "","", null,null,null,null,null,null)); + InterpreterResult interpreterResult = t.interpret(sqlQuery, new InterpreterContext("", "1", "", "", null, null, null, null, null, null, null)); // if prefix not found return ERROR and Prefix not found. assertEquals(InterpreterResult.Code.ERROR, interpreterResult.code()); @@ -139,7 +139,7 @@ public void testSelectQuery() throws SQLException, IOException { String sqlQuery = "select * from test_table WHERE ID in ('a', 'b')"; - InterpreterResult interpreterResult = t.interpret(sqlQuery, new InterpreterContext("", "1", "","", null,null,null,null,null,null)); + InterpreterResult interpreterResult = t.interpret(sqlQuery, new InterpreterContext("", "1", "", "", null, null, null, null, null, null, null)); assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code()); assertEquals(InterpreterResult.Type.TABLE, interpreterResult.type()); @@ -160,7 +160,7 @@ public void testSelectQueryWithNull() throws SQLException, IOException { String sqlQuery = "select * from test_table WHERE ID = 'c'"; - InterpreterResult interpreterResult = t.interpret(sqlQuery, new InterpreterContext("", "1", "","", null,null,null,null,null,null)); + InterpreterResult interpreterResult = t.interpret(sqlQuery, new InterpreterContext("", "1", "", "", null, null, null, null, null, null, null)); assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code()); assertEquals(InterpreterResult.Type.TABLE, interpreterResult.type()); @@ -183,7 +183,7 @@ public void testSelectQueryMaxResult() throws SQLException, IOException { String sqlQuery = "select * from test_table"; - InterpreterResult interpreterResult = t.interpret(sqlQuery, new InterpreterContext("", "1", "","", null,null,null,null,null,null)); + InterpreterResult interpreterResult = t.interpret(sqlQuery, new InterpreterContext("", "1", "", "", null, null, null, null, null, null, null)); assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code()); assertEquals(InterpreterResult.Type.TABLE, interpreterResult.type()); diff --git a/scalding/src/test/java/org/apache/zeppelin/scalding/ScaldingInterpreterTest.java b/scalding/src/test/java/org/apache/zeppelin/scalding/ScaldingInterpreterTest.java index 1a6f2b9ce5e..198fd62b444 100644 --- a/scalding/src/test/java/org/apache/zeppelin/scalding/ScaldingInterpreterTest.java +++ b/scalding/src/test/java/org/apache/zeppelin/scalding/ScaldingInterpreterTest.java @@ -26,6 +26,7 @@ import org.apache.zeppelin.display.AngularObjectRegistry; import org.apache.zeppelin.display.GUI; +import org.apache.zeppelin.user.AuthenticationInfo; import org.apache.zeppelin.interpreter.InterpreterContext; import org.apache.zeppelin.interpreter.InterpreterContextRunner; import org.apache.zeppelin.interpreter.InterpreterGroup; @@ -62,7 +63,7 @@ public void setUp() throws Exception { } InterpreterGroup intpGroup = new InterpreterGroup(); - context = new InterpreterContext("note", "id", "title", "text", + context = new InterpreterContext("note", "id", "title", "text", new AuthenticationInfo(), new HashMap(), new GUI(), new AngularObjectRegistry( intpGroup.getId(), null), null, new LinkedList(), null); diff --git a/spark/src/test/java/org/apache/zeppelin/spark/DepInterpreterTest.java b/spark/src/test/java/org/apache/zeppelin/spark/DepInterpreterTest.java index 11c0beb16c6..11b93284535 100644 --- a/spark/src/test/java/org/apache/zeppelin/spark/DepInterpreterTest.java +++ b/spark/src/test/java/org/apache/zeppelin/spark/DepInterpreterTest.java @@ -25,11 +25,9 @@ import java.util.Properties; import org.apache.zeppelin.display.AngularObjectRegistry; +import org.apache.zeppelin.user.AuthenticationInfo; import org.apache.zeppelin.display.GUI; -import org.apache.zeppelin.interpreter.InterpreterContext; -import org.apache.zeppelin.interpreter.InterpreterContextRunner; -import org.apache.zeppelin.interpreter.InterpreterGroup; -import org.apache.zeppelin.interpreter.InterpreterResult; +import org.apache.zeppelin.interpreter.*; import org.apache.zeppelin.interpreter.InterpreterResult.Code; import org.junit.After; import org.junit.Before; @@ -58,7 +56,8 @@ public void setUp() throws Exception { intpGroup.add(dep); dep.setInterpreterGroup(intpGroup); - context = new InterpreterContext("note", "id", "title", "text", new HashMap(), new GUI(), + context = new InterpreterContext("note", "id", "title", "text", new AuthenticationInfo(), + new HashMap(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), null, new LinkedList(), null); diff --git a/spark/src/test/java/org/apache/zeppelin/spark/SparkInterpreterTest.java b/spark/src/test/java/org/apache/zeppelin/spark/SparkInterpreterTest.java index ea08f175c0d..17e844d962a 100644 --- a/spark/src/test/java/org/apache/zeppelin/spark/SparkInterpreterTest.java +++ b/spark/src/test/java/org/apache/zeppelin/spark/SparkInterpreterTest.java @@ -27,6 +27,7 @@ import org.apache.spark.SparkConf; import org.apache.spark.SparkContext; import org.apache.zeppelin.display.AngularObjectRegistry; +import org.apache.zeppelin.user.AuthenticationInfo; import org.apache.zeppelin.display.GUI; import org.apache.zeppelin.interpreter.*; import org.apache.zeppelin.interpreter.InterpreterResult.Code; @@ -76,22 +77,23 @@ public void setUp() throws Exception { InterpreterGroup intpGroup = new InterpreterGroup(); context = new InterpreterContext("note", "id", "title", "text", - new HashMap(), - new GUI(), - new AngularObjectRegistry(intpGroup.getId(), null), - null, - new LinkedList(), - new InterpreterOutput(new InterpreterOutputListener() { - @Override - public void onAppend(InterpreterOutput out, byte[] line) { - - } - - @Override - public void onUpdate(InterpreterOutput out, byte[] output) { - - } - })); + new AuthenticationInfo(), + new HashMap(), + new GUI(), + new AngularObjectRegistry(intpGroup.getId(), null), + null, + new LinkedList(), + new InterpreterOutput(new InterpreterOutputListener() { + @Override + public void onAppend(InterpreterOutput out, byte[] line) { + + } + + @Override + public void onUpdate(InterpreterOutput out, byte[] output) { + + } + })); } @After diff --git a/spark/src/test/java/org/apache/zeppelin/spark/SparkSqlInterpreterTest.java b/spark/src/test/java/org/apache/zeppelin/spark/SparkSqlInterpreterTest.java index 30de6d6cf0c..a95461fa93b 100644 --- a/spark/src/test/java/org/apache/zeppelin/spark/SparkSqlInterpreterTest.java +++ b/spark/src/test/java/org/apache/zeppelin/spark/SparkSqlInterpreterTest.java @@ -24,10 +24,10 @@ import java.util.Properties; import org.apache.zeppelin.display.AngularObjectRegistry; +import org.apache.zeppelin.user.AuthenticationInfo; import org.apache.zeppelin.display.GUI; import org.apache.zeppelin.interpreter.*; import org.apache.zeppelin.interpreter.InterpreterResult.Type; -import org.apache.zeppelin.resource.LocalResourcePool; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -65,7 +65,8 @@ public void setUp() throws Exception { sql.setInterpreterGroup(intpGroup); sql.open(); } - context = new InterpreterContext("note", "id", "title", "text", new HashMap(), new GUI(), + context = new InterpreterContext("note", "id", "title", "text", new AuthenticationInfo(), + new HashMap(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), null, new LinkedList(), new InterpreterOutput(new InterpreterOutputListener() { diff --git a/zeppelin-display/src/test/scala/org/apache/zeppelin/display/angular/AbstractAngularElemTest.scala b/zeppelin-display/src/test/scala/org/apache/zeppelin/display/angular/AbstractAngularElemTest.scala index 0e870267574..9b5cd6269c8 100644 --- a/zeppelin-display/src/test/scala/org/apache/zeppelin/display/angular/AbstractAngularElemTest.scala +++ b/zeppelin-display/src/test/scala/org/apache/zeppelin/display/angular/AbstractAngularElemTest.scala @@ -21,6 +21,7 @@ import java.util import org.apache.zeppelin.display.{AngularObject, AngularObjectRegistry, GUI} import org.apache.zeppelin.interpreter._ +import org.apache.zeppelin.user.AuthenticationInfo import org.scalatest.concurrent.Eventually import org.scalatest.{BeforeAndAfter, BeforeAndAfterEach, FlatSpec, Matchers} @@ -33,8 +34,8 @@ trait AbstractAngularElemTest override def beforeEach() { val intpGroup = new InterpreterGroup() val context = new InterpreterContext("note", "paragraph", "title", "text", - new util.HashMap[String, Object](), new GUI(), new AngularObjectRegistry( - intpGroup.getId(), null), + new AuthenticationInfo(), new util.HashMap[String, Object](), new GUI(), + new AngularObjectRegistry(intpGroup.getId(), null), null, new util.LinkedList[InterpreterContextRunner](), new InterpreterOutput(new InterpreterOutputListener() { diff --git a/zeppelin-display/src/test/scala/org/apache/zeppelin/display/angular/AbstractAngularModelTest.scala b/zeppelin-display/src/test/scala/org/apache/zeppelin/display/angular/AbstractAngularModelTest.scala index 32a1932c9fa..33ca5086427 100644 --- a/zeppelin-display/src/test/scala/org/apache/zeppelin/display/angular/AbstractAngularModelTest.scala +++ b/zeppelin-display/src/test/scala/org/apache/zeppelin/display/angular/AbstractAngularModelTest.scala @@ -18,6 +18,7 @@ package org.apache.zeppelin.display.angular import org.apache.zeppelin.display.{AngularObjectRegistry, GUI} import org.apache.zeppelin.interpreter._ +import org.apache.zeppelin.user.AuthenticationInfo import org.scalatest.concurrent.Eventually import org.scalatest.{BeforeAndAfter, BeforeAndAfterEach, FlatSpec, Matchers} @@ -28,7 +29,7 @@ trait AbstractAngularModelTest extends FlatSpec with BeforeAndAfter with BeforeAndAfterEach with Eventually with Matchers { override def beforeEach() { val intpGroup = new InterpreterGroup() - val context = new InterpreterContext("note", "id", "title", "text", + val context = new InterpreterContext("note", "id", "title", "text", new AuthenticationInfo(), new java.util.HashMap[String, Object](), new GUI(), new AngularObjectRegistry( intpGroup.getId(), null), null, 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 fd76912f116..72c7deaeeed 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 @@ -21,6 +21,7 @@ import java.util.Map; import org.apache.zeppelin.display.AngularObjectRegistry; +import org.apache.zeppelin.user.AuthenticationInfo; import org.apache.zeppelin.display.GUI; import org.apache.zeppelin.resource.ResourcePool; @@ -48,6 +49,7 @@ public static void remove() { private final String paragraphTitle; private final String paragraphId; private final String paragraphText; + private AuthenticationInfo authenticationInfo; private final Map config; private GUI gui; private AngularObjectRegistry angularObjectRegistry; @@ -58,6 +60,7 @@ public InterpreterContext(String noteId, String paragraphId, String paragraphTitle, String paragraphText, + AuthenticationInfo authenticationInfo, Map config, GUI gui, AngularObjectRegistry angularObjectRegistry, @@ -69,6 +72,7 @@ public InterpreterContext(String noteId, this.paragraphId = paragraphId; this.paragraphTitle = paragraphTitle; this.paragraphText = paragraphText; + this.authenticationInfo = authenticationInfo; this.config = config; this.gui = gui; this.angularObjectRegistry = angularObjectRegistry; @@ -94,6 +98,10 @@ public String getParagraphTitle() { return paragraphTitle; } + public AuthenticationInfo getAuthenticationInfo() { + return authenticationInfo; + } + public Map getConfig() { return config; } diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java index 43c934f038e..b1eb458b12e 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java @@ -364,6 +364,7 @@ private RemoteInterpreterContext convert(InterpreterContext ic) { ic.getParagraphId(), ic.getParagraphTitle(), ic.getParagraphText(), + gson.toJson(ic.getAuthenticationInfo()), gson.toJson(ic.getConfig()), gson.toJson(ic.getGui()), gson.toJson(ic.getRunners())); 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 c3a0f9020e9..3174484e3d2 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 @@ -33,10 +33,7 @@ import org.apache.thrift.server.TThreadPoolServer; import org.apache.thrift.transport.TServerSocket; import org.apache.thrift.transport.TTransportException; -import org.apache.zeppelin.display.AngularObject; -import org.apache.zeppelin.display.AngularObjectRegistry; -import org.apache.zeppelin.display.AngularObjectRegistryListener; -import org.apache.zeppelin.display.GUI; +import org.apache.zeppelin.display.*; import org.apache.zeppelin.interpreter.*; import org.apache.zeppelin.interpreter.InterpreterResult.Code; import org.apache.zeppelin.interpreter.thrift.RemoteInterpreterContext; @@ -49,6 +46,7 @@ import org.apache.zeppelin.scheduler.JobListener; import org.apache.zeppelin.scheduler.JobProgressPoller; import org.apache.zeppelin.scheduler.Scheduler; +import org.apache.zeppelin.user.AuthenticationInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -392,6 +390,7 @@ private InterpreterContext convert(RemoteInterpreterContext ric) { ric.getParagraphId(), ric.getParagraphTitle(), ric.getParagraphText(), + gson.fromJson(ric.getAuthenticationInfo(), AuthenticationInfo.class), (Map) gson.fromJson(ric.getConfig(), new TypeToken>() {}.getType()), gson.fromJson(ric.getGui(), GUI.class), diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/thrift/RemoteInterpreterContext.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/thrift/RemoteInterpreterContext.java index b6a3da1e4f5..adcde0f82c2 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/thrift/RemoteInterpreterContext.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/thrift/RemoteInterpreterContext.java @@ -16,7 +16,7 @@ * limitations under the License. */ /** - * Autogenerated by Thrift Compiler (0.9.2) + * Autogenerated by Thrift Compiler (0.9.3) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -51,7 +51,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2016-1-24") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-02-16") public class RemoteInterpreterContext implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("RemoteInterpreterContext"); @@ -59,9 +59,10 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { @@ -73,6 +74,7 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase byName = new HashMap(); @@ -108,11 +111,13 @@ public static _Fields findByThriftId(int fieldId) { return PARAGRAPH_TITLE; case 4: // PARAGRAPH_TEXT return PARAGRAPH_TEXT; - case 5: // CONFIG + case 5: // AUTHENTICATION_INFO + return AUTHENTICATION_INFO; + case 6: // CONFIG return CONFIG; - case 6: // GUI + case 7: // GUI return GUI; - case 7: // RUNNERS + case 8: // RUNNERS return RUNNERS; default: return null; @@ -165,6 +170,8 @@ public String getFieldName() { new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.PARAGRAPH_TEXT, new org.apache.thrift.meta_data.FieldMetaData("paragraphText", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.AUTHENTICATION_INFO, new org.apache.thrift.meta_data.FieldMetaData("authenticationInfo", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.CONFIG, new org.apache.thrift.meta_data.FieldMetaData("config", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.GUI, new org.apache.thrift.meta_data.FieldMetaData("gui", org.apache.thrift.TFieldRequirementType.DEFAULT, @@ -183,6 +190,7 @@ public RemoteInterpreterContext( String paragraphId, String paragraphTitle, String paragraphText, + String authenticationInfo, String config, String gui, String runners) @@ -192,6 +200,7 @@ public RemoteInterpreterContext( this.paragraphId = paragraphId; this.paragraphTitle = paragraphTitle; this.paragraphText = paragraphText; + this.authenticationInfo = authenticationInfo; this.config = config; this.gui = gui; this.runners = runners; @@ -213,6 +222,9 @@ public RemoteInterpreterContext(RemoteInterpreterContext other) { if (other.isSetParagraphText()) { this.paragraphText = other.paragraphText; } + if (other.isSetAuthenticationInfo()) { + this.authenticationInfo = other.authenticationInfo; + } if (other.isSetConfig()) { this.config = other.config; } @@ -234,6 +246,7 @@ public void clear() { this.paragraphId = null; this.paragraphTitle = null; this.paragraphText = null; + this.authenticationInfo = null; this.config = null; this.gui = null; this.runners = null; @@ -335,6 +348,30 @@ public void setParagraphTextIsSet(boolean value) { } } + public String getAuthenticationInfo() { + return this.authenticationInfo; + } + + public RemoteInterpreterContext setAuthenticationInfo(String authenticationInfo) { + this.authenticationInfo = authenticationInfo; + return this; + } + + public void unsetAuthenticationInfo() { + this.authenticationInfo = null; + } + + /** Returns true if field authenticationInfo is set (has been assigned a value) and false otherwise */ + public boolean isSetAuthenticationInfo() { + return this.authenticationInfo != null; + } + + public void setAuthenticationInfoIsSet(boolean value) { + if (!value) { + this.authenticationInfo = null; + } + } + public String getConfig() { return this.config; } @@ -441,6 +478,14 @@ public void setFieldValue(_Fields field, Object value) { } break; + case AUTHENTICATION_INFO: + if (value == null) { + unsetAuthenticationInfo(); + } else { + setAuthenticationInfo((String)value); + } + break; + case CONFIG: if (value == null) { unsetConfig(); @@ -482,6 +527,9 @@ public Object getFieldValue(_Fields field) { case PARAGRAPH_TEXT: return getParagraphText(); + case AUTHENTICATION_INFO: + return getAuthenticationInfo(); + case CONFIG: return getConfig(); @@ -510,6 +558,8 @@ public boolean isSet(_Fields field) { return isSetParagraphTitle(); case PARAGRAPH_TEXT: return isSetParagraphText(); + case AUTHENTICATION_INFO: + return isSetAuthenticationInfo(); case CONFIG: return isSetConfig(); case GUI: @@ -569,6 +619,15 @@ public boolean equals(RemoteInterpreterContext that) { return false; } + boolean this_present_authenticationInfo = true && this.isSetAuthenticationInfo(); + boolean that_present_authenticationInfo = true && that.isSetAuthenticationInfo(); + if (this_present_authenticationInfo || that_present_authenticationInfo) { + if (!(this_present_authenticationInfo && that_present_authenticationInfo)) + return false; + if (!this.authenticationInfo.equals(that.authenticationInfo)) + return false; + } + boolean this_present_config = true && this.isSetConfig(); boolean that_present_config = true && that.isSetConfig(); if (this_present_config || that_present_config) { @@ -623,6 +682,11 @@ public int hashCode() { if (present_paragraphText) list.add(paragraphText); + boolean present_authenticationInfo = true && (isSetAuthenticationInfo()); + list.add(present_authenticationInfo); + if (present_authenticationInfo) + list.add(authenticationInfo); + boolean present_config = true && (isSetConfig()); list.add(present_config); if (present_config) @@ -689,6 +753,16 @@ public int compareTo(RemoteInterpreterContext other) { return lastComparison; } } + lastComparison = Boolean.valueOf(isSetAuthenticationInfo()).compareTo(other.isSetAuthenticationInfo()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetAuthenticationInfo()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.authenticationInfo, other.authenticationInfo); + if (lastComparison != 0) { + return lastComparison; + } + } lastComparison = Boolean.valueOf(isSetConfig()).compareTo(other.isSetConfig()); if (lastComparison != 0) { return lastComparison; @@ -771,6 +845,14 @@ public String toString() { } first = false; if (!first) sb.append(", "); + sb.append("authenticationInfo:"); + if (this.authenticationInfo == null) { + sb.append("null"); + } else { + sb.append(this.authenticationInfo); + } + first = false; + if (!first) sb.append(", "); sb.append("config:"); if (this.config == null) { sb.append("null"); @@ -869,7 +951,15 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, RemoteInterpreterCo org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case 5: // CONFIG + case 5: // AUTHENTICATION_INFO + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.authenticationInfo = iprot.readString(); + struct.setAuthenticationInfoIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 6: // CONFIG if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.config = iprot.readString(); struct.setConfigIsSet(true); @@ -877,7 +967,7 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, RemoteInterpreterCo org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case 6: // GUI + case 7: // GUI if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.gui = iprot.readString(); struct.setGuiIsSet(true); @@ -885,7 +975,7 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, RemoteInterpreterCo org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case 7: // RUNNERS + case 8: // RUNNERS if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.runners = iprot.readString(); struct.setRunnersIsSet(true); @@ -928,6 +1018,11 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, RemoteInterpreterC oprot.writeString(struct.paragraphText); oprot.writeFieldEnd(); } + if (struct.authenticationInfo != null) { + oprot.writeFieldBegin(AUTHENTICATION_INFO_FIELD_DESC); + oprot.writeString(struct.authenticationInfo); + oprot.writeFieldEnd(); + } if (struct.config != null) { oprot.writeFieldBegin(CONFIG_FIELD_DESC); oprot.writeString(struct.config); @@ -973,16 +1068,19 @@ public void write(org.apache.thrift.protocol.TProtocol prot, RemoteInterpreterCo if (struct.isSetParagraphText()) { optionals.set(3); } - if (struct.isSetConfig()) { + if (struct.isSetAuthenticationInfo()) { optionals.set(4); } - if (struct.isSetGui()) { + if (struct.isSetConfig()) { optionals.set(5); } - if (struct.isSetRunners()) { + if (struct.isSetGui()) { optionals.set(6); } - oprot.writeBitSet(optionals, 7); + if (struct.isSetRunners()) { + optionals.set(7); + } + oprot.writeBitSet(optionals, 8); if (struct.isSetNoteId()) { oprot.writeString(struct.noteId); } @@ -995,6 +1093,9 @@ public void write(org.apache.thrift.protocol.TProtocol prot, RemoteInterpreterCo if (struct.isSetParagraphText()) { oprot.writeString(struct.paragraphText); } + if (struct.isSetAuthenticationInfo()) { + oprot.writeString(struct.authenticationInfo); + } if (struct.isSetConfig()) { oprot.writeString(struct.config); } @@ -1009,7 +1110,7 @@ public void write(org.apache.thrift.protocol.TProtocol prot, RemoteInterpreterCo @Override public void read(org.apache.thrift.protocol.TProtocol prot, RemoteInterpreterContext struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(7); + BitSet incoming = iprot.readBitSet(8); if (incoming.get(0)) { struct.noteId = iprot.readString(); struct.setNoteIdIsSet(true); @@ -1027,14 +1128,18 @@ public void read(org.apache.thrift.protocol.TProtocol prot, RemoteInterpreterCon struct.setParagraphTextIsSet(true); } if (incoming.get(4)) { + struct.authenticationInfo = iprot.readString(); + struct.setAuthenticationInfoIsSet(true); + } + if (incoming.get(5)) { struct.config = iprot.readString(); struct.setConfigIsSet(true); } - if (incoming.get(5)) { + if (incoming.get(6)) { struct.gui = iprot.readString(); struct.setGuiIsSet(true); } - if (incoming.get(6)) { + if (incoming.get(7)) { struct.runners = iprot.readString(); struct.setRunnersIsSet(true); } diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/thrift/RemoteInterpreterEvent.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/thrift/RemoteInterpreterEvent.java index e560ec886d9..3df9946bd70 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/thrift/RemoteInterpreterEvent.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/thrift/RemoteInterpreterEvent.java @@ -16,7 +16,7 @@ * limitations under the License. */ /** - * Autogenerated by Thrift Compiler (0.9.2) + * Autogenerated by Thrift Compiler (0.9.3) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -51,7 +51,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2016-1-24") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-02-16") public class RemoteInterpreterEvent implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("RemoteInterpreterEvent"); diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/thrift/RemoteInterpreterEventType.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/thrift/RemoteInterpreterEventType.java index 7cb7963130f..664e5ad6cab 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/thrift/RemoteInterpreterEventType.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/thrift/RemoteInterpreterEventType.java @@ -16,7 +16,7 @@ * limitations under the License. */ /** - * Autogenerated by Thrift Compiler (0.9.2) + * Autogenerated by Thrift Compiler (0.9.3) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/thrift/RemoteInterpreterResult.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/thrift/RemoteInterpreterResult.java index 6539756a645..f6ac9b54f81 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/thrift/RemoteInterpreterResult.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/thrift/RemoteInterpreterResult.java @@ -16,7 +16,7 @@ * limitations under the License. */ /** - * Autogenerated by Thrift Compiler (0.9.2) + * Autogenerated by Thrift Compiler (0.9.3) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -51,7 +51,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2016-1-24") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-02-16") public class RemoteInterpreterResult implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("RemoteInterpreterResult"); diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/thrift/RemoteInterpreterService.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/thrift/RemoteInterpreterService.java index abf4316829d..722ec9d2baf 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/thrift/RemoteInterpreterService.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/thrift/RemoteInterpreterService.java @@ -16,7 +16,7 @@ * limitations under the License. */ /** - * Autogenerated by Thrift Compiler (0.9.2) + * Autogenerated by Thrift Compiler (0.9.3) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -51,7 +51,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2016-1-24") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-02-16") public class RemoteInterpreterService { public interface Iface { @@ -6900,7 +6900,7 @@ public void setFieldValue(_Fields field, Object value) { public Object getFieldValue(_Fields field) { switch (field) { case SUCCESS: - return Integer.valueOf(getSuccess()); + return getSuccess(); } throw new IllegalStateException(); @@ -8079,7 +8079,7 @@ public Object getFieldValue(_Fields field) { return getBuf(); case CURSOR: - return Integer.valueOf(getCursor()); + return getCursor(); } throw new IllegalStateException(); diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/user/AuthenticationInfo.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/user/AuthenticationInfo.java new file mode 100644 index 00000000000..5d54342c531 --- /dev/null +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/user/AuthenticationInfo.java @@ -0,0 +1,55 @@ +/* + * 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.user; + +/*** + * + */ +public class AuthenticationInfo { + String user; + String ticket; + + public AuthenticationInfo() {} + + /*** + * + * @param user + * @param ticket + */ + public AuthenticationInfo(String user, String ticket) { + this.user = user; + this.ticket = ticket; + } + + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + + public String getTicket() { + return ticket; + } + + public void setTicket(String ticket) { + this.ticket = ticket; + } +} diff --git a/zeppelin-interpreter/src/main/thrift/RemoteInterpreterService.thrift b/zeppelin-interpreter/src/main/thrift/RemoteInterpreterService.thrift index 3d6a62e3f47..d288324fbe8 100644 --- a/zeppelin-interpreter/src/main/thrift/RemoteInterpreterService.thrift +++ b/zeppelin-interpreter/src/main/thrift/RemoteInterpreterService.thrift @@ -24,9 +24,10 @@ struct RemoteInterpreterContext { 2: string paragraphId, 3: string paragraphTitle, 4: string paragraphText, - 5: string config, // json serialized config - 6: string gui, // json serialized gui - 7: string runners // json serialized runner + 5: string authenticationInfo, + 6: string config, // json serialized config + 7: string gui, // json serialized gui + 8: string runners // json serialized runner } struct RemoteInterpreterResult { diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterContextTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterContextTest.java index 40fd2edbfe6..764c8b3823b 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterContextTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterContextTest.java @@ -27,7 +27,7 @@ public class InterpreterContextTest { public void testThreadLocal() { assertNull(InterpreterContext.get()); - InterpreterContext.set(new InterpreterContext(null, null, null, null, null, null, null, null, null, null)); + InterpreterContext.set(new InterpreterContext(null, null, null, null, null, null, null, null, null, null, null)); assertNotNull(InterpreterContext.get()); InterpreterContext.remove(); diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteAngularObjectTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteAngularObjectTest.java index b6801e4fee2..bd8f43621f7 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteAngularObjectTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteAngularObjectTest.java @@ -25,17 +25,11 @@ import java.util.Properties; import java.util.concurrent.atomic.AtomicInteger; -import org.apache.zeppelin.display.AngularObject; -import org.apache.zeppelin.display.AngularObjectRegistry; -import org.apache.zeppelin.display.AngularObjectRegistryListener; -import org.apache.zeppelin.display.GUI; -import org.apache.zeppelin.interpreter.InterpreterContext; -import org.apache.zeppelin.interpreter.InterpreterContextRunner; -import org.apache.zeppelin.interpreter.InterpreterGroup; -import org.apache.zeppelin.interpreter.InterpreterResult; +import org.apache.zeppelin.display.*; +import org.apache.zeppelin.interpreter.*; import org.apache.zeppelin.interpreter.remote.mock.MockInterpreterAngular; import org.apache.zeppelin.resource.LocalResourcePool; -import org.apache.zeppelin.resource.ResourcePool; +import org.apache.zeppelin.user.AuthenticationInfo; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -84,6 +78,7 @@ public void setUp() throws Exception { "id", "title", "text", + new AuthenticationInfo(), new HashMap(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterOutputTestStream.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterOutputTestStream.java index 7ebe597b08e..c52055c87e2 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterOutputTestStream.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterOutputTestStream.java @@ -18,6 +18,7 @@ package org.apache.zeppelin.interpreter.remote; import org.apache.zeppelin.display.AngularObjectRegistry; +import org.apache.zeppelin.user.AuthenticationInfo; import org.apache.zeppelin.display.GUI; import org.apache.zeppelin.interpreter.*; import org.apache.zeppelin.interpreter.remote.mock.MockInterpreterOutputStream; @@ -75,6 +76,7 @@ private InterpreterContext createInterpreterContext() { "id", "title", "text", + new AuthenticationInfo(), new HashMap(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java index 4af9ba47620..333e4b4df99 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java @@ -29,11 +29,9 @@ import org.apache.thrift.transport.TTransportException; import org.apache.zeppelin.display.AngularObjectRegistry; +import org.apache.zeppelin.user.AuthenticationInfo; import org.apache.zeppelin.display.GUI; -import org.apache.zeppelin.interpreter.InterpreterContext; -import org.apache.zeppelin.interpreter.InterpreterContextRunner; -import org.apache.zeppelin.interpreter.InterpreterGroup; -import org.apache.zeppelin.interpreter.InterpreterResult; +import org.apache.zeppelin.interpreter.*; import org.apache.zeppelin.interpreter.InterpreterResult.Code; import org.apache.zeppelin.interpreter.remote.mock.MockInterpreterA; import org.apache.zeppelin.interpreter.remote.mock.MockInterpreterB; @@ -121,6 +119,7 @@ public void testRemoteInterperterCall() throws TTransportException, IOException "id", "title", "text", + new AuthenticationInfo(), new HashMap(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), @@ -155,6 +154,7 @@ public void testRemoteInterperterErrorStatus() throws TTransportException, IOExc "id", "title", "text", + new AuthenticationInfo(), new HashMap(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), @@ -204,6 +204,7 @@ public void testRemoteSchedulerSharing() throws TTransportException, IOException "id", "title", "text", + new AuthenticationInfo(), new HashMap(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), @@ -217,6 +218,7 @@ public void testRemoteSchedulerSharing() throws TTransportException, IOException "id", "title", "text", + new AuthenticationInfo(), new HashMap(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), @@ -269,6 +271,7 @@ protected Object jobRun() throws Throwable { "jobA", "title", "text", + new AuthenticationInfo(), new HashMap(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), @@ -304,6 +307,7 @@ protected Object jobRun() throws Throwable { "jobB", "title", "text", + new AuthenticationInfo(), new HashMap(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), @@ -370,6 +374,7 @@ protected Object jobRun() throws Throwable { jobId, "title", "text", + new AuthenticationInfo(), new HashMap(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), @@ -448,6 +453,7 @@ protected Object jobRun() throws Throwable { jobId, "title", "text", + new AuthenticationInfo(), new HashMap(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), @@ -547,6 +553,7 @@ protected Object jobRun() throws Throwable { "jobA", "title", "text", + new AuthenticationInfo(), new HashMap(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/resource/DistributedResourcePoolTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/resource/DistributedResourcePoolTest.java index bedaa021a66..138c1e4febb 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/resource/DistributedResourcePoolTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/resource/DistributedResourcePoolTest.java @@ -17,11 +17,9 @@ package org.apache.zeppelin.resource; import com.google.gson.Gson; +import org.apache.zeppelin.user.AuthenticationInfo; import org.apache.zeppelin.display.GUI; -import org.apache.zeppelin.interpreter.InterpreterContext; -import org.apache.zeppelin.interpreter.InterpreterContextRunner; -import org.apache.zeppelin.interpreter.InterpreterGroup; -import org.apache.zeppelin.interpreter.InterpreterResult; +import org.apache.zeppelin.interpreter.*; import org.apache.zeppelin.interpreter.remote.RemoteInterpreter; import org.apache.zeppelin.interpreter.remote.RemoteInterpreterEventPoller; import org.apache.zeppelin.interpreter.remote.mock.MockInterpreterResourcePool; @@ -93,6 +91,7 @@ public void setUp() throws Exception { "id", "title", "text", + new AuthenticationInfo(), new HashMap(), new GUI(), null, diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/RemoteSchedulerTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/RemoteSchedulerTest.java index 2bdcd4ffc12..5acfcc14892 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/RemoteSchedulerTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/RemoteSchedulerTest.java @@ -29,6 +29,7 @@ import java.util.Properties; import org.apache.zeppelin.display.AngularObjectRegistry; +import org.apache.zeppelin.user.AuthenticationInfo; import org.apache.zeppelin.display.GUI; import org.apache.zeppelin.interpreter.InterpreterContext; import org.apache.zeppelin.interpreter.InterpreterContextRunner; @@ -103,6 +104,7 @@ protected Object jobRun() throws Throwable { "jobId", "title", "text", + new AuthenticationInfo(), new HashMap(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), @@ -175,6 +177,7 @@ public void testAbortOnPending() throws Exception { "jobId1", "title", "text", + new AuthenticationInfo(), new HashMap(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), @@ -212,6 +215,7 @@ protected boolean jobAbort() { "jobId2", "title", "text", + new AuthenticationInfo(), new HashMap(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java b/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java index be177f5dc4c..00e48583644 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java @@ -16,20 +16,14 @@ */ package org.apache.zeppelin.socket; -import java.io.IOException; -import java.net.URISyntaxException; -import java.net.UnknownHostException; -import java.util.*; -import java.util.concurrent.ConcurrentLinkedQueue; - -import javax.servlet.http.HttpServletRequest; - +import com.google.common.base.Strings; +import com.google.gson.Gson; import org.apache.zeppelin.conf.ZeppelinConfiguration; import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars; import org.apache.zeppelin.display.AngularObject; import org.apache.zeppelin.display.AngularObjectRegistry; import org.apache.zeppelin.display.AngularObjectRegistryListener; -import org.apache.zeppelin.display.Input; +import org.apache.zeppelin.user.AuthenticationInfo; import org.apache.zeppelin.interpreter.InterpreterOutput; import org.apache.zeppelin.interpreter.InterpreterResult; import org.apache.zeppelin.interpreter.InterpreterSetting; @@ -37,7 +31,6 @@ import org.apache.zeppelin.notebook.*; import org.apache.zeppelin.scheduler.Job; import org.apache.zeppelin.scheduler.Job.Status; -import org.apache.zeppelin.scheduler.JobListener; import org.apache.zeppelin.server.ZeppelinServer; import org.apache.zeppelin.socket.Message.OP; import org.apache.zeppelin.ticket.TicketContainer; @@ -48,8 +41,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Strings; -import com.google.gson.Gson; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.UnknownHostException; +import java.util.*; +import java.util.concurrent.ConcurrentLinkedQueue; /** * Zeppelin websocket service. @@ -696,6 +693,15 @@ private void runParagraph(NotebookSocket conn, Notebook notebook, String text = (String) fromMessage.get("paragraph"); p.setText(text); p.setTitle((String) fromMessage.get("title")); + if (!fromMessage.principal.equals("anonymous")) { + AuthenticationInfo authenticationInfo = new AuthenticationInfo(fromMessage.principal, + fromMessage.ticket); + p.setAuthenticationInfo(authenticationInfo); + + } else { + p.setAuthenticationInfo(new AuthenticationInfo()); + } + Map params = (Map) fromMessage .get("params"); p.settings.setParams(params); diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ZeppelinIT.java b/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ZeppelinIT.java index f01a5de88c2..026535bdf00 100644 --- a/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ZeppelinIT.java +++ b/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ZeppelinIT.java @@ -17,6 +17,8 @@ package org.apache.zeppelin.integration; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.io.FileUtils; import org.apache.zeppelin.AbstractZeppelinIT; import org.apache.zeppelin.WebDriverManager; import org.junit.After; diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java index bf17c358040..2882557b161 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java @@ -18,6 +18,7 @@ package org.apache.zeppelin.notebook; import org.apache.zeppelin.display.AngularObjectRegistry; +import org.apache.zeppelin.user.AuthenticationInfo; import org.apache.zeppelin.display.GUI; import org.apache.zeppelin.display.Input; import org.apache.zeppelin.interpreter.*; @@ -45,6 +46,7 @@ public class Paragraph extends Job implements Serializable, Cloneable { String title; String text; + AuthenticationInfo authenticationInfo; Date dateUpdated; private Map config; // paragraph configs like isOpen, colWidth, etc public final GUI settings; // form and parameter settings @@ -55,6 +57,7 @@ public Paragraph(Note note, JobListener listener, NoteInterpreterLoader replLoad this.replLoader = replLoader; title = null; text = null; + authenticationInfo = null; dateUpdated = null; settings = new GUI(); config = new HashMap(); @@ -74,6 +77,13 @@ public void setText(String newText) { this.dateUpdated = new Date(); } + public AuthenticationInfo getAuthenticationInfo() { + return authenticationInfo; + } + + public void setAuthenticationInfo(AuthenticationInfo authenticationInfo) { + this.authenticationInfo = authenticationInfo; + } public String getTitle() { return title; @@ -276,6 +286,7 @@ private InterpreterContext getInterpreterContext() { getId(), this.getTitle(), this.getText(), + this.getAuthenticationInfo(), this.getConfig(), this.settings, registry, diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java index d9e965e82af..7020a47b576 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java @@ -62,7 +62,7 @@ public void setUp() throws Exception { conf = new ZeppelinConfiguration(); depResolver = new DependencyResolver(tmpDir.getAbsolutePath() + "/local-repo"); factory = new InterpreterFactory(conf, new InterpreterOption(false), null, null, depResolver); - context = new InterpreterContext("note", "id", "title", "text", null, null, null, null, null, null); + context = new InterpreterContext("note", "id", "title", "text", null, null, null, null, null, null, null); }