Examples of RedisConnection


Examples of com.lambdaworks.redis.RedisConnection

     */
    @Override
    public void run(Timeout timeout) throws Exception {
        ChannelPipeline old = channel.getPipeline();
        CommandHandler handler = old.get(CommandHandler.class);
        RedisConnection connection = old.get(RedisConnection.class);
        ChannelPipeline pipeline = Channels.pipeline(this, handler, connection);

        Channel c = bootstrap.getFactory().newChannel(pipeline);
        c.getConfig().setOptions(bootstrap.getOptions());
        c.connect((SocketAddress) bootstrap.getOption("remoteAddress"));
View Full Code Here

Examples of com.lambdaworks.redis.RedisConnection

            log.debug("{} freezed", addr);
            connectionEntry.setFreezed(true);

            // close all connections
            while (true) {
                RedisConnection connection = connectionEntry.getConnections().poll();
                if (connection == null) {
                    break;
                }
                connection.close();
            }

            // close all pub/sub connections
            while (true) {
                RedisPubSubConnection connection = connectionEntry.pollFreeSubscribeConnection();
                if (connection == null) {
                    break;
                }
                connection.close();
            }


            boolean allFreezed = true;
            for (SubscribesConnectionEntry entry : clients) {
View Full Code Here

Examples of com.lambdaworks.redis.RedisConnection

            if (entry.isFreezed()
                    || !entry.getConnectionsSemaphore().tryAcquire()) {
                clientsCopy.remove(index);
            } else {
                RedisConnection conn = entry.getConnections().poll();
                if (conn != null) {
                    return conn;
                }
                try {
                    conn = entry.getClient().connect(codec);
                    if (config.getPassword() != null) {
                        conn.auth(config.getPassword());
                    }
                    if (config.getDatabase() != 0) {
                        conn.select(config.getDatabase());
                    }

                    return conn;
                } catch (RedisConnectionException e) {
                    entry.getConnectionsSemaphore().release();
View Full Code Here

Examples of org.springframework.data.keyvalue.redis.connection.RedisConnection

   */
  public <T> T execute(RedisCallback<T> action, boolean exposeConnection, boolean pipeline) {
    Assert.notNull(action, "Callback object must not be null");

    RedisConnectionFactory factory = getConnectionFactory();
    RedisConnection conn = RedisConnectionUtils.getConnection(factory);

    boolean existingConnection = TransactionSynchronizationManager.hasResource(factory);
    preProcessConnection(conn, existingConnection);

    boolean pipelineStatus = conn.isPipelined();
    if (pipeline && !pipelineStatus) {
      conn.openPipeline();
    }

    try {
      RedisConnection connToExpose = (exposeConnection ? conn : createRedisConnectionProxy(conn));
      T result = action.doInRedis(connToExpose);
      // TODO: any other connection processing?
      return postProcessResult(result, conn, existingConnection);
    } finally {
      try {
View Full Code Here

Examples of org.springframework.data.keyvalue.redis.connection.RedisConnection

    }

    if (log.isDebugEnabled())
      log.debug("Opening RedisConnection");

    RedisConnection conn = factory.getConnection();

    boolean synchronizationActive = TransactionSynchronizationManager.isSynchronizationActive();

    if (bind || synchronizationActive) {
      connHolder = new RedisConnectionHolder(conn);
View Full Code Here

Examples of org.springframework.data.keyvalue.redis.connection.RedisConnection

   * @param factory Redis factory
   */
  public static void unbindConnection(RedisConnectionFactory factory) {
    RedisConnectionHolder connHolder = (RedisConnectionHolder) TransactionSynchronizationManager.unbindResourceIfPossible(factory);
    if (connHolder != null) {
      RedisConnection connection = connHolder.getConnection();
      connection.close();
    }
  }
View Full Code Here

Examples of org.springframework.data.keyvalue.redis.connection.RedisConnection

*/
public class SessionTest {

  @Test
  public void testSession() throws Exception {
    final RedisConnection conn = mock(RedisConnection.class);
    RedisConnectionFactory factory = mock(RedisConnectionFactory.class);

    when(factory.getConnection()).thenReturn(conn);
    final StringRedisTemplate template = new StringRedisTemplate(factory);

View Full Code Here

Examples of org.springframework.data.keyvalue.redis.connection.RedisConnection

    ConnectionFactoryTracker.add(factory);
  }

  @After
  public void stop() {
    RedisConnection connection = factory.getConnection();
    connection.flushDb();
    connection.close();
  }
View Full Code Here

Examples of org.springframework.data.redis.connection.RedisConnection

    this.redisConnectionFactory = connectionFactory;
  }

  @Override
  protected void doHealthCheck(Health.Builder builder) throws Exception {
    RedisConnection connection = RedisConnectionUtils
        .getConnection(this.redisConnectionFactory);
    try {
      Properties info = connection.info();
      builder.up().withDetail("version", info.getProperty("redis_version"));
    }
    finally {
      RedisConnectionUtils.releaseConnection(connection,
          this.redisConnectionFactory);
View Full Code Here

Examples of org.springframework.data.redis.connection.RedisConnection

  @Test
  public void redisIsUp() throws Exception {
    Properties info = new Properties();
    info.put("redis_version", "2.8.9");

    RedisConnection redisConnection = mock(RedisConnection.class);
    RedisConnectionFactory redisConnectionFactory = mock(RedisConnectionFactory.class);
    given(redisConnectionFactory.getConnection()).willReturn(redisConnection);
    given(redisConnection.info()).willReturn(info);
    RedisHealthIndicator healthIndicator = new RedisHealthIndicator(
        redisConnectionFactory);

    Health health = healthIndicator.health();
    assertEquals(Status.UP, health.getStatus());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.