com.github.lontime.extredisson.provider.AbstractProvider Maven / Gradle / Ivy
The newest version!
package com.github.lontime.extredisson.provider;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import com.github.lontime.base.commonj.components.AbstractComponentLifecycle;
import com.github.lontime.base.commonj.components.ComponentShutdownPriority;
import com.github.lontime.base.commonj.utils.CommonManager;
import com.github.lontime.base.commonj.utils.StringHelper;
import com.github.lontime.base.logging.GLogger;
import com.github.lontime.extredisson.cache.R2LevelMapCache;
import com.github.lontime.extredisson.cache.Redisson2LevelMapCache;
import com.github.lontime.extredisson.common.CodecKind;
import com.github.lontime.extredisson.configuration.ConnectionOption;
import com.github.lontime.extredisson.configuration.OptionResolver;
import com.github.lontime.extredisson.container.ServiceContainer;
import com.github.lontime.shaded.org.redisson.Redisson;
import com.github.lontime.shaded.org.redisson.WriteBehindService;
import com.github.lontime.shaded.org.redisson.api.LocalCachedMapOptions;
import com.github.lontime.shaded.org.redisson.api.RedissonClient;
import com.github.lontime.shaded.org.redisson.api.RedissonReactiveClient;
import com.github.lontime.shaded.org.redisson.api.RedissonRxClient;
import com.github.lontime.shaded.org.redisson.client.codec.Codec;
import com.github.lontime.shaded.org.redisson.config.ClusterServersConfig;
import com.github.lontime.shaded.org.redisson.config.Config;
import com.github.lontime.shaded.org.redisson.config.MasterSlaveServersConfig;
import com.github.lontime.shaded.org.redisson.config.SentinelServersConfig;
import com.github.lontime.shaded.org.redisson.config.SingleServerConfig;
import com.github.lontime.shaded.org.redisson.connection.CRC16;
import static com.github.lontime.base.commonj.constants.Consts.DEFAULT_OBJECT_NAME;
/**
* AbstractProvider.
*
* @author lontime
* @since 1.0
*/
public abstract class AbstractProvider extends AbstractComponentLifecycle implements Provider {
protected final ServiceContainer container;
private final Map map = new ConcurrentHashMap<>();
private final Map mapRx = new ConcurrentHashMap<>();
private final Map mapReactive = new ConcurrentHashMap<>();
public AbstractProvider() {
this.container = new ServiceContainer();
}
@Override
public void initialize() {
OptionResolver.getInstance().getConnections().forEach(this::loadIfAbsent);
this.container.initialize();
}
@Override
public void afterRunning() {
this.container.start();
}
@Override
public void beforeStopping() {
this.container.stop();
}
@Override
public void destroy() {
this.container.destroy();
shutdownClient();
}
@Override
public int getShutdownPriority() {
return ComponentShutdownPriority.LIB_LOWEST.getValue();
}
@Override
public String resolve(String name) {
if (StringHelper.isBlank(name)) {
return DEFAULT_OBJECT_NAME;
}
final int atIndex = name.indexOf('@');
if (atIndex > -1) {
return name.substring(0, atIndex);
}
final int hashIndex = name.indexOf('#');
if (hashIndex > -1) {
return name.substring(0, hashIndex);
}
return name;
}
private RedissonClient load(ConnectionOption options) {
return Redisson.create(config(options));
}
@Override
public String resolveConnectionName(List names) {
lazyReentrantStart();
if (map.isEmpty()) {
throw new IllegalArgumentException("Cannot configure redisson connections!");
}
for (String name : names) {
if (StringHelper.isBlank(name) || DEFAULT_OBJECT_NAME.equals(name)) {
continue;
}
final String realName = calcConnectionName(name);
if (realName != null) {
if (map.containsKey(realName)) {
return realName;
}
throw new IllegalArgumentException("Cannot configure redis connection name (" + realName + ")");
}
}
if (map.containsKey(DEFAULT_OBJECT_NAME)) {
return DEFAULT_OBJECT_NAME;
}
throw new IllegalArgumentException("Cannot configure default redis connection name (" + DEFAULT_OBJECT_NAME + ")");
}
private String calcConnectionName(String name) {
final int atIndex = name.indexOf('@');
final int len = name.length();
if (atIndex > -1 && atIndex < len) {
return name.substring(atIndex + 1);
}
final int hashIndex = name.indexOf('#');
if (hashIndex > -1 && hashIndex < len) {
final List keys = new ArrayList<>(map.keySet());
if (!keys.isEmpty()) {
final int hash = CRC16.crc16(name.substring(hashIndex + 1).getBytes(StandardCharsets.UTF_8));
return keys.get(hash % (keys.size()));
}
}
return null;
}
@Override
public RedissonRxClient clientRx(List names) {
final String actualName = resolveConnectionName(names);
return mapRx.computeIfAbsent(actualName, k -> directClient(k).rxJava());
}
@Override
public RedissonReactiveClient clientReactive(List names) {
final String actualName = resolveConnectionName(names);
return mapReactive.computeIfAbsent(actualName, k -> directClient(k).reactive());
}
/**
* getClient.
* start with '@@' is fixed name
* @param names names
* @return Redisson client
*/
@Override
public RedissonClient client(List names) {
final String actualName = resolveConnectionName(names);
return directClient(actualName);
}
@Override
public RedissonClient directClient(String name) {
final RedissonClient client = map.get(name).getClient();
if (client.isShutdown() || client.isShuttingDown()) {
GLogger.defaults().warn(getClass(), "redisson is shutdowning, {0}-{1}", client.isShutdown(), client.isShuttingDown());
throw new IllegalMonitorStateException("Redisson is shutdowning");
}
return client;
}
@Override
public RedissonRxClient directClientRx(String name) {
final RedissonRxClient client = mapRx.get(name);
if (client.isShutdown() || client.isShuttingDown()) {
GLogger.defaults().warn(getClass(), "redisson[Rx] is shutdowning, {0}-{1}", client.isShutdown(), client.isShuttingDown());
throw new IllegalMonitorStateException("Redisson[Rx] is shutdowning");
}
return client;
}
@Override
public RedissonReactiveClient directClientReactive(String name) {
final RedissonReactiveClient client = mapReactive.get(name);
if (client.isShutdown() || client.isShuttingDown()) {
GLogger.defaults().warn(getClass(), "redisson[Reactive] is shutdowning, {0}-{1}", client.isShutdown(), client.isShuttingDown());
throw new IllegalMonitorStateException("Redisson[Reactive] is shutdowning");
}
return client;
}
@Override
public R2LevelMapCache l2Cache(String name, Codec codec, LocalCachedMapOptions options) {
return l2CacheInternal(name, codec, options);
}
private R2LevelMapCache l2CacheInternal(String name, Codec codec, LocalCachedMapOptions options) {
final Redisson redisson = (Redisson) client(name);
final String actualName = resolve(name);
final WriteBehindService writeBehindService = new WriteBehindService(redisson.getCommandExecutor());
if (codec == null) {
return new Redisson2LevelMapCache<>(redisson.getCommandExecutor(), actualName,
options, redisson.getEvictionScheduler(), redisson, writeBehindService);
}
return new Redisson2LevelMapCache<>(codec, redisson.getCommandExecutor(), actualName,
options, redisson.getEvictionScheduler(), redisson, writeBehindService);
}
protected void loadIfAbsent(ConnectionOption options) {
map.computeIfAbsent(options.getName(), name -> RedissonClientWrapper.from(load(options), options));
}
protected void shutdownClient() {
map.forEach((k, v) -> {
final RedissonClient client = v.getClient();
if (client.isShutdown() || client.isShuttingDown()) {
GLogger.defaults().warn(getClass(), "{0} isShutdown {1} or isShuttingDown {2}!",
k, client.isShutdown(), client.isShuttingDown());
return;
}
client.shutdown();
});
}
// protected String resolveName(String name) {
// final String actualName = StringHelper.hasText(name) ? name : Consts.DEFAULT_OBJECT_NAME;
// final int index = actualName.lastIndexOf(':');
// if (index > -1) {
// return actualName.substring(0, index);
// }
// return actualName;
// }
private Config config(ConnectionOption options) {
final Config config = new Config();
Optional.ofNullable(options.getCodec()).map(CodecKind::toCodec).ifPresent(config::setCodec);
Optional.ofNullable(options.getThreads()).ifPresent(config::setThreads);
Optional.ofNullable(options.getNettyThreads()).ifPresent(config::setNettyThreads);
Optional.ofNullable(options.getTransportMode()).ifPresent(config::setTransportMode);
Optional.ofNullable(options.getExecutor())
.map(s -> CommonManager.getInstance().getExecutorService(s))
.ifPresent(config::setExecutor);
Optional.ofNullable(options.getLockWatchdogTimeout()).ifPresent(config::setLockWatchdogTimeout);
Optional.ofNullable(options.getKeepPubSubOrder()).ifPresent(config::setKeepPubSubOrder);
if (options.getCluster() != null) {
final ConnectionOption.Cluster clusterOptions = options.getCluster();
final ClusterServersConfig clusterConfig = config.useClusterServers();
Optional.ofNullable(clusterOptions.getNodeAddresses()).ifPresent(clusterConfig::setNodeAddresses);
Optional.ofNullable(clusterOptions.getScanInterval()).ifPresent(clusterConfig::setScanInterval);
Optional.ofNullable(clusterOptions.getCheckSlotsCoverage()).ifPresent(clusterConfig::setCheckSlotsCoverage);
//------------
Optional.ofNullable(options.getClientName()).ifPresent(clusterConfig::setClientName);
Optional.ofNullable(options.getUsername()).ifPresent(clusterConfig::setUsername);
Optional.ofNullable(options.getPassword()).ifPresent(clusterConfig::setPassword);
//TIME
Optional.ofNullable(options.getPingConnectionInterval()).ifPresent(clusterConfig::setPingConnectionInterval);
Optional.ofNullable(options.getKeepAlive()).ifPresent(clusterConfig::setKeepAlive);
Optional.ofNullable(options.getTcpNoDelay()).ifPresent(clusterConfig::setTcpNoDelay);
Optional.ofNullable(options.getIdleConnectionTimeout()).ifPresent(clusterConfig::setIdleConnectionTimeout);
Optional.ofNullable(options.getConnectTimeout()).ifPresent(clusterConfig::setConnectTimeout);
Optional.ofNullable(options.getTimeout()).ifPresent(clusterConfig::setTimeout);
Optional.ofNullable(options.getRetryAttempts()).ifPresent(clusterConfig::setRetryAttempts);
Optional.ofNullable(options.getRetryInterval()).ifPresent(clusterConfig::setRetryInterval);
Optional.ofNullable(options.getDnsMonitoringInterval()).ifPresent(clusterConfig::setDnsMonitoringInterval);
//Subscription
Optional.ofNullable(options.getSubscriptionMode()).ifPresent(clusterConfig::setSubscriptionMode);
Optional.ofNullable(options.getSubscriptionsPerConnection()).ifPresent(clusterConfig::setSubscriptionsPerConnection);
Optional.ofNullable(options.getSubscriptionConnectionMinimumIdleSize()).ifPresent(clusterConfig::setSubscriptionConnectionMinimumIdleSize);
Optional.ofNullable(options.getSubscriptionConnectionPoolSize()).ifPresent(clusterConfig::setSubscriptionConnectionPoolSize);
//Multi
Optional.ofNullable(options.getLoadBalancer()).ifPresent(clusterConfig::setLoadBalancer);
Optional.ofNullable(options.getReadMode()).ifPresent
(clusterConfig::setReadMode);
Optional.ofNullable(options.getFailedSlaveReconnectionInterval()).ifPresent(clusterConfig::setFailedSlaveReconnectionInterval);
Optional.ofNullable(options.getFailedSlaveCheckInterval()).ifPresent(clusterConfig::setFailedSlaveCheckInterval);
Optional.ofNullable(options.getSlaveConnectionPoolSize()).ifPresent(clusterConfig::setSlaveConnectionPoolSize);
Optional.ofNullable(options.getSlaveConnectionMinimumIdleSize()).ifPresent(clusterConfig::setSlaveConnectionMinimumIdleSize);
Optional.ofNullable(options.getMasterConnectionMinimumIdleSize()).ifPresent(clusterConfig::setMasterConnectionMinimumIdleSize);
Optional.ofNullable(options.getMasterConnectionPoolSize()).ifPresent(clusterConfig::setMasterConnectionPoolSize);
//SSL
Optional.ofNullable(options.getSslEnableEndpointIdentification()).ifPresent(clusterConfig::setSslEnableEndpointIdentification);
Optional.ofNullable(options.getSslProtocols())
.map(p -> p.toArray(new String[0]))
.ifPresent(clusterConfig::setSslProtocols);
Optional.ofNullable(options.getSslProvider()).ifPresent(clusterConfig::setSslProvider);
Optional.ofNullable(options.getSslTruststore()).ifPresent(clusterConfig::setSslTruststore);
Optional.ofNullable(options.getSslTruststorePassword()).ifPresent(clusterConfig::setSslTruststorePassword);
Optional.ofNullable(options.getSslKeystore()).ifPresent(clusterConfig::setSslKeystore);
Optional.ofNullable(options.getSslKeystorePassword()).ifPresent(clusterConfig::setSslKeystorePassword);
} else if (options.getSentinel() != null) {
final ConnectionOption.Sentinel sentinelOptions = options.getSentinel();
final SentinelServersConfig sentinelConfig = config.useSentinelServers();
Optional.ofNullable(sentinelOptions.getMasterName()).ifPresent(sentinelConfig::setMasterName);
Optional.ofNullable(sentinelOptions.getSentinelAddress()).ifPresent(sentinelConfig::setSentinelAddresses);
Optional.ofNullable(sentinelOptions.getSentinelPassword()).ifPresent(sentinelConfig::setSentinelPassword);
Optional.ofNullable(sentinelOptions.getScanInterval()).ifPresent(sentinelConfig::setScanInterval);
Optional.ofNullable(sentinelOptions.getCheckSentinelsList()).ifPresent(sentinelConfig::setCheckSentinelsList);
Optional.ofNullable(sentinelOptions.getCheckSlaveStatusWithSyncing()).ifPresent(sentinelConfig::setCheckSlaveStatusWithSyncing);
Optional.ofNullable(sentinelOptions.getSentinelsDiscovery()).ifPresent(sentinelConfig::setSentinelsDiscovery);
//------------
Optional.ofNullable(options.getClientName()).ifPresent(sentinelConfig::setClientName);
Optional.ofNullable(options.getUsername()).ifPresent(sentinelConfig::setUsername);
Optional.ofNullable(options.getPassword()).ifPresent(sentinelConfig::setPassword);
Optional.ofNullable(options.getDatabase()).ifPresent(sentinelConfig::setDatabase);
//TIME
Optional.ofNullable(options.getPingConnectionInterval()).ifPresent(sentinelConfig::setPingConnectionInterval);
Optional.ofNullable(options.getKeepAlive()).ifPresent(sentinelConfig::setKeepAlive);
Optional.ofNullable(options.getTcpNoDelay()).ifPresent(sentinelConfig::setTcpNoDelay);
Optional.ofNullable(options.getIdleConnectionTimeout()).ifPresent(sentinelConfig::setIdleConnectionTimeout);
Optional.ofNullable(options.getConnectTimeout()).ifPresent(sentinelConfig::setConnectTimeout);
Optional.ofNullable(options.getTimeout()).ifPresent(sentinelConfig::setTimeout);
Optional.ofNullable(options.getRetryAttempts()).ifPresent(sentinelConfig::setRetryAttempts);
Optional.ofNullable(options.getRetryInterval()).ifPresent(sentinelConfig::setRetryInterval);
Optional.ofNullable(options.getDnsMonitoringInterval()).ifPresent(sentinelConfig::setDnsMonitoringInterval);
//Subscription
Optional.ofNullable(options.getSubscriptionMode()).ifPresent(sentinelConfig::setSubscriptionMode);
Optional.ofNullable(options.getSubscriptionsPerConnection()).ifPresent(sentinelConfig::setSubscriptionsPerConnection);
Optional.ofNullable(options.getSubscriptionConnectionMinimumIdleSize()).ifPresent(sentinelConfig::setSubscriptionConnectionMinimumIdleSize);
Optional.ofNullable(options.getSubscriptionConnectionPoolSize()).ifPresent(sentinelConfig::setSubscriptionConnectionPoolSize);
//Multi
Optional.ofNullable(options.getLoadBalancer()).ifPresent(sentinelConfig::setLoadBalancer);
Optional.ofNullable(options.getReadMode()).ifPresent
(sentinelConfig::setReadMode);
Optional.ofNullable(options.getFailedSlaveReconnectionInterval()).ifPresent(sentinelConfig::setFailedSlaveReconnectionInterval);
Optional.ofNullable(options.getFailedSlaveCheckInterval()).ifPresent(sentinelConfig::setFailedSlaveCheckInterval);
Optional.ofNullable(options.getSlaveConnectionPoolSize()).ifPresent(sentinelConfig::setSlaveConnectionPoolSize);
Optional.ofNullable(options.getSlaveConnectionMinimumIdleSize()).ifPresent(sentinelConfig::setSlaveConnectionMinimumIdleSize);
Optional.ofNullable(options.getMasterConnectionMinimumIdleSize()).ifPresent(sentinelConfig::setMasterConnectionMinimumIdleSize);
Optional.ofNullable(options.getMasterConnectionPoolSize()).ifPresent(sentinelConfig::setMasterConnectionPoolSize);
//SSL
Optional.ofNullable(options.getSslEnableEndpointIdentification()).ifPresent(sentinelConfig::setSslEnableEndpointIdentification);
Optional.ofNullable(options.getSslProtocols())
.map(p -> p.toArray(new String[0]))
.ifPresent(sentinelConfig::setSslProtocols);
Optional.ofNullable(options.getSslProvider()).ifPresent(sentinelConfig::setSslProvider);
Optional.ofNullable(options.getSslTruststore()).ifPresent(sentinelConfig::setSslTruststore);
Optional.ofNullable(options.getSslTruststorePassword()).ifPresent(sentinelConfig::setSslTruststorePassword);
Optional.ofNullable(options.getSslKeystore()).ifPresent(sentinelConfig::setSslKeystore);
Optional.ofNullable(options.getSslKeystorePassword()).ifPresent(sentinelConfig::setSslKeystorePassword);
} else if (options.getMasterSlave() != null) {
final ConnectionOption.MasterSlave masterSlaveOptions = options.getMasterSlave();
final MasterSlaveServersConfig masterSlaveConfig = config.useMasterSlaveServers();
Optional.ofNullable(masterSlaveOptions.getMasterAddress()).ifPresent(masterSlaveConfig::setMasterAddress);
Optional.ofNullable(masterSlaveOptions.getSlaveAddress()).ifPresent(masterSlaveConfig::setSlaveAddresses);
//------------
Optional.ofNullable(options.getClientName()).ifPresent(masterSlaveConfig::setClientName);
Optional.ofNullable(options.getUsername()).ifPresent(masterSlaveConfig::setUsername);
Optional.ofNullable(options.getPassword()).ifPresent(masterSlaveConfig::setPassword);
Optional.ofNullable(options.getDatabase()).ifPresent(masterSlaveConfig::setDatabase);
//TIME
Optional.ofNullable(options.getPingConnectionInterval()).ifPresent(masterSlaveConfig::setPingConnectionInterval);
Optional.ofNullable(options.getKeepAlive()).ifPresent(masterSlaveConfig::setKeepAlive);
Optional.ofNullable(options.getTcpNoDelay()).ifPresent(masterSlaveConfig::setTcpNoDelay);
Optional.ofNullable(options.getIdleConnectionTimeout()).ifPresent(masterSlaveConfig::setIdleConnectionTimeout);
Optional.ofNullable(options.getConnectTimeout()).ifPresent(masterSlaveConfig::setConnectTimeout);
Optional.ofNullable(options.getTimeout()).ifPresent(masterSlaveConfig::setTimeout);
Optional.ofNullable(options.getRetryAttempts()).ifPresent(masterSlaveConfig::setRetryAttempts);
Optional.ofNullable(options.getRetryInterval()).ifPresent(masterSlaveConfig::setRetryInterval);
Optional.ofNullable(options.getDnsMonitoringInterval()).ifPresent(masterSlaveConfig::setDnsMonitoringInterval);
//Subscription
Optional.ofNullable(options.getSubscriptionMode()).ifPresent(masterSlaveConfig::setSubscriptionMode);
Optional.ofNullable(options.getSubscriptionsPerConnection()).ifPresent(masterSlaveConfig::setSubscriptionsPerConnection);
Optional.ofNullable(options.getSubscriptionConnectionMinimumIdleSize()).ifPresent(masterSlaveConfig::setSubscriptionConnectionMinimumIdleSize);
Optional.ofNullable(options.getSubscriptionConnectionPoolSize()).ifPresent(masterSlaveConfig::setSubscriptionConnectionPoolSize);
//Multi
Optional.ofNullable(options.getLoadBalancer()).ifPresent(masterSlaveConfig::setLoadBalancer);
Optional.ofNullable(options.getReadMode()).ifPresent
(masterSlaveConfig::setReadMode);
Optional.ofNullable(options.getFailedSlaveReconnectionInterval()).ifPresent(masterSlaveConfig::setFailedSlaveReconnectionInterval);
Optional.ofNullable(options.getFailedSlaveCheckInterval()).ifPresent(masterSlaveConfig::setFailedSlaveCheckInterval);
Optional.ofNullable(options.getSlaveConnectionPoolSize()).ifPresent(masterSlaveConfig::setSlaveConnectionPoolSize);
Optional.ofNullable(options.getSlaveConnectionMinimumIdleSize()).ifPresent(masterSlaveConfig::setSlaveConnectionMinimumIdleSize);
Optional.ofNullable(options.getMasterConnectionMinimumIdleSize()).ifPresent(masterSlaveConfig::setMasterConnectionMinimumIdleSize);
Optional.ofNullable(options.getMasterConnectionPoolSize()).ifPresent(masterSlaveConfig::setMasterConnectionPoolSize);
//SSL
Optional.ofNullable(options.getSslEnableEndpointIdentification()).ifPresent(masterSlaveConfig::setSslEnableEndpointIdentification);
Optional.ofNullable(options.getSslProtocols())
.map(p -> p.toArray(new String[0]))
.ifPresent(masterSlaveConfig::setSslProtocols);
Optional.ofNullable(options.getSslProvider()).ifPresent(masterSlaveConfig::setSslProvider);
Optional.ofNullable(options.getSslTruststore()).ifPresent(masterSlaveConfig::setSslTruststore);
Optional.ofNullable(options.getSslTruststorePassword()).ifPresent(masterSlaveConfig::setSslTruststorePassword);
Optional.ofNullable(options.getSslKeystore()).ifPresent(masterSlaveConfig::setSslKeystore);
Optional.ofNullable(options.getSslKeystorePassword()).ifPresent(masterSlaveConfig::setSslKeystorePassword);
} else if (options.getAddress() != null) {
// final ConnectionOption.Single singleOptions = options.getSingle();
final SingleServerConfig singleConfig = config.useSingleServer();
Optional.ofNullable(options.getAddress()).ifPresent(singleConfig::setAddress);
Optional.ofNullable(options.getConnectionPoolSize()).ifPresent(singleConfig::setConnectionPoolSize);
Optional.ofNullable(options.getConnectionMinimumIdleSize()).ifPresent(singleConfig::setConnectionMinimumIdleSize);
//------------
Optional.ofNullable(options.getClientName()).ifPresent(singleConfig::setClientName);
Optional.ofNullable(options.getUsername()).ifPresent(singleConfig::setUsername);
Optional.ofNullable(options.getPassword()).ifPresent(singleConfig::setPassword);
Optional.ofNullable(options.getDatabase()).ifPresent(singleConfig::setDatabase);
//TIME
Optional.ofNullable(options.getPingConnectionInterval()).ifPresent(singleConfig::setPingConnectionInterval);
Optional.ofNullable(options.getKeepAlive()).ifPresent(singleConfig::setKeepAlive);
Optional.ofNullable(options.getTcpNoDelay()).ifPresent(singleConfig::setTcpNoDelay);
Optional.ofNullable(options.getIdleConnectionTimeout()).ifPresent(singleConfig::setIdleConnectionTimeout);
Optional.ofNullable(options.getConnectTimeout()).ifPresent(singleConfig::setConnectTimeout);
Optional.ofNullable(options.getTimeout()).ifPresent(singleConfig::setTimeout);
Optional.ofNullable(options.getRetryAttempts()).ifPresent(singleConfig::setRetryAttempts);
Optional.ofNullable(options.getRetryInterval()).ifPresent(singleConfig::setRetryInterval);
Optional.ofNullable(options.getDnsMonitoringInterval()).ifPresent(singleConfig::setDnsMonitoringInterval);
//Subscription
Optional.ofNullable(options.getSubscriptionsPerConnection()).ifPresent(singleConfig::setSubscriptionsPerConnection);
Optional.ofNullable(options.getSubscriptionConnectionMinimumIdleSize()).ifPresent(singleConfig::setSubscriptionConnectionMinimumIdleSize);
Optional.ofNullable(options.getSubscriptionConnectionPoolSize()).ifPresent(singleConfig::setSubscriptionConnectionPoolSize);
//SSL
Optional.ofNullable(options.getSslEnableEndpointIdentification()).ifPresent(singleConfig::setSslEnableEndpointIdentification);
Optional.ofNullable(options.getSslProtocols())
.map(p -> p.toArray(new String[0]))
.ifPresent(singleConfig::setSslProtocols);
Optional.ofNullable(options.getSslProvider()).ifPresent(singleConfig::setSslProvider);
Optional.ofNullable(options.getSslTruststore()).ifPresent(singleConfig::setSslTruststore);
Optional.ofNullable(options.getSslTruststorePassword()).ifPresent(singleConfig::setSslTruststorePassword);
Optional.ofNullable(options.getSslKeystore()).ifPresent(singleConfig::setSslKeystore);
Optional.ofNullable(options.getSslKeystorePassword()).ifPresent(singleConfig::setSslKeystorePassword);
}
return config;
}
}