public void updatePassivationStats(String ctx, long elapsed) { TimeStatistic stat = getTimeStatistic(ctx); stat.totalPassivationTime += elapsed; if( stat.minPassivationTime > elapsed ) stat.minPassivationTime = elapsed; if( stat.maxPassivationTime < elapsed ) stat.maxPassivationTime = elapsed; }
private TimeStatistic getTimeStatistic(String ctx) { TimeStatistic stat = (TimeStatistic) ctxStats.get(ctx); if( stat == null ) { stat = new TimeStatistic(); ctxStats.put(ctx, stat); } return stat; }
/** Resets all current TimeStatistics. * */ public void resetStats() { synchronized( ctxStats ) { for(TimeStatistic stat: ctxStats.values()) { stat.reset(); } } lastResetTime = System.currentTimeMillis(); }
public boolean storeSession(Session baseSession) { boolean stored = false; if (baseSession != null && started_) { ClusteredSession session = (ClusteredSession) baseSession; synchronized (session) { if (logger.isDebugEnabled()) { log_.debug("check to see if needs to store and replicate " + "session with id " + session.getIdInternal()); } if (session.isValid() && (session.isSessionDirty() || session .getExceedsMaxUnreplicatedInterval())) { String realId = session.getRealId(); // Notify all session attributes that they get serialized // (SRV 7.7.2) long begin = System.currentTimeMillis(); session.passivate(); long elapsed = System.currentTimeMillis() - begin; stats_.updatePassivationStats(realId, elapsed); // Do the actual replication begin = System.currentTimeMillis(); processSessionRepl(session); elapsed = System.currentTimeMillis() - begin; stored = true; stats_.updateReplicationStats(realId, elapsed); } } } return stored; }
private void bruteForceCleanup(String realId, Exception ex) { log_.warn("Standard expiration of session " + realId + " failed; switching to a brute " + "force cleanup. Problem is" + ex.getLocalizedMessage()); try { proxy_.removeSessionLocal(realId, null); } catch (Exception e) { log_.error("processExpirationPassivation(): Caught exception " + "during brute force cleanup of unloaded session " + realId + " session will be removed from Manager " + "but may still exist in distributed cache", e); } finally { // Get rid of our refs even if distributed store fails unloadedSessions_.remove(realId); stats_.removeStats(realId); } }
/** Update the TimeStatistic for the given ctx. This does not synchronize * on the TimeStatistic so the results are an approximate values. * * @param ctx the method to update the statistics for. * @param elapsed the elapsed time in milliseconds for the invocation. */ public void updateStats(String ctx, long elapsed) { TimeStatistic stat = (TimeStatistic) ctxStats.get(ctx); if( stat == null ) { stat = new TimeStatistic(); ctxStats.put(ctx, stat); } stat.count ++; stat.totalTime += elapsed; if( stat.minTime > elapsed ) stat.minTime = elapsed; if( stat.maxTime < elapsed ) stat.maxTime = elapsed; }
/** Resets all current TimeStatistics. * */ public void resetStats() { synchronized( ctxStats ) { for(TimeStatistic stat : ctxStats.values()) { stat.reset(); } } maxConcurrentCalls = 0; lastResetTime = System.currentTimeMillis(); }
/** * {@inheritDoc} */ public void resetStats() { stats_.resetStats(); maxActiveCounter_.set(localActiveCounter_.get()); rejectedCounter_.set(0); createdCounter_.set(0); expiredCounter_.set(0); processingTime_.set(0); maxAliveTime.set(0); averageAliveTime.set(0); duplicates_.set(0); timeSinceLastReset_ = System.currentTimeMillis(); }
Map<String, ReplicationStatistics.TimeStatistic> stats = stats_.getStats(); ReplicationStatistics.TimeStatistic stat = (ReplicationStatistics.TimeStatistic) stats.get(sessionId);
session.passivate(); long elapsed = System.currentTimeMillis() - begin; stats_.updatePassivationStats(realId, elapsed); elapsed = System.currentTimeMillis() - begin; stored = true; stats_.updateReplicationStats(realId, elapsed);
public void updateLoadStats(String ctx, long elapsed) { TimeStatistic stat = getTimeStatistic(ctx); stat.loadCount ++; stat.totalLoadlTime += elapsed; if( stat.minLoadTime > elapsed ) stat.minLoadTime = elapsed; if( stat.maxLoadTime < elapsed ) stat.maxLoadTime = elapsed; }
session.notifyWillPassivate(ClusteredSessionNotificationCause.REPLICATION); long elapsed = System.currentTimeMillis() - begin; stats_.updatePassivationStats(realId, elapsed); elapsed = System.currentTimeMillis() - begin; stored = true; stats_.updateReplicationStats(realId, elapsed);
/** * Removes the session from this Manager's collection of actively managed * sessions. Also removes the session from the distributed cache, both on * this server and on all other server to which this one replicates. */ public void remove(Session session) { ClusteredSession clusterSess = (ClusteredSession) session; synchronized (clusterSess) { String realId = clusterSess.getRealId(); if (realId == null) return; if (log_.isDebugEnabled()) { log_.debug("Removing session from store with id: " + realId); } try { // Ignore any cache notifications that our own work generates ConvergedSessionReplicationContext.startCacheActivity(); clusterSess.removeMyself(); } finally { ConvergedSessionReplicationContext.finishCacheActivity(); // We don't want to replicate this session at the end // of the request; the removal process took care of that ConvergedSessionReplicationContext.sessionExpired(clusterSess, realId, snapshotManager_); sessions_.remove(realId); stats_.removeStats(realId); activeCounter_--; } } }
/** Update the TimeStatistic for the given ctx. This does not synchronize * on the TimeStatistic so the results are an approximate values. * * @param ctx the method to update the statistics for. * @param elapsed the elapsed time in milliseconds for the invocation. */ public void updateReplicationStats(String ctx, long elapsed) { TimeStatistic stat = getTimeStatistic(ctx); stat.replicationCount ++; stat.totalReplicationlTime += elapsed; if( stat.minReplicationTime > elapsed ) stat.minReplicationTime = elapsed; if( stat.maxReplicationTime < elapsed ) stat.maxReplicationTime = elapsed; }
/** * {@inheritDoc} */ public MobicentsSipSession removeSipSession(final MobicentsSipSessionKey key) { ClusteredSipSession clusterSess = (ClusteredSipSession) sipManagerDelegate.removeSipSession(key); if(clusterSess == null) { return null; } synchronized (clusterSess) { final String realId = clusterSess.getId(); if (log_.isDebugEnabled()) { log_.debug("Removing session from store with id: " + realId); } try { // Ignore any cache notifications that our own work generates ConvergedSessionReplicationContext.startSipCacheActivity(); clusterSess.removeMyself(); } finally { ConvergedSessionReplicationContext.finishSipCacheActivity(); // We don't want to replicate this session at the end // of the request; the removal process took care of that ConvergedSessionReplicationContext.sipSessionExpired(clusterSess, realId, snapshotManager_); stats_.removeStats(realId); activeCounter_--; } } return clusterSess; }
/** * {@inheritDoc} */ public MobicentsSipApplicationSession removeSipApplicationSession( final MobicentsSipApplicationSessionKey key) { ClusteredSipApplicationSession clusterSess = (ClusteredSipApplicationSession) sipManagerDelegate.removeSipApplicationSession(key); if(clusterSess == null) { return null; } synchronized (clusterSess) { final String realId = clusterSess.getId(); if (log_.isDebugEnabled()) { log_.debug("Removing session from store with id: " + realId); } try { // Ignore any cache notifications that our own work generates ConvergedSessionReplicationContext.startSipCacheActivity(); clusterSess.removeMyself(); } finally { ConvergedSessionReplicationContext.finishSipCacheActivity(); // We don't want to replicate this session at the end // of the request; the removal process took care of that ConvergedSessionReplicationContext.sipApplicationSessionExpired(clusterSess, realId, snapshotManager_); stats_.removeStats(realId); activeCounter_--; } } return clusterSess; }