use of com.hazelcast.spi.MemberAddressProvider in project hazelcast by hazelcast.
the class DefaultNodeContext method newMemberAddressProviderInstance.
@SuppressWarnings("checkstyle:npathcomplexity")
private static // would make it harder to read
MemberAddressProvider newMemberAddressProviderInstance(Class<? extends MemberAddressProvider> clazz, ILogger logger, Properties properties) {
Properties nonNullProps = properties == null ? new Properties() : properties;
MemberAddressProvider provider = InstantiationUtils.newInstanceOrNull(clazz, nonNullProps, logger);
if (provider == null) {
provider = InstantiationUtils.newInstanceOrNull(clazz, logger, nonNullProps);
}
if (provider == null) {
provider = InstantiationUtils.newInstanceOrNull(clazz, nonNullProps);
}
if (provider == null) {
if (properties != null && !properties.isEmpty()) {
throw new InvalidConfigurationException("Cannot find a matching constructor for MemberAddressProvider. " + "The member address provider has properties configured, but the class " + "'" + clazz.getName() + "' does not have a public constructor accepting properties.");
}
provider = InstantiationUtils.newInstanceOrNull(clazz, logger);
}
if (provider == null) {
provider = InstantiationUtils.newInstanceOrNull(clazz);
}
if (provider == null) {
throw new InvalidConfigurationException("Cannot find a matching constructor for MemberAddressProvider " + "implementation '" + clazz.getName() + "'.");
}
return provider;
}
use of com.hazelcast.spi.MemberAddressProvider in project hazelcast by hazelcast.
the class DefaultNodeContext method createAddressPicker.
@Override
public AddressPicker createAddressPicker(Node node) {
Config config = node.getConfig();
MemberAddressProviderConfig memberAddressProviderConfig = getActiveMemberNetworkConfig(config).getMemberAddressProviderConfig();
final ILogger addressPickerLogger = node.getLogger(AddressPicker.class);
if (!memberAddressProviderConfig.isEnabled()) {
if (config.getAdvancedNetworkConfig().isEnabled()) {
return new AdvancedNetworkAddressPicker(config, addressPickerLogger);
}
return new DefaultAddressPicker(config, addressPickerLogger);
}
MemberAddressProvider implementation = memberAddressProviderConfig.getImplementation();
if (implementation != null) {
return new DelegatingAddressPicker(implementation, config, addressPickerLogger);
}
ClassLoader classLoader = config.getClassLoader();
String classname = memberAddressProviderConfig.getClassName();
Class<? extends MemberAddressProvider> clazz = loadMemberAddressProviderClass(classLoader, classname);
ILogger memberAddressProviderLogger = node.getLogger(clazz);
Properties properties = memberAddressProviderConfig.getProperties();
MemberAddressProvider memberAddressProvider = newMemberAddressProviderInstance(clazz, memberAddressProviderLogger, properties);
return new DelegatingAddressPicker(memberAddressProvider, config, addressPickerLogger);
}
Aggregations