Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions zeppelin-server/conf/notebook-authorization.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"authInfo": {
"2F8GB7HN7": {
"readers": [],
"owners": [],
"writers": [],
"runners": []
},
"2F9W6X5GY": {
"readers": [],
"owners": [],
"writers": [],
"runners": []
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,15 @@ private static Thread shutdown(ZeppelinConfiguration conf) {
() -> {
LOG.info("Shutting down Zeppelin Server ... ");
try {
jettyWebServer.stop();
if (!conf.isRecoveryEnabled()) {
sharedServiceLocator.getService(InterpreterSettingManager.class).close();
if (jettyWebServer != null) {
jettyWebServer.stop();
}
if (sharedServiceLocator != null) {
if (!conf.isRecoveryEnabled()) {
sharedServiceLocator.getService(InterpreterSettingManager.class).close();
}
sharedServiceLocator.getService(Notebook.class).close();
}
sharedServiceLocator.getService(Notebook.class).close();
Thread.sleep(3000);
} catch (Exception e) {
LOG.error("Error while stopping servlet container", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,23 @@ public Note importNote(String notePath,
}
}

/**
* Executes given paragraph with passed paragraph info like noteId, paragraphId, title, text and etc.
*
* @param noteId
* @param paragraphId
* @param title
* @param text
* @param params
* @param config
* @param failIfDisabled
* @param blocking
* @param context
* @param callback
* @return return true only when paragraph execution finished, it could end with succeed or error due to user code.
* return false when paragraph execution fails due to zeppelin internal issue.
* @throws IOException
*/
public boolean runParagraph(String noteId,
String paragraphId,
String title,
Expand Down Expand Up @@ -334,9 +351,9 @@ public boolean runParagraph(String noteId,

try {
notebook.saveNote(note, context.getAutheInfo());
boolean result = note.run(p.getId(), blocking, context.getAutheInfo().getUser());
note.run(p.getId(), blocking, context.getAutheInfo().getUser());
callback.onSuccess(p, context);
return result;
return true;
} catch (Exception ex) {
LOGGER.error("Exception from run", ex);
p.setReturn(new InterpreterResult(InterpreterResult.Code.ERROR, ex.getMessage()), ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static org.junit.Assert.assertThat;

import com.google.gson.Gson;
import com.google.gson.internal.StringMap;
import com.google.gson.reflect.TypeToken;

import org.apache.commons.httpclient.methods.GetMethod;
Expand All @@ -40,6 +41,7 @@
import org.junit.runners.MethodSorters;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;

Expand Down Expand Up @@ -160,6 +162,28 @@ public void testRunParagraphSynchronously() throws IOException {
// Check if the paragraph is emptied
assertEquals(title, p.getTitle());
assertEquals(text, p.getText());

// run invalid code
text = "%sh\n invalid_cmd";
p.setTitle(title);
p.setText(text);

post = httpPost("/notebook/run/" + note1.getId() + "/" + p.getId(), "");
assertEquals(500, post.getStatusCode());
resp = gson.fromJson(post.getResponseBodyAsString(),
new TypeToken<Map<String, Object>>() {}.getType());
assertEquals("INTERNAL_SERVER_ERROR", resp.get("status"));
StringMap stringMap = (StringMap) resp.get("body");
assertEquals("ERROR", stringMap.get("code"));
List<StringMap> interpreterResults = (List<StringMap>) stringMap.get("msg");
assertTrue(interpreterResults.get(0).toString(),
interpreterResults.get(0).get("data").toString().contains("invalid_cmd: command not found"));
post.releaseConnection();
assertNotEquals(p.getStatus(), Job.Status.READY);

// Check if the paragraph is emptied
assertEquals(title, p.getTitle());
assertEquals(text, p.getText());
} finally {
// cleanup
if (null != note1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ public void testParagraphOperations() throws IOException {
reset(callback);
runStatus = notebookService.runParagraph(note1.getId(), p.getId(), "my_title", "invalid_code",
new HashMap<>(), new HashMap<>(), false, true, context, callback);
assertFalse(runStatus);
assertTrue(runStatus);
// TODO(zjffdu) Enable it after ZEPPELIN-3699
// assertNotNull(p.getResult());
verify(callback).onSuccess(p, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ public boolean run(String paragraphId, boolean blocking) {
}

/**
* Run a single paragraph
* Run a single paragraph. Return true only when paragraph run successfully.
*
* @param paragraphId
* @param blocking
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@ public boolean shouldSkipRunParagraph() {
return checkEmptyConfig && Strings.isNullOrEmpty(scriptText) && localProperties.isEmpty();
}

/**
* Return true only when paragraph run successfully with state of FINISHED.
* @param blocking
* @return
*/
public boolean execute(boolean blocking) {
try {
this.interpreter = getBindedInterpreter();
Expand Down