Search in sources :

Example 1 with ClientAwsConfig

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;
}
Also used : AwsAddressProvider(com.hazelcast.client.spi.impl.AwsAddressProvider) DefaultAddressProvider(com.hazelcast.client.spi.impl.DefaultAddressProvider) AddressProvider(com.hazelcast.client.connection.AddressProvider) DiscoveryAddressProvider(com.hazelcast.client.spi.impl.discovery.DiscoveryAddressProvider) AwsAddressProvider(com.hazelcast.client.spi.impl.AwsAddressProvider) DiscoveryAddressProvider(com.hazelcast.client.spi.impl.discovery.DiscoveryAddressProvider) DefaultAddressProvider(com.hazelcast.client.spi.impl.DefaultAddressProvider) HazelcastClient(com.hazelcast.client.HazelcastClient) ILogger(com.hazelcast.logging.ILogger) ClientAwsConfig(com.hazelcast.client.config.ClientAwsConfig) LinkedList(java.util.LinkedList) ClientNetworkConfig(com.hazelcast.client.config.ClientNetworkConfig)

Example 2 with ClientAwsConfig

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);
}
Also used : Address(com.hazelcast.nio.Address) LoggingService(com.hazelcast.logging.LoggingService) ILogger(com.hazelcast.logging.ILogger) AWSClient(com.hazelcast.aws.AWSClient) ClientAwsConfig(com.hazelcast.client.config.ClientAwsConfig) Before(org.junit.Before)

Example 3 with ClientAwsConfig

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());
}
Also used : ClientConfig(com.hazelcast.client.config.ClientConfig) ClientAwsConfig(com.hazelcast.client.config.ClientAwsConfig) ClientNetworkConfig(com.hazelcast.client.config.ClientNetworkConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with ClientAwsConfig

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);
}
Also used : AddressTranslator(com.hazelcast.client.connection.AddressTranslator) DefaultAddressTranslator(com.hazelcast.client.spi.impl.DefaultAddressTranslator) AwsAddressTranslator(com.hazelcast.client.spi.impl.AwsAddressTranslator) DiscoveryAddressTranslator(com.hazelcast.client.spi.impl.discovery.DiscoveryAddressTranslator) AwsAddressTranslator(com.hazelcast.client.spi.impl.AwsAddressTranslator) ClientConnectionManagerImpl(com.hazelcast.client.connection.nio.ClientConnectionManagerImpl) DefaultAddressTranslator(com.hazelcast.client.spi.impl.DefaultAddressTranslator) LoggingService(com.hazelcast.logging.LoggingService) ILogger(com.hazelcast.logging.ILogger) DiscoveryAddressTranslator(com.hazelcast.client.spi.impl.discovery.DiscoveryAddressTranslator) ClientAwsConfig(com.hazelcast.client.config.ClientAwsConfig)

Aggregations

ClientAwsConfig (com.hazelcast.client.config.ClientAwsConfig)4 ILogger (com.hazelcast.logging.ILogger)3 ClientNetworkConfig (com.hazelcast.client.config.ClientNetworkConfig)2 LoggingService (com.hazelcast.logging.LoggingService)2 AWSClient (com.hazelcast.aws.AWSClient)1 HazelcastClient (com.hazelcast.client.HazelcastClient)1 ClientConfig (com.hazelcast.client.config.ClientConfig)1 AddressProvider (com.hazelcast.client.connection.AddressProvider)1 AddressTranslator (com.hazelcast.client.connection.AddressTranslator)1 ClientConnectionManagerImpl (com.hazelcast.client.connection.nio.ClientConnectionManagerImpl)1 AwsAddressProvider (com.hazelcast.client.spi.impl.AwsAddressProvider)1 AwsAddressTranslator (com.hazelcast.client.spi.impl.AwsAddressTranslator)1 DefaultAddressProvider (com.hazelcast.client.spi.impl.DefaultAddressProvider)1 DefaultAddressTranslator (com.hazelcast.client.spi.impl.DefaultAddressTranslator)1 DiscoveryAddressProvider (com.hazelcast.client.spi.impl.discovery.DiscoveryAddressProvider)1 DiscoveryAddressTranslator (com.hazelcast.client.spi.impl.discovery.DiscoveryAddressTranslator)1 Address (com.hazelcast.nio.Address)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 LinkedList (java.util.LinkedList)1 Before (org.junit.Before)1