use of com.twosigma.beakerx.NamespaceClient in project beakerx by twosigma.
the class KotlinWorkerThread method call.
@Override
public TryResult call() throws Exception {
NamespaceClient nc = null;
TryResult either;
try {
nc = NamespaceClient.getBeaker(kotlinEvaluator.getSessionId());
nc.setOutputObj(j.outputObject);
j.outputObject.started();
try {
KotlinCodeRunner kotlinCodeRunner = new KotlinCodeRunner(j.outputObject, kotlinEvaluator.getClassLoader(), kotlinEvaluator.getRepl(), j.codeToBeExecuted);
either = kotlinEvaluator.executeTask(kotlinCodeRunner);
if (nc != null) {
nc.setOutputObj(null);
nc = null;
}
} catch (Exception e) {
either = TryResult.createError(e.getMessage());
}
} catch (Throwable e) {
e.printStackTrace();
either = TryResult.createError(e.getMessage());
} finally {
if (nc != null) {
nc.setOutputObj(null);
nc = null;
}
}
return either;
}
use of com.twosigma.beakerx.NamespaceClient in project beakerx by twosigma.
the class SQLWorkerThread method call.
@Override
public TryResult call() throws Exception {
NamespaceClient namespaceClient = null;
TryResult r;
job.getSimpleEvaluationObject().started();
try {
job.getSimpleEvaluationObject().setOutputHandler();
namespaceClient = NamespaceClient.getBeaker(sqlEvaluator.getSessionId());
namespaceClient.setOutputObj(job.getSimpleEvaluationObject());
r = sqlEvaluator.executeTask(new SQLCodeRunner(sqlEvaluator, job.getSimpleEvaluationObject(), namespaceClient));
} finally {
job.getSimpleEvaluationObject().clrOutputHandler();
if (namespaceClient != null) {
namespaceClient.setOutputObj(null);
}
}
return r;
}
use of com.twosigma.beakerx.NamespaceClient in project beakerx by twosigma.
the class ScalaWorkerThread method call.
@Override
public TryResult call() throws Exception {
NamespaceClient nc = null;
TryResult either;
try {
j.outputObject.started();
nc = NamespaceClient.getBeaker(scalaEvaluator.getSessionId());
nc.setOutputObj(j.outputObject);
either = scalaEvaluator.executeTask(new ScalaCodeRunner(scalaEvaluator, j.codeToBeExecuted, j.outputObject));
if (nc != null) {
nc.setOutputObj(null);
nc = null;
}
} catch (Throwable e) {
e.printStackTrace();
either = TryResult.createError(e.getMessage());
} finally {
if (nc != null) {
nc.setOutputObj(null);
nc = null;
}
}
return either;
}
use of com.twosigma.beakerx.NamespaceClient in project beakerx by twosigma.
the class JavaWorkerThread method call.
@Override
public TryResult call() throws Exception {
NamespaceClient nc = null;
TryResult r;
try {
nc = NamespaceClient.getBeaker(javaEvaluator.getSessionId());
nc.setOutputObj(j.outputObject);
r = javaEvaluator.executeTask(new JavaCodeRunner(javaEvaluator, j.outputObject, j));
} catch (Throwable e) {
e.printStackTrace();
r = TryResult.createError(e.getLocalizedMessage());
} finally {
if (nc != null) {
nc.setOutputObj(null);
nc = null;
}
}
return r;
}
use of com.twosigma.beakerx.NamespaceClient in project beakerx by twosigma.
the class DbExplorerFactory method getDbInfo.
// private static final String VENDOR_JDBC_ORACLE = "jdbc:oracle:";
// private static final String VENDOR_JDBC_MSSQL = "jdbc:sqlserver:";
public static DbInfo getDbInfo(String txt, JDBCClient jdbcClient, String sessionId, ConnectionStringHolder defaultConnectionString, Map<String, ConnectionStringHolder> namedConnectionString) {
final NamespaceClient namespaceClient = NamespaceClient.getBeaker(sessionId);
final BeakerParser beakerParser;
try {
beakerParser = new BeakerParser(txt, namespaceClient, defaultConnectionString, namedConnectionString, jdbcClient);
final String uri = beakerParser.getDbURI().getActualConnectionString();
if (uri != null) {
final DataSource ds = jdbcClient.getDataSource(uri);
if (uri.startsWith(VENDOR_JDBC_MYSQL)) {
return new MysqlDbExplorer(ds);
}
}
} catch (IOException | DBConnectionException e) {
logger.error(e.getMessage());
}
return null;
}
Aggregations