[ZEPPELIN-2403] converter for old settings to new (with widgets)

This commit is contained in:
Tinkoff DWH 2017-05-11 11:11:07 +05:00
parent 76a9808307
commit c6d24c4c35
3 changed files with 31 additions and 1 deletions

View file

@ -61,7 +61,7 @@ So, copying `notebook` and `conf` directory should be enough.
- From 0.8, we recommend to use `PYSPARK_PYTHON` and `PYSPARK_DRIVER_PYTHON` instead of `zeppelin.pyspark.python` as `zeppelin.pyspark.python` only effects driver. You can use `PYSPARK_PYTHON` and `PYSPARK_DRIVER_PYTHON` as using them in spark.
- From 0.8, depending on your device, the keyboard shortcut `Ctrl-L` or `Command-L` which goes to the line somewhere user wants is not supported.
- From 0.8, changed the format settings for interpreters (`interpreter.json`)
- From 0.8, changed the format settings for interpreters (`interpreter.json`). Old settings automatically converted to widget `textarea` and type `string`.
old format:
```

View file

@ -29,6 +29,8 @@ import java.util.Set;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import com.google.gson.annotations.SerializedName;
import com.google.gson.internal.StringMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -410,4 +412,29 @@ public class InterpreterSetting {
public void clearNoteIdAndParaMap() {
runtimeInfosToBeCleared = null;
}
// For backward compatibility of interpreter.json format after ZEPPELIN-2403
public void convertFlatPropertiesToPropertiesWithWidgets() {
StringMap newProperties = new StringMap();
if (properties != null && properties instanceof StringMap) {
StringMap p = (StringMap) properties;
for (Object o : p.entrySet()) {
Map.Entry entry = (Map.Entry) o;
if (!(entry.getValue() instanceof StringMap)) {
StringMap newProperty = new StringMap();
newProperty.put("name", entry.getKey());
newProperty.put("value", entry.getValue());
newProperty.put("widget", InterpreterPropertyWidget.TEXTAREA.getValue());
newProperty.put("type", InterpreterPropertyType.STRING.getValue());
newProperties.put(entry.getKey().toString(), newProperty);
} else {
// already converted
return;
}
}
this.properties = newProperties;
}
}
}

View file

@ -165,6 +165,9 @@ public class InterpreterSettingManager {
for (String k : infoSaving.interpreterSettings.keySet()) {
InterpreterSetting setting = infoSaving.interpreterSettings.get(k);
setting.convertFlatPropertiesToPropertiesWithWidgets();
List<InterpreterInfo> infos = setting.getInterpreterInfos();
// Convert json StringMap to Properties