use of org.apache.zeppelin.scheduler.Job.Status in project zeppelin by apache.
the class NotebookServer method broadcastSpellExecution.
private void broadcastSpellExecution(NotebookSocket conn, HashSet<String> userAndRoles, Notebook notebook, Message fromMessage) throws IOException {
final String paragraphId = (String) fromMessage.get("id");
if (paragraphId == null) {
return;
}
String noteId = getOpenNoteId(conn);
if (!hasParagraphWriterPermission(conn, notebook, noteId, userAndRoles, fromMessage.principal, "write")) {
return;
}
String text = (String) fromMessage.get("paragraph");
String title = (String) fromMessage.get("title");
Status status = Status.valueOf((String) fromMessage.get("status"));
Map<String, Object> params = (Map<String, Object>) fromMessage.get("params");
Map<String, Object> config = (Map<String, Object>) fromMessage.get("config");
final Note note = notebook.getNote(noteId);
Paragraph p = setParagraphUsingMessage(note, fromMessage, paragraphId, text, title, params, config);
p.setResult(fromMessage.get("results"));
p.setErrorMessage((String) fromMessage.get("errorMessage"));
p.setStatusWithoutNotification(status);
addNewParagraphIfLastParagraphIsExecuted(note, p);
if (!persistNoteWithAuthInfo(conn, note, p)) {
return;
}
// broadcast to other clients only
broadcastExcept(note.getId(), new Message(OP.RUN_PARAGRAPH_USING_SPELL).put("paragraph", p), conn);
}
use of org.apache.zeppelin.scheduler.Job.Status in project zeppelin by apache.
the class NotebookTest method testNotebookEventListener.
@Test
public void testNotebookEventListener() throws IOException {
final AtomicInteger onNoteRemove = new AtomicInteger(0);
final AtomicInteger onNoteCreate = new AtomicInteger(0);
final AtomicInteger onParagraphRemove = new AtomicInteger(0);
final AtomicInteger onParagraphCreate = new AtomicInteger(0);
final AtomicInteger unbindInterpreter = new AtomicInteger(0);
notebook.addNotebookEventListener(new NotebookEventListener() {
@Override
public void onNoteRemove(Note note) {
onNoteRemove.incrementAndGet();
}
@Override
public void onNoteCreate(Note note) {
onNoteCreate.incrementAndGet();
}
@Override
public void onUnbindInterpreter(Note note, InterpreterSetting setting) {
unbindInterpreter.incrementAndGet();
}
@Override
public void onParagraphRemove(Paragraph p) {
onParagraphRemove.incrementAndGet();
}
@Override
public void onParagraphCreate(Paragraph p) {
onParagraphCreate.incrementAndGet();
}
@Override
public void onParagraphStatusChange(Paragraph p, Status status) {
}
});
Note note1 = notebook.createNote(anonymous);
assertEquals(1, onNoteCreate.get());
Paragraph p1 = note1.addParagraph(AuthenticationInfo.ANONYMOUS);
assertEquals(1, onParagraphCreate.get());
note1.addCloneParagraph(p1);
assertEquals(2, onParagraphCreate.get());
note1.removeParagraph(anonymous.getUser(), p1.getId());
assertEquals(1, onParagraphRemove.get());
List<String> settings = notebook.getBindedInterpreterSettingsIds(note1.getId());
notebook.bindInterpretersToNote(anonymous.getUser(), note1.getId(), new LinkedList<String>());
assertEquals(settings.size(), unbindInterpreter.get());
notebook.removeNote(note1.getId(), anonymous);
assertEquals(1, onNoteRemove.get());
assertEquals(1, onParagraphRemove.get());
}
use of org.apache.zeppelin.scheduler.Job.Status in project zeppelin by apache.
the class NotebookTest method testSchedulePoolUsage.
@Test
public void testSchedulePoolUsage() throws InterruptedException, IOException {
final int timeout = 30;
final String everySecondCron = "* * * * * ?";
final CountDownLatch jobsToExecuteCount = new CountDownLatch(13);
final Note note = notebook.createNote(anonymous);
executeNewParagraphByCron(note, everySecondCron);
afterStatusChangedListener = new StatusChangedListener() {
@Override
public void onStatusChanged(Job job, Status before, Status after) {
if (after == Status.FINISHED) {
jobsToExecuteCount.countDown();
}
}
};
assertTrue(jobsToExecuteCount.await(timeout, TimeUnit.SECONDS));
terminateScheduledNote(note);
afterStatusChangedListener = null;
}
Aggregations