User: azakkerman
  Date: 01/06/06 10:48:29

  Modified:    src/main/org/jboss/tm/plugins/tyrex CoordinatorInvoker.java
                        CoordinatorRemote.java ResourceInvoker.java
                        TyrexTxPropagationContext.java
  Log:
  Bug fix in ResourceRemote to return the Vote in prepare() and slight performance 
improvement by sending only a CoordinatorRemote stub and creating the coordinator 
proxy already on the remote side
  
  Revision  Changes    Path
  1.2       +7 -23     
jboss/src/main/org/jboss/tm/plugins/tyrex/CoordinatorInvoker.java
  
  Index: CoordinatorInvoker.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/tm/plugins/tyrex/CoordinatorInvoker.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CoordinatorInvoker.java   2001/05/22 22:12:57     1.1
  +++ CoordinatorInvoker.java   2001/06/06 17:48:29     1.2
  @@ -33,10 +33,10 @@
    *        CoordinatorRemote,
    *        ResourceRemote
    *   @author <a href="mailto:[EMAIL PROTECTED]";>Anatoly Akkerman</a>
  - *   @version $Revision: 1.1 $
  + *   @version $Revision: 1.2 $
    */
   
  -class CoordinatorInvoker implements InvocationHandler, Externalizable {
  +class CoordinatorInvoker implements InvocationHandler {
   
       private static Method register_resource;
   
  @@ -52,27 +52,10 @@
   
       private CoordinatorRemoteInterface remoteCoordinator;
   
  -    public CoordinatorInvoker() {
  -      // for externalization to work
  +    protected CoordinatorInvoker (CoordinatorRemoteInterface coord) {
  +      remoteCoordinator = coord;
       }
   
  -    protected CoordinatorInvoker (Coordinator coord) {
  -      try {
  -        remoteCoordinator = new CoordinatorRemote(coord);
  -      } catch (Exception e) {
  -        e.printStackTrace();
  -        Logger.warning("CoordinatorInvoker could not instantiate properly, there 
will be problems with this transaction!");
  -      }
  -    }
  -
  -    public void writeExternal(java.io.ObjectOutput out) throws IOException {
  -      out.writeObject(remoteCoordinator);
  -    }
  -
  -    public void readExternal(java.io.ObjectInput in) throws IOException, 
ClassNotFoundException{
  -      remoteCoordinator = (CoordinatorRemoteInterface) in.readObject();
  -    }
  -
       public Object invoke (Object proxy, Method method, Object[] args)
           throws Throwable {
   
  @@ -87,8 +70,9 @@
             // DEBUG          Logger.debug("TyrexTxPropagationContex: Created Proxy 
for Resource, calling Proxy for Coordinator");
             // call our Coordinator
             remoteCoordinator.register_resource(serializableResource);
  -          // register_resource in our remoteCoordinator is a 'void' method call
  -          // we ignore the RecoveryCoordinator for now
  +          // register_resource in RemoteCoordinator is a 'void' method call
  +          // while the actual Coordinator returns a RecoveryCoordinator
  +          // for simplicity we ignore the RecoveryCoordinator for now
             return null;
           }
           else {
  
  
  
  1.2       +5 -2      jboss/src/main/org/jboss/tm/plugins/tyrex/CoordinatorRemote.java
  
  Index: CoordinatorRemote.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/tm/plugins/tyrex/CoordinatorRemote.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CoordinatorRemote.java    2001/05/22 22:12:57     1.1
  +++ CoordinatorRemote.java    2001/06/06 17:48:29     1.2
  @@ -7,8 +7,8 @@
   package org.jboss.tm.plugins.tyrex;
   
   import java.rmi.Remote;
  -import java.rmi.RemoteException;
   import java.lang.reflect.Proxy;
  +import java.rmi.RemoteException;
   
   import org.omg.CosTransactions.Coordinator;
   import org.omg.CosTransactions._CoordinatorImplBase;
  @@ -25,7 +25,7 @@
    *
    *   @see CoordinatorRemoteInterface, CoordinatorInvoker, ResourceRemote
    *   @author <a href="mailto:[EMAIL PROTECTED]";>Anatoly Akkerman</a>
  - *   @version $Revision: 1.1 $
  + *   @version $Revision: 1.2 $
    */
   
   public class CoordinatorRemote extends java.rmi.server.UnicastRemoteObject 
implements CoordinatorRemoteInterface {
  @@ -40,6 +40,9 @@
       // DEBUG    Logger.debug("CoordinatorRemote: Registering resource");
       RecoveryCoordinator recoveryCoord = 
localCoordinator.register_resource(serializableResource);
       // ignore the recovery coordinator for now
  +    // if we choose, we can wrap the RecoveryCoordinator
  +    // and return its serializable dynamic proxy to the other side
  +
       // DEBUG    Logger.debug("CoordinatorRemote: Resource registered");
     }
   }
  
  
  
  1.2       +2 -3      jboss/src/main/org/jboss/tm/plugins/tyrex/ResourceInvoker.java
  
  Index: ResourceInvoker.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/tm/plugins/tyrex/ResourceInvoker.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ResourceInvoker.java      2001/05/22 22:12:57     1.1
  +++ ResourceInvoker.java      2001/06/06 17:48:29     1.2
  @@ -30,7 +30,7 @@
    *        ResourceRemote,
    *        CoordinatorRemote
    *   @author <a href="mailto:[EMAIL PROTECTED]";>Anatoly Akkerman</a>
  - *   @version $Revision: 1.1 $
  + *   @version $Revision: 1.2 $
    */
   
   public class ResourceInvoker implements InvocationHandler, Externalizable {
  @@ -85,8 +85,7 @@
   
       if (method.equals(prepare)) {
         // DEBUG      Logger.debug("ResourceInvoker: calling prepare()");
  -      remoteResource.prepare();
  -      return null;
  +      return remoteResource.prepare();
       }
       else if (method.equals(rollback)) {
         // DEBUG      Logger.debug("ResourceInvoker: calling rollback()");
  
  
  
  1.2       +37 -18    
jboss/src/main/org/jboss/tm/plugins/tyrex/TyrexTxPropagationContext.java
  
  Index: TyrexTxPropagationContext.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/tm/plugins/tyrex/TyrexTxPropagationContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TyrexTxPropagationContext.java    2001/05/22 22:12:57     1.1
  +++ TyrexTxPropagationContext.java    2001/06/06 17:48:29     1.2
  @@ -10,6 +10,7 @@
   import java.io.ObjectOutput;
   import java.io.ObjectInput;
   import java.io.IOException;
  +import java.rmi.RemoteException;
   
   import org.jboss.logging.Logger;
   
  @@ -37,7 +38,7 @@
    *        org.omg.CosTransactions.Coordinator,
    *        java.lang.reflect.Proxy
    *   @author <a href="mailto:[EMAIL PROTECTED]";>Anatoly Akkerman</a>
  - *   @version $Revision: 1.1 $
  + *   @version $Revision: 1.2 $
    */
   
   public class TyrexTxPropagationContext implements Externalizable {
  @@ -49,22 +50,32 @@
     }
   
     protected TyrexTxPropagationContext (PropagationContext tpc) {
  -    this.isNull = false; // this is not a null Propagation Context
  -    this.timeout = tpc.timeout;
  -    this.coord = (Coordinator) Proxy.newProxyInstance(getClass().getClassLoader(),
  -                                        new Class[] {Coordinator.class},
  -                                        new CoordinatorInvoker(tpc.current.coord));
  -    this.otid = tpc.current.otid;
  -    // DEBUG    Logger.debug("TyrexTxPropagationContext: created new tpc");
  +    try {
  +      this.isNull = false; // this is not a null Propagation Context
  +      this.timeout = tpc.timeout;
  +      this.coord = new CoordinatorRemote(tpc.current.coord);
  +      this.otid = tpc.current.otid;
  +      // DEBUG    Logger.debug("TyrexTxPropagationContext: created new tpc");
  +    } catch (RemoteException e) {
  +      // should never happen, we are instantiating the RemoteCoordinator
  +      // locally
  +      e.printStackTrace();
  +      Logger.warning("Impossible, CoordinatorRemote threw a RemoteException!");
  +    }
     }
   
     // this is called on the remote side
     protected PropagationContext getPropagationContext() {
   
  -    if ( !isNull && (tpc == null) ) {
  -      // create once
  +    if ( !isNull && (tpc == null)) {
  +      // create these guys once
  +      // perhaps the coordinator Proxy can be cached and not recreated each
  +      // time we come in with the same tpc
  +      coordProxy = (Coordinator) Proxy.newProxyInstance(getClass().getClassLoader(),
  +                                        new Class[] {Coordinator.class},
  +                                        new CoordinatorInvoker(this.coord));
         tpc = new PropagationContext( this.timeout,
  -                                    new TransIdentity(this.coord,
  +                                    new TransIdentity(this.coordProxy,
                                                         null,
                                                         this.otid),
                                       new TransIdentity[0], // no parents, but not 
null
  @@ -81,8 +92,8 @@
         if (! isNull) {
           out.writeInt(this.timeout);
           // DEBUG       Logger.debug("TPC: wrote timeout");
  -        out.writeObject((Proxy) this.coord);
  -        // DEBUG       Logger.debug("TPC: wrote CoordinatorProxy");
  +        out.writeObject(this.coord);
  +        // DEBUG       Logger.debug("TPC: wrote CoordinatorRemote stub");
           out.writeObject(this.otid); // otid implements IDLEntity which extends 
Serializable
           // DEBUG       Logger.debug("TPC: wrote otid");
         }
  @@ -99,8 +110,8 @@
         if (!isNull) {
           this.timeout = in.readInt();
           // DEBUG      Logger.debug("TPC: read timeout");
  -        this.coord = (Coordinator) in.readObject();
  -        // DEBUG      Logger.debug("TPC: read coordinator");
  +        this.coord = (CoordinatorRemoteInterface) in.readObject();
  +        // DEBUG      Logger.debug("TPC: read coordinator stub");
           this.otid = (otid_t) in.readObject();
           // DEBUG      Logger.debug("TPC: read otid");
         }
  @@ -115,9 +126,7 @@
      */
   
     protected int timeout;
  -  // this is a Proxy for the local transaction coordinator
  -  // since we need to serialize the Coordinator and it is not serializable
  -  protected Coordinator coord;
  +  protected CoordinatorRemoteInterface coord;
     protected otid_t otid;
   
     // this is a special field that gets propagated to the remote side to
  @@ -130,4 +139,14 @@
     // cached copy of tpc, so that we need to create it only once
     // on the remote side
     protected PropagationContext tpc = null;
  +
  +  // proxy that wraps the coordinator remote stub on the remote side
  +  // This proxy is created when the tpc arrives to the remote side and
  +  // it is given to the Tyrex TM as part of the recreated tpc
  +  // to register the subordinate transaction with the originator as a Resource.
  +  // When Tyrex invokes coordinator.register_resource, this Proxy wraps the Resource
  +  // with a dynamic Proxy and calls the coordinator remote object passing
  +  // it the Resource proxy instead of the actual Resource, so that the
  +  // coordination can proceed through RMI rather than CORBA
  +  protected Coordinator coordProxy = null;
   }
  
  
  

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

Reply via email to