0

I am using Johm to cache and retrieve some data in Redis database. However when the object data I want to pull like using JOhm.getAll(MT.class); for instance I get an exception

   redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: Read timed out
        at redis.clients.jedis.Protocol.process(Protocol.java:85)
        at redis.clients.jedis.Protocol.read(Protocol.java:137)
        at redis.clients.jedis.Connection.getIntegerReply(Connection.java:191)
        at redis.clients.jedis.Jedis.exists(Jedis.java:83)
        at redis.clients.johm.Nest.exists(Nest.java:117)
        at redis.clients.johm.JOhm.get(JOhm.java:55)
        at redis.clients.johm.JOhm.getAll(JOhm.java:393)
        at com.smsgh.smpp.Components.Database.MTProc.getAll(MTProc.java:67)
..................................................
        Caused by: java.net.SocketTimeoutException: Read timed out
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(Unknown Source)
        at java.net.SocketInputStream.read(Unknown Source)
        at java.net.SocketInputStream.read(Unknown Source)
        at redis.clients.util.RedisInputStream.fill(RedisInputStream.java:109)
        at redis.clients.util.RedisInputStream.readByte(RedisInputStream.java:45)
        at redis.clients.jedis.Protocol.process(Protocol.java:70)
        ... 31 more

This is my Johm setup

public class Redis {

    @SuppressWarnings("unused")
    private static Logger logger = LoggerFactory.getLogger(Redis.class);
    private static Redis redis = new Redis();
    protected JedisPool jedisPool;

    /**
     * 
     */
    private Redis() {
        jedisPool = new JedisPool(new Config(), "localhost", 6379);
        JOhm.setPool(jedisPool);
        // purgeRedis();
    }

    protected void purgeRedis() {
        Jedis jedis = jedisPool.getResource();
        jedis.flushAll();
        jedisPool.returnResource(jedis);
    }

    public synchronized static Redis getInstance() {
        if (redis == null)
            redis = new Redis();
        return redis;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        throw new CloneNotSupportedException("Clone is not allowed.");
    }

}

and this the retrieval function :

public Set<MT> getAll(){
    return JOhm.getAll(MT.class);
}

My Redis was up and running Can someone assist me?

Arsene
  • 1,037
  • 4
  • 20
  • 47

1 Answers1

0

This a connection problem.

Check you are trying to connect to the right address and that all your connection configuration is correct.

Jean Logeart
  • 52,687
  • 11
  • 83
  • 118