/** * Persist the time the session was last accessed. * * @param data the session * @throws Exception */ private void updateSessionAccessTime (Session data) throws Exception { try (Connection connection = getConnection(); PreparedStatement statement = connection.prepareStatement(_jdbcSessionIdMgr._updateSessionAccessTime)) { long now = System.currentTimeMillis(); connection.setAutoCommit(true); statement.setString(1, getSessionIdManager().getWorkerName()); statement.setLong(2, data.getAccessed()); statement.setLong(3, data.getLastAccessedTime()); statement.setLong(4, now); statement.setLong(5, data.getExpiryTime()); statement.setLong(6, data.getMaxInactiveInterval()); statement.setString(7, data.getRowId()); statement.executeUpdate(); data.setLastSaved(now); } if (LOG.isDebugEnabled()) LOG.debug("Updated access time session id="+data.getId()+" with lastsaved="+data.getLastSaved()); }
/** * Update the node on which the session was last seen to be my node. * * @param data the session * @throws Exception if unable to update the session node */ protected void updateSessionNode (Session data) throws Exception { String nodeId = getSessionIdManager().getWorkerName(); try (Connection connection = getConnection(); PreparedStatement statement = connection.prepareStatement(_jdbcSessionIdMgr._updateSessionNode)) { connection.setAutoCommit(true); statement.setString(1, nodeId); statement.setString(2, data.getRowId()); statement.executeUpdate(); } if (LOG.isDebugEnabled()) LOG.debug("Updated last node for session id="+data.getId()+", lastNode = "+nodeId); }
/** * Persist the time the session was last accessed. * * @param data the session * @throws Exception */ private void updateSessionAccessTime (Session data) throws Exception { try (Connection connection = getConnection(); PreparedStatement statement = connection.prepareStatement(_jdbcSessionIdMgr._updateSessionAccessTime)) { long now = System.currentTimeMillis(); connection.setAutoCommit(true); statement.setString(1, getSessionIdManager().getWorkerName()); statement.setLong(2, data.getAccessed()); statement.setLong(3, data.getLastAccessedTime()); statement.setLong(4, now); statement.setLong(5, data.getExpiryTime()); statement.setLong(6, data.getMaxInactiveInterval()); statement.setString(7, data.getRowId()); statement.executeUpdate(); data.setLastSaved(now); } if (LOG.isDebugEnabled()) LOG.debug("Updated access time session id="+data.getId()+" with lastsaved="+data.getLastSaved()); }
LOG.warn("Problem persisting changed session data id="+getId(), e);
LOG.warn("Problem persisting changed session data id="+getId(), e);
/** * Update the node on which the session was last seen to be my node. * * @param data the session * @throws Exception */ protected void updateSessionNode (Session data) throws Exception { String nodeId = getSessionIdManager().getWorkerName(); try (Connection connection = getConnection(); PreparedStatement statement = connection.prepareStatement(_jdbcSessionIdMgr._updateSessionNode)) { connection.setAutoCommit(true); statement.setString(1, nodeId); statement.setString(2, data.getRowId()); statement.executeUpdate(); } if (LOG.isDebugEnabled()) LOG.debug("Updated last node for session id="+data.getId()+", lastNode = "+nodeId); }
/** * Calculate a unique id for this session across the cluster. * * Unique id is composed of: contextpath_virtualhost0_sessionid * @param data * @return */ private String calculateRowId (Session data) { String rowId = canonicalize(_context.getContextPath()); rowId = rowId + "_" + getVirtualHost(_context); rowId = rowId+"_"+data.getId(); return rowId; }
/** * Calculate a unique id for this session across the cluster. * * Unique id is composed of: contextpath_virtualhost0_sessionid * @param data * @return */ private String calculateRowId (Session data) { String rowId = canonicalize(_context.getContextPath()); rowId = rowId + "_" + getVirtualHost(_context); rowId = rowId+"_"+data.getId(); return rowId; }
/** * Calculate a unique id for this session across the cluster. * * Unique id is composed of: contextpath_virtualhost0_sessionid * @param data * @return */ private String calculateRowId (Session data) { String rowId = canonicalize(_context.getContextPath()); rowId = rowId + "_" + getVirtualHost(_context); rowId = rowId+"_"+data.getId(); return rowId; }
/** * Calculate a unique id for this session across the cluster. * * Unique id is composed of: contextpath_virtualhost0_sessionid * @param data * @return */ private String calculateRowId (Session data) { String rowId = canonicalize(_context.getContextPath()); rowId = rowId + "_" + getVirtualHost(_context); rowId = rowId+"_"+data.getId(); return rowId; }
/** * Calculate a unique id for this session across the cluster. * * Unique id is composed of: contextpath_virtualhost0_sessionid * @param data * @return */ private String calculateRowId (Session data) { String rowId = canonicalize(_context.getContextPath()); rowId = rowId + "_" + getVirtualHost(_context); rowId = rowId+"_"+data.getId(); return rowId; }
/** * Calculate a unique id for this session across the cluster. * * Unique id is composed of: contextpath_virtualhost0_sessionid * @param data * @return */ private String calculateRowId (Session data) { String rowId = canonicalize(_context.getContextPath()); rowId = rowId + "_" + getVirtualHost(_context); rowId = rowId+"_"+data.getId(); return rowId; }
@Override public String toString () { return "Session rowId="+_rowId+",id="+getId()+",lastNode="+_lastNode+ ",created="+getCreationTime()+",accessed="+getAccessed()+ ",lastAccessed="+getLastAccessedTime()+",cookieSet="+_cookieSet+ ",maxInterval="+getMaxInactiveInterval()+",lastSaved="+_lastSaved+",expiry="+_expiryTime; } }
/** * Calculate a unique id for this session across the cluster. * * Unique id is composed of: contextpath_virtualhost0_sessionid * @param data * @return */ private String calculateRowId (Session data) { String rowId = canonicalize(_context.getContextPath()); rowId = rowId + "_" + getVirtualHost(_context); rowId = rowId+"_"+data.getId(); return rowId; }
@Override public String toString () { return "Session rowId="+_rowId+",id="+getId()+",lastNode="+_lastNode+ ",created="+getCreationTime()+",accessed="+getAccessed()+ ",lastAccessed="+getLastAccessedTime()+",cookieSet="+_cookieSet+ ",lastSaved="+_lastSaved+",expiry="+_expiryTime; } }
@Override public String toString () { return "Session rowId="+_rowId+",id="+getId()+",lastNode="+_lastNode+ ",created="+getCreationTime()+",accessed="+getAccessed()+ ",lastAccessed="+getLastAccessedTime()+",cookieSet="+_cookieSet+ ",lastSaved="+_lastSaved+",expiry="+_expiryTime; } }
@Override public String toString () { return "Session rowId="+_rowId+",id="+getId()+",lastNode="+_lastNode+ ",created="+getCreationTime()+",accessed="+getAccessed()+ ",lastAccessed="+getLastAccessedTime()+",cookieSet="+getCookieSetTime()+ ",maxInterval="+getMaxInactiveInterval()+",lastSaved="+_lastSaved+",expiry="+_expiryTime; } }
@Override public String toString () { return "Session rowId="+_rowId+",id="+getId()+",lastNode="+_lastNode+ ",created="+getCreationTime()+",accessed="+getAccessed()+ ",lastAccessed="+getLastAccessedTime()+",cookieSet="+_cookieSet+ ",lastSaved="+_lastSaved+",expiry="+_expiryTime; } }
@Override public String toString () { return "Session rowId="+_rowId+",id="+getId()+",lastNode="+_lastNode+ ",created="+getCreationTime()+",accessed="+getAccessed()+ ",lastAccessed="+getLastAccessedTime()+",cookieSet="+_cookieSet+ ",lastSaved="+_lastSaved+",expiry="+_expiryTime; } }
@Override public String toString () { return "Session rowId="+_rowId+",id="+getId()+",lastNode="+_lastNode+ ",created="+getCreationTime()+",accessed="+getAccessed()+ ",lastAccessed="+getLastAccessedTime()+",cookieSet="+_cookieSet+ ",lastSaved="+_lastSaved+",expiry="+_expiryTime; } }