Search in sources :

Example 11 with DiscoveryServiceProvider

use of com.hazelcast.spi.discovery.integration.DiscoveryServiceProvider in project hazelcast by hazelcast.

the class HazelcastClientInstanceImpl method initDiscoveryService.

private DiscoveryService initDiscoveryService(ClientConfig config) {
    // and strategies are resolved but the AddressProvider is never registered
    if (!properties.getBoolean(ClientProperty.DISCOVERY_SPI_ENABLED)) {
        return null;
    }
    ILogger logger = loggingService.getLogger(DiscoveryService.class);
    ClientNetworkConfig networkConfig = config.getNetworkConfig();
    DiscoveryConfig discoveryConfig = networkConfig.getDiscoveryConfig().getAsReadOnly();
    DiscoveryServiceProvider factory = discoveryConfig.getDiscoveryServiceProvider();
    if (factory == null) {
        factory = new DefaultDiscoveryServiceProvider();
    }
    DiscoveryServiceSettings settings = new DiscoveryServiceSettings().setConfigClassLoader(config.getClassLoader()).setLogger(logger).setDiscoveryMode(DiscoveryMode.Client).setDiscoveryConfig(discoveryConfig);
    DiscoveryService discoveryService = factory.newDiscoveryService(settings);
    discoveryService.start();
    return discoveryService;
}
Also used : DefaultDiscoveryServiceProvider(com.hazelcast.spi.discovery.impl.DefaultDiscoveryServiceProvider) DiscoveryServiceProvider(com.hazelcast.spi.discovery.integration.DiscoveryServiceProvider) DefaultDiscoveryServiceProvider(com.hazelcast.spi.discovery.impl.DefaultDiscoveryServiceProvider) ILogger(com.hazelcast.logging.ILogger) DiscoveryConfig(com.hazelcast.config.DiscoveryConfig) DiscoveryService(com.hazelcast.spi.discovery.integration.DiscoveryService) DiscoveryServiceSettings(com.hazelcast.spi.discovery.integration.DiscoveryServiceSettings) ClientNetworkConfig(com.hazelcast.client.config.ClientNetworkConfig)

Aggregations

DiscoveryServiceProvider (com.hazelcast.spi.discovery.integration.DiscoveryServiceProvider)11 DefaultDiscoveryServiceProvider (com.hazelcast.spi.discovery.impl.DefaultDiscoveryServiceProvider)10 QuickTest (com.hazelcast.test.annotation.QuickTest)9 Test (org.junit.Test)9 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)8 DiscoveryService (com.hazelcast.spi.discovery.integration.DiscoveryService)8 DefaultDiscoveryService (com.hazelcast.spi.discovery.impl.DefaultDiscoveryService)7 DiscoveryServiceSettings (com.hazelcast.spi.discovery.integration.DiscoveryServiceSettings)7 ClientNetworkConfig (com.hazelcast.client.config.ClientNetworkConfig)6 ClientConfig (com.hazelcast.client.config.ClientConfig)5 JoinConfig (com.hazelcast.config.JoinConfig)4 InputStream (java.io.InputStream)4 XmlClientConfigBuilder (com.hazelcast.client.config.XmlClientConfigBuilder)3 AwsConfig (com.hazelcast.config.AwsConfig)3 Config (com.hazelcast.config.Config)3 DiscoveryStrategyConfig (com.hazelcast.config.DiscoveryStrategyConfig)3 InterfacesConfig (com.hazelcast.config.InterfacesConfig)3 MulticastConfig (com.hazelcast.config.MulticastConfig)3 TcpIpConfig (com.hazelcast.config.TcpIpConfig)3 Address (com.hazelcast.nio.Address)3