Search in sources :

Example 1 with NamespaceClient

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;
}
Also used : NamespaceClient(com.twosigma.beakerx.NamespaceClient) TryResult(com.twosigma.beakerx.TryResult) IOException(java.io.IOException)

Example 2 with NamespaceClient

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;
}
Also used : NamespaceClient(com.twosigma.beakerx.NamespaceClient) TryResult(com.twosigma.beakerx.TryResult)

Example 3 with NamespaceClient

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;
}
Also used : NamespaceClient(com.twosigma.beakerx.NamespaceClient) TryResult(com.twosigma.beakerx.TryResult)

Example 4 with NamespaceClient

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;
}
Also used : NamespaceClient(com.twosigma.beakerx.NamespaceClient) TryResult(com.twosigma.beakerx.TryResult)

Example 5 with NamespaceClient

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;
}
Also used : NamespaceClient(com.twosigma.beakerx.NamespaceClient) DBConnectionException(com.twosigma.beakerx.sql.DBConnectionException) BeakerParser(com.twosigma.beakerx.sql.BeakerParser) IOException(java.io.IOException) DataSource(javax.sql.DataSource)

Aggregations

NamespaceClient (com.twosigma.beakerx.NamespaceClient)6 TryResult (com.twosigma.beakerx.TryResult)5 IOException (java.io.IOException)2 BeakerParser (com.twosigma.beakerx.sql.BeakerParser)1 DBConnectionException (com.twosigma.beakerx.sql.DBConnectionException)1 DataSource (javax.sql.DataSource)1