use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.
the class ReliableChannelTest method testReinitDuplicatedAddress.
/**
* Checks that reinitialization of duplicated address is correct.
*/
@Test
public void testReinitDuplicatedAddress() {
TestAddressFinder finder = new TestAddressFinder().nextAddresesResponse("127.0.0.1:10800", "127.0.0.1:10801", "127.0.0.1:10802").nextAddresesResponse("127.0.0.1:10803", "127.0.0.1:10804", "127.0.0.1:10805").nextAddresesResponse("127.0.0.1:10803", "127.0.0.1:10804", "127.0.0.1:10806").nextAddresesResponse("127.0.0.1:10803", "127.0.0.1:10803", "127.0.0.1:10806").nextAddresesResponse("127.0.0.1:10803", "127.0.0.1:10803", "127.0.0.1:10803").nextAddresesResponse("127.0.0.1:10803", "127.0.0.1:10803", "127.0.0.1:10804").nextAddresesResponse("127.0.0.1:10803", "127.0.0.1:10804", "127.0.0.1:10804").nextAddresesResponse("127.0.0.1:10800", "127.0.0.1:10801", "127.0.0.1:10802");
ClientConfiguration ccfg = new ClientConfiguration().setAddressesFinder(finder);
ReliableChannel rc = new ReliableChannel(chFactory, ccfg, null);
Supplier<List<String>> holderAddresses = () -> rc.getChannelHolders().stream().map(h -> h.getAddress().toString()).sorted().collect(Collectors.toList());
Consumer<List<String>> assertAddrReInitAndEqualsTo = (addrs) -> {
rc.channelsInit();
assertEquals(addrs, holderAddresses.get());
};
assertAddrReInitAndEqualsTo.accept(Arrays.asList("127.0.0.1:10800", "127.0.0.1:10801", "127.0.0.1:10802"));
assertAddrReInitAndEqualsTo.accept(Arrays.asList("127.0.0.1:10803", "127.0.0.1:10804", "127.0.0.1:10805"));
assertAddrReInitAndEqualsTo.accept(Arrays.asList("127.0.0.1:10803", "127.0.0.1:10804", "127.0.0.1:10806"));
assertAddrReInitAndEqualsTo.accept(Arrays.asList("127.0.0.1:10803", "127.0.0.1:10803", "127.0.0.1:10806"));
assertAddrReInitAndEqualsTo.accept(Arrays.asList("127.0.0.1:10803", "127.0.0.1:10803", "127.0.0.1:10803"));
assertAddrReInitAndEqualsTo.accept(Arrays.asList("127.0.0.1:10803", "127.0.0.1:10803", "127.0.0.1:10804"));
assertAddrReInitAndEqualsTo.accept(Arrays.asList("127.0.0.1:10803", "127.0.0.1:10804", "127.0.0.1:10804"));
assertAddrReInitAndEqualsTo.accept(Arrays.asList("127.0.0.1:10800", "127.0.0.1:10801", "127.0.0.1:10802"));
}
use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.
the class ReliableChannelTest method testNodeChannelsAreNotCleaned.
/**
* Checks that node channels are persisted if channels are reinit with static address configuration.
*/
@Test
public void testNodeChannelsAreNotCleaned() {
ClientConfiguration ccfg = new ClientConfiguration().setAddresses(dfltAddrs).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(1, rc.getNodeChannels().size());
}
use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.
the class ReliableChannelTest method testChannelsNotReinitForStaticAddressConfiguration.
/**
* Checks that channel holders are not reinited for static address configuration.
*/
@Test
public void testChannelsNotReinitForStaticAddressConfiguration() {
ClientConfiguration ccfg = new ClientConfiguration().setAddresses(dfltAddrs);
checkDoesNotReinit(ccfg);
}
use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.
the class ReliableChannelTest method testDynamicAddressReinitializedCorrectly.
/**
* Checks that channels are changed (add new, remove old) and close channels if reinitialization performed.
*/
@Test
public void testDynamicAddressReinitializedCorrectly() {
TestAddressFinder finder = new TestAddressFinder().nextAddresesResponse(dfltAddrs).nextAddresesResponse("127.0.0.1:10800", "127.0.0.1:10803");
ClientConfiguration ccfg = new ClientConfiguration().setAddressesFinder(finder);
ReliableChannel rc = new ReliableChannel(chFactory, ccfg, null);
rc.channelsInit();
List<ReliableChannel.ClientChannelHolder> originChannels = Collections.unmodifiableList(rc.getChannelHolders());
// Imitate topology change.
rc.initChannelHolders();
assertEquals(2, F.size(originChannels, ReliableChannel.ClientChannelHolder::isClosed));
List<ReliableChannel.ClientChannelHolder> reuseChannel = originChannels.stream().filter(c -> !c.isClosed()).collect(Collectors.toList());
assertEquals(1, reuseChannel.size());
List<ReliableChannel.ClientChannelHolder> newChannels = rc.getChannelHolders();
assertEquals(2, newChannels.size());
assertTrue(newChannels.get(0) == reuseChannel.get(0) || newChannels.get(1) == reuseChannel.get(0));
newChannels.forEach(c -> assertFalse(c.isClosed()));
}
use of org.apache.ignite.configuration.ClientConfiguration in project ignite by apache.
the class ReliableChannelTest method testFailOnInitIfDefaultChannelFailed.
/**
* Should fail if default channel is not initialized.
*/
@Test(expected = TestChannelException.class)
public void testFailOnInitIfDefaultChannelFailed() {
ClientConfiguration ccfg = new ClientConfiguration().setAddresses(dfltAddrs).setPartitionAwarenessEnabled(true);
ReliableChannel rc = new ReliableChannel((cfg, hnd) -> new TestFailureClientChannel(), ccfg, null);
rc.channelsInit();
}
Aggregations