Bug fixes and added redis sentinel supportability changes.
parent
d4a2a68a8a
commit
9238d1ee9d
|
@ -7,7 +7,7 @@ import redis.clients.jedis.exceptions.JedisConnectionException;
|
|||
import redis.clients.util.Pool;
|
||||
import tomcat.request.session.data.cache.DataCache;
|
||||
|
||||
/** author: Ranjith Manickam @ 12 Jul' 2018 */
|
||||
/** author: Ranjith Manickam @ 3 Dec' 2018 */
|
||||
public abstract class AbstractRedisUtil implements DataCache {
|
||||
|
||||
private static final int NUM_RETRIES = 3;
|
||||
|
|
|
@ -5,7 +5,7 @@ import redis.clients.jedis.JedisSentinelPool;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
/** author: Ranjith Manickam @ 12 Jul' 2018 */
|
||||
/** author: Ranjith Manickam @ 3 Dec' 2018 */
|
||||
class RedisSentinelUtil extends AbstractRedisUtil {
|
||||
|
||||
private static final long FAILIURE_WAIT_TIME = 2000L;
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package tomcat.request.session.exception;
|
||||
|
||||
/** author: Ranjith Manickam @ 3 Dec' 2018 */
|
||||
public class BackendException extends RuntimeException {
|
||||
|
||||
private static final String ERROR_MESSAGE = "For some reason, we could process your request. Please contact system administrator for more details.";
|
||||
|
||||
public BackendException() {
|
||||
super(ERROR_MESSAGE, null, false, false);
|
||||
}
|
||||
}
|
|
@ -1,16 +1,20 @@
|
|||
package tomcat.request.session.redis;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import org.apache.catalina.connector.Request;
|
||||
import org.apache.catalina.connector.Response;
|
||||
import org.apache.catalina.valves.ValveBase;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import tomcat.request.session.exception.BackendException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import java.io.IOException;
|
||||
|
||||
/** author: Ranjith Manickam @ 12 Jul' 2018 */
|
||||
public class SessionHandlerValve extends ValveBase {
|
||||
|
||||
private static final Log LOGGER = LogFactory.getLog(SessionHandlerValve.class);
|
||||
|
||||
private SessionManager manager;
|
||||
|
||||
/** To set session manager */
|
||||
|
@ -23,6 +27,9 @@ public class SessionHandlerValve extends ValveBase {
|
|||
public void invoke(Request request, Response response) throws IOException, ServletException {
|
||||
try {
|
||||
getNext().invoke(request, response);
|
||||
} catch (IOException | ServletException | RuntimeException ex) {
|
||||
LOGGER.error("Error processing request", ex);
|
||||
new BackendException();
|
||||
} finally {
|
||||
manager.afterRequest(request);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#- redis hosts ex: 127.0.0.1:6379, 127.0.0.2:6379, 127.0.0.2:6380, ....
|
||||
redis.hosts=127.0.0.1:6379
|
||||
|
||||
#- redis password (used for default and sentinel mode)
|
||||
#- redis password
|
||||
#redis.password=
|
||||
|
||||
#- set true to enable redis cluster mode
|
||||
|
|
Loading…
Reference in New Issue