@Override protected void startInternal() throws LifecycleException { super.startInternal(); redisson = buildClient(); getEngine().getPipeline().addValve(new UpdateValve(this)); RTopic updatesTopic = getTopic(); updatesTopic.addListener(AttributeMessage.class, new MessageListener<AttributeMessage>() { setState(LifecycleState.STARTING);
@Override public Session createSession(String sessionId) { RedissonSession session = (RedissonSession) createEmptySession(); session.setNew(true); session.setValid(true); session.setCreationTime(System.currentTimeMillis()); session.setMaxInactiveInterval(getContext().getSessionTimeout() * 60); if (sessionId == null) { sessionId = generateSessionId(); } session.setManager(this); session.setId(sessionId); return session; }
@Override protected void stopInternal() throws LifecycleException { super.stopInternal(); setState(LifecycleState.STOPPING); try { shutdownRedisson(); } catch (Exception e) { throw new LifecycleException(e); } }
@Override public Session createSession(String sessionId) { RedissonSession session = (RedissonSession) createEmptySession(); session.setNew(true); session.setValid(true); session.setCreationTime(System.currentTimeMillis()); session.setMaxInactiveInterval(((Context) getContainer()).getSessionTimeout() * 60); if (sessionId == null) { sessionId = generateSessionId(); } session.setManager(this); session.setId(sessionId); return session; }
@Override public void invoke(Request request, Response response) throws IOException, ServletException { String sessionId = request.getRequestedSessionId(); Session session = request.getContext().getManager().findSession(sessionId); if (session != null) { if (!session.isValid()) { session.expire(); request.getContext().getManager().remove(session); } else { manager.add(session); session.access(); session.endAccess(); } } try { getNext().invoke(request, response); } finally { manager.store(request.getSession(false)); } }
try { if (readMode == ReadMode.MEMORY) { attrs = getMap(id).readAllMap(); } else { attrs = getMap(id).getAll(RedissonSession.ATTRS); RedissonSession session = (RedissonSession) createEmptySession(); session.setId(id); session.setManager(this);
@Override public void start() throws LifecycleException { redisson = buildClient(); getEngine().getPipeline().addValve(new UpdateValve(this)); RTopic updatesTopic = getTopic(); updatesTopic.addListener(AttributeMessage.class, new MessageListener<AttributeMessage>() {
protected AttributesPutAllMessage createPutAllMessage(Map<String, Object> newMap) { Map<String, Object> map = new HashMap<String, Object>(); for (Entry<String, Object> entry : newMap.entrySet()) { map.put(entry.getKey(), entry.getValue()); } try { return new AttributesPutAllMessage(redissonManager.getNodeId(), getId(), map); } catch (IOException e) { throw new IllegalStateException(e); } }
public RedissonSession(RedissonSessionManager manager, RedissonSessionManager.ReadMode readMode, UpdateMode updateMode) { super(manager); this.redissonManager = manager; this.readMode = readMode; this.updateMode = updateMode; this.topic = redissonManager.getTopic(); try { Field attr = StandardSession.class.getDeclaredField("attributes"); attrs = (Map<String, Object>) attr.get(this); } catch (Exception e) { throw new IllegalStateException(e); } }
public void save() { if (map == null) { map = redissonManager.getMap(id); } Map<String, Object> newMap = new HashMap<String, Object>(); newMap.put(CREATION_TIME_ATTR, creationTime); newMap.put(LAST_ACCESSED_TIME_ATTR, lastAccessedTime); newMap.put(THIS_ACCESSED_TIME_ATTR, thisAccessedTime); newMap.put(MAX_INACTIVE_INTERVAL_ATTR, maxInactiveInterval); newMap.put(IS_VALID_ATTR, isValid); newMap.put(IS_NEW_ATTR, isNew); if (attrs != null) { for (Entry<String, Object> entry : attrs.entrySet()) { newMap.put(entry.getKey(), entry.getValue()); } } map.putAll(newMap); if (readMode == ReadMode.MEMORY) { topic.publish(createPutAllMessage(newMap)); } expireSession(); }
@Override public void stop() throws LifecycleException { try { shutdownRedisson(); } catch (Exception e) { throw new LifecycleException(e); } lifecycle.fireLifecycleEvent(STOP_EVENT, null); }
@Override public void invoke(Request request, Response response) throws IOException, ServletException { String sessionId = request.getRequestedSessionId(); Session session = request.getContext().getManager().findSession(sessionId); if (session != null) { if (!session.isValid()) { session.expire(); request.getContext().getManager().remove(session); } else { manager.add(session); session.access(); session.endAccess(); } } try { getNext().invoke(request, response); } finally { manager.store(request.getSession(false)); } }
try { if (readMode == ReadMode.MEMORY) { attrs = getMap(id).readAllMap(); } else { attrs = getMap(id).getAll(RedissonSession.ATTRS); RedissonSession session = (RedissonSession) createEmptySession(); session.setId(id); session.setManager(this);
protected AttributesPutAllMessage createPutAllMessage(Map<String, Object> newMap) { Map<String, Object> map = new HashMap<String, Object>(); for (Entry<String, Object> entry : newMap.entrySet()) { map.put(entry.getKey(), entry.getValue()); } try { return new AttributesPutAllMessage(redissonManager.getNodeId(), getId(), map); } catch (IOException e) { throw new IllegalStateException(e); } }
@Override public Session createSession(String sessionId) { RedissonSession session = (RedissonSession) createEmptySession(); session.setNew(true); session.setValid(true); session.setCreationTime(System.currentTimeMillis()); session.setMaxInactiveInterval(((Context) getContainer()).getSessionTimeout() * 60); if (sessionId == null) { sessionId = generateSessionId(); } session.setManager(this); session.setId(sessionId); return session; }
@Override protected void stopInternal() throws LifecycleException { super.stopInternal(); setState(LifecycleState.STOPPING); try { shutdownRedisson(); } catch (Exception e) { throw new LifecycleException(e); } }
public RedissonSession(RedissonSessionManager manager, RedissonSessionManager.ReadMode readMode, UpdateMode updateMode) { super(manager); this.redissonManager = manager; this.readMode = readMode; this.updateMode = updateMode; this.topic = redissonManager.getTopic(); try { Field attr = StandardSession.class.getDeclaredField("attributes"); attrs = (Map<String, Object>) attr.get(this); } catch (Exception e) { throw new IllegalStateException(e); } }
public void save() { if (map == null) { map = redissonManager.getMap(id); } Map<String, Object> newMap = new HashMap<String, Object>(); newMap.put(CREATION_TIME_ATTR, creationTime); newMap.put(LAST_ACCESSED_TIME_ATTR, lastAccessedTime); newMap.put(THIS_ACCESSED_TIME_ATTR, thisAccessedTime); newMap.put(MAX_INACTIVE_INTERVAL_ATTR, maxInactiveInterval); newMap.put(IS_VALID_ATTR, isValid); newMap.put(IS_NEW_ATTR, isNew); if (attrs != null) { for (Entry<String, Object> entry : attrs.entrySet()) { newMap.put(entry.getKey(), entry.getValue()); } } map.putAll(newMap); if (readMode == ReadMode.MEMORY) { topic.publish(createPutAllMessage(newMap)); } expireSession(); }
@Override protected void startInternal() throws LifecycleException { super.startInternal(); redisson = buildClient(); getEngine().getPipeline().addValve(new UpdateValve(this)); RTopic updatesTopic = getTopic(); updatesTopic.addListener(AttributeMessage.class, new MessageListener<AttributeMessage>() { setState(LifecycleState.STARTING);