mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Extracted InterpreterSetting from InterpreterFactory
This commit is contained in:
parent
6b304a9691
commit
1e995f5af7
18 changed files with 1398 additions and 1221 deletions
|
|
@ -37,7 +37,9 @@ import org.apache.zeppelin.helium.Helium;
|
|||
import org.apache.zeppelin.helium.HeliumApplicationFactory;
|
||||
import org.apache.zeppelin.helium.HeliumBundleFactory;
|
||||
import org.apache.zeppelin.interpreter.InterpreterFactory;
|
||||
import org.apache.zeppelin.interpreter.InterpreterOption;
|
||||
import org.apache.zeppelin.interpreter.InterpreterOutput;
|
||||
import org.apache.zeppelin.interpreter.InterpreterSettingManager;
|
||||
import org.apache.zeppelin.notebook.Notebook;
|
||||
import org.apache.zeppelin.notebook.NotebookAuthorization;
|
||||
import org.apache.zeppelin.notebook.repo.NotebookRepoSync;
|
||||
|
|
@ -85,6 +87,7 @@ public class ZeppelinServer extends Application {
|
|||
public static NotebookServer notebookWsServer;
|
||||
public static Helium helium;
|
||||
|
||||
private final InterpreterSettingManager interpreterSettingManager;
|
||||
private SchedulerFactory schedulerFactory;
|
||||
private InterpreterFactory replFactory;
|
||||
private SearchService noteSearchService;
|
||||
|
|
@ -139,14 +142,17 @@ public class ZeppelinServer extends Application {
|
|||
}
|
||||
|
||||
this.schedulerFactory = new SchedulerFactory();
|
||||
this.interpreterSettingManager = new InterpreterSettingManager(conf, depResolver,
|
||||
new InterpreterOption(true));
|
||||
this.replFactory = new InterpreterFactory(conf, notebookWsServer,
|
||||
notebookWsServer, heliumApplicationFactory, depResolver, SecurityUtils.isAuthenticated());
|
||||
notebookWsServer, heliumApplicationFactory, depResolver, SecurityUtils.isAuthenticated(),
|
||||
interpreterSettingManager);
|
||||
this.notebookRepo = new NotebookRepoSync(conf);
|
||||
this.noteSearchService = new LuceneSearch();
|
||||
this.notebookAuthorization = NotebookAuthorization.init(conf);
|
||||
this.credentials = new Credentials(conf.credentialsPersist(), conf.getCredentialsPath());
|
||||
notebook = new Notebook(conf,
|
||||
notebookRepo, schedulerFactory, replFactory, notebookWsServer,
|
||||
notebookRepo, schedulerFactory, replFactory, interpreterSettingManager, notebookWsServer,
|
||||
noteSearchService, notebookAuthorization, credentials);
|
||||
|
||||
// to update notebook from application event from remote process.
|
||||
|
|
@ -194,7 +200,7 @@ public class ZeppelinServer extends Application {
|
|||
LOG.info("Shutting down Zeppelin Server ... ");
|
||||
try {
|
||||
jettyWebServer.stop();
|
||||
notebook.getInterpreterFactory().shutdown();
|
||||
notebook.getInterpreterSettingManager().shutdown();
|
||||
notebook.close();
|
||||
Thread.sleep(3000);
|
||||
} catch (Exception e) {
|
||||
|
|
@ -217,7 +223,7 @@ public class ZeppelinServer extends Application {
|
|||
}
|
||||
|
||||
jettyWebServer.join();
|
||||
ZeppelinServer.notebook.getInterpreterFactory().close();
|
||||
ZeppelinServer.notebook.getInterpreterSettingManager().close();
|
||||
}
|
||||
|
||||
private static Server setupJettyServer(ZeppelinConfiguration conf) {
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ import org.apache.zeppelin.display.AngularObjectRegistry;
|
|||
import org.apache.zeppelin.display.AngularObjectRegistryListener;
|
||||
import org.apache.zeppelin.helium.ApplicationEventListener;
|
||||
import org.apache.zeppelin.helium.HeliumPackage;
|
||||
import org.apache.zeppelin.interpreter.Interpreter;
|
||||
import org.apache.zeppelin.interpreter.InterpreterContextRunner;
|
||||
import org.apache.zeppelin.interpreter.InterpreterGroup;
|
||||
import org.apache.zeppelin.interpreter.InterpreterResult;
|
||||
|
|
@ -473,7 +474,7 @@ public class NotebookServer extends WebSocketServlet
|
|||
Notebook notebook = notebook();
|
||||
List<Note> notes = notebook.getAllNotes();
|
||||
for (Note note : notes) {
|
||||
List<String> ids = notebook.getInterpreterFactory().getInterpreters(note.getId());
|
||||
List<String> ids = notebook.getInterpreterSettingManager().getInterpreters(note.getId());
|
||||
for (String id : ids) {
|
||||
if (id.equals(interpreterGroupId)) {
|
||||
broadcast(note.getId(), m);
|
||||
|
|
@ -991,7 +992,7 @@ public class NotebookServer extends WebSocketServlet
|
|||
if (!StringUtils.isEmpty(defaultInterpreterId)) {
|
||||
List<String> interpreterSettingIds = new LinkedList<>();
|
||||
interpreterSettingIds.add(defaultInterpreterId);
|
||||
for (String interpreterSettingId : notebook.getInterpreterFactory().
|
||||
for (String interpreterSettingId : notebook.getInterpreterSettingManager().
|
||||
getDefaultInterpreterSettingList()) {
|
||||
if (!interpreterSettingId.equals(defaultInterpreterId)) {
|
||||
interpreterSettingIds.add(interpreterSettingId);
|
||||
|
|
@ -1334,7 +1335,7 @@ public class NotebookServer extends WebSocketServlet
|
|||
Note note = notebook.getNote(noteId);
|
||||
if (note != null) {
|
||||
List<InterpreterSetting> settings =
|
||||
notebook.getInterpreterFactory().getInterpreterSettings(note.getId());
|
||||
notebook.getInterpreterSettingManager().getInterpreterSettings(note.getId());
|
||||
for (InterpreterSetting setting : settings) {
|
||||
if (setting.getInterpreterGroup(user, note.getId()) == null) {
|
||||
continue;
|
||||
|
|
@ -1376,7 +1377,7 @@ public class NotebookServer extends WebSocketServlet
|
|||
// interpreter.
|
||||
for (Note n : notebook.getAllNotes()) {
|
||||
List<InterpreterSetting> settings =
|
||||
notebook.getInterpreterFactory().getInterpreterSettings(note.getId());
|
||||
notebook.getInterpreterSettingManager().getInterpreterSettings(note.getId());
|
||||
for (InterpreterSetting setting : settings) {
|
||||
if (setting.getInterpreterGroup(user, n.getId()) == null) {
|
||||
continue;
|
||||
|
|
@ -2197,7 +2198,7 @@ public class NotebookServer extends WebSocketServlet
|
|||
private void sendAllAngularObjects(Note note, String user, NotebookSocket conn)
|
||||
throws IOException {
|
||||
List<InterpreterSetting> settings =
|
||||
notebook().getInterpreterFactory().getInterpreterSettings(note.getId());
|
||||
notebook().getInterpreterSettingManager().getInterpreterSettings(note.getId());
|
||||
if (settings == null || settings.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -2235,7 +2236,7 @@ public class NotebookServer extends WebSocketServlet
|
|||
}
|
||||
|
||||
List<InterpreterSetting> intpSettings =
|
||||
notebook.getInterpreterFactory().getInterpreterSettings(note.getId());
|
||||
notebook.getInterpreterSettingManager().getInterpreterSettings(note.getId());
|
||||
if (intpSettings.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -2255,7 +2256,8 @@ public class NotebookServer extends WebSocketServlet
|
|||
continue;
|
||||
}
|
||||
|
||||
List<String> settingIds = notebook.getInterpreterFactory().getInterpreters(note.getId());
|
||||
List<String> settingIds =
|
||||
notebook.getInterpreterSettingManager().getInterpreters(note.getId());
|
||||
for (String id : settingIds) {
|
||||
if (interpreterGroupId.contains(id)) {
|
||||
broadcast(note.getId(),
|
||||
|
|
@ -2274,21 +2276,25 @@ public class NotebookServer extends WebSocketServlet
|
|||
String user = fromMessage.principal;
|
||||
Message resp = new Message(OP.EDITOR_SETTING);
|
||||
resp.put("paragraphId", paragraphId);
|
||||
resp.put("editor", notebook().getInterpreterFactory().getEditorSetting(user, noteId, replName));
|
||||
Interpreter interpreter =
|
||||
notebook().getInterpreterFactory().getInterpreter(user, noteId, replName);
|
||||
resp.put("editor", notebook().getInterpreterSettingManager().
|
||||
getEditorSetting(interpreter, user, noteId, replName));
|
||||
conn.send(serializeMessage(resp));
|
||||
return;
|
||||
}
|
||||
|
||||
private void getInterpreterSettings(NotebookSocket conn, AuthenticationInfo subject)
|
||||
throws IOException {
|
||||
List<InterpreterSetting> availableSettings = notebook().getInterpreterFactory().get();
|
||||
List<InterpreterSetting> availableSettings = notebook().getInterpreterSettingManager().get();
|
||||
conn.send(serializeMessage(
|
||||
new Message(OP.INTERPRETER_SETTINGS).put("interpreterSettings", availableSettings)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMetaInfosReceived(String settingId, Map<String, String> metaInfos) {
|
||||
InterpreterSetting interpreterSetting = notebook().getInterpreterFactory().get(settingId);
|
||||
InterpreterSetting interpreterSetting =
|
||||
notebook().getInterpreterSettingManager().get(settingId);
|
||||
interpreterSetting.setInfos(metaInfos);
|
||||
}
|
||||
|
||||
|
|
@ -2342,8 +2348,8 @@ public class NotebookServer extends WebSocketServlet
|
|||
if (note != null) {
|
||||
Paragraph paragraph = note.getParagraph(paragraphId);
|
||||
if (paragraph != null) {
|
||||
InterpreterSetting setting = notebook().getInterpreterFactory()
|
||||
.get(interpreterSettingId);
|
||||
InterpreterSetting setting = notebook().getInterpreterSettingManager()
|
||||
.get(interpreterSettingId);
|
||||
setting.addNoteToPara(noteId, paragraphId);
|
||||
String label = metaInfos.get("label");
|
||||
String tooltip = metaInfos.get("tooltip");
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -77,6 +77,7 @@ public class Note implements Serializable, ParagraphJobListener {
|
|||
private Map<String, List<AngularObject>> angularObjects = new HashMap<>();
|
||||
|
||||
private transient InterpreterFactory factory;
|
||||
private transient InterpreterSettingManager interpreterSettingManager;
|
||||
private transient JobListenerFactory jobListenerFactory;
|
||||
private transient NotebookRepo repo;
|
||||
private transient SearchService index;
|
||||
|
|
@ -101,10 +102,12 @@ public class Note implements Serializable, ParagraphJobListener {
|
|||
public Note() {
|
||||
}
|
||||
|
||||
public Note(NotebookRepo repo, InterpreterFactory factory, JobListenerFactory jlFactory,
|
||||
public Note(NotebookRepo repo, InterpreterFactory factory,
|
||||
InterpreterSettingManager interpreterSettingManager, JobListenerFactory jlFactory,
|
||||
SearchService noteIndex, Credentials credentials, NoteEventListener noteEventListener) {
|
||||
this.repo = repo;
|
||||
this.factory = factory;
|
||||
this.interpreterSettingManager = interpreterSettingManager;
|
||||
this.jobListenerFactory = jlFactory;
|
||||
this.index = noteIndex;
|
||||
this.noteEventListener = noteEventListener;
|
||||
|
|
@ -117,7 +120,7 @@ public class Note implements Serializable, ParagraphJobListener {
|
|||
}
|
||||
|
||||
private String getDefaultInterpreterName() {
|
||||
InterpreterSetting setting = factory.getDefaultInterpreterSetting(getId());
|
||||
InterpreterSetting setting = interpreterSettingManager.getDefaultInterpreterSetting(getId());
|
||||
return null != setting ? setting.getName() : StringUtils.EMPTY;
|
||||
}
|
||||
|
||||
|
|
@ -272,7 +275,7 @@ public class Note implements Serializable, ParagraphJobListener {
|
|||
* Add paragraph last.
|
||||
*/
|
||||
public Paragraph addParagraph(AuthenticationInfo authenticationInfo) {
|
||||
Paragraph p = new Paragraph(this, this, factory);
|
||||
Paragraph p = new Paragraph(this, this, factory, interpreterSettingManager);
|
||||
p.setAuthenticationInfo(authenticationInfo);
|
||||
setParagraphMagic(p, paragraphs.size());
|
||||
synchronized (paragraphs) {
|
||||
|
|
@ -292,7 +295,8 @@ public class Note implements Serializable, ParagraphJobListener {
|
|||
void addCloneParagraph(Paragraph srcParagraph) {
|
||||
|
||||
// Keep paragraph original ID
|
||||
final Paragraph newParagraph = new Paragraph(srcParagraph.getId(), this, this, factory);
|
||||
final Paragraph newParagraph = new Paragraph(srcParagraph.getId(), this, this, factory,
|
||||
interpreterSettingManager);
|
||||
|
||||
Map<String, Object> config = new HashMap<>(srcParagraph.getConfig());
|
||||
Map<String, Object> param = new HashMap<>(srcParagraph.settings.getParams());
|
||||
|
|
@ -329,7 +333,7 @@ public class Note implements Serializable, ParagraphJobListener {
|
|||
* @param index index of paragraphs
|
||||
*/
|
||||
public Paragraph insertParagraph(int index, AuthenticationInfo authenticationInfo) {
|
||||
Paragraph p = new Paragraph(this, this, factory);
|
||||
Paragraph p = new Paragraph(this, this, factory, interpreterSettingManager);
|
||||
p.setAuthenticationInfo(authenticationInfo);
|
||||
setParagraphMagic(p, index);
|
||||
synchronized (paragraphs) {
|
||||
|
|
@ -623,7 +627,7 @@ public class Note implements Serializable, ParagraphJobListener {
|
|||
private void snapshotAngularObjectRegistry(String user) {
|
||||
angularObjects = new HashMap<>();
|
||||
|
||||
List<InterpreterSetting> settings = factory.getInterpreterSettings(getId());
|
||||
List<InterpreterSetting> settings = interpreterSettingManager.getInterpreterSettings(getId());
|
||||
if (settings == null || settings.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -638,7 +642,7 @@ public class Note implements Serializable, ParagraphJobListener {
|
|||
private void removeAllAngularObjectInParagraph(String user, String paragraphId) {
|
||||
angularObjects = new HashMap<>();
|
||||
|
||||
List<InterpreterSetting> settings = factory.getInterpreterSettings(getId());
|
||||
List<InterpreterSetting> settings = interpreterSettingManager.getInterpreterSettings(getId());
|
||||
if (settings == null || settings.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ public class Notebook implements NoteEventListener {
|
|||
private SchedulerFactory schedulerFactory;
|
||||
|
||||
private InterpreterFactory replFactory;
|
||||
private InterpreterSettingManager interpreterSettingManager;
|
||||
/**
|
||||
* Keep the order.
|
||||
*/
|
||||
|
|
@ -102,13 +103,14 @@ public class Notebook implements NoteEventListener {
|
|||
*/
|
||||
public Notebook(ZeppelinConfiguration conf, NotebookRepo notebookRepo,
|
||||
SchedulerFactory schedulerFactory, InterpreterFactory replFactory,
|
||||
JobListenerFactory jobListenerFactory, SearchService noteSearchService,
|
||||
NotebookAuthorization notebookAuthorization, Credentials credentials)
|
||||
throws IOException, SchedulerException {
|
||||
InterpreterSettingManager interpreterSettingManager, JobListenerFactory jobListenerFactory,
|
||||
SearchService noteSearchService, NotebookAuthorization notebookAuthorization,
|
||||
Credentials credentials) throws IOException, SchedulerException {
|
||||
this.conf = conf;
|
||||
this.notebookRepo = notebookRepo;
|
||||
this.schedulerFactory = schedulerFactory;
|
||||
this.replFactory = replFactory;
|
||||
this.interpreterSettingManager = interpreterSettingManager;
|
||||
this.jobListenerFactory = jobListenerFactory;
|
||||
this.noteSearchService = noteSearchService;
|
||||
this.notebookAuthorization = notebookAuthorization;
|
||||
|
|
@ -138,7 +140,7 @@ public class Notebook implements NoteEventListener {
|
|||
Preconditions.checkNotNull(subject, "AuthenticationInfo should not be null");
|
||||
Note note;
|
||||
if (conf.getBoolean(ConfVars.ZEPPELIN_NOTEBOOK_AUTO_INTERPRETER_BINDING)) {
|
||||
note = createNote(replFactory.getDefaultInterpreterSettingList(), subject);
|
||||
note = createNote(interpreterSettingManager.getDefaultInterpreterSettingList(), subject);
|
||||
} else {
|
||||
note = createNote(null, subject);
|
||||
}
|
||||
|
|
@ -154,7 +156,7 @@ public class Notebook implements NoteEventListener {
|
|||
public Note createNote(List<String> interpreterIds, AuthenticationInfo subject)
|
||||
throws IOException {
|
||||
Note note =
|
||||
new Note(notebookRepo, replFactory, jobListenerFactory,
|
||||
new Note(notebookRepo, replFactory, interpreterSettingManager, jobListenerFactory,
|
||||
noteSearchService, credentials, this);
|
||||
note.setNoteNameListener(folders);
|
||||
|
||||
|
|
@ -270,14 +272,15 @@ public class Notebook implements NoteEventListener {
|
|||
throws IOException {
|
||||
Note note = getNote(id);
|
||||
if (note != null) {
|
||||
List<InterpreterSetting> currentBindings = replFactory.getInterpreterSettings(id);
|
||||
List<InterpreterSetting> currentBindings =
|
||||
interpreterSettingManager.getInterpreterSettings(id);
|
||||
for (InterpreterSetting setting : currentBindings) {
|
||||
if (!interpreterSettingIds.contains(setting.getId())) {
|
||||
fireUnbindInterpreter(note, setting);
|
||||
}
|
||||
}
|
||||
|
||||
replFactory.setInterpreters(user, note.getId(), interpreterSettingIds);
|
||||
interpreterSettingManager.setInterpreters(user, note.getId(), interpreterSettingIds);
|
||||
// comment out while note.getNoteReplLoader().setInterpreters(...) do the same
|
||||
// replFactory.putNoteInterpreterSettingBinding(id, interpreterSettingIds);
|
||||
}
|
||||
|
|
@ -286,7 +289,7 @@ public class Notebook implements NoteEventListener {
|
|||
List<String> getBindedInterpreterSettingsIds(String id) {
|
||||
Note note = getNote(id);
|
||||
if (note != null) {
|
||||
return getInterpreterFactory().getInterpreters(note.getId());
|
||||
return interpreterSettingManager.getInterpreters(note.getId());
|
||||
} else {
|
||||
return new LinkedList<>();
|
||||
}
|
||||
|
|
@ -295,7 +298,7 @@ public class Notebook implements NoteEventListener {
|
|||
public List<InterpreterSetting> getBindedInterpreterSettings(String id) {
|
||||
Note note = getNote(id);
|
||||
if (note != null) {
|
||||
return replFactory.getInterpreterSettings(note.getId());
|
||||
return interpreterSettingManager.getInterpreterSettings(note.getId());
|
||||
} else {
|
||||
return new LinkedList<>();
|
||||
}
|
||||
|
|
@ -328,12 +331,12 @@ public class Notebook implements NoteEventListener {
|
|||
note = notes.remove(id);
|
||||
folders.removeNote(note);
|
||||
}
|
||||
replFactory.removeNoteInterpreterSettingBinding(subject.getUser(), id);
|
||||
interpreterSettingManager.removeNoteInterpreterSettingBinding(subject.getUser(), id);
|
||||
noteSearchService.deleteIndexDocs(note);
|
||||
notebookAuthorization.removeNote(id);
|
||||
|
||||
// remove from all interpreter instance's angular object registry
|
||||
for (InterpreterSetting settings : replFactory.get()) {
|
||||
for (InterpreterSetting settings : interpreterSettingManager.get()) {
|
||||
AngularObjectRegistry registry =
|
||||
settings.getInterpreterGroup(subject.getUser(), id).getAngularObjectRegistry();
|
||||
if (registry instanceof RemoteAngularObjectRegistry) {
|
||||
|
|
@ -510,7 +513,7 @@ public class Notebook implements NoteEventListener {
|
|||
|
||||
for (String name : angularObjectSnapshot.keySet()) {
|
||||
SnapshotAngularObject snapshot = angularObjectSnapshot.get(name);
|
||||
List<InterpreterSetting> settings = replFactory.get();
|
||||
List<InterpreterSetting> settings = interpreterSettingManager.get();
|
||||
for (InterpreterSetting setting : settings) {
|
||||
InterpreterGroup intpGroup = setting.getInterpreterGroup(subject.getUser(), note.getId());
|
||||
if (intpGroup.getId().equals(snapshot.getIntpGroupId())) {
|
||||
|
|
@ -754,9 +757,10 @@ public class Notebook implements NoteEventListener {
|
|||
|
||||
// set interpreter bind type
|
||||
String interpreterGroupName = null;
|
||||
if (replFactory.getInterpreterSettings(jobNote.getId()) != null
|
||||
&& replFactory.getInterpreterSettings(jobNote.getId()).size() >= 1) {
|
||||
interpreterGroupName = replFactory.getInterpreterSettings(jobNote.getId()).get(0).getName();
|
||||
if (interpreterSettingManager.getInterpreterSettings(jobNote.getId()) != null
|
||||
&& interpreterSettingManager.getInterpreterSettings(jobNote.getId()).size() >= 1) {
|
||||
interpreterGroupName =
|
||||
interpreterSettingManager.getInterpreterSettings(jobNote.getId()).get(0).getName();
|
||||
}
|
||||
|
||||
// note json object root information.
|
||||
|
|
@ -830,9 +834,10 @@ public class Notebook implements NoteEventListener {
|
|||
|
||||
// set interpreter bind type
|
||||
String interpreterGroupName = null;
|
||||
if (replFactory.getInterpreterSettings(note.getId()) != null
|
||||
&& replFactory.getInterpreterSettings(note.getId()).size() >= 1) {
|
||||
interpreterGroupName = replFactory.getInterpreterSettings(note.getId()).get(0).getName();
|
||||
if (interpreterSettingManager.getInterpreterSettings(note.getId()) != null
|
||||
&& interpreterSettingManager.getInterpreterSettings(note.getId()).size() >= 1) {
|
||||
interpreterGroupName =
|
||||
interpreterSettingManager.getInterpreterSettings(note.getId()).get(0).getName();
|
||||
}
|
||||
|
||||
// not update and not running -> pass
|
||||
|
|
@ -882,9 +887,9 @@ public class Notebook implements NoteEventListener {
|
|||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
if (releaseResource) {
|
||||
for (InterpreterSetting setting : notebook.getInterpreterFactory()
|
||||
for (InterpreterSetting setting : notebook.getInterpreterSettingManager()
|
||||
.getInterpreterSettings(note.getId())) {
|
||||
notebook.getInterpreterFactory().restart(setting.getId());
|
||||
notebook.getInterpreterSettingManager().restart(setting.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -949,6 +954,10 @@ public class Notebook implements NoteEventListener {
|
|||
return replFactory;
|
||||
}
|
||||
|
||||
public InterpreterSettingManager getInterpreterSettingManager() {
|
||||
return interpreterSettingManager;
|
||||
}
|
||||
|
||||
public NotebookAuthorization getNotebookAuthorization() {
|
||||
return notebookAuthorization;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ public class Paragraph extends Job implements Serializable, Cloneable {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(Paragraph.class);
|
||||
private transient InterpreterFactory factory;
|
||||
private transient InterpreterSettingManager interpreterSettingManager;
|
||||
private transient Note note;
|
||||
private transient AuthenticationInfo authenticationInfo;
|
||||
private transient Map<String, Paragraph> userParagraphMap = Maps.newHashMap(); // personalized
|
||||
|
|
@ -85,10 +86,11 @@ public class Paragraph extends Job implements Serializable, Cloneable {
|
|||
}
|
||||
|
||||
public Paragraph(String paragraphId, Note note, JobListener listener,
|
||||
InterpreterFactory factory) {
|
||||
InterpreterFactory factory, InterpreterSettingManager interpreterSettingManager) {
|
||||
super(paragraphId, generateId(), listener);
|
||||
this.note = note;
|
||||
this.factory = factory;
|
||||
this.interpreterSettingManager = interpreterSettingManager;
|
||||
title = null;
|
||||
text = null;
|
||||
authenticationInfo = null;
|
||||
|
|
@ -98,10 +100,12 @@ public class Paragraph extends Job implements Serializable, Cloneable {
|
|||
config = new HashMap<>();
|
||||
}
|
||||
|
||||
public Paragraph(Note note, JobListener listener, InterpreterFactory factory) {
|
||||
public Paragraph(Note note, JobListener listener, InterpreterFactory factory,
|
||||
InterpreterSettingManager interpreterSettingManager) {
|
||||
super(generateId(), listener);
|
||||
this.note = note;
|
||||
this.factory = factory;
|
||||
this.interpreterSettingManager = interpreterSettingManager;
|
||||
title = null;
|
||||
text = null;
|
||||
authenticationInfo = null;
|
||||
|
|
@ -248,7 +252,7 @@ public class Paragraph extends Job implements Serializable, Cloneable {
|
|||
|
||||
public List<InterpreterCompletion> getInterpreterCompletion() {
|
||||
List<InterpreterCompletion> completion = new LinkedList();
|
||||
for (InterpreterSetting intp : factory.getInterpreterSettings(note.getId())) {
|
||||
for (InterpreterSetting intp : interpreterSettingManager.getInterpreterSettings(note.getId())) {
|
||||
List<InterpreterInfo> intInfo = intp.getInterpreterInfos();
|
||||
if (intInfo.size() > 1) {
|
||||
for (InterpreterInfo info : intInfo) {
|
||||
|
|
@ -415,7 +419,7 @@ public class Paragraph extends Job implements Serializable, Cloneable {
|
|||
}
|
||||
|
||||
private boolean noteHasInterpreters() {
|
||||
return !factory.getInterpreterSettings(note.getId()).isEmpty();
|
||||
return !interpreterSettingManager.getInterpreterSettings(note.getId()).isEmpty();
|
||||
}
|
||||
|
||||
private boolean interpreterHasUser(InterpreterSetting intp) {
|
||||
|
|
@ -429,7 +433,7 @@ public class Paragraph extends Job implements Serializable, Cloneable {
|
|||
|
||||
private InterpreterSetting getInterpreterSettingById(String id) {
|
||||
InterpreterSetting setting = null;
|
||||
for (InterpreterSetting i : factory.getInterpreterSettings(note.getId())) {
|
||||
for (InterpreterSetting i : interpreterSettingManager.getInterpreterSettings(note.getId())) {
|
||||
if (id.startsWith(i.getId())) {
|
||||
setting = i;
|
||||
break;
|
||||
|
|
@ -503,8 +507,9 @@ public class Paragraph extends Job implements Serializable, Cloneable {
|
|||
AngularObjectRegistry registry = null;
|
||||
ResourcePool resourcePool = null;
|
||||
|
||||
if (!factory.getInterpreterSettings(note.getId()).isEmpty()) {
|
||||
InterpreterSetting intpGroup = factory.getInterpreterSettings(note.getId()).get(0);
|
||||
if (!interpreterSettingManager.getInterpreterSettings(note.getId()).isEmpty()) {
|
||||
InterpreterSetting intpGroup =
|
||||
interpreterSettingManager.getInterpreterSettings(note.getId()).get(0);
|
||||
registry = intpGroup.getInterpreterGroup(getUser(), note.getId()).getAngularObjectRegistry();
|
||||
resourcePool = intpGroup.getInterpreterGroup(getUser(), note.getId()).getResourcePool();
|
||||
}
|
||||
|
|
@ -531,8 +536,9 @@ public class Paragraph extends Job implements Serializable, Cloneable {
|
|||
AngularObjectRegistry registry = null;
|
||||
ResourcePool resourcePool = null;
|
||||
|
||||
if (!factory.getInterpreterSettings(note.getId()).isEmpty()) {
|
||||
InterpreterSetting intpGroup = factory.getInterpreterSettings(note.getId()).get(0);
|
||||
if (!interpreterSettingManager.getInterpreterSettings(note.getId()).isEmpty()) {
|
||||
InterpreterSetting intpGroup =
|
||||
interpreterSettingManager.getInterpreterSettings(note.getId()).get(0);
|
||||
registry = intpGroup.getInterpreterGroup(getUser(), note.getId()).getAngularObjectRegistry();
|
||||
resourcePool = intpGroup.getInterpreterGroup(getUser(), note.getId()).getResourcePool();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ public class HeliumApplicationFactoryTest implements JobListenerFactory {
|
|||
private SchedulerFactory schedulerFactory;
|
||||
private DependencyResolver depResolver;
|
||||
private InterpreterFactory factory;
|
||||
private InterpreterSettingManager interpreterSettingManager;
|
||||
private VFSNotebookRepo notebookRepo;
|
||||
private Notebook notebook;
|
||||
private HeliumApplicationFactory heliumAppFactory;
|
||||
|
|
@ -84,8 +85,8 @@ public class HeliumApplicationFactoryTest implements JobListenerFactory {
|
|||
|
||||
heliumAppFactory = new HeliumApplicationFactory();
|
||||
depResolver = new DependencyResolver(tmpDir.getAbsolutePath() + "/local-repo");
|
||||
factory = new InterpreterFactory(conf,
|
||||
new InterpreterOption(true), null, null, heliumAppFactory, depResolver, false);
|
||||
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
|
||||
factory = new InterpreterFactory(conf, null, null, heliumAppFactory, depResolver, false, interpreterSettingManager);
|
||||
HashMap<String, String> env = new HashMap<>();
|
||||
env.put("ZEPPELIN_CLASSPATH", new File("./target/test-classes").getAbsolutePath());
|
||||
factory.setEnv(env);
|
||||
|
|
@ -98,6 +99,7 @@ public class HeliumApplicationFactoryTest implements JobListenerFactory {
|
|||
notebookRepo,
|
||||
schedulerFactory,
|
||||
factory,
|
||||
interpreterSettingManager,
|
||||
this,
|
||||
search,
|
||||
notebookAuthorization,
|
||||
|
|
@ -112,7 +114,7 @@ public class HeliumApplicationFactoryTest implements JobListenerFactory {
|
|||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
List<InterpreterSetting> settings = factory.get();
|
||||
List<InterpreterSetting> settings = interpreterSettingManager.get();
|
||||
for (InterpreterSetting setting : settings) {
|
||||
for (InterpreterGroup intpGroup : setting.getAllInterpreterGroups()) {
|
||||
intpGroup.close();
|
||||
|
|
@ -138,7 +140,7 @@ public class HeliumApplicationFactoryTest implements JobListenerFactory {
|
|||
"", "");
|
||||
|
||||
Note note1 = notebook.createNote(anonymous);
|
||||
factory.setInterpreters("user", note1.getId(),factory.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.setInterpreters("user", note1.getId(),interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
|
||||
Paragraph p1 = note1.addParagraph(AuthenticationInfo.ANONYMOUS);
|
||||
|
||||
|
|
@ -184,7 +186,7 @@ public class HeliumApplicationFactoryTest implements JobListenerFactory {
|
|||
"", "");
|
||||
|
||||
Note note1 = notebook.createNote(anonymous);
|
||||
factory.setInterpreters("user", note1.getId(), factory.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.setInterpreters("user", note1.getId(), interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
|
||||
Paragraph p1 = note1.addParagraph(AuthenticationInfo.ANONYMOUS);
|
||||
|
||||
|
|
@ -224,7 +226,7 @@ public class HeliumApplicationFactoryTest implements JobListenerFactory {
|
|||
"", "");
|
||||
|
||||
Note note1 = notebook.createNote(anonymous);
|
||||
notebook.bindInterpretersToNote("user", note1.getId(), factory.getDefaultInterpreterSettingList());
|
||||
notebook.bindInterpretersToNote("user", note1.getId(), interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
|
||||
Paragraph p1 = note1.addParagraph(AuthenticationInfo.ANONYMOUS);
|
||||
|
||||
|
|
@ -285,7 +287,7 @@ public class HeliumApplicationFactoryTest implements JobListenerFactory {
|
|||
"", "");
|
||||
|
||||
Note note1 = notebook.createNote(anonymous);
|
||||
notebook.bindInterpretersToNote("user", note1.getId(), factory.getDefaultInterpreterSettingList());
|
||||
notebook.bindInterpretersToNote("user", note1.getId(), interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
String mock1IntpSettingId = null;
|
||||
for (InterpreterSetting setting : notebook.getBindedInterpreterSettings(note1.getId())) {
|
||||
if (setting.getName().equals("mock1")) {
|
||||
|
|
@ -312,7 +314,7 @@ public class HeliumApplicationFactoryTest implements JobListenerFactory {
|
|||
Thread.yield();
|
||||
}
|
||||
// when restart interpreter
|
||||
factory.restart(mock1IntpSettingId);
|
||||
interpreterSettingManager.restart(mock1IntpSettingId);
|
||||
while (app.getStatus() == ApplicationState.Status.LOADED) {
|
||||
Thread.yield();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ import org.mockito.Mock;
|
|||
public class InterpreterFactoryTest {
|
||||
|
||||
private InterpreterFactory factory;
|
||||
private InterpreterSettingManager interpreterSettingManager;
|
||||
private File tmpDir;
|
||||
private ZeppelinConfiguration conf;
|
||||
private InterpreterContext context;
|
||||
|
|
@ -102,13 +103,14 @@ public class InterpreterFactoryTest {
|
|||
conf = new ZeppelinConfiguration();
|
||||
schedulerFactory = new SchedulerFactory();
|
||||
depResolver = new DependencyResolver(tmpDir.getAbsolutePath() + "/local-repo");
|
||||
factory = new InterpreterFactory(conf, new InterpreterOption(false), null, null, null, depResolver, false);
|
||||
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
|
||||
factory = new InterpreterFactory(conf, null, null, null, depResolver, false, interpreterSettingManager);
|
||||
context = new InterpreterContext("note", "id", null, "title", "text", null, null, null, null, null, null, null);
|
||||
|
||||
SearchService search = mock(SearchService.class);
|
||||
notebookRepo = new VFSNotebookRepo(conf);
|
||||
notebookAuthorization = NotebookAuthorization.init(conf);
|
||||
notebook = new Notebook(conf, notebookRepo, schedulerFactory, factory, jobListenerFactory, search,
|
||||
notebook = new Notebook(conf, notebookRepo, schedulerFactory, factory, interpreterSettingManager, jobListenerFactory, search,
|
||||
notebookAuthorization, null);
|
||||
}
|
||||
|
||||
|
|
@ -119,7 +121,7 @@ public class InterpreterFactoryTest {
|
|||
|
||||
@Test
|
||||
public void testBasic() {
|
||||
List<InterpreterSetting> all = factory.get();
|
||||
List<InterpreterSetting> all = interpreterSettingManager.get();
|
||||
InterpreterSetting mock1Setting = null;
|
||||
for (InterpreterSetting setting : all) {
|
||||
if (setting.getName().equals("mock1")) {
|
||||
|
|
@ -137,17 +139,18 @@ public class InterpreterFactoryTest {
|
|||
assertNotNull("get Interpreter", interpreterGroup.get("session").get(0));
|
||||
|
||||
// try to get unavailable interpreter
|
||||
assertNull(factory.get("unknown"));
|
||||
assertNull(interpreterSettingManager.get("unknown"));
|
||||
|
||||
// restart interpreter
|
||||
factory.restart(mock1Setting.getId());
|
||||
interpreterSettingManager.restart(mock1Setting.getId());
|
||||
assertNull(mock1Setting.getInterpreterGroup("user", "sharedProcess").get("session"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoteRepl() throws Exception {
|
||||
factory = new InterpreterFactory(conf, new InterpreterOption(true), null, null, null, depResolver, false);
|
||||
List<InterpreterSetting> all = factory.get();
|
||||
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
|
||||
factory = new InterpreterFactory(conf, null, null, null, depResolver, false, interpreterSettingManager);
|
||||
List<InterpreterSetting> all = interpreterSettingManager.get();
|
||||
InterpreterSetting mock1Setting = null;
|
||||
for (InterpreterSetting setting : all) {
|
||||
if (setting.getName().equals("mock1")) {
|
||||
|
|
@ -174,8 +177,9 @@ public class InterpreterFactoryTest {
|
|||
*/
|
||||
@Test
|
||||
public void testRestartInterpreterInScopedMode() throws Exception {
|
||||
factory = new InterpreterFactory(conf, new InterpreterOption(true), null, null, null, depResolver, false);
|
||||
List<InterpreterSetting> all = factory.get();
|
||||
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
|
||||
factory = new InterpreterFactory(conf, null, null, null, depResolver, false, interpreterSettingManager);
|
||||
List<InterpreterSetting> all = interpreterSettingManager.get();
|
||||
InterpreterSetting mock1Setting = null;
|
||||
for (InterpreterSetting setting : all) {
|
||||
if (setting.getName().equals("mock1")) {
|
||||
|
|
@ -210,8 +214,9 @@ public class InterpreterFactoryTest {
|
|||
*/
|
||||
@Test
|
||||
public void testRestartInterpreterInIsolatedMode() throws Exception {
|
||||
factory = new InterpreterFactory(conf, new InterpreterOption(true), null, null, null, depResolver, false);
|
||||
List<InterpreterSetting> all = factory.get();
|
||||
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
|
||||
factory = new InterpreterFactory(conf, null, null, null, depResolver, false, interpreterSettingManager);
|
||||
List<InterpreterSetting> all = interpreterSettingManager.get();
|
||||
InterpreterSetting mock1Setting = null;
|
||||
for (InterpreterSetting setting : all) {
|
||||
if (setting.getName().equals("mock1")) {
|
||||
|
|
@ -243,21 +248,21 @@ public class InterpreterFactoryTest {
|
|||
@Test
|
||||
public void testFactoryDefaultList() throws IOException, RepositoryException {
|
||||
// get default settings
|
||||
List<String> all = factory.getDefaultInterpreterSettingList();
|
||||
assertTrue(factory.get().size() >= all.size());
|
||||
List<String> all = interpreterSettingManager.getDefaultInterpreterSettingList();
|
||||
assertTrue(interpreterSettingManager.get().size() >= all.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExceptions() throws InterpreterException, IOException, RepositoryException {
|
||||
List<String> all = factory.getDefaultInterpreterSettingList();
|
||||
List<String> all = interpreterSettingManager.getDefaultInterpreterSettingList();
|
||||
// add setting with null option & properties expected nullArgumentException.class
|
||||
try {
|
||||
factory.add("mock2", new ArrayList<InterpreterInfo>(), new LinkedList<Dependency>(), new InterpreterOption(false), Collections.EMPTY_MAP, "", null);
|
||||
interpreterSettingManager.add("mock2", new ArrayList<InterpreterInfo>(), new LinkedList<Dependency>(), new InterpreterOption(false), Collections.EMPTY_MAP, "", null);
|
||||
} catch(NullArgumentException e) {
|
||||
assertEquals("Test null option" , e.getMessage(),new NullArgumentException("option").getMessage());
|
||||
}
|
||||
try {
|
||||
factory.add("mock2", new ArrayList<InterpreterInfo>(), new LinkedList<Dependency>(), new InterpreterOption(false), Collections.EMPTY_MAP, "", null);
|
||||
interpreterSettingManager.add("mock2", new ArrayList<InterpreterInfo>(), new LinkedList<Dependency>(), new InterpreterOption(false), Collections.EMPTY_MAP, "", null);
|
||||
} catch (NullArgumentException e){
|
||||
assertEquals("Test null properties" , e.getMessage(),new NullArgumentException("properties").getMessage());
|
||||
}
|
||||
|
|
@ -267,22 +272,23 @@ public class InterpreterFactoryTest {
|
|||
@Test
|
||||
public void testSaveLoad() throws IOException, RepositoryException {
|
||||
// interpreter settings
|
||||
int numInterpreters = factory.get().size();
|
||||
int numInterpreters = interpreterSettingManager.get().size();
|
||||
|
||||
// check if file saved
|
||||
assertTrue(new File(conf.getInterpreterSettingPath()).exists());
|
||||
|
||||
factory.createNewSetting("new-mock1", "mock1", new LinkedList<Dependency>(), new InterpreterOption(false), new Properties());
|
||||
assertEquals(numInterpreters + 1, factory.get().size());
|
||||
interpreterSettingManager.createNewSetting("new-mock1", "mock1", new LinkedList<Dependency>(), new InterpreterOption(false), new Properties());
|
||||
assertEquals(numInterpreters + 1, interpreterSettingManager.get().size());
|
||||
|
||||
InterpreterFactory factory2 = new InterpreterFactory(conf, null, null, null, depResolver, false);
|
||||
assertEquals(numInterpreters + 1, factory2.get().size());
|
||||
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
|
||||
|
||||
assertEquals(numInterpreters + 1, interpreterSettingManager.get().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInterpreterSettingPropertyClass() throws IOException, RepositoryException {
|
||||
// check if default interpreter reference's property type is map
|
||||
Map<String, InterpreterSetting> interpreterSettingRefs = factory.getAvailableInterpreterSettings();
|
||||
Map<String, InterpreterSetting> interpreterSettingRefs = interpreterSettingManager.getAvailableInterpreterSettings();
|
||||
InterpreterSetting intpSetting = interpreterSettingRefs.get("mock1");
|
||||
Map<String, InterpreterProperty> intpProperties =
|
||||
(Map<String, InterpreterProperty>) intpSetting.getProperties();
|
||||
|
|
@ -293,7 +299,7 @@ public class InterpreterFactoryTest {
|
|||
properties.put("key1", "value1");
|
||||
properties.put("key2", "value2");
|
||||
|
||||
factory.createNewSetting("newMock", "mock1", new LinkedList<Dependency>(), new InterpreterOption(false), properties);
|
||||
interpreterSettingManager.createNewSetting("newMock", "mock1", new LinkedList<Dependency>(), new InterpreterOption(false), properties);
|
||||
|
||||
String confFilePath = conf.getInterpreterSettingPath();
|
||||
byte[] encoded = Files.readAllBytes(Paths.get(confFilePath));
|
||||
|
|
@ -312,20 +318,21 @@ public class InterpreterFactoryTest {
|
|||
|
||||
@Test
|
||||
public void testInterpreterAliases() throws IOException, RepositoryException {
|
||||
factory = new InterpreterFactory(conf, null, null, null, depResolver, false);
|
||||
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
|
||||
factory = new InterpreterFactory(conf, null, null, null, depResolver, false, interpreterSettingManager);
|
||||
final InterpreterInfo info1 = new InterpreterInfo("className1", "name1", true, null);
|
||||
final InterpreterInfo info2 = new InterpreterInfo("className2", "name1", true, null);
|
||||
factory.add("group1", new ArrayList<InterpreterInfo>() {{
|
||||
interpreterSettingManager.add("group1", new ArrayList<InterpreterInfo>() {{
|
||||
add(info1);
|
||||
}}, new ArrayList<Dependency>(), new InterpreterOption(true), Collections.EMPTY_MAP, "/path1", null);
|
||||
factory.add("group2", new ArrayList<InterpreterInfo>(){{
|
||||
interpreterSettingManager.add("group2", new ArrayList<InterpreterInfo>(){{
|
||||
add(info2);
|
||||
}}, new ArrayList<Dependency>(), new InterpreterOption(true), Collections.EMPTY_MAP, "/path2", null);
|
||||
|
||||
final InterpreterSetting setting1 = factory.createNewSetting("test-group1", "group1", new ArrayList<Dependency>(), new InterpreterOption(true), new Properties());
|
||||
final InterpreterSetting setting2 = factory.createNewSetting("test-group2", "group1", new ArrayList<Dependency>(), new InterpreterOption(true), new Properties());
|
||||
final InterpreterSetting setting1 = interpreterSettingManager.createNewSetting("test-group1", "group1", new ArrayList<Dependency>(), new InterpreterOption(true), new Properties());
|
||||
final InterpreterSetting setting2 = interpreterSettingManager.createNewSetting("test-group2", "group1", new ArrayList<Dependency>(), new InterpreterOption(true), new Properties());
|
||||
|
||||
factory.setInterpreters("user", "note", new ArrayList<String>() {{
|
||||
interpreterSettingManager.setInterpreters("user", "note", new ArrayList<String>() {{
|
||||
add(setting1.getId());
|
||||
add(setting2.getId());
|
||||
}});
|
||||
|
|
@ -336,20 +343,21 @@ public class InterpreterFactoryTest {
|
|||
|
||||
@Test
|
||||
public void testMultiUser() throws IOException, RepositoryException {
|
||||
factory = new InterpreterFactory(conf, null, null, null, depResolver, true);
|
||||
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
|
||||
factory = new InterpreterFactory(conf, null, null, null, depResolver, true, interpreterSettingManager);
|
||||
final InterpreterInfo info1 = new InterpreterInfo("className1", "name1", true, null);
|
||||
factory.add("group1", new ArrayList<InterpreterInfo>(){{
|
||||
interpreterSettingManager.add("group1", new ArrayList<InterpreterInfo>(){{
|
||||
add(info1);
|
||||
}}, new ArrayList<Dependency>(), new InterpreterOption(true), Collections.EMPTY_MAP, "/path1", null);
|
||||
|
||||
InterpreterOption perUserInterpreterOption = new InterpreterOption(true, InterpreterOption.ISOLATED, InterpreterOption.SHARED);
|
||||
final InterpreterSetting setting1 = factory.createNewSetting("test-group1", "group1", new ArrayList<Dependency>(), perUserInterpreterOption, new Properties());
|
||||
final InterpreterSetting setting1 = interpreterSettingManager.createNewSetting("test-group1", "group1", new ArrayList<Dependency>(), perUserInterpreterOption, new Properties());
|
||||
|
||||
factory.setInterpreters("user1", "note", new ArrayList<String>() {{
|
||||
interpreterSettingManager.setInterpreters("user1", "note", new ArrayList<String>() {{
|
||||
add(setting1.getId());
|
||||
}});
|
||||
|
||||
factory.setInterpreters("user2", "note", new ArrayList<String>() {{
|
||||
interpreterSettingManager.setInterpreters("user2", "note", new ArrayList<String>() {{
|
||||
add(setting1.getId());
|
||||
}});
|
||||
|
||||
|
|
@ -360,7 +368,7 @@ public class InterpreterFactoryTest {
|
|||
@Test
|
||||
public void testInvalidInterpreterSettingName() {
|
||||
try {
|
||||
factory.createNewSetting("new.mock1", "mock1", new LinkedList<Dependency>(), new InterpreterOption(false), new Properties());
|
||||
interpreterSettingManager.createNewSetting("new.mock1", "mock1", new LinkedList<Dependency>(), new InterpreterOption(false), new Properties());
|
||||
fail("expect fail because of invalid InterpreterSetting Name");
|
||||
} catch (IOException e) {
|
||||
assertEquals("'.' is invalid for InterpreterSetting name.", e.getMessage());
|
||||
|
|
@ -371,39 +379,40 @@ public class InterpreterFactoryTest {
|
|||
@Test
|
||||
public void getEditorSetting() throws IOException, RepositoryException, SchedulerException {
|
||||
List<String> intpIds = new ArrayList<>();
|
||||
for(InterpreterSetting intpSetting: factory.get()) {
|
||||
for(InterpreterSetting intpSetting: interpreterSettingManager.get()) {
|
||||
if (intpSetting.getName().startsWith("mock1")) {
|
||||
intpIds.add(intpSetting.getId());
|
||||
}
|
||||
}
|
||||
Note note = notebook.createNote(intpIds, new AuthenticationInfo("anonymous"));
|
||||
|
||||
Interpreter interpreter = factory.getInterpreter("user1", note.getId(), "mock11");
|
||||
// get editor setting from interpreter-setting.json
|
||||
Map<String, Object> editor = factory.getEditorSetting("user1", note.getId(), "mock11");
|
||||
Map<String, Object> editor = interpreterSettingManager.getEditorSetting(interpreter, "user1", note.getId(), "mock11");
|
||||
assertEquals("java", editor.get("language"));
|
||||
|
||||
// when interpreter is not loaded via interpreter-setting.json
|
||||
// or editor setting doesn't exit
|
||||
editor = factory.getEditorSetting("user1", note.getId(), "mock1");
|
||||
editor = interpreterSettingManager.getEditorSetting(factory.getInterpreter("user1", note.getId(), "mock1"),"user1", note.getId(), "mock1");
|
||||
assertEquals(null, editor.get("language"));
|
||||
|
||||
// when interpreter is not bound to note
|
||||
editor = factory.getEditorSetting("user1", note.getId(), "mock2");
|
||||
editor = interpreterSettingManager.getEditorSetting(factory.getInterpreter("user1", note.getId(), "mock11"),"user1", note.getId(), "mock2");
|
||||
assertEquals("text", editor.get("language"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerCustomInterpreterRunner() throws IOException {
|
||||
InterpreterFactory spyFactory = spy(factory);
|
||||
InterpreterSettingManager spyInterpreterSettingManager = spy(interpreterSettingManager);
|
||||
|
||||
doNothing().when(spyFactory).saveToFile();
|
||||
doNothing().when(spyInterpreterSettingManager).saveToFile();
|
||||
|
||||
ArrayList<InterpreterInfo> interpreterInfos1 = new ArrayList<>();
|
||||
interpreterInfos1.add(new InterpreterInfo("name1.class", "name1", true, Maps.<String, Object>newHashMap()));
|
||||
|
||||
spyFactory.add("normalGroup1", interpreterInfos1, Lists.<Dependency>newArrayList(), new InterpreterOption(true), Maps.<String, InterpreterProperty>newHashMap(), "/normalGroup1", null);
|
||||
spyInterpreterSettingManager.add("normalGroup1", interpreterInfos1, Lists.<Dependency>newArrayList(), new InterpreterOption(true), Maps.<String, InterpreterProperty>newHashMap(), "/normalGroup1", null);
|
||||
|
||||
spyFactory.createNewSetting("normalGroup1", "normalGroup1", Lists.<Dependency>newArrayList(), new InterpreterOption(true), new Properties());
|
||||
spyInterpreterSettingManager.createNewSetting("normalGroup1", "normalGroup1", Lists.<Dependency>newArrayList(), new InterpreterOption(true), new Properties());
|
||||
|
||||
ArrayList<InterpreterInfo> interpreterInfos2 = new ArrayList<>();
|
||||
interpreterInfos2.add(new InterpreterInfo("name1.class", "name1", true, Maps.<String, Object>newHashMap()));
|
||||
|
|
@ -412,13 +421,13 @@ public class InterpreterFactoryTest {
|
|||
|
||||
when(mockInterpreterRunner.getPath()).thenReturn("custom-linux-path.sh");
|
||||
|
||||
spyFactory.add("customGroup1", interpreterInfos2, Lists.<Dependency>newArrayList(), new InterpreterOption(true), Maps.<String, InterpreterProperty>newHashMap(), "/customGroup1", mockInterpreterRunner);
|
||||
spyInterpreterSettingManager.add("customGroup1", interpreterInfos2, Lists.<Dependency>newArrayList(), new InterpreterOption(true), Maps.<String, InterpreterProperty>newHashMap(), "/customGroup1", mockInterpreterRunner);
|
||||
|
||||
spyFactory.createNewSetting("customGroup1", "customGroup1", Lists.<Dependency>newArrayList(), new InterpreterOption(true), new Properties());
|
||||
spyInterpreterSettingManager.createNewSetting("customGroup1", "customGroup1", Lists.<Dependency>newArrayList(), new InterpreterOption(true), new Properties());
|
||||
|
||||
spyFactory.setInterpreters("anonymous", "noteCustome", spyFactory.getDefaultInterpreterSettingList());
|
||||
spyInterpreterSettingManager.setInterpreters("anonymous", "noteCustome", spyInterpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
|
||||
spyFactory.getInterpreter("anonymous", "noteCustome", "customGroup1");
|
||||
factory.getInterpreter("anonymous", "noteCustome", "customGroup1");
|
||||
|
||||
verify(mockInterpreterRunner, times(1)).getPath();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.apache.zeppelin.notebook;
|
|||
|
||||
import org.apache.zeppelin.interpreter.Interpreter;
|
||||
import org.apache.zeppelin.interpreter.InterpreterFactory;
|
||||
import org.apache.zeppelin.interpreter.InterpreterSettingManager;
|
||||
import org.apache.zeppelin.notebook.repo.NotebookRepo;
|
||||
import org.apache.zeppelin.scheduler.Scheduler;
|
||||
import org.apache.zeppelin.search.SearchService;
|
||||
|
|
@ -59,6 +60,9 @@ public class FolderTest {
|
|||
@Mock
|
||||
InterpreterFactory interpreterFactory;
|
||||
|
||||
@Mock
|
||||
InterpreterSettingManager interpreterSettingManager;
|
||||
|
||||
Folder folder;
|
||||
|
||||
Note note1;
|
||||
|
|
@ -67,13 +71,13 @@ public class FolderTest {
|
|||
|
||||
@Before
|
||||
public void createFolderAndNotes() {
|
||||
note1 = new Note(repo, interpreterFactory, jobListenerFactory, index, credentials, noteEventListener);
|
||||
note1 = new Note(repo, interpreterFactory, interpreterSettingManager, jobListenerFactory, index, credentials, noteEventListener);
|
||||
note1.setName("this/is/a/folder/note1");
|
||||
|
||||
note2 = new Note(repo, interpreterFactory, jobListenerFactory, index, credentials, noteEventListener);
|
||||
note2 = new Note(repo, interpreterFactory, interpreterSettingManager, jobListenerFactory, index, credentials, noteEventListener);
|
||||
note2.setName("this/is/a/folder/note2");
|
||||
|
||||
note3 = new Note(repo, interpreterFactory, jobListenerFactory, index, credentials, noteEventListener);
|
||||
note3 = new Note(repo, interpreterFactory, interpreterSettingManager, jobListenerFactory, index, credentials, noteEventListener);
|
||||
note3.setName("this/is/a/folder/note3");
|
||||
|
||||
folder = new Folder("this/is/a/folder");
|
||||
|
|
@ -114,7 +118,7 @@ public class FolderTest {
|
|||
|
||||
@Test
|
||||
public void addNoteTest() {
|
||||
Note note4 = new Note(repo, interpreterFactory, jobListenerFactory, index, credentials, noteEventListener);
|
||||
Note note4 = new Note(repo, interpreterFactory, interpreterSettingManager, jobListenerFactory, index, credentials, noteEventListener);
|
||||
note4.setName("this/is/a/folder/note4");
|
||||
|
||||
folder.addNote(note4);
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.apache.zeppelin.notebook;
|
|||
|
||||
import org.apache.zeppelin.interpreter.Interpreter;
|
||||
import org.apache.zeppelin.interpreter.InterpreterFactory;
|
||||
import org.apache.zeppelin.interpreter.InterpreterSettingManager;
|
||||
import org.apache.zeppelin.notebook.repo.NotebookRepo;
|
||||
import org.apache.zeppelin.scheduler.Scheduler;
|
||||
import org.apache.zeppelin.search.SearchService;
|
||||
|
|
@ -61,6 +62,9 @@ public class FolderViewTest {
|
|||
@Mock
|
||||
InterpreterFactory interpreterFactory;
|
||||
|
||||
@Mock
|
||||
InterpreterSettingManager interpreterSettingManager;
|
||||
|
||||
FolderView folderView;
|
||||
|
||||
Note note1;
|
||||
|
|
@ -85,7 +89,7 @@ public class FolderViewTest {
|
|||
Note abNote2;
|
||||
|
||||
private Note createNote() {
|
||||
Note note = new Note(repo, interpreterFactory, jobListenerFactory, index, credentials, noteEventListener);
|
||||
Note note = new Note(repo, interpreterFactory, interpreterSettingManager, jobListenerFactory, index, credentials, noteEventListener);
|
||||
note.setNoteNameListener(folderView);
|
||||
return note;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import org.apache.zeppelin.interpreter.Interpreter;
|
|||
import org.apache.zeppelin.interpreter.InterpreterFactory;
|
||||
import org.apache.zeppelin.interpreter.InterpreterOption;
|
||||
import org.apache.zeppelin.interpreter.InterpreterSetting;
|
||||
import org.apache.zeppelin.interpreter.InterpreterSettingManager;
|
||||
import org.apache.zeppelin.interpreter.LazyOpenInterpreter;
|
||||
import org.apache.zeppelin.interpreter.mock.MockInterpreter1;
|
||||
import org.apache.zeppelin.interpreter.mock.MockInterpreter11;
|
||||
|
|
@ -47,6 +48,7 @@ public class NoteInterpreterLoaderTest {
|
|||
private File tmpDir;
|
||||
private ZeppelinConfiguration conf;
|
||||
private InterpreterFactory factory;
|
||||
private InterpreterSettingManager interpreterSettingManager;
|
||||
private DependencyResolver depResolver;
|
||||
|
||||
@Before
|
||||
|
|
@ -66,7 +68,8 @@ public class NoteInterpreterLoaderTest {
|
|||
MockInterpreter2.register("mock2", "group2", "org.apache.zeppelin.interpreter.mock.MockInterpreter2");
|
||||
|
||||
depResolver = new DependencyResolver(tmpDir.getAbsolutePath() + "/local-repo");
|
||||
factory = new InterpreterFactory(conf, new InterpreterOption(false), null, null, null, depResolver, false);
|
||||
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
|
||||
factory = new InterpreterFactory(conf, null, null, null, depResolver, false, interpreterSettingManager);
|
||||
}
|
||||
|
||||
@After
|
||||
|
|
@ -77,7 +80,7 @@ public class NoteInterpreterLoaderTest {
|
|||
|
||||
@Test
|
||||
public void testGetInterpreter() throws IOException {
|
||||
factory.setInterpreters("user", "note", factory.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.setInterpreters("user", "note", interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
|
||||
// when there're no interpreter selection directive
|
||||
assertEquals("org.apache.zeppelin.interpreter.mock.MockInterpreter1", factory.getInterpreter("user", "note", null).getClassName());
|
||||
|
|
@ -96,20 +99,20 @@ public class NoteInterpreterLoaderTest {
|
|||
assertEquals("org.apache.zeppelin.interpreter.mock.MockInterpreter11", factory.getInterpreter("user", "note", "group1.mock11").getClassName());
|
||||
assertEquals("org.apache.zeppelin.interpreter.mock.MockInterpreter2", factory.getInterpreter("user", "note", "group2.mock2").getClassName());
|
||||
|
||||
factory.closeNote("user", "note");
|
||||
interpreterSettingManager.closeNote("user", "note");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoteSession() throws IOException {
|
||||
factory.setInterpreters("user", "noteA", factory.getDefaultInterpreterSettingList());
|
||||
factory.getInterpreterSettings("noteA").get(0).getOption().setPerNote(InterpreterOption.SCOPED);
|
||||
interpreterSettingManager.setInterpreters("user", "noteA", interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.getInterpreterSettings("noteA").get(0).getOption().setPerNote(InterpreterOption.SCOPED);
|
||||
|
||||
factory.setInterpreters("user", "noteB", factory.getDefaultInterpreterSettingList());
|
||||
factory.getInterpreterSettings("noteB").get(0).getOption().setPerNote(InterpreterOption.SCOPED);
|
||||
interpreterSettingManager.setInterpreters("user", "noteB", interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.getInterpreterSettings("noteB").get(0).getOption().setPerNote(InterpreterOption.SCOPED);
|
||||
|
||||
// interpreters are not created before accessing it
|
||||
assertNull(factory.getInterpreterSettings("noteA").get(0).getInterpreterGroup("user", "noteA").get("noteA"));
|
||||
assertNull(factory.getInterpreterSettings("noteB").get(0).getInterpreterGroup("user", "noteB").get("noteB"));
|
||||
assertNull(interpreterSettingManager.getInterpreterSettings("noteA").get(0).getInterpreterGroup("user", "noteA").get("noteA"));
|
||||
assertNull(interpreterSettingManager.getInterpreterSettings("noteB").get(0).getInterpreterGroup("user", "noteB").get("noteB"));
|
||||
|
||||
factory.getInterpreter("user", "noteA", null).open();
|
||||
factory.getInterpreter("user", "noteB", null).open();
|
||||
|
|
@ -119,35 +122,35 @@ public class NoteInterpreterLoaderTest {
|
|||
factory.getInterpreter("user", "noteB", null).getInterpreterGroup().getId()));
|
||||
|
||||
// interpreters are created after accessing it
|
||||
assertNotNull(factory.getInterpreterSettings("noteA").get(0).getInterpreterGroup("user", "noteA").get("noteA"));
|
||||
assertNotNull(factory.getInterpreterSettings("noteB").get(0).getInterpreterGroup("user", "noteB").get("noteB"));
|
||||
assertNotNull(interpreterSettingManager.getInterpreterSettings("noteA").get(0).getInterpreterGroup("user", "noteA").get("noteA"));
|
||||
assertNotNull(interpreterSettingManager.getInterpreterSettings("noteB").get(0).getInterpreterGroup("user", "noteB").get("noteB"));
|
||||
|
||||
// invalid close
|
||||
factory.closeNote("user", "note");
|
||||
assertNotNull(factory.getInterpreterSettings("noteA").get(0).getInterpreterGroup("user", "shared_process").get("noteA"));
|
||||
assertNotNull(factory.getInterpreterSettings("noteB").get(0).getInterpreterGroup("user", "shared_process").get("noteB"));
|
||||
interpreterSettingManager.closeNote("user", "note");
|
||||
assertNotNull(interpreterSettingManager.getInterpreterSettings("noteA").get(0).getInterpreterGroup("user", "shared_process").get("noteA"));
|
||||
assertNotNull(interpreterSettingManager.getInterpreterSettings("noteB").get(0).getInterpreterGroup("user", "shared_process").get("noteB"));
|
||||
|
||||
// when
|
||||
factory.closeNote("user", "noteA");
|
||||
factory.closeNote("user", "noteB");
|
||||
interpreterSettingManager.closeNote("user", "noteA");
|
||||
interpreterSettingManager.closeNote("user", "noteB");
|
||||
|
||||
// interpreters are destroyed after close
|
||||
assertNull(factory.getInterpreterSettings("noteA").get(0).getInterpreterGroup("user", "shared_process").get("noteA"));
|
||||
assertNull(factory.getInterpreterSettings("noteB").get(0).getInterpreterGroup("user", "shared_process").get("noteB"));
|
||||
assertNull(interpreterSettingManager.getInterpreterSettings("noteA").get(0).getInterpreterGroup("user", "shared_process").get("noteA"));
|
||||
assertNull(interpreterSettingManager.getInterpreterSettings("noteB").get(0).getInterpreterGroup("user", "shared_process").get("noteB"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotePerInterpreterProcess() throws IOException {
|
||||
factory.setInterpreters("user", "noteA", factory.getDefaultInterpreterSettingList());
|
||||
factory.getInterpreterSettings("noteA").get(0).getOption().setPerNote(InterpreterOption.ISOLATED);
|
||||
interpreterSettingManager.setInterpreters("user", "noteA", interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.getInterpreterSettings("noteA").get(0).getOption().setPerNote(InterpreterOption.ISOLATED);
|
||||
|
||||
factory.setInterpreters("user", "noteB", factory.getDefaultInterpreterSettingList());
|
||||
factory.getInterpreterSettings("noteB").get(0).getOption().setPerNote(InterpreterOption.ISOLATED);
|
||||
interpreterSettingManager.setInterpreters("user", "noteB", interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.getInterpreterSettings("noteB").get(0).getOption().setPerNote(InterpreterOption.ISOLATED);
|
||||
|
||||
// interpreters are not created before accessing it
|
||||
assertNull(factory.getInterpreterSettings("noteA").get(0).getInterpreterGroup("user", "noteA").get("shared_session"));
|
||||
assertNull(factory.getInterpreterSettings("noteB").get(0).getInterpreterGroup("user", "noteB").get("shared_session"));
|
||||
assertNull(interpreterSettingManager.getInterpreterSettings("noteA").get(0).getInterpreterGroup("user", "noteA").get("shared_session"));
|
||||
assertNull(interpreterSettingManager.getInterpreterSettings("noteB").get(0).getInterpreterGroup("user", "noteB").get("shared_session"));
|
||||
|
||||
factory.getInterpreter("user", "noteA", null).open();
|
||||
factory.getInterpreter("user", "noteB", null).open();
|
||||
|
|
@ -158,29 +161,29 @@ public class NoteInterpreterLoaderTest {
|
|||
factory.getInterpreter("user", "noteB", null).getInterpreterGroup().getId()));
|
||||
|
||||
// interpreters are created after accessing it
|
||||
assertNotNull(factory.getInterpreterSettings("noteA").get(0).getInterpreterGroup("user", "noteA").get("shared_session"));
|
||||
assertNotNull(factory.getInterpreterSettings("noteB").get(0).getInterpreterGroup("user", "noteB").get("shared_session"));
|
||||
assertNotNull(interpreterSettingManager.getInterpreterSettings("noteA").get(0).getInterpreterGroup("user", "noteA").get("shared_session"));
|
||||
assertNotNull(interpreterSettingManager.getInterpreterSettings("noteB").get(0).getInterpreterGroup("user", "noteB").get("shared_session"));
|
||||
|
||||
// when
|
||||
factory.closeNote("user", "noteA");
|
||||
factory.closeNote("user", "noteB");
|
||||
interpreterSettingManager.closeNote("user", "noteA");
|
||||
interpreterSettingManager.closeNote("user", "noteB");
|
||||
|
||||
// interpreters are destroyed after close
|
||||
assertNull(factory.getInterpreterSettings("noteA").get(0).getInterpreterGroup("user", "noteA").get("shared_session"));
|
||||
assertNull(factory.getInterpreterSettings("noteB").get(0).getInterpreterGroup("user", "noteB").get("shared_session"));
|
||||
assertNull(interpreterSettingManager.getInterpreterSettings("noteA").get(0).getInterpreterGroup("user", "noteA").get("shared_session"));
|
||||
assertNull(interpreterSettingManager.getInterpreterSettings("noteB").get(0).getInterpreterGroup("user", "noteB").get("shared_session"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoteInterpreterCloseForAll() throws IOException {
|
||||
factory.setInterpreters("user", "FitstNote", factory.getDefaultInterpreterSettingList());
|
||||
factory.getInterpreterSettings("FitstNote").get(0).getOption().setPerNote(InterpreterOption.SCOPED);
|
||||
interpreterSettingManager.setInterpreters("user", "FitstNote", interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.getInterpreterSettings("FitstNote").get(0).getOption().setPerNote(InterpreterOption.SCOPED);
|
||||
|
||||
factory.setInterpreters("user", "yourFirstNote", factory.getDefaultInterpreterSettingList());
|
||||
factory.getInterpreterSettings("yourFirstNote").get(0).getOption().setPerNote(InterpreterOption.ISOLATED);
|
||||
interpreterSettingManager.setInterpreters("user", "yourFirstNote", interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.getInterpreterSettings("yourFirstNote").get(0).getOption().setPerNote(InterpreterOption.ISOLATED);
|
||||
|
||||
// interpreters are not created before accessing it
|
||||
assertNull(factory.getInterpreterSettings("FitstNote").get(0).getInterpreterGroup("user", "FitstNote").get("FitstNote"));
|
||||
assertNull(factory.getInterpreterSettings("yourFirstNote").get(0).getInterpreterGroup("user", "yourFirstNote").get("yourFirstNote"));
|
||||
assertNull(interpreterSettingManager.getInterpreterSettings("FitstNote").get(0).getInterpreterGroup("user", "FitstNote").get("FitstNote"));
|
||||
assertNull(interpreterSettingManager.getInterpreterSettings("yourFirstNote").get(0).getInterpreterGroup("user", "yourFirstNote").get("yourFirstNote"));
|
||||
|
||||
Interpreter firstNoteIntp = factory.getInterpreter("user", "FitstNote", "group1.mock1");
|
||||
Interpreter yourFirstNoteIntp = factory.getInterpreter("user", "yourFirstNote", "group1.mock1");
|
||||
|
|
@ -191,7 +194,7 @@ public class NoteInterpreterLoaderTest {
|
|||
assertTrue(((LazyOpenInterpreter)firstNoteIntp).isOpen());
|
||||
assertTrue(((LazyOpenInterpreter)yourFirstNoteIntp).isOpen());
|
||||
|
||||
factory.closeNote("user", "FitstNote");
|
||||
interpreterSettingManager.closeNote("user", "FitstNote");
|
||||
|
||||
assertFalse(((LazyOpenInterpreter)firstNoteIntp).isOpen());
|
||||
assertTrue(((LazyOpenInterpreter)yourFirstNoteIntp).isOpen());
|
||||
|
|
@ -203,13 +206,13 @@ public class NoteInterpreterLoaderTest {
|
|||
assertTrue(((LazyOpenInterpreter)yourFirstNoteIntp).isOpen());
|
||||
|
||||
// invalid check
|
||||
factory.closeNote("invalid", "Note");
|
||||
interpreterSettingManager.closeNote("invalid", "Note");
|
||||
|
||||
assertTrue(((LazyOpenInterpreter)firstNoteIntp).isOpen());
|
||||
assertTrue(((LazyOpenInterpreter)yourFirstNoteIntp).isOpen());
|
||||
|
||||
// invalid contains value check
|
||||
factory.closeNote("u", "Note");
|
||||
interpreterSettingManager.closeNote("u", "Note");
|
||||
|
||||
assertTrue(((LazyOpenInterpreter)firstNoteIntp).isOpen());
|
||||
assertTrue(((LazyOpenInterpreter)yourFirstNoteIntp).isOpen());
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package org.apache.zeppelin.notebook;
|
|||
import org.apache.zeppelin.interpreter.Interpreter;
|
||||
import org.apache.zeppelin.interpreter.InterpreterFactory;
|
||||
import org.apache.zeppelin.interpreter.InterpreterResult;
|
||||
import org.apache.zeppelin.interpreter.InterpreterSettingManager;
|
||||
import org.apache.zeppelin.notebook.repo.NotebookRepo;
|
||||
import org.apache.zeppelin.scheduler.Scheduler;
|
||||
import org.apache.zeppelin.search.SearchService;
|
||||
|
|
@ -60,6 +61,9 @@ public class NoteTest {
|
|||
@Mock
|
||||
InterpreterFactory interpreterFactory;
|
||||
|
||||
@Mock
|
||||
InterpreterSettingManager interpreterSettingManager;
|
||||
|
||||
private AuthenticationInfo anonymous = new AuthenticationInfo("anonymous");
|
||||
|
||||
@Test
|
||||
|
|
@ -68,7 +72,7 @@ public class NoteTest {
|
|||
when(interpreter.getScheduler()).thenReturn(scheduler);
|
||||
|
||||
String pText = "%spark sc.version";
|
||||
Note note = new Note(repo, interpreterFactory, jobListenerFactory, index, credentials, noteEventListener);
|
||||
Note note = new Note(repo, interpreterFactory, interpreterSettingManager, jobListenerFactory, index, credentials, noteEventListener);
|
||||
|
||||
Paragraph p = note.addParagraph(AuthenticationInfo.ANONYMOUS);
|
||||
p.setText(pText);
|
||||
|
|
@ -84,7 +88,7 @@ public class NoteTest {
|
|||
|
||||
@Test
|
||||
public void addParagraphWithEmptyReplNameTest() {
|
||||
Note note = new Note(repo, interpreterFactory, jobListenerFactory, index, credentials, noteEventListener);
|
||||
Note note = new Note(repo, interpreterFactory, interpreterSettingManager, jobListenerFactory, index, credentials, noteEventListener);
|
||||
|
||||
Paragraph p = note.addParagraph(AuthenticationInfo.ANONYMOUS);
|
||||
assertNull(p.getText());
|
||||
|
|
@ -94,7 +98,7 @@ public class NoteTest {
|
|||
public void addParagraphWithLastReplNameTest() {
|
||||
when(interpreterFactory.getInterpreter(anyString(), anyString(), eq("spark"))).thenReturn(interpreter);
|
||||
|
||||
Note note = new Note(repo, interpreterFactory, jobListenerFactory, index, credentials, noteEventListener);
|
||||
Note note = new Note(repo, interpreterFactory, interpreterSettingManager, jobListenerFactory, index, credentials, noteEventListener);
|
||||
Paragraph p1 = note.addParagraph(AuthenticationInfo.ANONYMOUS);
|
||||
p1.setText("%spark ");
|
||||
Paragraph p2 = note.addParagraph(AuthenticationInfo.ANONYMOUS);
|
||||
|
|
@ -106,7 +110,7 @@ public class NoteTest {
|
|||
public void insertParagraphWithLastReplNameTest() {
|
||||
when(interpreterFactory.getInterpreter(anyString(), anyString(), eq("spark"))).thenReturn(interpreter);
|
||||
|
||||
Note note = new Note(repo, interpreterFactory, jobListenerFactory, index, credentials, noteEventListener);
|
||||
Note note = new Note(repo, interpreterFactory, interpreterSettingManager, jobListenerFactory, index, credentials, noteEventListener);
|
||||
Paragraph p1 = note.addParagraph(AuthenticationInfo.ANONYMOUS);
|
||||
p1.setText("%spark ");
|
||||
Paragraph p2 = note.insertParagraph(note.getParagraphs().size(), AuthenticationInfo.ANONYMOUS);
|
||||
|
|
@ -118,7 +122,7 @@ public class NoteTest {
|
|||
public void insertParagraphWithInvalidReplNameTest() {
|
||||
when(interpreterFactory.getInterpreter(anyString(), anyString(), eq("invalid"))).thenReturn(null);
|
||||
|
||||
Note note = new Note(repo, interpreterFactory, jobListenerFactory, index, credentials, noteEventListener);
|
||||
Note note = new Note(repo, interpreterFactory, interpreterSettingManager, jobListenerFactory, index, credentials, noteEventListener);
|
||||
Paragraph p1 = note.addParagraph(AuthenticationInfo.ANONYMOUS);
|
||||
p1.setText("%invalid ");
|
||||
Paragraph p2 = note.insertParagraph(note.getParagraphs().size(), AuthenticationInfo.ANONYMOUS);
|
||||
|
|
@ -131,7 +135,7 @@ public class NoteTest {
|
|||
when(interpreterFactory.getInterpreter(anyString(), anyString(), eq("md"))).thenReturn(interpreter);
|
||||
when(interpreter.getScheduler()).thenReturn(scheduler);
|
||||
|
||||
Note note = new Note(repo, interpreterFactory, jobListenerFactory, index, credentials, noteEventListener);
|
||||
Note note = new Note(repo, interpreterFactory, interpreterSettingManager, jobListenerFactory, index, credentials, noteEventListener);
|
||||
Paragraph p1 = note.addParagraph(AuthenticationInfo.ANONYMOUS);
|
||||
InterpreterResult result = new InterpreterResult(InterpreterResult.Code.SUCCESS, InterpreterResult.Type.TEXT, "result");
|
||||
p1.setResult(result);
|
||||
|
|
@ -147,7 +151,7 @@ public class NoteTest {
|
|||
|
||||
@Test
|
||||
public void getFolderIdTest() {
|
||||
Note note = new Note(repo, interpreterFactory, jobListenerFactory, index, credentials, noteEventListener);
|
||||
Note note = new Note(repo, interpreterFactory, interpreterSettingManager, jobListenerFactory, index, credentials, noteEventListener);
|
||||
// Ordinary case test
|
||||
note.setName("this/is/a/folder/noteName");
|
||||
assertEquals("this/is/a/folder", note.getFolderId());
|
||||
|
|
@ -163,7 +167,7 @@ public class NoteTest {
|
|||
|
||||
@Test
|
||||
public void getNameWithoutPathTest() {
|
||||
Note note = new Note(repo, interpreterFactory, jobListenerFactory, index, credentials, noteEventListener);
|
||||
Note note = new Note(repo, interpreterFactory, interpreterSettingManager, jobListenerFactory, index, credentials, noteEventListener);
|
||||
// Notes in the root folder
|
||||
note.setName("noteOnRootFolder");
|
||||
assertEquals("noteOnRootFolder", note.getNameWithoutPath());
|
||||
|
|
@ -178,7 +182,7 @@ public class NoteTest {
|
|||
|
||||
@Test
|
||||
public void isTrashTest() {
|
||||
Note note = new Note(repo, interpreterFactory, jobListenerFactory, index, credentials, noteEventListener);
|
||||
Note note = new Note(repo, interpreterFactory, interpreterSettingManager, jobListenerFactory, index, credentials, noteEventListener);
|
||||
// Notes in the root folder
|
||||
note.setName("noteOnRootFolder");
|
||||
assertFalse(note.isTrash());
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ public class NotebookTest implements JobListenerFactory{
|
|||
private Notebook notebook;
|
||||
private NotebookRepo notebookRepo;
|
||||
private InterpreterFactory factory;
|
||||
private InterpreterSettingManager interpreterSettingManager;
|
||||
private DependencyResolver depResolver;
|
||||
private NotebookAuthorization notebookAuthorization;
|
||||
private Credentials credentials;
|
||||
|
|
@ -91,14 +92,15 @@ public class NotebookTest implements JobListenerFactory{
|
|||
MockInterpreter2.register("mock2", "org.apache.zeppelin.interpreter.mock.MockInterpreter2");
|
||||
|
||||
depResolver = new DependencyResolver(tmpDir.getAbsolutePath() + "/local-repo");
|
||||
factory = new InterpreterFactory(conf, new InterpreterOption(false), null, null, null, depResolver, false);
|
||||
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(false));
|
||||
factory = new InterpreterFactory(conf, null, null, null, depResolver, false, interpreterSettingManager);
|
||||
|
||||
SearchService search = mock(SearchService.class);
|
||||
notebookRepo = new VFSNotebookRepo(conf);
|
||||
notebookAuthorization = NotebookAuthorization.init(conf);
|
||||
credentials = new Credentials(conf.credentialsPersist(), conf.getCredentialsPath());
|
||||
|
||||
notebook = new Notebook(conf, notebookRepo, schedulerFactory, factory, this, search,
|
||||
notebook = new Notebook(conf, notebookRepo, schedulerFactory, factory, interpreterSettingManager, this, search,
|
||||
notebookAuthorization, credentials);
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +112,7 @@ public class NotebookTest implements JobListenerFactory{
|
|||
@Test
|
||||
public void testSelectingReplImplementation() throws IOException {
|
||||
Note note = notebook.createNote(anonymous);
|
||||
factory.setInterpreters(anonymous.getUser(), note.getId(), factory.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.setInterpreters(anonymous.getUser(), note.getId(), interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
|
||||
// run with default repl
|
||||
Paragraph p1 = note.addParagraph(AuthenticationInfo.ANONYMOUS);
|
||||
|
|
@ -236,7 +238,8 @@ public class NotebookTest implements JobListenerFactory{
|
|||
|
||||
Notebook notebook2 = new Notebook(
|
||||
conf, notebookRepo, schedulerFactory,
|
||||
new InterpreterFactory(conf, null, null, null, depResolver, false), this, null, null, null);
|
||||
new InterpreterFactory(conf, null, null, null, depResolver, false, interpreterSettingManager),
|
||||
interpreterSettingManager, null, null, null, null);
|
||||
|
||||
assertEquals(1, notebook2.getAllNotes().size());
|
||||
notebook.removeNote(note.getId(), anonymous);
|
||||
|
|
@ -292,7 +295,7 @@ public class NotebookTest implements JobListenerFactory{
|
|||
@Test
|
||||
public void testRunAll() throws IOException {
|
||||
Note note = notebook.createNote(anonymous);
|
||||
factory.setInterpreters("user", note.getId(), factory.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.setInterpreters("user", note.getId(), interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
|
||||
// p1
|
||||
Paragraph p1 = note.addParagraph(AuthenticationInfo.ANONYMOUS);
|
||||
|
|
@ -331,7 +334,7 @@ public class NotebookTest implements JobListenerFactory{
|
|||
public void testSchedule() throws InterruptedException, IOException {
|
||||
// create a note and a paragraph
|
||||
Note note = notebook.createNote(anonymous);
|
||||
factory.setInterpreters("user", note.getId(), factory.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.setInterpreters("user", note.getId(), interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
|
||||
Paragraph p = note.addParagraph(AuthenticationInfo.ANONYMOUS);
|
||||
Map config = new HashMap<>();
|
||||
|
|
@ -364,7 +367,7 @@ public class NotebookTest implements JobListenerFactory{
|
|||
public void testSchedulePoolUsage() throws InterruptedException, IOException {
|
||||
// create a note and a paragraph
|
||||
Note note = notebook.createNote(anonymous);
|
||||
factory.setInterpreters("user", note.getId(), factory.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.setInterpreters("user", note.getId(), interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
Paragraph p = note.addParagraph(AuthenticationInfo.ANONYMOUS);
|
||||
Map config = Maps.newHashMap();
|
||||
p.setConfig(config);
|
||||
|
|
@ -432,7 +435,7 @@ public class NotebookTest implements JobListenerFactory{
|
|||
public void testAutoRestartInterpreterAfterSchedule() throws InterruptedException, IOException{
|
||||
// create a note and a paragraph
|
||||
Note note = notebook.createNote(anonymous);
|
||||
factory.setInterpreters(anonymous.getUser(), note.getId(), factory.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.setInterpreters(anonymous.getUser(), note.getId(), interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
|
||||
Paragraph p = note.addParagraph(AuthenticationInfo.ANONYMOUS);
|
||||
Map config = new HashMap<>();
|
||||
|
|
@ -485,7 +488,7 @@ public class NotebookTest implements JobListenerFactory{
|
|||
public void testExportAndImportNote() throws IOException, CloneNotSupportedException,
|
||||
InterruptedException, InterpreterException, SchedulerException, RepositoryException {
|
||||
Note note = notebook.createNote(anonymous);
|
||||
factory.setInterpreters("user", note.getId(), factory.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.setInterpreters("user", note.getId(), interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
|
||||
final Paragraph p = note.addParagraph(AuthenticationInfo.ANONYMOUS);
|
||||
String simpleText = "hello world";
|
||||
|
|
@ -524,7 +527,7 @@ public class NotebookTest implements JobListenerFactory{
|
|||
public void testCloneNote() throws IOException, CloneNotSupportedException,
|
||||
InterruptedException, InterpreterException, SchedulerException, RepositoryException {
|
||||
Note note = notebook.createNote(anonymous);
|
||||
factory.setInterpreters("user", note.getId(), factory.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.setInterpreters("user", note.getId(), interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
|
||||
final Paragraph p = note.addParagraph(AuthenticationInfo.ANONYMOUS);
|
||||
p.setText("hello world");
|
||||
|
|
@ -558,7 +561,7 @@ public class NotebookTest implements JobListenerFactory{
|
|||
public void testCloneNoteWithNoName() throws IOException, CloneNotSupportedException,
|
||||
InterruptedException {
|
||||
Note note = notebook.createNote(anonymous);
|
||||
factory.setInterpreters(anonymous.getUser(), note.getId(), factory.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.setInterpreters(anonymous.getUser(), note.getId(), interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
|
||||
Note cloneNote = notebook.cloneNote(note.getId(), null, anonymous);
|
||||
assertEquals(cloneNote.getName(), "Note " + cloneNote.getId());
|
||||
|
|
@ -570,7 +573,7 @@ public class NotebookTest implements JobListenerFactory{
|
|||
public void testCloneNoteWithExceptionResult() throws IOException, CloneNotSupportedException,
|
||||
InterruptedException {
|
||||
Note note = notebook.createNote(anonymous);
|
||||
factory.setInterpreters(anonymous.getUser(), note.getId(), factory.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.setInterpreters(anonymous.getUser(), note.getId(), interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
|
||||
final Paragraph p = note.addParagraph(AuthenticationInfo.ANONYMOUS);
|
||||
p.setText("hello world");
|
||||
|
|
@ -595,7 +598,7 @@ public class NotebookTest implements JobListenerFactory{
|
|||
@Test
|
||||
public void testResourceRemovealOnParagraphNoteRemove() throws IOException {
|
||||
Note note = notebook.createNote(anonymous);
|
||||
factory.setInterpreters(anonymous.getUser(), note.getId(), factory.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.setInterpreters(anonymous.getUser(), note.getId(), interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
for (InterpreterGroup intpGroup : InterpreterGroup.getAll()) {
|
||||
intpGroup.setResourcePool(new LocalResourcePool(intpGroup.getId()));
|
||||
}
|
||||
|
|
@ -624,9 +627,9 @@ public class NotebookTest implements JobListenerFactory{
|
|||
IOException {
|
||||
// create a note and a paragraph
|
||||
Note note = notebook.createNote(anonymous);
|
||||
factory.setInterpreters(anonymous.getUser(), note.getId(), factory.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.setInterpreters(anonymous.getUser(), note.getId(), interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
|
||||
AngularObjectRegistry registry = factory
|
||||
AngularObjectRegistry registry = interpreterSettingManager
|
||||
.getInterpreterSettings(note.getId()).get(0).getInterpreterGroup(anonymous.getUser(), "sharedProcess")
|
||||
.getAngularObjectRegistry();
|
||||
|
||||
|
|
@ -657,9 +660,9 @@ public class NotebookTest implements JobListenerFactory{
|
|||
IOException {
|
||||
// create a note and a paragraph
|
||||
Note note = notebook.createNote(anonymous);
|
||||
factory.setInterpreters(anonymous.getUser(), note.getId(), factory.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.setInterpreters(anonymous.getUser(), note.getId(), interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
|
||||
AngularObjectRegistry registry = factory
|
||||
AngularObjectRegistry registry = interpreterSettingManager
|
||||
.getInterpreterSettings(note.getId()).get(0).getInterpreterGroup(anonymous.getUser(), "sharedProcess")
|
||||
.getAngularObjectRegistry();
|
||||
|
||||
|
|
@ -691,9 +694,9 @@ public class NotebookTest implements JobListenerFactory{
|
|||
IOException {
|
||||
// create a note and a paragraph
|
||||
Note note = notebook.createNote(anonymous);
|
||||
factory.setInterpreters(anonymous.getUser(), note.getId(), factory.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.setInterpreters(anonymous.getUser(), note.getId(), interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
|
||||
AngularObjectRegistry registry = factory
|
||||
AngularObjectRegistry registry = interpreterSettingManager
|
||||
.getInterpreterSettings(note.getId()).get(0).getInterpreterGroup(anonymous.getUser(), "sharedProcess")
|
||||
.getAngularObjectRegistry();
|
||||
|
||||
|
|
@ -703,8 +706,8 @@ public class NotebookTest implements JobListenerFactory{
|
|||
registry.add("o2", "object2", null, null);
|
||||
|
||||
// restart interpreter
|
||||
factory.restart(factory.getInterpreterSettings(note.getId()).get(0).getId());
|
||||
registry = factory.getInterpreterSettings(note.getId()).get(0).getInterpreterGroup(anonymous.getUser(), "sharedProcess")
|
||||
interpreterSettingManager.restart(interpreterSettingManager.getInterpreterSettings(note.getId()).get(0).getId());
|
||||
registry = interpreterSettingManager.getInterpreterSettings(note.getId()).get(0).getInterpreterGroup(anonymous.getUser(), "sharedProcess")
|
||||
.getAngularObjectRegistry();
|
||||
|
||||
// local and global scope object should be removed
|
||||
|
|
@ -804,7 +807,7 @@ public class NotebookTest implements JobListenerFactory{
|
|||
public void testAbortParagraphStatusOnInterpreterRestart() throws InterruptedException,
|
||||
IOException {
|
||||
Note note = notebook.createNote(anonymous);
|
||||
factory.setInterpreters(anonymous.getUser(), note.getId(), factory.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.setInterpreters(anonymous.getUser(), note.getId(), interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
|
||||
// create three paragraphs
|
||||
Paragraph p1 = note.addParagraph(anonymous);
|
||||
|
|
@ -825,7 +828,7 @@ public class NotebookTest implements JobListenerFactory{
|
|||
assertEquals(Status.PENDING, p3.getStatus());
|
||||
|
||||
// restart interpreter
|
||||
factory.restart(factory.getInterpreterSettings(note.getId()).get(0).getId());
|
||||
interpreterSettingManager.restart(interpreterSettingManager.getInterpreterSettings(note.getId()).get(0).getId());
|
||||
|
||||
// make sure three differnt status aborted well.
|
||||
assertEquals(Status.FINISHED, p1.getStatus());
|
||||
|
|
@ -844,9 +847,9 @@ public class NotebookTest implements JobListenerFactory{
|
|||
p1.setAuthenticationInfo(anonymous);
|
||||
|
||||
// restart interpreter with per user session enabled
|
||||
for (InterpreterSetting setting : factory.getInterpreterSettings(note1.getId())) {
|
||||
for (InterpreterSetting setting : interpreterSettingManager.getInterpreterSettings(note1.getId())) {
|
||||
setting.getOption().setPerNote(setting.getOption().SCOPED);
|
||||
notebook.getInterpreterFactory().restart(setting.getId());
|
||||
notebook.getInterpreterSettingManager().restart(setting.getId());
|
||||
}
|
||||
|
||||
note1.run(p1.getId());
|
||||
|
|
@ -892,9 +895,9 @@ public class NotebookTest implements JobListenerFactory{
|
|||
|
||||
|
||||
// restart interpreter with per note session enabled
|
||||
for (InterpreterSetting setting : notebook.getInterpreterFactory().getInterpreterSettings(note1.getId())) {
|
||||
for (InterpreterSetting setting : notebook.getInterpreterSettingManager().getInterpreterSettings(note1.getId())) {
|
||||
setting.getOption().setPerNote(InterpreterOption.SCOPED);
|
||||
notebook.getInterpreterFactory().restart(setting.getId());
|
||||
notebook.getInterpreterSettingManager().restart(setting.getId());
|
||||
}
|
||||
|
||||
// run per note session enabled
|
||||
|
|
@ -935,10 +938,10 @@ public class NotebookTest implements JobListenerFactory{
|
|||
assertEquals(p1.getResult().message().get(0).getData(), p2.getResult().message().get(0).getData());
|
||||
|
||||
// restart interpreter with scoped mode enabled
|
||||
for (InterpreterSetting setting : notebook.getInterpreterFactory().getInterpreterSettings(note1.getId())) {
|
||||
for (InterpreterSetting setting : notebook.getInterpreterSettingManager().getInterpreterSettings(note1.getId())) {
|
||||
setting.getOption().setPerNote(InterpreterOption.SCOPED);
|
||||
notebook.getInterpreterFactory().restart(setting.getId(), note1.getId());
|
||||
notebook.getInterpreterFactory().restart(setting.getId(), note2.getId());
|
||||
notebook.getInterpreterSettingManager().restart(setting.getId(), note1.getId());
|
||||
notebook.getInterpreterSettingManager().restart(setting.getId(), note2.getId());
|
||||
}
|
||||
|
||||
// run per note session enabled
|
||||
|
|
@ -951,10 +954,10 @@ public class NotebookTest implements JobListenerFactory{
|
|||
assertNotEquals(p1.getResult().message().get(0).getData(), p2.getResult().message().get(0).getData());
|
||||
|
||||
// restart interpreter with isolated mode enabled
|
||||
for (InterpreterSetting setting : notebook.getInterpreterFactory().getInterpreterSettings(note1.getId())) {
|
||||
for (InterpreterSetting setting : notebook.getInterpreterSettingManager().getInterpreterSettings(note1.getId())) {
|
||||
setting.getOption().setPerNote(InterpreterOption.ISOLATED);
|
||||
notebook.getInterpreterFactory().restart(setting.getId(), note1.getId());
|
||||
notebook.getInterpreterFactory().restart(setting.getId(), note2.getId());
|
||||
notebook.getInterpreterSettingManager().restart(setting.getId(), note1.getId());
|
||||
notebook.getInterpreterSettingManager().restart(setting.getId(), note2.getId());
|
||||
}
|
||||
|
||||
// run per note process enabled
|
||||
|
|
@ -979,9 +982,9 @@ public class NotebookTest implements JobListenerFactory{
|
|||
p1.setText("getId");
|
||||
|
||||
// restart interpreter with per note session enabled
|
||||
for (InterpreterSetting setting : factory.getInterpreterSettings(note1.getId())) {
|
||||
for (InterpreterSetting setting : interpreterSettingManager.getInterpreterSettings(note1.getId())) {
|
||||
setting.getOption().setPerNote(InterpreterOption.SCOPED);
|
||||
notebook.getInterpreterFactory().restart(setting.getId());
|
||||
notebook.getInterpreterSettingManager().restart(setting.getId());
|
||||
}
|
||||
|
||||
note1.run(p1.getId());
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ public class ParagraphTest {
|
|||
final String scriptBody = "My name is ${name} and I am ${age=20} years old. " +
|
||||
"My occupation is ${ job = engineer | developer | artists}";
|
||||
|
||||
final Paragraph paragraph = new Paragraph(note, null, null);
|
||||
final Paragraph paragraph = new Paragraph(note, null, null, null);
|
||||
final String paragraphId = paragraph.getId();
|
||||
|
||||
final AngularObject nameAO = AngularObjectBuilder.build("name", "DuyHai DOAN", noteId,
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import org.apache.zeppelin.interpreter.InterpreterFactory;
|
|||
import org.apache.zeppelin.interpreter.InterpreterOption;
|
||||
import org.apache.zeppelin.interpreter.InterpreterOutput;
|
||||
import org.apache.zeppelin.interpreter.InterpreterResultMessage;
|
||||
import org.apache.zeppelin.interpreter.InterpreterSettingManager;
|
||||
import org.apache.zeppelin.interpreter.mock.MockInterpreter1;
|
||||
import org.apache.zeppelin.interpreter.mock.MockInterpreter2;
|
||||
import org.apache.zeppelin.notebook.*;
|
||||
|
|
@ -66,6 +67,7 @@ public class NotebookRepoSyncTest implements JobListenerFactory {
|
|||
private Notebook notebookSync;
|
||||
private NotebookRepoSync notebookRepoSync;
|
||||
private InterpreterFactory factory;
|
||||
private InterpreterSettingManager interpreterSettingManager;
|
||||
private DependencyResolver depResolver;
|
||||
private SearchService search;
|
||||
private NotebookAuthorization notebookAuthorization;
|
||||
|
|
@ -101,13 +103,14 @@ public class NotebookRepoSyncTest implements JobListenerFactory {
|
|||
MockInterpreter2.register("mock2", "org.apache.zeppelin.interpreter.mock.MockInterpreter2");
|
||||
|
||||
depResolver = new DependencyResolver(mainZepDir.getAbsolutePath() + "/local-repo");
|
||||
factory = new InterpreterFactory(conf, new InterpreterOption(false), null, null, null, depResolver, false);
|
||||
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
|
||||
factory = new InterpreterFactory(conf, null, null, null, depResolver, false, interpreterSettingManager);
|
||||
|
||||
search = mock(SearchService.class);
|
||||
notebookRepoSync = new NotebookRepoSync(conf);
|
||||
notebookAuthorization = NotebookAuthorization.init(conf);
|
||||
credentials = new Credentials(conf.credentialsPersist(), conf.getCredentialsPath());
|
||||
notebookSync = new Notebook(conf, notebookRepoSync, schedulerFactory, factory, this, search,
|
||||
notebookSync = new Notebook(conf, notebookRepoSync, schedulerFactory, factory, interpreterSettingManager, this, search,
|
||||
notebookAuthorization, credentials);
|
||||
anonymous = new AuthenticationInfo("anonymous");
|
||||
}
|
||||
|
|
@ -236,7 +239,7 @@ public class NotebookRepoSyncTest implements JobListenerFactory {
|
|||
System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_ONE_WAY_SYNC.getVarName(), "true");
|
||||
conf = ZeppelinConfiguration.create();
|
||||
notebookRepoSync = new NotebookRepoSync(conf);
|
||||
notebookSync = new Notebook(conf, notebookRepoSync, schedulerFactory, factory, this, search,
|
||||
notebookSync = new Notebook(conf, notebookRepoSync, schedulerFactory, factory, interpreterSettingManager, this, search,
|
||||
notebookAuthorization, credentials);
|
||||
|
||||
// check that both storage repos are empty
|
||||
|
|
@ -284,7 +287,7 @@ public class NotebookRepoSyncTest implements JobListenerFactory {
|
|||
ZeppelinConfiguration vConf = ZeppelinConfiguration.create();
|
||||
|
||||
NotebookRepoSync vRepoSync = new NotebookRepoSync(vConf);
|
||||
Notebook vNotebookSync = new Notebook(vConf, vRepoSync, schedulerFactory, factory, this, search,
|
||||
Notebook vNotebookSync = new Notebook(vConf, vRepoSync, schedulerFactory, factory, interpreterSettingManager, this, search,
|
||||
notebookAuthorization, credentials);
|
||||
|
||||
// one git versioned storage initialized
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars;
|
|||
import org.apache.zeppelin.dep.DependencyResolver;
|
||||
import org.apache.zeppelin.interpreter.InterpreterFactory;
|
||||
import org.apache.zeppelin.interpreter.InterpreterOption;
|
||||
import org.apache.zeppelin.interpreter.InterpreterSettingManager;
|
||||
import org.apache.zeppelin.interpreter.mock.MockInterpreter1;
|
||||
import org.apache.zeppelin.notebook.JobListenerFactory;
|
||||
import org.apache.zeppelin.notebook.Note;
|
||||
|
|
@ -55,6 +56,7 @@ public class VFSNotebookRepoTest implements JobListenerFactory {
|
|||
private SchedulerFactory schedulerFactory;
|
||||
private Notebook notebook;
|
||||
private NotebookRepo notebookRepo;
|
||||
private InterpreterSettingManager interpreterSettingManager;
|
||||
private InterpreterFactory factory;
|
||||
private DependencyResolver depResolver;
|
||||
private NotebookAuthorization notebookAuthorization;
|
||||
|
|
@ -84,12 +86,13 @@ public class VFSNotebookRepoTest implements JobListenerFactory {
|
|||
|
||||
this.schedulerFactory = new SchedulerFactory();
|
||||
depResolver = new DependencyResolver(mainZepDir.getAbsolutePath() + "/local-repo");
|
||||
factory = new InterpreterFactory(conf, new InterpreterOption(false), null, null, null, depResolver, false);
|
||||
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
|
||||
factory = new InterpreterFactory(conf, null, null, null, depResolver, false, interpreterSettingManager);
|
||||
|
||||
SearchService search = mock(SearchService.class);
|
||||
notebookRepo = new VFSNotebookRepo(conf);
|
||||
notebookAuthorization = NotebookAuthorization.init(conf);
|
||||
notebook = new Notebook(conf, notebookRepo, schedulerFactory, factory, this, search,
|
||||
notebook = new Notebook(conf, notebookRepo, schedulerFactory, factory, interpreterSettingManager, this, search,
|
||||
notebookAuthorization, null);
|
||||
}
|
||||
|
||||
|
|
@ -118,7 +121,7 @@ public class VFSNotebookRepoTest implements JobListenerFactory {
|
|||
public void testSaveNotebook() throws IOException, InterruptedException {
|
||||
AuthenticationInfo anonymous = new AuthenticationInfo("anonymous");
|
||||
Note note = notebook.createNote(anonymous);
|
||||
factory.setInterpreters("user", note.getId(), factory.getDefaultInterpreterSettingList());
|
||||
interpreterSettingManager.setInterpreters("user", note.getId(), interpreterSettingManager.getDefaultInterpreterSettingList());
|
||||
|
||||
Paragraph p1 = note.addParagraph(AuthenticationInfo.ANONYMOUS);
|
||||
Map<String, Object> config = p1.getConfig();
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.zeppelin.interpreter.InterpreterFactory;
|
||||
import org.apache.zeppelin.interpreter.InterpreterSettingManager;
|
||||
import org.apache.zeppelin.notebook.Note;
|
||||
import org.apache.zeppelin.notebook.Paragraph;
|
||||
import org.apache.zeppelin.notebook.repo.NotebookRepo;
|
||||
|
|
@ -41,6 +42,7 @@ public class LuceneSearchTest {
|
|||
|
||||
private static NotebookRepo notebookRepoMock;
|
||||
private static InterpreterFactory interpreterFactory;
|
||||
private static InterpreterSettingManager interpreterSettingManager;
|
||||
|
||||
private SearchService noteSearchService;
|
||||
private AuthenticationInfo anonymous;
|
||||
|
|
@ -49,6 +51,7 @@ public class LuceneSearchTest {
|
|||
public static void beforeStartUp() {
|
||||
notebookRepoMock = mock(NotebookRepo.class);
|
||||
interpreterFactory = mock(InterpreterFactory.class);
|
||||
interpreterSettingManager = mock(InterpreterSettingManager.class);
|
||||
|
||||
// when(replLoaderMock.getInterpreterSettings())
|
||||
// .thenReturn(ImmutableList.<InterpreterSetting>of());
|
||||
|
|
@ -288,7 +291,7 @@ public class LuceneSearchTest {
|
|||
}
|
||||
|
||||
private Note newNote(String name) {
|
||||
Note note = new Note(notebookRepoMock, interpreterFactory, null, noteSearchService, null, null);
|
||||
Note note = new Note(notebookRepoMock, interpreterFactory, interpreterSettingManager, null, noteSearchService, null, null);
|
||||
note.setName(name);
|
||||
return note;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue