You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zeppelin.apache.org by GitBox <gi...@apache.org> on 2020/01/20 01:56:47 UTC
[GitHub] [zeppelin] tokenian opened a new pull request #3612: add MongoDB
interpreter
tokenian opened a new pull request #3612: add MongoDB interpreter
URL: https://github.com/apache/zeppelin/pull/3612
### What is this PR for?
add interpreter for mongodb
### What type of PR is it?
[Feature]
### Todos
* [ ] - Task
### What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-4571
### How should this be tested?
unit test supplied
### Screenshots (if appropriate)
### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? Yes,Updated
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian commented on a change in pull request #3612:
[ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
tokenian commented on a change in pull request #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#discussion_r373906723
##########
File path: mongodb/src/main/java/org/apache/zeppelin/mongodb/MongoDbInterpreter.java
##########
@@ -0,0 +1,209 @@
+/*
+ * 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.mongodb;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Scanner;
+
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.ExecuteException;
+import org.apache.commons.exec.ExecuteWatchdog;
+import org.apache.commons.exec.Executor;
+import org.apache.commons.exec.PumpStreamHandler;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.zeppelin.interpreter.Interpreter;
+import org.apache.zeppelin.interpreter.InterpreterContext;
+import org.apache.zeppelin.interpreter.InterpreterResult;
+import org.apache.zeppelin.interpreter.InterpreterResult.Code;
+import org.apache.zeppelin.scheduler.Scheduler;
+import org.apache.zeppelin.scheduler.SchedulerFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * MongoDB interpreter. It uses the mongo shell to interpret the commands.
+ */
+public class MongoDbInterpreter extends Interpreter {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(MongoDbInterpreter.class);
+
+ private static final String SHELL_EXTENSION =
+ new Scanner(MongoDbInterpreter.class.getResourceAsStream("/shell_extension.js"), "UTF-8")
+ .useDelimiter("\\A").next();
+
+ private static final int SIGTERM_CODE = 143;
+
+ private long commandTimeout = 60000;
+
+ private String dbAddress;
+
+ private int maxConcurrency = 10;
+
+ private Map<String, Executor> runningProcesses = new HashMap<>();
+
+ public MongoDbInterpreter(Properties property) {
+ super(property);
+ }
+
+ @Override
+ public void open() {
+ commandTimeout = Long.parseLong(getProperty("mongo.shell.command.timeout"));
+ maxConcurrency = Integer.parseInt(getProperty("mongo.interpreter.concurrency.max"));
+ dbAddress = getProperty("mongo.server.host") + ":"
+ + getProperty("mongo.server.port") + "/"
+ + getProperty("mongo.server.database");
+ }
+
+ @Override
+ public void close() {
+ runningProcesses.clear();
+ runningProcesses = null;
+ }
+
+ @Override
+ public FormType getFormType() {
+ return FormType.SIMPLE;
+ }
+
+ @Override
+ public InterpreterResult interpret(String script, InterpreterContext context) {
+ LOGGER.debug("Run MongoDB script: {}", script);
+
+ if (StringUtils.isEmpty(script)) {
+ return new InterpreterResult(Code.SUCCESS);
+ }
+
+ String paragraphId = context.getParagraphId();
+ // Write script in a temporary file
+ // The script is enriched with extensions
+ final File scriptFile = new File(getScriptFileName(paragraphId));
+ try {
+ FileUtils.write(scriptFile,
+ SHELL_EXTENSION
+ .replace("__ZEPPELIN_TABLE_LIMIT__", getProperty("mongo.shell.command.table.limit")) +
+ script);
+ }
+ catch (IOException e) {
+ LOGGER.error("Can not write script in temp file", e);
+ return new InterpreterResult(Code.ERROR, e.getMessage());
+ }
+
+ InterpreterResult result = new InterpreterResult(InterpreterResult.Code.SUCCESS);
+
+ final DefaultExecutor executor = new DefaultExecutor();
+ final ByteArrayOutputStream errorStream = new ByteArrayOutputStream();
+
+ executor.setStreamHandler(new PumpStreamHandler(context.out, errorStream));
+ executor.setWatchdog(new ExecuteWatchdog(commandTimeout));
+
+ final CommandLine cmdLine = CommandLine.parse(getProperty("mongo.shell.path"));
+ cmdLine.addArgument("--quiet", false);
+
+ if (!StringUtils.isEmpty(getProperty("mongo.server.username"))) {
+ cmdLine.addArgument("-u", false);
+ cmdLine.addArgument(getProperty("mongo.server.username"), false);
+ cmdLine.addArgument("-p", false);
+ cmdLine.addArgument(getProperty("mongo.server.password"), false);
Review comment:
ok,I'll try
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on issue #3612: [ZEPPELIN-4571] Add
MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
zjffdu commented on issue #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-585654428
ping @tokenian
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] asfgit closed pull request #3612: [ZEPPELIN-4571] Add
MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian commented on a change in pull request #3612:
[ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
tokenian commented on a change in pull request #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#discussion_r384994328
##########
File path: bin/interpreter.sh
##########
@@ -69,7 +69,7 @@ fi
. "${bin}/common.sh"
-ZEPPELIN_INTERPRETER_API_JAR=$(find "${ZEPPELIN_HOME}/interpreter" -name 'zeppelin-interpreter-shaded-*.jar')
+ZEPPELIN_INTERPRETER_API_JAR=$(find "${ZEPPELIN_HOME}/interpreter" -name 'zeppelin-interpreter-api-*.jar')
Review comment:
I use git -X ours to add my commits on top of master.Thanks a lot
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu edited a comment on issue #3612: [ZEPPELIN-4571]
Add MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
zjffdu edited a comment on issue #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-589454444
@tokenian Could you check the travis CI ? https://zeppelin.apache.org/contribution/contributions.html
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on a change in pull request #3612: add
MongoDB interpreter
Posted by GitBox <gi...@apache.org>.
zjffdu commented on a change in pull request #3612: add MongoDB interpreter
URL: https://github.com/apache/zeppelin/pull/3612#discussion_r369001907
##########
File path: mongodb/src/main/java/org/apache/zeppelin/mongodb/MongoDbInterpreter.java
##########
@@ -0,0 +1,190 @@
+/*
+ * 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.mongodb;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Scanner;
+
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.ExecuteException;
+import org.apache.commons.exec.ExecuteWatchdog;
+import org.apache.commons.exec.Executor;
+import org.apache.commons.exec.PumpStreamHandler;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.zeppelin.interpreter.Interpreter;
+import org.apache.zeppelin.interpreter.InterpreterContext;
+import org.apache.zeppelin.interpreter.InterpreterResult;
+import org.apache.zeppelin.interpreter.InterpreterResult.Code;
+import org.apache.zeppelin.scheduler.Scheduler;
+import org.apache.zeppelin.scheduler.SchedulerFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * MongoDB interpreter. It uses the mongo shell to interpret the commands.
+ *
+ */
+public class MongoDbInterpreter extends Interpreter {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(MongoDbInterpreter.class);
+
+ private static final String SHELL_EXTENSION =
+ new Scanner(MongoDbInterpreter.class.getResourceAsStream("/shell_extension.js"), "UTF-8")
+ .useDelimiter("\\A").next();
+
+ private long commandTimeout = 60000;
+
+ private String dbAddress;
+
+ private Map<String, Executor> runningProcesses = new HashMap<>();
+
+
+ public MongoDbInterpreter(Properties property) {
+ super(property);
+ }
+
+ @Override
+ public void open() {
+ commandTimeout = Long.parseLong(getProperty("mongo.shell.command.timeout"));
+ dbAddress = getProperty("mongo.server.host") + ":"
+ + getProperty("mongo.server.port") + "/"
+ + getProperty("mongo.server.database");
+ }
+
+ @Override
+ public void close() {
+ //Nothing to do
+ }
+
+ @Override
+ public FormType getFormType() {
+ return FormType.SIMPLE;
+ }
+
+ @Override
+ public InterpreterResult interpret(String script, InterpreterContext context) {
+ LOGGER.debug("Run MongoDB script: {}", script);
+
+ if (StringUtils.isEmpty(script)) {
+ return new InterpreterResult(Code.SUCCESS);
+ }
+
+ // Write script in a temporary file
+ // The script is enriched with extensions
+ final File scriptFile = new File(getScriptFileName(context.getParagraphId()));
+ try {
+ FileUtils.write(scriptFile,
+ SHELL_EXTENSION
+ .replace("__ZEPPELIN_TABLE_LIMIT__", getProperty("mongo.shell.command.table.limit")) +
+ script);
+ }
+ catch (IOException e) {
+ LOGGER.error("Can not write script in temp file", e);
+ return new InterpreterResult(Code.ERROR, e.getMessage());
+ }
+
+ InterpreterResult result = new InterpreterResult(InterpreterResult.Code.SUCCESS);
+
+ final DefaultExecutor executor = new DefaultExecutor();
+ final ByteArrayOutputStream errorStream = new ByteArrayOutputStream();
+ executor.setStreamHandler(new PumpStreamHandler(context.out, errorStream));
+ executor.setWatchdog(new ExecuteWatchdog(commandTimeout)); //ExecuteWatchdog.INFINITE_TIMEOUT
+
+ final CommandLine cmdLine = CommandLine.parse(getProperty("mongo.shell.path"));
+ cmdLine.addArgument("--quiet", false);
+
+ if (!StringUtils.isEmpty(getProperty("mongo.server.username"))) {
+ cmdLine.addArgument("-u", false);
+ cmdLine.addArgument(getProperty("mongo.server.username"), false);
+ cmdLine.addArgument("-p", false);
+ cmdLine.addArgument(getProperty("mongo.server.password"), false);
+
+ if (!StringUtils.isEmpty(getProperty("mongo.server.authentdatabase"))) {
+ cmdLine.addArgument("--authenticationDatabase", false);
+ cmdLine.addArgument(getProperty("mongo.server.authentdatabase"), false);
+ }
+ }
+
+ cmdLine.addArgument(dbAddress, false);
+ cmdLine.addArgument(scriptFile.getAbsolutePath(), false);
+
+ try {
+ executor.execute(cmdLine);
+ runningProcesses.put(context.getParagraphId(), executor);
Review comment:
Should remove it from `runningProcesses` after the process is completed
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu edited a comment on issue #3612: [ZEPPELIN-4571]
Add MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
zjffdu edited a comment on issue #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-591465413
@tokenian I just fixed the CI issue, Could you do a rebase again and resolve the conflict ? Thanks
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian commented on a change in pull request #3612:
[ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
tokenian commented on a change in pull request #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#discussion_r375877254
##########
File path: mongodb/pom.xml
##########
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>zeppelin-interpreter-parent</artifactId>
+ <groupId>org.apache.zeppelin</groupId>
+ <version>0.9.0-SNAPSHOT</version>
+ <relativePath>../zeppelin-interpreter-parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.zeppelin</groupId>
+ <artifactId>zeppelin-mongodb</artifactId>
+ <packaging>jar</packaging>
+ <version>0.9.0-SNAPSHOT</version>
+ <name>Zeppelin: MongoDB interpreter</name>
+
+ <properties>
+ <interpreter.name>mongodb</interpreter.name>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-shade-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+
+ <repositories>
+ <repository>
+ <id>apache-snap</id>
+ <name>apache snapshots</name>
+ <url>https://maven.aliyun.com/repository/apache-snapshots</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+
+ <repository>
+ <id>alimaven</id>
+ <name>Maven Aliyun Mirror</name>
Review comment:
yes
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian commented on issue #3612: add MongoDB
interpreter
Posted by GitBox <gi...@apache.org>.
tokenian commented on issue #3612: add MongoDB interpreter
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-576480438
@zjffdu ok,I will
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian commented on a change in pull request #3612:
[ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
tokenian commented on a change in pull request #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#discussion_r373835753
##########
File path: mongodb/src/main/java/org/apache/zeppelin/mongodb/MongoDbInterpreter.java
##########
@@ -0,0 +1,209 @@
+/*
+ * 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.mongodb;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Scanner;
+
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.ExecuteException;
+import org.apache.commons.exec.ExecuteWatchdog;
+import org.apache.commons.exec.Executor;
+import org.apache.commons.exec.PumpStreamHandler;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.zeppelin.interpreter.Interpreter;
+import org.apache.zeppelin.interpreter.InterpreterContext;
+import org.apache.zeppelin.interpreter.InterpreterResult;
+import org.apache.zeppelin.interpreter.InterpreterResult.Code;
+import org.apache.zeppelin.scheduler.Scheduler;
+import org.apache.zeppelin.scheduler.SchedulerFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * MongoDB interpreter. It uses the mongo shell to interpret the commands.
+ */
+public class MongoDbInterpreter extends Interpreter {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(MongoDbInterpreter.class);
+
+ private static final String SHELL_EXTENSION =
+ new Scanner(MongoDbInterpreter.class.getResourceAsStream("/shell_extension.js"), "UTF-8")
+ .useDelimiter("\\A").next();
+
+ private static final int SIGTERM_CODE = 143;
+
+ private long commandTimeout = 60000;
+
+ private String dbAddress;
+
+ private int maxConcurrency = 10;
+
+ private Map<String, Executor> runningProcesses = new HashMap<>();
+
+ public MongoDbInterpreter(Properties property) {
+ super(property);
+ }
+
+ @Override
+ public void open() {
+ commandTimeout = Long.parseLong(getProperty("mongo.shell.command.timeout"));
+ maxConcurrency = Integer.parseInt(getProperty("mongo.interpreter.concurrency.max"));
+ dbAddress = getProperty("mongo.server.host") + ":"
+ + getProperty("mongo.server.port") + "/"
+ + getProperty("mongo.server.database");
+ }
+
+ @Override
+ public void close() {
+ runningProcesses.clear();
+ runningProcesses = null;
+ }
+
+ @Override
+ public FormType getFormType() {
+ return FormType.SIMPLE;
+ }
+
+ @Override
+ public InterpreterResult interpret(String script, InterpreterContext context) {
+ LOGGER.debug("Run MongoDB script: {}", script);
+
+ if (StringUtils.isEmpty(script)) {
+ return new InterpreterResult(Code.SUCCESS);
+ }
+
+ String paragraphId = context.getParagraphId();
+ // Write script in a temporary file
+ // The script is enriched with extensions
+ final File scriptFile = new File(getScriptFileName(paragraphId));
+ try {
+ FileUtils.write(scriptFile,
+ SHELL_EXTENSION
+ .replace("__ZEPPELIN_TABLE_LIMIT__", getProperty("mongo.shell.command.table.limit")) +
+ script);
+ }
+ catch (IOException e) {
+ LOGGER.error("Can not write script in temp file", e);
+ return new InterpreterResult(Code.ERROR, e.getMessage());
+ }
+
+ InterpreterResult result = new InterpreterResult(InterpreterResult.Code.SUCCESS);
+
+ final DefaultExecutor executor = new DefaultExecutor();
+ final ByteArrayOutputStream errorStream = new ByteArrayOutputStream();
+
+ executor.setStreamHandler(new PumpStreamHandler(context.out, errorStream));
+ executor.setWatchdog(new ExecuteWatchdog(commandTimeout));
+
+ final CommandLine cmdLine = CommandLine.parse(getProperty("mongo.shell.path"));
+ cmdLine.addArgument("--quiet", false);
+
+ if (!StringUtils.isEmpty(getProperty("mongo.server.username"))) {
+ cmdLine.addArgument("-u", false);
+ cmdLine.addArgument(getProperty("mongo.server.username"), false);
+ cmdLine.addArgument("-p", false);
+ cmdLine.addArgument(getProperty("mongo.server.password"), false);
Review comment:
I don't get your point. If we want the data to be secure, we need to use --tls option in the mongo shell. `CommandLine` with option --quiet will be less chatty, not visible in the `ps` output. Although this interpreter has not provided the secure TLS option, it's a simple one.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on issue #3612: [ZEPPELIN-4571] Add
MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
zjffdu commented on issue #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-592268588
Will merge if no more comment
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian commented on issue #3612: [ZEPPELIN-4571] Add
MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
tokenian commented on issue #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-591897786
https://travis-ci.org/tokenian/zeppelin/jobs/655715790
https://travis-ci.org/tokenian/zeppelin/jobs/655715789
maybe some bug @zjffdu
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on issue #3612: [ZEPPELIN-4571] Add
MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
zjffdu commented on issue #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-590058560
What's the problem ? Could you paste the travis CI link ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian removed a comment on issue #3612:
[ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
tokenian removed a comment on issue #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-590225399
@zjffdu I have followed these instructions, [Development-workflow-with-Git](https://github.com/sevntu-checkstyle/sevntu.checkstyle/wiki/Development-workflow-with-Git:-Fork,-Branching,-Commits,-and-Pull-Request). rebase is too complicated. Could you give me some suggestions, I have no idea.
I have googled some answers, revert merge.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on issue #3612: [ZEPPELIN-4571] Add
MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
zjffdu commented on issue #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-586126967
@tokenian Could you resolve the conflicting ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] alexott commented on issue #3612: [ZEPPELIN-4571] Add
MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
alexott commented on issue #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-586128738
@tokenian look to the end of the PR - there are conflicts in the `pom.xml` file...
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian commented on issue #3612: add MongoDB
interpreter
Posted by GitBox <gi...@apache.org>.
tokenian commented on issue #3612: add MongoDB interpreter
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-576167216
@zjffdu I have written a simple doc in docs/interpreter/mongodb.md. By the way, this interpreter use javascript language.I'll add more details to help people to understand this interpreter.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on a change in pull request #3612:
[ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
zjffdu commented on a change in pull request #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#discussion_r375717975
##########
File path: docs/_includes/themes/zeppelin/_navigation.html
##########
@@ -157,6 +157,7 @@
<li><a href="{{BASE_PATH}}/interpreter/shell.html">Shell</a></li>
<li><a href="{{BASE_PATH}}/interpreter/sparql.html">Sparql</a></li>
<li><a href="{{BASE_PATH}}/interpreter/submarine.html">Submarine</a></li>
+ <li><a href="{{BASE_PATH}}/interpreter/mongodb.html">MongoDB</a></li>
Review comment:
Put it after `Markdown`, we order interpreters by alphabet.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on a change in pull request #3612: add
MongoDB interpreter
Posted by GitBox <gi...@apache.org>.
zjffdu commented on a change in pull request #3612: add MongoDB interpreter
URL: https://github.com/apache/zeppelin/pull/3612#discussion_r369002295
##########
File path: mongodb/src/main/java/org/apache/zeppelin/mongodb/MongoDbInterpreter.java
##########
@@ -0,0 +1,190 @@
+/*
+ * 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.mongodb;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Scanner;
+
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.ExecuteException;
+import org.apache.commons.exec.ExecuteWatchdog;
+import org.apache.commons.exec.Executor;
+import org.apache.commons.exec.PumpStreamHandler;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.zeppelin.interpreter.Interpreter;
+import org.apache.zeppelin.interpreter.InterpreterContext;
+import org.apache.zeppelin.interpreter.InterpreterResult;
+import org.apache.zeppelin.interpreter.InterpreterResult.Code;
+import org.apache.zeppelin.scheduler.Scheduler;
+import org.apache.zeppelin.scheduler.SchedulerFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * MongoDB interpreter. It uses the mongo shell to interpret the commands.
+ *
+ */
+public class MongoDbInterpreter extends Interpreter {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(MongoDbInterpreter.class);
+
+ private static final String SHELL_EXTENSION =
+ new Scanner(MongoDbInterpreter.class.getResourceAsStream("/shell_extension.js"), "UTF-8")
+ .useDelimiter("\\A").next();
+
+ private long commandTimeout = 60000;
+
+ private String dbAddress;
+
+ private Map<String, Executor> runningProcesses = new HashMap<>();
+
+
+ public MongoDbInterpreter(Properties property) {
+ super(property);
+ }
+
+ @Override
+ public void open() {
+ commandTimeout = Long.parseLong(getProperty("mongo.shell.command.timeout"));
+ dbAddress = getProperty("mongo.server.host") + ":"
+ + getProperty("mongo.server.port") + "/"
+ + getProperty("mongo.server.database");
+ }
+
+ @Override
+ public void close() {
+ //Nothing to do
+ }
+
+ @Override
+ public FormType getFormType() {
+ return FormType.SIMPLE;
+ }
+
+ @Override
+ public InterpreterResult interpret(String script, InterpreterContext context) {
+ LOGGER.debug("Run MongoDB script: {}", script);
+
+ if (StringUtils.isEmpty(script)) {
+ return new InterpreterResult(Code.SUCCESS);
+ }
+
+ // Write script in a temporary file
+ // The script is enriched with extensions
+ final File scriptFile = new File(getScriptFileName(context.getParagraphId()));
+ try {
+ FileUtils.write(scriptFile,
+ SHELL_EXTENSION
+ .replace("__ZEPPELIN_TABLE_LIMIT__", getProperty("mongo.shell.command.table.limit")) +
+ script);
+ }
+ catch (IOException e) {
+ LOGGER.error("Can not write script in temp file", e);
+ return new InterpreterResult(Code.ERROR, e.getMessage());
+ }
+
+ InterpreterResult result = new InterpreterResult(InterpreterResult.Code.SUCCESS);
+
+ final DefaultExecutor executor = new DefaultExecutor();
+ final ByteArrayOutputStream errorStream = new ByteArrayOutputStream();
+ executor.setStreamHandler(new PumpStreamHandler(context.out, errorStream));
+ executor.setWatchdog(new ExecuteWatchdog(commandTimeout)); //ExecuteWatchdog.INFINITE_TIMEOUT
+
+ final CommandLine cmdLine = CommandLine.parse(getProperty("mongo.shell.path"));
+ cmdLine.addArgument("--quiet", false);
+
+ if (!StringUtils.isEmpty(getProperty("mongo.server.username"))) {
+ cmdLine.addArgument("-u", false);
+ cmdLine.addArgument(getProperty("mongo.server.username"), false);
+ cmdLine.addArgument("-p", false);
+ cmdLine.addArgument(getProperty("mongo.server.password"), false);
+
+ if (!StringUtils.isEmpty(getProperty("mongo.server.authentdatabase"))) {
+ cmdLine.addArgument("--authenticationDatabase", false);
+ cmdLine.addArgument(getProperty("mongo.server.authentdatabase"), false);
+ }
+ }
+
+ cmdLine.addArgument(dbAddress, false);
+ cmdLine.addArgument(scriptFile.getAbsolutePath(), false);
+
+ try {
+ executor.execute(cmdLine);
+ runningProcesses.put(context.getParagraphId(), executor);
+ }
+ catch (ExecuteException e) {
+ LOGGER.error("Can not run script in paragraph {}", context.getParagraphId(), e);
+
+ final int exitValue = e.getExitValue();
+ Code code = Code.ERROR;
+ String msg = errorStream.toString();
+ if (exitValue == 143) {
+ code = Code.INCOMPLETE;
+ msg = msg + "Paragraph received a SIGTERM.\n";
+ LOGGER.info("The paragraph {} stopped executing: {}", context.getParagraphId(), msg);
+ }
+ msg += "ExitValue: " + exitValue;
+ result = new InterpreterResult(code, msg);
+ }
+ catch (IOException e) {
+ LOGGER.error("Can not run script in paragraph {}", context.getParagraphId(), e);
+ result = new InterpreterResult(Code.ERROR, e.getMessage());
+ }
+ finally {
+ FileUtils.deleteQuietly(scriptFile);
+ }
+
+ return result;
+ }
+
+ @Override
+ public int getProgress(InterpreterContext context) {
+ return 0;
+ }
+
+ @Override
+ public void cancel(InterpreterContext context) {
+ stopProcess(context.getParagraphId());
+ FileUtils.deleteQuietly(new File(getScriptFileName(context.getParagraphId())));
+ }
+
+ @Override
+ public Scheduler getScheduler() {
+ return SchedulerFactory.singleton().createOrGetParallelScheduler("mongo", 10);
Review comment:
10 is hard coded, should it be configurable ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on issue #3612: add MongoDB interpreter
Posted by GitBox <gi...@apache.org>.
zjffdu commented on issue #3612: add MongoDB interpreter
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-576163899
@tokenian Could you attach any screenshot which would help me and others to understand what this interpreter does
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on a change in pull request #3612: add
MongoDB interpreter
Posted by GitBox <gi...@apache.org>.
zjffdu commented on a change in pull request #3612: add MongoDB interpreter
URL: https://github.com/apache/zeppelin/pull/3612#discussion_r368995732
##########
File path: docs/interpreter/mongodb.md
##########
@@ -0,0 +1,92 @@
+---
+layout: page
+title: "MongoDB Interpreter for Apache Zeppelin"
+description: "MongoDB is a general purpose, document-based, distributed database built for modern application developers and for the cloud era."
+group: interpreter
+---
+<!--
+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.
+-->
+{% include JB/setup %}
+
+# MongoDB interpreter for Apache Zeppelin
+
+<div id="toc"></div>
+
+## Overview
+[MongoDB](https://www.mongodb.com/) is a general purpose, document-based, distributed database built for modern application developers and for the cloud era.
+This interpreter use mongo shell to execute [scripts](https://docs.mongodb.com/manual/tutorial/write-scripts-for-the-mongo-shell/)
Review comment:
Miss dot at the end of this sentence. This is what I see in web

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] alexott commented on a change in pull request #3612:
ZEPPELIN-4571
Posted by GitBox <gi...@apache.org>.
alexott commented on a change in pull request #3612: ZEPPELIN-4571
URL: https://github.com/apache/zeppelin/pull/3612#discussion_r370928464
##########
File path: mongodb/src/main/java/org/apache/zeppelin/mongodb/MongoDbInterpreter.java
##########
@@ -0,0 +1,209 @@
+/*
+ * 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.mongodb;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Scanner;
+
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.ExecuteException;
+import org.apache.commons.exec.ExecuteWatchdog;
+import org.apache.commons.exec.Executor;
+import org.apache.commons.exec.PumpStreamHandler;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.zeppelin.interpreter.Interpreter;
+import org.apache.zeppelin.interpreter.InterpreterContext;
+import org.apache.zeppelin.interpreter.InterpreterResult;
+import org.apache.zeppelin.interpreter.InterpreterResult.Code;
+import org.apache.zeppelin.scheduler.Scheduler;
+import org.apache.zeppelin.scheduler.SchedulerFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * MongoDB interpreter. It uses the mongo shell to interpret the commands.
+ */
+public class MongoDbInterpreter extends Interpreter {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(MongoDbInterpreter.class);
+
+ private static final String SHELL_EXTENSION =
+ new Scanner(MongoDbInterpreter.class.getResourceAsStream("/shell_extension.js"), "UTF-8")
+ .useDelimiter("\\A").next();
+
+ private static final int SIGTERM_CODE = 143;
+
+ private long commandTimeout = 60000;
+
+ private String dbAddress;
+
+ private int maxConcurrency = 10;
+
+ private Map<String, Executor> runningProcesses = new HashMap<>();
+
+ public MongoDbInterpreter(Properties property) {
+ super(property);
+ }
+
+ @Override
+ public void open() {
+ commandTimeout = Long.parseLong(getProperty("mongo.shell.command.timeout"));
+ maxConcurrency = Integer.parseInt(getProperty("mongo.interpreter.concurrency.max"));
+ dbAddress = getProperty("mongo.server.host") + ":"
+ + getProperty("mongo.server.port") + "/"
+ + getProperty("mongo.server.database");
+ }
+
+ @Override
+ public void close() {
+ runningProcesses.clear();
+ runningProcesses = null;
+ }
+
+ @Override
+ public FormType getFormType() {
+ return FormType.SIMPLE;
+ }
+
+ @Override
+ public InterpreterResult interpret(String script, InterpreterContext context) {
+ LOGGER.debug("Run MongoDB script: {}", script);
+
+ if (StringUtils.isEmpty(script)) {
+ return new InterpreterResult(Code.SUCCESS);
+ }
+
+ String paragraphId = context.getParagraphId();
+ // Write script in a temporary file
+ // The script is enriched with extensions
+ final File scriptFile = new File(getScriptFileName(paragraphId));
+ try {
+ FileUtils.write(scriptFile,
+ SHELL_EXTENSION
+ .replace("__ZEPPELIN_TABLE_LIMIT__", getProperty("mongo.shell.command.table.limit")) +
+ script);
+ }
+ catch (IOException e) {
+ LOGGER.error("Can not write script in temp file", e);
+ return new InterpreterResult(Code.ERROR, e.getMessage());
+ }
+
+ InterpreterResult result = new InterpreterResult(InterpreterResult.Code.SUCCESS);
+
+ final DefaultExecutor executor = new DefaultExecutor();
+ final ByteArrayOutputStream errorStream = new ByteArrayOutputStream();
+
+ executor.setStreamHandler(new PumpStreamHandler(context.out, errorStream));
+ executor.setWatchdog(new ExecuteWatchdog(commandTimeout));
+
+ final CommandLine cmdLine = CommandLine.parse(getProperty("mongo.shell.path"));
+ cmdLine.addArgument("--quiet", false);
+
+ if (!StringUtils.isEmpty(getProperty("mongo.server.username"))) {
+ cmdLine.addArgument("-u", false);
+ cmdLine.addArgument(getProperty("mongo.server.username"), false);
+ cmdLine.addArgument("-p", false);
+ cmdLine.addArgument(getProperty("mongo.server.password"), false);
Review comment:
We should be really careful with passing passwords on the command-line, because they are visible in the `ps` output, etc. Maybe we can pass credentials as part of the script to execute? like this:
```
use admin
db.auth("uname", "password")
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian commented on a change in pull request #3612:
add MongoDB interpreter
Posted by GitBox <gi...@apache.org>.
tokenian commented on a change in pull request #3612: add MongoDB interpreter
URL: https://github.com/apache/zeppelin/pull/3612#discussion_r368415326
##########
File path: mongodb/pom.xml
##########
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>zeppelin-interpreter-parent</artifactId>
+ <groupId>org.apache.zeppelin</groupId>
+ <version>0.9.0-SNAPSHOT</version>
+ <relativePath>../zeppelin-interpreter-parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.zeppelin</groupId>
+ <artifactId>zeppelin-mongodb</artifactId>
+ <packaging>jar</packaging>
+ <version>0.9.0-SNAPSHOT</version>
+ <name>Zeppelin: MongoDB interpreter</name>
+
+ <properties>
+ <interpreter.name>mongodb</interpreter.name>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-shade-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>alimaven</id>
+ <name>Maven Aliyun Mirror</name>
+ <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
Review comment:
low speed in china, I'll remove it
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian commented on issue #3612: [ZEPPELIN-4571] Add
MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
tokenian commented on issue #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-592282507
ok
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on issue #3612: add MongoDB interpreter
Posted by GitBox <gi...@apache.org>.
zjffdu commented on issue #3612: add MongoDB interpreter
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-576274910
@tokenian Another thing you need to do is to ask the original author of this interpreter for the permission to contribute it into Zeppelin https://github.com/bbonnin/zeppelin-mongodb-interpreter
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on issue #3612: add MongoDB interpreter
Posted by GitBox <gi...@apache.org>.
zjffdu commented on issue #3612: add MongoDB interpreter
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-576975550
Another thing is the PR title, could you make it as [ZEPPELIN-xxx] jira title ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian commented on issue #3612: [ZEPPELIN-4571] Add
MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
tokenian commented on issue #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-590225399
@zjffdu I have followed these instructions, [Development-workflow-with-Git](https://github.com/sevntu-checkstyle/sevntu.checkstyle/wiki/Development-workflow-with-Git:-Fork,-Branching,-Commits,-and-Pull-Request). rebase is too complicated. Could you give me some suggestions, I have no idea.
I have googled some answers, revert merge.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on issue #3612: [ZEPPELIN-4571] Add
MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
zjffdu commented on issue #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-590179035
@tokenian Could you do a rebase ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on a change in pull request #3612: add
MongoDB interpreter
Posted by GitBox <gi...@apache.org>.
zjffdu commented on a change in pull request #3612: add MongoDB interpreter
URL: https://github.com/apache/zeppelin/pull/3612#discussion_r368996019
##########
File path: docs/interpreter/mongodb.md
##########
@@ -0,0 +1,92 @@
+---
+layout: page
+title: "MongoDB Interpreter for Apache Zeppelin"
+description: "MongoDB is a general purpose, document-based, distributed database built for modern application developers and for the cloud era."
+group: interpreter
+---
+<!--
+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.
+-->
+{% include JB/setup %}
+
+# MongoDB interpreter for Apache Zeppelin
+
+<div id="toc"></div>
+
+## Overview
+[MongoDB](https://www.mongodb.com/) is a general purpose, document-based, distributed database built for modern application developers and for the cloud era.
+This interpreter use mongo shell to execute [scripts](https://docs.mongodb.com/manual/tutorial/write-scripts-for-the-mongo-shell/)
+Use mongo-shell `JavaScript` to analyze data as you need
+## Installing AND Configuration
+First, you need to install mongo shell with Zeppelin in the same machine.
Review comment:
Could you add one link for how to install mongo shell ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] alexott commented on a change in pull request #3612:
[ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
alexott commented on a change in pull request #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#discussion_r373835890
##########
File path: mongodb/src/main/java/org/apache/zeppelin/mongodb/MongoDbInterpreter.java
##########
@@ -0,0 +1,209 @@
+/*
+ * 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.mongodb;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Scanner;
+
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.ExecuteException;
+import org.apache.commons.exec.ExecuteWatchdog;
+import org.apache.commons.exec.Executor;
+import org.apache.commons.exec.PumpStreamHandler;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.zeppelin.interpreter.Interpreter;
+import org.apache.zeppelin.interpreter.InterpreterContext;
+import org.apache.zeppelin.interpreter.InterpreterResult;
+import org.apache.zeppelin.interpreter.InterpreterResult.Code;
+import org.apache.zeppelin.scheduler.Scheduler;
+import org.apache.zeppelin.scheduler.SchedulerFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * MongoDB interpreter. It uses the mongo shell to interpret the commands.
+ */
+public class MongoDbInterpreter extends Interpreter {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(MongoDbInterpreter.class);
+
+ private static final String SHELL_EXTENSION =
+ new Scanner(MongoDbInterpreter.class.getResourceAsStream("/shell_extension.js"), "UTF-8")
+ .useDelimiter("\\A").next();
+
+ private static final int SIGTERM_CODE = 143;
+
+ private long commandTimeout = 60000;
+
+ private String dbAddress;
+
+ private int maxConcurrency = 10;
+
+ private Map<String, Executor> runningProcesses = new HashMap<>();
+
+ public MongoDbInterpreter(Properties property) {
+ super(property);
+ }
+
+ @Override
+ public void open() {
+ commandTimeout = Long.parseLong(getProperty("mongo.shell.command.timeout"));
+ maxConcurrency = Integer.parseInt(getProperty("mongo.interpreter.concurrency.max"));
+ dbAddress = getProperty("mongo.server.host") + ":"
+ + getProperty("mongo.server.port") + "/"
+ + getProperty("mongo.server.database");
+ }
+
+ @Override
+ public void close() {
+ runningProcesses.clear();
+ runningProcesses = null;
+ }
+
+ @Override
+ public FormType getFormType() {
+ return FormType.SIMPLE;
+ }
+
+ @Override
+ public InterpreterResult interpret(String script, InterpreterContext context) {
+ LOGGER.debug("Run MongoDB script: {}", script);
+
+ if (StringUtils.isEmpty(script)) {
+ return new InterpreterResult(Code.SUCCESS);
+ }
+
+ String paragraphId = context.getParagraphId();
+ // Write script in a temporary file
+ // The script is enriched with extensions
+ final File scriptFile = new File(getScriptFileName(paragraphId));
+ try {
+ FileUtils.write(scriptFile,
+ SHELL_EXTENSION
+ .replace("__ZEPPELIN_TABLE_LIMIT__", getProperty("mongo.shell.command.table.limit")) +
+ script);
+ }
+ catch (IOException e) {
+ LOGGER.error("Can not write script in temp file", e);
+ return new InterpreterResult(Code.ERROR, e.getMessage());
+ }
+
+ InterpreterResult result = new InterpreterResult(InterpreterResult.Code.SUCCESS);
+
+ final DefaultExecutor executor = new DefaultExecutor();
+ final ByteArrayOutputStream errorStream = new ByteArrayOutputStream();
+
+ executor.setStreamHandler(new PumpStreamHandler(context.out, errorStream));
+ executor.setWatchdog(new ExecuteWatchdog(commandTimeout));
+
+ final CommandLine cmdLine = CommandLine.parse(getProperty("mongo.shell.path"));
+ cmdLine.addArgument("--quiet", false);
+
+ if (!StringUtils.isEmpty(getProperty("mongo.server.username"))) {
+ cmdLine.addArgument("-u", false);
+ cmdLine.addArgument(getProperty("mongo.server.username"), false);
+ cmdLine.addArgument("-p", false);
+ cmdLine.addArgument(getProperty("mongo.server.password"), false);
Review comment:
my point is that people with shell access, for example, via shell interpreter, could do `ps -aef|grep mongo` and get the full command line with username & password.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on a change in pull request #3612:
[ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
zjffdu commented on a change in pull request #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#discussion_r375718425
##########
File path: mongodb/pom.xml
##########
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>zeppelin-interpreter-parent</artifactId>
+ <groupId>org.apache.zeppelin</groupId>
+ <version>0.9.0-SNAPSHOT</version>
+ <relativePath>../zeppelin-interpreter-parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.zeppelin</groupId>
+ <artifactId>zeppelin-mongodb</artifactId>
+ <packaging>jar</packaging>
+ <version>0.9.0-SNAPSHOT</version>
+ <name>Zeppelin: MongoDB interpreter</name>
+
+ <properties>
+ <interpreter.name>mongodb</interpreter.name>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-shade-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+
+ <repositories>
+ <repository>
+ <id>apache-snap</id>
+ <name>apache snapshots</name>
+ <url>https://maven.aliyun.com/repository/apache-snapshots</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+
+ <repository>
+ <id>alimaven</id>
+ <name>Maven Aliyun Mirror</name>
Review comment:
it is not removed ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on a change in pull request #3612: add
MongoDB interpreter
Posted by GitBox <gi...@apache.org>.
zjffdu commented on a change in pull request #3612: add MongoDB interpreter
URL: https://github.com/apache/zeppelin/pull/3612#discussion_r369001907
##########
File path: mongodb/src/main/java/org/apache/zeppelin/mongodb/MongoDbInterpreter.java
##########
@@ -0,0 +1,190 @@
+/*
+ * 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.mongodb;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Scanner;
+
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.ExecuteException;
+import org.apache.commons.exec.ExecuteWatchdog;
+import org.apache.commons.exec.Executor;
+import org.apache.commons.exec.PumpStreamHandler;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.zeppelin.interpreter.Interpreter;
+import org.apache.zeppelin.interpreter.InterpreterContext;
+import org.apache.zeppelin.interpreter.InterpreterResult;
+import org.apache.zeppelin.interpreter.InterpreterResult.Code;
+import org.apache.zeppelin.scheduler.Scheduler;
+import org.apache.zeppelin.scheduler.SchedulerFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * MongoDB interpreter. It uses the mongo shell to interpret the commands.
+ *
+ */
+public class MongoDbInterpreter extends Interpreter {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(MongoDbInterpreter.class);
+
+ private static final String SHELL_EXTENSION =
+ new Scanner(MongoDbInterpreter.class.getResourceAsStream("/shell_extension.js"), "UTF-8")
+ .useDelimiter("\\A").next();
+
+ private long commandTimeout = 60000;
+
+ private String dbAddress;
+
+ private Map<String, Executor> runningProcesses = new HashMap<>();
+
+
+ public MongoDbInterpreter(Properties property) {
+ super(property);
+ }
+
+ @Override
+ public void open() {
+ commandTimeout = Long.parseLong(getProperty("mongo.shell.command.timeout"));
+ dbAddress = getProperty("mongo.server.host") + ":"
+ + getProperty("mongo.server.port") + "/"
+ + getProperty("mongo.server.database");
+ }
+
+ @Override
+ public void close() {
+ //Nothing to do
+ }
+
+ @Override
+ public FormType getFormType() {
+ return FormType.SIMPLE;
+ }
+
+ @Override
+ public InterpreterResult interpret(String script, InterpreterContext context) {
+ LOGGER.debug("Run MongoDB script: {}", script);
+
+ if (StringUtils.isEmpty(script)) {
+ return new InterpreterResult(Code.SUCCESS);
+ }
+
+ // Write script in a temporary file
+ // The script is enriched with extensions
+ final File scriptFile = new File(getScriptFileName(context.getParagraphId()));
+ try {
+ FileUtils.write(scriptFile,
+ SHELL_EXTENSION
+ .replace("__ZEPPELIN_TABLE_LIMIT__", getProperty("mongo.shell.command.table.limit")) +
+ script);
+ }
+ catch (IOException e) {
+ LOGGER.error("Can not write script in temp file", e);
+ return new InterpreterResult(Code.ERROR, e.getMessage());
+ }
+
+ InterpreterResult result = new InterpreterResult(InterpreterResult.Code.SUCCESS);
+
+ final DefaultExecutor executor = new DefaultExecutor();
+ final ByteArrayOutputStream errorStream = new ByteArrayOutputStream();
+ executor.setStreamHandler(new PumpStreamHandler(context.out, errorStream));
+ executor.setWatchdog(new ExecuteWatchdog(commandTimeout)); //ExecuteWatchdog.INFINITE_TIMEOUT
+
+ final CommandLine cmdLine = CommandLine.parse(getProperty("mongo.shell.path"));
+ cmdLine.addArgument("--quiet", false);
+
+ if (!StringUtils.isEmpty(getProperty("mongo.server.username"))) {
+ cmdLine.addArgument("-u", false);
+ cmdLine.addArgument(getProperty("mongo.server.username"), false);
+ cmdLine.addArgument("-p", false);
+ cmdLine.addArgument(getProperty("mongo.server.password"), false);
+
+ if (!StringUtils.isEmpty(getProperty("mongo.server.authentdatabase"))) {
+ cmdLine.addArgument("--authenticationDatabase", false);
+ cmdLine.addArgument(getProperty("mongo.server.authentdatabase"), false);
+ }
+ }
+
+ cmdLine.addArgument(dbAddress, false);
+ cmdLine.addArgument(scriptFile.getAbsolutePath(), false);
+
+ try {
+ executor.execute(cmdLine);
+ runningProcesses.put(context.getParagraphId(), executor);
Review comment:
Should remove it from Map after the process is completed
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on issue #3612: [ZEPPELIN-4571] Add
MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
zjffdu commented on issue #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-591987680
These are known flaky test, thanks @tokenian
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian commented on issue #3612: [ZEPPELIN-4571] Add
MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
tokenian commented on issue #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-586122850
@zjffdu is there something else need me to do?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian commented on a change in pull request #3612:
ZEPPELIN-4571
Posted by GitBox <gi...@apache.org>.
tokenian commented on a change in pull request #3612: ZEPPELIN-4571
URL: https://github.com/apache/zeppelin/pull/3612#discussion_r373833358
##########
File path: mongodb/src/main/java/org/apache/zeppelin/mongodb/MongoDbInterpreter.java
##########
@@ -0,0 +1,190 @@
+/*
+ * 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.mongodb;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Scanner;
+
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.ExecuteException;
+import org.apache.commons.exec.ExecuteWatchdog;
+import org.apache.commons.exec.Executor;
+import org.apache.commons.exec.PumpStreamHandler;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.zeppelin.interpreter.Interpreter;
+import org.apache.zeppelin.interpreter.InterpreterContext;
+import org.apache.zeppelin.interpreter.InterpreterResult;
+import org.apache.zeppelin.interpreter.InterpreterResult.Code;
+import org.apache.zeppelin.scheduler.Scheduler;
+import org.apache.zeppelin.scheduler.SchedulerFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * MongoDB interpreter. It uses the mongo shell to interpret the commands.
+ *
+ */
+public class MongoDbInterpreter extends Interpreter {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(MongoDbInterpreter.class);
+
+ private static final String SHELL_EXTENSION =
+ new Scanner(MongoDbInterpreter.class.getResourceAsStream("/shell_extension.js"), "UTF-8")
+ .useDelimiter("\\A").next();
+
+ private long commandTimeout = 60000;
+
+ private String dbAddress;
+
+ private Map<String, Executor> runningProcesses = new HashMap<>();
+
+
+ public MongoDbInterpreter(Properties property) {
+ super(property);
+ }
+
+ @Override
+ public void open() {
+ commandTimeout = Long.parseLong(getProperty("mongo.shell.command.timeout"));
+ dbAddress = getProperty("mongo.server.host") + ":"
+ + getProperty("mongo.server.port") + "/"
+ + getProperty("mongo.server.database");
+ }
+
+ @Override
+ public void close() {
+ //Nothing to do
+ }
+
+ @Override
+ public FormType getFormType() {
+ return FormType.SIMPLE;
+ }
+
+ @Override
+ public InterpreterResult interpret(String script, InterpreterContext context) {
+ LOGGER.debug("Run MongoDB script: {}", script);
+
+ if (StringUtils.isEmpty(script)) {
+ return new InterpreterResult(Code.SUCCESS);
+ }
+
+ // Write script in a temporary file
+ // The script is enriched with extensions
+ final File scriptFile = new File(getScriptFileName(context.getParagraphId()));
+ try {
+ FileUtils.write(scriptFile,
+ SHELL_EXTENSION
+ .replace("__ZEPPELIN_TABLE_LIMIT__", getProperty("mongo.shell.command.table.limit")) +
+ script);
+ }
+ catch (IOException e) {
+ LOGGER.error("Can not write script in temp file", e);
+ return new InterpreterResult(Code.ERROR, e.getMessage());
+ }
+
+ InterpreterResult result = new InterpreterResult(InterpreterResult.Code.SUCCESS);
+
+ final DefaultExecutor executor = new DefaultExecutor();
+ final ByteArrayOutputStream errorStream = new ByteArrayOutputStream();
+ executor.setStreamHandler(new PumpStreamHandler(context.out, errorStream));
+ executor.setWatchdog(new ExecuteWatchdog(commandTimeout)); //ExecuteWatchdog.INFINITE_TIMEOUT
+
+ final CommandLine cmdLine = CommandLine.parse(getProperty("mongo.shell.path"));
+ cmdLine.addArgument("--quiet", false);
+
+ if (!StringUtils.isEmpty(getProperty("mongo.server.username"))) {
+ cmdLine.addArgument("-u", false);
+ cmdLine.addArgument(getProperty("mongo.server.username"), false);
+ cmdLine.addArgument("-p", false);
+ cmdLine.addArgument(getProperty("mongo.server.password"), false);
+
+ if (!StringUtils.isEmpty(getProperty("mongo.server.authentdatabase"))) {
+ cmdLine.addArgument("--authenticationDatabase", false);
+ cmdLine.addArgument(getProperty("mongo.server.authentdatabase"), false);
+ }
+ }
+
+ cmdLine.addArgument(dbAddress, false);
+ cmdLine.addArgument(scriptFile.getAbsolutePath(), false);
+
+ try {
+ executor.execute(cmdLine);
+ runningProcesses.put(context.getParagraphId(), executor);
+ }
+ catch (ExecuteException e) {
+ LOGGER.error("Can not run script in paragraph {}", context.getParagraphId(), e);
+
+ final int exitValue = e.getExitValue();
+ Code code = Code.ERROR;
+ String msg = errorStream.toString();
+ if (exitValue == 143) {
+ code = Code.INCOMPLETE;
+ msg = msg + "Paragraph received a SIGTERM.\n";
+ LOGGER.info("The paragraph {} stopped executing: {}", context.getParagraphId(), msg);
+ }
+ msg += "ExitValue: " + exitValue;
+ result = new InterpreterResult(code, msg);
+ }
+ catch (IOException e) {
+ LOGGER.error("Can not run script in paragraph {}", context.getParagraphId(), e);
+ result = new InterpreterResult(Code.ERROR, e.getMessage());
+ }
+ finally {
+ FileUtils.deleteQuietly(scriptFile);
+ }
+
+ return result;
+ }
+
+ @Override
+ public int getProgress(InterpreterContext context) {
+ return 0;
+ }
+
+ @Override
+ public void cancel(InterpreterContext context) {
+ stopProcess(context.getParagraphId());
+ FileUtils.deleteQuietly(new File(getScriptFileName(context.getParagraphId())));
+ }
+
+ @Override
+ public Scheduler getScheduler() {
+ return SchedulerFactory.singleton().createOrGetParallelScheduler("mongo", 10);
Review comment:
mongo.interpreter.concurrency.max property supplied
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian commented on issue #3612: [ZEPPELIN-4571] Add
MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
tokenian commented on issue #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-586131585
I'm sorry. I don't have permissions someday ago, so I don't fix it.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian commented on issue #3612: [ZEPPELIN-4571] Add
MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
tokenian commented on issue #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-586128536
> @tokenian Could you resolve the conflicting ?
everything you mentioned upstairs have been fixed.I don't know what exactly your meaning?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian commented on issue #3612: add MongoDB
interpreter
Posted by GitBox <gi...@apache.org>.
tokenian commented on issue #3612: add MongoDB interpreter
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-576162520
@zjffdu it use zeppelin web ui with chart. It can give us a clear way to look data, use mongodb aggregate function to analyze data
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on a change in pull request #3612: add
MongoDB interpreter
Posted by GitBox <gi...@apache.org>.
zjffdu commented on a change in pull request #3612: add MongoDB interpreter
URL: https://github.com/apache/zeppelin/pull/3612#discussion_r369000296
##########
File path: mongodb/pom.xml
##########
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>zeppelin-interpreter-parent</artifactId>
+ <groupId>org.apache.zeppelin</groupId>
+ <version>0.9.0-SNAPSHOT</version>
+ <relativePath>../zeppelin-interpreter-parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.zeppelin</groupId>
+ <artifactId>zeppelin-mongodb</artifactId>
+ <packaging>jar</packaging>
+ <version>0.9.0-SNAPSHOT</version>
+ <name>Zeppelin: MongoDB interpreter</name>
+
+ <properties>
+ <interpreter.name>mongodb</interpreter.name>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-shade-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <skip>false</skip>
Review comment:
I would suggest you to enable the checkstyle. It is set to false in other modules temporary, but finally we would enable checkstyle in all modules.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on issue #3612: ZEPPELIN-4571
Posted by GitBox <gi...@apache.org>.
zjffdu commented on issue #3612: ZEPPELIN-4571
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-581008191
@tokenian Could you update the PR title and resolve the conflicting ? Thanks
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on issue #3612: [ZEPPELIN-4571] Add
MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
zjffdu commented on issue #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-589454444
@tokenian Could you check the travis CI ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian commented on issue #3612: [ZEPPELIN-4571] Add
MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
tokenian commented on issue #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-590308306
@zjffdu I have done a rebase, but it seems some difference between master. Please check
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian commented on issue #3612: ZEPPELIN-4571
Posted by GitBox <gi...@apache.org>.
tokenian commented on issue #3612: ZEPPELIN-4571
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-576994994
I get TTransportException with thrift when running in Zeppelin 0.8.2 , I don't know why. Maybe this morning updated interpreter snapshots. Is there any doc tell me how to debug interpreter with IDEA?
Thanks for your help! @zjffdu
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on a change in pull request #3612:
[ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
zjffdu commented on a change in pull request #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#discussion_r383603518
##########
File path: bin/interpreter.sh
##########
@@ -69,7 +69,7 @@ fi
. "${bin}/common.sh"
-ZEPPELIN_INTERPRETER_API_JAR=$(find "${ZEPPELIN_HOME}/interpreter" -name 'zeppelin-interpreter-shaded-*.jar')
+ZEPPELIN_INTERPRETER_API_JAR=$(find "${ZEPPELIN_HOME}/interpreter" -name 'zeppelin-interpreter-api-*.jar')
Review comment:
@tokenian You reverted the previous commits. I think you may need to do rebase again.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian edited a comment on issue #3612:
[ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
tokenian edited a comment on issue #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-590308306
@zjffdu I have done a rebase, but it seems some difference between master. It was my first time to do a so complicated rebase. Please check, I will correct it if something wrong.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian commented on a change in pull request #3612:
[ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
tokenian commented on a change in pull request #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#discussion_r384994328
##########
File path: bin/interpreter.sh
##########
@@ -69,7 +69,7 @@ fi
. "${bin}/common.sh"
-ZEPPELIN_INTERPRETER_API_JAR=$(find "${ZEPPELIN_HOME}/interpreter" -name 'zeppelin-interpreter-shaded-*.jar')
+ZEPPELIN_INTERPRETER_API_JAR=$(find "${ZEPPELIN_HOME}/interpreter" -name 'zeppelin-interpreter-api-*.jar')
Review comment:
@zjffdu I use git -X ours to add my commits on top of master. Thanks a lot
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian commented on issue #3612: add MongoDB
interpreter
Posted by GitBox <gi...@apache.org>.
tokenian commented on issue #3612: add MongoDB interpreter
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-576673235
<img width="1049" alt="Screen Shot 2020-01-21 at 9 05 45 PM" src="https://user-images.githubusercontent.com/9793694/72807312-1ac17800-3c92-11ea-8cb1-f09fd5e5e190.png">
@zjffdu I have get the original author's permissionn
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on issue #3612: add MongoDB interpreter
Posted by GitBox <gi...@apache.org>.
zjffdu commented on issue #3612: add MongoDB interpreter
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-576684357
Thanks @tokenian I left some comments
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian commented on issue #3612: [ZEPPELIN-4571] Add
MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
tokenian commented on issue #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-590056839
@zjffdu I have fixed rat problem, but there were some other problems not associated with the mongo interpreter.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on issue #3612: [ZEPPELIN-4571] Add
MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
zjffdu commented on issue #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-591465413
@tokenian Could you do a rebase again and resolve the conflict ? Thanks
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on a change in pull request #3612: add
MongoDB interpreter
Posted by GitBox <gi...@apache.org>.
zjffdu commented on a change in pull request #3612: add MongoDB interpreter
URL: https://github.com/apache/zeppelin/pull/3612#discussion_r368997700
##########
File path: docs/interpreter/mongodb.md
##########
@@ -0,0 +1,92 @@
+---
+layout: page
+title: "MongoDB Interpreter for Apache Zeppelin"
+description: "MongoDB is a general purpose, document-based, distributed database built for modern application developers and for the cloud era."
+group: interpreter
+---
+<!--
+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.
+-->
+{% include JB/setup %}
+
+# MongoDB interpreter for Apache Zeppelin
+
+<div id="toc"></div>
+
+## Overview
+[MongoDB](https://www.mongodb.com/) is a general purpose, document-based, distributed database built for modern application developers and for the cloud era.
+This interpreter use mongo shell to execute [scripts](https://docs.mongodb.com/manual/tutorial/write-scripts-for-the-mongo-shell/)
+Use mongo-shell `JavaScript` to analyze data as you need
+## Installing AND Configuration
+First, you need to install mongo shell with Zeppelin in the same machine.
+Second, create mongodb interpreter in Zeppelin.
+
+<table class="table-configuration">
+ <tr>
+ <th>Name</th>
+ <th>Default Value</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>mongo.shell.path</td>
+ <td>mongo</td>
+ <td>MongoDB shell local path. <br/> Use `which mongo` to get local path in linux or mac.</td>
+ </tr>
+ <tr>
+ <td>mongo.shell.command.table.limit</td>
+ <td>1000</td>
+ <td>Limit of documents displayed in a table. <br/> Use table function when get data from mongodb</td>
+ </tr>
+ <tr>
+ <td>mongo.shell.command.timeout</td>
+ <td>60000</td>
+ <td>MongoDB shell command timeout in millisecond</td>
+ </tr>
+ <tr>
+ <td>mongo.server.host</td>
+ <td>localhost</td>
+ <td>MongoDB server host to connect to</td>
+ </tr>
+ <tr>
+ <td>mongo.server.port</td>
+ <td>27017</td>
+ <td>MongoDB server port to connect to</td>
+ </tr>
+ <tr>
+ <td>mongo.server.database</td>
+ <td>test</td>
+ <td>MongoDB database name</td>
+ </tr>
+ <tr>
+ <td>mongo.server.authentdatabase</td>
+ <td></td>
+ <td>MongoDB database name for authentication</td>
+ </tr>
+ <tr>
+ <td>mongo.server.username</td>
+ <td></td>
+ <td>Username for authentication</td>
+ </tr>
+ <tr>
+ <td>mongo.server.password</td>
+ <td></td>
+ <td>Password for authentication</td>
+ </tr>
+</table>
+## Examples
+In a notebook, to enable the **mongodb** interpreter, click the **Gear** icon and select **mongodb**.
Review comment:
This line could be deleted, it is not necessary to do it in the latest zeppelin
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] tokenian commented on issue #3612: [ZEPPELIN-4571] Add
MongoDB interpreter for Zeppelin
Posted by GitBox <gi...@apache.org>.
tokenian commented on issue #3612: [ZEPPELIN-4571] Add MongoDB interpreter for Zeppelin
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-590158362
@zjffdu [1](https://travis-ci.org/tokenian/zeppelin/jobs/654015381)
[2](https://travis-ci.org/tokenian/zeppelin/jobs/654015376)
[3](https://travis-ci.org/tokenian/zeppelin/jobs/654015374)
[4](https://travis-ci.org/tokenian/zeppelin/jobs/654015377)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on issue #3612: add MongoDB interpreter
Posted by GitBox <gi...@apache.org>.
zjffdu commented on issue #3612: add MongoDB interpreter
URL: https://github.com/apache/zeppelin/pull/3612#issuecomment-576090257
Thanks @tokenian for the contribution. IIRC, this interpreter just use mongo shell for any mongo command. So why not just use the shell interpreter to run the mongo command ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [zeppelin] zjffdu commented on a change in pull request #3612: add
MongoDB interpreter
Posted by GitBox <gi...@apache.org>.
zjffdu commented on a change in pull request #3612: add MongoDB interpreter
URL: https://github.com/apache/zeppelin/pull/3612#discussion_r368356279
##########
File path: mongodb/pom.xml
##########
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>zeppelin-interpreter-parent</artifactId>
+ <groupId>org.apache.zeppelin</groupId>
+ <version>0.9.0-SNAPSHOT</version>
+ <relativePath>../zeppelin-interpreter-parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.zeppelin</groupId>
+ <artifactId>zeppelin-mongodb</artifactId>
+ <packaging>jar</packaging>
+ <version>0.9.0-SNAPSHOT</version>
+ <name>Zeppelin: MongoDB interpreter</name>
+
+ <properties>
+ <interpreter.name>mongodb</interpreter.name>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-shade-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>alimaven</id>
+ <name>Maven Aliyun Mirror</name>
+ <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
Review comment:
Why adding aliyun repo ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services