use of org.apache.zeppelin.interpreter.InterpreterNotFoundException in project zeppelin by apache.
the class Paragraph method completion.
public List<InterpreterCompletion> completion(String buffer, int cursor) {
setText(buffer);
try {
this.interpreter = getBindedInterpreter();
} catch (InterpreterNotFoundException e) {
LOGGER.debug("Unable to get completion because there's no interpreter bind to it", e);
return new ArrayList<>();
}
cursor = calculateCursorPosition(buffer, cursor);
InterpreterContext interpreterContext = getInterpreterContext();
try {
return this.interpreter.completion(this.scriptText, cursor, interpreterContext);
} catch (InterpreterException e) {
LOGGER.warn("Fail to get completion", e);
return new ArrayList<>();
}
}
use of org.apache.zeppelin.interpreter.InterpreterNotFoundException in project zeppelin by apache.
the class Paragraph method recover.
public void recover() {
try {
LOGGER.info("Recovering paragraph: {}", getId());
this.interpreter = getBindedInterpreter();
InterpreterSetting interpreterSetting = ((ManagedInterpreterGroup) interpreter.getInterpreterGroup()).getInterpreterSetting();
Map<String, Object> config = interpreterSetting.getConfig(interpreter.getClassName());
mergeConfig(config);
if (shouldSkipRunParagraph()) {
LOGGER.info("Skip to run blank paragraph. {}", getId());
setStatus(Job.Status.FINISHED);
return;
}
setStatus(Status.READY);
localProperties.put("isRecover", "true");
for (List<Interpreter> sessions : this.interpreter.getInterpreterGroup().values()) {
for (Interpreter intp : sessions) {
// exclude ConfInterpreter
if (intp instanceof RemoteInterpreter) {
((RemoteInterpreter) intp).setOpened(true);
}
}
}
if (getConfig().get("enabled") == null || (Boolean) getConfig().get("enabled")) {
setAuthenticationInfo(getAuthenticationInfo());
interpreter.getScheduler().submit(this);
}
} catch (InterpreterNotFoundException e) {
InterpreterResult intpResult = new InterpreterResult(InterpreterResult.Code.ERROR, String.format("Interpreter %s not found", this.intpText));
setReturn(intpResult, e);
setStatus(Job.Status.ERROR);
} catch (Throwable e) {
InterpreterResult intpResult = new InterpreterResult(InterpreterResult.Code.ERROR, "Unexpected exception: " + ExceptionUtils.getStackTrace(e));
setReturn(intpResult, e);
setStatus(Job.Status.ERROR);
}
}
use of org.apache.zeppelin.interpreter.InterpreterNotFoundException in project zeppelin by apache.
the class Note method getBindedInterpreterSettings.
public List<InterpreterSetting> getBindedInterpreterSettings(List<String> userAndRoles) {
// use LinkedHashSet because order matters, the first one represent the default interpreter setting.
Set<InterpreterSetting> settings = new LinkedHashSet<>();
// add the default interpreter group
InterpreterSetting defaultIntpSetting = interpreterSettingManager.getByName(getDefaultInterpreterGroup());
if (defaultIntpSetting != null) {
settings.add(defaultIntpSetting);
}
// add the interpreter setting with the same group of default interpreter group
if (defaultIntpSetting != null) {
for (InterpreterSetting intpSetting : interpreterSettingManager.get()) {
if (intpSetting.getGroup().equals(defaultIntpSetting.getGroup())) {
if (intpSetting.isUserAuthorized(userAndRoles)) {
settings.add(intpSetting);
}
}
}
}
// add interpreter group used by each paragraph
for (Paragraph p : getParagraphs()) {
try {
Interpreter intp = p.getBindedInterpreter();
InterpreterSetting interpreterSetting = ((ManagedInterpreterGroup) intp.getInterpreterGroup()).getInterpreterSetting();
if (interpreterSetting.isUserAuthorized(userAndRoles)) {
settings.add(interpreterSetting);
}
} catch (InterpreterNotFoundException e) {
// ignore this
}
}
return new ArrayList<>(settings);
}
use of org.apache.zeppelin.interpreter.InterpreterNotFoundException in project zeppelin by apache.
the class ZeppelinSparkClusterTest method testAngularObjects.
@Test
public void testAngularObjects() throws IOException, InterpreterNotFoundException {
assumeTrue("Hadoop version mismatch, skip test", isHadoopVersionMatch());
String noteId = null;
try {
noteId = TestUtils.getInstance(Notebook.class).createNote("note1", anonymous);
TestUtils.getInstance(Notebook.class).processNote(noteId, note -> {
Paragraph p1 = note.addNewParagraph(anonymous);
// add local angular object
p1.setText("%spark z.angularBind(\"name\", \"world\")");
note.run(p1.getId(), true);
assertEquals(Status.FINISHED, p1.getStatus());
// angular object is saved to InterpreterGroup's AngularObjectRegistry
List<AngularObject> angularObjects;
try {
angularObjects = p1.getBindedInterpreter().getInterpreterGroup().getAngularObjectRegistry().getAll(note.getId(), null);
assertEquals(1, angularObjects.size());
assertEquals("name", angularObjects.get(0).getName());
assertEquals("world", angularObjects.get(0).get());
} catch (InterpreterNotFoundException e) {
fail();
}
// angular object is saved to note as well.
try {
angularObjects = note.getAngularObjects(p1.getBindedInterpreter().getInterpreterGroup().getId());
assertEquals(1, angularObjects.size());
assertEquals("name", angularObjects.get(0).getName());
assertEquals("world", angularObjects.get(0).get());
} catch (InterpreterNotFoundException e) {
fail();
}
// remove local angular object
Paragraph p2 = note.addNewParagraph(anonymous);
p2.setText("%spark z.angularUnbind(\"name\")");
note.run(p2.getId(), true);
assertEquals(Status.FINISHED, p2.getStatus());
try {
angularObjects = p1.getBindedInterpreter().getInterpreterGroup().getAngularObjectRegistry().getAll(note.getId(), null);
assertEquals(0, angularObjects.size());
} catch (InterpreterNotFoundException e) {
fail();
}
try {
angularObjects = note.getAngularObjects(p1.getBindedInterpreter().getInterpreterGroup().getId());
assertEquals(0, angularObjects.size());
} catch (InterpreterNotFoundException e) {
fail();
}
// add global angular object
Paragraph p3 = note.addNewParagraph(anonymous);
p3.setText("%spark z.angularBindGlobal(\"name2\", \"world2\")");
note.run(p3.getId(), true);
assertEquals(Status.FINISHED, p3.getStatus());
List<AngularObject> globalAngularObjects;
try {
globalAngularObjects = p3.getBindedInterpreter().getInterpreterGroup().getAngularObjectRegistry().getAll(null, null);
assertEquals(1, globalAngularObjects.size());
assertEquals("name2", globalAngularObjects.get(0).getName());
assertEquals("world2", globalAngularObjects.get(0).get());
} catch (InterpreterNotFoundException e) {
fail();
}
// global angular object is not saved to note
try {
angularObjects = note.getAngularObjects(p1.getBindedInterpreter().getInterpreterGroup().getId());
assertEquals(0, angularObjects.size());
} catch (InterpreterNotFoundException e) {
fail();
}
// remove global angular object
Paragraph p4 = note.addNewParagraph(anonymous);
p4.setText("%spark z.angularUnbindGlobal(\"name2\")");
note.run(p4.getId(), true);
assertEquals(Status.FINISHED, p4.getStatus());
try {
globalAngularObjects = p4.getBindedInterpreter().getInterpreterGroup().getAngularObjectRegistry().getAll(note.getId(), null);
assertEquals(0, globalAngularObjects.size());
} catch (InterpreterNotFoundException e) {
fail();
}
// global angular object is not saved to note
try {
angularObjects = note.getAngularObjects(p1.getBindedInterpreter().getInterpreterGroup().getId());
assertEquals(0, angularObjects.size());
} catch (InterpreterNotFoundException e) {
fail();
}
return null;
});
} finally {
if (null != noteId) {
TestUtils.getInstance(Notebook.class).removeNote(noteId, anonymous);
}
}
}
use of org.apache.zeppelin.interpreter.InterpreterNotFoundException in project zeppelin by apache.
the class Helium method suggestApp.
public HeliumPackageSuggestion suggestApp(Paragraph paragraph) {
HeliumPackageSuggestion suggestion = new HeliumPackageSuggestion();
Interpreter intp = null;
try {
intp = paragraph.getBindedInterpreter();
} catch (InterpreterNotFoundException e) {
return suggestion;
}
ResourcePool resourcePool = intp.getInterpreterGroup().getResourcePool();
ResourceSet allResources;
if (resourcePool != null) {
if (resourcePool instanceof DistributedResourcePool) {
allResources = ((DistributedResourcePool) resourcePool).getAll(true);
} else {
allResources = resourcePool.getAll();
}
} else {
allResources = interpreterSettingManager.getAllResources();
}
for (List<HeliumPackageSearchResult> pkgs : allPackages.values()) {
for (HeliumPackageSearchResult pkg : pkgs) {
if (pkg.getPkg().getType() == HeliumType.APPLICATION && pkg.isEnabled()) {
ResourceSet resources = ApplicationLoader.findRequiredResourceSet(pkg.getPkg().getResources(), paragraph.getNote().getId(), paragraph.getId(), allResources);
if (resources == null) {
continue;
} else {
suggestion.addAvailablePackage(pkg);
}
break;
}
}
}
suggestion.sort();
return suggestion;
}
Aggregations