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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -428,6 +428,7 @@ public static enum ConfVars {
// Decide when new note is created, interpreter settings will be binded automatically or not.
ZEPPELIN_NOTEBOOK_AUTO_INTERPRETER_BINDING("zeppelin.notebook.autoInterpreterBinding", true),
ZEPPELIN_CONF_DIR("zeppelin.conf.dir", "conf"),
ZEPPELIN_INTERPRETER_REPO_DIR("zeppelin.user.interpreter.dir", "interpreter"),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add this property to conf/zeppelin-env.sh.template, conf/zeppelin-site.xml.template and docs/install/install.md ?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Leemoonsoo Thank you for feed back.
I will add that information.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the name ZEPPELIN_INTERPRETER_REPO_DIR and zeppelin.user.interpreter.dir are little bit confusing.

How about more intuitive name such as ZEPPELIN_INTERPRETER_DOWNLOAD_DIR and zeppelin.interpreter.download.dir ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's the temp directory for downloaded interpreter, why not making it more general like: ZEPPELIN_PLUGINS_DOWNLOAD_DIR?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@corneadoug because Interpreter is loaded by conf/interpreter.sh and other pluggable component are not, copying dependencies in a directory is only requirement of conf/interpreter.sh. So this configuration shouldn't be generalized for other pluggable module.

Dependencies for other pluggable components will directly loaded from local repository for dependency loader, which is configured by ZEPPELIN_DEP_LOCALREPO.

ZEPPELIN_DEP_LOCALREPO("zeppelin.dep.localrepo", "local-repo"),
// Allows a way to specify a ',' separated list of allowed origins for rest and websockets
// i.e. http://localhost:8080
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -53,7 +53,7 @@ public class InterpreterFactory {
.synchronizedMap(new HashMap<String, URLClassLoader>());

private ZeppelinConfiguration conf;
String[] interpreterClassList;
List<String> interpreterClassList;

private Map<String, InterpreterSetting> interpreterSettings =
new HashMap<String, InterpreterSetting>();
Expand DownExpand Up@@ -85,7 +85,10 @@ public InterpreterFactory(ZeppelinConfiguration conf, InterpreterOption defaultO
this.angularObjectRegistryListener = angularObjectRegistryListener;
this.depResolver = depResolver;
String replsConf = conf.getString(ConfVars.ZEPPELIN_INTERPRETERS);
interpreterClassList = replsConf.split(",");
interpreterClassList = new ArrayList<String>();
for (String className : replsConf.split(",")) {
interpreterClassList.add(className);
}

GsonBuilder builder = new GsonBuilder();
builder.setPrettyPrinting();
Expand All@@ -95,6 +98,95 @@ public InterpreterFactory(ZeppelinConfiguration conf, InterpreterOption defaultO
init();
}

public boolean loadDynamicInterpreter(String intpGroupName, String intpName, String artifact,
String intpClassName) {
return loadDynamicInterpreter(intpGroupName, intpName, artifact, intpClassName, null, false);
}

public boolean loadDynamicInterpreter(String intpGroupName, String intpName, String artifact,
String intpClassName, String repositoryUrl, boolean isSnapShotRepo) {
String[] artifactItem = artifact.split(":");
String zepInterpreterRepoDir = conf.getString(ConfVars.ZEPPELIN_INTERPRETER_REPO_DIR);
String zepInterpreterRepoFullPath = conf.getRelativeDir(ConfVars.ZEPPELIN_INTERPRETER_REPO_DIR);
String interpreterDesPath = String.format("%s/%s/%s/", zepInterpreterRepoDir,
intpGroupName, intpName);
String interpreterLoadPath = String.format("%s/%s/%s", zepInterpreterRepoFullPath,
intpGroupName, intpName);

if (artifactItem.length <= 0) {
logger.error("Failed load dynamic interpreter - invalid artifact : {}", artifact);
return false;
}

try {
if (repositoryUrl != null) {
depResolver.addRepo("dyInterpreterRepo", repositoryUrl, isSnapShotRepo);
}
logger.info("interpreter path : {}", interpreterLoadPath);
depResolver.load(artifact, interpreterDesPath);
setDynamicInterpreter(intpClassName, interpreterLoadPath);
} catch (Exception e) {
logger.error("Failed load dynamic interpreter : ", e);
return false;
}
return true;
}

public boolean unloadDynamicInterpreter(String intpGorupName, String intpName) {
try {
remove(intpName);
} catch (Exception e) {
logger.error("Faild Unload Dynaminc Interpreter", e);
return false;
}
return true;
}

protected void setDynamicInterpreter(String interpreterClassName, String fileDirPath)
throws InterpreterException, IOException {
logger.info("load Dynamic Interpreter ClassName : {}", interpreterClassName);
logger.info("load Dynamic Interpreter FilePath : {}", interpreterClassName);

ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
interpreterClassList.add(interpreterClassName);
// Load classes
File interpreterDir = new File(fileDirPath);

if (interpreterDir != null) {
URL[] urls = null;
try {
urls = recursiveBuildLibList(interpreterDir);
} catch (MalformedURLException e1) {
logger.error("Can't load jars ", e1);
}
URLClassLoader ccl = new URLClassLoader(urls, oldcl);

try {
Class.forName(interpreterClassName, true, ccl);
Set<String> keys = Interpreter.registeredInterpreters.keySet();
for (String intName : keys) {
if (interpreterClassName.equals(
Interpreter.registeredInterpreters.get(intName).getClassName())) {
Interpreter.registeredInterpreters.get(intName).setPath(fileDirPath);
logger.info("Interpreter {} found. class={}", intName, fileDirPath);
cleanCl.put(fileDirPath, ccl);
}
}
} catch (ClassNotFoundException e) {
logger.error("Load error : ", e);
}
}

for (String settingId : interpreterSettings.keySet()) {
InterpreterSetting setting = interpreterSettings.get(settingId);
logger.info("Interpreter setting group {} : id={}, name={}",
setting.getGroup(), settingId, setting.getName());
for (Interpreter interpreter : setting.getInterpreterGroup()) {
logger.info(" className = {}", interpreter.getClassName());
}
}
}

private void init() throws InterpreterException, IOException {
ClassLoader oldcl = Thread.currentThread().getContextClassLoader();

Expand Down