use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project gridgain by gridgain.
the class DynamicIndexAbstractConcurrentSelfTest method checkClientReconnect.
/**
* Make sure that client receives schema changes made while it was disconnected, optionally with cache restart
* in the interim.
*
* @param restartCache Whether cache needs to be recreated during client's absence.
* @throws Exception If failed.
*/
private void checkClientReconnect(final boolean restartCache) throws Exception {
// Start complex topology.
final Ignite srv = ignitionStart(serverConfiguration(1));
ignitionStart(serverConfiguration(2));
ignitionStart(serverConfiguration(3, true));
final Ignite cli = ignitionStart(clientConfiguration(4));
createSqlCache(cli);
// Check index create.
reconnectClientNode(srv, cli, restartCache, new RunnableX() {
@Override
public void runx() throws Exception {
final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1));
queryProcessor(srv).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false, 0).get();
}
});
assertIndex(cli, CACHE_NAME, TBL_NAME, IDX_NAME_1, QueryIndex.DFLT_INLINE_SIZE, field(FIELD_NAME_1));
assertIndexUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_1, SQL_ARG_1);
// Check index drop.
reconnectClientNode(srv, cli, restartCache, new RunnableX() {
@Override
public void runx() throws Exception {
if (!restartCache)
queryProcessor(srv).dynamicIndexDrop(CACHE_NAME, CACHE_NAME, IDX_NAME_1, false).get();
}
});
assertNoIndex(cli, CACHE_NAME, TBL_NAME, IDX_NAME_1);
assertIndexNotUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_1, SQL_ARG_1);
// Update existing index.
QueryIndex idx = index(IDX_NAME_2, field(aliasUnescaped(FIELD_NAME_2)));
queryProcessor(srv).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false, 0).get();
assertIndex(cli, CACHE_NAME, TBL_NAME, IDX_NAME_2, QueryIndex.DFLT_INLINE_SIZE, field(aliasUnescaped(FIELD_NAME_2)));
assertIndexUsed(IDX_NAME_2, SQL_SIMPLE_FIELD_2, SQL_ARG_2);
reconnectClientNode(srv, cli, restartCache, new RunnableX() {
@Override
public void runx() throws Exception {
if (!restartCache)
queryProcessor(srv).dynamicIndexDrop(CACHE_NAME, CACHE_NAME, IDX_NAME_2, false).get();
final QueryIndex idx = index(IDX_NAME_2, field(FIELD_NAME_1), field(aliasUnescaped(FIELD_NAME_2)));
queryProcessor(srv).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false, 0).get();
}
});
assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_2, QueryIndex.DFLT_INLINE_SIZE, field(FIELD_NAME_1), field(aliasUnescaped(FIELD_NAME_2)));
assertIndexUsed(IDX_NAME_2, SQL_COMPOSITE, SQL_ARG_1, SQL_ARG_2);
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JmxExporterSpiTest method testFilterAndExport.
/**
*/
@Test
public void testFilterAndExport() throws Exception {
createAdditionalMetrics(ignite);
assertThrowsWithCause(new RunnableX() {
@Override
public void runx() throws Exception {
metricRegistry(ignite.name(), "filtered", "metric");
}
}, IgniteException.class);
DynamicMBean bean1 = metricRegistry(ignite.name(), "other", "prefix");
assertEquals(42L, bean1.getAttribute("test"));
assertEquals(43L, bean1.getAttribute("test2"));
DynamicMBean bean2 = metricRegistry(ignite.name(), "other", "prefix2");
assertEquals(44L, bean2.getAttribute("test3"));
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinConnectionSelfTest method testCommit.
/**
* @throws Exception If failed.
*/
@Test
public void testCommit() throws Exception {
try (Connection conn = DriverManager.getConnection(urlWithPartitionAwarenessProp)) {
// Should not be called in auto-commit mode
assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
conn.commit();
return null;
}
}, SQLException.class, "Transaction cannot be committed explicitly in auto-commit mode");
assertTrue(conn.getAutoCommit());
// Should not be called in auto-commit mode
assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
conn.commit();
return null;
}
}, SQLException.class, "Transaction cannot be committed explicitly in auto-commit mode.");
conn.close();
// Exception when called on closed connection
checkConnectionClosed(new RunnableX() {
@Override
public void runx() throws Exception {
conn.commit();
}
});
}
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinConnectionSelfTest method testCreateStatement.
/**
* @throws Exception If failed.
*/
@Test
public void testCreateStatement() throws Exception {
try (Connection conn = DriverManager.getConnection(urlWithPartitionAwarenessProp)) {
try (Statement stmt = conn.createStatement()) {
assertNotNull(stmt);
stmt.close();
conn.close();
// Exception when called on closed connection
checkConnectionClosed(new RunnableX() {
@Override
public void runx() throws Exception {
conn.createStatement();
}
});
}
}
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinConnectionSelfTest method testCreateStruct.
/**
* @throws Exception If failed.
*/
@Test
public void testCreateStruct() throws Exception {
try (Connection conn = DriverManager.getConnection(urlWithPartitionAwarenessProp)) {
// Invalid typename
assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
return conn.createStruct(null, null);
}
}, SQLException.class, "Type name cannot be null");
final String typeName = "employee";
final Object[] attrs = new Object[] { 100, "Tom" };
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
conn.createStruct(typeName, attrs);
}
});
conn.close();
checkConnectionClosed(new RunnableX() {
@Override
public void runx() throws Exception {
conn.createStruct(typeName, attrs);
}
});
}
}
Aggregations