本文整理了Java中redis.clients.jedis.exceptions.JedisConnectionException
类的一些代码示例,展示了JedisConnectionException
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JedisConnectionException
类的具体详情如下:
包路径:redis.clients.jedis.exceptions.JedisConnectionException
类名称:JedisConnectionException
暂无
代码示例来源:origin: sohutv/cachecloud
public void rollbackTimeout() {
try {
socket.setSoTimeout(soTimeout);
} catch (SocketException ex) {
broken = true;
throw new JedisConnectionException(ex);
}
}
代码示例来源: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: sohutv/cachecloud
String errorMessage = Protocol.readErrorLineIfPossible(inputStream);
if (errorMessage != null && errorMessage.length() > 0) {
ex = new JedisConnectionException(errorMessage, ex.getCause());
代码示例来源: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: Allianzcortex/code_collection
@Override
public void run() {
try {
System.out.println("移除使用的线程为: " + Thread.currentThread().getName());
jedis.select(MainConfig.redisDatabaseIndex);
jedis.srem(key_, stuId);
jedis.close();
} catch (JedisDataException ex) {// multiple catch is not supported before java7
ex.printStackTrace();
} catch (NullPointerException ex) {
ex.printStackTrace();
} catch (JedisConnectionException ex) {
ex.printStackTrace();
}
}
代码示例来源:origin: pyloque/captain
context.put("kversion", kversion);
} catch (JedisConnectionException e) {
context.put("reason", e.toString());
context.put("stacktraces", e.getStackTrace());
代码示例来源:origin: yangfuhai/jboot
public Jedis getJedis() {
try {
return jedisPool.getResource();
} catch (JedisConnectionException e) {
throw new JbootIllegalConfigException("can not connect to redis host " + config.getHost() + ":" + config.getPort() + " ," +
" cause : " + e.toString(), e);
}
}
代码示例来源:origin: imloama/api-server-seed
@Override
public int getSize()
{
int result = 0;
JedisConnection connection = null;
try
{
connection = jedisConnectionFactory.getConnection();
result = Integer.valueOf(connection.dbSize().toString());
}
catch (JedisConnectionException e)
{
e.printStackTrace();
}
finally
{
if (connection != null) {
connection.close();
}
}
return result;
}
代码示例来源:origin: sohutv/cachecloud
/**
* This methods assumes there are required bytes to be read. If we cannot read anymore bytes an
* exception is thrown to quickly ascertain that the stream was smaller than expected.
*/
private void ensureFill() throws JedisConnectionException {
if (count >= limit) {
try {
limit = in.read(buf);
count = 0;
if (limit == -1) {
throw new JedisConnectionException("Unexpected end of stream.");
}
} catch (IOException e) {
throw new JedisConnectionException(e);
}
}
}
}
代码示例来源:origin: apache/servicemix-bundles
public void sendCommand(final ProtocolCommand cmd, final byte[]... args) {
try {
connect();
Protocol.sendCommand(outputStream, cmd, args);
} catch (JedisConnectionException ex) {
/*
* When client send request which formed by invalid protocol, Redis send back error message
* before close connection. We try to read it to provide reason of failure.
*/
try {
String errorMessage = Protocol.readErrorLineIfPossible(inputStream);
if (errorMessage != null && errorMessage.length() > 0) {
ex = new JedisConnectionException(errorMessage, ex.getCause());
}
} catch (Exception e) {
/*
* Catch any IOException or JedisConnectionException occurred from InputStream#read and just
* ignore. This approach is safe because reading error message is optional and connection
* will eventually be closed.
*/
}
// Any other exceptions related to connection?
broken = true;
throw ex;
}
}
代码示例来源: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: imloama/api-server-seed
@Override
public void clear()
{
JedisConnection connection = null;
try
{
connection = jedisConnectionFactory.getConnection();
connection.flushDb();
connection.flushAll();
}
catch (JedisConnectionException e)
{
e.printStackTrace();
}
finally
{
if (connection != null) {
connection.close();
}
}
}
代码示例来源:origin: sohutv/cachecloud
public T getResource() {
try {
return internalPool.borrowObject();
} catch (Exception e) {
throw new JedisConnectionException("Could not get a resource from the pool", e);
}
}
代码示例来源: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: imloama/api-server-seed
@Override
public Object removeObject(Object key)
{
JedisConnection connection = null;
Object result = null;
try
{
connection = jedisConnectionFactory.getConnection();
RedisSerializer<Object> serializer = new JdkSerializationRedisSerializer();
result =connection.expire(serializer.serialize(key), 0);
}
catch (JedisConnectionException e)
{
e.printStackTrace();
}
finally
{
if (connection != null) {
connection.close();
}
}
return result;
}
代码示例来源:origin: sohutv/cachecloud
protected void flush() {
try {
outputStream.flush();
} catch (IOException ex) {
broken = true;
throw new JedisConnectionException(ex);
}
}
代码示例来源: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: imloama/api-server-seed
@Override
public Object getObject(Object key)
{
Object result = null;
JedisConnection connection = null;
try
{
connection = jedisConnectionFactory.getConnection();
RedisSerializer<Object> serializer = new JdkSerializationRedisSerializer();
result = serializer.deserialize(connection.get(serializer.serialize(key)));
}
catch (JedisConnectionException e)
{
e.printStackTrace();
}
finally
{
if (connection != null) {
connection.close();
}
}
return result;
}
代码示例来源:origin: sohutv/cachecloud
public void setTimeoutInfinite() {
try {
if (!isConnected()) {
connect();
}
socket.setSoTimeout(0);
} catch (SocketException ex) {
broken = true;
throw new JedisConnectionException(ex);
}
}
代码示例来源: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;
内容来源于网络,如有侵权,请联系作者删除!