Skip to content

Commit

Permalink
ZEPPELIN-3322. Update interpreterBind when restarting zeppelin server
Browse files Browse the repository at this point in the history
  • Loading branch information
zjffdu committed Mar 13, 2018
1 parent f4a798b commit 94f4882
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
Expand Up @@ -208,6 +208,19 @@ private void loadFromFile() throws IOException {
return;
}

// update interpreter binding first as we change interpreter setting id in ZEPPELIN-3208.
Map<String, List<String>> newBindingMap = new HashMap<>();
for (Map.Entry<String, List<String>> entry : infoSaving.interpreterBindings.entrySet()) {
String noteId = entry.getKey();
List<String> oldSettingIdList = entry.getValue();
List<String> newSettingIdList = new ArrayList<>();
for (String oldId : oldSettingIdList) {
newSettingIdList.add(infoSaving.interpreterSettings.get(oldId).getName());
}
newBindingMap.put(noteId, newSettingIdList);
}
interpreterBindings.putAll(newBindingMap);

//TODO(zjffdu) still ugly (should move all to InterpreterInfoSaving)
for (InterpreterSetting savedInterpreterSetting : infoSaving.interpreterSettings.values()) {
savedInterpreterSetting.setProperties(InterpreterSetting.convertInterpreterProperties(
Expand Down Expand Up @@ -259,8 +272,6 @@ private void loadFromFile() throws IOException {
interpreterSettings.put(savedInterpreterSetting.getId(), savedInterpreterSetting);
}

interpreterBindings.putAll(infoSaving.interpreterBindings);

if (infoSaving.interpreterRepositories != null) {
for (RemoteRepository repo : infoSaving.interpreterRepositories) {
if (!dependencyResolver.getRepos().contains(repo)) {
Expand Down
Expand Up @@ -72,6 +72,12 @@ public void testInitInterpreterSettingManager() throws IOException, RepositoryEx
assertEquals(2, repositories.size());
assertEquals("central", repositories.get(0).getId());

// verify interpreter binding
List<String> interpreterSettingIds = interpreterSettingManager.getInterpreterBinding("2C6793KRV");
assertEquals(2, interpreterSettingIds.size());
assertEquals("test", interpreterSettingIds.get(0));
assertEquals("test2", interpreterSettingIds.get(1));

// Load it again
InterpreterSettingManager interpreterSettingManager2 = new InterpreterSettingManager(conf,
mock(AngularObjectRegistryListener.class), mock(RemoteInterpreterProcessListener.class), mock(ApplicationEventListener.class));
Expand Down
21 changes: 1 addition & 20 deletions zeppelin-zengine/src/test/resources/conf/interpreter.json
Expand Up @@ -124,27 +124,8 @@
},
"interpreterBindings": {
"2C6793KRV": [
"2C48Y7FSJ",
"2C63XW4XE",
"2C66GE1VB",
"2C5VH924X",
"2C4BJDRRZ",
"2C3SQSB7V",
"2C4HKDCQW",
"2C3DR183X",
"2C66Z9XPQ",
"2C3PTPMUH",
"2C69WE69N",
"2C5SRRXHM",
"2C4ZD49PF",
"2C6V3D44K",
"2C4UB1UZA",
"2C5S1R21W",
"2C5DCRVGM",
"2C686X8ZH",
"2C3RWCVAG",
"2C3JKFMJU",
"2C3VECEG2"
"2CKWE7B19"
]
},
"interpreterRepositories": [
Expand Down

0 comments on commit 94f4882

Please sign in to comment.