Search in sources :

Example 1 with IgniteH2Indexing

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

the class GridQueryParsingTest method connection.

/**
     *
     */
private JdbcConnection connection() throws Exception {
    GridKernalContext ctx = ((IgniteEx) ignite).context();
    GridQueryProcessor qryProcessor = ctx.query();
    IgniteH2Indexing idx = U.field(qryProcessor, "idx");
    String schemaName = idx.schema(DEFAULT_CACHE_NAME);
    return (JdbcConnection) idx.connectionForSchema(schemaName);
}
Also used : GridKernalContext(org.apache.ignite.internal.GridKernalContext) IgniteEx(org.apache.ignite.internal.IgniteEx) GridQueryProcessor(org.apache.ignite.internal.processors.query.GridQueryProcessor) JdbcConnection(org.h2.jdbc.JdbcConnection) IgniteH2Indexing(org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing)

Example 2 with IgniteH2Indexing

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

the class IgniteCacheQueryH2IndexingLeakTest method getStatementCacheSize.

/**
     * @param qryProcessor Query processor.
     * @return size of statement cache.
     */
private static int getStatementCacheSize(GridQueryProcessor qryProcessor) {
    IgniteH2Indexing h2Idx = GridTestUtils.getFieldValue(qryProcessor, GridQueryProcessor.class, "idx");
    ConcurrentMap stmtCache = GridTestUtils.getFieldValue(h2Idx, IgniteH2Indexing.class, "stmtCache");
    return stmtCache.size();
}
Also used : ConcurrentMap(java.util.concurrent.ConcurrentMap) IgniteH2Indexing(org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing)

Example 3 with IgniteH2Indexing

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

the class GridMapQueryExecutor method start.

/**
     * @param ctx Context.
     * @param h2 H2 Indexing.
     * @throws IgniteCheckedException If failed.
     */
public void start(final GridKernalContext ctx, IgniteH2Indexing h2) throws IgniteCheckedException {
    this.ctx = ctx;
    this.h2 = h2;
    log = ctx.log(GridMapQueryExecutor.class);
    final UUID locNodeId = ctx.localNodeId();
    ctx.event().addLocalEventListener(new GridLocalEventListener() {

        @Override
        public void onEvent(final Event evt) {
            UUID nodeId = ((DiscoveryEvent) evt).eventNode().id();
            GridH2QueryContext.clearAfterDeadNode(locNodeId, nodeId);
            NodeResults nodeRess = qryRess.remove(nodeId);
            if (nodeRess == null)
                return;
            nodeRess.cancelAll();
        }
    }, EventType.EVT_NODE_FAILED, EventType.EVT_NODE_LEFT);
    ctx.io().addMessageListener(GridTopic.TOPIC_QUERY, new GridMessageListener() {

        @Override
        public void onMessage(UUID nodeId, Object msg) {
            if (!busyLock.enterBusy())
                return;
            try {
                if (msg instanceof GridCacheQueryMarshallable)
                    ((GridCacheQueryMarshallable) msg).unmarshall(ctx.config().getMarshaller(), ctx);
                GridMapQueryExecutor.this.onMessage(nodeId, msg);
            } finally {
                busyLock.leaveBusy();
            }
        }
    });
}
Also used : GridLocalEventListener(org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener) GridMessageListener(org.apache.ignite.internal.managers.communication.GridMessageListener) GridCacheQueryMarshallable(org.apache.ignite.internal.processors.cache.query.GridCacheQueryMarshallable) CacheQueryExecutedEvent(org.apache.ignite.events.CacheQueryExecutedEvent) Event(org.apache.ignite.events.Event) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) CacheQueryReadEvent(org.apache.ignite.events.CacheQueryReadEvent) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) GridH2ValueCacheObject(org.apache.ignite.internal.processors.query.h2.opt.GridH2ValueCacheObject) UUID(java.util.UUID)

Example 4 with IgniteH2Indexing

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

the class H2DynamicTableSelfTest method doTestCreateTable.

/**
     * Test that {@code CREATE TABLE} with given template cache name actually creates new cache,
     * H2 table and type descriptor on all nodes, optionally with cache type check.
     * @param tplCacheName Template cache name.
     * @param mode Expected cache mode, or {@code null} if no check is needed.
     */
private void doTestCreateTable(String tplCacheName, CacheMode mode) {
    executeDdl("CREATE TABLE \"Person\" (\"id\" int, \"city\" varchar," + " \"name\" varchar, \"surname\" varchar, \"age\" int, PRIMARY KEY (\"id\", \"city\")) WITH " + (F.isEmpty(tplCacheName) ? "" : "\"template=" + tplCacheName + "\",") + "\"backups=10,atomicity=atomic\"");
    for (int i = 0; i < 4; i++) {
        IgniteEx node = grid(i);
        assertNotNull(node.cache("Person"));
        DynamicCacheDescriptor cacheDesc = node.context().cache().cacheDescriptor("Person");
        assertNotNull(cacheDesc);
        if (mode == CacheMode.REPLICATED)
            assertEquals(Integer.MAX_VALUE, cacheDesc.cacheConfiguration().getBackups());
        else
            assertEquals(10, cacheDesc.cacheConfiguration().getBackups());
        assertEquals(CacheAtomicityMode.ATOMIC, cacheDesc.cacheConfiguration().getAtomicityMode());
        assertTrue(cacheDesc.sql());
        if (mode != null)
            assertEquals(mode, cacheDesc.cacheConfiguration().getCacheMode());
        QueryTypeDescriptorImpl desc = typeExisting(node, "Person", "Person");
        assertEquals(Object.class, desc.keyClass());
        assertEquals("PersonKey", desc.keyTypeName());
        assertEquals(Object.class, desc.valueClass());
        assertEquals("Person", desc.valueTypeName());
        assertEquals(F.asList("id", "city", "name", "surname", "age"), new ArrayList<>(desc.fields().keySet()));
        assertProperty(desc, "id", Integer.class, true);
        assertProperty(desc, "city", String.class, true);
        assertProperty(desc, "name", String.class, false);
        assertProperty(desc, "surname", String.class, false);
        assertProperty(desc, "age", Integer.class, false);
        GridH2Table tbl = ((IgniteH2Indexing) node.context().query().getIndexing()).dataTable("PUBLIC", "Person");
        assertNotNull(tbl);
    }
}
Also used : QueryTypeDescriptorImpl(org.apache.ignite.internal.processors.query.QueryTypeDescriptorImpl) IgniteEx(org.apache.ignite.internal.IgniteEx) GridH2Table(org.apache.ignite.internal.processors.query.h2.opt.GridH2Table) DynamicCacheDescriptor(org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor) IgniteH2Indexing(org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing)

Aggregations

IgniteH2Indexing (org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing)3 IgniteEx (org.apache.ignite.internal.IgniteEx)2 UUID (java.util.UUID)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 CacheQueryExecutedEvent (org.apache.ignite.events.CacheQueryExecutedEvent)1 CacheQueryReadEvent (org.apache.ignite.events.CacheQueryReadEvent)1 DiscoveryEvent (org.apache.ignite.events.DiscoveryEvent)1 Event (org.apache.ignite.events.Event)1 GridKernalContext (org.apache.ignite.internal.GridKernalContext)1 GridMessageListener (org.apache.ignite.internal.managers.communication.GridMessageListener)1 GridLocalEventListener (org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener)1 DynamicCacheDescriptor (org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor)1 GridCacheQueryMarshallable (org.apache.ignite.internal.processors.cache.query.GridCacheQueryMarshallable)1 GridQueryProcessor (org.apache.ignite.internal.processors.query.GridQueryProcessor)1 QueryTypeDescriptorImpl (org.apache.ignite.internal.processors.query.QueryTypeDescriptorImpl)1 GridH2Table (org.apache.ignite.internal.processors.query.h2.opt.GridH2Table)1 GridH2ValueCacheObject (org.apache.ignite.internal.processors.query.h2.opt.GridH2ValueCacheObject)1 JdbcConnection (org.h2.jdbc.JdbcConnection)1