Search in sources :

Example 1 with DiscoveryConfigReadOnly

use of com.hazelcast.internal.config.DiscoveryConfigReadOnly in project hazelcast by hazelcast.

the class DiscoveryTest method test_DiscoveryConfigReadOnly_addDiscoveryStrategyConfig_thenUnsupportedOperationException.

@Test(expected = UnsupportedOperationException.class)
public void test_DiscoveryConfigReadOnly_addDiscoveryStrategyConfig_thenUnsupportedOperationException() {
    DiscoveryConfig discoveryConfig = new DiscoveryConfig();
    DiscoveryConfig readOnly = new DiscoveryConfigReadOnly(discoveryConfig);
    DiscoveryStrategyFactory discoveryStrategyFactory = new TestDiscoveryStrategyFactory();
    DiscoveryStrategyConfig discoveryStrategyConfig = new DiscoveryStrategyConfig(discoveryStrategyFactory);
    readOnly.addDiscoveryStrategyConfig(discoveryStrategyConfig);
}
Also used : DiscoveryStrategyFactory(com.hazelcast.spi.discovery.DiscoveryStrategyFactory) DiscoveryConfigReadOnly(com.hazelcast.internal.config.DiscoveryConfigReadOnly) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with DiscoveryConfigReadOnly

use of com.hazelcast.internal.config.DiscoveryConfigReadOnly in project hazelcast by hazelcast.

the class ClusterDiscoveryServiceBuilder method initDiscoveryService.

private DiscoveryService initDiscoveryService(ClientConfig config) {
    // Prevent confusing behavior where the DiscoveryService is started
    // and strategies are resolved but the AddressProvider is never registered
    List<DiscoveryStrategyConfig> aliasedDiscoveryConfigs = ClientAliasedDiscoveryConfigUtils.createDiscoveryStrategyConfigs(config);
    if (!properties.getBoolean(ClientProperty.DISCOVERY_SPI_ENABLED) && aliasedDiscoveryConfigs.isEmpty() && !config.getNetworkConfig().isAutoDetectionEnabled()) {
        return null;
    }
    ILogger logger = loggingService.getLogger(DiscoveryService.class);
    ClientNetworkConfig networkConfig = config.getNetworkConfig();
    DiscoveryConfig discoveryConfig = new DiscoveryConfigReadOnly(networkConfig.getDiscoveryConfig());
    DiscoveryServiceProvider factory = discoveryConfig.getDiscoveryServiceProvider();
    if (factory == null) {
        factory = new DefaultDiscoveryServiceProvider();
    }
    boolean isAutoDetectionEnabled = networkConfig.isAutoDetectionEnabled();
    DiscoveryServiceSettings settings = new DiscoveryServiceSettings().setConfigClassLoader(config.getClassLoader()).setLogger(logger).setDiscoveryMode(DiscoveryMode.Client).setAliasedDiscoveryConfigs(aliasedDiscoveryConfigs).setDiscoveryConfig(discoveryConfig).setAutoDetectionEnabled(isAutoDetectionEnabled);
    DiscoveryService discoveryService = factory.newDiscoveryService(settings);
    if (isAutoDetectionEnabled && isEmptyDiscoveryStrategies(discoveryService)) {
        return null;
    }
    discoveryService.start();
    return discoveryService;
}
Also used : DiscoveryServiceProvider(com.hazelcast.spi.discovery.integration.DiscoveryServiceProvider) DefaultDiscoveryServiceProvider(com.hazelcast.spi.discovery.impl.DefaultDiscoveryServiceProvider) DefaultDiscoveryServiceProvider(com.hazelcast.spi.discovery.impl.DefaultDiscoveryServiceProvider) DiscoveryStrategyConfig(com.hazelcast.config.DiscoveryStrategyConfig) ILogger(com.hazelcast.logging.ILogger) DiscoveryConfig(com.hazelcast.config.DiscoveryConfig) DefaultDiscoveryService(com.hazelcast.spi.discovery.impl.DefaultDiscoveryService) DiscoveryService(com.hazelcast.spi.discovery.integration.DiscoveryService) DiscoveryServiceSettings(com.hazelcast.spi.discovery.integration.DiscoveryServiceSettings) DiscoveryConfigReadOnly(com.hazelcast.internal.config.DiscoveryConfigReadOnly) ClientNetworkConfig(com.hazelcast.client.config.ClientNetworkConfig)

Aggregations

DiscoveryConfigReadOnly (com.hazelcast.internal.config.DiscoveryConfigReadOnly)2 ClientNetworkConfig (com.hazelcast.client.config.ClientNetworkConfig)1 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)1 DiscoveryStrategyConfig (com.hazelcast.config.DiscoveryStrategyConfig)1 ILogger (com.hazelcast.logging.ILogger)1 DiscoveryStrategyFactory (com.hazelcast.spi.discovery.DiscoveryStrategyFactory)1 DefaultDiscoveryService (com.hazelcast.spi.discovery.impl.DefaultDiscoveryService)1 DefaultDiscoveryServiceProvider (com.hazelcast.spi.discovery.impl.DefaultDiscoveryServiceProvider)1 DiscoveryService (com.hazelcast.spi.discovery.integration.DiscoveryService)1 DiscoveryServiceProvider (com.hazelcast.spi.discovery.integration.DiscoveryServiceProvider)1 DiscoveryServiceSettings (com.hazelcast.spi.discovery.integration.DiscoveryServiceSettings)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 Test (org.junit.Test)1