use of com.hazelcast.client.config.ClientNetworkConfig 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.ClientNetworkConfig in project hazelcast by hazelcast.
the class HazelcastClientInstanceImpl method initListenerService.
private ClientListenerServiceImpl initListenerService() {
int eventQueueCapacity = properties.getInteger(ClientProperty.EVENT_QUEUE_CAPACITY);
int eventThreadCount = properties.getInteger(ClientProperty.EVENT_THREAD_COUNT);
final ClientNetworkConfig networkConfig = config.getNetworkConfig();
if (networkConfig.isSmartRouting()) {
return new ClientSmartListenerService(this, eventThreadCount, eventQueueCapacity);
} else {
return new ClientNonSmartListenerService(this, eventThreadCount, eventQueueCapacity);
}
}
use of com.hazelcast.client.config.ClientNetworkConfig in project bazel by bazelbuild.
the class ConcurrentMapFactory method createHazelcast.
public static ConcurrentMap<String, byte[]> createHazelcast(RemoteOptions options) {
HazelcastInstance instance;
if (options.hazelcastClientConfig != null) {
try {
ClientConfig config = new XmlClientConfigBuilder(options.hazelcastClientConfig).build();
instance = HazelcastClient.newHazelcastClient(config);
} catch (IOException e) {
throw new RuntimeException(e);
}
} else if (options.hazelcastNode != null) {
// If --hazelcast_node is specified then create a client instance.
ClientConfig config = new ClientConfig();
ClientNetworkConfig net = config.getNetworkConfig();
net.addAddress(options.hazelcastNode.split(","));
instance = HazelcastClient.newHazelcastClient(config);
} else if (options.hazelcastStandaloneListenPort != 0) {
Config config = new Config();
config.getNetworkConfig().setPort(options.hazelcastStandaloneListenPort).getJoin().getMulticastConfig().setEnabled(false);
instance = Hazelcast.newHazelcastInstance(config);
} else {
// Otherwise create a default instance. This is going to look at
// -Dhazelcast.config=some-hazelcast.xml for configuration.
instance = Hazelcast.newHazelcastInstance();
}
return instance.getMap(HAZELCAST_CACHE_NAME);
}
use of com.hazelcast.client.config.ClientNetworkConfig in project hazelcast by hazelcast.
the class ClientDiscoverySpiTest method test_discovery_address_translator.
@Test
public void test_discovery_address_translator() throws Exception {
String xmlFileName = "hazelcast-client-discovery-spi-test.xml";
InputStream xmlResource = ClientDiscoverySpiTest.class.getClassLoader().getResourceAsStream(xmlFileName);
ClientConfig clientConfig = new XmlClientConfigBuilder(xmlResource).build();
ClientNetworkConfig networkConfig = clientConfig.getNetworkConfig();
DiscoveryConfig discoveryConfig = networkConfig.getDiscoveryConfig();
DiscoveryServiceProvider provider = new DefaultDiscoveryServiceProvider();
DiscoveryService discoveryService = provider.newDiscoveryService(buildDiscoveryServiceSettings(discoveryConfig));
AddressTranslator translator = new DiscoveryAddressTranslator(discoveryService, false);
Address address = new Address("127.0.0.1", 50001);
assertNull(translator.translate(null));
assertEquals(address, translator.translate(address));
// Enforce refresh of the internal mapping
assertEquals(address, translator.translate(address));
}
use of com.hazelcast.client.config.ClientNetworkConfig in project hazelcast by hazelcast.
the class ClientDiscoverySpiTest method test_enabled_whenDiscoveryConfigIsNull.
@Test(expected = IllegalArgumentException.class)
public void test_enabled_whenDiscoveryConfigIsNull() {
ClientConfig config = new ClientConfig();
config.setProperty(GroupProperty.DISCOVERY_SPI_ENABLED.getName(), "true");
ClientNetworkConfig networkConfig = config.getNetworkConfig();
networkConfig.setDiscoveryConfig(null);
}
Aggregations