mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Merge branch 'master' into notebook_interpreter_session
This commit is contained in:
commit
7b073f6047
62 changed files with 1402 additions and 183 deletions
2
NOTICE
2
NOTICE
|
|
@ -1,5 +1,5 @@
|
|||
Apache Zeppelin (incubating)
|
||||
Copyright 2015 The Apache Software Foundation
|
||||
Copyright 2015 - 2016 The Apache Software Foundation
|
||||
|
||||
This product includes software developed at
|
||||
The Apache Software Foundation (http://www.apache.org/).
|
||||
|
|
|
|||
|
|
@ -36,10 +36,6 @@ if [[ -z "${ZEPPELIN_LOG_DIR}" ]]; then
|
|||
export ZEPPELIN_LOG_DIR="${ZEPPELIN_HOME}/logs"
|
||||
fi
|
||||
|
||||
if [[ -z "${ZEPPELIN_NOTEBOOK_DIR}" ]]; then
|
||||
export ZEPPELIN_NOTEBOOK_DIR="${ZEPPELIN_HOME}/notebook"
|
||||
fi
|
||||
|
||||
if [[ -z "$ZEPPELIN_PID_DIR" ]]; then
|
||||
export ZEPPELIN_PID_DIR="${ZEPPELIN_HOME}/run"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2007 The Apache Software Foundation
|
||||
#
|
||||
# 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
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2007 The Apache Software Foundation
|
||||
#
|
||||
# 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
|
||||
|
|
@ -21,7 +19,7 @@
|
|||
# description: Start and stop daemon script for.
|
||||
#
|
||||
|
||||
USAGE="Usage: zeppelin-daemon.sh [--config <conf-dir>] {start|stop|restart|reload|status}"
|
||||
USAGE="Usage: zeppelin-daemon.sh [--config <conf-dir>] {start|stop|upstart|restart|reload|status}"
|
||||
|
||||
if [[ "$1" == "--config" ]]; then
|
||||
shift
|
||||
|
|
@ -93,11 +91,6 @@ function initialize_default_directories() {
|
|||
echo "Pid dir doesn't exist, create ${ZEPPELIN_PID_DIR}"
|
||||
$(mkdir -p "${ZEPPELIN_PID_DIR}")
|
||||
fi
|
||||
|
||||
if [[ ! -d "${ZEPPELIN_NOTEBOOK_DIR}" ]]; then
|
||||
echo "Notebook dir doesn't exist, create ${ZEPPELIN_NOTEBOOK_DIR}"
|
||||
$(mkdir -p "${ZEPPELIN_NOTEBOOK_DIR}")
|
||||
fi
|
||||
}
|
||||
|
||||
function wait_for_zeppelin_to_die() {
|
||||
|
|
@ -159,6 +152,16 @@ function check_if_process_is_alive() {
|
|||
fi
|
||||
}
|
||||
|
||||
function upstart() {
|
||||
|
||||
# upstart() allows zeppelin to be run and managed as a service
|
||||
# for example, this could be called from an upstart script in /etc/init
|
||||
# where the service manager starts and stops the process
|
||||
initialize_default_directories
|
||||
|
||||
$ZEPPELIN_RUNNER $JAVA_OPTS -cp $ZEPPELIN_CLASSPATH_OVERRIDES:$CLASSPATH $ZEPPELIN_MAIN >> "${ZEPPELIN_OUTFILE}"
|
||||
}
|
||||
|
||||
function start() {
|
||||
local pid
|
||||
|
||||
|
|
@ -241,6 +244,9 @@ case "${1}" in
|
|||
stop)
|
||||
stop
|
||||
;;
|
||||
upstart)
|
||||
upstart
|
||||
;;
|
||||
reload)
|
||||
stop
|
||||
start
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2007 The Apache Software Foundation
|
||||
#
|
||||
# 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
|
||||
|
|
|
|||
|
|
@ -83,6 +83,33 @@
|
|||
</property>
|
||||
-->
|
||||
|
||||
<!-- If using Azure for storage use the following settings -->
|
||||
<!--
|
||||
<property>
|
||||
<name>zeppelin.notebook.azure.user</name>
|
||||
<value>user</value>
|
||||
<description>optional user name for Azure folder structure</description>
|
||||
</property>
|
||||
|
||||
<property>
|
||||
<name>zeppelin.notebook.azure.share</name>
|
||||
<value>zeppelin</value>
|
||||
<description>share name for notebook storage</description>
|
||||
</property>
|
||||
|
||||
<property>
|
||||
<name>zeppelin.notebook.azure.connectionString</name>
|
||||
<value>DefaultEndpointsProtocol=https;AccountName=<accountName>;AccountKey=<accountKey></value>
|
||||
<description>share name for notebook storage</description>
|
||||
</property>
|
||||
|
||||
<property>
|
||||
<name>zeppelin.notebook.storage</name>
|
||||
<value>org.apache.zeppelin.notebook.repo.AzureNotebookRepo</value>
|
||||
<description>notebook persistence layer implementation</description>
|
||||
</property>
|
||||
-->
|
||||
|
||||
<!-- For versioning your local norebook storage using Git repository
|
||||
<property>
|
||||
<name>zeppelin.notebook.storage</name>
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 104 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 80 KiB |
|
|
@ -178,6 +178,24 @@ You can configure Zeppelin with both **environment variables** in `conf/zeppelin
|
|||
<td>user</td>
|
||||
<td>A user name of S3 bucket<br />i.e. <code>bucket/user/notebook/2A94M5J1Z/note.json</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ZEPPELIN_NOTEBOOK_AZURE_CONNECTION_STRING</td>
|
||||
<td>zeppelin.notebook.azure.connectionString</td>
|
||||
<td></td>
|
||||
<td>The Azure storage account connection string<br />i.e. <code>DefaultEndpointsProtocol=https;AccountName=<accountName>;AccountKey=<accountKey></code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ZEPPELIN_NOTEBOOK_AZURE_SHARE</td>
|
||||
<td>zeppelin.notebook.azure.share</td>
|
||||
<td>zeppelin</td>
|
||||
<td>Share where the Zeppelin notebook files will be saved</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ZEPPELIN_NOTEBOOK_AZURE_USER</td>
|
||||
<td>zeppelin.notebook.azure.user</td>
|
||||
<td>user</td>
|
||||
<td>An optional user name of Azure file share<br />i.e. <code>share/user/notebook/2A94M5J1Z/note.json</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ZEPPELIN_NOTEBOOK_STORAGE</td>
|
||||
<td>zeppelin.notebook.storage</td>
|
||||
|
|
@ -217,3 +235,39 @@ After successful start, visit [http://localhost:8080](http://localhost:8080) wit
|
|||
```
|
||||
bin/zeppelin-daemon.sh stop
|
||||
```
|
||||
|
||||
#### Start Zeppelin with a service manager such as upstart
|
||||
|
||||
Zeppelin can auto start as a service with an init script, such as services managed by upstart.
|
||||
|
||||
The following is an example upstart script to be saved as `/etc/init/zeppelin.conf`
|
||||
This example has been tested with Ubuntu Linux.
|
||||
This also allows the service to be managed with commands such as
|
||||
|
||||
`sudo service zeppelin start`
|
||||
`sudo service zeppelin stop`
|
||||
`sudo service zeppelin restart`
|
||||
|
||||
Other service managers could use a similar approach with the `upstart` argument passed to the zeppelin-daemon.sh script: `bin/zeppelin-daemon.sh upstart`
|
||||
|
||||
##### zeppelin.conf
|
||||
|
||||
```
|
||||
description "zeppelin"
|
||||
|
||||
start on (local-filesystems and net-device-up IFACE!=lo)
|
||||
stop on shutdown
|
||||
|
||||
# Respawn the process on unexpected termination
|
||||
respawn
|
||||
|
||||
# respawn the job up to 7 times within a 5 second period.
|
||||
# If the job exceeds these values, it will be stopped and marked as failed.
|
||||
respawn limit 7 5
|
||||
|
||||
# zeppelin was installed in /usr/share/zeppelin in this example
|
||||
chdir /usr/share/zeppelin
|
||||
exec bin/zeppelin-daemon.sh upstart
|
||||
```
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ This interpreter lets you create a JDBC connection to any data source, by now it
|
|||
* MariaDB
|
||||
* Redshift
|
||||
* Hive
|
||||
* Apache Drill
|
||||
* Details on using [Drill JDBC Driver](https://drill.apache.org/docs/using-the-jdbc-driver)
|
||||
|
||||
If someone else used another database please report how it works to improve functionality.
|
||||
|
||||
|
|
@ -54,14 +56,15 @@ It is not necessary to add driver jar to the classpath for PostgreSQL as it is i
|
|||
|
||||
#### Simple connection
|
||||
|
||||
Before creating the interpreter it is necessary to add to the Zeppelin classpath the path of the JDBC you want to use, to do it you must edit the file `zeppelin-daemon.sh` as shown:
|
||||
Prior to creating the interpreter it is necessary to add maven coordinate or path of the JDBC driver to the Zeppelin classpath. To do this you must edit dependencies artifact(ex. `mysql:mysql-connector-java:5.1.38`) in interpreter menu as shown:
|
||||
|
||||
```
|
||||
# Add jdbc connector jar
|
||||
ZEPPELIN_CLASSPATH+=":${ZEPPELIN_HOME}/jdbc/jars/mysql-connector-java-5.1.6.jar"
|
||||
```
|
||||
<div class="row">
|
||||
<div class="col-md-11">
|
||||
<img src="../assets/themes/zeppelin/img/docs-img/jdbc-simple-connection-setting.png" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
For create the interpreter you need to specify connection parameters as shown in the table.
|
||||
To create the interpreter you need to specify connection parameters as shown in the table.
|
||||
|
||||
<table class="table-configuration">
|
||||
<tr>
|
||||
|
|
@ -92,14 +95,15 @@ For create the interpreter you need to specify connection parameters as shown in
|
|||
|
||||
#### Multiple connections
|
||||
|
||||
This JDBC interpreter also allows connections to multiple data sources. For every connection is necessary a prefix for reference in the paragraph this way `%jdbc(prefix)`. Before creating the interpreter it is necessary to add to the Zeppelin classpath all paths to access to each driver's jar file you want to use, to do it you must edit the file `zeppelin-daemon.sh` as following:
|
||||
JDBC interpreter also allows connections to multiple data sources. It is necessary to set a prefix for each connection to reference it in the paragraph in the form of `%jdbc(prefix)`. Before you create the interpreter it is necessary to add each driver's maven coordinates or JDBC driver's jar file path to the Zeppelin classpath. To do this you must edit the dependencies of JDBC interpreter in interpreter menu as following:
|
||||
|
||||
```
|
||||
# Add jdbc connector jar
|
||||
ZEPPELIN_CLASSPATH+=":${ZEPPELIN_HOME}/jdbc/jars/RedshiftJDBC41-1.1.10.1010.jar"
|
||||
ZEPPELIN_CLASSPATH+=":${ZEPPELIN_HOME}/jdbc/jars/mysql-connector-java-5.1.6.jar"
|
||||
```
|
||||
You can add all the jars you need to make multiple connections into the same interpreter. To create the interpreter you must specify the parameters, for example we will create two connections to PostgreSQL and Redshift, the respective prefixes are `default` and `redshift`:
|
||||
<div class="row">
|
||||
<div class="col-md-11">
|
||||
<img src="../assets/themes/zeppelin/img/docs-img/jdbc-multi-connection-setting.png" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
You can add all the jars you need to make multiple connections into the same JDBC interpreter. To create the interpreter you must specify the parameters. For example we will create two connections to MySQL and Redshift, the respective prefixes are `default` and `redshift`:
|
||||
|
||||
<table class="table-configuration">
|
||||
<tr>
|
||||
|
|
@ -112,7 +116,7 @@ You can add all the jars you need to make multiple connections into the same int
|
|||
</tr>
|
||||
<tr>
|
||||
<td>default.driver</td>
|
||||
<td>org.postgresql.Driver</td>
|
||||
<td>com.mysql.jdbc.Driver</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>default.password</td>
|
||||
|
|
@ -120,11 +124,11 @@ You can add all the jars you need to make multiple connections into the same int
|
|||
</tr>
|
||||
<tr>
|
||||
<td>default.url</td>
|
||||
<td>jdbc:postgresql://localhost:5432/</td>
|
||||
<td>jdbc:mysql://localhost:3306/</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>default.user</td>
|
||||
<td>gpadmin</td>
|
||||
<td>mysql-user</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>redshift.driver</td>
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class FlinkInterpreterTest {
|
|||
Properties p = new Properties();
|
||||
flink = new FlinkInterpreter(p);
|
||||
flink.open();
|
||||
context = new InterpreterContext(null, null, null, null, null, null, null, null, null, null);
|
||||
context = new InterpreterContext(null, null, null, null, null, null, null, null, null, null, null);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
|
|
|||
|
|
@ -169,6 +169,9 @@ public class HiveInterpreter extends Interpreter {
|
|||
|
||||
public Connection getConnection(String propertyKey) throws ClassNotFoundException, SQLException {
|
||||
Connection connection = null;
|
||||
if (propertyKey == null || propertiesMap.get(propertyKey) == null) {
|
||||
return null;
|
||||
}
|
||||
if (propertyKeyUnusedConnectionListMap.containsKey(propertyKey)) {
|
||||
ArrayList<Connection> connectionList = propertyKeyUnusedConnectionListMap.get(propertyKey);
|
||||
if (0 != connectionList.size()) {
|
||||
|
|
@ -203,6 +206,10 @@ public class HiveInterpreter extends Interpreter {
|
|||
} else {
|
||||
connection = getConnection(propertyKey);
|
||||
}
|
||||
|
||||
if (connection == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Statement statement = connection.createStatement();
|
||||
if (isStatementClosed(statement)) {
|
||||
|
|
@ -232,6 +239,10 @@ public class HiveInterpreter extends Interpreter {
|
|||
|
||||
Statement statement = getStatement(propertyKey, paragraphId);
|
||||
|
||||
if (statement == null) {
|
||||
return new InterpreterResult(Code.ERROR, "Prefix not found.");
|
||||
}
|
||||
|
||||
statement.setMaxRows(getMaxResult());
|
||||
|
||||
StringBuilder msg;
|
||||
|
|
@ -315,10 +326,8 @@ public class HiveInterpreter extends Interpreter {
|
|||
public InterpreterResult interpret(String cmd, InterpreterContext contextInterpreter) {
|
||||
String propertyKey = getPropertyKey(cmd);
|
||||
|
||||
if (null != propertyKey) {
|
||||
if (null != propertyKey && !propertyKey.equals(DEFAULT_KEY)) {
|
||||
cmd = cmd.substring(propertyKey.length() + 2);
|
||||
} else {
|
||||
propertyKey = DEFAULT_KEY;
|
||||
}
|
||||
|
||||
cmd = cmd.trim();
|
||||
|
|
@ -334,17 +343,19 @@ public class HiveInterpreter extends Interpreter {
|
|||
}
|
||||
|
||||
public String getPropertyKey(String cmd) {
|
||||
int firstLineIndex = cmd.indexOf("\n");
|
||||
if (-1 == firstLineIndex) {
|
||||
firstLineIndex = cmd.length();
|
||||
boolean firstLineIndex = cmd.startsWith("(");
|
||||
|
||||
if (firstLineIndex) {
|
||||
int configStartIndex = cmd.indexOf("(");
|
||||
int configLastIndex = cmd.indexOf(")");
|
||||
if (configStartIndex != -1 && configLastIndex != -1) {
|
||||
return cmd.substring(configStartIndex + 1, configLastIndex);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return DEFAULT_KEY;
|
||||
}
|
||||
int configStartIndex = cmd.indexOf("(");
|
||||
int configLastIndex = cmd.indexOf(")");
|
||||
if (configStartIndex != -1 && configLastIndex != -1
|
||||
&& configLastIndex < firstLineIndex && configLastIndex < firstLineIndex) {
|
||||
return cmd.substring(configStartIndex + 1, configLastIndex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -66,7 +66,53 @@ public class HiveInterpreterTest {
|
|||
@After
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForParsePropertyKey() throws IOException {
|
||||
HiveInterpreter t = new HiveInterpreter(new Properties());
|
||||
|
||||
assertEquals(t.getPropertyKey("(fake) select max(cant) from test_table where id >= 2452640"),
|
||||
"fake");
|
||||
|
||||
assertEquals(t.getPropertyKey("() select max(cant) from test_table where id >= 2452640"),
|
||||
"");
|
||||
|
||||
assertEquals(t.getPropertyKey(")fake( select max(cant) from test_table where id >= 2452640"),
|
||||
"default");
|
||||
|
||||
// when you use a %hive(prefix1), prefix1 is the propertyKey as form part of the cmd string
|
||||
assertEquals(t.getPropertyKey("(prefix1)\n select max(cant) from test_table where id >= 2452640"),
|
||||
"prefix1");
|
||||
|
||||
assertEquals(t.getPropertyKey("(prefix2) select max(cant) from test_table where id >= 2452640"),
|
||||
"prefix2");
|
||||
|
||||
// when you use a %hive, prefix is the default
|
||||
assertEquals(t.getPropertyKey("select max(cant) from test_table where id >= 2452640"),
|
||||
"default");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForMapPrefix() throws SQLException, IOException {
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("common.max_count", "1000");
|
||||
properties.setProperty("common.max_retry", "3");
|
||||
properties.setProperty("default.driver", "org.h2.Driver");
|
||||
properties.setProperty("default.url", getJdbcConnection());
|
||||
properties.setProperty("default.user", "");
|
||||
properties.setProperty("default.password", "");
|
||||
HiveInterpreter t = new HiveInterpreter(properties);
|
||||
t.open();
|
||||
|
||||
String sqlQuery = "(fake) select * from test_table";
|
||||
|
||||
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());
|
||||
assertEquals("Prefix not found.", interpreterResult.message());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readTest() throws IOException {
|
||||
Properties properties = new Properties();
|
||||
|
|
@ -79,9 +125,9 @@ public class HiveInterpreterTest {
|
|||
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
|
||||
|
|
@ -101,7 +147,7 @@ public class HiveInterpreterTest {
|
|||
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
|
||||
|
|
@ -117,13 +163,13 @@ public class HiveInterpreterTest {
|
|||
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());
|
||||
}
|
||||
|
||||
|
|
@ -139,7 +185,7 @@ public class HiveInterpreterTest {
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -305,7 +305,15 @@ public class JDBCInterpreter extends Interpreter {
|
|||
int displayRowCount = 0;
|
||||
while (resultSet.next() && displayRowCount < getMaxResult()) {
|
||||
for (int i = 1; i < md.getColumnCount() + 1; i++) {
|
||||
msg.append(replaceReservedChars(isTableType, resultSet.getString(i)));
|
||||
Object resultObject;
|
||||
String resultValue;
|
||||
resultObject = resultSet.getObject(i);
|
||||
if (resultObject == null) {
|
||||
resultValue = "null";
|
||||
} else {
|
||||
resultValue = resultSet.getString(i);
|
||||
}
|
||||
msg.append(replaceReservedChars(isTableType, resultValue));
|
||||
if (i != md.getColumnCount()) {
|
||||
msg.append(TAB);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,10 +26,7 @@ import static org.apache.zeppelin.jdbc.JDBCInterpreter.COMMON_MAX_LINE;
|
|||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.sql.*;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.zeppelin.interpreter.InterpreterContext;
|
||||
|
|
@ -64,9 +61,10 @@ public class JDBCInterpreterTest extends BasicJDBCTestCaseAdapter {
|
|||
statement.execute(
|
||||
"DROP TABLE IF EXISTS test_table; " +
|
||||
"CREATE TABLE test_table(id varchar(255), name varchar(255));");
|
||||
statement.execute(
|
||||
"insert into test_table(id, name) values ('a', 'a_name'),('b', 'b_name');"
|
||||
);
|
||||
|
||||
PreparedStatement insertStatement = connection.prepareStatement("insert into test_table(id, name) values ('a', 'a_name'),('b', 'b_name'),('c', ?);");
|
||||
insertStatement.setString(1, null);
|
||||
insertStatement.execute();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -109,7 +107,7 @@ public class JDBCInterpreterTest extends BasicJDBCTestCaseAdapter {
|
|||
|
||||
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,15 +137,37 @@ public class JDBCInterpreterTest extends BasicJDBCTestCaseAdapter {
|
|||
JDBCInterpreter t = new JDBCInterpreter(properties);
|
||||
t.open();
|
||||
|
||||
String sqlQuery = "select * from test_table";
|
||||
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());
|
||||
assertEquals("ID\tNAME\na\ta_name\nb\tb_name\n", interpreterResult.message());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelectQueryWithNull() throws SQLException, IOException {
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("common.max_count", "1000");
|
||||
properties.setProperty("common.max_retry", "3");
|
||||
properties.setProperty("default.driver", "org.h2.Driver");
|
||||
properties.setProperty("default.url", getJdbcConnection());
|
||||
properties.setProperty("default.user", "");
|
||||
properties.setProperty("default.password", "");
|
||||
JDBCInterpreter t = new JDBCInterpreter(properties);
|
||||
t.open();
|
||||
|
||||
String sqlQuery = "select * from test_table WHERE ID = 'c'";
|
||||
|
||||
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());
|
||||
assertEquals("ID\tNAME\nc\tnull\n", interpreterResult.message());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSelectQueryMaxResult() throws SQLException, IOException {
|
||||
|
||||
|
|
@ -163,7 +183,7 @@ public class JDBCInterpreterTest extends BasicJDBCTestCaseAdapter {
|
|||
|
||||
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());
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import java.util.Properties;
|
|||
|
||||
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 class ScaldingInterpreterTest {
|
|||
}
|
||||
|
||||
InterpreterGroup intpGroup = new InterpreterGroup();
|
||||
context = new InterpreterContext("note", "id", "title", "text",
|
||||
context = new InterpreterContext("note", "id", "title", "text", new AuthenticationInfo(),
|
||||
new HashMap<String, Object>(), new GUI(), new AngularObjectRegistry(
|
||||
intpGroup.getId(), null), null,
|
||||
new LinkedList<InterpreterContextRunner>(), null);
|
||||
|
|
|
|||
|
|
@ -329,7 +329,12 @@ public class SparkInterpreter extends Interpreter {
|
|||
}
|
||||
pythonLibUris.trimToSize();
|
||||
if (pythonLibs.length == pythonLibUris.size()) {
|
||||
conf.set("spark.yarn.dist.files", Joiner.on(",").join(pythonLibUris));
|
||||
try {
|
||||
String confValue = conf.get("spark.yarn.dist.files");
|
||||
conf.set("spark.yarn.dist.files", confValue + "," + Joiner.on(",").join(pythonLibUris));
|
||||
} catch (NoSuchElementException e) {
|
||||
conf.set("spark.yarn.dist.files", Joiner.on(",").join(pythonLibUris));
|
||||
}
|
||||
if (!useSparkSubmit()) {
|
||||
conf.set("spark.files", conf.get("spark.yarn.dist.files"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import java.util.LinkedList;
|
|||
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.Code;
|
||||
|
|
@ -56,7 +57,8 @@ public class DepInterpreterTest {
|
|||
intpGroup.get("note").add(dep);
|
||||
dep.setInterpreterGroup(intpGroup);
|
||||
|
||||
context = new InterpreterContext("note", "id", "title", "text", new HashMap<String, Object>(), new GUI(),
|
||||
context = new InterpreterContext("note", "id", "title", "text", new AuthenticationInfo(),
|
||||
new HashMap<String, Object>(), new GUI(),
|
||||
new AngularObjectRegistry(intpGroup.getId(), null),
|
||||
null,
|
||||
new LinkedList<InterpreterContextRunner>(), null);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import org.apache.spark.SecurityManager;
|
|||
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;
|
||||
|
|
@ -80,6 +81,7 @@ public class SparkInterpreterTest {
|
|||
}
|
||||
|
||||
context = new InterpreterContext("note", "id", "title", "text",
|
||||
new AuthenticationInfo(),
|
||||
new HashMap<String, Object>(),
|
||||
new GUI(),
|
||||
new AngularObjectRegistry(intpGroup.getId(), null),
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@ import java.util.LinkedList;
|
|||
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;
|
||||
|
|
@ -70,8 +70,8 @@ public class SparkSqlInterpreterTest {
|
|||
sql.setInterpreterGroup(intpGroup);
|
||||
sql.open();
|
||||
}
|
||||
|
||||
context = new InterpreterContext("note", "id", "title", "text", new HashMap<String, Object>(), new GUI(),
|
||||
context = new InterpreterContext("note", "id", "title", "text", new AuthenticationInfo(),
|
||||
new HashMap<String, Object>(), new GUI(),
|
||||
new AngularObjectRegistry(intpGroup.getId(), null),
|
||||
null,
|
||||
new LinkedList<InterpreterContextRunner>(), new InterpreterOutput(new InterpreterOutputListener() {
|
||||
|
|
|
|||
|
|
@ -26,13 +26,26 @@ fi
|
|||
SPARK_VERSION="${1}"
|
||||
HADOOP_VERSION="${2}"
|
||||
|
||||
echo ${SPARK_VERSION} | grep "^1.[123].[0-9]" > /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "${SPARK_VERSION}" | grep "^1.[12].[0-9]" > /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
SPARK_VER_RANGE="<=1.2"
|
||||
else
|
||||
SPARK_VER_RANGE="<=1.3"
|
||||
fi
|
||||
else
|
||||
SPARK_VER_RANGE=">1.3"
|
||||
fi
|
||||
|
||||
set -xe
|
||||
|
||||
FWDIR=$(dirname "${BASH_SOURCE-$0}")
|
||||
ZEPPELIN_HOME="$(cd "${FWDIR}/.."; pwd)"
|
||||
export SPARK_HOME=${ZEPPELIN_HOME}/spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}
|
||||
echo "SPARK_HOME is ${SPARK_HOME} "
|
||||
echo "SPARK_HOME is ${SPARK_HOME}"
|
||||
if [ ! -d "${SPARK_HOME}" ]; then
|
||||
echo "${SPARK_VERSION}" | grep "^1.[12].[0-9]" > /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
if [ "${SPARK_VER_RANGE}" == "<=1.2" ]; then
|
||||
# spark 1.1.x and spark 1.2.x can be downloaded from archive
|
||||
wget -q http://archive.apache.org/dist/spark/spark-${SPARK_VERSION}/spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}.tgz
|
||||
else
|
||||
|
|
@ -51,16 +64,17 @@ fi
|
|||
mkdir -p ${SPARK_HOME}/run
|
||||
export SPARK_PID_DIR=${SPARK_HOME}/run
|
||||
|
||||
|
||||
# start
|
||||
export SPARK_MASTER_PORT=7071
|
||||
export SPARK_MASTER_WEBUI_PORT=7072
|
||||
export SPARK_WORKER_WEBUI_PORT=8082
|
||||
${SPARK_HOME}/sbin/start-master.sh
|
||||
|
||||
echo ${SPARK_VERSION} | grep "^1.[123].[0-9]" > /dev/null
|
||||
if [ $? -eq 0 ]; then # spark 1.3 or prior
|
||||
if [ "${SPARK_VER_RANGE}" == "<=1.3" ]||[ "${SPARK_VER_RANGE}" == "<=1.2" ]; then
|
||||
# spark 1.3 or prior
|
||||
${SPARK_HOME}/sbin/start-slave.sh 1 `hostname`:${SPARK_MASTER_PORT}
|
||||
else
|
||||
${SPARK_HOME}/sbin/start-slave.sh spark://`hostname`:7071
|
||||
fi
|
||||
|
||||
set +xe
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ fi
|
|||
SPARK_VERSION="${1}"
|
||||
HADOOP_VERSION="${2}"
|
||||
|
||||
set -xe
|
||||
|
||||
FWDIR=$(dirname "${BASH_SOURCE-$0}")
|
||||
ZEPPELIN_HOME="$(cd "${FWDIR}/.."; pwd)"
|
||||
export SPARK_HOME=${ZEPPELIN_HOME}/spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}
|
||||
|
|
@ -32,6 +34,6 @@ export SPARK_HOME=${ZEPPELIN_HOME}/spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VER
|
|||
# set create PID dir
|
||||
export SPARK_PID_DIR=${SPARK_HOME}/run
|
||||
|
||||
|
||||
${SPARK_HOME}/sbin/spark-daemon.sh stop org.apache.spark.deploy.worker.Worker 1
|
||||
${SPARK_HOME}/sbin/stop-master.sh
|
||||
set +xe
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ The following components are provided under Apache License.
|
|||
(Apache 2.0) Tachyon Servers (org.tachyonproject:tachyon-servers:0.8.2 - http://tachyon-project.org)
|
||||
(Apache 2.0) Tachyon Minicluster (org.tachyonproject:tachyon-minicluster:0.8.2 - http://tachyon-project.org)
|
||||
(Apache 2.0) Tachyon Underfs Local (org.tachyonproject:tachyon-underfs-local:0.8.2 - http://tachyon-project.org)
|
||||
(Apache 2.0) Microsoft Azure Storage Library for Java (com.microsoft.azure:azure-storage:4.0.0 - https://github.com/Azure/azure-storage-java)
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,202 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed 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.
|
||||
|
|
@ -71,8 +71,8 @@ public class DependencyResolver extends AbstractDependencyResolver {
|
|||
public synchronized List<File> load(String artifact, Collection<String> excludes)
|
||||
throws RepositoryException, IOException {
|
||||
if (StringUtils.isBlank(artifact)) {
|
||||
// Should throw here
|
||||
throw new RuntimeException("Invalid artifact to load");
|
||||
// Skip dependency loading if artifact is empty
|
||||
return new LinkedList<File>();
|
||||
}
|
||||
|
||||
// <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>
|
||||
|
|
@ -88,22 +88,26 @@ public class DependencyResolver extends AbstractDependencyResolver {
|
|||
|
||||
public List<File> load(String artifact, Collection<String> excludes, String destPath)
|
||||
throws RepositoryException, IOException {
|
||||
List<File> libs = load(artifact, excludes);
|
||||
|
||||
// find home dir
|
||||
String home = System.getenv("ZEPPELIN_HOME");
|
||||
if (home == null) {
|
||||
home = System.getProperty("zeppelin.home");
|
||||
}
|
||||
if (home == null) {
|
||||
home = "..";
|
||||
}
|
||||
|
||||
for (File srcFile: libs) {
|
||||
File destFile = new File(home + "/" + destPath, srcFile.getName());
|
||||
if (!destFile.exists() || !FileUtils.contentEquals(srcFile, destFile)) {
|
||||
FileUtils.copyFile(srcFile, destFile);
|
||||
logger.info("copy {} to {}", srcFile.getAbsolutePath(), destPath);
|
||||
List<File> libs = new LinkedList<File>();
|
||||
|
||||
if (StringUtils.isNotBlank(artifact)) {
|
||||
libs = load(artifact, excludes);
|
||||
|
||||
// find home dir
|
||||
String home = System.getenv("ZEPPELIN_HOME");
|
||||
if (home == null) {
|
||||
home = System.getProperty("zeppelin.home");
|
||||
}
|
||||
if (home == null) {
|
||||
home = "..";
|
||||
}
|
||||
|
||||
for (File srcFile : libs) {
|
||||
File destFile = new File(home + "/" + destPath, srcFile.getName());
|
||||
if (!destFile.exists() || !FileUtils.contentEquals(srcFile, destFile)) {
|
||||
FileUtils.copyFile(srcFile, destFile);
|
||||
logger.info("copy {} to {}", srcFile.getAbsolutePath(), destPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
return libs;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import java.util.List;
|
|||
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 class InterpreterContext {
|
|||
private final String paragraphTitle;
|
||||
private final String paragraphId;
|
||||
private final String paragraphText;
|
||||
private AuthenticationInfo authenticationInfo;
|
||||
private final Map<String, Object> config;
|
||||
private GUI gui;
|
||||
private AngularObjectRegistry angularObjectRegistry;
|
||||
|
|
@ -58,6 +60,7 @@ public class InterpreterContext {
|
|||
String paragraphId,
|
||||
String paragraphTitle,
|
||||
String paragraphText,
|
||||
AuthenticationInfo authenticationInfo,
|
||||
Map<String, Object> config,
|
||||
GUI gui,
|
||||
AngularObjectRegistry angularObjectRegistry,
|
||||
|
|
@ -69,6 +72,7 @@ public class InterpreterContext {
|
|||
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 class InterpreterContext {
|
|||
return paragraphTitle;
|
||||
}
|
||||
|
||||
public AuthenticationInfo getAuthenticationInfo() {
|
||||
return authenticationInfo;
|
||||
}
|
||||
|
||||
public Map<String, Object> getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -374,6 +374,7 @@ public class RemoteInterpreter extends Interpreter {
|
|||
ic.getParagraphId(),
|
||||
ic.getParagraphTitle(),
|
||||
ic.getParagraphText(),
|
||||
gson.toJson(ic.getAuthenticationInfo()),
|
||||
gson.toJson(ic.getConfig()),
|
||||
gson.toJson(ic.getGui()),
|
||||
gson.toJson(ic.getRunners()));
|
||||
|
|
|
|||
|
|
@ -29,10 +29,7 @@ import org.apache.thrift.TException;
|
|||
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;
|
||||
|
|
@ -45,6 +42,7 @@ import org.apache.zeppelin.scheduler.Job.Status;
|
|||
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;
|
||||
|
||||
|
|
@ -415,6 +413,7 @@ public class RemoteInterpreterServer
|
|||
ric.getParagraphId(),
|
||||
ric.getParagraphTitle(),
|
||||
ric.getParagraphText(),
|
||||
gson.fromJson(ric.getAuthenticationInfo(), AuthenticationInfo.class),
|
||||
(Map<String, Object>) gson.fromJson(ric.getConfig(),
|
||||
new TypeToken<Map<String, Object>>() {}.getType()),
|
||||
gson.fromJson(ric.getGui(), GUI.class),
|
||||
|
|
|
|||
|
|
@ -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.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
|
||||
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2016-2-2")
|
||||
@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-02-16")
|
||||
public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteInterpreterContext, RemoteInterpreterContext._Fields>, java.io.Serializable, Cloneable, Comparable<RemoteInterpreterContext> {
|
||||
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<RemoteI
|
|||
private static final org.apache.thrift.protocol.TField PARAGRAPH_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("paragraphId", org.apache.thrift.protocol.TType.STRING, (short)2);
|
||||
private static final org.apache.thrift.protocol.TField PARAGRAPH_TITLE_FIELD_DESC = new org.apache.thrift.protocol.TField("paragraphTitle", org.apache.thrift.protocol.TType.STRING, (short)3);
|
||||
private static final org.apache.thrift.protocol.TField PARAGRAPH_TEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("paragraphText", org.apache.thrift.protocol.TType.STRING, (short)4);
|
||||
private static final org.apache.thrift.protocol.TField CONFIG_FIELD_DESC = new org.apache.thrift.protocol.TField("config", org.apache.thrift.protocol.TType.STRING, (short)5);
|
||||
private static final org.apache.thrift.protocol.TField GUI_FIELD_DESC = new org.apache.thrift.protocol.TField("gui", org.apache.thrift.protocol.TType.STRING, (short)6);
|
||||
private static final org.apache.thrift.protocol.TField RUNNERS_FIELD_DESC = new org.apache.thrift.protocol.TField("runners", org.apache.thrift.protocol.TType.STRING, (short)7);
|
||||
private static final org.apache.thrift.protocol.TField AUTHENTICATION_INFO_FIELD_DESC = new org.apache.thrift.protocol.TField("authenticationInfo", org.apache.thrift.protocol.TType.STRING, (short)5);
|
||||
private static final org.apache.thrift.protocol.TField CONFIG_FIELD_DESC = new org.apache.thrift.protocol.TField("config", org.apache.thrift.protocol.TType.STRING, (short)6);
|
||||
private static final org.apache.thrift.protocol.TField GUI_FIELD_DESC = new org.apache.thrift.protocol.TField("gui", org.apache.thrift.protocol.TType.STRING, (short)7);
|
||||
private static final org.apache.thrift.protocol.TField RUNNERS_FIELD_DESC = new org.apache.thrift.protocol.TField("runners", org.apache.thrift.protocol.TType.STRING, (short)8);
|
||||
|
||||
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
|
||||
static {
|
||||
|
|
@ -73,6 +74,7 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
public String paragraphId; // required
|
||||
public String paragraphTitle; // required
|
||||
public String paragraphText; // required
|
||||
public String authenticationInfo; // required
|
||||
public String config; // required
|
||||
public String gui; // required
|
||||
public String runners; // required
|
||||
|
|
@ -83,9 +85,10 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
PARAGRAPH_ID((short)2, "paragraphId"),
|
||||
PARAGRAPH_TITLE((short)3, "paragraphTitle"),
|
||||
PARAGRAPH_TEXT((short)4, "paragraphText"),
|
||||
CONFIG((short)5, "config"),
|
||||
GUI((short)6, "gui"),
|
||||
RUNNERS((short)7, "runners");
|
||||
AUTHENTICATION_INFO((short)5, "authenticationInfo"),
|
||||
CONFIG((short)6, "config"),
|
||||
GUI((short)7, "gui"),
|
||||
RUNNERS((short)8, "runners");
|
||||
|
||||
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
|
||||
|
||||
|
|
@ -108,11 +111,13 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
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 class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
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 class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
String paragraphId,
|
||||
String paragraphTitle,
|
||||
String paragraphText,
|
||||
String authenticationInfo,
|
||||
String config,
|
||||
String gui,
|
||||
String runners)
|
||||
|
|
@ -192,6 +200,7 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
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 class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
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 class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
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 class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
}
|
||||
}
|
||||
|
||||
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 class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
}
|
||||
break;
|
||||
|
||||
case AUTHENTICATION_INFO:
|
||||
if (value == null) {
|
||||
unsetAuthenticationInfo();
|
||||
} else {
|
||||
setAuthenticationInfo((String)value);
|
||||
}
|
||||
break;
|
||||
|
||||
case CONFIG:
|
||||
if (value == null) {
|
||||
unsetConfig();
|
||||
|
|
@ -482,6 +527,9 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
case PARAGRAPH_TEXT:
|
||||
return getParagraphText();
|
||||
|
||||
case AUTHENTICATION_INFO:
|
||||
return getAuthenticationInfo();
|
||||
|
||||
case CONFIG:
|
||||
return getConfig();
|
||||
|
||||
|
|
@ -510,6 +558,8 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
return isSetParagraphTitle();
|
||||
case PARAGRAPH_TEXT:
|
||||
return isSetParagraphText();
|
||||
case AUTHENTICATION_INFO:
|
||||
return isSetAuthenticationInfo();
|
||||
case CONFIG:
|
||||
return isSetConfig();
|
||||
case GUI:
|
||||
|
|
@ -569,6 +619,15 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
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 class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
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 class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
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 class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
}
|
||||
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 class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
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 class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
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 class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
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 class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
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 class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
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 class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
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 class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
@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 class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
|
|||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
|
||||
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2016-2-2")
|
||||
@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-02-16")
|
||||
public class RemoteInterpreterEvent implements org.apache.thrift.TBase<RemoteInterpreterEvent, RemoteInterpreterEvent._Fields>, java.io.Serializable, Cloneable, Comparable<RemoteInterpreterEvent> {
|
||||
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("RemoteInterpreterEvent");
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
|
||||
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2016-2-2")
|
||||
@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-02-16")
|
||||
public class RemoteInterpreterResult implements org.apache.thrift.TBase<RemoteInterpreterResult, RemoteInterpreterResult._Fields>, java.io.Serializable, Cloneable, Comparable<RemoteInterpreterResult> {
|
||||
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("RemoteInterpreterResult");
|
||||
|
||||
|
|
|
|||
|
|
@ -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.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
|
||||
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2016-2-2")
|
||||
@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-02-16")
|
||||
public class RemoteInterpreterService {
|
||||
|
||||
public interface Iface {
|
||||
|
|
@ -7566,7 +7566,7 @@ public class RemoteInterpreterService {
|
|||
public Object getFieldValue(_Fields field) {
|
||||
switch (field) {
|
||||
case SUCCESS:
|
||||
return Integer.valueOf(getSuccess());
|
||||
return getSuccess();
|
||||
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
|
|
@ -8898,7 +8898,7 @@ public class RemoteInterpreterService {
|
|||
return getBuf();
|
||||
|
||||
case CURSOR:
|
||||
return Integer.valueOf(getCursor());
|
||||
return getCursor();
|
||||
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -25,14 +25,11 @@ import java.util.LinkedList;
|
|||
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.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;
|
||||
|
|
@ -83,6 +80,7 @@ public class RemoteAngularObjectTest implements AngularObjectRegistryListener {
|
|||
"id",
|
||||
"title",
|
||||
"text",
|
||||
new AuthenticationInfo(),
|
||||
new HashMap<String, Object>(),
|
||||
new GUI(),
|
||||
new AngularObjectRegistry(intpGroup.getId(), null),
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -78,6 +79,7 @@ public class RemoteInterpreterOutputTestStream implements RemoteInterpreterProce
|
|||
"id",
|
||||
"title",
|
||||
"text",
|
||||
new AuthenticationInfo(),
|
||||
new HashMap<String, Object>(),
|
||||
new GUI(),
|
||||
new AngularObjectRegistry(intpGroup.getId(), null),
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import java.util.Properties;
|
|||
|
||||
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.*;
|
||||
import org.apache.zeppelin.interpreter.InterpreterResult.Code;
|
||||
|
|
@ -130,6 +131,7 @@ public class RemoteInterpreterTest {
|
|||
"id",
|
||||
"title",
|
||||
"text",
|
||||
new AuthenticationInfo(),
|
||||
new HashMap<String, Object>(),
|
||||
new GUI(),
|
||||
new AngularObjectRegistry(intpGroup.getId(), null),
|
||||
|
|
@ -165,6 +167,7 @@ public class RemoteInterpreterTest {
|
|||
"id",
|
||||
"title",
|
||||
"text",
|
||||
new AuthenticationInfo(),
|
||||
new HashMap<String, Object>(),
|
||||
new GUI(),
|
||||
new AngularObjectRegistry(intpGroup.getId(), null),
|
||||
|
|
@ -218,6 +221,7 @@ public class RemoteInterpreterTest {
|
|||
"id",
|
||||
"title",
|
||||
"text",
|
||||
new AuthenticationInfo(),
|
||||
new HashMap<String, Object>(),
|
||||
new GUI(),
|
||||
new AngularObjectRegistry(intpGroup.getId(), null),
|
||||
|
|
@ -231,6 +235,7 @@ public class RemoteInterpreterTest {
|
|||
"id",
|
||||
"title",
|
||||
"text",
|
||||
new AuthenticationInfo(),
|
||||
new HashMap<String, Object>(),
|
||||
new GUI(),
|
||||
new AngularObjectRegistry(intpGroup.getId(), null),
|
||||
|
|
@ -284,6 +289,7 @@ public class RemoteInterpreterTest {
|
|||
"jobA",
|
||||
"title",
|
||||
"text",
|
||||
new AuthenticationInfo(),
|
||||
new HashMap<String, Object>(),
|
||||
new GUI(),
|
||||
new AngularObjectRegistry(intpGroup.getId(), null),
|
||||
|
|
@ -319,6 +325,7 @@ public class RemoteInterpreterTest {
|
|||
"jobB",
|
||||
"title",
|
||||
"text",
|
||||
new AuthenticationInfo(),
|
||||
new HashMap<String, Object>(),
|
||||
new GUI(),
|
||||
new AngularObjectRegistry(intpGroup.getId(), null),
|
||||
|
|
@ -384,6 +391,7 @@ public class RemoteInterpreterTest {
|
|||
jobId,
|
||||
"title",
|
||||
"text",
|
||||
new AuthenticationInfo(),
|
||||
new HashMap<String, Object>(),
|
||||
new GUI(),
|
||||
new AngularObjectRegistry(intpGroup.getId(), null),
|
||||
|
|
@ -463,6 +471,7 @@ public class RemoteInterpreterTest {
|
|||
jobId,
|
||||
"title",
|
||||
"text",
|
||||
new AuthenticationInfo(),
|
||||
new HashMap<String, Object>(),
|
||||
new GUI(),
|
||||
new AngularObjectRegistry(intpGroup.getId(), null),
|
||||
|
|
@ -564,6 +573,7 @@ public class RemoteInterpreterTest {
|
|||
"jobA",
|
||||
"title",
|
||||
"text",
|
||||
new AuthenticationInfo(),
|
||||
new HashMap<String, Object>(),
|
||||
new GUI(),
|
||||
new AngularObjectRegistry(intpGroup.getId(), null),
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
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.*;
|
||||
import org.apache.zeppelin.interpreter.remote.RemoteInterpreter;
|
||||
|
|
@ -94,6 +95,7 @@ public class DistributedResourcePoolTest {
|
|||
"id",
|
||||
"title",
|
||||
"text",
|
||||
new AuthenticationInfo(),
|
||||
new HashMap<String, Object>(),
|
||||
new GUI(),
|
||||
null,
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import java.util.Map;
|
|||
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.Interpreter;
|
||||
import org.apache.zeppelin.interpreter.InterpreterContext;
|
||||
|
|
@ -106,6 +107,7 @@ public class RemoteSchedulerTest implements RemoteInterpreterProcessListener {
|
|||
"jobId",
|
||||
"title",
|
||||
"text",
|
||||
new AuthenticationInfo(),
|
||||
new HashMap<String, Object>(),
|
||||
new GUI(),
|
||||
new AngularObjectRegistry(intpGroup.getId(), null),
|
||||
|
|
@ -180,6 +182,7 @@ public class RemoteSchedulerTest implements RemoteInterpreterProcessListener {
|
|||
"jobId1",
|
||||
"title",
|
||||
"text",
|
||||
new AuthenticationInfo(),
|
||||
new HashMap<String, Object>(),
|
||||
new GUI(),
|
||||
new AngularObjectRegistry(intpGroup.getId(), null),
|
||||
|
|
@ -217,6 +220,7 @@ public class RemoteSchedulerTest implements RemoteInterpreterProcessListener {
|
|||
"jobId2",
|
||||
"title",
|
||||
"text",
|
||||
new AuthenticationInfo(),
|
||||
new HashMap<String, Object>(),
|
||||
new GUI(),
|
||||
new AngularObjectRegistry(intpGroup.getId(), null),
|
||||
|
|
|
|||
|
|
@ -53,7 +53,11 @@ public class ConfigurationsRestApi {
|
|||
new ZeppelinConfiguration.ConfigurationKeyPredicate() {
|
||||
@Override
|
||||
public boolean apply(String key) {
|
||||
return !key.contains("password");
|
||||
return !key.contains("password") &&
|
||||
!key.equals(ZeppelinConfiguration
|
||||
.ConfVars
|
||||
.ZEPPELIN_NOTEBOOK_AZURE_CONNECTION_STRING
|
||||
.getVarName());
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
@ -70,7 +74,12 @@ public class ConfigurationsRestApi {
|
|||
new ZeppelinConfiguration.ConfigurationKeyPredicate() {
|
||||
@Override
|
||||
public boolean apply(String key) {
|
||||
return !key.contains("password") && key.startsWith(prefix);
|
||||
return !key.contains("password") &&
|
||||
!key.equals(ZeppelinConfiguration
|
||||
.ConfVars
|
||||
.ZEPPELIN_NOTEBOOK_AZURE_CONNECTION_STRING
|
||||
.getVarName()) &&
|
||||
key.startsWith(prefix);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -16,19 +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.user.AuthenticationInfo;
|
||||
import org.apache.zeppelin.interpreter.InterpreterOutput;
|
||||
import org.apache.zeppelin.interpreter.InterpreterResult;
|
||||
import org.apache.zeppelin.interpreter.InterpreterSetting;
|
||||
|
|
@ -46,8 +41,12 @@ import org.quartz.SchedulerException;
|
|||
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.
|
||||
|
|
@ -694,6 +693,15 @@ public class NotebookServer extends WebSocketServlet implements
|
|||
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<String, Object> params = (Map<String, Object>) fromMessage
|
||||
.get("params");
|
||||
p.settings.setParams(params);
|
||||
|
|
@ -729,7 +737,11 @@ public class NotebookServer extends WebSocketServlet implements
|
|||
new ZeppelinConfiguration.ConfigurationKeyPredicate() {
|
||||
@Override
|
||||
public boolean apply(String key) {
|
||||
return !key.contains("password");
|
||||
return !key.contains("password") &&
|
||||
!key.equals(ZeppelinConfiguration
|
||||
.ConfVars
|
||||
.ZEPPELIN_NOTEBOOK_AZURE_CONNECTION_STRING
|
||||
.getVarName());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@ package org.apache.zeppelin;
|
|||
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.openqa.selenium.*;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.FluentWait;
|
||||
|
|
@ -29,10 +27,14 @@ import org.openqa.selenium.support.ui.WebDriverWait;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.openqa.selenium.Keys.ENTER;
|
||||
import static org.openqa.selenium.Keys.SHIFT;
|
||||
|
||||
abstract public class AbstractZeppelinIT {
|
||||
protected WebDriver driver;
|
||||
|
||||
|
|
@ -131,4 +133,44 @@ abstract public class AbstractZeppelinIT {
|
|||
sleep(100, true);
|
||||
}
|
||||
|
||||
public enum HelperKeys implements CharSequence {
|
||||
OPEN_PARENTHESIS(Keys.chord(Keys.SHIFT, "9")),
|
||||
EXCLAMATION(Keys.chord(Keys.SHIFT, "1")),
|
||||
PERCENTAGE(Keys.chord(Keys.SHIFT, "5")),
|
||||
SHIFT_ENTER(Keys.chord(SHIFT, ENTER));
|
||||
|
||||
private final CharSequence keyCode;
|
||||
|
||||
HelperKeys(CharSequence keyCode) {
|
||||
this.keyCode = keyCode;
|
||||
}
|
||||
|
||||
public char charAt(int index) {
|
||||
return index == 0 ? keyCode.charAt(index) : '\ue000';
|
||||
}
|
||||
|
||||
public int length() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public CharSequence subSequence(int start, int end) {
|
||||
if (start == 0 && end == 1) {
|
||||
return String.valueOf(this.keyCode);
|
||||
} else {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return String.valueOf(this.keyCode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void handleException(String message, Exception e) throws Exception {
|
||||
LOG.error(message, e);
|
||||
File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,6 +137,41 @@ public class ParagraphActionsIT extends AbstractZeppelinIT {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveButton() throws InterruptedException {
|
||||
if (!endToEndTestEnabled()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
createNewNote();
|
||||
|
||||
waitForParagraph(1, "READY");
|
||||
driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click();
|
||||
driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='insertNew()']")).click();
|
||||
waitForParagraph(2, "READY");
|
||||
Integer oldNosOfParas = driver.findElements(By.xpath("//div[@ng-controller=\"ParagraphCtrl\"]")).size();
|
||||
collector.checkThat("Before Remove : Number of paragraphs are ",
|
||||
oldNosOfParas,
|
||||
CoreMatchers.equalTo(2));
|
||||
driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click();
|
||||
driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='removeParagraph()']")).click();
|
||||
sleep(1000, true);
|
||||
driver.findElement(By.xpath("//div[@class='modal-dialog'][contains(.,'delete this paragraph')]" +
|
||||
"//div[@class='modal-footer']//button[contains(.,'OK')]")).click();
|
||||
Integer newNosOfParas = driver.findElements(By.xpath("//div[@ng-controller=\"ParagraphCtrl\"]")).size();
|
||||
collector.checkThat("After Remove : Number of paragraphs are",
|
||||
oldNosOfParas-1,
|
||||
CoreMatchers.equalTo(newNosOfParas));
|
||||
ZeppelinITUtils.sleep(1000, false);
|
||||
deleteTestNotebook(driver);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Exception in ParagraphActionsIT while testRemoveButton ", e);
|
||||
File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoveUpAndDown() throws Exception {
|
||||
if (!endToEndTestEnabled()) {
|
||||
|
|
@ -192,9 +227,7 @@ public class ParagraphActionsIT extends AbstractZeppelinIT {
|
|||
deleteTestNotebook(driver);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Exception in ParagraphActionsIT while testMoveUpAndDown ", e);
|
||||
File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
|
||||
throw e;
|
||||
handleException("Exception in ParagraphActionsIT while testMoveUpAndDown ", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -232,9 +265,7 @@ public class ParagraphActionsIT extends AbstractZeppelinIT {
|
|||
deleteTestNotebook(driver);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Exception in ParagraphActionsIT while testDisableParagraphRunButton ", e);
|
||||
File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
|
||||
throw e;
|
||||
handleException("Exception in ParagraphActionsIT while testDisableParagraphRunButton ", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,228 @@
|
|||
/*
|
||||
* 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.integration;
|
||||
|
||||
|
||||
import org.apache.zeppelin.AbstractZeppelinIT;
|
||||
import org.apache.zeppelin.WebDriverManager;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ErrorCollector;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.TimeoutException;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.zeppelin.AbstractZeppelinIT.HelperKeys.*;
|
||||
import static org.openqa.selenium.Keys.*;
|
||||
|
||||
public class SparkParagraphIT extends AbstractZeppelinIT {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SparkParagraphIT.class);
|
||||
|
||||
|
||||
@Rule
|
||||
public ErrorCollector collector = new ErrorCollector();
|
||||
|
||||
@Before
|
||||
public void startUp() {
|
||||
if (!endToEndTestEnabled()) {
|
||||
return;
|
||||
}
|
||||
driver = WebDriverManager.getWebDriver();
|
||||
createNewNote();
|
||||
waitForParagraph(1, "READY");
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
if (!endToEndTestEnabled()) {
|
||||
return;
|
||||
}
|
||||
deleteTestNotebook(driver);
|
||||
driver.quit();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpark() throws Exception {
|
||||
if (!endToEndTestEnabled()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
WebElement paragraph1Editor = driver.findElement(By.xpath(getParagraphXPath(1) + "//textarea"));
|
||||
paragraph1Editor.sendKeys("sc.version");
|
||||
paragraph1Editor.sendKeys(SHIFT_ENTER);
|
||||
|
||||
waitForParagraph(1, "FINISHED");
|
||||
WebElement paragraph1Result = driver.findElement(By.xpath(
|
||||
getParagraphXPath(1) + "//div[@class=\"tableDisplay\"]"));
|
||||
Float sparkVersion = Float.parseFloat(paragraph1Result.getText().split("= ")[1].substring(0, 3));
|
||||
|
||||
WebElement paragraph2Editor = driver.findElement(By.xpath(getParagraphXPath(2) + "//textarea"));
|
||||
|
||||
|
||||
/*
|
||||
equivalent of
|
||||
import org.apache.commons.io.IOUtils
|
||||
import java.net.URL
|
||||
import java.nio.charset.Charset
|
||||
val bankText = sc.parallelize(IOUtils.toString(new URL("https://s3.amazonaws.com/apache-zeppelin/tutorial/bank/bank.csv"),Charset.forName("utf8")).split("\n"))
|
||||
case class Bank(age: Integer, job: String, marital: String, education: String, balance: Integer)
|
||||
|
||||
val bank = bankText.map(s => s.split(";")).filter(s => s(0) != "\"age\"").map(s => Bank(s(0).toInt,s(1).replaceAll("\"", ""),s(2).replaceAll("\"", ""),s(3).replaceAll("\"", ""),s(5).replaceAll("\"", "").toInt)).toDF()
|
||||
bank.registerTempTable("bank")
|
||||
*/
|
||||
paragraph2Editor.sendKeys("import org.apache.commons.io.IOUtils" +
|
||||
ENTER +
|
||||
|
||||
"import java.net.URL" +
|
||||
ENTER +
|
||||
|
||||
"import java.nio.charset.Charset" +
|
||||
ENTER +
|
||||
|
||||
"val bankText = sc.parallelize" + OPEN_PARENTHESIS +
|
||||
"IOUtils.toString" + OPEN_PARENTHESIS + "new URL" + OPEN_PARENTHESIS
|
||||
+ "\"https://s3.amazonaws.com/apache" + SUBTRACT + "zeppelin/tutorial/bank/bank." +
|
||||
"csv\"),Charset.forName" + OPEN_PARENTHESIS + "\"utf8\"))" +
|
||||
".split" + OPEN_PARENTHESIS + "\"\\n\"))" +
|
||||
ENTER +
|
||||
|
||||
"case class Bank" + OPEN_PARENTHESIS +
|
||||
"age: Integer, job: String, marital: String, education: String, balance: Integer)" +
|
||||
ENTER +
|
||||
ENTER +
|
||||
|
||||
"val bank = bankText.map" + OPEN_PARENTHESIS + "s => s.split" +
|
||||
OPEN_PARENTHESIS + "\";\")).filter" + OPEN_PARENTHESIS +
|
||||
"s => s" + OPEN_PARENTHESIS + "0) " + EXCLAMATION +
|
||||
"= \"\\\"age\\\"\").map" + OPEN_PARENTHESIS +
|
||||
"s => Bank" + OPEN_PARENTHESIS + "s" + OPEN_PARENTHESIS +
|
||||
"0).toInt,s" + OPEN_PARENTHESIS + "1).replaceAll" +
|
||||
OPEN_PARENTHESIS + "\"\\\"\", \"\")," +
|
||||
"s" + OPEN_PARENTHESIS + "2).replaceAll" +
|
||||
OPEN_PARENTHESIS + "\"\\\"\", \"\")," +
|
||||
"s" + OPEN_PARENTHESIS + "3).replaceAll" +
|
||||
OPEN_PARENTHESIS + "\"\\\"\", \"\")," +
|
||||
"s" + OPEN_PARENTHESIS + "5).replaceAll" +
|
||||
OPEN_PARENTHESIS + "\"\\\"\", \"\").toInt" + ")" +
|
||||
")" + (sparkVersion < 1.3f ? "" : ".toDF" + OPEN_PARENTHESIS + ")") +
|
||||
ENTER +
|
||||
|
||||
"bank.registerTempTable" + OPEN_PARENTHESIS + "\"bank\")"
|
||||
);
|
||||
paragraph2Editor.sendKeys("" + END + BACK_SPACE + BACK_SPACE +
|
||||
BACK_SPACE + BACK_SPACE + BACK_SPACE + BACK_SPACE +
|
||||
BACK_SPACE + BACK_SPACE + BACK_SPACE + BACK_SPACE + BACK_SPACE);
|
||||
|
||||
paragraph2Editor.sendKeys(SHIFT_ENTER);
|
||||
|
||||
try {
|
||||
waitForParagraph(2, "FINISHED");
|
||||
} catch (TimeoutException e) {
|
||||
waitForParagraph(2, "ERROR");
|
||||
collector.checkThat("2nd Paragraph from SparkParagraphIT of testSpark status:",
|
||||
"ERROR", CoreMatchers.equalTo("FINISHED")
|
||||
);
|
||||
}
|
||||
|
||||
WebElement paragraph2Result = driver.findElement(By.xpath(
|
||||
getParagraphXPath(2) + "//div[@class=\"tableDisplay\"]"));
|
||||
|
||||
collector.checkThat("2nd Paragraph from SparkParagraphIT of testSpark result: ",
|
||||
paragraph2Result.getText().toString(), CoreMatchers.containsString(
|
||||
"import org.apache.commons.io.IOUtils"
|
||||
)
|
||||
);
|
||||
|
||||
} catch (Exception e) {
|
||||
handleException("Exception in SparkParagraphIT while testSpark", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPySpark() throws Exception {
|
||||
if (!endToEndTestEnabled()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
WebElement paragraph1Editor = driver.findElement(By.xpath(getParagraphXPath(1) + "//textarea"));
|
||||
|
||||
paragraph1Editor.sendKeys(PERCENTAGE + "pyspark" + ENTER +
|
||||
"for x in range" + OPEN_PARENTHESIS + "0, 3):" + ENTER +
|
||||
" print \"test loop " + PERCENTAGE + "d\" " +
|
||||
PERCENTAGE + " " + OPEN_PARENTHESIS + "x)" + ENTER);
|
||||
|
||||
paragraph1Editor.sendKeys(SHIFT_ENTER);
|
||||
|
||||
try {
|
||||
waitForParagraph(1, "FINISHED");
|
||||
} catch (TimeoutException e) {
|
||||
waitForParagraph(1, "ERROR");
|
||||
collector.checkThat("Paragraph from SparkParagraphIT of testPySpark status: ",
|
||||
"ERROR", CoreMatchers.equalTo("FINISHED")
|
||||
);
|
||||
}
|
||||
|
||||
WebElement paragraph1Result = driver.findElement(By.xpath(
|
||||
getParagraphXPath(1) + "//div[@class=\"tableDisplay\"]"));
|
||||
collector.checkThat("Paragraph from SparkParagraphIT of testPySpark result: ",
|
||||
paragraph1Result.getText().toString(), CoreMatchers.equalTo("test loop 0\ntest loop 1\ntest loop 2")
|
||||
);
|
||||
|
||||
} catch (Exception e) {
|
||||
handleException("Exception in SparkParagraphIT while testPySpark", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSqlSpark() throws Exception {
|
||||
if (!endToEndTestEnabled()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
WebElement paragraph1Editor = driver.findElement(By.xpath(getParagraphXPath(1) + "//textarea"));
|
||||
|
||||
paragraph1Editor.sendKeys(PERCENTAGE + "sql" + ENTER +
|
||||
"select * from bank limit 1");
|
||||
|
||||
paragraph1Editor.sendKeys(SHIFT_ENTER);
|
||||
|
||||
try {
|
||||
waitForParagraph(1, "FINISHED");
|
||||
} catch (TimeoutException e) {
|
||||
waitForParagraph(1, "ERROR");
|
||||
collector.checkThat("Paragraph from SparkParagraphIT of testSqlSpark status: ",
|
||||
"ERROR", CoreMatchers.equalTo("FINISHED")
|
||||
);
|
||||
}
|
||||
|
||||
WebElement paragraph1Result = driver.findElement(By.xpath(
|
||||
getParagraphXPath(1) + "//div[@class=\"tableDisplay\"]"));
|
||||
collector.checkThat("Paragraph from SparkParagraphIT of testSqlSpark result: ",
|
||||
paragraph1Result.getText().toString(), CoreMatchers.equalTo("age job marital education balance\n" +
|
||||
"30 unemployed married primary 1,787")
|
||||
);
|
||||
} catch (Exception e) {
|
||||
handleException("Exception in SparkParagraphIT while testSqlSpark", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
@ -196,9 +198,7 @@ public class ZeppelinIT extends AbstractZeppelinIT {
|
|||
|
||||
System.out.println("testCreateNotebook Test executed");
|
||||
} catch (Exception e) {
|
||||
LOG.error("Exception in ZeppelinIT while testAngularDisplay ", e);
|
||||
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
|
||||
throw e;
|
||||
handleException("Exception in ZeppelinIT while testAngularDisplay ", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -254,9 +254,7 @@ public class ZeppelinIT extends AbstractZeppelinIT {
|
|||
driver.findElement(By.xpath("//button[contains(.,'Save')]")).submit();
|
||||
driver.switchTo().alert().accept();
|
||||
} catch (Exception e) {
|
||||
LOG.error("Exception in ZeppelinIT while testSparkInterpreterDependencyLoading ", e);
|
||||
File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
|
||||
throw e;
|
||||
handleException("Exception in ZeppelinIT while testSparkInterpreterDependencyLoading ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,16 +30,31 @@ This will launch a Zeppelin WebApplication on port **9000** that will update on
|
|||
|
||||
#### Troubleshooting
|
||||
|
||||
**git error**
|
||||
|
||||
In case of the error `ECMDERR Failed to execute "git ls-remote --tags --heads git://xxxxx", exit code of #128`
|
||||
|
||||
change your git config with `git config --global url."https://".insteadOf git://`
|
||||
|
||||
**OR**
|
||||
**proxy issues**
|
||||
|
||||
Try to add to the `.bowerrc` file the following content:
|
||||
```
|
||||
"proxy" : "http://<host>:<port>",
|
||||
"https-proxy" : "http://<host>:<port>"
|
||||
```
|
||||
|
||||
also try to add proxy info to npm install command:
|
||||
```
|
||||
<execution>
|
||||
<id>npm install</id>
|
||||
<goals>
|
||||
<goal>npm</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<arguments>--proxy=http://<host>:<port> --https-proxy=http://<host>:<port></arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
```
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -58,6 +58,26 @@
|
|||
<version>1.10.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.microsoft.azure</groupId>
|
||||
<artifactId>azure-storage</artifactId>
|
||||
<version>4.0.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
|
|
|
|||
|
|
@ -472,6 +472,9 @@ public class ZeppelinConfiguration extends XMLConfiguration {
|
|||
ZEPPELIN_NOTEBOOK_HOMESCREEN_HIDE("zeppelin.notebook.homescreen.hide", false),
|
||||
ZEPPELIN_NOTEBOOK_S3_BUCKET("zeppelin.notebook.s3.bucket", "zeppelin"),
|
||||
ZEPPELIN_NOTEBOOK_S3_USER("zeppelin.notebook.s3.user", "user"),
|
||||
ZEPPELIN_NOTEBOOK_AZURE_CONNECTION_STRING("zeppelin.notebook.azure.connectionString", null),
|
||||
ZEPPELIN_NOTEBOOK_AZURE_SHARE("zeppelin.notebook.azure.share", "zeppelin"),
|
||||
ZEPPELIN_NOTEBOOK_AZURE_USER("zeppelin.notebook.azure.user", "user"),
|
||||
ZEPPELIN_NOTEBOOK_STORAGE("zeppelin.notebook.storage", VFSNotebookRepo.class.getName()),
|
||||
ZEPPELIN_INTERPRETER_REMOTE_RUNNER("zeppelin.interpreter.remoterunner", "bin/interpreter.sh"),
|
||||
// Decide when new note is created, interpreter settings will be binded automatically or not.
|
||||
|
|
|
|||
|
|
@ -349,6 +349,9 @@ public class Note implements Serializable, JobListener {
|
|||
public void runAll() {
|
||||
synchronized (paragraphs) {
|
||||
for (Paragraph p : paragraphs) {
|
||||
if (!p.isEnabled()) {
|
||||
continue;
|
||||
}
|
||||
p.setNoteReplLoader(replLoader);
|
||||
p.setListener(jobListenerFactory.getParagraphJobListener(this));
|
||||
Interpreter intp = replLoader.get(p.getRequiredReplName());
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
|
@ -46,6 +47,7 @@ public class Paragraph extends Job implements Serializable, Cloneable {
|
|||
|
||||
String title;
|
||||
String text;
|
||||
AuthenticationInfo authenticationInfo;
|
||||
Date dateUpdated;
|
||||
private Map<String, Object> config; // paragraph configs like isOpen, colWidth, etc
|
||||
public final GUI settings; // form and parameter settings
|
||||
|
|
@ -56,6 +58,7 @@ public class Paragraph extends Job implements Serializable, Cloneable {
|
|||
this.replLoader = replLoader;
|
||||
title = null;
|
||||
text = null;
|
||||
authenticationInfo = null;
|
||||
dateUpdated = null;
|
||||
settings = new GUI();
|
||||
config = new HashMap<String, Object>();
|
||||
|
|
@ -75,6 +78,13 @@ public class Paragraph extends Job implements Serializable, Cloneable {
|
|||
this.dateUpdated = new Date();
|
||||
}
|
||||
|
||||
public AuthenticationInfo getAuthenticationInfo() {
|
||||
return authenticationInfo;
|
||||
}
|
||||
|
||||
public void setAuthenticationInfo(AuthenticationInfo authenticationInfo) {
|
||||
this.authenticationInfo = authenticationInfo;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
|
|
@ -92,6 +102,11 @@ public class Paragraph extends Job implements Serializable, Cloneable {
|
|||
return note;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
Boolean enabled = (Boolean) config.get("enabled");
|
||||
return enabled == null || enabled.booleanValue();
|
||||
}
|
||||
|
||||
public String getRequiredReplName() {
|
||||
return getRequiredReplName(text);
|
||||
}
|
||||
|
|
@ -287,6 +302,7 @@ public class Paragraph extends Job implements Serializable, Cloneable {
|
|||
getId(),
|
||||
this.getTitle(),
|
||||
this.getText(),
|
||||
this.getAuthenticationInfo(),
|
||||
this.getConfig(),
|
||||
this.settings,
|
||||
registry,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,213 @@
|
|||
/*
|
||||
* 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.notebook.repo;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.microsoft.azure.storage.CloudStorageAccount;
|
||||
import com.microsoft.azure.storage.StorageException;
|
||||
import com.microsoft.azure.storage.file.*;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
||||
import org.apache.zeppelin.notebook.Note;
|
||||
import org.apache.zeppelin.notebook.NoteInfo;
|
||||
import org.apache.zeppelin.notebook.Paragraph;
|
||||
import org.apache.zeppelin.scheduler.Job;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import java.io.*;
|
||||
import java.net.URISyntaxException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Azure storage backend for notebooks
|
||||
*/
|
||||
public class AzureNotebookRepo implements NotebookRepo {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(S3NotebookRepo.class);
|
||||
|
||||
private final ZeppelinConfiguration conf;
|
||||
private final String user;
|
||||
private final String shareName;
|
||||
private final CloudFileDirectory rootDir;
|
||||
|
||||
public AzureNotebookRepo(ZeppelinConfiguration conf)
|
||||
throws URISyntaxException, InvalidKeyException, StorageException {
|
||||
this.conf = conf;
|
||||
user = conf.getString(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_AZURE_USER);
|
||||
shareName = conf.getString(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_AZURE_SHARE);
|
||||
|
||||
CloudStorageAccount account = CloudStorageAccount.parse(
|
||||
conf.getString(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_AZURE_CONNECTION_STRING));
|
||||
CloudFileClient client = account.createCloudFileClient();
|
||||
CloudFileShare share = client.getShareReference(shareName);
|
||||
share.createIfNotExists();
|
||||
|
||||
CloudFileDirectory userDir = StringUtils.isBlank(user) ?
|
||||
share.getRootDirectoryReference() :
|
||||
share.getRootDirectoryReference().getDirectoryReference(user);
|
||||
userDir.createIfNotExists();
|
||||
|
||||
rootDir = userDir.getDirectoryReference("notebook");
|
||||
rootDir.createIfNotExists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NoteInfo> list() throws IOException {
|
||||
List<NoteInfo> infos = new LinkedList<NoteInfo>();
|
||||
NoteInfo info = null;
|
||||
|
||||
for (ListFileItem item : rootDir.listFilesAndDirectories()) {
|
||||
if (item.getClass() == CloudFileDirectory.class) {
|
||||
CloudFileDirectory dir = (CloudFileDirectory) item;
|
||||
|
||||
try {
|
||||
if (dir.getFileReference("note.json").exists()) {
|
||||
info = new NoteInfo(getNote(dir.getName()));
|
||||
|
||||
if (info != null) {
|
||||
infos.add(info);
|
||||
}
|
||||
}
|
||||
} catch (StorageException | URISyntaxException e) {
|
||||
String msg = "Error enumerating notebooks from Azure storage";
|
||||
|
||||
LOG.error(msg, e);
|
||||
|
||||
throw new IOException(msg, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return infos;
|
||||
}
|
||||
|
||||
private Note getNote(String noteId) throws IOException {
|
||||
InputStream ins = null;
|
||||
|
||||
try {
|
||||
CloudFileDirectory dir = rootDir.getDirectoryReference(noteId);
|
||||
CloudFile file = dir.getFileReference("note.json");
|
||||
|
||||
ins = file.openRead();
|
||||
} catch (URISyntaxException | StorageException e) {
|
||||
String msg = String.format("Error reading notebook %s from Azure storage", noteId);
|
||||
|
||||
LOG.error(msg, e);
|
||||
|
||||
throw new IOException(msg, e);
|
||||
}
|
||||
|
||||
String json = IOUtils.toString(ins,
|
||||
conf.getString(ZeppelinConfiguration.ConfVars.ZEPPELIN_ENCODING));
|
||||
ins.close();
|
||||
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
gsonBuilder.setPrettyPrinting();
|
||||
Gson gson = gsonBuilder.create();
|
||||
|
||||
Note note = gson.fromJson(json, Note.class);
|
||||
|
||||
for (Paragraph p : note.getParagraphs()) {
|
||||
if (p.getStatus() == Job.Status.PENDING || p.getStatus() == Job.Status.RUNNING) {
|
||||
p.setStatus(Job.Status.ABORT);
|
||||
}
|
||||
}
|
||||
|
||||
return note;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Note get(String noteId) throws IOException {
|
||||
return getNote(noteId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(Note note) throws IOException {
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
gsonBuilder.setPrettyPrinting();
|
||||
Gson gson = gsonBuilder.create();
|
||||
String json = gson.toJson(note);
|
||||
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
Writer writer = new OutputStreamWriter(output);
|
||||
writer.write(json);
|
||||
writer.close();
|
||||
output.close();
|
||||
|
||||
byte[] buffer = output.toByteArray();
|
||||
|
||||
try {
|
||||
CloudFileDirectory dir = rootDir.getDirectoryReference(note.getId());
|
||||
dir.createIfNotExists();
|
||||
|
||||
CloudFile cloudFile = dir.getFileReference("note.json");
|
||||
cloudFile.uploadFromByteArray(buffer, 0, buffer.length);
|
||||
} catch (URISyntaxException | StorageException e) {
|
||||
String msg = String.format("Error saving notebook %s to Azure storage", note.getId());
|
||||
|
||||
LOG.error(msg, e);
|
||||
|
||||
throw new IOException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
// unfortunately, we need to use a recursive delete here
|
||||
private void delete(ListFileItem item) throws StorageException {
|
||||
if (item.getClass() == CloudFileDirectory.class) {
|
||||
CloudFileDirectory dir = (CloudFileDirectory) item;
|
||||
|
||||
for (ListFileItem subItem : dir.listFilesAndDirectories()) {
|
||||
delete(subItem);
|
||||
}
|
||||
|
||||
dir.deleteIfExists();
|
||||
} else if (item.getClass() == CloudFile.class) {
|
||||
CloudFile file = (CloudFile) item;
|
||||
|
||||
file.deleteIfExists();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(String noteId) throws IOException {
|
||||
try {
|
||||
CloudFileDirectory dir = rootDir.getDirectoryReference(noteId);
|
||||
|
||||
delete(dir);
|
||||
} catch (URISyntaxException | StorageException e) {
|
||||
String msg = String.format("Error deleting notebook %s from Azure storage", noteId);
|
||||
|
||||
LOG.error(msg, e);
|
||||
|
||||
throw new IOException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkpoint(String noteId, String checkPointName) throws IOException {
|
||||
// no-op
|
||||
LOG.info("Checkpoint feature isn't supported in {}", this.getClass().toString());
|
||||
}
|
||||
}
|
||||
|
|
@ -193,6 +193,6 @@ public class S3NotebookRepo implements NotebookRepo {
|
|||
@Override
|
||||
public void checkpoint(String noteId, String checkPointName) throws IOException {
|
||||
// no-op
|
||||
LOG.info("Checkpoint feature isn't suported in {}", this.getClass().toString());
|
||||
LOG.info("Checkpoint feature isn't supported in {}", this.getClass().toString());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,13 @@ public class VFSNotebookRepo implements NotebookRepo {
|
|||
} else {
|
||||
this.filesystemRoot = filesystemRoot;
|
||||
}
|
||||
|
||||
fsManager = VFS.getManager();
|
||||
FileObject file = fsManager.resolveFile(filesystemRoot.getPath());
|
||||
if (!file.exists()) {
|
||||
logger.info("Notebook dir doesn't exist, create.");
|
||||
file.createFolder();
|
||||
}
|
||||
}
|
||||
|
||||
private String getPath(String path) {
|
||||
|
|
@ -247,7 +253,7 @@ public class VFSNotebookRepo implements NotebookRepo {
|
|||
@Override
|
||||
public void checkpoint(String noteId, String checkPointName) throws IOException {
|
||||
// no-op
|
||||
logger.info("Checkpoint feature isn't suported in {}", this.getClass().toString());
|
||||
logger.info("Checkpoint feature isn't supported in {}", this.getClass().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,11 @@
|
|||
package org.apache.zeppelin.conf;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.apache.commons.configuration.ConfigurationException;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
|
|
@ -28,6 +32,11 @@ import java.util.List;
|
|||
* Created by joelz on 8/19/15.
|
||||
*/
|
||||
public class ZeppelinConfigurationTest {
|
||||
@Before
|
||||
public void clearSystemVariables() {
|
||||
System.clearProperty(ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllowedOrigins2Test() throws MalformedURLException, ConfigurationException {
|
||||
|
||||
|
|
@ -70,4 +79,12 @@ public class ZeppelinConfigurationTest {
|
|||
Boolean isIt = conf.isWindowsPath("~/test/file.xml");
|
||||
Assert.assertFalse(isIt);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNotebookDirTest() throws ConfigurationException {
|
||||
|
||||
ZeppelinConfiguration conf = new ZeppelinConfiguration(this.getClass().getResource("/zeppelin-site.xml"));
|
||||
String notebookLocation = conf.getNotebookDir();
|
||||
Assert.assertEquals("notebook", notebookLocation);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class InterpreterFactoryTest {
|
|||
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);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -197,20 +197,38 @@ public class NotebookTest implements JobListenerFactory{
|
|||
public void testRunAll() throws IOException {
|
||||
Note note = notebook.createNote();
|
||||
note.getNoteReplLoader().setInterpreters(factory.getDefaultInterpreterSettingList());
|
||||
|
||||
// p1
|
||||
Paragraph p1 = note.addParagraph();
|
||||
Map config = p1.getConfig();
|
||||
config.put("enabled", true);
|
||||
p1.setConfig(config);
|
||||
Map config1 = p1.getConfig();
|
||||
config1.put("enabled", true);
|
||||
p1.setConfig(config1);
|
||||
p1.setText("p1");
|
||||
|
||||
// p2
|
||||
Paragraph p2 = note.addParagraph();
|
||||
Map config1 = p2.getConfig();
|
||||
p2.setConfig(config1);
|
||||
Map config2 = p2.getConfig();
|
||||
config2.put("enabled", false);
|
||||
p2.setConfig(config2);
|
||||
p2.setText("p2");
|
||||
assertEquals(null, p2.getResult());
|
||||
|
||||
// p3
|
||||
Paragraph p3 = note.addParagraph();
|
||||
p3.setText("p3");
|
||||
|
||||
// when
|
||||
note.runAll();
|
||||
|
||||
while(p2.isTerminated()==false || p2.getResult()==null) Thread.yield();
|
||||
assertEquals("repl1: p2", p2.getResult().message());
|
||||
// wait for finish
|
||||
while(p3.isTerminated()==false) {
|
||||
Thread.yield();
|
||||
}
|
||||
|
||||
assertEquals("repl1: p1", p1.getResult().message());
|
||||
assertNull(p2.getResult());
|
||||
assertEquals("repl1: p3", p3.getResult().message());
|
||||
|
||||
notebook.removeNote(note.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Reference in a new issue