org.redisson.config.MasterSlaveServersConfig Java Examples
The following examples show how to use
org.redisson.config.MasterSlaveServersConfig.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MasterSlaveConnectionManager.java From redisson with Apache License 2.0 | 6 votes |
protected void initTimer(MasterSlaveServersConfig config) { int[] timeouts = new int[]{config.getRetryInterval(), config.getTimeout()}; Arrays.sort(timeouts); int minTimeout = timeouts[0]; if (minTimeout % 100 != 0) { minTimeout = (minTimeout % 100) / 2; } else if (minTimeout == 100) { minTimeout = 50; } else { minTimeout = 100; } timer = new HashedWheelTimer(new DefaultThreadFactory("redisson-timer"), minTimeout, TimeUnit.MILLISECONDS, 1024, false); connectionWatcher = new IdleConnectionWatcher(this, config); subscribeService = new PublishSubscribeService(this, config); }
Example #2
Source File: RedisConfig.java From earth-frost with Apache License 2.0 | 6 votes |
/** * 主从模式 * * @param redissonProperties redisson配置 * @return client */ static RedissonClient redissonUseMasterSlaveServers(RedissonProperties redissonProperties) { Config config = new Config(); MasterSlaveServersConfig serverConfig = config.useMasterSlaveServers() .setMasterAddress(redissonProperties.getMasterAddress()) .addSlaveAddress(redissonProperties.getSlaveAddresses()) .setTimeout(redissonProperties.getTimeout()) .setDnsMonitoringInterval(redissonProperties.getDnsMonitoringInterval()) .setSlaveConnectionPoolSize(redissonProperties.getSlaveConnectionPoolSize()) .setMasterConnectionPoolSize(redissonProperties.getMasterConnectionPoolSize()); if (redissonProperties.getPassword() != null && redissonProperties.getPassword().length() > 0) { serverConfig.setPassword(redissonProperties.getPassword()); } return Redisson.create(config); }
Example #3
Source File: SingleConnectionManager.java From redisson with Apache License 2.0 | 5 votes |
private static MasterSlaveServersConfig create(SingleServerConfig cfg) { MasterSlaveServersConfig newconfig = new MasterSlaveServersConfig(); newconfig.setPingConnectionInterval(cfg.getPingConnectionInterval()); newconfig.setSslEnableEndpointIdentification(cfg.isSslEnableEndpointIdentification()); newconfig.setSslProvider(cfg.getSslProvider()); newconfig.setSslTruststore(cfg.getSslTruststore()); newconfig.setSslTruststorePassword(cfg.getSslTruststorePassword()); newconfig.setSslKeystore(cfg.getSslKeystore()); newconfig.setSslKeystorePassword(cfg.getSslKeystorePassword()); newconfig.setRetryAttempts(cfg.getRetryAttempts()); newconfig.setRetryInterval(cfg.getRetryInterval()); newconfig.setTimeout(cfg.getTimeout()); newconfig.setPassword(cfg.getPassword()); newconfig.setUsername(cfg.getUsername()); newconfig.setDatabase(cfg.getDatabase()); newconfig.setClientName(cfg.getClientName()); newconfig.setMasterAddress(cfg.getAddress()); newconfig.setMasterConnectionPoolSize(cfg.getConnectionPoolSize()); newconfig.setSubscriptionsPerConnection(cfg.getSubscriptionsPerConnection()); newconfig.setSubscriptionConnectionPoolSize(cfg.getSubscriptionConnectionPoolSize()); newconfig.setConnectTimeout(cfg.getConnectTimeout()); newconfig.setIdleConnectionTimeout(cfg.getIdleConnectionTimeout()); newconfig.setDnsMonitoringInterval(cfg.getDnsMonitoringInterval()); newconfig.setMasterConnectionMinimumIdleSize(cfg.getConnectionMinimumIdleSize()); newconfig.setSubscriptionConnectionMinimumIdleSize(cfg.getSubscriptionConnectionMinimumIdleSize()); newconfig.setReadMode(ReadMode.MASTER); newconfig.setSubscriptionMode(SubscriptionMode.MASTER); newconfig.setKeepAlive(cfg.isKeepAlive()); return newconfig; }
Example #4
Source File: RedissonTopic.java From redisson with Apache License 2.0 | 5 votes |
protected void acquire(AsyncSemaphore semaphore) { MasterSlaveServersConfig config = commandExecutor.getConnectionManager().getConfig(); int timeout = config.getTimeout() + config.getRetryInterval() * config.getRetryAttempts(); if (!semaphore.tryAcquire(timeout)) { throw new RedisTimeoutException("Remove listeners operation timeout: (" + timeout + "ms) for " + name + " topic"); } }
Example #5
Source File: CommandAsyncService.java From redisson with Apache License 2.0 | 5 votes |
@Override public void syncSubscriptionInterrupted(RFuture<?> future) throws InterruptedException { MasterSlaveServersConfig config = connectionManager.getConfig(); int timeout = config.getTimeout() + config.getRetryInterval() * config.getRetryAttempts(); if (!future.await(timeout)) { ((RPromise<?>) future).tryFailure(new RedisTimeoutException("Subscribe timeout: (" + timeout + "ms). Increase 'subscriptionsPerConnection' and/or 'subscriptionConnectionPoolSize' parameters.")); } future.sync(); }
Example #6
Source File: CommandAsyncService.java From redisson with Apache License 2.0 | 5 votes |
@Override public void syncSubscription(RFuture<?> future) { MasterSlaveServersConfig config = connectionManager.getConfig(); try { int timeout = config.getTimeout() + config.getRetryInterval() * config.getRetryAttempts(); if (!future.await(timeout)) { ((RPromise<?>) future).tryFailure(new RedisTimeoutException("Subscribe timeout: (" + timeout + "ms). Increase 'subscriptionsPerConnection' and/or 'subscriptionConnectionPoolSize' parameters.")); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } future.syncUninterruptibly(); }
Example #7
Source File: MasterSlaveConnectionManager.java From redisson with Apache License 2.0 | 5 votes |
protected MasterSlaveServersConfig create(BaseMasterSlaveServersConfig<?> cfg) { MasterSlaveServersConfig c = new MasterSlaveServersConfig(); c.setPingConnectionInterval(cfg.getPingConnectionInterval()); c.setSslEnableEndpointIdentification(cfg.isSslEnableEndpointIdentification()); c.setSslProvider(cfg.getSslProvider()); c.setSslTruststore(cfg.getSslTruststore()); c.setSslTruststorePassword(cfg.getSslTruststorePassword()); c.setSslKeystore(cfg.getSslKeystore()); c.setSslKeystorePassword(cfg.getSslKeystorePassword()); c.setRetryInterval(cfg.getRetryInterval()); c.setRetryAttempts(cfg.getRetryAttempts()); c.setTimeout(cfg.getTimeout()); c.setLoadBalancer(cfg.getLoadBalancer()); c.setPassword(cfg.getPassword()); c.setUsername(cfg.getUsername()); c.setClientName(cfg.getClientName()); c.setMasterConnectionPoolSize(cfg.getMasterConnectionPoolSize()); c.setSlaveConnectionPoolSize(cfg.getSlaveConnectionPoolSize()); c.setSubscriptionConnectionPoolSize(cfg.getSubscriptionConnectionPoolSize()); c.setSubscriptionsPerConnection(cfg.getSubscriptionsPerConnection()); c.setConnectTimeout(cfg.getConnectTimeout()); c.setIdleConnectionTimeout(cfg.getIdleConnectionTimeout()); c.setFailedSlaveCheckInterval(cfg.getFailedSlaveCheckInterval()); c.setFailedSlaveReconnectionInterval(cfg.getFailedSlaveReconnectionInterval()); c.setMasterConnectionMinimumIdleSize(cfg.getMasterConnectionMinimumIdleSize()); c.setSlaveConnectionMinimumIdleSize(cfg.getSlaveConnectionMinimumIdleSize()); c.setSubscriptionConnectionMinimumIdleSize(cfg.getSubscriptionConnectionMinimumIdleSize()); c.setReadMode(cfg.getReadMode()); c.setSubscriptionMode(cfg.getSubscriptionMode()); c.setDnsMonitoringInterval(cfg.getDnsMonitoringInterval()); c.setKeepAlive(cfg.isKeepAlive()); return c; }
Example #8
Source File: MasterSlaveConnectionManager.java From redisson with Apache License 2.0 | 5 votes |
protected MasterSlaveEntry createMasterSlaveEntry(MasterSlaveServersConfig config) { MasterSlaveEntry entry = new MasterSlaveEntry(this, config); List<RFuture<Void>> fs = entry.initSlaveBalancer(java.util.Collections.<RedisURI>emptySet()); for (RFuture<Void> future : fs) { future.syncUninterruptibly(); } return entry; }
Example #9
Source File: MasterSlaveConnectionManager.java From redisson with Apache License 2.0 | 5 votes |
public MasterSlaveConnectionManager(MasterSlaveServersConfig cfg, Config config, UUID id) { this(config, id); this.config = cfg; initTimer(cfg); initSingleEntry(); }
Example #10
Source File: MasterSlaveEntry.java From redisson with Apache License 2.0 | 5 votes |
public MasterSlaveEntry(ConnectionManager connectionManager, MasterSlaveServersConfig config) { this.connectionManager = connectionManager; this.config = config; slaveBalancer = new LoadBalancerManager(config, connectionManager, this); writeConnectionPool = new MasterConnectionPool(config, connectionManager, this); pubSubConnectionPool = new MasterPubSubConnectionPool(config, connectionManager, this); if (connectionManager instanceof ClusterConnectionManager) { sslHostname = ((ClusterConnectionManager) connectionManager).getConfigEndpointHostName(); } }
Example #11
Source File: PublishSubscribeService.java From redisson with Apache License 2.0 | 5 votes |
public PublishSubscribeService(ConnectionManager connectionManager, MasterSlaveServersConfig config) { super(); this.connectionManager = connectionManager; this.config = config; for (int i = 0; i < locks.length; i++) { locks[i] = new AsyncSemaphore(1); } }
Example #12
Source File: RedissonPatternTopic.java From redisson with Apache License 2.0 | 5 votes |
protected void acquire(AsyncSemaphore semaphore) { MasterSlaveServersConfig config = commandExecutor.getConnectionManager().getConfig(); int timeout = config.getTimeout() + config.getRetryInterval() * config.getRetryAttempts(); if (!semaphore.tryAcquire(timeout)) { throw new RedisTimeoutException("Remove listeners operation timeout: (" + timeout + "ms) for " + name + " topic"); } }
Example #13
Source File: LoadBalancerManager.java From redisson with Apache License 2.0 | 4 votes |
public LoadBalancerManager(MasterSlaveServersConfig config, ConnectionManager connectionManager, MasterSlaveEntry entry) { this.connectionManager = connectionManager; slaveConnectionPool = new SlaveConnectionPool(config, connectionManager, entry); pubSubConnectionPool = new PubSubConnectionPool(config, connectionManager, entry); }
Example #14
Source File: MasterSlaveEntry.java From redisson with Apache License 2.0 | 4 votes |
public MasterSlaveServersConfig getConfig() { return config; }
Example #15
Source File: SlaveConnectionPool.java From redisson with Apache License 2.0 | 4 votes |
public SlaveConnectionPool(MasterSlaveServersConfig config, ConnectionManager connectionManager, MasterSlaveEntry masterSlaveEntry) { super(config, connectionManager, masterSlaveEntry); }
Example #16
Source File: SingleEntry.java From redisson with Apache License 2.0 | 4 votes |
public SingleEntry(ConnectionManager connectionManager, MasterSlaveServersConfig config) { super(connectionManager, config); }
Example #17
Source File: ReplicatedConnectionManager.java From redisson with Apache License 2.0 | 4 votes |
@Override protected MasterSlaveServersConfig create(BaseMasterSlaveServersConfig<?> cfg) { MasterSlaveServersConfig res = super.create(cfg); res.setDatabase(((ReplicatedServersConfig) cfg).getDatabase()); return res; }
Example #18
Source File: PubSubConnectionPool.java From redisson with Apache License 2.0 | 4 votes |
public PubSubConnectionPool(MasterSlaveServersConfig config, ConnectionManager connectionManager, MasterSlaveEntry masterSlaveEntry) { super(config, connectionManager, masterSlaveEntry); }
Example #19
Source File: MasterSlaveConnectionManager.java From redisson with Apache License 2.0 | 4 votes |
@Override public MasterSlaveServersConfig getConfig() { return config; }
Example #20
Source File: MasterPubSubConnectionPool.java From redisson with Apache License 2.0 | 4 votes |
public MasterPubSubConnectionPool(MasterSlaveServersConfig config, ConnectionManager connectionManager, MasterSlaveEntry masterSlaveEntry) { super(config, connectionManager, masterSlaveEntry); }
Example #21
Source File: MasterConnectionPool.java From redisson with Apache License 2.0 | 4 votes |
public MasterConnectionPool(MasterSlaveServersConfig config, ConnectionManager connectionManager, MasterSlaveEntry masterSlaveEntry) { super(config, connectionManager, masterSlaveEntry); }
Example #22
Source File: ConnectionPool.java From redisson with Apache License 2.0 | 4 votes |
ConnectionPool(MasterSlaveServersConfig config, ConnectionManager connectionManager, MasterSlaveEntry masterSlaveEntry) { this.config = config; this.masterSlaveEntry = masterSlaveEntry; this.connectionManager = connectionManager; }
Example #23
Source File: SeimiConfig.java From SeimiCrawler with Apache License 2.0 | 2 votes |
/** * Init master/slave servers configuration. * * config.useMasterSlaveServers() * //可以用"rediss://"来启用SSL连接 * .setMasterAddress("redis://127.0.0.1:6379") * .addSlaveAddress("redis://127.0.0.1:6389", "redis://127.0.0.1:6332", "redis://127.0.0.1:6419") * .addSlaveAddress("redis://127.0.0.1:6399"); * * @return MasterSlaveServersConfig */ public MasterSlaveServersConfig redisMasterSlaveServers() { enableDistributedQueue(); return redissonConfig.useMasterSlaveServers(); }
Example #24
Source File: ConnectionManager.java From redisson with Apache License 2.0 | votes |
MasterSlaveServersConfig getConfig();