tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject cvs commit: jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp SimpleTcpCluster.java
Date Wed, 16 Apr 2003 04:06:57 GMT
fhanik      2003/04/15 21:06:55

  Modified:    catalina/src/share/org/apache/catalina Cluster.java
               catalina/src/share/org/apache/catalina/core
                        StandardContext.java
               modules/cluster/src/share/org/apache/catalina/cluster/session
                        SimpleTcpReplicationManager.java
               modules/cluster/src/share/org/apache/catalina/cluster/tcp
                        SimpleTcpCluster.java
  Log:
  clustering now respects the <distributable/> element,
  not the best solution, but I have no clue how the digester works, and changing around the
way the
  standard context start order was not an option
  
  Revision  Changes    Path
  1.4       +12 -4     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/Cluster.java
  
  Index: Cluster.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/Cluster.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Cluster.java	20 Mar 2003 00:11:05 -0000	1.3
  +++ Cluster.java	16 Apr 2003 04:06:53 -0000	1.4
  @@ -221,5 +221,13 @@
        *  the web application
        */
       public void stop(String contextPath) throws IOException;
  +    
  +    /**
  +     * Notifies the cluster if a context is distributable or not
  +     * @param contextName - the name of the registed context
  +     * @param distributable - true means that the sessions will be replicated
  +     */
  +    public void setDistributable(String contextName, boolean distributable);
  +    
   
   }
  
  
  
  1.39      +13 -7     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java
  
  Index: StandardContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- StandardContext.java	15 Apr 2003 23:01:46 -0000	1.38
  +++ StandardContext.java	16 Apr 2003 04:06:54 -0000	1.39
  @@ -879,9 +879,11 @@
       public void setDistributable(boolean distributable) {
           boolean oldDistributable = this.distributable;
           this.distributable = distributable;
  +        if ( getCluster() != null ) getCluster().setDistributable(getName(),distributable);
           support.firePropertyChange("distributable",
                                      new Boolean(oldDistributable),
                                      new Boolean(this.distributable));
  +        
   
       }
   
  @@ -3891,13 +3893,15 @@
                   log.debug("Configuring default Manager");
               if (getCluster() != null) {
                   try {
  -                    if ( this.getDistributable() ) {
  +//                    The setDistributable is set after the context is started, hence 
  +//                    this doesn't work :(
  +//                    if ( this.getDistributable() ) {
                           log.info("Creating clustering manager for context="+getName());
                           setManager(getCluster().createManager(getName()));
  -                    } else {
  -                        log.info("Ignoring clustering manager for context="+getName()+
" element <distributable> not present in web.xml");
  -                        setManager(new StandardManager());    
  -                    }
  +//                    } else {
  +//                        log.info("Ignoring clustering manager for context="+getName()+
" element <distributable> not present in web.xml");
  +//                        setManager(new StandardManager());    
  +//                    }
                   } catch ( Exception x ) {
                       log.warn("Clustering disabled for context:"+getName()+" reason:"+x.getMessage());
                       setManager(new StandardManager());
  @@ -4004,8 +4008,10 @@
                   // Notify our interested LifecycleListeners
                   lifecycle.fireLifecycleEvent(START_EVENT, null);
   
  -                if ((manager != null) && (manager instanceof Lifecycle))
  +                if ((manager != null) && (manager instanceof Lifecycle)) {
                       ((Lifecycle) manager).start();
  +                }
  +                    
   
               } finally {
                   // Unbinding thread
  
  
  
  1.5       +26 -10    jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/SimpleTcpReplicationManager.java
  
  Index: SimpleTcpReplicationManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/SimpleTcpReplicationManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SimpleTcpReplicationManager.java	20 Mar 2003 20:46:14 -0000	1.4
  +++ SimpleTcpReplicationManager.java	16 Apr 2003 04:06:54 -0000	1.5
  @@ -110,8 +110,6 @@
    */
   public class SimpleTcpReplicationManager extends org.apache.catalina.session.StandardManager
   {
  -    private static org.apache.commons.logging.Log log =
  -        org.apache.commons.logging.LogFactory.getLog( SimpleTcpCluster.class );
   
       //the channel configuration
       protected String mChannelConfig = null;
  @@ -142,7 +140,9 @@
   
       protected String name;
   
  -    protected int debug = 0;
  +    protected int debug = 10;
  +
  +    protected boolean distributable = true;
   
       protected org.apache.catalina.cluster.tcp.SimpleTcpCluster cluster;
       /**
  @@ -201,6 +201,11 @@
       {
           return this.debug;
       }
  +
  +    public void setDebug(int debug) {
  +        this.debug = debug;
  +        super.setDebug(debug);
  +    }
       /**
        * Creates a HTTP session.
        * Most of the code in here is copied from the StandardManager.
  @@ -267,7 +272,7 @@
           */
           if ( setId ) session.setId(sessionId);
   
  -        if ( notify )
  +        if ( notify && (cluster!=null) )
           {
               //notify javagroups
               SessionMessage msg = new SessionMessage(this.name,
  @@ -296,7 +301,7 @@
       public Session createSession()
       {
           //create a session and notify the other nodes in the cluster
  -        Session session =  createSession(true,true);
  +        Session session =  createSession(distributable,true);
           add(session);
           return session;
       }
  @@ -411,6 +416,11 @@
           try {
               //the channel is already running
               if ( mChannelStarted ) return;
  +            log("Starting clustering manager...:"+getName(),1);
  +            if ( cluster == null ) {
  +                log("Starting... no cluster associated with this context:"+getName(),1);
  +                return;
  +            }
               if (cluster.getMembers().length > 0) {
                   SessionMessage msg =
                       new SessionMessage(this.getName(),
  @@ -453,7 +463,13 @@
           }
       }
   
  +    public void setDistributable(boolean dist) {
  +        this.distributable = dist;
  +    }
   
  +    public boolean getDistributable() {
  +        return distributable;
  +    }
   
       /**
        * This method is called by the received thread when a SessionMessage has
  @@ -553,7 +569,7 @@
           if ( getDebug() >= level ) {
               String lmsg = "[InMemoryReplicationManager] "+msg;
               if ( mPrintToScreen ) System.out.println(lmsg);
  -            super.log(lmsg);
  +            SimpleTcpCluster.log.info(lmsg);
           }
       }
   
  @@ -564,7 +580,7 @@
                   System.out.println(lmsg);
                   x.printStackTrace();
               }
  -            super.log(lmsg,x);
  +            SimpleTcpCluster.log.info(lmsg,x);
           }//end if
       }
   }
  
  
  
  1.12      +28 -12    jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java
  
  Index: SimpleTcpCluster.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- SimpleTcpCluster.java	13 Apr 2003 02:34:02 -0000	1.11
  +++ SimpleTcpCluster.java	16 Apr 2003 04:06:55 -0000	1.12
  @@ -125,7 +125,7 @@
                  LifecycleListener {
   
   
  -    private static org.apache.commons.logging.Log log =
  +    public static org.apache.commons.logging.Log log =
           org.apache.commons.logging.LogFactory.getLog( SimpleTcpCluster.class );
   
   
  @@ -253,9 +253,13 @@
   
   
       /**
  -     * The context name <-> manager association.
  +     * The context name <-> manager association for distributed contexts. 
        */
       protected HashMap managers = new HashMap();
  +    /**
  +     * The context name <-> manager association for all contexts.
  +     */
  +    protected HashMap allmanagers = new HashMap();
   
       /**
        * Nr of milliseconds between every heart beat
  @@ -401,16 +405,28 @@
   
       public synchronized Manager createManager(String name) {
           SimpleTcpReplicationManager manager = new SimpleTcpReplicationManager(name);
  -        manager.setCluster(this);
  +        manager.setCluster(null);
  +        manager.setDistributable(false);
           manager.setExpireSessionsOnShutdown(expireSessionsOnShutdown);
           manager.setPrintToScreen(printToScreen);
           manager.setUseDirtyFlag(useDirtyFlag);
           manager.setDebug(debug);
  -        managers.put(name, manager);
  +        allmanagers.put(name, manager);
           return manager;
       }
   
  -
  +    public void setDistributable(String contextName, boolean distributable)
  +    {
  +        log.info("Setting distributable for context:"+contextName+" to "+distributable);
  +        SimpleTcpReplicationManager manager = (SimpleTcpReplicationManager)allmanagers.get(contextName);
  +        manager.setDistributable(distributable);
  +        if (distributable) {
  +            manager.setCluster(this);
  +            manager.setDistributable(true);
  +            managers.put(contextName,manager);
  +        }
  +        
  +    }
   
   
       // ------------------------------------------------------ Lifecycle Methods
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message