org.springframework.data.redis.connection.RedisClusterConnection Java Examples

The following examples show how to use org.springframework.data.redis.connection.RedisClusterConnection. 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: TracingRedisConnectionFactory.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public RedisConnection getConnection() {
  // support cluster connection
  RedisConnection connection = this.delegate.getConnection();
  if (connection instanceof RedisClusterConnection) {
    return new TracingRedisClusterConnection((RedisClusterConnection) connection,
        tracingConfiguration);
  }
  return new TracingRedisConnection(connection, tracingConfiguration);
}
 
Example #2
Source File: RedissonConnectionFactory.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Override
public RedisClusterConnection getClusterConnection() {
    if (!redisson.getConfig().isClusterConfig()) {
        throw new InvalidDataAccessResourceUsageException("Redisson is not in Cluster mode");
    }
    return new RedissonClusterConnection(redisson);
}
 
Example #3
Source File: RedissonConnectionFactory.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Override
public RedisClusterConnection getClusterConnection() {
    if (!redisson.getConfig().isClusterConfig()) {
        throw new InvalidDataAccessResourceUsageException("Redisson is not in Cluster mode");
    }
    return new RedissonClusterConnection(redisson);
}
 
Example #4
Source File: RedissonConnectionFactory.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Override
public RedisClusterConnection getClusterConnection() {
    if (!redisson.getConfig().isClusterConfig()) {
        throw new InvalidDataAccessResourceUsageException("Redisson is not in Cluster mode");
    }
    return new RedissonClusterConnection(redisson);
}
 
Example #5
Source File: RedissonConnectionFactory.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Override
public RedisClusterConnection getClusterConnection() {
    if (!redisson.getConfig().isClusterConfig()) {
        throw new InvalidDataAccessResourceUsageException("Redisson is not in Cluster mode");
    }
    return new RedissonClusterConnection(redisson);
}
 
Example #6
Source File: RedisLimitConfig.java    From springboot-cloud with MIT License 5 votes vote down vote up
@Bean
public RedisLimit build() {
    RedisClusterConnection clusterConnection = jedisConnectionFactory.getClusterConnection();
    JedisCluster jedisCluster = (JedisCluster) clusterConnection.getNativeConnection();
    RedisLimit redisLimit = new RedisLimit.Builder<>(jedisCluster)
            .limit(limit)
            .build();

    return redisLimit;
}
 
Example #7
Source File: TracingRedisConnectionFactoryTest.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Test
public void delegatesClusterConnectionIfCluster() {
  RedisConnectionFactory connectionFactory = mock(RedisConnectionFactory.class);
  when(connectionFactory.getConnection()).thenReturn(mock(RedisClusterConnection.class));
  TracingRedisConnectionFactory tracingConnectionFactory = new TracingRedisConnectionFactory(
      connectionFactory,
      new TracingConfiguration.Builder(tracer).traceWithActiveSpanOnly(false).build());
  assertTrue(tracingConnectionFactory.getConnection() instanceof RedisClusterConnection);
}
 
Example #8
Source File: RedisLimit.java    From Taroco with Apache License 2.0 5 votes vote down vote up
private Object getConnection() {
    Object connection;
    if (type == RedisToolsConstant.SINGLE) {
        RedisConnection redisConnection = jedisConnectionFactory.getConnection();
        connection = redisConnection.getNativeConnection();
    } else {
        RedisClusterConnection clusterConnection = jedisConnectionFactory.getClusterConnection();
        connection = clusterConnection.getNativeConnection();
    }
    return connection;
}
 
Example #9
Source File: TracingRedisConnectionFactoryTest.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Test
public void delegatesClusterConnectionIfCluster() {
  RedisConnectionFactory connectionFactory = mock(RedisConnectionFactory.class);
  when(connectionFactory.getConnection()).thenReturn(mock(RedisClusterConnection.class));
  TracingRedisConnectionFactory tracingConnectionFactory = new TracingRedisConnectionFactory(
      connectionFactory,
      new TracingConfiguration.Builder(tracer).traceWithActiveSpanOnly(false).build());
  assertTrue(tracingConnectionFactory.getConnection() instanceof RedisClusterConnection);
}
 
Example #10
Source File: TracingRedisConnectionFactory.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public RedisConnection getConnection() {
  // support cluster connection
  RedisConnection connection = this.delegate.getConnection();
  if (connection instanceof RedisClusterConnection) {
    return new TracingRedisClusterConnection((RedisClusterConnection) connection,
        tracingConfiguration);
  }
  return new TracingRedisConnection(connection, tracingConfiguration);
}
 
Example #11
Source File: RedisAspect.java    From java-spring-cloud with Apache License 2.0 5 votes vote down vote up
/**
 * Intercepts calls to {@link RedisConnectionFactory#getClusterConnection()} (and related),
 * wrapping the outcome in a {@link TracingRedisClusterConnection}
 *
 * @param pjp the intercepted join point
 * @return a new {@link TracingRedisClusterConnection} wrapping the result of the joint point
 */
@Around("getClusterConnection() && connectionFactory()")
public Object aroundGetClusterConnection(final ProceedingJoinPoint pjp) throws Throwable {
  final RedisClusterConnection clusterConnection = (RedisClusterConnection) pjp.proceed();

  final String prefixOperationName = this.properties.getPrefixOperationName();
  final TracingConfiguration tracingConfiguration = new TracingConfiguration.Builder(tracer)
      .withSpanNameProvider(RedisSpanNameProvider.PREFIX_OPERATION_NAME(prefixOperationName))
      .build();

  return new TracingRedisClusterConnection(clusterConnection, tracingConfiguration);
}
 
Example #12
Source File: TracingRedisConnectionFactoryTest.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
@Test
public void connectionIsTracingRedisClusterConnection() {
  RedisClusterConnection connection = connectionFactory.getClusterConnection();
  verify(delegate).getClusterConnection();
  assertTrue(connection instanceof TracingRedisClusterConnection);
}
 
Example #13
Source File: TracingRedisClusterConnectionTest.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
@Override
protected RedisClusterConnection getConnection() {
  return connectionFactory.getClusterConnection();
}
 
Example #14
Source File: TracingRedisClusterConnection.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
public TracingRedisClusterConnection(RedisClusterConnection connection,
    TracingConfiguration tracingConfiguration) {
  super(connection, tracingConfiguration);
  this.connection = connection;
  this.helper = new TracingHelper(tracingConfiguration);
}
 
Example #15
Source File: TracingRedisClusterConnectionTest.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
@Override
protected RedisClusterConnection mockRedisConnection() {
  return mockRedisClusterConnection;
}
 
Example #16
Source File: TracingRedisConnectionFactory.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
@Override
public RedisClusterConnection getClusterConnection() {
  return new TracingRedisClusterConnection(delegate.getClusterConnection(), tracingConfiguration);
}
 
Example #17
Source File: MockConfiguration.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
@Bean
public RedisClusterConnection mockRedisClusterConnection() {
  return mock(RedisClusterConnection.class);
}
 
Example #18
Source File: TracingRedisClusterConnectionTest.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
@Override
protected RedisClusterConnection mockRedisConnection() {
  return mockRedisClusterConnection;
}
 
Example #19
Source File: TracingRedisClusterConnectionTest.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
@Override
protected RedisClusterConnection getConnection() {
  return connectionFactory.getClusterConnection();
}
 
Example #20
Source File: TracingRedisConnectionFactoryTest.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
@Test
public void connectionIsTracingRedisClusterConnection() {
  RedisClusterConnection connection = connectionFactory.getClusterConnection();
  verify(delegate).getClusterConnection();
  assertTrue(connection instanceof TracingRedisClusterConnection);
}
 
Example #21
Source File: MockConfiguration.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
@Bean
public RedisClusterConnection mockRedisClusterConnection() {
  return mock(RedisClusterConnection.class);
}
 
Example #22
Source File: TracingRedisConnectionFactory.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
@Override
public RedisClusterConnection getClusterConnection() {
  return new TracingRedisClusterConnection(delegate.getClusterConnection(), tracingConfiguration);
}
 
Example #23
Source File: TracingRedisClusterConnection.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
public TracingRedisClusterConnection(RedisClusterConnection connection,
    TracingConfiguration tracingConfiguration) {
  super(connection, tracingConfiguration);
  this.connection = connection;
  this.helper = new TracingHelper(tracingConfiguration);
}
 
Example #24
Source File: LCNJedisFactoryProxy.java    From tx-lcn with Apache License 2.0 4 votes vote down vote up
@Override
public RedisClusterConnection getClusterConnection() {
    System.out.println("getClusterConnection");
    return redisConnectionFactory.getClusterConnection();
}