use of com.hazelcast.client.config.ClientAwsConfig in project hazelcast by hazelcast.
the class HazelcastClientInstanceImpl method createAddressProviders.
private Collection<AddressProvider> createAddressProviders(AddressProvider externalAddressProvider) {
ClientNetworkConfig networkConfig = getClientConfig().getNetworkConfig();
final ClientAwsConfig awsConfig = networkConfig.getAwsConfig();
Collection<AddressProvider> addressProviders = new LinkedList<AddressProvider>();
addressProviders.add(new DefaultAddressProvider(networkConfig));
if (externalAddressProvider != null) {
addressProviders.add(externalAddressProvider);
}
if (discoveryService != null) {
addressProviders.add(new DiscoveryAddressProvider(discoveryService, loggingService));
}
if (awsConfig != null && awsConfig.isEnabled()) {
try {
addressProviders.add(new AwsAddressProvider(awsConfig, loggingService));
} catch (NoClassDefFoundError e) {
ILogger logger = loggingService.getLogger(HazelcastClient.class);
logger.warning("hazelcast-aws.jar might be missing!");
throw e;
}
}
return addressProviders;
}
use of com.hazelcast.client.config.ClientAwsConfig in project hazelcast by hazelcast.
the class AwsAddressTranslatorTest method setUp.
@Before
public void setUp() throws Exception {
privateAddress = new Address("127.0.0.1", 5701);
publicAddress = new Address("192.168.0.1", 5701);
awsClient = mock(AWSClient.class);
when(awsClient.getAddresses()).thenReturn(lookup);
config = new ClientAwsConfig();
config.setIamRole("anyRole");
ILogger logger = Logger.getLogger(AwsAddressTranslatorTest.class);
loggingService = mock(LoggingService.class);
when(loggingService.getLogger(eq(AwsAddressTranslator.class))).thenReturn(logger);
translator = new AwsAddressTranslator(config, loggingService);
}
use of com.hazelcast.client.config.ClientAwsConfig in project hazelcast by hazelcast.
the class TestClientApplicationContext method testAwsClientConfig.
@Test
public void testAwsClientConfig() {
assertNotNull(client4);
ClientConfig config = client4.getClientConfig();
ClientNetworkConfig networkConfig = config.getNetworkConfig();
ClientAwsConfig awsConfig = networkConfig.getAwsConfig();
assertFalse(awsConfig.isEnabled());
assertTrue(awsConfig.isInsideAws());
assertEquals("sample-access-key", awsConfig.getAccessKey());
assertEquals("sample-secret-key", awsConfig.getSecretKey());
assertEquals("sample-region", awsConfig.getRegion());
assertEquals("sample-group", awsConfig.getSecurityGroupName());
assertEquals("sample-tag-key", awsConfig.getTagKey());
assertEquals("sample-tag-value", awsConfig.getTagValue());
}
use of com.hazelcast.client.config.ClientAwsConfig in project hazelcast by hazelcast.
the class DefaultClientConnectionManagerFactory method createConnectionManager.
@Override
public ClientConnectionManager createConnectionManager(ClientConfig config, HazelcastClientInstanceImpl client, DiscoveryService discoveryService) {
LoggingService loggingService = client.getLoggingService();
ILogger logger = loggingService.getLogger(HazelcastClient.class);
ClientAwsConfig awsConfig = config.getNetworkConfig().getAwsConfig();
AddressTranslator addressTranslator;
if (awsConfig != null && awsConfig.isEnabled()) {
try {
addressTranslator = new AwsAddressTranslator(awsConfig, loggingService);
} catch (NoClassDefFoundError e) {
logger.warning("hazelcast-aws.jar might be missing!");
throw e;
}
} else if (discoveryService != null) {
addressTranslator = new DiscoveryAddressTranslator(discoveryService, client.getProperties().getBoolean(ClientProperty.DISCOVERY_SPI_PUBLIC_IP_ENABLED));
} else {
addressTranslator = new DefaultAddressTranslator();
}
return new ClientConnectionManagerImpl(client, addressTranslator);
}
Aggregations