Search in sources :

Example 1 with ConnectionManager

use of org.apache.ignite.internal.processors.query.h2.ConnectionManager in project ignite by apache.

the class ValidateIndexesClosure method mvccSession.

/**
 * Get session with MVCC snapshot and QueryContext.
 *
 * @param cctx Cache context.
 * @return Session with QueryContext and MVCC snapshot.
 * @throws IgniteCheckedException If failed.
 */
private Session mvccSession(GridCacheContext<?, ?> cctx) throws IgniteCheckedException {
    Session session = null;
    boolean mvccEnabled = cctx.mvccEnabled();
    if (mvccEnabled) {
        ConnectionManager connMgr = ((IgniteH2Indexing) ignite.context().query().getIndexing()).connections();
        JdbcConnection connection = (JdbcConnection) connMgr.connection().connection();
        session = (Session) connection.getSession();
        MvccQueryTracker tracker = MvccUtils.mvccTracker(cctx, true);
        MvccSnapshot mvccSnapshot = tracker.snapshot();
        final QueryContext qctx = new QueryContext(0, cacheName -> null, null, mvccSnapshot, null, true);
        session.setVariable(H2Utils.QCTX_VARIABLE_NAME, new H2Utils.ValueRuntimeSimpleObject<>(qctx));
    }
    return session;
}
Also used : H2Utils(org.apache.ignite.internal.processors.query.h2.H2Utils) MvccQueryTracker(org.apache.ignite.internal.processors.cache.mvcc.MvccQueryTracker) MvccSnapshot(org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot) ConnectionManager(org.apache.ignite.internal.processors.query.h2.ConnectionManager) JdbcConnection(org.h2.jdbc.JdbcConnection) QueryContext(org.apache.ignite.internal.processors.query.h2.opt.QueryContext) IgniteH2Indexing(org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing) Session(org.h2.engine.Session)

Example 2 with ConnectionManager

use of org.apache.ignite.internal.processors.query.h2.ConnectionManager in project ignite by apache.

the class JdbcThinTransactionsLeaksMvccTest method usedConnectionCount.

/**
 * @param igx Node.
 * @return Count of detached connections.
 */
private int usedConnectionCount(IgniteEx igx) {
    ConnectionManager connMgr = ((IgniteH2Indexing) igx.context().query().getIndexing()).connections();
    Set<H2Connection> usedConns = GridTestUtils.getFieldValue(connMgr, "usedConns");
    return usedConns.size();
}
Also used : ConnectionManager(org.apache.ignite.internal.processors.query.h2.ConnectionManager) IgniteH2Indexing(org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing) H2Connection(org.apache.ignite.internal.processors.query.h2.H2Connection)

Example 3 with ConnectionManager

use of org.apache.ignite.internal.processors.query.h2.ConnectionManager in project ignite by apache.

the class IgniteH2Indexing method start.

/**
 * {@inheritDoc}
 */
@SuppressWarnings({ "deprecation", "AssignmentToStaticFieldFromInstanceMethod" })
@Override
public void start(GridKernalContext ctx, GridSpinBusyLock busyLock) throws IgniteCheckedException {
    if (log.isDebugEnabled())
        log.debug("Starting cache query index...");
    this.busyLock = busyLock;
    if (SysProperties.serializeJavaObject) {
        U.warn(log, "Serialization of Java objects in H2 was enabled.");
        SysProperties.serializeJavaObject = false;
    }
    this.ctx = ctx;
    partReservationMgr = new PartitionReservationManager(ctx);
    connMgr = new ConnectionManager(ctx);
    longRunningQryMgr = new LongRunningQueryManager(ctx);
    parser = new QueryParser(this, connMgr);
    schemaMgr = new SchemaManager(ctx, connMgr);
    schemaMgr.start(ctx.config().getSqlConfiguration().getSqlSchemas());
    statsMgr = new IgniteStatisticsManagerImpl(ctx, schemaMgr);
    nodeId = ctx.localNodeId();
    marshaller = ctx.config().getMarshaller();
    mapQryExec = new GridMapQueryExecutor();
    rdcQryExec = new GridReduceQueryExecutor();
    mapQryExec.start(ctx, this);
    rdcQryExec.start(ctx, this);
    discoLsnr = evt -> {
        mapQryExec.onNodeLeft((DiscoveryEvent) evt);
        rdcQryExec.onNodeLeft((DiscoveryEvent) evt);
    };
    ctx.event().addLocalEventListener(discoLsnr, EventType.EVT_NODE_FAILED, EventType.EVT_NODE_LEFT);
    qryLsnr = (nodeId, msg, plc) -> onMessage(nodeId, msg);
    ctx.io().addMessageListener(GridTopic.TOPIC_QUERY, qryLsnr);
    runningQryMgr = new RunningQueryManager(ctx);
    partExtractor = new PartitionExtractor(new H2PartitionResolver(this), ctx);
    cmdProc = new CommandProcessor(ctx, schemaMgr, this);
    cmdProc.start();
    if (JdbcUtils.serializer != null)
        U.warn(log, "Custom H2 serialization is already configured, will override.");
    JdbcUtils.serializer = h2Serializer();
    distrCfg = new DistributedSqlConfiguration(ctx, log);
    funcMgr = new FunctionsManager(distrCfg);
}
Also used : H2PartitionResolver(org.apache.ignite.internal.processors.query.h2.affinity.H2PartitionResolver) GridMapQueryExecutor(org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor) RunningQueryManager(org.apache.ignite.internal.processors.query.RunningQueryManager) IgniteStatisticsManagerImpl(org.apache.ignite.internal.processors.query.stat.IgniteStatisticsManagerImpl) PartitionReservationManager(org.apache.ignite.internal.processors.query.h2.twostep.PartitionReservationManager) PartitionExtractor(org.apache.ignite.internal.processors.query.h2.affinity.PartitionExtractor) GridReduceQueryExecutor(org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor)

Aggregations

ConnectionManager (org.apache.ignite.internal.processors.query.h2.ConnectionManager)2 IgniteH2Indexing (org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing)2 MvccQueryTracker (org.apache.ignite.internal.processors.cache.mvcc.MvccQueryTracker)1 MvccSnapshot (org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot)1 RunningQueryManager (org.apache.ignite.internal.processors.query.RunningQueryManager)1 H2Connection (org.apache.ignite.internal.processors.query.h2.H2Connection)1 H2Utils (org.apache.ignite.internal.processors.query.h2.H2Utils)1 H2PartitionResolver (org.apache.ignite.internal.processors.query.h2.affinity.H2PartitionResolver)1 PartitionExtractor (org.apache.ignite.internal.processors.query.h2.affinity.PartitionExtractor)1 QueryContext (org.apache.ignite.internal.processors.query.h2.opt.QueryContext)1 GridMapQueryExecutor (org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor)1 GridReduceQueryExecutor (org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor)1 PartitionReservationManager (org.apache.ignite.internal.processors.query.h2.twostep.PartitionReservationManager)1 IgniteStatisticsManagerImpl (org.apache.ignite.internal.processors.query.stat.IgniteStatisticsManagerImpl)1 Session (org.h2.engine.Session)1 JdbcConnection (org.h2.jdbc.JdbcConnection)1