use of com.hazelcast.client.impl.connection.Addresses in project hazelcast by hazelcast.
the class DefaultAddressProvider method loadAddresses.
@Override
public Addresses loadAddresses() {
List<String> configuredAddresses = networkConfig.getAddresses();
if (configuredAddresses.isEmpty()) {
configuredAddresses.add("127.0.0.1");
}
Addresses addresses = new Addresses();
for (String address : configuredAddresses) {
addresses.addAll(AddressHelper.getSocketAddresses(address));
}
return addresses;
}
use of com.hazelcast.client.impl.connection.Addresses in project hazelcast by hazelcast.
the class AddressHelper method toAddresses.
private static Addresses toAddresses(List<Address> addressList) {
Addresses result = new Addresses();
if (addressList.size() > 0) {
result.primary().add(addressList.remove(0));
result.secondary().addAll(addressList);
}
return result;
}
use of com.hazelcast.client.impl.connection.Addresses in project hazelcast by hazelcast.
the class TcpClientConnectionManager method getPossibleMemberAddresses.
Collection<Address> getPossibleMemberAddresses(AddressProvider addressProvider) {
Collection<Address> addresses = new LinkedHashSet<>();
try {
Addresses result = addressProvider.loadAddresses();
if (shuffleMemberList) {
// The relative order between primary and secondary addresses should not be changed.
// so we shuffle the lists separately and then add them to the final list so that
// secondary addresses are not tried before all primary addresses have been tried.
// Otherwise we can get startup delays.
Collections.shuffle(result.primary());
Collections.shuffle(result.secondary());
}
addresses.addAll(result.primary());
addresses.addAll(result.secondary());
} catch (NullPointerException e) {
throw e;
} catch (Exception e) {
logger.warning("Exception from AddressProvider: " + addressProvider, e);
}
return addresses;
}
use of com.hazelcast.client.impl.connection.Addresses in project hazelcast by hazelcast.
the class DefaultAddressProviderTest method whenExplicitPorts.
@Test
public void whenExplicitPorts() throws UnknownHostException {
ClientNetworkConfig config = new ClientNetworkConfig();
config.addAddress("10.0.0.1:5703");
config.addAddress("10.0.0.1:5702");
DefaultAddressProvider provider = new DefaultAddressProvider(config);
Addresses addresses = provider.loadAddresses();
assertPrimary(addresses, new Address("10.0.0.1", 5703), new Address("10.0.0.1", 5702));
assertSecondaryEmpty(addresses);
}
use of com.hazelcast.client.impl.connection.Addresses in project hazelcast by hazelcast.
the class DefaultAddressProviderTest method whenMix.
@Test
public void whenMix() throws UnknownHostException {
ClientNetworkConfig config = new ClientNetworkConfig();
config.addAddress("10.0.0.1:5701");
config.addAddress("10.0.0.1:5702");
config.addAddress("10.0.0.2");
DefaultAddressProvider provider = new DefaultAddressProvider(config);
Addresses addresses = provider.loadAddresses();
assertPrimary(addresses, new Address("10.0.0.1", 5701), new Address("10.0.0.1", 5702), new Address("10.0.0.2", 5701));
assertSecondary(addresses, new Address("10.0.0.2", 5702), new Address("10.0.0.2", 5703));
}
Aggregations