use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.
the class LongDestroyDurableBackgroundTaskTest method batchQuery.
/**
* Batch query.
*
* @param ignite Ignite instance.
* @param qry SQL query.
* @param batchArgs Batch arguments.
* @throws Exception If failed.
*/
private void batchQuery(Ignite ignite, String qry, List<Object[]> batchArgs) throws Exception {
String 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())) {
PreparedStatement statement = conn.prepareStatement(qry);
for (Object[] args : batchArgs) {
for (int i = 1; i <= args.length; i++) statement.setObject(i, args[i - 1]);
statement.addBatch();
statement.clearParameters();
}
statement.executeBatch();
}
}
}
use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.
the class TestClusterClientConnection method testClientConnectsToCluster.
/**
*/
@Test
public void testClientConnectsToCluster() throws Exception {
mockServerResponse();
IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName(), false);
IgniteEx crd = startGrid(cfg);
String crdAddr = crd.localNode().addresses().iterator().next();
mockServerResponse(crdAddr);
ClientConfiguration ccfg = new ClientConfiguration();
ccfg.setAddressesFinder(new ThinClientKubernetesAddressFinder(prepareConfiguration()));
IgniteClient client = Ignition.startClient(ccfg);
ClientCache cache = client.createCache("cache");
cache.put(1, 2);
assertEquals(2, cache.get(1));
}
use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.
the class ArrayIndexTest method checkTableExpression.
/**
*/
private void checkTableExpression(boolean useTypedArrays) throws Exception {
System.setProperty(IGNITE_USE_BINARY_ARRAYS, Boolean.toString(useTypedArrays));
BinaryArray.initUseBinaryArrays();
try (IgniteEx ex = startGrid(0);
IgniteEx cli = startClientGrid(1);
IgniteClient thinCli = Ignition.startClient(new ClientConfiguration().setAddresses(SERVER))) {
ex.cluster().active(true);
executeSql(cli, "CREATE TABLE T1 (id int not null, name varchar(1), PRIMARY KEY(id))");
String insertQry = "INSERT INTO T1(id, name) VALUES (?, ?)";
executeSql(cli, insertQry, 1, "A");
executeSql(cli, insertQry, 2, "B");
executeSql(cli, insertQry, 3, "C");
String select = "SELECT T1.ID, T1.NAME FROM T1 INNER JOIN TABLE (id2 int = ?) T2 on (T1.id = T2.id2) ORDER BY id";
Object arg = new Integer[] { 1, 2 };
Consumer<List<List<?>>> checker = res -> {
assertNotNull(res);
assertEquals(2, res.size());
assertEquals(1, res.get(0).get(0));
assertEquals("A", res.get(0).get(1));
assertEquals(2, res.get(1).get(0));
assertEquals("B", res.get(1).get(1));
};
checker.accept(executeSql(ex, select, arg));
checker.accept(executeSql(cli, select, arg));
checker.accept(thinCli.query(new SqlFieldsQuery(select).setArgs(arg)).getAll());
} finally {
System.clearProperty(IGNITE_USE_BINARY_ARRAYS);
BinaryArray.initUseBinaryArrays();
}
}
Aggregations