Search in sources :

Example 1 with InterpreterClient

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;
}
Also used : Path(org.apache.hadoop.fs.Path) InterpreterClient(org.apache.zeppelin.interpreter.launcher.InterpreterClient) HashMap(java.util.HashMap)

Example 2 with InterpreterClient

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();
        }
    }
}
Also used : InterpreterClient(org.apache.zeppelin.interpreter.launcher.InterpreterClient) ZeppelinConfiguration(org.apache.zeppelin.conf.ZeppelinConfiguration) InterpreterSettingManager(org.apache.zeppelin.interpreter.InterpreterSettingManager)

Example 3 with InterpreterClient

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;
}
Also used : InterpreterClient(org.apache.zeppelin.interpreter.launcher.InterpreterClient) HashMap(java.util.HashMap) File(java.io.File)

Example 4 with InterpreterClient

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;
}
Also used : InterpreterClient(org.apache.zeppelin.interpreter.launcher.InterpreterClient) HashMap(java.util.HashMap) RemoteInterpreterRunningProcess(org.apache.zeppelin.interpreter.remote.RemoteInterpreterRunningProcess) Properties(java.util.Properties)

Aggregations

InterpreterClient (org.apache.zeppelin.interpreter.launcher.InterpreterClient)4 HashMap (java.util.HashMap)3 File (java.io.File)1 Properties (java.util.Properties)1 Path (org.apache.hadoop.fs.Path)1 ZeppelinConfiguration (org.apache.zeppelin.conf.ZeppelinConfiguration)1 InterpreterSettingManager (org.apache.zeppelin.interpreter.InterpreterSettingManager)1 RemoteInterpreterRunningProcess (org.apache.zeppelin.interpreter.remote.RemoteInterpreterRunningProcess)1