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