User: patriot1burke
  Date: 01/09/26 20:14:53

  Modified:    src/main/org/jboss/ejb/plugins/jrmp13/server
                        JRMPContainerInvokerHA.java
  Log:
  no message
  
  Revision  Changes    Path
  1.4       +82 -271   
jbossmx/src/main/org/jboss/ejb/plugins/jrmp13/server/JRMPContainerInvokerHA.java
  
  Index: JRMPContainerInvokerHA.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jbossmx/src/main/org/jboss/ejb/plugins/jrmp13/server/JRMPContainerInvokerHA.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JRMPContainerInvokerHA.java       2001/09/11 18:39:55     1.3
  +++ JRMPContainerInvokerHA.java       2001/09/27 03:14:53     1.4
  @@ -1,10 +1,9 @@
   /*
  - * JBoss, the OpenSource J2EE WebOS
  + * JBoss, the OpenSource J2EE webOS
    *
    * Distributable under LGPL license.
    * See terms of license at gnu.org.
    */
  -
   package org.jboss.ejb.plugins.jrmp13.server;
   
   import java.lang.reflect.InvocationHandler;
  @@ -12,12 +11,13 @@
   import java.util.ArrayList;
   import java.util.Collection;
   import java.util.Iterator;
  -import java.util.Vector;
   
   import javax.ejb.EJBMetaData;
   import javax.ejb.EJBHome;
   import javax.ejb.EJBObject;
   
  +import javax.naming.InitialContext;
  +
   import org.jboss.ejb.Container;
   import org.jboss.ejb.ContainerInvoker;
   import org.jboss.ejb.ContainerInvokerContainer;
  @@ -25,337 +25,148 @@
   import org.jboss.metadata.SessionMetaData;
   
   import org.jboss.ejb.plugins.jrmp.interfaces.ContainerRemote;
  -import org.jboss.ejb.plugins.jrmp.interfaces.HASLSBTargetsManager;
  -
  -import org.jboss.ejb.plugins.jrmp13.interfaces.HomeProxy;
   import org.jboss.ejb.plugins.jrmp13.interfaces.HomeProxyHA;
  -import org.jboss.ejb.plugins.jrmp13.interfaces.StatelessSessionProxy;
   import org.jboss.ejb.plugins.jrmp13.interfaces.StatelessSessionProxyHA;
   import org.jboss.ejb.plugins.jrmp13.interfaces.StatefulSessionProxy;
   import org.jboss.ejb.plugins.jrmp13.interfaces.EntityProxy;
   import org.jboss.logging.Logger;
  -
  -import org.jboss.ha.HAConfigNode;
  -import org.jboss.ha.HAConfigEntry;
  -
  -import javax.naming.InitialContext;
  -import javax.naming.Context;
   
  -import org.jboss.ha.HAConfigNode.HAEventsCallbackable;
  +import org.jboss.ha.HARMIServerImpl;
  +import org.jboss.ha.HARMIServer;
  +import org.jboss.ha.HAPartition;
  +import org.jboss.ha.RoundRobin;
   
  -import java.util.Hashtable;
  -
   /**
  - *   Based on JRMPContainerInvoker v.1.10 for HA use in SLSB
  - *
  - *   @see StatelessSessionProxy
  - *   @author Rickard �berg ([EMAIL PROTECTED])
  - *   @author <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
  - *   @author <a href="mailto:[EMAIL PROTECTED]";>Sacha Labourey</a>
  - *   @version $Revision: 1.3 $
  - *
  - *   <p><b>Revisions:</b>
  + *  <description>
    *
  - *   <p><b>20010819 Sacha Labourey:</b>
  - *   <ul>
  - *   <li> First import of sources
  - *   </ul>
  + *  @see <related>
  + *  @author <a href="mailto:[EMAIL PROTECTED]";>Rickard �berg</a>
  + *  @author <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
  + *  @version $Revision: 1.4 $
    */
  -
   public final class JRMPContainerInvokerHA
  -implements ContainerInvoker, HAConfigNode.HAEventsCallbackable
  +   implements ContainerInvoker
   {
  -   static Logger log = Logger.create(JRMPContainerInvokerHA.class);
  +   static Logger log = Logger.create(JRMPContainerInvoker.class);
      EJBHome home;
      EJBObject statelessObject;
   
      Container container;
  -   org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker ci; // Parent invoker
  +   org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvokerHA ci; // Parent invoker
   
  -   String _beanName = null;
  -   String _appName = null;
  -   String _nodeName = null;
  -   StatelessSessionProxyHA _ssp = null; // optimization
  -   HomeProxyHA _sshp = null; // optimization
  -   Hashtable localJndiProps = null;
  -   String haAppPathName = null;
  +   HomeProxyHA homeProxy;
  +   StatelessSessionProxyHA statelessProxy;
  +   protected HARMIServerImpl harmi;
  +   protected HAPartition partition;
  +   protected String partitionName;
  +   
   
  -   public JRMPContainerInvokerHA 
(org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker ci)
  +   public 
JRMPContainerInvokerHA(org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvokerHA ci, 
String partitionName)
      {
         this.ci = ci;
  +      this.partitionName = partitionName;
      }
   
  -   public void setContainer (Container con)
  +   public void setContainer(Container con)
      {
         this.container = con;
      }
   
  -   public void init ()
  +   public void init()
      {
  -      // Create stateless session object
  -      // Same instance is used for all objects
  -      if (!(container.getBeanMetaData () instanceof EntityMetaData) &&
  -      ((SessionMetaData)container.getBeanMetaData ()).isStateless ())
  +      // Create EJBHome object
  +      // We add the Handle methods to the Home
  +      Class handleClass;
  +      try
         {
  -         try
  -         {
  -            Context ctx = new InitialContext ();
  -
  -            // names used for HA
  -            //
  -            _appName = new java.io.File (new java.net.URL 
(this.container.getApplication ().getName ()).getFile ()).getName ();
  -            _beanName = this.container.getBeanMetaData ().getEjbName ();
  -
  -            // Get the HAConfigService
  -            //
  -            HAConfigNode ha = (HAConfigNode)ctx.lookup ("java:/HAConfigServer");
  -            _nodeName = ha.getNodeName ();
  -            localJndiProps = ha.getLocalJndiProps ();
  -
  -            // Get already running replica
  -            //
  -            Vector replicateContainers = ha.getReplicateContainers (_appName , 
_beanName, HAConfigNode.REMOTE_TYPE);
  -            haAppPathName = ha.getHaAppPath (_appName , _beanName, 
HAConfigNode.REMOTE_TYPE);
  -
  -            this.createStatelessSessionProxy (replicateContainers, 
ha.getNormalDelay (), ha.getDeathDelay ());
  -         }
  -         catch (Exception e)
  -         {
  -            e.printStackTrace ();
  -         }
  -      }
  -      else
  +         handleClass = Class.forName("javax.ejb.Handle");
  +      } catch (Exception e)
         {
  -         // Create EJBHome object
  -         // We add the Handle methods to the Home
  -         Class handleClass;
  -         try
  -         {
  -            handleClass = Class.forName ("javax.ejb.Handle");
  -         } catch (Exception e)
  -         {
  -            log.error("No javax.ejb.Handle", e);
  -            handleClass = null;
  -         }
  -         this.home = (EJBHome)Proxy.newProxyInstance 
(((ContainerInvokerContainer)container).getHomeClass ().getClassLoader (),
  -         new Class[]
  -         { ((ContainerInvokerContainer)container).getHomeClass (), handleClass },
  -         new HomeProxy (ci.getJndiName (), ci.getEJBMetaData (), ci, ci.isOptimized 
()));
  +         log.error("Failed to get javax.ejb.Handle", e);
  +         handleClass = null;
         }
   
  -      log.debug ("JRMP 1.3 CI initialized (HA)");
  +      homeProxy = new HomeProxyHA(ci.getJndiName(), ci.getEJBMetaData(), null, 
ci.isOptimized());
  +      this.home = 
(EJBHome)Proxy.newProxyInstance(((ContainerInvokerContainer)container).getHomeClass().getClassLoader(),
  +                                                  new Class[] { 
((ContainerInvokerContainer)container).getHomeClass(), handleClass },
  +                                                  homeProxy);
  +      // Create stateless session object
  +      // Same instance is used for all objects
  +      if (!(container.getBeanMetaData() instanceof EntityMetaData) &&
  +          ((SessionMetaData)container.getBeanMetaData()).isStateless())
  +      {
  +         statelessProxy = new StatelessSessionProxyHA(ci.getJndiName(), null, 
ci.isOptimized());
  +         this.statelessObject = 
(EJBObject)Proxy.newProxyInstance(((ContainerInvokerContainer)container).getRemoteClass().getClassLoader(),
  +                                                                  new Class[] { 
((ContainerInvokerContainer)container).getRemoteClass() } ,
  +                                                                  statelessProxy);
  +      }
  +      log.debug("JRMP 1.3 CI initialized");
      }
   
  -   public void start ()
  +   public void start()
      {
  -      if (!(container.getBeanMetaData () instanceof EntityMetaData) &&
  -      ((SessionMetaData)container.getBeanMetaData ()).isStateless ())
  +      try
  +      {
  +         this.partition = (HAPartition)new InitialContext().lookup("/HAPartition/" 
+ partitionName);
  +         this.harmi = new HARMIServerImpl(partition, ci.getJndiName(), 
ContainerRemote.class, this);
  +         ContainerRemote stub = (ContainerRemote)harmi.createHAStub(new 
RoundRobin());
  +         homeProxy.setHAProxy(stub);
  +         if (statelessProxy != null)
  +            statelessProxy.setHAProxy(stub);
  +      }
  +      catch (Exception ex)
         {
  -         try
  -         {
  -            Context ctx = new InitialContext ();
  -            HAConfigNode ha = (HAConfigNode)ctx.lookup ("java:/HAConfigServer");
  -            HAConfigEntry detail = new  HAConfigEntry 
((ContainerRemote)java.rmi.server.RemoteObject.toStub (ci), null, null);
  -            ha.registerContainer (this, _appName , _beanName, 
HAConfigNode.REMOTE_TYPE, detail);
  -         }
  -         catch (Exception e)
  -         { e.printStackTrace (); }
  +         log.error(ex);
  +         throw new RuntimeException("Error starting JRMPContainerInvokerHA");
         }
      }
   
  -   public void stop ()
  +   public void stop()
      {
  -      unregisterFromHA ();
  +      try
  +      {
  +         harmi.destroy();
  +      }
  +      catch (Exception ex)
  +      {
  +         log.error(ex);
  +         throw new RuntimeException("Error starting JRMPContainerInvokerHA");
  +      }
      }
   
  -   public void destroy ()
  +   public void destroy()
      {
  -      unregisterFromHA ();
      }
   
  -   public EJBMetaData getEJBMetaData ()
  +   public EJBMetaData getEJBMetaData()
      {
         // Ignore, never called
         return null;
      }
   
  -   public EJBHome getEJBHome ()
  +   public EJBHome getEJBHome()
      {
         return home;
      }
   
  -   public EJBObject getStatelessSessionEJBObject ()
  +   public EJBObject getStatelessSessionEJBObject()
      {
         return statelessObject;
      }
  -
  -   public EJBObject getStatefulSessionEJBObject (Object id)
  -   {
  -      return (EJBObject)Proxy.newProxyInstance 
(((ContainerInvokerContainer)container).getRemoteClass ().getClassLoader (),
  -      new Class[]
  -      { ((ContainerInvokerContainer)container).getRemoteClass () },
  -      new StatefulSessionProxy (ci.getJndiName (), ci, id, ci.isOptimized ()));
  -   }
  -
  -   public EJBObject getEntityEJBObject (Object id)
  -   {
  -      return (EJBObject)Proxy.newProxyInstance 
(((ContainerInvokerContainer)container).getRemoteClass ().getClassLoader (),
  -      new Class[]
  -      { ((ContainerInvokerContainer)container).getRemoteClass () },
  -      new EntityProxy (ci.getJndiName (), ci, id, ci.isOptimized ()));
  -   }
  -
  -   public Collection getEntityCollection (Collection ids)
  -   {
  -      ArrayList list = new ArrayList (ids.size ());
  -      Iterator idEnum = ids.iterator ();
  -      while(idEnum.hasNext ())
  -      {
  -         list.add (Proxy.newProxyInstance 
(((ContainerInvokerContainer)container).getRemoteClass ().getClassLoader (),
  -         new Class[]
  -         { ((ContainerInvokerContainer)container).getRemoteClass () },
  -         new EntityProxy (ci.getJndiName (), ci, idEnum.next (), ci.isOptimized 
())));
  -      }
  -      return list;
  -   }
  -
  -   // private methods -----------------------------------------------------
   
  -   public void beanReplicaModified (java.util.Vector newValue)
  +   public EJBObject getStatefulSessionEJBObject(Object id)
      {
  -      System.out.println/*Logger.debug*/("Cluster structure has changed, need to 
recompute proxies");
  -      this.createStatelessSessionProxy (newValue, 5000, 30000); // these delays 
won't be used anyway
  +      throw new RuntimeException("NOT IMPLEMENTED");
      }
   
  -   private void createStatelessSessionProxy (java.util.Vector replicateContainers, 
long normalDelay, long deathDelay)
  +   public EJBObject getEntityEJBObject(Object id)
      {
  -      try
  -      {
  -         // set all replicas, including myself in first position, in a vector
  -         //
  -         int nbElem = replicateContainers.size ();
  -         ContainerRemote[] cis = new ContainerRemote [nbElem + 1];
  -         Hashtable[] props = new Hashtable[nbElem + 1];
  -         cis[0] = this.ci;
  -         props[0] = this.localJndiProps;
  -         HAConfigEntry tmpEntry = null;
  -         boolean foundMeInList = false;
  -
  -         for (int i=0, cursor=0; i < nbElem; i++)
  -         {
  -            tmpEntry = (HAConfigEntry)(replicateContainers.elementAt (i));
  -            if (tmpEntry.node != this._nodeName)
  -            {
  -               ++cursor;
  -               cis[cursor] = tmpEntry.targetContainer;
  -               props[cursor] = tmpEntry.jndiServerProps;
  -            }
  -            foundMeInList = true;
  -         }
  -
  -         // If I was in the list, it means that nbElem had the good size and that 
cis is now too big (nbElem + 1)
  -         // as well as props
  -         //
  -         if (foundMeInList)
  -         {
  -            System.arraycopy (cis, 0, cis, 0, nbElem);
  -            System.arraycopy (props, 0, props, 0, nbElem);
  -         }
  -
  -
  -         // create home proxy and set it all its possible targets (replicas)
  -         //
  -         if ((this._sshp == null) || (this.home == null)) // create it only the 
first time, after it is only updated
  -         {
  -            // Create EJBHome object
  -            // We add the Handle methods to the Home
  -            Class handleClass;
  -            try
  -            {
  -               handleClass = Class.forName ("javax.ejb.Handle");
  -            } catch (Exception e)
  -            {
  -               log.error("No javax.ejb.Handle", e);
  -               handleClass = null;
  -            }
  -            this._sshp = new HomeProxyHA (ci.getJndiName (), ci.getEJBMetaData (), 
ci, ci.isOptimized (), new HASLSBTargetsManager (normalDelay, deathDelay));
  -            this._sshp.setMultipleContainers (cis, props, haAppPathName);
  -            this.home = (EJBHome)Proxy.newProxyInstance 
(((ContainerInvokerContainer)container).getHomeClass ().getClassLoader (),
  -            new Class[]
  -            { ((ContainerInvokerContainer)container).getHomeClass (), handleClass } 
,
  -            _sshp );
  -         }
  -         else
  -            this._sshp.setMultipleContainers (cis, props, haAppPathName);
  -
  -         // create proxy and set it all its possible targets (replicas)
  -         //
  -         if ((this._ssp == null) || (this.statelessObject == null)) // create it 
only the first time, after it is only updated
  -         {
  -            this._ssp = new StatelessSessionProxyHA (ci.getJndiName (), ci, 
ci.isOptimized (), new HASLSBTargetsManager (normalDelay, deathDelay));
  -            this._ssp.setMultipleContainers (cis, props, haAppPathName);
  -            this.statelessObject = (EJBObject)Proxy.newProxyInstance 
(((ContainerInvokerContainer)container).getRemoteClass ().getClassLoader (),
  -            new Class[]
  -            { ((ContainerInvokerContainer)container).getRemoteClass () } ,
  -            _ssp );
  -         }
  -         else
  -            this._ssp.setMultipleContainers (cis, props, haAppPathName);
  -      }
  -      catch (Exception e)
  -      {
  -         e.printStackTrace ();
  -
  -         // Create EJBHome object
  -         // We add the Handle methods to the Home
  -         Class handleClass;
  -         try
  -         {
  -            handleClass = Class.forName ("javax.ejb.Handle");
  -         } catch (Exception eh)
  -         {
  -            log.error("No javax.ejb.Handle", e);
  -            handleClass = null;
  -         }
  -         this.home = (EJBHome)Proxy.newProxyInstance 
(((ContainerInvokerContainer)container).getHomeClass ().getClassLoader (),
  -         new Class[]
  -         { ((ContainerInvokerContainer)container).getHomeClass (), handleClass },
  -         new HomeProxy (ci.getJndiName (), ci.getEJBMetaData (), ci, ci.isOptimized 
()));
  -
  -         // problem? create a standard stateless proxy object...
  -         this.statelessObject = (EJBObject)Proxy.newProxyInstance 
(((ContainerInvokerContainer)container).getRemoteClass ().getClassLoader (),
  -         new Class[]
  -         { ((ContainerInvokerContainer)container).getRemoteClass () } ,
  -         new StatelessSessionProxy (ci.getJndiName (), ci, ci.isOptimized ()));
  -      }
  +      throw new RuntimeException("NOT IMPLEMENTED");
      }
   
  -   private void unregisterFromHA ()
  +   public Collection getEntityCollection(Collection ids)
      {
  -      if (!(container.getBeanMetaData () instanceof EntityMetaData) &&
  -      ((SessionMetaData)container.getBeanMetaData ()).isStateless ())
  -      {
  -         try
  -         {
  -            // Get the HAConfigService
  -            //
  -            Context ctx = new InitialContext ();
  -            HAConfigNode ha = (HAConfigNode)ctx.lookup ("java:/HAConfigServer");
  -
  -            try
  -            {
  -               ha.unregisterContainer (_appName , _beanName, 
HAConfigNode.REMOTE_TYPE);
  -            }
  -            catch (Exception e)
  -            {
  -               e.printStackTrace ();
  -            }
  -         }
  -         // do nothing, this may be due to a standard shutdown : HAConfigServer is 
already unbounded.
  -         catch (Exception e)
  -         {}
  -      }
  +      throw new RuntimeException("NOT IMPLEMENTED");
      }
  -   // ********SL********END
  -
   }
  +
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to