Search in sources :

Example 31 with ClientConfiguration

use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.

the class ReliableChannelTest method testAddressWithoutPort.

/**
 * Checks that in case if address specified without port, the default port will be processed first
 */
@Test
public void testAddressWithoutPort() {
    ClientConfiguration ccfg = new ClientConfiguration().setAddresses("127.0.0.1");
    ReliableChannel rc = new ReliableChannel(chFactory, ccfg, null);
    rc.channelsInit();
    assertEquals(ClientConnectorConfiguration.DFLT_PORT_RANGE + 1, rc.getChannelHolders().size());
    assertEquals(ClientConnectorConfiguration.DFLT_PORT, rc.getChannelHolders().iterator().next().getAddress().getPort());
}
Also used : ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) Test(org.junit.Test)

Example 32 with ClientConfiguration

use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.

the class ReliableChannelTest method testThatNodeChannelsCleanFullReinitialization.

/**
 * Check that node channels are cleaned in case of full reinitialization.
 */
@Test
public void testThatNodeChannelsCleanFullReinitialization() {
    TestAddressFinder finder = new TestAddressFinder().nextAddresesResponse(dfltAddrs).nextAddresesResponse("127.0.0.1:10803", "127.0.0.1:10804");
    ClientConfiguration ccfg = new ClientConfiguration().setAddressesFinder(finder).setPartitionAwarenessEnabled(false);
    ReliableChannel rc = new ReliableChannel(chFactory, ccfg, null);
    rc.channelsInit();
    // Trigger TestClientChannel creation.
    rc.service(null, null, null);
    assertEquals(1, rc.getNodeChannels().size());
    // Imitate topology change.
    rc.initChannelHolders();
    assertEquals(0, rc.getNodeChannels().size());
}
Also used : ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) Test(org.junit.Test)

Example 33 with ClientConfiguration

use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.

the class ReliableChannelTest method testChannelsNotReinitForStableDynamicAddressConfiguration.

/**
 * Checks that channel holders are not reinited if address finder return the same list of addresses.
 */
@Test
public void testChannelsNotReinitForStableDynamicAddressConfiguration() {
    TestAddressFinder finder = new TestAddressFinder().nextAddresesResponse(dfltAddrs).nextAddresesResponse("127.0.0.1:10800", "127.0.0.1:10801", "127.0.0.1:10802");
    ClientConfiguration ccfg = new ClientConfiguration().setAddressesFinder(finder);
    checkDoesNotReinit(ccfg);
}
Also used : ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) Test(org.junit.Test)

Example 34 with ClientConfiguration

use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.

the class ThinClientPartitionAwarenessDiscoveryTest method getClientConfigurationWithDiscovery.

/**
 * Provide ClientConfiguration with addrResolver that find all alive nodes.
 */
private ClientConfiguration getClientConfigurationWithDiscovery(int... excludeIdx) {
    Set<Integer> exclude = Arrays.stream(excludeIdx).boxed().collect(Collectors.toSet());
    ClientAddressFinder addrFinder = () -> IgnitionEx.allGrids().stream().map(node -> {
        int port = (Integer) node.cluster().localNode().attributes().get(CLIENT_LISTENER_PORT);
        if (exclude.contains(port - DFLT_PORT))
            return null;
        return "127.0.0.1:" + port;
    }).filter(Objects::nonNull).toArray(String[]::new);
    return new ClientConfiguration().setAddressesFinder(addrFinder).setPartitionAwarenessEnabled(true);
}
Also used : ClientAddressFinder(org.apache.ignite.client.ClientAddressFinder) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration)

Example 35 with ClientConfiguration

use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.

the class JavaThinCompatibilityTest method testExpiryPolicy.

/**
 */
private void testExpiryPolicy() throws Exception {
    X.println(">>>> Testing expiry policy");
    try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(ADDR))) {
        ClientCache<Object, Object> cache = client.getOrCreateCache("testExpiryPolicy");
        cache = cache.withExpirePolicy(new CreatedExpiryPolicy(new Duration(TimeUnit.MILLISECONDS, 1)));
        cache.put(1, 1);
        doSleep(10);
        assertFalse(cache.containsKey(1));
    }
}
Also used : IgniteClient(org.apache.ignite.client.IgniteClient) BinaryObject(org.apache.ignite.binary.BinaryObject) Duration(javax.cache.expiry.Duration) CreatedExpiryPolicy(javax.cache.expiry.CreatedExpiryPolicy) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) ThinClientConfiguration(org.apache.ignite.configuration.ThinClientConfiguration)

Aggregations

ClientConfiguration (org.apache.ignite.configuration.ClientConfiguration)83 Test (org.junit.Test)44 IgniteClient (org.apache.ignite.client.IgniteClient)42 Ignite (org.apache.ignite.Ignite)28 ThinClientConfiguration (org.apache.ignite.configuration.ThinClientConfiguration)23 BinaryObject (org.apache.ignite.binary.BinaryObject)14 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)14 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)14 List (java.util.List)11 Ignition (org.apache.ignite.Ignition)10 SqlFieldsQuery (org.apache.ignite.cache.query.SqlFieldsQuery)10 GridTestUtils (org.apache.ignite.testframework.GridTestUtils)9 Collections (java.util.Collections)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 IgniteBinary (org.apache.ignite.IgniteBinary)7 Connection (java.sql.Connection)6 Arrays (java.util.Arrays)6 Map (java.util.Map)6 Consumer (java.util.function.Consumer)6 ScanQuery (org.apache.ignite.cache.query.ScanQuery)6