use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class GridCommandHandlerMetadataTest method testDropThinConnectionsOnRemove.
/**
* Check the all thin connections are dropped on the command '--meta remove' and '--meta update'.
* Steps:
* - opens thin client connection.
* - creates Type0 on thin client side.
* - removes type by cmd line util.
* - executes any command on thin client to detect disconnect.
* - creates Type0 on thin client side with other type of field (checks the type was removed).
*/
@Test
public void testDropThinConnectionsOnRemove() throws Exception {
Path typeFile = FS.getPath("type0.bin");
try (IgniteClient cli = Ignition.startClient(clientConfiguration())) {
createType(cli.binary(), "Type0", 1);
assertEquals(EXIT_CODE_OK, execute("--meta", "remove", "--typeName", "Type0", "--out", typeFile.toString()));
// Executes command to check disconnect / reconnect.
GridTestUtils.assertThrows(log, () -> cli.createCache(new ClientCacheConfiguration().setName("test")), Exception.class, null);
createType(cli.binary(), "Type0", "str");
} finally {
if (Files.exists(typeFile))
Files.delete(typeFile);
}
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class SystemViewCommandTest method testClientsConnections.
/**
*/
@Test
public void testClientsConnections() throws Exception {
String host = ignite0.configuration().getClientConnectorConfiguration().getHost();
if (host == null)
host = ignite0.configuration().getLocalHost();
int port = ignite0.configuration().getClientConnectorConfiguration().getPort();
try (IgniteClient ignored1 = Ignition.startClient(new ClientConfiguration().setAddresses(host + ":" + port));
Connection ignored2 = new IgniteJdbcThinDriver().connect("jdbc:ignite:thin://" + host, new Properties())) {
assertEquals(2, systemView(ignite0, CLI_CONN_VIEW).size());
}
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class BinaryArraySelfTest method testPrimitivesArrays.
/**
*/
@Test
public void testPrimitivesArrays() {
doTestBoxedPrimitivesArrays(srvCache);
doTestBoxedPrimitivesArrays(cliCache);
doTestPrimitivesArrays(srvCache);
doTestPrimitivesArrays(cliCache);
try (IgniteClient thinClient = thinClient()) {
ClientCacheAdapter<Object, Object> c = new ClientCacheAdapter<>(thinClient.getOrCreateCache(DEFAULT_CACHE_NAME));
doTestBoxedPrimitivesArrays(c);
doTestPrimitivesArrays(c);
}
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class BinaryArraySelfTest method testArrayKey.
/**
*/
@Test
public void testArrayKey() {
doTestKeys(srvCache, arr -> arr);
doTestKeys(cliCache, arr -> arr);
try (IgniteClient thinClient = thinClient()) {
// Using other cache because
// 1. Removed entry store in `GridCacheAdapter#map`
// 2. Bytes representation of multidimensional BinaryArray from thin client and Ignite node differ.
// 2a. Thin client reads array from byte stream and preserve pointer equality (look at #dataToTest() -> arr6).
// 2b. Client node invoke `CacheObjectBinaryProcessorImpl#marshallToBinary` before storing
// which breaks link equality of array
// 3. During invocation of `put` node inserts key representation from previous invocation of methods from client node.
// 4. This lead to `ClientCache#containsKey` can't find key because
// it invokes search based equality on `byte[]` key representaion.
//
// This doesn't happen in `useBinaryArrays=false` becuase Ignite node obtain `Object[]`
// from byte stream and invoke marshallToBinary for it which also breaks pointer equality
// therefore during serialization handle will NOT be used.
// In `useBinaryArrays=true` node read `BinaryArray` from stream which mean no need to marshall to binary
// therefore link equality preserved which mean during serialization handle will be used.
doTestKeys(new ClientCacheAdapter<>(thinClient.getOrCreateCache(DEFAULT_CACHE_NAME + (useBinaryArrays ? "2" : ""))), arr -> arr);
}
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class BinaryArraySelfTest method testArrayFieldInValue.
/**
*/
@Test
public void testArrayFieldInValue() {
doTestValue(srvCache, TO_TEST_CLS, false, true);
doTestValue(cliCache, TO_TEST_CLS, false, true);
doTestValue(srvCache, TO_TEST_CLS, true, true);
doTestValue(cliCache, TO_TEST_CLS, true, true);
try (IgniteClient thinClient = thinClient()) {
ClientCacheAdapter<Object, Object> c = new ClientCacheAdapter<>(thinClient.getOrCreateCache(DEFAULT_CACHE_NAME));
doTestValue(c, TO_TEST_CLS, false, true);
doTestValue(c, TO_TEST_CLS, true, true);
}
}
Aggregations