org.redisson.connection.ConnectionManager Java Examples

The following examples show how to use org.redisson.connection.ConnectionManager. 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: ConfigSupport.java    From redisson with Apache License 2.0 6 votes vote down vote up
public static ConnectionManager createConnectionManager(Config configCopy) {
    UUID id = UUID.randomUUID();
    
    if (configCopy.getMasterSlaveServersConfig() != null) {
        validate(configCopy.getMasterSlaveServersConfig());
        return new MasterSlaveConnectionManager(configCopy.getMasterSlaveServersConfig(), configCopy, id);
    } else if (configCopy.getSingleServerConfig() != null) {
        validate(configCopy.getSingleServerConfig());
        return new SingleConnectionManager(configCopy.getSingleServerConfig(), configCopy, id);
    } else if (configCopy.getSentinelServersConfig() != null) {
        validate(configCopy.getSentinelServersConfig());
        return new SentinelConnectionManager(configCopy.getSentinelServersConfig(), configCopy, id);
    } else if (configCopy.getClusterServersConfig() != null) {
        validate(configCopy.getClusterServersConfig());
        return new ClusterConnectionManager(configCopy.getClusterServersConfig(), configCopy, id);
    } else if (configCopy.getReplicatedServersConfig() != null) {
        validate(configCopy.getReplicatedServersConfig());
        return new ReplicatedConnectionManager(configCopy.getReplicatedServersConfig(), configCopy, id);
    } else if (configCopy.getConnectionManager() != null) {
        return configCopy.getConnectionManager();
    }else {
        throw new IllegalArgumentException("server(s) address(es) not defined!");
    }
}
 
Example #2
Source File: RedisExecutor.java    From redisson with Apache License 2.0 6 votes vote down vote up
public RedisExecutor(boolean readOnlyMode, NodeSource source, Codec codec, RedisCommand<V> command,
        Object[] params, RPromise<R> mainPromise, boolean ignoreRedirect, 
        ConnectionManager connectionManager, RedissonObjectBuilder objectBuilder) {
    super();
    this.readOnlyMode = readOnlyMode;
    this.source = source;
    this.codec = codec;
    this.command = command;
    this.params = params;
    this.mainPromise = mainPromise;
    this.ignoreRedirect = ignoreRedirect;
    this.connectionManager = connectionManager;
    this.objectBuilder = objectBuilder;
    
    this.attempts = connectionManager.getConfig().getRetryAttempts();
    this.retryInterval = connectionManager.getConfig().getRetryInterval();
    this.responseTimeout = connectionManager.getConfig().getTimeout();
}
 
Example #3
Source File: RedisCommonBatchExecutor.java    From redisson with Apache License 2.0 6 votes vote down vote up
public RedisCommonBatchExecutor(NodeSource source, RPromise<Void> mainPromise, 
        ConnectionManager connectionManager, BatchOptions options, Entry entry, AtomicInteger slots) {
    super(entry.isReadOnlyMode(), source, null, null, null, mainPromise, true, connectionManager, null);
    this.options = options;
    this.entry = entry;
    this.slots = slots;
    
    if (options.getRetryAttempts() > 0) {
        this.attempts = options.getRetryAttempts();
    }
    if (options.getRetryInterval() > 0) {
        this.retryInterval  = options.getRetryInterval();
    }
    if (options.getResponseTimeout() > 0) {
        this.responseTimeout = options.getResponseTimeout();
    }
    
}
 
Example #4
Source File: BaseRegion.java    From redisson with Apache License 2.0 6 votes vote down vote up
public BaseRegion(RMapCache<Object, Object> mapCache, ConnectionManager connectionManager, RegionFactory regionFactory, CacheDataDescription metadata, Properties properties, String defaultKey) {
    super();
    this.mapCache = mapCache;
    this.regionFactory = regionFactory;
    this.metadata = metadata;
    this.connectionManager = connectionManager;
    
    String maxEntries = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.MAX_ENTRIES_SUFFIX);
    if (maxEntries != null) {
        mapCache.setMaxSize(Integer.valueOf(maxEntries));
    }
    String timeToLive = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.TTL_SUFFIX);
    if (timeToLive != null) {
        ttl = Integer.valueOf(timeToLive);
    }
    String maxIdleTime = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.MAX_IDLE_SUFFIX);
    if (maxIdleTime != null) {
        maxIdle = Integer.valueOf(maxIdleTime);
    }

    String fallbackValue = (String) properties.getOrDefault(RedissonRegionFactory.FALLBACK, "false");
    fallback = Boolean.valueOf(fallbackValue);
}
 
Example #5
Source File: BaseRegion.java    From redisson with Apache License 2.0 6 votes vote down vote up
public BaseRegion(RMapCache<Object, Object> mapCache, ConnectionManager connectionManager, RegionFactory regionFactory, CacheDataDescription metadata, Properties properties, String defaultKey) {
    super();
    this.mapCache = mapCache;
    this.regionFactory = regionFactory;
    this.metadata = metadata;
    this.connectionManager = connectionManager;
    
    String maxEntries = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.MAX_ENTRIES_SUFFIX);
    if (maxEntries != null) {
        mapCache.setMaxSize(Integer.valueOf(maxEntries));
    }
    String timeToLive = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.TTL_SUFFIX);
    if (timeToLive != null) {
        ttl = Integer.valueOf(timeToLive);
    }
    String maxIdleTime = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.MAX_IDLE_SUFFIX);
    if (maxIdleTime != null) {
        maxIdle = Integer.valueOf(maxIdleTime);
    }

    String fallbackValue = (String) properties.getOrDefault(RedissonRegionFactory.FALLBACK, "false");
    fallback = Boolean.valueOf(fallbackValue);
}
 
Example #6
Source File: RedissonStorage.java    From redisson with Apache License 2.0 6 votes vote down vote up
public RedissonStorage(RMapCache<Object, Object> mapCache, ConnectionManager connectionManager, Map<String, Object> properties, String defaultKey) {
    super();
    this.mapCache = mapCache;
    this.connectionManager = connectionManager;
    
    String maxEntries = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.MAX_ENTRIES_SUFFIX);
    if (maxEntries != null) {
        mapCache.setMaxSize(Integer.valueOf(maxEntries));
    }
    String timeToLive = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.TTL_SUFFIX);
    if (timeToLive != null) {
        ttl = Integer.valueOf(timeToLive);
    }
    String maxIdleTime = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.MAX_IDLE_SUFFIX);
    if (maxIdleTime != null) {
        maxIdle = Integer.valueOf(maxIdleTime);
    }

    String fallbackValue = (String) properties.getOrDefault(RedissonRegionFactory.FALLBACK, "false");
    fallback = Boolean.valueOf(fallbackValue);
}
 
Example #7
Source File: LiveObjectInterceptor.java    From redisson with Apache License 2.0 6 votes vote down vote up
public LiveObjectInterceptor(CommandAsyncExecutor commandExecutor, ConnectionManager connectionManager,
                             RedissonLiveObjectService service, Class<?> entityClass, String idFieldName) {
    this.service = service;
    this.commandExecutor = commandExecutor;
    this.connectionManager = connectionManager;
    this.originalClass = entityClass;
    this.idFieldName = idFieldName;

    namingScheme = connectionManager.getCommandExecutor().getObjectBuilder().getNamingScheme(entityClass);

    try {
        this.idFieldType = ClassUtils.getDeclaredField(originalClass, idFieldName).getType();
    } catch (Exception e) {
        throw new IllegalArgumentException(e);
    }
}
 
Example #8
Source File: BaseRegion.java    From redisson with Apache License 2.0 6 votes vote down vote up
public BaseRegion(RMapCache<Object, Object> mapCache, ConnectionManager connectionManager, RegionFactory regionFactory, CacheDataDescription metadata, Properties properties, String defaultKey) {
    super();
    this.mapCache = mapCache;
    this.regionFactory = regionFactory;
    this.metadata = metadata;
    this.connectionManager = connectionManager;
    
    String maxEntries = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.MAX_ENTRIES_SUFFIX);
    if (maxEntries != null) {
        mapCache.setMaxSize(Integer.valueOf(maxEntries));
    }
    String timeToLive = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.TTL_SUFFIX);
    if (timeToLive != null) {
        ttl = Integer.valueOf(timeToLive);
    }
    String maxIdleTime = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.MAX_IDLE_SUFFIX);
    if (maxIdleTime != null) {
        maxIdle = Integer.valueOf(maxIdleTime);
    }

    String fallbackValue = (String) properties.getOrDefault(RedissonRegionFactory.FALLBACK, "false");
    fallback = Boolean.valueOf(fallbackValue);
}
 
Example #9
Source File: RedisBatchExecutor.java    From redisson with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("ParameterNumber")
public RedisBatchExecutor(boolean readOnlyMode, NodeSource source, Codec codec, RedisCommand<V> command,
        Object[] params, RPromise<R> mainPromise, boolean ignoreRedirect, ConnectionManager connectionManager,
        RedissonObjectBuilder objectBuilder, ConcurrentMap<MasterSlaveEntry, Entry> commands,
        BatchOptions options, AtomicInteger index,
        AtomicBoolean executed) {
    super(readOnlyMode, source, codec, command, params, mainPromise, ignoreRedirect, connectionManager, objectBuilder,
            commands, options, index, executed);
}
 
Example #10
Source File: RedissonSubSortedSet.java    From redisson with Apache License 2.0 5 votes vote down vote up
RedissonSubSortedSet(RedissonSortedSet<V> redissonSortedSet, ConnectionManager connectionManager, V headValue, V tailValue) {
    super();
    this.headValue = headValue;
    this.tailValue = tailValue;

    this.connectionManager = connectionManager;
    this.redissonSortedSet = redissonSortedSet;
}
 
Example #11
Source File: RedisQueuedBatchExecutor.java    From redisson with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("ParameterNumber")
public RedisQueuedBatchExecutor(boolean readOnlyMode, NodeSource source, Codec codec, RedisCommand<V> command,
        Object[] params, RPromise<R> mainPromise, boolean ignoreRedirect, ConnectionManager connectionManager,
        RedissonObjectBuilder objectBuilder, ConcurrentMap<MasterSlaveEntry, Entry> commands,
        ConcurrentMap<MasterSlaveEntry, ConnectionEntry> connections, BatchOptions options, AtomicInteger index,
        AtomicBoolean executed, AsyncSemaphore semaphore) {
    super(readOnlyMode, source, codec, command, params, mainPromise, ignoreRedirect, connectionManager, objectBuilder,
            commands, options, index, executed);
    
    this.connections = connections;
    this.semaphore = semaphore;
}
 
Example #12
Source File: PublishSubscribeService.java    From redisson with Apache License 2.0 5 votes vote down vote up
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 #13
Source File: BaseRedisBatchExecutor.java    From redisson with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("ParameterNumber")
public BaseRedisBatchExecutor(boolean readOnlyMode, NodeSource source, Codec codec, RedisCommand<V> command,
        Object[] params, RPromise<R> mainPromise, boolean ignoreRedirect,
        ConnectionManager connectionManager, RedissonObjectBuilder objectBuilder, 
        ConcurrentMap<MasterSlaveEntry, Entry> commands,
        BatchOptions options, AtomicInteger index, AtomicBoolean executed) {
    
    super(readOnlyMode, source, codec, command, params, mainPromise, ignoreRedirect, connectionManager,
            objectBuilder);
    this.commands = commands;
    this.options = options;
    this.index = index;
    this.executed = executed;
}
 
Example #14
Source File: MapReduceExecutor.java    From redisson with Apache License 2.0 5 votes vote down vote up
MapReduceExecutor(RObject object, RedissonClient redisson, ConnectionManager connectionManager) {
    this.objectName = object.getName();
    this.objectCodec = object.getCodec();
    this.objectClass = object.getClass();

    this.redisson = redisson;
    UUID id = UUID.randomUUID();
    this.resultMapName = object.getName() + ":result:" + id;
    this.executorService = redisson.getExecutorService(RExecutorService.MAPREDUCE_NAME);
    this.connectionManager = connectionManager;
}
 
Example #15
Source File: RedissonEntityRegion.java    From redisson with Apache License 2.0 4 votes vote down vote up
public RedissonEntityRegion(RMapCache<Object, Object> mapCache, ConnectionManager connectionManager, RegionFactory regionFactory,
                            CacheDataDescription metadata, Settings settings, Properties properties, String defaultKey, CacheKeysFactory cacheKeysFactory) {
    super(mapCache, connectionManager, regionFactory, metadata, properties, defaultKey);
    this.settings = settings;
    this.cacheKeysFactory = cacheKeysFactory;
}
 
Example #16
Source File: RedissonBatchRx.java    From redisson with Apache License 2.0 4 votes vote down vote up
public RedissonBatchRx(EvictionScheduler evictionScheduler, ConnectionManager connectionManager, CommandRxExecutor commandExecutor, BatchOptions options) {
    this.evictionScheduler = evictionScheduler;
    this.executorService = new CommandRxBatchService(connectionManager, options);
    this.commandExecutor = commandExecutor;
}
 
Example #17
Source File: RedissonQueryRegion.java    From redisson with Apache License 2.0 4 votes vote down vote up
public RedissonQueryRegion(RMapCache<Object, Object> mapCache, ConnectionManager connectionManager,
        RegionFactory regionFactory, Properties properties, String defaultKey) {
    super(mapCache, connectionManager, regionFactory, null, properties, defaultKey);
}
 
Example #18
Source File: RedissonQueryRegion.java    From redisson with Apache License 2.0 4 votes vote down vote up
public RedissonQueryRegion(RMapCache<Object, Object> mapCache, ConnectionManager connectionManager,
        RegionFactory regionFactory, Properties properties, String defaultKey) {
    super(mapCache, connectionManager, regionFactory, null, properties, defaultKey);
}
 
Example #19
Source File: RedissonTimestampsRegion.java    From redisson with Apache License 2.0 4 votes vote down vote up
public RedissonTimestampsRegion(RMapCache<Object, Object> mapCache, ConnectionManager connectionManager,
        RegionFactory regionFactory, Properties properties, String defaultKey) {
    super(mapCache, connectionManager, regionFactory, null, properties, defaultKey);
}
 
Example #20
Source File: RedissonEntityRegion.java    From redisson with Apache License 2.0 4 votes vote down vote up
public RedissonEntityRegion(RMapCache<Object, Object> mapCache, ConnectionManager connectionManager, RegionFactory regionFactory,
                            CacheDataDescription metadata, Settings settings, Properties properties, String defaultKey) {
    super(mapCache, connectionManager, regionFactory, metadata, properties, defaultKey);
    this.settings = settings;
}
 
Example #21
Source File: RedissonNaturalIdRegion.java    From redisson with Apache License 2.0 4 votes vote down vote up
public RedissonNaturalIdRegion(RMapCache<Object, Object> mapCache, ConnectionManager connectionManager, RegionFactory regionFactory,
                               CacheDataDescription metadata, Settings settings, Properties properties, String defaultKey, CacheKeysFactory cacheKeysFactory) {
    super(mapCache, connectionManager, regionFactory, metadata, properties, defaultKey);
    this.settings = settings;
    this.cacheKeysFactory = cacheKeysFactory;
}
 
Example #22
Source File: CommandAsyncService.java    From redisson with Apache License 2.0 4 votes vote down vote up
public CommandAsyncService(ConnectionManager connectionManager) {
    this.connectionManager = connectionManager;
}
 
Example #23
Source File: CommandBatchService.java    From redisson with Apache License 2.0 4 votes vote down vote up
public CommandBatchService(ConnectionManager connectionManager, BatchOptions options) {
    super(connectionManager);
    this.options = options;
}
 
Example #24
Source File: CommandBatchService.java    From redisson with Apache License 2.0 4 votes vote down vote up
public CommandBatchService(ConnectionManager connectionManager) {
    super(connectionManager);
}
 
Example #25
Source File: RedissonCollectionRegion.java    From redisson with Apache License 2.0 4 votes vote down vote up
public RedissonCollectionRegion(RMapCache<Object, Object> mapCache, ConnectionManager connectionManager, RegionFactory regionFactory,
                                CacheDataDescription metadata, Settings settings, Properties properties, String defaultKey, CacheKeysFactory cacheKeysFactory) {
    super(mapCache, connectionManager, regionFactory, metadata, properties, defaultKey);
    this.settings = settings;
    this.cacheKeysFactory = cacheKeysFactory;
}
 
Example #26
Source File: CommandSyncService.java    From redisson with Apache License 2.0 4 votes vote down vote up
public CommandSyncService(ConnectionManager connectionManager) {
    super(connectionManager);
}
 
Example #27
Source File: RedissonReactive.java    From redisson with Apache License 2.0 4 votes vote down vote up
public ConnectionManager getConnectionManager() {
    return connectionManager;
}
 
Example #28
Source File: RedissonEntityRegion.java    From redisson with Apache License 2.0 4 votes vote down vote up
public RedissonEntityRegion(RMapCache<Object, Object> mapCache, ConnectionManager connectionManager, RegionFactory regionFactory,
                            CacheDataDescription metadata, Settings settings, Properties properties, String defaultKey, CacheKeysFactory cacheKeysFactory) {
    super(mapCache, connectionManager, regionFactory, metadata, properties, defaultKey);
    this.settings = settings;
    this.cacheKeysFactory = cacheKeysFactory;
}
 
Example #29
Source File: CommandRxService.java    From redisson with Apache License 2.0 4 votes vote down vote up
public CommandRxService(ConnectionManager connectionManager) {
    super(connectionManager);
}
 
Example #30
Source File: CommandRxBatchService.java    From redisson with Apache License 2.0 4 votes vote down vote up
public CommandRxBatchService(ConnectionManager connectionManager, BatchOptions options) {
    super(connectionManager);
    batchService = new CommandBatchService(connectionManager, options);
}