use of com.hazelcast.client.impl.connection.Addresses in project hazelcast by hazelcast.
the class DefaultAddressProviderTest method whenExplicitNoPortAddress.
@Test
public void whenExplicitNoPortAddress() throws UnknownHostException {
ClientNetworkConfig config = new ClientNetworkConfig();
config.addAddress("10.0.0.1");
DefaultAddressProvider provider = new DefaultAddressProvider(config);
Addresses addresses = provider.loadAddresses();
assertPrimary(addresses, new Address("10.0.0.1", 5701));
assertSecondary(addresses, new Address("10.0.0.1", 5702), new Address("10.0.0.1", 5703));
}
use of com.hazelcast.client.impl.connection.Addresses in project hazelcast by hazelcast.
the class DefaultAddressProviderTest method whenNoAddresses.
@Test
public void whenNoAddresses() throws UnknownHostException {
ClientNetworkConfig config = new ClientNetworkConfig();
DefaultAddressProvider provider = new DefaultAddressProvider(config);
Addresses addresses = provider.loadAddresses();
assertPrimary(addresses, new Address("127.0.0.1", 5701));
assertSecondary(addresses, new Address("127.0.0.1", 5702), new Address("127.0.0.1", 5703));
}
use of com.hazelcast.client.impl.connection.Addresses in project hazelcast by hazelcast.
the class DefaultAddressProviderTest method whenBogusAddress.
@Test
public void whenBogusAddress() {
ClientNetworkConfig config = new ClientNetworkConfig();
config.addAddress(UUID.randomUUID().toString());
DefaultAddressProvider provider = new DefaultAddressProvider(config);
Addresses addresses = provider.loadAddresses();
assertPrimaryEmpty(addresses);
assertSecondaryEmpty(addresses);
}
use of com.hazelcast.client.impl.connection.Addresses in project hazelcast by hazelcast.
the class TestHazelcastFactory method createAddressProvider.
private AddressProvider createAddressProvider(ClientConfig config) {
boolean discoveryEnabled = new HazelcastProperties(config.getProperties()).getBoolean(ClientProperty.DISCOVERY_SPI_ENABLED);
List<DiscoveryStrategyConfig> aliasedDiscoveryConfigs = ClientAliasedDiscoveryConfigUtils.createDiscoveryStrategyConfigs(config);
List<String> userConfiguredAddresses = config.getNetworkConfig().getAddresses();
boolean isAtLeastAProviderConfigured = discoveryEnabled || !aliasedDiscoveryConfigs.isEmpty() || !userConfiguredAddresses.isEmpty();
if (isAtLeastAProviderConfigured) {
// address providers or addresses are configured explicitly, don't add more addresses
return null;
}
return new AddressProvider() {
@Override
public Addresses loadAddresses() {
Addresses possibleAddresses = new Addresses();
for (Address address : getKnownAddresses()) {
Addresses addresses = AddressHelper.getPossibleSocketAddresses(address.getPort(), address.getHost(), 1);
possibleAddresses.addAll(addresses);
}
return possibleAddresses;
}
@Override
public Address translate(Address address) {
return address;
}
};
}
Aggregations