Skip to content

Commit

Permalink
Merge pull request #9 from cthiebault/master
Browse files Browse the repository at this point in the history
Upgrade to Zeppelin 0.7.0
  • Loading branch information
bbonnin authored Mar 21, 2017
2 parents 92c8994 + 2c0e22e commit a2cb1db
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
<groupId>org.apache.zeppelin</groupId>
<artifactId>zeppelin-mongodb</artifactId>
<packaging>jar</packaging>
<version>0.6.0</version>
<version>0.7.0</version>
<name>Zeppelin: MongoDB interpreter</name>
<url>http://www.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<zeppelin.version>0.6.0</zeppelin.version>
<zeppelin.version>0.7.0</zeppelin.version>
<junit.version>4.11</junit.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.apache.commons.exec.Executor;
import org.apache.commons.exec.PumpStreamHandler;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.zeppelin.interpreter.Interpreter;
import org.apache.zeppelin.interpreter.InterpreterContext;
import org.apache.zeppelin.interpreter.InterpreterResult;
Expand Down Expand Up @@ -84,7 +84,7 @@ public FormType getFormType() {

@Override
public InterpreterResult interpret(String script, InterpreterContext context) {
LOGGER.debug("Run MongoDB script: " + script);
LOGGER.debug("Run MongoDB script: {}", script);

if (StringUtils.isEmpty(script)) {
return new InterpreterResult(Code.SUCCESS);
Expand Down Expand Up @@ -134,21 +134,21 @@ public InterpreterResult interpret(String script, InterpreterContext context) {
runningProcesses.put(context.getParagraphId(), executor);
}
catch (ExecuteException e) {
LOGGER.error("Can not run script in paragraph " + context.getParagraphId(), 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 " + context.getParagraphId() + " stopped executing: " + msg);
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);
LOGGER.error("Can not run script in paragraph {}", context.getParagraphId(), e);
result = new InterpreterResult(Code.ERROR, e.getMessage());
}
finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.zeppelin.interpreter.InterpreterOutputListener;
import org.apache.zeppelin.interpreter.InterpreterResult;
import org.apache.zeppelin.interpreter.InterpreterResult.Code;
import org.apache.zeppelin.interpreter.InterpreterResultMessageOutput;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
Expand All @@ -54,7 +55,7 @@ public class MongoDbInterpreterTest implements InterpreterOutputListener {
private final MongoDbInterpreter interpreter = new MongoDbInterpreter(props);
private final InterpreterOutput out = new InterpreterOutput(this);
private final InterpreterContext context = new InterpreterContext("test", "test",
null, null, null, null, null, null, null, null, out);
null, null, null, null, null, null, null, null, null, out);

private ByteBuffer buffer;

Expand Down Expand Up @@ -83,7 +84,7 @@ public void testSuccess() {

final InterpreterResult res = interpreter.interpret(userScript, context);

assertTrue("Check SUCCESS: " + res.message(), res.code().equals(Code.SUCCESS));
assertTrue("Check SUCCESS: " + res.message(), res.code() == Code.SUCCESS);

try {
out.flush();
Expand All @@ -105,18 +106,24 @@ public void testBadConf() {
props.setProperty("mongo.shell.path", "/bad/path/to/mongo");
final InterpreterResult res = interpreter.interpret("print('hello')", context);

assertTrue(res.code().equals(Code.ERROR));
assertTrue(res.code() == Code.ERROR);
}

@Override
public void onAppend(InterpreterOutput out, byte[] line) {
buffer.put(line);
public void onUpdateAll(InterpreterOutput interpreterOutput) {

}

@Override
public void onUpdate(InterpreterOutput out, byte[] output) {
public void onAppend(int i, InterpreterResultMessageOutput interpreterResultMessageOutput, byte[] bytes) {
buffer.put(bytes);
}


@Override
public void onUpdate(int i, InterpreterResultMessageOutput interpreterResultMessageOutput) {

}

private byte[] getBufferBytes() {
buffer.flip();
final byte[] bufferBytes = new byte[buffer.remaining()];
Expand Down

0 comments on commit a2cb1db

Please sign in to comment.