use of org.apache.zeppelin.interpreter.launcher.InterpreterClient in project zeppelin by apache.
the class FileSystemRecoveryStorage method restore.
@Override
public Map<String, InterpreterClient> restore() throws IOException {
Map<String, InterpreterClient> clients = new HashMap<>();
List<Path> paths = fs.list(new Path(recoveryDir + "/*.recovery"));
for (Path path : paths) {
String fileName = path.getName();
String interpreterSettingName = fileName.substring(0, fileName.length() - ".recovery".length());
String recoveryContent = fs.readFile(path);
clients.putAll(RecoveryUtils.restoreFromRecoveryData(recoveryContent, interpreterSettingName, interpreterSettingManager, zConf));
}
return clients;
}
use of org.apache.zeppelin.interpreter.launcher.InterpreterClient in project zeppelin by apache.
the class StopInterpreter method main.
public static void main(String[] args) throws IOException {
ZeppelinConfiguration zConf = ZeppelinConfiguration.create();
InterpreterSettingManager interpreterSettingManager = new InterpreterSettingManager(zConf, null, null, null);
RecoveryStorage recoveryStorage = ReflectionUtils.createClazzInstance(zConf.getRecoveryStorageClass(), new Class[] { ZeppelinConfiguration.class, InterpreterSettingManager.class }, new Object[] { zConf, interpreterSettingManager });
LOGGER.info("Using RecoveryStorage: {}", recoveryStorage.getClass().getName());
Map<String, InterpreterClient> restoredClients = recoveryStorage.restore();
if (restoredClients != null) {
for (InterpreterClient client : restoredClients.values()) {
LOGGER.info("Stop Interpreter Process: {}:{}", client.getHost(), client.getPort());
client.stop();
}
}
}
use of org.apache.zeppelin.interpreter.launcher.InterpreterClient in project zeppelin by apache.
the class LocalRecoveryStorage method restore.
@Override
public Map<String, InterpreterClient> restore() throws IOException {
Map<String, InterpreterClient> clients = new HashMap<>();
File[] recoveryFiles = recoveryDir.listFiles(file -> file.getName().endsWith(".recovery"));
for (File recoveryFile : recoveryFiles) {
String fileName = recoveryFile.getName();
String interpreterSettingName = fileName.substring(0, fileName.length() - ".recovery".length());
String recoveryData = org.apache.zeppelin.util.FileUtils.readFromFile(recoveryFile);
clients.putAll(RecoveryUtils.restoreFromRecoveryData(recoveryData, interpreterSettingName, interpreterSettingManager, zConf));
}
return clients;
}
use of org.apache.zeppelin.interpreter.launcher.InterpreterClient in project zeppelin by apache.
the class RecoveryUtils method restoreFromRecoveryData.
/**
* Return interpreterClient from recoveryData of one interpreterSetting.
*
* @param recoveryData
* @param interpreterSettingName
* @param interpreterSettingManager
* @param zConf
* @return
*/
public static Map<String, InterpreterClient> restoreFromRecoveryData(String recoveryData, String interpreterSettingName, InterpreterSettingManager interpreterSettingManager, ZeppelinConfiguration zConf) {
int connectTimeout = zConf.getInt(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_CONNECT_TIMEOUT);
Properties interpreterProperties = interpreterSettingManager.getByName(interpreterSettingName).getJavaProperties();
int connectionPoolSize = Integer.parseInt(interpreterProperties.getProperty(ZEPPELIN_INTERPRETER_CONNECTION_POOL_SIZE.getVarName(), ZEPPELIN_INTERPRETER_CONNECTION_POOL_SIZE.getIntValue() + ""));
Map<String, InterpreterClient> clients = new HashMap<>();
if (!StringUtils.isBlank(recoveryData)) {
for (String line : recoveryData.split(System.lineSeparator())) {
String[] tokens = line.split("\t");
String interpreterGroupId = tokens[0];
String[] hostPort = tokens[1].split(":");
RemoteInterpreterRunningProcess client = new RemoteInterpreterRunningProcess(interpreterSettingName, interpreterGroupId, connectTimeout, connectionPoolSize, interpreterSettingManager.getInterpreterEventServer().getHost(), interpreterSettingManager.getInterpreterEventServer().getPort(), hostPort[0], Integer.parseInt(hostPort[1]), true);
clients.put(interpreterGroupId, client);
LOGGER.info("Recovering Interpreter Process: " + interpreterGroupId + ", " + hostPort[0] + ":" + hostPort[1]);
}
}
return clients;
}
Aggregations