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());
}
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());
}
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);
}
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);
}
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));
}
}
Aggregations