Search in sources :

Example 16 with IgniteClient

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);
    }
}
Also used : Path(java.nio.file.Path) IgniteClient(org.apache.ignite.client.IgniteClient) ClientCacheConfiguration(org.apache.ignite.client.ClientCacheConfiguration) Test(org.junit.Test)

Example 17 with IgniteClient

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());
    }
}
Also used : IgniteJdbcThinDriver(org.apache.ignite.IgniteJdbcThinDriver) IgniteClient(org.apache.ignite.client.IgniteClient) Connection(java.sql.Connection) Properties(java.util.Properties) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) Test(org.junit.Test)

Example 18 with IgniteClient

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);
    }
}
Also used : IgniteClient(org.apache.ignite.client.IgniteClient) BinaryObject(org.apache.ignite.binary.BinaryObject) Test(org.junit.Test)

Example 19 with IgniteClient

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);
    }
}
Also used : IgniteClient(org.apache.ignite.client.IgniteClient) Test(org.junit.Test)

Example 20 with IgniteClient

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);
    }
}
Also used : IgniteClient(org.apache.ignite.client.IgniteClient) BinaryObject(org.apache.ignite.binary.BinaryObject) Test(org.junit.Test)

Aggregations

IgniteClient (org.apache.ignite.client.IgniteClient)106 Test (org.junit.Test)76 ClientConfiguration (org.apache.ignite.configuration.ClientConfiguration)43 ThinClientConfiguration (org.apache.ignite.configuration.ThinClientConfiguration)26 UUID (java.util.UUID)21 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)15 Ignite (org.apache.ignite.Ignite)14 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)14 HashSet (java.util.HashSet)13 T2 (org.apache.ignite.internal.util.typedef.T2)13 Set (java.util.Set)12 CountDownLatch (java.util.concurrent.CountDownLatch)12 ContinuousQuery (org.apache.ignite.cache.query.ContinuousQuery)12 List (java.util.List)10 BinaryObject (org.apache.ignite.binary.BinaryObject)10 GridTestUtils (org.apache.ignite.testframework.GridTestUtils)10 GridTestUtils.assertThrowsWithCause (org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause)10 Map (java.util.Map)9 Duration (javax.cache.expiry.Duration)9 ClientCacheConfiguration (org.apache.ignite.client.ClientCacheConfiguration)9