use of org.apache.ignite.events.EventType.EVT_SQL_QUERY_EXECUTION in project ignite by apache.
the class UserQueriesTestBase method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
IgnitePredicate<SqlQueryExecutionEvent> lsnr = evt -> {
assertNotNull(evt.text());
SQL_QRY_EXEC_EVT_CNTR.incrementAndGet();
return true;
};
int[] evts = new int[] { EVT_SQL_QUERY_EXECUTION };
cfg.setIncludeEventTypes(evts);
cfg.setLocalEventListeners(Collections.singletonMap(lsnr, evts));
return cfg;
}
use of org.apache.ignite.events.EventType.EVT_SQL_QUERY_EXECUTION in project ignite by apache.
the class IgniteCacheAbstractQuerySelfTest method doTestClientQueryExecutedEvents.
/**
*/
public void doTestClientQueryExecutedEvents(boolean inclSens) throws Exception {
CountDownLatch execLatch = new CountDownLatch(9);
IgnitePredicate<SqlQueryExecutionEvent> lsnr = evt -> {
assertNotNull(evt.text());
if (inclSens)
assertTrue(evt.toString().contains("args="));
else
assertFalse(evt.toString().contains("args="));
execLatch.countDown();
return true;
};
ignite().events().localListen(lsnr, EVT_SQL_QUERY_EXECUTION);
ClientConfiguration cc = new ClientConfiguration().setAddresses(Config.SERVER);
try (IgniteClient client = Ignition.startClient(cc)) {
client.query(new SqlFieldsQuery("create table TEST_TABLE(key int primary key, val int)")).getAll();
client.query(new SqlFieldsQuery("insert into TEST_TABLE values (?, ?)").setArgs(1, 1)).getAll();
client.query(new SqlFieldsQuery("update TEST_TABLE set val = ?2 where key = ?1").setArgs(1, 2)).getAll();
client.query(new SqlFieldsQuery("select * from TEST_TABLE")).getAll();
client.query(new SqlFieldsQuery("create index idx_1 on TEST_TABLE(key)")).getAll();
client.query(new SqlFieldsQuery("drop index idx_1")).getAll();
client.query(new SqlFieldsQuery("alter table TEST_TABLE add column val2 int")).getAll();
client.query(new SqlFieldsQuery("alter table TEST_TABLE drop val2")).getAll();
client.query(new SqlFieldsQuery("drop table TEST_TABLE")).getAll();
assert execLatch.await(3_000, MILLISECONDS);
} finally {
ignite().events().stopLocalListen(lsnr, EVT_SQL_QUERY_EXECUTION);
}
}
Aggregations