Search in sources :

Example 1 with WebServer

use of org.h2.server.web.WebServer in project ignite by apache.

the class IgniteH2Indexing method start.

/** {@inheritDoc} */
@SuppressWarnings("NonThreadSafeLazyInitialization")
@Override
public void start(GridKernalContext ctx, GridSpinBusyLock busyLock) throws IgniteCheckedException {
    if (log.isDebugEnabled())
        log.debug("Starting cache query index...");
    this.busyLock = busyLock;
    qryIdGen = new AtomicLong();
    if (SysProperties.serializeJavaObject) {
        U.warn(log, "Serialization of Java objects in H2 was enabled.");
        SysProperties.serializeJavaObject = false;
    }
    String dbName = (ctx != null ? ctx.localNodeId() : UUID.randomUUID()).toString();
    dbUrl = "jdbc:h2:mem:" + dbName + DB_OPTIONS;
    org.h2.Driver.load();
    try {
        if (getString(IGNITE_H2_DEBUG_CONSOLE) != null) {
            Connection c = DriverManager.getConnection(dbUrl);
            int port = getInteger(IGNITE_H2_DEBUG_CONSOLE_PORT, 0);
            WebServer webSrv = new WebServer();
            Server web = new Server(webSrv, "-webPort", Integer.toString(port));
            web.start();
            String url = webSrv.addSession(c);
            U.quietAndInfo(log, "H2 debug console URL: " + url);
            try {
                Server.openBrowser(url);
            } catch (Exception e) {
                U.warn(log, "Failed to open browser: " + e.getMessage());
            }
        }
    } catch (SQLException e) {
        throw new IgniteCheckedException(e);
    }
    if (ctx == null) {
        // This is allowed in some tests.
        nodeId = UUID.randomUUID();
        marshaller = new JdkMarshaller();
    } else {
        this.ctx = ctx;
        schemas.put(QueryUtils.DFLT_SCHEMA, new H2Schema(QueryUtils.DFLT_SCHEMA));
        valCtx = new CacheQueryObjectValueContext(ctx);
        nodeId = ctx.localNodeId();
        marshaller = ctx.config().getMarshaller();
        mapQryExec = new GridMapQueryExecutor(busyLock);
        rdcQryExec = new GridReduceQueryExecutor(qryIdGen, busyLock);
        mapQryExec.start(ctx, this);
        rdcQryExec.start(ctx, this);
        stmtCacheCleanupTask = ctx.timeout().schedule(new Runnable() {

            @Override
            public void run() {
                cleanupStatementCache();
            }
        }, CLEANUP_STMT_CACHE_PERIOD, CLEANUP_STMT_CACHE_PERIOD);
        dmlProc = new DmlStatementsProcessor();
        ddlProc = new DdlStatementsProcessor();
        dmlProc.start(ctx, this);
        ddlProc.start(ctx, this);
    }
    if (JdbcUtils.serializer != null)
        U.warn(log, "Custom H2 serialization is already configured, will override.");
    JdbcUtils.serializer = h2Serializer();
// TODO https://issues.apache.org/jira/browse/IGNITE-2139
// registerMBean(igniteInstanceName, this, GridH2IndexingSpiMBean.class);
}
Also used : WebServer(org.h2.server.web.WebServer) Server(org.h2.tools.Server) SQLException(java.sql.SQLException) IgniteSQLException(org.apache.ignite.internal.processors.query.IgniteSQLException) Connection(java.sql.Connection) IgniteSystemProperties.getString(org.apache.ignite.IgniteSystemProperties.getString) QueryCancelledException(org.apache.ignite.cache.query.QueryCancelledException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) SQLException(java.sql.SQLException) IgniteException(org.apache.ignite.IgniteException) GridCacheEntryRemovedException(org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException) CacheException(javax.cache.CacheException) IgniteSQLException(org.apache.ignite.internal.processors.query.IgniteSQLException) GridMapQueryExecutor(org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor) AtomicLong(java.util.concurrent.atomic.AtomicLong) DdlStatementsProcessor(org.apache.ignite.internal.processors.query.h2.ddl.DdlStatementsProcessor) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) WebServer(org.h2.server.web.WebServer) GridPlainRunnable(org.apache.ignite.internal.util.lang.GridPlainRunnable) JdkMarshaller(org.apache.ignite.marshaller.jdk.JdkMarshaller) CacheQueryObjectValueContext(org.apache.ignite.internal.processors.query.CacheQueryObjectValueContext) GridReduceQueryExecutor(org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor)

Aggregations

Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 CacheException (javax.cache.CacheException)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteException (org.apache.ignite.IgniteException)1 IgniteSystemProperties.getString (org.apache.ignite.IgniteSystemProperties.getString)1 QueryCancelledException (org.apache.ignite.cache.query.QueryCancelledException)1 GridCacheEntryRemovedException (org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException)1 CacheQueryObjectValueContext (org.apache.ignite.internal.processors.query.CacheQueryObjectValueContext)1 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)1 DdlStatementsProcessor (org.apache.ignite.internal.processors.query.h2.ddl.DdlStatementsProcessor)1 GridMapQueryExecutor (org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor)1 GridReduceQueryExecutor (org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor)1 GridPlainRunnable (org.apache.ignite.internal.util.lang.GridPlainRunnable)1 JdkMarshaller (org.apache.ignite.marshaller.jdk.JdkMarshaller)1 WebServer (org.h2.server.web.WebServer)1 Server (org.h2.tools.Server)1