redis.clients.util.Pool.returnBrokenResource()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(96)

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

Pool.returnBrokenResource介绍

暂无

代码示例

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

@Override
protected void returnBrokenResource(Jedis resource) {
 super.returnBrokenResource(resource);
}

代码示例来源:origin: lindzh/hasting

@Override
public void returnBrokenResource(Jedis resource) {
  redisPool.returnBrokenResource(resource);
}

代码示例来源:origin: org.datanucleus/datanucleus-cache

@Override
public void evict(Object oid)
{
  Jedis jedis = null;
  try
  {
    jedis = pool.getResource();
    jedis.del(getCacheKeyForId(oid).getBytes());
    pool.returnResource(jedis);
  }
  catch (Exception e)
  {
    pool.returnBrokenResource(jedis);
    throw new NucleusException(String.format("Failed to evict key %s from Redis cache", oid), e);
  }
}

代码示例来源:origin: org.datanucleus/datanucleus-cache

@Override
public void evictAll(Object[] objects)
{
  Jedis jedis = null;
  jedis = pool.getResource();
  for (Object oid : objects)
  {
    try
    {
      jedis.del(getCacheKeyForId(oid).getBytes());
    }
    catch (Exception e)
    {
      pool.returnBrokenResource(jedis);
      throw new NucleusException(String.format("Failed to evict keys %s from cache {0}", objects), e);
    }
  }
  pool.returnResource(jedis);
}

代码示例来源:origin: org.datanucleus/datanucleus-cache

@Override
public CachedPC get(Object oid)
{
  Jedis jedis = null;
  Object value;
  try
  {
    jedis = pool.getResource();
    value = getObjectInternal(jedis.get(getCacheKeyForId(oid).getBytes()));
    pool.returnResource(jedis);
  }
  catch (Exception e)
  {
    pool.returnBrokenResource(jedis);
    throw new NucleusException(String.format("Failed to get key %s from cache {0}", oid), e);
  }
  return (CachedPC) value;
}

代码示例来源:origin: org.datanucleus/datanucleus-cache

public void evict(Query query)
{
  Jedis jedis = null;
  String key = null;
  try
  {
    jedis = pool.getResource();
    key = QueryUtils.getKeyForQueryResultsCache(query, null);
    jedis.del(key);
    pool.returnResource(jedis);
  }
  catch (Exception e)
  {
    pool.returnBrokenResource(jedis);
    throw new NucleusException(String.format("Failed to evict key %s from Redis cache", key), e);
  }
}

代码示例来源:origin: org.datanucleus/datanucleus-cache

public void evict(Query query, Map params)
{
  Jedis jedis = null;
  String key = null;
  try
  {
    jedis = pool.getResource();
    key = QueryUtils.getKeyForQueryResultsCache(query, params);
    jedis.del(key);
    pool.returnResource(jedis);
  }
  catch (Exception e)
  {
    pool.returnBrokenResource(jedis);
    throw new NucleusException(String.format("Failed to evict key %s from Redis cache", key), e);
  }
}

代码示例来源:origin: org.datanucleus/datanucleus-cache

public List<Object> get(String queryKey)
{
  String key = KEY_PREFIX + queryKey;
  Jedis jedis = null;
  Object value;
  try
  {
    jedis = pool.getResource();
    value = getObjectFromBytes(jedis.get(key.getBytes()));
    pool.returnResource(jedis);
  }
  catch (Exception e)
  {
    pool.returnBrokenResource(jedis);
    throw new NucleusException("Failed to get from Redis cache", e);
  }
  return (List<Object>) value;
}

代码示例来源:origin: org.datanucleus/datanucleus-cache

public List<Object> put(String queryKey, List<Object> results)
{
  if (queryKey == null || results == null)
  {
    return null;
  }
  Jedis jedis = null;
  String key = KEY_PREFIX + queryKey;
  try
  {
    jedis = pool.getResource();
    jedis.setex(key.getBytes(), expirySeconds, getBytesForObject(results));
    pool.returnResource(jedis);
  }
  catch (Exception e)
  {
    pool.returnBrokenResource(jedis);
    throw new NucleusException(String.format("Failed to set object %s with ID %s into Redis cache", results, queryKey));
  }
  return results;
}

代码示例来源:origin: org.datanucleus/datanucleus-cache

public void evictAll()
{
  Jedis jedis = null;
  try
  {
    jedis = pool.getResource();
    jedis.flushDB();
    pool.returnResource(jedis);
  }
  catch (Exception e)
  {
    pool.returnBrokenResource(jedis);
    throw new NucleusException("Failed to evict-all from Redis cache", e);
  }
}

代码示例来源:origin: org.datanucleus/datanucleus-cache

@Override
public void evictAll()
{
  Jedis jedis = null;
  try
  {
    jedis = pool.getResource();
    jedis.flushDB();
    pool.returnResource(jedis);
  }
  catch (Exception e)
  {
    pool.returnBrokenResource(jedis);
    throw new NucleusException("Failed to evict-all from Redis cache", e);
  }
}

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

pool.returnBrokenResource(jedis);
} else {
  pool.returnResource(jedis);

代码示例来源:origin: org.datanucleus/datanucleus-cache

@Override
public CachedPC put(Object o, CachedPC cachedPC)
{
  if (o == null || cachedPC == null)
  {
    return null;
  }
  Jedis jedis = null;
  try
  {
    jedis = pool.getResource();
    jedis.setex(getCacheKeyForId(o).getBytes(), expirySeconds, getBytesForObject(cachedPC));
    pool.returnResource(jedis);
  }
  catch (Exception e)
  {
    pool.returnBrokenResource(jedis);
    throw new NucleusException(String.format("Failed to set object %s with id %s into Redis cache", cachedPC.toString("", true), o), e);
  }
  return cachedPC;
}

代码示例来源:origin: penggle/jedis-ms-sentinel

public void close() {
  if (dataSource != null) {
    boolean broken = false;
    for (MasterSlaveJedis jedis : getAllShards()) {
      if (jedis.getClient().isBroken()) {
        broken = true;
        break;
      }
    }
    if (broken) {
      dataSource.returnBrokenResource(this);
    } else {
      dataSource.returnResource(this);
    }
  } else {
    disconnect();
  }
}

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

@Override
public void close() throws DataAccessException {
  super.close();
  // return the connection to the pool
  if (pool != null) {
    if (broken) {
      pool.returnBrokenResource(jedis);
    } else {
      jedis.close();
    }
    return;
  }
  // else close the connection normally (doing the try/catch dance)
  Exception exc = null;
  try {
    jedis.quit();
  } catch (Exception ex) {
    exc = ex;
  }
  try {
    jedis.disconnect();
  } catch (Exception ex) {
    exc = ex;
  }
  if (exc != null)
    throw convertJedisAccessException(exc);
}

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

@Override
public void close() throws DataAccessException {
  super.close();
  // return the connection to the pool
  if (pool != null) {
    if (broken) {
      pool.returnBrokenResource(jedis);
    } else {
      jedis.close();
    }
    return;
  }
  // else close the connection normally (doing the try/catch dance)
  Exception exc = null;
  try {
    jedis.quit();
  } catch (Exception ex) {
    exc = ex;
  }
  try {
    jedis.disconnect();
  } catch (Exception ex) {
    exc = ex;
  }
  if (exc != null)
    throw convertJedisAccessException(exc);
}

代码示例来源:origin: penggle/jedis-ms-sentinel

public void close() {
  if (dataSource != null) {
    boolean broken = getClient().isBroken();
    if(!broken){
      for (Jedis jedis : getAllShards()) {
        if (jedis.getClient().isBroken()) {
          broken = true;
          break;
        }
      }
    }
    if (broken) {
      dataSource.returnBrokenResource(this);
    } else {
      dataSource.returnResource(this);
    }
  } else {
    disconnect();
  }
}

相关文章