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

x33g5p2x  于9个月前 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(14)

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

JedisException.getMessage介绍

暂无

代码示例

代码示例来源:origin: apache/incubator-druid

@Override
public Map<NamedKey, byte[]> getBulk(Iterable<NamedKey> keys)
{
 totalRequestCount.incrementAndGet();
 Map<NamedKey, byte[]> results = new HashMap<>();
 try (Jedis jedis = pool.getResource()) {
  List<NamedKey> namedKeys = Lists.newArrayList(keys);
  List<byte[]> byteKeys = Lists.transform(namedKeys, NamedKey::toByteArray);
  List<byte[]> byteValues = jedis.mget(byteKeys.toArray(new byte[0][]));
  for (int i = 0; i < byteValues.size(); ++i) {
   if (byteValues.get(i) != null) {
    results.put(namedKeys.get(i), byteValues.get(i));
   }
  }
  hitCount.addAndGet(results.size());
  missCount.addAndGet(namedKeys.size() - results.size());
 }
 catch (JedisException e) {
  if (e.getMessage().contains("Read timed out")) {
   timeoutCount.incrementAndGet();
  } else {
   errorCount.incrementAndGet();
  }
  log.warn(e, "Exception pulling items from cache");
 }
 return results;
}

代码示例来源:origin: apache/incubator-druid

@Override
public byte[] get(NamedKey key)
{
 totalRequestCount.incrementAndGet();
 try (Jedis jedis = pool.getResource()) {
  byte[] bytes = jedis.get(key.toByteArray());
  if (bytes == null) {
   missCount.incrementAndGet();
   return null;
  } else {
   hitCount.incrementAndGet();
   return bytes;
  }
 }
 catch (JedisException e) {
  if (e.getMessage().contains("Read timed out")) {
   timeoutCount.incrementAndGet();
  } else {
   errorCount.incrementAndGet();
  }
  log.warn(e, "Exception pulling item from cache");
  return null;
 }
}

代码示例来源:origin: spring-projects/spring-data-redis

/**
 * Converts the given, native Jedis exception to Spring's DAO hierarchy.
 *
 * @param ex Jedis exception
 * @return converted exception
 */
public static DataAccessException convertJedisAccessException(JedisException ex) {
  if (ex instanceof JedisDataException) {
    return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
  }
  if (ex instanceof JedisConnectionException) {
    return new RedisConnectionFailureException(ex.getMessage(), ex);
  }
  // fallback to invalid data exception
  return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
}

代码示例来源:origin: org.springframework.data/spring-data-redis

/**
 * Converts the given, native Jedis exception to Spring's DAO hierarchy.
 *
 * @param ex Jedis exception
 * @return converted exception
 */
public static DataAccessException convertJedisAccessException(JedisException ex) {
  if (ex instanceof JedisDataException) {
    return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
  }
  if (ex instanceof JedisConnectionException) {
    return new RedisConnectionFailureException(ex.getMessage(), ex);
  }
  // fallback to invalid data exception
  return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Converts the given, native Jedis exception to Spring's DAO hierarchy.
 *
 * @param ex Jedis exception
 * @return converted exception
 */
public static DataAccessException convertJedisAccessException(JedisException ex) {
  if (ex instanceof JedisDataException) {
    return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
  }
  if (ex instanceof JedisConnectionException) {
    return new RedisConnectionFailureException(ex.getMessage(), ex);
  }
  // fallback to invalid data exception
  return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
}

代码示例来源:origin: tangyanbo/springmore

/**
 * Handle jedisException, write log and return whether the connection is broken.
 */
protected boolean handleJedisException(JedisException jedisException) {
  if (jedisException instanceof JedisConnectionException) {
    logger.error("Redis connection " + jedisPool.getAddress() + " lost.", jedisException);
  } else if (jedisException instanceof JedisDataException) {
    if ((jedisException.getMessage() != null) && (jedisException.getMessage().indexOf("READONLY") != -1)) {
      logger.error("Redis connection " + jedisPool.getAddress() + " are read-only slave.", jedisException);
    } else {
      // dataException, isBroken=false
      return false;
    }
  } else {
    logger.error("Jedis exception happen.", jedisException);
  }
  return true;
}

代码示例来源:origin: com.gitee.l0km/facelog-client-base

@Override
    public void run() {
      // 将设备命令交给命令类型对应的方法执行设备命令
      Ack<?> ack = t.getCmd().run(cmdAdapter, t.getParameters()).setCmdSn(cmdSn);
      // 如果指定了响应频道且频道名有效则向指定的频道发送响应消息
      if(!Strings.isNullOrEmpty(t.getAckChannel())){
        String ackChannel = t.getAckChannel();
        if(ackChannelValidator.apply(ackChannel)){
          Channel<Ack<?>> channel = new Channel<Ack<?>>(ackChannel){};
          try{
            redisPublisher.publish(channel, ack);
          }catch(JedisException e){
            logger.error(e.getMessage());
          }
        }else{
          logger.warn("INVALID ack channel: {}",ackChannel);
        }
      }
    }});
}else{

相关文章