Search in sources :

Example 6 with InterpreterRPCException

use of org.apache.zeppelin.interpreter.thrift.InterpreterRPCException in project zeppelin by apache.

the class RemoteInterpreterServer method getProgress.

@Override
public int getProgress(String sessionId, String className, RemoteInterpreterContext interpreterContext) throws InterpreterRPCException, TException {
    lifecycleManager.onInterpreterUse(interpreterGroupId);
    Integer manuallyProvidedProgress = progressMap.get(interpreterContext.getParagraphId());
    if (manuallyProvidedProgress != null) {
        return manuallyProvidedProgress;
    } else {
        Interpreter intp = getInterpreter(sessionId, className);
        if (intp == null) {
            throw new InterpreterRPCException("No interpreter " + className + " existed for session " + sessionId);
        }
        try {
            return intp.getProgress(convert(interpreterContext, null));
        } catch (InterpreterException e) {
            throw new InterpreterRPCException(e.toString());
        }
    }
}
Also used : InterpreterRPCException(org.apache.zeppelin.interpreter.thrift.InterpreterRPCException) Interpreter(org.apache.zeppelin.interpreter.Interpreter) LazyOpenInterpreter(org.apache.zeppelin.interpreter.LazyOpenInterpreter) InterpreterException(org.apache.zeppelin.interpreter.InterpreterException)

Example 7 with InterpreterRPCException

use of org.apache.zeppelin.interpreter.thrift.InterpreterRPCException in project zeppelin by apache.

the class RemoteInterpreterServer method angularObjectUpdate.

/**
 * called when object is updated in client (web) side.
 *
 * @param name
 * @param noteId      noteId where the update issues
 * @param paragraphId paragraphId where the update issues
 * @param object
 * @throws InterpreterRPCException, TException
 */
@Override
public void angularObjectUpdate(String name, String noteId, String paragraphId, String object) throws InterpreterRPCException, TException {
    AngularObjectRegistry registry = interpreterGroup.getAngularObjectRegistry();
    // first try local objects
    AngularObject ao = registry.get(name, noteId, paragraphId);
    if (ao == null) {
        LOGGER.debug("Angular object {} not exists", name);
        return;
    }
    if (object == null) {
        ao.set(null, false);
        return;
    }
    Object oldObject = ao.get();
    Object value = null;
    if (oldObject != null) {
        // first try with previous object's type
        try {
            value = gson.fromJson(object, oldObject.getClass());
            ao.set(value, false);
            return;
        } catch (Exception e) {
            // it's not a previous object's type. proceed to treat as a generic type
            LOGGER.debug(e.getMessage(), e);
        }
    }
    // Generic java object type for json.
    if (value == null) {
        try {
            value = gson.fromJson(object, new TypeToken<Map<String, Object>>() {
            }.getType());
        } catch (Exception e) {
            // it's not a generic json object, too. okay, proceed to threat as a string type
            LOGGER.debug(e.getMessage(), e);
        }
    }
    // try string object type at last
    if (value == null) {
        value = gson.fromJson(object, String.class);
    }
    ao.set(value, false);
}
Also used : AngularObject(org.apache.zeppelin.display.AngularObject) AngularObject(org.apache.zeppelin.display.AngularObject) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) HeliumAppAngularObjectRegistry(org.apache.zeppelin.helium.HeliumAppAngularObjectRegistry) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry) 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)

Example 8 with InterpreterRPCException

use of org.apache.zeppelin.interpreter.thrift.InterpreterRPCException 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)

Example 9 with InterpreterRPCException

use of org.apache.zeppelin.interpreter.thrift.InterpreterRPCException in project zeppelin by apache.

the class RemoteInterpreterServer method loadApplication.

@Override
public RemoteApplicationResult loadApplication(String applicationInstanceId, String packageInfo, String noteId, String paragraphId) throws InterpreterRPCException, TException {
    if (runningApplications.containsKey(applicationInstanceId)) {
        LOGGER.warn("Application instance {} is already running", applicationInstanceId);
        return new RemoteApplicationResult(true, "");
    }
    HeliumPackage pkgInfo = HeliumPackage.fromJson(packageInfo);
    ApplicationContext context = getApplicationContext(pkgInfo, noteId, paragraphId, applicationInstanceId);
    try {
        Application app = null;
        LOGGER.info("Loading application {}({}), artifact={}, className={} into note={}, paragraph={}", pkgInfo.getName(), applicationInstanceId, pkgInfo.getArtifact(), pkgInfo.getClassName(), noteId, paragraphId);
        app = appLoader.load(pkgInfo, context);
        runningApplications.put(applicationInstanceId, new RunningApplication(pkgInfo, app, noteId, paragraphId));
        return new RemoteApplicationResult(true, "");
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
        return new RemoteApplicationResult(false, e.getMessage());
    }
}
Also used : ApplicationContext(org.apache.zeppelin.helium.ApplicationContext) HeliumPackage(org.apache.zeppelin.helium.HeliumPackage) RemoteApplicationResult(org.apache.zeppelin.interpreter.thrift.RemoteApplicationResult) Application(org.apache.zeppelin.helium.Application) 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)

Example 10 with InterpreterRPCException

use of org.apache.zeppelin.interpreter.thrift.InterpreterRPCException in project zeppelin by apache.

the class RemoteInterpreterServer method reconnect.

@Override
public void reconnect(String host, int port) throws InterpreterRPCException, TException {
    try {
        LOGGER.info("Reconnect to this interpreter process from {}:{}", host, port);
        this.intpEventServerHost = host;
        this.intpEventServerPort = port;
        intpEventClient = new RemoteInterpreterEventClient(intpEventServerHost, intpEventServerPort, this.zConf.getInt(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_CONNECTION_POOL_SIZE));
        intpEventClient.setIntpGroupId(interpreterGroupId);
        this.angularObjectRegistry = new AngularObjectRegistry(interpreterGroup.getId(), intpEventClient);
        this.resourcePool = new DistributedResourcePool(interpreterGroup.getId(), intpEventClient);
        // reset all the available InterpreterContext's components that use intpEventClient.
        for (InterpreterContext context : InterpreterContext.getAllContexts().values()) {
            context.setIntpEventClient(intpEventClient);
            context.setAngularObjectRegistry(angularObjectRegistry);
            context.setResourcePool(resourcePool);
        }
    } catch (Exception e) {
        throw new InterpreterRPCException(e.toString());
    }
}
Also used : InterpreterRPCException(org.apache.zeppelin.interpreter.thrift.InterpreterRPCException) InterpreterContext(org.apache.zeppelin.interpreter.InterpreterContext) RemoteInterpreterContext(org.apache.zeppelin.interpreter.thrift.RemoteInterpreterContext) HeliumAppAngularObjectRegistry(org.apache.zeppelin.helium.HeliumAppAngularObjectRegistry) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry) DistributedResourcePool(org.apache.zeppelin.resource.DistributedResourcePool) 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)

Aggregations

InterpreterRPCException (org.apache.zeppelin.interpreter.thrift.InterpreterRPCException)11 IOException (java.io.IOException)9 InterpreterException (org.apache.zeppelin.interpreter.InterpreterException)9 TException (org.apache.thrift.TException)7 TTransportException (org.apache.thrift.transport.TTransportException)7 ApplicationException (org.apache.zeppelin.helium.ApplicationException)7 AngularObject (org.apache.zeppelin.display.AngularObject)5 AngularObjectRegistry (org.apache.zeppelin.display.AngularObjectRegistry)4 HeliumAppAngularObjectRegistry (org.apache.zeppelin.helium.HeliumAppAngularObjectRegistry)4 Interpreter (org.apache.zeppelin.interpreter.Interpreter)4 LazyOpenInterpreter (org.apache.zeppelin.interpreter.LazyOpenInterpreter)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 ConcurrentMap (java.util.concurrent.ConcurrentMap)3 InterpreterContext (org.apache.zeppelin.interpreter.InterpreterContext)2 RemoteAngularObject (org.apache.zeppelin.interpreter.remote.RemoteAngularObject)2 RemoteInterpreterContext (org.apache.zeppelin.interpreter.thrift.RemoteInterpreterContext)2 DistributedResourcePool (org.apache.zeppelin.resource.DistributedResourcePool)2 ByteBuffer (java.nio.ByteBuffer)1