FileDocCategorySizeDatePackage
BackupManager.javaAPI DocApache Tomcat 6.0.149498Fri Jul 20 04:20:36 BST 2007org.apache.catalina.ha.session

BackupManager

public class BackupManager extends org.apache.catalina.session.StandardManager implements org.apache.catalina.ha.ClusterManager
author
Filip Hanik
version
1.0

Fields Summary
public static org.apache.juli.logging.Log
log
protected static long
DEFAULT_REPL_TIMEOUT
protected boolean
mExpireSessionsOnShutdown
Set to true if we don't want the sessions to expire on shutdown
protected String
name
The name of this manager
protected org.apache.catalina.ha.CatalinaCluster
cluster
A reference to the cluster
private boolean
notifyListenersOnReplication
Should listeners be notified?
private int
mapSendOptions
Constructors Summary
public BackupManager()
Constructor, just calls super()


             
      
        super();
    
Methods Summary
public org.apache.catalina.ha.ClusterManagercloneFromTemplate()

        BackupManager result = new BackupManager();
        result.mExpireSessionsOnShutdown = mExpireSessionsOnShutdown;
        result.name = "Clone-from-"+name;
        result.cluster = cluster;
        result.notifyListenersOnReplication = notifyListenersOnReplication;
        result.mapSendOptions = mapSendOptions;
        return result;
    
public org.apache.catalina.SessioncreateEmptySession()

        return new DeltaSession(this);
    
public booleandoDomainReplication()

        return false;
    
public java.lang.ClassLoader[]getClassLoaders()

        return ClusterManagerBase.getClassLoaders(this.container);
    
public org.apache.catalina.ha.CatalinaClustergetCluster()

        return cluster;
    
public booleangetDistributable()

        return distributable;
    
public booleangetExpireSessionsOnShutdown()

        return mExpireSessionsOnShutdown;
    
public java.lang.String[]getInvalidatedSessions()

        return new String[0];
    
public java.lang.StringgetMapName()

        CatalinaCluster catclust = (CatalinaCluster)cluster;
        String name = catclust.getManagerName(getName(),this)+"-"+"map";
        if ( log.isDebugEnabled() ) log.debug("Backup manager, Setting map name to:"+name);
        return name;
    
public intgetMapSendOptions()

        return mapSendOptions;
    
public java.lang.StringgetName()

        return this.name;
    
public org.apache.catalina.tribes.io.ReplicationStreamgetReplicationStream(byte[] data)
Open Stream and use correct ClassLoader (Container) Switch ThreadClassLoader

param
data
return
The object input stream
throws
IOException

        return getReplicationStream(data,0,data.length);
    
public org.apache.catalina.tribes.io.ReplicationStreamgetReplicationStream(byte[] data, int offset, int length)

        ByteArrayInputStream fis = new ByteArrayInputStream(data, offset, length);
        return new ReplicationStream(fis, getClassLoaders());
    
public booleanisDefaultMode()

return
Returns the defaultMode.

        return false;
    
public booleanisNotifyListenersOnReplication()

        return notifyListenersOnReplication;
    
public voidmessageDataReceived(org.apache.catalina.ha.ClusterMessage msg)

    
public org.apache.catalina.ha.ClusterMessagerequestCompleted(java.lang.String sessionId)

        if ( !this.started ) return null;
        LazyReplicatedMap map = (LazyReplicatedMap)sessions;
        map.replicate(sessionId,false);
        return null;
    
public voidsetCluster(org.apache.catalina.ha.CatalinaCluster cluster)

        if(log.isDebugEnabled())
            log.debug("Cluster associated with SimpleTcpReplicationManager");
        this.cluster = cluster;
    
public voidsetDefaultMode(boolean defaultMode)

param
defaultMode The defaultMode to set.

    
public voidsetDistributable(boolean dist)

        this.distributable = dist;
    
public voidsetDomainReplication(boolean sendClusterDomainOnly)

param
sendClusterDomainOnly The sendClusterDomainOnly to set.

    
public voidsetExpireSessionsOnShutdown(boolean expireSessionsOnShutdown)

        mExpireSessionsOnShutdown = expireSessionsOnShutdown;
    
public voidsetMapSendOptions(int mapSendOptions)

        this.mapSendOptions = mapSendOptions;
    
public voidsetName(java.lang.String name)

        this.name = name;
    
public voidsetNotifyListenersOnReplication(boolean notifyListenersOnReplication)

        this.notifyListenersOnReplication = notifyListenersOnReplication;
    
public voidstart()
Prepare for the beginning of active use of the public methods of this component. This method should be called after configure(), and before any of the public methods of the component are utilized.
Starts the cluster communication channel, this will connect with the other nodes in the cluster, and request the current session state to be transferred to this node.

exception
IllegalStateException if this component has already been started
exception
LifecycleException if this component detects a fatal error that prevents this component from being used

        if ( this.started ) return;
        
        try {
            cluster.registerManager(this);
            CatalinaCluster catclust = (CatalinaCluster)cluster;
            LazyReplicatedMap map = new LazyReplicatedMap(this,
                                                          catclust.getChannel(),
                                                          DEFAULT_REPL_TIMEOUT,
                                                          getMapName(),
                                                          getClassLoaders());
            map.setChannelSendOptions(mapSendOptions);
            this.sessions = map;
            super.start();
            this.started = true;
        }  catch ( Exception x ) {
            log.error("Unable to start BackupManager",x);
            throw new LifecycleException("Failed to start BackupManager",x);
        }
    
public voidstop()
Gracefully terminate the active use of the public methods of this component. This method should be the last one called on a given instance of this component.
This will disconnect the cluster communication channel and stop the listener thread.

exception
IllegalStateException if this component has not been started
exception
LifecycleException if this component detects a fatal error that needs to be reported

        
        LazyReplicatedMap map = (LazyReplicatedMap)sessions;
        if ( map!=null ) {
            map.breakdown();
        }
        if ( !this.started ) return;
        try {
        } catch ( Exception x ){
            log.error("Unable to stop BackupManager",x);
            throw new LifecycleException("Failed to stop BackupManager",x);
        } finally {
            super.stop();
        }
        cluster.removeManager(this);

    
public voidunload()
Override persistence since they don't go hand in hand with replication for now.