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);
}
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;
}
Aggregations