use of org.apache.zeppelin.interpreter.InterpreterSetting in project zeppelin by apache.
the class NotebookServer method onMetaInfosReceived.
@Override
public void onMetaInfosReceived(String settingId, Map<String, String> metaInfos) {
InterpreterSetting interpreterSetting = notebook().getInterpreterSettingManager().get(settingId);
interpreterSetting.setInfos(metaInfos);
}
use of org.apache.zeppelin.interpreter.InterpreterSetting in project zeppelin by apache.
the class NotebookServer method onUpdate.
@Override
public void onUpdate(String interpreterGroupId, AngularObject object) {
Notebook notebook = notebook();
if (notebook == null) {
return;
}
List<Note> notes = notebook.getAllNotes();
for (Note note : notes) {
if (object.getNoteId() != null && !note.getId().equals(object.getNoteId())) {
continue;
}
List<InterpreterSetting> intpSettings = notebook.getInterpreterSettingManager().getInterpreterSettings(note.getId());
if (intpSettings.isEmpty()) {
continue;
}
broadcast(note.getId(), new Message(OP.ANGULAR_OBJECT_UPDATE).put("angularObject", object).put("interpreterGroupId", interpreterGroupId).put("noteId", note.getId()).put("paragraphId", object.getParagraphId()));
}
}
use of org.apache.zeppelin.interpreter.InterpreterSetting in project zeppelin by apache.
the class NotebookServerTest method testCreateNoteWithDefaultInterpreterId.
@Test
public void testCreateNoteWithDefaultInterpreterId() throws IOException {
// create two sockets and open it
NotebookSocket sock1 = createWebSocket();
NotebookSocket sock2 = createWebSocket();
assertEquals(sock1, sock1);
assertNotEquals(sock1, sock2);
notebookServer.onOpen(sock1);
notebookServer.onOpen(sock2);
String noteName = "Note with millis " + System.currentTimeMillis();
String defaultInterpreterId = "";
List<InterpreterSetting> settings = notebook.getInterpreterSettingManager().get();
if (settings.size() > 1) {
defaultInterpreterId = settings.get(1).getId();
}
// create note from sock1
notebookServer.onMessage(sock1, gson.toJson(new Message(OP.NEW_NOTE).put("name", noteName).put("defaultInterpreterId", defaultInterpreterId)));
// expect the events are broadcasted properly
verify(sock1, times(2)).send(anyString());
Note createdNote = null;
for (Note note : notebook.getAllNotes()) {
if (note.getName().equals(noteName)) {
createdNote = note;
break;
}
}
if (settings.size() > 1) {
assertEquals(notebook.getInterpreterSettingManager().getDefaultInterpreterSetting(createdNote.getId()).getId(), defaultInterpreterId);
}
notebook.removeNote(createdNote.getId(), anonymous);
}
use of org.apache.zeppelin.interpreter.InterpreterSetting in project zeppelin by apache.
the class ZeppelinSparkClusterTest method sparkRTest.
@Test
public void sparkRTest() throws IOException {
// create new note
Note note = ZeppelinServer.notebook.createNote(anonymous);
int sparkVersion = getSparkVersionNumber(note);
if (isSparkR() && sparkVersion >= 14) {
// sparkr supported from 1.4.0
// restart spark interpreter
List<InterpreterSetting> settings = ZeppelinServer.notebook.getBindedInterpreterSettings(note.getId());
for (InterpreterSetting setting : settings) {
if (setting.getName().equals("spark")) {
ZeppelinServer.notebook.getInterpreterSettingManager().restart(setting.getId());
break;
}
}
String sqlContextName = "sqlContext";
if (sparkVersion >= 20) {
sqlContextName = "spark";
}
Paragraph p = note.addParagraph(AuthenticationInfo.ANONYMOUS);
Map config = p.getConfig();
config.put("enabled", true);
p.setConfig(config);
p.setText("%r localDF <- data.frame(name=c(\"a\", \"b\", \"c\"), age=c(19, 23, 18))\n" + "df <- createDataFrame(" + sqlContextName + ", localDF)\n" + "count(df)");
p.setAuthenticationInfo(anonymous);
note.run(p.getId());
waitForFinish(p);
System.err.println("sparkRTest=" + p.getResult().message().get(0).getData());
assertEquals(Status.FINISHED, p.getStatus());
assertEquals("[1] 3", p.getResult().message().get(0).getData().trim());
}
ZeppelinServer.notebook.removeNote(note.getId(), anonymous);
}
use of org.apache.zeppelin.interpreter.InterpreterSetting in project zeppelin by apache.
the class NotebookServerTest method testMakeSureNoAngularObjectBroadcastToWebsocketWhoFireTheEvent.
@Test
public void testMakeSureNoAngularObjectBroadcastToWebsocketWhoFireTheEvent() throws IOException {
// create a notebook
Note note1 = notebook.createNote(anonymous);
// get reference to interpreterGroup
InterpreterGroup interpreterGroup = null;
List<InterpreterSetting> settings = notebook.getInterpreterSettingManager().getInterpreterSettings(note1.getId());
for (InterpreterSetting setting : settings) {
if (setting.getName().equals("md")) {
interpreterGroup = setting.getInterpreterGroup("anonymous", "sharedProcess");
break;
}
}
// start interpreter process
Paragraph p1 = note1.addParagraph(AuthenticationInfo.ANONYMOUS);
p1.setText("%md start remote interpreter process");
p1.setAuthenticationInfo(anonymous);
note1.run(p1.getId());
// add angularObject
interpreterGroup.getAngularObjectRegistry().add("object1", "value1", note1.getId(), null);
// create two sockets and open it
NotebookSocket sock1 = createWebSocket();
NotebookSocket sock2 = createWebSocket();
assertEquals(sock1, sock1);
assertNotEquals(sock1, sock2);
notebookServer.onOpen(sock1);
notebookServer.onOpen(sock2);
// getNote, getAngularObject
verify(sock1, times(0)).send(anyString());
// open the same notebook from sockets
notebookServer.onMessage(sock1, gson.toJson(new Message(OP.GET_NOTE).put("id", note1.getId())));
notebookServer.onMessage(sock2, gson.toJson(new Message(OP.GET_NOTE).put("id", note1.getId())));
reset(sock1);
reset(sock2);
// update object from sock1
notebookServer.onMessage(sock1, gson.toJson(new Message(OP.ANGULAR_OBJECT_UPDATED).put("noteId", note1.getId()).put("name", "object1").put("value", "value1").put("interpreterGroupId", interpreterGroup.getId())));
// expect object is broadcasted except for where the update is created
verify(sock1, times(0)).send(anyString());
verify(sock2, times(1)).send(anyString());
notebook.removeNote(note1.getId(), anonymous);
}
Aggregations