@Override public Log getLogger() { if (LOGGER == null) { LOGGER = LogFactory.getLog(DeltaSessionManager.class); } return LOGGER; }
public CommitSessionValve() { log.info("Initialized"); }
protected void unregisterJvmRouteBinderValve() { if (getLogger().isDebugEnabled()) { getLogger().debug(this + ": Unregistering JVM route binder valve"); } if (jvmRouteBinderValve != null) { getPipeline().removeValve(jvmRouteBinderValve); } }
public Context getTheContext() { if (getContainer() instanceof Context) { return (Context) getContainer(); } else { getLogger().error("Unable to unload sessions - container is of type " + getContainer().getClass().getName() + " instead of StandardContext"); return null; } } }
protected byte[] serialize(Object obj) { byte[] serializedValue = null; try { serializedValue = BlobHelper.serializeToBlob(obj); } catch (IOException e) { StringBuilder builder = new StringBuilder(); builder.append(this).append(": Object ").append(obj) .append(" cannot be serialized due to the following exception"); ((DeltaSessionManager) getManager()).getLogger().warn(builder.toString(), e); } return serializedValue; }
@Override public void initialize() { // Bootstrap the servers bootstrapServers(); // Create or retrieve the region try { createOrRetrieveRegion(); } catch (Exception ex) { sessionManager.getLogger().fatal("Unable to create or retrieve region", ex); throw new IllegalStateException(ex); } // Set the session region directly as the operating region since there is no difference // between the local cache region and the session region. this.operatingRegion = this.sessionRegion; // Create or retrieve the statistics createStatistics(); }
protected void unregisterCommitSessionValve() { if (getLogger().isDebugEnabled()) { getLogger().debug(this + ": Unregistering CommitSessionValve"); } if (commitSessionValve != null) { getPipeline().removeValve(commitSessionValve); } }
protected void logError(Exception e) { if (getManager() != null) { DeltaSessionManager mgr = (DeltaSessionManager) getManager(); mgr.getLogger().error(e); } }
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); } }
protected RedissonClient buildClient() throws LifecycleException { Config config = null; try { config = Config.fromJSON(new File(configPath), getClass().getClassLoader()); } catch (IOException e) { // trying next format try { config = Config.fromYAML(new File(configPath), getClass().getClassLoader()); } catch (IOException e1) { log.error("Can't parse json config " + configPath, e); throw new LifecycleException("Can't parse yaml config " + configPath, e1); } } try { return Redisson.create(config); } catch (Exception e) { throw new LifecycleException(e); } }
protected void registerJvmRouteBinderValve() { if (getLogger().isDebugEnabled()) { getLogger().debug(this + ": Registering JVM route binder valve"); } jvmRouteBinderValve = new JvmRouteBinderValve(); getPipeline().addValve(jvmRouteBinderValve); }
protected RedissonClient buildClient() throws LifecycleException { Config config = null; try { config = Config.fromJSON(new File(configPath), getClass().getClassLoader()); } catch (IOException e) { // trying next format try { config = Config.fromYAML(new File(configPath), getClass().getClassLoader()); } catch (IOException e1) { log.error("Can't parse json config " + configPath, e); throw new LifecycleException("Can't parse yaml config " + configPath, e1); } } try { return Redisson.create(config); } catch (Exception e) { throw new LifecycleException(e); } }
@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); } } } };
protected RedissonClient buildClient() throws LifecycleException { Config config = null; try { config = Config.fromJSON(new File(configPath), getClass().getClassLoader()); } catch (IOException e) { // trying next format try { config = Config.fromYAML(new File(configPath), getClass().getClassLoader()); } catch (IOException e1) { log.error("Can't parse json config " + configPath, e); throw new LifecycleException("Can't parse yaml config " + configPath, e1); } } try { return Redisson.create(config); } catch (Exception e) { throw new LifecycleException(e); } }
protected void registerCommitSessionValve() { if (getLogger().isDebugEnabled()) { getLogger().debug(this + ": Registering CommitSessionValve"); } commitSessionValve = new CommitSessionValve(); getPipeline().addValve(commitSessionValve); }
@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); } } } };
private byte[] getSerializedPrincipal() { if (this.serializedPrincipal == null) { if (this.principal != null && this.principal instanceof GenericPrincipal) { GenericPrincipal gp = (GenericPrincipal) this.principal; SerializablePrincipal sp = SerializablePrincipal.createPrincipal(gp); this.serializedPrincipal = serialize(sp); if (manager != null) { DeltaSessionManager mgr = (DeltaSessionManager) getManager(); if (mgr.getLogger().isDebugEnabled()) { mgr.getLogger().debug(this + ": Serialized principal: " + sp); // mgr.logCurrentStack(); } } } } return this.serializedPrincipal; }
@Override public void setPrincipal(Principal principal) { super.setPrincipal(principal); // Put the session into the region to serialize the principal if (getManager() != null) { // TODO convert this to a delta getManager().add(this); DeltaSessionManager mgr = (DeltaSessionManager) getManager(); if (mgr.getLogger().isDebugEnabled()) { mgr.getLogger().debug(this + ": Cached principal: " + principal); // mgr.logCurrentStack(); } } }
@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(); }