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