use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.
the class JavaThinCompatibilityTest method testBinary.
/**
*/
private void testBinary() throws Exception {
X.println(">>>> Testing binary");
try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(ADDR))) {
IgniteBinary binary = client.binary();
BinaryObject val = binary.builder("Person").setField("id", 1, int.class).setField("name", "Joe", String.class).build();
ClientCache<Object, BinaryObject> cache = client.getOrCreateCache("testBinary").withKeepBinary();
cache.put(0, val);
BinaryObject cachedVal = cache.get(0);
assertEquals(val, cachedVal);
}
}
use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.
the class JavaThinCompatibilityTest method testServiceDescriptorsThrows.
/**
*/
private void testServiceDescriptorsThrows() {
X.println(">>>> Testing services descriptors queries throws");
try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(ADDR))) {
String errMsg = "Feature " + GET_SERVICE_DESCRIPTORS.name() + " is not supported by the server";
Throwable err = assertThrowsWithCause(() -> client.services().serviceDescriptors(), ClientFeatureNotSupportedByServerException.class);
assertEquals(errMsg, err.getMessage());
err = assertThrowsWithCause(() -> client.services().serviceDescriptor("test_service"), ClientFeatureNotSupportedByServerException.class);
assertEquals(errMsg, err.getMessage());
}
}
use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.
the class JavaThinCompatibilityTest method testCacheConfiguration.
/**
*/
private void testCacheConfiguration(boolean checkFieldsPrecessionAndScale, boolean checkExpiryPlc) throws Exception {
X.println(">>>> Testing cache configuration");
try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(ADDR))) {
String cacheName = "testCacheConfiguration";
ClientCacheConfiguration ccfg = new ClientCacheConfiguration();
ccfg.setName(cacheName);
ccfg.setBackups(3);
ccfg.setGroupName("cache");
ccfg.setCacheMode(CacheMode.PARTITIONED);
QueryEntity qryEntity = new QueryEntity(int.class.getName(), "Entity").setTableName("ENTITY").setFields(new LinkedHashMap<>(F.asMap("id", Integer.class.getName(), "rate", Double.class.getName())));
if (checkFieldsPrecessionAndScale) {
qryEntity.setFieldsPrecision(F.asMap("rate", 5));
qryEntity.setFieldsScale(F.asMap("rate", 2));
}
ccfg.setQueryEntities(qryEntity);
if (checkExpiryPlc)
ccfg.setExpiryPolicy(new PlatformExpiryPolicy(10, 20, 30));
client.createCache(ccfg);
ClientCacheConfiguration ccfg1 = client.cache(cacheName).getConfiguration();
assertEquals(ccfg.getName(), ccfg1.getName());
assertEquals(ccfg.getBackups(), ccfg1.getBackups());
assertEquals(ccfg.getGroupName(), ccfg1.getGroupName());
assertEquals(ccfg.getCacheMode(), ccfg1.getCacheMode());
assertEquals(ccfg.getQueryEntities().length, ccfg1.getQueryEntities().length);
assertEquals(ccfg.getQueryEntities()[0].getTableName(), ccfg1.getQueryEntities()[0].getTableName());
assertEquals(ccfg.getQueryEntities()[0].getFields(), ccfg1.getQueryEntities()[0].getFields());
if (checkFieldsPrecessionAndScale) {
assertEquals(ccfg.getQueryEntities()[0].getFieldsPrecision(), ccfg1.getQueryEntities()[0].getFieldsPrecision());
assertEquals(ccfg.getQueryEntities()[0].getFieldsScale(), ccfg1.getQueryEntities()[0].getFieldsScale());
}
if (checkExpiryPlc) {
assertEquals(ccfg.getExpiryPolicy().getExpiryForCreation(), ccfg1.getExpiryPolicy().getExpiryForCreation());
assertEquals(ccfg.getExpiryPolicy().getExpiryForAccess(), ccfg1.getExpiryPolicy().getExpiryForAccess());
assertEquals(ccfg.getExpiryPolicy().getExpiryForUpdate(), ccfg1.getExpiryPolicy().getExpiryForUpdate());
}
}
}
use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.
the class JavaThinCompatibilityTest method testQueries.
/**
*/
private void testQueries() throws Exception {
X.println(">>>> Testing queries");
try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(ADDR))) {
ClientCache<Object, Object> cache = client.getOrCreateCache("testQueries");
cache.put(1, 1);
List<Cache.Entry<Object, Object>> res = cache.query(new ScanQuery<>()).getAll();
assertEquals(1, res.size());
assertEquals(1, res.get(0).getKey());
assertEquals(1, res.get(0).getValue());
}
}
use of org.apache.ignite.configuration.ClientConfiguration 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