/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) Ericsson AB, 2004-2008. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can obtain
* a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
* or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
* Sun designates this particular file as subject to the "Classpath" exception
* as provided by Sun in the GPL Version 2 section of the License file that
* accompanied this code. If applicable, add the following below the License
* Header, with the fields enclosed by brackets [] replaced by your own
* identifying information: "Portions Copyrighted [year]
* [name of copyright owner]"
*
* Contributor(s):
*
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package org.jvnet.glassfish.comms.replication.sessmgmt;
import com.ericsson.ssa.sip.RemoteLockException;
import com.ericsson.ssa.sip.SipApplicationSessionUtil;
import com.ericsson.ssa.sip.SipSessionManager;
import com.ericsson.ssa.sip.timer.ServletTimerImpl;
import com.ericsson.ssa.sip.timer.ServletTimerStore;
import com.sun.appserv.ha.spi.BackingStore;
import com.sun.appserv.ha.spi.BackingStoreException;
import com.sun.appserv.ha.util.SimpleMetadata;
import com.sun.appserv.ha.util.SimpleMetadataFactory;
import com.sun.appserv.ha.uow.ReplicableEntity;
import com.sun.appserv.util.cache.BaseCache;
import com.sun.enterprise.web.ServerConfigLookup;
import com.sun.enterprise.ee.web.sessmgmt.ExpatListElement;
import com.sun.enterprise.ee.web.sessmgmt.JxtaBackingStoreImpl;
import com.sun.enterprise.ee.web.sessmgmt.JxtaReplicationSender;
import com.sun.enterprise.ee.web.sessmgmt.ReplicationUtil;
import com.sun.enterprise.ee.web.sessmgmt.ReplicationState;
import com.sun.enterprise.ee.web.sessmgmt.StorePoolElement;
import com.sun.enterprise.ee.web.sessmgmt.SessionStoreInterface;
import java.io.*;
import java.util.logging.Level;
import java.util.zip.GZIPInputStream;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.catalina.*;
import org.apache.catalina.session.IOUtilsCaller;
/**
* @author lwhite
*/
public class ServletTimerStoreImpl extends SipStoreBase
implements StorePoolElement, ServletTimerStore, SessionStoreInterface {
public final static String BEKEY
= ReplicationState.BEKEY;
private static boolean useReplicationUnicastLoadBatching = false;
static {
ServerConfigLookup lookup = new ServerConfigLookup();
useReplicationUnicastLoadBatching
= lookup.isReplicationUnicastLoadBatchingEnabled();
}
/**
* gets the BackingStore used for replicating ServletTimers
*
* @return the BackingStore initialized for ServletTimers
*
*/
protected BackingStore getBackingStore() {
SipTransactionPersistentManager mgr
= (SipTransactionPersistentManager)this.getSipSessionManager();
return mgr.getServletTimerBackingStore();
}
/**
* Loads and returns the ServletTimer with the given id from
* this store.
*
* @param id The id of the ServletTimer to load
*
* @return The ServletTimer with the given id, or null if not
* found
*
* @throws IOException
*/
public ServletTimerImpl load(String id, boolean loadDependencies)
throws IOException, RemoteLockException {
return load(id, null, loadDependencies);
}
public ServletTimerImpl load(String id, String version,
boolean loadDependencies)
throws IOException, RemoteLockException {
try {
ExpatListElement expat = this.getExpatListElementFor(id);
if (expat != null && expat.isFromActive()) {
/**
* Irrespective of the backing store implementation, if the session
* is activated in the remote instance, then we should load it from there.
*/
return loadFromRemoteActiveCache(id, expat, loadDependencies);
} else {
return loadFromBackingStore(id, version, loadDependencies);
}
} catch(BackingStoreException ex) {
IOException ex1 =
(IOException) new IOException("Error during load: " + ex.getMessage()).initCause(ex);
throw ex1;
}
}
/**
* This will use the Jxta channel to load the session from remote instance's
* active cache.
*/
private HAServletTimer loadFromRemoteActiveCache(String id,
ExpatListElement expat,
boolean loadDependecies)
throws IOException, BackingStoreException, RemoteLockException {
/**
* For the in-memory implementation, the restarted instance might
* have the session in its replica cache, if the load-factor is used.
*/
BaseCache replicaCache = getReplicaCache();
if(replicaCache != null) {
replicaCache.remove(id);
}
ReplicationState sessionState = loadTimerFromRemoteActiveCache(
id, String.valueOf(expat.getVersion()), expat.getInstanceName());
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("ServletTimerStoreImpl>>loadFromActiveCache:id="
+ id + ", sessionState=" + sessionState);
}
HAServletTimer timer = getServletTimer(sessionState);
validateAndSave(timer, loadDependecies);
return timer;
}
private HAServletTimer loadFromBackingStore(String id, String version, boolean loadDependencies)
throws IOException, BackingStoreException, RemoteLockException {
SimpleMetadata metaData = (SimpleMetadata) getBackingStore().load(id, version);
if(_logger.isLoggable(Level.FINE)) {
_logger.fine("ServletTimerStoreImpl>>loadFromBackingStore:id=" +
id + ", metaData=" + metaData);
}
HAServletTimer timer = getServletTimer(id, metaData);
validateAndSave(timer, loadDependencies);
return timer;
}
private void validateAndSave(HAServletTimer timer, boolean loadDependencies)
throws IOException, RemoteLockException {
if(timer != null) {
// If HAServletTimer.validate throws a RemoteLockedException,
// the load will be aborted.
// If it returns true, the HAServletTimer will be saved
// immediately. Else, we set timer to null, so that the
// HAServletTimer, which has been found to be invalid, won't
// be added to the active cache. In either case, a load
// acknowledgement is sent, so that the HAServletTimer is purged
// from replicas as appropriate
boolean isRemotelyLoaded = __removeFromRemotelyLoadedSessionIds(timer.getId());
if (timer.validate(loadDependencies)) {
//save timer - save will reset dirty to false
if (timer.getTimeRemaining() > 0 && isRemotelyLoaded) {
/**
* Issue #1448. Don't save the timer if it is already expired.
* timer.activate() which happens soon after the load will
* either remove or replicate the timer depending on whether
* the timer is one-time or repeating.
*/
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("ServletTimerStoreImpl>>validateAndSave saving " +
"the servlet timer after loading it. ServletTimer=" + timer);
}
timer.setDirty(true, false);
save(timer);
}
} else {
timer = null;
}
}
}
/**
* Loads and returns the ServletTimer with the given id from
* this store.
*
* @param id The id of the ServletTimer to load
* @param version The version of the ServletTimer to load
*
* @return The ServletTimer with the given id, or null if not
* found
*
* @throws IOException
*/
public SimpleMetadata __load(String id, String version)
throws BackingStoreException {
SimpleMetadata result = null;
if(id == null) {
return result;
}
SipTransactionPersistentManager repMgr
= (SipTransactionPersistentManager)this.getSipSessionManager();
ReplicationState localCachedState
= repMgr.removeFromServletTimerReplicationCache(id);
//check if we got a hit from our own replica cache
//and check if we can trust it. If so save and return it immediately
boolean trustCachedState = canTrustLocallyCachedState(id, version, localCachedState);
ReplicationState bestState = null;
if(_logger.isLoggable(Level.FINE)) {
_logger.fine("ServletTimerStoreImpl>>__load:id= " + id + ", localCachedState=" +
localCachedState + ", trustCachedState=" + trustCachedState);
}
if(trustCachedState) {
bestState = localCachedState;
} else {
ReplicationState broadcastResultState =
findServletTimerViaBroadcastOrUnicast(id, version);
bestState = ReplicationState.getBestResult(localCachedState, broadcastResultState);
if(_logger.isLoggable(Level.FINE)) {
_logger.fine("ServletTimerStoreImpl>>__load:id=" + id + ", broadcastResultState " +
"from broadcast or unicast=" + broadcastResultState + ", bestState = " + bestState);
}
}
if(bestState != null && bestState.getState() != null) {
__addToRemotelyLoadedSessionIds(id);
}
result = ReplicationState.createSimpleMetadataFrom(
bestState, isReplicationCompressionEnabled());
return result;
}
protected ExpatListElement getExpatListElementFor(String id) {
SipTransactionPersistentManager mgr
= (SipTransactionPersistentManager)getSipSessionManager();
if(mgr.isExpectingExpatIdsMap()) {
//in this period do not trust expatIdsMap
return null;
} else {
return mgr.getServletTimerExpatListElement(id);
}
}
protected ExpatListElement removeExpatListElementFor(String id) {
SipTransactionPersistentManager mgr
= (SipTransactionPersistentManager)getSipSessionManager();
return mgr.removeServletTimerExpatListElement(id);
}
private ReplicationState findServletTimerViaBroadcastOrUnicast(String id, String version)
throws BackingStoreException {
try {
ExpatListElement expat = this.getExpatListElementFor(id);
if(expat == null || expat.getInstanceName() == null) {
return findServletTimerViaBroadcast(id, version);
} else {
if(_logger.isLoggable(Level.FINE)) {
_logger.fine("doing unicast load id = " + id
+ " version = " + version
+ "to instance: " + expat.getInstanceName());
}
return findServletTimerViaUnicast(id, version, expat.getInstanceName());
}
} finally {
removeExpatListElementFor(id);
}
}
private ReplicationState findServletTimerViaBroadcast(String id, String version)
throws BackingStoreException {
if(_logger.isLoggable(Level.FINE)) {
_logger.fine("ServletTimerStoreImpl>>findServletTimerViaBroadcast");
}
BackingStore replicator = this.getBackingStore();
JxtaBackingStoreImpl jxtaReplicator = null;
if(replicator instanceof JxtaBackingStoreImpl) {
jxtaReplicator = (JxtaBackingStoreImpl)replicator;
}
if(_logger.isLoggable(Level.FINE)) {
_logger.fine("ServletTimerStoreImpl>>findServletTimerViaBroadcast: replicator: " + replicator);
}
ReplicationState queryResult = jxtaReplicator != null ?
jxtaReplicator.__load(id, version) : null;
return queryResult;
}
private ReplicationState loadTimerFromRemoteActiveCache(String id,
String version,
String instanceName)
throws BackingStoreException {
ReplicationState returnState = findServletTimerViaUnicast(id, version, instanceName);
if (returnState != null && returnState.getState() != null) {
__addToRemotelyLoadedSessionIds(id);
removeExpatListElementFor(id);
}
return returnState;
}
private ReplicationState findServletTimerViaUnicast(String id, String version, String instanceName)
throws BackingStoreException {
if(ReplicationUtil.getInstanceName().equalsIgnoreCase(instanceName)) {
return null;
}
return sendUnicastLoadQuery(id, version, instanceName);
}
SimpleMetadata loadUnicast(String id, String version, String instanceName)
throws BackingStoreException {
ReplicationState returnState = sendUnicastLoadQuery(id, version, instanceName);
SimpleMetadata result = ReplicationState.createSimpleMetadataFrom(
returnState, isReplicationCompressionEnabled());
if(result != null) {
__addToRemotelyLoadedSessionIds(id); // Maintain this id, we need to remove state replica sessions after the next save.
}
return result;
}
/**
* Given a byte[] containing session data, return a session
* object
* if isReplicationCompressionEnabled() returns true the
* input byte[] will be assumed compressed and treated
* accordingly
*
* @param replicationState
* The byte[] with the session data
*
* @return
* A newly created ServletTimer for the given data, and associated
* with this Manager
*/
protected HAServletTimer getServletTimer(ReplicationState replicationState)
throws IOException {
if (replicationState == null || replicationState.getState() == null) {
return null;
} else {
return getServletTimer((String) replicationState.getId(),
replicationState.getState(),
replicationState.getVersion(),
replicationState.getContainerExtraParamsState(),
null);
}
}
protected HAServletTimer getServletTimer(String id, SimpleMetadata metadata)
throws IOException {
if (metadata == null || metadata.getState() == null) {
return null;
} else {
return getServletTimer(id, metadata.getState(),
metadata.getVersion(), null,
(ServletTimerExtraParams) metadata.getExtraParam());
}
}
protected HAServletTimer getServletTimer(String id,
byte[] state,
long version,
byte[] extraParamState,
ServletTimerExtraParams extraParams)
throws IOException
{
HAServletTimer _timer = null;
InputStream is = null;
BufferedInputStream bis = null;
ByteArrayInputStream bais = null;
Loader loader = null;
ClassLoader classLoader = null;
ObjectInputStream ois = null;
SipSessionManager manager
= this.getSipSessionManager();
Container container = manager.getContext();
IOUtilsCaller utilsCaller = null;
bais = new ByteArrayInputStream(state);
bis = new BufferedInputStream(bais);
if(isReplicationCompressionEnabled()) {
is = new GZIPInputStream(bis);
} else {
is = bis;
}
if(_logger.isLoggable(Level.FINEST)) {
_logger.finest("loaded session from replicationstore, length = "+state.length);
}
if (container != null) {
loader = container.getLoader();
}
if (loader != null) {
classLoader = loader.getClassLoader();
}
if (classLoader != null) {
if( (utilsCaller = ReplicationUtil.getWebUtilsCaller()) != null) {
try {
ois = utilsCaller.createObjectInputStream(is, true, classLoader);
} catch (Exception ex) {}
}
}
if (ois == null) {
ois = new ObjectInputStream(is);
}
if(ois != null) {
try {
_timer = (HAServletTimer)ois.readObject();
} catch (ClassNotFoundException ex) {
IOException ex1 = (IOException) new IOException(
"Error during deserialization: " + ex.getMessage()).initCause(ex);
throw ex1;
} finally {
if (ois != null) {
try {
ois.close();
bis = null;
}
catch (IOException e) {
}
}
}
}
_timer.setId(id);
_timer.setSipSessionManager(manager);
_timer.update(extraParamState, extraParams);
//currentOwnerInstanceName is in the manager already
if(version != Integer.MAX_VALUE) {
//if version == Integer.MAX_VALUE it is an active ST so it's version
// is correct
_timer.setVersion(version);
}
_timer.setDirty(false);
_timer.setReplicated(false);
return _timer;
}
/**
* Saves the given ServletTimer to this store.
*
* If a ServletTimer with the same id already exists in this
* store, it will be replaced.
*
* @param timer The ServletTimer to be saved
*
* @exception IOException
*/
public void save(ServletTimerImpl timer) throws IOException {
HAServletTimer haTimer = (HAServletTimer)timer;
long previousVersion = haTimer.getVersion();
haTimer.incrementVersion();
haTimer.setInternalLastAccessedTime(System.currentTimeMillis());
try {
if( haTimer.isReplicated() && !haTimer.isDirty() ) {
this.updateContainerExtraParam(haTimer);
} else {
haTimer.setIsBeingReplicated(true);
this.doSave(haTimer);
haTimer.setReplicated(true);
}
haTimer.setDirty(false);
} catch (IOException ex) {
haTimer.setVersion(previousVersion);
throw ex;
} finally {
haTimer.setIsBeingReplicated(false);
}
}
boolean isReplicationCompressionEnabled() {
SipTransactionPersistentManager repMgr
= (SipTransactionPersistentManager)this.getSipSessionManager();
return repMgr.isReplicationCompressionEnabled();
}
/**
* Saves the given ServletTimer to this store.
*
* If a ServletTimer with the same id already exists in this
* store, it will be replaced.
*
* @param haTimer The ServletTimer to be saved
*
* @exception IOException
*/
public void doSave(HAServletTimer haTimer) throws IOException {
haTimer.setInternalLastAccessedTime(System.currentTimeMillis());
byte[] timerState = ReplicationUtil.getByteArray(haTimer, isReplicationCompressionEnabled());
BackingStore replicator = this.getBackingStore();
SimpleMetadata simpleMetadata =
SimpleMetadataFactory.createSimpleMetadata(
haTimer.getVersion(),
haTimer.getInternalLastAccessedTime(), //lastAccessedTime
0L, //maxinactiveinterval
timerState,
haTimer.getExtraParameters() //containerExtraParam
);
if(haTimer.getParentSASId() != null) {
String beKey = SipApplicationSessionUtil.getSipApplicationKey(haTimer.getParentSASId());
simpleMetadata.setBeKey(beKey);
simpleMetadata.setOwningInstanceName(ReplicationUtil.getInstanceName());
}
try {
replicator.save(haTimer.getId(), //id
simpleMetadata, haTimer.isReplicated());
} catch (BackingStoreException ex) {
IOException ex1 =
(IOException) new IOException("Error during save: " + ex.getMessage()).initCause(ex);
throw ex1;
}
}
public ReplicationState getTransmitState(HAServletTimer haTimer) throws IOException {
SipTransactionPersistentManager mgr
= (SipTransactionPersistentManager)this.getSipSessionManager();
BackingStore replicator = mgr.getServletTimerBackingStore();
if(!(replicator instanceof JxtaBackingStoreImpl)) {
return null;
}
JxtaBackingStoreImpl jxtaReplicator = (JxtaBackingStoreImpl)replicator;
ReplicationState transmitState = null;
byte[] timerState = ReplicationUtil.getByteArray(haTimer, isReplicationCompressionEnabled());
SimpleMetadata simpleMetadata =
SimpleMetadataFactory.createSimpleMetadata(
haTimer.getVersion(),
haTimer.getInternalLastAccessedTime(),
0L, //maxinactiveinterval
timerState,
haTimer.getExtraParameters() //containerExtraParam
);
if(haTimer.getParentSASId() != null) {
String beKey = SipApplicationSessionUtil.getSipApplicationKey(haTimer.getParentSASId());
simpleMetadata.setBeKey(beKey);
simpleMetadata.setOwningInstanceName(ReplicationUtil.getInstanceName());
}
try {
transmitState = jxtaReplicator.getSimpleTransmitState(haTimer.getId(), simpleMetadata);
} catch (BackingStoreException ex) {}
return transmitState;
}
/**
* Removes the ServletTimer with the given id from this store.
*
* @param id The id of the ServletTimer to be removed
*
* @exception IOException
*/
public void remove(String id) throws IOException {
if(_logger.isLoggable(Level.FINE)) {
_logger.fine("ServletTimerStoreImpl>>remove" + " id: " + id);
}
BackingStore replicator = this.getBackingStore();
if(_logger.isLoggable(Level.FINE)) {
_logger.fine("ServletTimerStoreImpl>>remove: replicator: " + replicator);
}
try {
replicator.remove(id);
} catch (BackingStoreException ex) {
IOException ex1 =
(IOException) new IOException("Error during remove: " + ex.getMessage()).initCause(ex);
throw ex1;
}
}
/**
* Removes the ServletTimer with the given id from this store.
*
* @param id The id of the ServletTimer to be removed
* @param originatingInstanceName the name of the originating instance
* @param count a counter to track the number of hops in this cycle
*
* @exception IOException
*/
public void remove(String id, String originatingInstanceName, int count) throws IOException {
if(_logger.isLoggable(Level.FINE)) {
_logger.fine("ServletTimerStoreImpl>>remove" + " id: " + id + " originatingInstanceName: " + originatingInstanceName);
}
BackingStore replicator = this.getBackingStore();
if(!(replicator instanceof JxtaBackingStoreImpl)) {
return;
}
JxtaBackingStoreImpl jxtaReplicator
= (JxtaBackingStoreImpl)replicator;
if(_logger.isLoggable(Level.FINE)) {
_logger.fine("ServletTimerStoreImpl>>remove: jxtaReplicator: " + jxtaReplicator);
}
try {
jxtaReplicator.remove(id, originatingInstanceName, count);
} catch (BackingStoreException ex) {
IOException ex1 =
(IOException) new IOException("Error during remove: " + ex.getMessage()).initCause(ex);
throw ex1;
}
}
void sendLoadAdvisory(String id, String instanceName)
throws IOException {
//send load advisory to instanceName
SipTransactionPersistentManager mgr
= (SipTransactionPersistentManager)getSipSessionManager();
String theCommand = mgr.MESSAGE_LOAD_ADVISORY_SERVLET_TIMER;
ReplicationState loadAdvisoryState
= ReplicationState.createUnicastLoadAdvisoryState(MODE_SIP, id, this.getApplicationId(), 0L, mgr.getInstanceName(), theCommand);
JxtaReplicationSender sender
= JxtaReplicationSender.createInstance();
//sender.sendOverPropagatedPipe(loadAdvisoryState, instanceName, false);
sender.sendReplicationAdvisoryState(loadAdvisoryState, instanceName);
}
void sendUnicastLoadAcknowledgement(String id, String instanceName, String bekey) {
//send load received ack to instanceName
SipTransactionPersistentManager mgr
= (SipTransactionPersistentManager)getSipSessionManager();
String theCommand = mgr.MESSAGE_BROADCAST_LOAD_RECEIVED_SERVLET_TIMER;
ReplicationState loadReceivedState =
ReplicationState.createBroadcastLoadReceivedState(MODE_SIP, id, this.getApplicationId(), 0L, mgr.getInstanceName(), theCommand);
loadReceivedState.setProperty(
ReplicationState.IGNORE_REMOVE_INSTANCE_NAME, bekey);
JxtaReplicationSender sender
= JxtaReplicationSender.createInstance();
sender.sendOverPropagatedPipe(loadReceivedState, instanceName, false);
//if we want to batch unicast load acks use next line
//sender.sendReplicationReceivedState(loadReceivedState, instanceName);
}
ReplicationState sendUnicastLoadQuery(String id, String version, String instanceName) {
//send load query to instanceName via unicast
SipTransactionPersistentManager mgr
= (SipTransactionPersistentManager)getSipSessionManager();
String theCommand = mgr.LOAD_SERVLET_TIMER_COMMAND;
ReplicationState loadState
= ReplicationState.createUnicastLoadState(MODE_SIP, id, this.getApplicationId(), ReplicationUtil.parseLong(version), mgr.getInstanceName(), theCommand);
JxtaReplicationSender sender
= JxtaReplicationSender.createInstance();
ReplicationState returnState
= sender.sendReplicationLoadState(loadState, instanceName, useReplicationUnicastLoadBatching);
return returnState;
}
/**
* update the lastaccess time of the specified ServletTimer into this Store.
*
* @param timer ServletTimerImpl to be saved
*
* @exception IOException if an input/output error occurs
*/
public void updateContainerExtraParam(HAServletTimer timer) throws IOException {
BackingStore replicator = this.getBackingStore();
JxtaBackingStoreImpl jxtaReplicator = null;
if(replicator instanceof JxtaBackingStoreImpl) {
jxtaReplicator = (JxtaBackingStoreImpl)replicator;
}
if(_logger.isLoggable(Level.FINE)) {
_logger.fine("ServletTimerStoreImpl>>updateContainerExtraParam: replicator: " + replicator);
}
try {
SimpleMetadata smd = SimpleMetadataFactory.createSimpleMetadata(0L, //lastaccesstime not used for ServletTimer
timer.getVersion(), //version
timer.getExtraParameters());
replicator.save(timer.getId(), smd, timer.isReplicated()); //containerExtraParams
} catch (BackingStoreException ex) {
IOException ex1 =
(IOException) new IOException("Error during updateContainerExtraParam: " + ex.getMessage()).initCause(ex);
throw ex1;
}
}
/**
* Removes all ServletTimers from this store.
*/
public void clear() throws IOException {
//FIXME
}
/**
* Cleans up any resources that were used by this instance.
*/
public void cleanup() {
//FIXME
}
/**
* Removes any expired ServletTimers from this store.
*
* This method is invoked by the background reaper thread.
*/
public void processExpires() {
SipTransactionPersistentManager replicationMgr =
(SipTransactionPersistentManager) this.getSipSessionManager();
// if(!(replicationMgr.isThirdPartyBackingStoreInUse())) {
// replicationMgr.processExpiredServletTimerReplicas();
// } else {
// replicationMgr.processExpiredServletTimerReplicasThirdPartySPI();
// }
replicationMgr._processExpiredServletTimers();
}
// find the session in local active cache, passivate it and remove from local cache.
public ReplicableEntity findSessionAndPassivate(String id) {
SipTransactionPersistentManager mgr =
(SipTransactionPersistentManager) this.getSipSessionManager();
return mgr.findServletTimerAndPassivate(id, new AtomicBoolean());
}
// get the active cache sessions.
public Map<String, ReplicableEntity> getActiveCache() {
SipTransactionPersistentManager mgr
= (SipTransactionPersistentManager)getSipSessionManager();
return mgr.getActiveServletTimers();
}
// put the state in the local replica cache.
public void putInReplicaCache(ReplicationState state) {
SipTransactionPersistentManager mgr
= (SipTransactionPersistentManager)getSipSessionManager();
mgr.putInServletTimerReplicationCache(state);
}
// remove the entry from replica cache with given id.
public void removeFromReplicaCache(String id) {
SipTransactionPersistentManager mgr
= (SipTransactionPersistentManager)getSipSessionManager();
mgr.removeFromServletTimerReplicationCache(id);
}
public BaseCache getReplicaCache() {
SipTransactionPersistentManager mgr
= (SipTransactionPersistentManager)getSipSessionManager();
return mgr.getReplicatedServletTimers();
}
public ReplicableEntity deserialize(ReplicationState state) {
try {
return getServletTimer(state);
} catch (IOException ex) {
return null;
}
}
public void activate(ReplicableEntity session) {
SipTransactionPersistentManager mgr
= (SipTransactionPersistentManager)getSipSessionManager();
mgr.activate((HAServletTimer)session, true);
}
}