...
|
...
|
@@ -39,6 +39,11 @@ public class RedisTask extends Task { |
|
|
|
|
|
this.tUrl = tUrl;
|
|
|
|
|
|
sureConnect();
|
|
|
}
|
|
|
|
|
|
|
|
|
private void connect() {
|
|
|
try {
|
|
|
client = new Jedis(this.getIp(), this.getPort(), 5 * 1000);
|
|
|
|
...
|
...
|
@@ -50,7 +55,28 @@ public class RedisTask extends Task { |
|
|
|
|
|
client = null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void sureConnect() {
|
|
|
DEBUG.info("start to connect to redis {},time {}", super.url, System.currentTimeMillis());
|
|
|
|
|
|
connect();
|
|
|
|
|
|
//等待两秒重连
|
|
|
try {
|
|
|
|
|
|
Thread.sleep(2 * 1000);
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
DEBUG.error("Failed to wait for reconnect to redis {}", super.url);
|
|
|
}
|
|
|
|
|
|
if (null == client || !client.isConnected()) {
|
|
|
connect();
|
|
|
}
|
|
|
|
|
|
DEBUG.info("End to connect to redis {},time {}", super.url, System.currentTimeMillis());
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|