redis.clients.jedis.exceptions.JedisConnectionException.getMessage()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(4.3k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中redis.clients.jedis.exceptions.JedisConnectionException.getMessage()方法的一些代码示例,展示了JedisConnectionException.getMessage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JedisConnectionException.getMessage()方法的具体详情如下:
包路径:redis.clients.jedis.exceptions.JedisConnectionException
类名称:JedisConnectionException
方法名:getMessage

JedisConnectionException.getMessage介绍

暂无

代码示例

代码示例来源:origin: sohutv/cachecloud

} catch (JedisConnectionException e) {
  logger.error("RedisConnectionError-{}:{} keys={}", jedisPool.getHost(), jedisPool.getPort(), subkeys);
  logger.error(e.getMessage(), e);
} catch (Exception e) {
  logger.error(e.getMessage(), e);

代码示例来源:origin: magro/memcached-session-manager

@Override
public T call() throws Exception {
  BinaryJedis jedis = null;
  // Borrow an instance from Jedis without checking it for performance reasons and execute the command on it
  try {
    jedis = _pool.borrowInstance(false);
    return execute(jedis);
  } catch (JedisConnectionException e) {
    // Connection error occurred with this Jedis connection, so now make sure to get a known-good one
    // The old connection is not given back to the pool since it is defunct anyway
    if (_log.isDebugEnabled())
      _log.debug("Connection error occurred, discarding Jedis connection: " + e.getMessage());
    if (jedis != null)
      try { jedis.close(); } catch (Exception e2) { /* ignore */ }
    jedis = null;
  } finally {
    if (jedis != null)
      _pool.returnInstance(jedis);
  }
  
  // Try to execute the command again with a known-good instance
  try {
    jedis = _pool.borrowInstance(true);
    return execute(jedis);
  } finally {
    if (jedis != null)
      _pool.returnInstance(jedis);
  }
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-redis

@Override
public Runnable pollElement() {
  try {
    Work work = queuing.getWorkFromQueue(queueId);
    return work == null ? null : new WorkHolder(work);
  } catch (IOException e) {
    if (delayExpired(LAST_IO_EXCEPTION)) {
      // log full stacktrace
      log.error(e.getMessage(), e);
    }
    // for io errors make poll return no result
    return null;
  } catch (JedisConnectionException e) {
    if (delayExpired(LAST_CONNECTION_EXCEPTION)) {
      Throwable cause = e.getCause();
      if (cause != null && cause.getMessage().contains(ConnectException.class.getName())) {
        log.error(e.getMessage() + ": " + cause.getMessage());
        log.debug(e.getMessage(), e);
      } else {
        // log full stacktrace
        log.error(e.getMessage(), e);
      }
    }
    // for connection errors make poll return no result
    return null;
  }
}

代码示例来源:origin: simpleci/simpleci

public static boolean testRedis(String host, int port) {
  final int tryCount = 10;
  for (int i = 1; i <= tryCount; i++) {
    logger.info(String.format("redis: connecting to %s:%s, try %d of %d",   host, port, i, tryCount));
    try {
      Jedis connection = new Jedis(host, port);
      connection.connect();
      connection.close();
      logger.info("Connection to redis established successfully");
      return true;
    } catch (JedisConnectionException e) {
      logger.info("Failed to connect: " + e.getMessage());
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e1) {
        logger.error("", e);
      }
    }
  }
  logger.info(String.format("Failed connect to redis on %s:%d", host, port));
  return false;
}

代码示例来源:origin: com.vlkan.log4j2/log4j2-redis-appender

private void disconnect() {
  logger.debug("disconnecting");
  try {
    jedisPool.destroy();
  } catch (JedisConnectionException error) {
    logger.debug("disconnect failure: %s", error.getMessage());
  } finally {
    jedisPool = null;
  }
}

代码示例来源:origin: com.netflix.dyno/dyno-jedis

Logger.warn("Caught JedisConnectionException: " + ex.getMessage());
opMonitor.recordFailure(opName, ex.getMessage());
lastDynoException = (DynoConnectException) new FatalConnectionException(ex).setAttempt(1).setHost(this.getHost());
throw lastDynoException;

代码示例来源:origin: de.javakaffee.msm/memcached-session-manager

@Override
public T call() throws Exception {
  BinaryJedis jedis = null;
  // Borrow an instance from Jedis without checking it for performance reasons and execute the command on it
  try {
    jedis = _pool.borrowInstance(false);
    return execute(jedis);
  } catch (JedisConnectionException e) {
    // Connection error occurred with this Jedis connection, so now make sure to get a known-good one
    // The old connection is not given back to the pool since it is defunct anyway
    if (_log.isDebugEnabled())
      _log.debug("Connection error occurred, discarding Jedis connection: " + e.getMessage());
    if (jedis != null)
      try { jedis.close(); } catch (Exception e2) { /* ignore */ }
    jedis = null;
  } finally {
    if (jedis != null)
      _pool.returnInstance(jedis);
  }
  
  // Try to execute the command again with a known-good instance
  try {
    jedis = _pool.borrowInstance(true);
    return execute(jedis);
  } finally {
    if (jedis != null)
      _pool.returnInstance(jedis);
  }
}

相关文章