Merge remote-tracking branch 'origin/master' into ZEPPELIN-1149

# Conflicts:
#	docs/interpreter/shell.md
This commit is contained in:
Rohit Choudhary 2016-07-12 23:27:38 +05:30
commit 1924b99d3f
30 changed files with 137 additions and 92 deletions

2
.gitignore vendored
View file

@ -51,7 +51,7 @@ zeppelin-web/bower_components
# project level
/logs/
/run/
/metastore_db/
**/metastore_db/
/*.log
/jobs/
/zan-repo/

View file

@ -68,15 +68,6 @@ public class AlluxioInterpreter extends Interpreter {
alluxioMasterPort = property.getProperty(ALLUXIO_MASTER_PORT);
}
static {
Interpreter.register("alluxio", "alluxio",
AlluxioInterpreter.class.getName(),
new InterpreterPropertyBuilder()
.add(ALLUXIO_MASTER_HOSTNAME, "localhost", "Alluxio master hostname")
.add(ALLUXIO_MASTER_PORT, "19998", "Alluxio master port")
.build());
}
@Override
public void open() {
logger.info("Starting Alluxio shell to connect to " + alluxioMasterHostname +
@ -116,14 +107,14 @@ public class AlluxioInterpreter extends Interpreter {
System.setOut(ps);
for (String command : commands) {
int commandResuld = 1;
int commandResult = 1;
String[] args = splitAndRemoveEmpty(command, " ");
if (args.length > 0 && args[0].equals("help")) {
System.out.println(getCommandList());
} else {
commandResuld = fs.run(args);
commandResult = fs.run(args);
}
if (commandResuld != 0) {
if (commandResult != 0) {
isSuccess = false;
break;
} else {

View file

@ -0,0 +1,21 @@
[
{
"group": "alluxio",
"name": "alluxio",
"className": "org.apache.zeppelin.alluxio.AlluxioInterpreter",
"properties": {
"alluxio.master.hostname": {
"envName": "ALLUXIO_MASTER_HOSTNAME",
"propertyName": "alluxio.master.hostname",
"defaultValue": "localhost",
"description": "Alluxio master hostname"
},
"alluxio.master.port": {
"envName": "ALLUXIO_MASTER_PORT",
"propertyName": "alluxio.master.port",
"defaultValue": "19998",
"description": "Alluxio master port"
}
}
}
]

View file

@ -64,7 +64,7 @@
<li><a href="{{BASE_PATH}}/interpreter/postgresql.html">Postgresql, HAWQ</a></li>
<li><a href="{{BASE_PATH}}/interpreter/r.html">R</a></li>
<li><a href="{{BASE_PATH}}/interpreter/scalding.html">Scalding</a></li>
<li><a href="{{BASE_PATH}}/pleasecontribute.html">Shell</a></li>
<li><a href="{{BASE_PATH}}/interpreter/shell.html">Shell</a></li>
<li><a href="{{BASE_PATH}}/interpreter/spark.html">Spark</a></li>
</ul>
</li>

View file

@ -2,7 +2,7 @@
layout: page
title: "Alluxio Interpreter"
description: "Alluxio Interpreter"
group: manual
group: interpreter
---
{% include JB/setup %}

View file

@ -2,7 +2,7 @@
layout: page
title: "Cassandra Interpreter"
description: "Cassandra Interpreter"
group: manual
group: interpreter
---
{% include JB/setup %}

View file

@ -2,7 +2,7 @@
layout: page
title: "Elasticsearch Interpreter"
description: ""
group: manual
group: interpreter
---
{% include JB/setup %}

View file

@ -2,7 +2,7 @@
layout: page
title: "Flink Interpreter"
description: ""
group: manual
group: interpreter
---
{% include JB/setup %}

View file

@ -2,7 +2,7 @@
layout: page
title: "Geode OQL Interpreter"
description: ""
group: manual
group: interpreter
---
{% include JB/setup %}

View file

@ -2,7 +2,7 @@
layout: page
title: "HBase Shell Interpreter"
description: ""
group: manual
group: interpreter
---
{% include JB/setup %}

View file

@ -2,7 +2,7 @@
layout: page
title: "HDFS File System Interpreter"
description: ""
group: manual
group: interpreter
---
{% include JB/setup %}

View file

@ -2,7 +2,7 @@
layout: page
title: "Hive Interpreter"
description: ""
group: manual
group: interpreter
---
{% include JB/setup %}

View file

@ -2,7 +2,7 @@
layout: page
title: "Ignite Interpreter"
description: "Ignite user guide"
group: manual
group: interpreter
---
{% include JB/setup %}

View file

@ -2,7 +2,7 @@
layout: page
title: "Generic JDBC Interpreter"
description: "JDBC user guide"
group: manual
group: interpreter
---
{% include JB/setup %}

View file

@ -2,7 +2,7 @@
layout: page
title: "Lens Interpreter"
description: "Lens user guide"
group: manual
group: interpreter
---
{% include JB/setup %}

View file

@ -2,7 +2,7 @@
layout: page
title: "Livy Interpreter"
description: ""
group: manual
group: interpreter
---
{% include JB/setup %}

View file

@ -2,7 +2,7 @@
layout: page
title: "Markdown Interpreter"
description: "Markdown Interpreter"
group: manual
group: interpreter
---
{% include JB/setup %}

View file

@ -2,7 +2,7 @@
layout: page
title: "PostgreSQL and HAWQ Interpreter"
description: ""
group: manual
group: interpreter
---
{% include JB/setup %}

View file

@ -2,7 +2,7 @@
layout: page
title: "Python Interpreter"
description: "Python Interpreter"
group: manual
group: interpreter
---
{% include JB/setup %}

View file

@ -2,7 +2,7 @@
layout: page
title: "R Interpreter"
description: ""
group: manual
group: interpreter
---
{% include JB/setup %}

View file

@ -2,7 +2,7 @@
layout: page
title: "Scalding Interpreter"
description: ""
group: manual
group: interpreter
---
{% include JB/setup %}

View file

@ -1,43 +1,40 @@
---
layout: page
title: "Shell Interpreter"
description: "Shell Interpreter"
group: manual
---
{% include JB/setup %}
## Shell interpreter for Apache Zeppelin
### Overview
Shell interpreter uses [Apache Commons Exec](https://commons.apache.org/proper/commons-exec) to execute external processes.
In Zeppelin notebook, you can use ` %sh ` in the beginning of a paragraph to invoke system shell and run commands.
Note: Currently each command runs as Zeppelin user.
## Properties
You can modify the interpreter configuration in the `Interpreter` section. The most common properties are as follows, but you can specify other properties that need to be connected.
<table class="table-configuration">
<tr>
<td>shell.command.timeout.millisecs</td>
<td>Shell command time out in millisecs. Default = 60000</td>
</tr>
<tr>
<td>zeppelin.shell.auth.type</td>
<td>Types of authentications' methods supported are SIMPLE, and KERBEROS</td>
</tr>
<tr>
<td>zeppelin.shell.principal</td>
<td>The principal name to load from the keytab</td>
</tr>
<tr>
<td>zeppelin.shell.keytab.location</td>
<td>The path to the keytab file</td>
</tr>
</table>
### Example
The following example demonstrates the basic usage of Shell in a Zeppelin notebook.
<img src="{{BASE_PATH}}/assets/themes/zeppelin/img/docs-img/shell-example.png" width="70%" />
---
layout: page
title: "Shell Interpreter"
description: "Shell Interpreter"
group: interpreter
---
{% include JB/setup %}
# Shell interpreter for Apache Zeppelin
<div id="toc"></div>
## Overview
Shell interpreter uses [Apache Commons Exec](https://commons.apache.org/proper/commons-exec) to execute external processes.
In Zeppelin notebook, you can use ` %sh ` in the beginning of a paragraph to invoke system shell and run commands.
> **Note :** Currently each command runs as the user Zeppelin server is running as.
## Configuration
At the "Interpreters" menu in Zeppelin dropdown menu, you can set the property value for Shell interpreter.
<table class="table-configuration">
<tr>
<th>Name</th>
<th>Value</th>
<th>Description</th>
</tr>
<tr>
<td>shell.command.timeout.millisecs</td>
<td>60000</td>
<td>Shell command time out in millisecs</td>
</tr>
</table>
## Example
The following example demonstrates the basic usage of Shell in a Zeppelin notebook.
<img src="{{BASE_PATH}}/assets/themes/zeppelin/img/docs-img/shell-example.png" />
If you need further information about **Zeppelin Interpreter Setting** for using Shell interpreter, please read [What is interpreter setting?](../manual/interpreters.html#what-is-interpreter-setting) section first.

View file

@ -2,7 +2,7 @@
layout: page
title: "Spark Interpreter Group"
description: ""
group: manual
group: interpreter
---
{% include JB/setup %}

View file

@ -19,14 +19,18 @@ limitations under the License.
-->
{% include JB/setup %}
## Zeppelin REST API
Zeppelin provides several REST APIs for interaction and remote activation of zeppelin functionality.
# Apache Zeppelin Credential REST API
All REST APIs are available starting with the following endpoint `http://[zeppelin-server]:[zeppelin-port]/api`. Note that zeppelin REST APIs receive or return JSON objects, it is recommended for you to install some JSON viewers such as [JSONView](https://chrome.google.com/webstore/detail/jsonview/chklaanhfefbnpoihckbnefhakgolnmc).
<div id="toc"></div>
If you work with Zeppelin and find a need for an additional REST API, please [file an issue or send us mail](http://zeppelin.apache.org/community.html).
## Overview
Apache Zeppelin provides several REST APIs for interaction and remote activation of zeppelin functionality.
All REST APIs are available starting with the following endpoint `http://[zeppelin-server]:[zeppelin-port]/api`.
Note that Apache Zeppelin REST APIs receive or return JSON objects, it is recommended for you to install some JSON viewers such as [JSONView](https://chrome.google.com/webstore/detail/jsonview/chklaanhfefbnpoihckbnefhakgolnmc).
<br />
If you work with Apache Zeppelin and find a need for an additional REST API, please [file an issue or send us an email](http://zeppelin.apache.org/community.html).
<br />
## Credential REST API List
### List Credential information
@ -34,7 +38,7 @@ limitations under the License.
<col width="200">
<tr>
<td>Description</td>
<td>This ```GET``` method returns all key/value pairs of credential information on the server.</td>
<td>This ```GET``` method returns all key/value pairs of the credential information on the server.</td>
</tr>
<tr>
<td>URL</td>
@ -78,7 +82,7 @@ limitations under the License.
<col width="200">
<tr>
<td>Description</td>
<td>This ```PUT``` method creates an credential information with new properties.</td>
<td>This ```PUT``` method creates the credential information with new properties.</td>
</tr>
<tr>
<td>URL</td>
@ -124,7 +128,7 @@ limitations under the License.
<col width="200">
<tr>
<td>Description</td>
<td>This ```DELETE``` method deletes credential information.</td>
<td>This ```DELETE``` method deletes the credential information.</td>
</tr>
<tr>
<td>URL</td>
@ -154,7 +158,7 @@ limitations under the License.
<col width="200">
<tr>
<td>Description</td>
<td>This ```DELETE``` method deletes an given credential entity.</td>
<td>This ```DELETE``` method deletes a given credential entity.</td>
</tr>
<tr>
<td>URL</td>

View file

@ -48,7 +48,6 @@ public class LivyHelper {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
HashMap<String, Object> paragraphHttpMap = new HashMap<>();
Properties property;
Integer MAX_NOS_RETRY = 60;
LivyHelper(Properties property) {
this.property = property;
@ -83,9 +82,17 @@ public class LivyHelper {
}.getType());
Integer sessionId = ((Double) jsonMap.get("id")).intValue();
if (!jsonMap.get("state").equals("idle")) {
Integer nosRetry = MAX_NOS_RETRY;
Integer retryCount = 60;
while (nosRetry >= 0) {
try {
retryCount = Integer.valueOf(
property.getProperty("zeppelin.livy.create.session.retries"));
} catch (Exception e) {
LOGGER.info("zeppelin.livy.create.session.retries property is not configured." +
" Using default retry count.");
}
while (retryCount >= 0) {
LOGGER.error(String.format("sessionId:%s state is %s",
jsonMap.get("id"), jsonMap.get("state")));
Thread.sleep(1000);
@ -108,10 +115,10 @@ public class LivyHelper {
LOGGER.error(String.format("Cannot start %s.\n%s", kind, logs));
throw new Exception(String.format("Cannot start %s.\n%s", kind, logs));
}
nosRetry--;
retryCount--;
}
if (nosRetry <= 0) {
LOGGER.error("Error getting session for user within 60Sec.");
if (retryCount <= 0) {
LOGGER.error("Error getting session for user within the configured number of retries.");
throw new Exception(String.format("Cannot start %s.", kind));
}
}

View file

@ -11,6 +11,12 @@
"defaultValue": "http://localhost:8998",
"description": "The URL for Livy Server."
},
"zeppelin.livy.create.session.retries": {
"envName": "ZEPPELIN_LIVY_CREATE_SESSION_RETRIES",
"propertyName": "zeppelin.livy.create.session.retries",
"defaultValue": "120",
"description": "Livy Server create session retry count."
},
"livy.spark.master": {
"propertyName": "livy.spark.master",
"defaultValue": "local[*]",

View file

@ -66,4 +66,8 @@ angular.module('zeppelinWebApp').controller('HomeCtrl', function($scope, noteboo
node.hidden = !node.hidden;
};
angular.element('#loginModal').on('hidden.bs.modal', function(e) {
$rootScope.$broadcast('initLoginValues');
});
});

View file

@ -93,6 +93,10 @@ angular.module('zeppelinWebApp').controller('NotebookCtrl', function($scope, $ro
$('html, body').scrollTo({top: top, left: 0});
}
// force notebook reload on user change
$scope.$on('setNoteMenu', function(event, note) {
initNotebook();
});
},
1000
);

View file

@ -39,5 +39,15 @@ angular.module('zeppelinWebApp').controller('LoginCtrl',
});
};
$scope.$on('initLoginValues', function() {
initValues();
});
var initValues = function() {
$scope.loginParams = {
userName: '',
password: ''
};
};
}
);

View file

@ -16,9 +16,11 @@
angular.module('zeppelinWebApp').service('SaveAsService', function(browserDetectService) {
this.SaveAs = function(content, filename, extension) {
var BOM = '\uFEFF';
if (browserDetectService.detectIE()) {
angular.element('body').append('<iframe id="SaveAsId" style="display: none"></iframe>');
var frameSaveAs = angular.element('body > iframe#SaveAsId')[0].contentWindow;
content = BOM + content;
frameSaveAs.document.open('text/json', 'replace');
frameSaveAs.document.write(content);
frameSaveAs.document.close();
@ -34,7 +36,7 @@ angular.module('zeppelinWebApp').service('SaveAsService', function(browserDetect
}
angular.element('body > iframe#SaveAsId').remove();
} else {
content = 'data:image/svg;charset=utf-8,' + encodeURIComponent(content);
content = 'data:image/svg;charset=utf-8,' + BOM + encodeURIComponent(content);
angular.element('body').append('<a id="SaveAsId"></a>');
var saveAsElement = angular.element('body > a#SaveAsId');
saveAsElement.attr('href', content);
@ -44,5 +46,4 @@ angular.module('zeppelinWebApp').service('SaveAsService', function(browserDetect
saveAsElement.remove();
}
};
});