Search in sources :

Example 1 with InterpreterHookRegistry

use of org.apache.zeppelin.interpreter.InterpreterHookRegistry in project zeppelin by apache.

the class RemoteInterpreterServer method createInterpreter.

@Override
public void createInterpreter(String interpreterGroupId, String sessionId, String className, Map<String, String> properties, String userName) throws InterpreterRPCException, TException {
    try {
        if (interpreterGroup == null) {
            interpreterGroup = new InterpreterGroup(interpreterGroupId);
            angularObjectRegistry = new AngularObjectRegistry(interpreterGroup.getId(), intpEventClient);
            hookRegistry = new InterpreterHookRegistry();
            resourcePool = new DistributedResourcePool(interpreterGroup.getId(), intpEventClient);
            interpreterGroup.setInterpreterHookRegistry(hookRegistry);
            interpreterGroup.setAngularObjectRegistry(angularObjectRegistry);
            interpreterGroup.setResourcePool(resourcePool);
            intpEventClient.setIntpGroupId(interpreterGroupId);
            String localRepoPath = properties.get("zeppelin.interpreter.localRepo");
            if (properties.containsKey("zeppelin.interpreter.output.limit")) {
                InterpreterOutput.LIMIT = Integer.parseInt(properties.get("zeppelin.interpreter.output.limit"));
            }
            depLoader = new DependencyResolver(localRepoPath);
            appLoader = new ApplicationLoader(resourcePool, depLoader);
            resultCacheInSeconds = Integer.parseInt(properties.getOrDefault("zeppelin.interpreter.result.cache", "0"));
        }
        Class<Interpreter> replClass = (Class<Interpreter>) Object.class.forName(className);
        Properties p = new Properties();
        p.putAll(properties);
        setSystemProperty(p);
        Constructor<Interpreter> constructor = replClass.getConstructor(new Class[] { Properties.class });
        Interpreter interpreter = constructor.newInstance(p);
        interpreter.setClassloaderUrls(new URL[] {});
        interpreter.setInterpreterGroup(interpreterGroup);
        interpreter.setUserName(userName);
        interpreterGroup.addInterpreterToSession(new LazyOpenInterpreter(interpreter), sessionId);
        this.isForceShutdown = Boolean.parseBoolean(properties.getOrDefault("zeppelin.interpreter.forceShutdown", "true"));
        LOGGER.info("Instantiate interpreter {}, isForceShutdown: {}", className, isForceShutdown);
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
        throw new InterpreterRPCException("Fail to create interpreter, cause: " + e.toString());
    }
}
Also used : InterpreterRPCException(org.apache.zeppelin.interpreter.thrift.InterpreterRPCException) Interpreter(org.apache.zeppelin.interpreter.Interpreter) LazyOpenInterpreter(org.apache.zeppelin.interpreter.LazyOpenInterpreter) LazyOpenInterpreter(org.apache.zeppelin.interpreter.LazyOpenInterpreter) InterpreterHookRegistry(org.apache.zeppelin.interpreter.InterpreterHookRegistry) Properties(java.util.Properties) TTransportException(org.apache.thrift.transport.TTransportException) InterpreterRPCException(org.apache.zeppelin.interpreter.thrift.InterpreterRPCException) InterpreterException(org.apache.zeppelin.interpreter.InterpreterException) ApplicationException(org.apache.zeppelin.helium.ApplicationException) TException(org.apache.thrift.TException) IOException(java.io.IOException) DependencyResolver(org.apache.zeppelin.dep.DependencyResolver) InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) AngularObject(org.apache.zeppelin.display.AngularObject) HeliumAppAngularObjectRegistry(org.apache.zeppelin.helium.HeliumAppAngularObjectRegistry) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry) DistributedResourcePool(org.apache.zeppelin.resource.DistributedResourcePool) ApplicationLoader(org.apache.zeppelin.helium.ApplicationLoader)

Aggregations

IOException (java.io.IOException)1 Properties (java.util.Properties)1 TException (org.apache.thrift.TException)1 TTransportException (org.apache.thrift.transport.TTransportException)1 DependencyResolver (org.apache.zeppelin.dep.DependencyResolver)1 AngularObject (org.apache.zeppelin.display.AngularObject)1 AngularObjectRegistry (org.apache.zeppelin.display.AngularObjectRegistry)1 ApplicationException (org.apache.zeppelin.helium.ApplicationException)1 ApplicationLoader (org.apache.zeppelin.helium.ApplicationLoader)1 HeliumAppAngularObjectRegistry (org.apache.zeppelin.helium.HeliumAppAngularObjectRegistry)1 Interpreter (org.apache.zeppelin.interpreter.Interpreter)1 InterpreterException (org.apache.zeppelin.interpreter.InterpreterException)1 InterpreterGroup (org.apache.zeppelin.interpreter.InterpreterGroup)1 InterpreterHookRegistry (org.apache.zeppelin.interpreter.InterpreterHookRegistry)1 LazyOpenInterpreter (org.apache.zeppelin.interpreter.LazyOpenInterpreter)1 InterpreterRPCException (org.apache.zeppelin.interpreter.thrift.InterpreterRPCException)1 DistributedResourcePool (org.apache.zeppelin.resource.DistributedResourcePool)1