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();
}
}
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;
}
}
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);
}
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;
}
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);
}
}
Aggregations