Search in sources :

Example 1 with InterpreterException

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

the class ZeppelinContext method runNote.

public void runNote(String noteId, InterpreterContext context) {
    String runningNoteId = context.getNoteId();
    String runningParagraphId = context.getParagraphId();
    List<InterpreterContextRunner> runners = getInterpreterContextRunner(noteId, context);
    if (runners.size() <= 0) {
        throw new InterpreterException("Note " + noteId + " not found " + runners.size());
    }
    for (InterpreterContextRunner r : runners) {
        if (r.getNoteId().equals(runningNoteId) && r.getParagraphId().equals(runningParagraphId)) {
            continue;
        }
        r.run();
    }
}
Also used : InterpreterContextRunner(org.apache.zeppelin.interpreter.InterpreterContextRunner) InterpreterException(org.apache.zeppelin.interpreter.InterpreterException)

Example 2 with InterpreterException

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

the class IgniteSqlInterpreter method close.

@Override
public void close() {
    try {
        if (conn != null) {
            conn.close();
        }
    } catch (SQLException e) {
        throw new InterpreterException(e);
    } finally {
        conn = null;
        connEx = null;
    }
}
Also used : SQLException(java.sql.SQLException) InterpreterException(org.apache.zeppelin.interpreter.InterpreterException)

Example 3 with InterpreterException

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

the class RemoteInterpreterManagedProcess method start.

@Override
public void start(String userName, Boolean isUserImpersonate) {
    // start server process
    try {
        port = RemoteInterpreterUtils.findRandomAvailablePortOnAllLocalInterfaces();
    } catch (IOException e1) {
        throw new InterpreterException(e1);
    }
    CommandLine cmdLine = CommandLine.parse(interpreterRunner);
    cmdLine.addArgument("-d", false);
    cmdLine.addArgument(interpreterDir, false);
    cmdLine.addArgument("-p", false);
    cmdLine.addArgument(Integer.toString(port), false);
    if (isUserImpersonate && !userName.equals("anonymous")) {
        cmdLine.addArgument("-u", false);
        cmdLine.addArgument(userName, false);
    }
    cmdLine.addArgument("-l", false);
    cmdLine.addArgument(localRepoDir, false);
    cmdLine.addArgument("-n", false);
    cmdLine.addArgument(interpreterGroupName, false);
    executor = new DefaultExecutor();
    ByteArrayOutputStream cmdOut = new ByteArrayOutputStream();
    ProcessLogOutputStream processOutput = new ProcessLogOutputStream(logger);
    processOutput.setOutputStream(cmdOut);
    executor.setStreamHandler(new PumpStreamHandler(processOutput));
    watchdog = new ExecuteWatchdog(ExecuteWatchdog.INFINITE_TIMEOUT);
    executor.setWatchdog(watchdog);
    try {
        Map procEnv = EnvironmentUtils.getProcEnvironment();
        procEnv.putAll(env);
        logger.info("Run interpreter process {}", cmdLine);
        executor.execute(cmdLine, procEnv, this);
        running = true;
    } catch (IOException e) {
        running = false;
        throw new InterpreterException(e);
    }
    long startTime = System.currentTimeMillis();
    while (System.currentTimeMillis() - startTime < getConnectTimeout()) {
        if (!running) {
            try {
                cmdOut.flush();
            } catch (IOException e) {
            // nothing to do
            }
            throw new InterpreterException(new String(cmdOut.toByteArray()));
        }
        try {
            if (RemoteInterpreterUtils.checkIfRemoteEndpointAccessible("localhost", port)) {
                break;
            } else {
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    logger.error("Exception in RemoteInterpreterProcess while synchronized reference " + "Thread.sleep", e);
                }
            }
        } catch (Exception e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Remote interpreter not yet accessible at localhost:" + port);
            }
        }
    }
    processOutput.setOutputStream(null);
}
Also used : InterpreterException(org.apache.zeppelin.interpreter.InterpreterException) IOException(java.io.IOException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) InterpreterException(org.apache.zeppelin.interpreter.InterpreterException) Map(java.util.Map)

Example 4 with InterpreterException

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

the class ClientFactory method create.

@Override
public Client create() throws Exception {
    TSocket transport = new TSocket(host, port);
    try {
        transport.open();
    } catch (TTransportException e) {
        throw new InterpreterException(e);
    }
    TProtocol protocol = new TBinaryProtocol(transport);
    Client client = new RemoteInterpreterService.Client(protocol);
    synchronized (clientSocketMap) {
        clientSocketMap.put(client, transport);
    }
    return client;
}
Also used : TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) TProtocol(org.apache.thrift.protocol.TProtocol) InterpreterException(org.apache.zeppelin.interpreter.InterpreterException) TTransportException(org.apache.thrift.transport.TTransportException) Client(org.apache.zeppelin.interpreter.thrift.RemoteInterpreterService.Client) TSocket(org.apache.thrift.transport.TSocket)

Example 5 with InterpreterException

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

the class InterpreterContextRunnerPool method run.

public void run(String noteId, String paragraphId) {
    synchronized (interpreterContextRunners) {
        List<InterpreterContextRunner> list = interpreterContextRunners.get(noteId);
        if (list != null) {
            for (InterpreterContextRunner r : list) {
                if (noteId.equals(r.getNoteId()) && paragraphId.equals(r.getParagraphId())) {
                    logger.info("run paragraph {} on note {} from InterpreterContext", r.getParagraphId(), r.getNoteId());
                    r.run();
                    return;
                }
            }
        }
        throw new InterpreterException("Can not run paragraph " + paragraphId + " on " + noteId);
    }
}
Also used : InterpreterContextRunner(org.apache.zeppelin.interpreter.InterpreterContextRunner) InterpreterException(org.apache.zeppelin.interpreter.InterpreterException)

Aggregations

InterpreterException (org.apache.zeppelin.interpreter.InterpreterException)19 IOException (java.io.IOException)5 ZeppelinApi (org.apache.zeppelin.annotation.ZeppelinApi)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 Method (java.lang.reflect.Method)3 Path (javax.ws.rs.Path)3 InterpreterContextRunner (org.apache.zeppelin.interpreter.InterpreterContextRunner)3 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)3 InterpreterSetting (org.apache.zeppelin.interpreter.InterpreterSetting)3 JsonResponse (org.apache.zeppelin.server.JsonResponse)3 SQLException (java.sql.SQLException)2 Properties (java.util.Properties)2 PUT (javax.ws.rs.PUT)2 TTransportException (org.apache.thrift.transport.TTransportException)2 AngularObject (org.apache.zeppelin.display.AngularObject)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 PrintWriter (java.io.PrintWriter)1 Field (java.lang.reflect.Field)1 URL (java.net.URL)1