use of org.apache.ignite.internal.processors.odbc.ClientListenerProcessor.CLI_CONN_VIEW in project ignite by apache.
the class JmxExporterSpiTest method testClientsConnections.
/**
*/
@Test
public void testClientsConnections() throws Exception {
String host = ignite.configuration().getClientConnectorConfiguration().getHost();
if (host == null)
host = ignite.configuration().getLocalHost();
int port = ignite.configuration().getClientConnectorConfiguration().getPort();
try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(host + ":" + port))) {
try (Connection conn = new IgniteJdbcThinDriver().connect("jdbc:ignite:thin://" + host, new Properties())) {
TabularDataSupport conns = systemView(CLI_CONN_VIEW);
Consumer<CompositeData> checkThin = c -> {
assertEquals("THIN", c.get("type"));
assertTrue(c.get("localAddress").toString().endsWith(Integer.toString(port)));
assertEquals(c.get("version"), ProtocolVersion.LATEST_VER.toString());
};
Consumer<CompositeData> checkJdbc = c -> {
assertEquals("JDBC", c.get("type"));
assertTrue(c.get("localAddress").toString().endsWith(Integer.toString(port)));
assertEquals(c.get("version"), JdbcConnectionContext.CURRENT_VER.asString());
};
CompositeData c0 = conns.get(new Object[] { 0 });
CompositeData c1 = conns.get(new Object[] { 1 });
if (c0.get("type").equals("JDBC")) {
checkJdbc.accept(c0);
checkThin.accept(c1);
} else {
checkJdbc.accept(c1);
checkThin.accept(c0);
}
assertEquals(2, conns.size());
}
}
boolean res = GridTestUtils.waitForCondition(() -> systemView(CLI_CONN_VIEW).isEmpty(), 5_000);
assertTrue(res);
}
Aggregations