@Override public String getRegionAttributesId() { // This property will be null if it hasn't been set in the context.xml file. // Since its default is dependent on the session cache, get the default from // the session cache. if (this.regionAttributesId == null) { this.regionAttributesId = getSessionCache().getDefaultRegionAttributesId(); } return this.regionAttributesId; }
@Override public boolean getEnableLocalCache() { // This property will be null if it hasn't been set in the context.xml file. // Since its default is dependent on the session cache, get the default from // the session cache. if (this.enableLocalCache == null) { this.enableLocalCache = getSessionCache().getDefaultEnableLocalCache(); } return this.enableLocalCache; }
/** * Returns the number of active sessions * * @return number of sessions active */ @Override public int getActiveSessions() { return getSessionCache().size(); }
public boolean isClientServer() { return getSessionCache().isClientServer(); }
public DeltaSessionStatistics getStatistics() { return getSessionCache().getStatistics(); }
public boolean isPeerToPeer() { return getSessionCache().isPeerToPeer(); }
/** * For debugging: return a list of all session ids currently active */ @Override public String listSessionIds() { StringBuilder builder = new StringBuilder(); Iterator<String> sessionIds = getSessionCache().keySet().iterator(); while (sessionIds.hasNext()) { builder.append(sessionIds.next()); if (sessionIds.hasNext()) { builder.append(" "); } } return builder.toString(); }
@Override public void run() { // Get the sessionIds to touch and clear the set inside synchronization Set<String> sessionIds = null; sessionIds = new HashSet<String>(getSessionsToTouch()); getSessionsToTouch().clear(); // Touch the sessions we currently have if (!sessionIds.isEmpty()) { getSessionCache().touchSessions(sessionIds); if (getLogger().isDebugEnabled()) { getLogger().debug(DeltaSessionManager.this + ": Touched sessions: " + sessionIds); } } } };
@Override public void add(Session session) { // super.add(session); if (getLogger().isDebugEnabled()) { getLogger().debug(this + ": Storing session " + session.getId() + " into " + getSessionCache().getOperatingRegionName()); } getSessionCache().putSession(session); if (getLogger().isDebugEnabled()) { getLogger().debug(this + ": Stored session " + session.getId() + " into " + getSessionCache().getOperatingRegionName()); } getSessionCache().getStatistics().incSessionsCreated(); }
public static void setupServer(DeltaSessionManager manager) throws Exception { FileUtils.copyDirectory(Paths.get("..", "resources", "integrationTest", "tomcat").toFile(), new File("./tomcat")); port = AvailablePortHelper.getRandomAvailableTCPPort(); server = new EmbeddedTomcat("/test", port, "JVM-1"); PeerToPeerCacheLifecycleListener p2pListener = new PeerToPeerCacheLifecycleListener(); p2pListener.setProperty(MCAST_PORT, "0"); p2pListener.setProperty(LOG_LEVEL, "config"); server.getEmbedded().addLifecycleListener(p2pListener); sessionManager = manager; sessionManager.setEnableCommitValve(true); server.getRootContext().setManager(sessionManager); servlet = server.addServlet("/test/*", "default", CommandServlet.class.getName()); server.startContainer(); /* * Can only retrieve the region once the container has started up (and the cache has started * too). */ region = sessionManager.getSessionCache().getSessionRegion(); }
private void initializeRegion(DeltaSessionManager sessionManager) { // Get the session region name this.sessionRegionName = sessionManager.getRegionName(); // Get the operating region. // If a P2P manager is used, then this will be a local region fronting the // session region if local cache is enabled; otherwise, it will be the // session region itself. // If a CS manager is used, it will be the session proxy region. this.operatingRegion = sessionManager.getSessionCache().getOperatingRegion(); if (sessionManager.getLogger().isDebugEnabled()) { sessionManager.getLogger().debug(this + ": Set operating region: " + this.operatingRegion); } }
@Override public void run() { int currentActiveSessions = getSessionCache().size(); if (currentActiveSessions > getMaxActive()) { setMaxActive(currentActiveSessions); if (getLogger().isDebugEnabled()) { getLogger().debug( DeltaSessionManager.this + ": Set max active sessions: " + currentActiveSessions); } } } };
public void remove(Session session, boolean update) { // super.remove(session); // Remove the session from the region if necessary. // It will have already been removed if it expired implicitly. DeltaSessionInterface ds = (DeltaSessionInterface) session; if (ds.getExpired()) { if (getLogger().isDebugEnabled()) { getLogger().debug(this + ": Expired session " + session.getId() + " from " + getSessionCache().getOperatingRegionName()); } } else { if (getLogger().isDebugEnabled()) { getLogger().debug(this + ": Destroying session " + session.getId() + " from " + getSessionCache().getOperatingRegionName()); } getSessionCache().destroySession(session.getId()); if (getLogger().isDebugEnabled()) { getLogger().debug(this + ": Destroyed session " + session.getId() + " from " + getSessionCache().getOperatingRegionName()); } } }
this + ": Finding session " + id + " in " + getSessionCache().getOperatingRegionName()); DeltaSessionInterface session = (DeltaSessionInterface) getSessionCache().getSession(id); if (getLogger().isDebugEnabled()) { getLogger().debug(this + ": Did not find session " + id + " in " + getSessionCache().getOperatingRegionName()); + getSessionCache().getOperatingRegionName() + ": " + session);
if (getSessionCache().isClientServer()) { for (DeltaSessionInterface session : list) { if (getLogger().isDebugEnabled()) { getLogger().debug("Locally destroying session " + session.getId()); getSessionCache().getOperatingRegion().localDestroy(session.getId());
session.setManager(this); Region region = getSessionCache().getOperatingRegion(); DeltaSessionInterface existingSession = (DeltaSessionInterface) region.get(session.getId());
@Override public String getRegionAttributesId() { // This property will be null if it hasn't been set in the context.xml file. // Since its default is dependent on the session cache, get the default from // the session cache. if (this.regionAttributesId == null) { this.regionAttributesId = getSessionCache().getDefaultRegionAttributesId(); } return this.regionAttributesId; }
@Override public boolean getEnableLocalCache() { // This property will be null if it hasn't been set in the context.xml file. // Since its default is dependent on the session cache, get the default from // the session cache. if (this.enableLocalCache == null) { this.enableLocalCache = getSessionCache().getDefaultEnableLocalCache(); } return this.enableLocalCache; }
/** * Returns the number of active sessions * * @return number of sessions active */ @Override public int getActiveSessions() { return getSessionCache().size(); }
@Override public void run() { int currentActiveSessions = getSessionCache().size(); if (currentActiveSessions > getMaxActive()) { setMaxActive(currentActiveSessions); if (getLogger().isDebugEnabled()) { getLogger().debug( DeltaSessionManager.this + ": Set max active sessions: " + currentActiveSessions); } } } };