[JBoss-dev] CVS update: jbossmx/src/main/org/jboss/ha HARMIServerImpl.java

2001-09-24 Thread Bill Burke

  User: patriot1burke
  Date: 01/09/24 17:45:34

  Modified:src/main/org/jboss/ha HARMIServerImpl.java
  Log:
  more cleanup
  
  Revision  ChangesPath
  1.4   +47 -15jbossmx/src/main/org/jboss/ha/HARMIServerImpl.java
  
  Index: HARMIServerImpl.java
  ===
  RCS file: /cvsroot/jboss/jbossmx/src/main/org/jboss/ha/HARMIServerImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HARMIServerImpl.java  2001/09/21 21:58:47 1.3
  +++ HARMIServerImpl.java  2001/09/25 00:45:34 1.4
  @@ -7,8 +7,13 @@
   import java.util.Collection;
   import java.rmi.Remote;
   import java.rmi.server.RemoteStub;
  +import java.rmi.server.RemoteServer;
   import java.rmi.server.UnicastRemoteObject;
   import java.io.Serializable;
  +import java.io.Externalizable;
  +import java.io.ObjectInput;
  +import java.io.ObjectOutput;
  +import java.io.IOException;
   import java.rmi.RemoteException;
   
   import org.jboss.logging.Logger;
  @@ -16,11 +21,12 @@
   import java.rmi.MarshalledObject;
   import java.lang.reflect.Method;
   import java.lang.reflect.InvocationTargetException;
  +import java.lang.reflect.Proxy;
   
   public class HARMIServerImpl
  -
  -implements HARMIServer, DistributedReplicantManager.ReplicantListener
  -
  +   implements HARMIServer, 
  +  DistributedReplicantManager.ReplicantListener, 
  +  java.lang.reflect.InvocationHandler
   {
  protected String replicantName;
  protected long lastSet = System.currentTimeMillis();
  @@ -28,10 +34,13 @@
  protected Object handler;
  protected HashMap invokerMap = new HashMap ();
  protected HAPartition partition = null;
  -   protected RemoteStub myStub = null;
  protected Logger log;
  -   
  -   public HARMIServerImpl (HAPartition partition, String replicantName, Object 
handler) throws Exception
  +   protected HARMIClient client;
  +   protected RemoteStub rmistub;
  +   protected Object stub;
  +   protected Object proxy;
  +
  +   public HARMIServerImpl (HAPartition partition, String replicantName, Class intf, 
Object handler, LoadBalancePolicy policy) throws Exception
  {
 this.replicantName = replicantName;
 this.partition = partition;
  @@ -41,13 +50,26 @@
 
 for (int i = 0; i  methods.length; i++)
invokerMap.put (new Long (RemoteMethodInvocation.calculateHash 
(methods[i])), methods[i]);
  -  
  -  this.myStub = UnicastRemoteObject.exportObject (this);
 
  +  this.rmistub = UnicastRemoteObject.exportObject (this);
  +  this.client = new HARMIClient(new Object[0], policy);
  +  this.stub = Proxy.newProxyInstance(
  + intf.getClassLoader(),
  + new Class[] { intf },
  + this.client);
  +  this.proxy = Proxy.newProxyInstance(
  + intf.getClassLoader(),
  + new Class[] { intf },
  + this);
 partition.getDistributedReplicantManager ().registerListener (replicantName, 
this);
  -  partition.getDistributedReplicantManager ().add (replicantName, this.myStub);
  +  partition.getDistributedReplicantManager ().add (replicantName, rmistub);
  }
  
  +   public Object getHAStub()
  +   {
  +  return stub;
  +   }
  +
  public void destroy ()
  {
 try
  @@ -60,11 +82,6 @@
 {e.printStackTrace ();}
  }
  
  -   public RemoteStub getStub ()
  -   {
  -  return this.myStub;
  -   }
  -   
  public long getTag ()
  {
 return lastSet;
  @@ -74,9 +91,10 @@
  {
 log.info(replicantsChanged + key +  to  + newReplicants.size());
 replicants = newReplicants;
  +  client.setTargets(replicants.toArray());
 lastSet = System.currentTimeMillis ();
  }
  -   
  +
  public HARMIResponse invoke (long tag, MarshalledObject mimo) throws Exception
  {
 RemoteMethodInvocation rmi = (RemoteMethodInvocation)mimo.get ();
  @@ -108,4 +126,18 @@
throw (Exception)ite.getTargetException ();
 }
  }
  +
  +   public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
  +   {
  +  try
  +  {
  + log.info(collocated call);
  + return method.invoke(handler, args);
  +  }
  +  catch (InvocationTargetException ite)
  +  {
  + throw ite.getTargetException ();
  +  }
  +   }
  + 
   }
  
  
  

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



[JBoss-dev] CVS update: jbossmx/src/main/org/jboss/ha HARMIServerImpl.java

2001-09-21 Thread Bill Burke

  User: patriot1burke
  Date: 01/09/21 14:58:47

  Modified:src/main/org/jboss/ha HARMIServerImpl.java
  Log:
  added logging
  
  Revision  ChangesPath
  1.3   +5 -3  jbossmx/src/main/org/jboss/ha/HARMIServerImpl.java
  
  Index: HARMIServerImpl.java
  ===
  RCS file: /cvsroot/jboss/jbossmx/src/main/org/jboss/ha/HARMIServerImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HARMIServerImpl.java  2001/09/20 23:29:27 1.2
  +++ HARMIServerImpl.java  2001/09/21 21:58:47 1.3
  @@ -23,19 +23,20 @@
   
   {
  protected String replicantName;
  -   protected long lastSet = 0;
  +   protected long lastSet = System.currentTimeMillis();
  protected ArrayList replicants;
  protected Object handler;
  protected HashMap invokerMap = new HashMap ();
  protected HAPartition partition = null;
  protected RemoteStub myStub = null;
  +   protected Logger log;
  
  public HARMIServerImpl (HAPartition partition, String replicantName, Object 
handler) throws Exception
  {
 this.replicantName = replicantName;
 this.partition = partition;
 this.handler = handler;
  -  
  +  this.log = Logger.create(this.getClass());
 Method[] methods = handler.getClass ().getMethods ();
 
 for (int i = 0; i  methods.length; i++)
  @@ -71,6 +72,7 @@
  
  public void replicantsChanged (String key, ArrayList newReplicants)
  {
  +  log.info(replicantsChanged + key +  to  + newReplicants.size());
 replicants = newReplicants;
 lastSet = System.currentTimeMillis ();
  }
  @@ -106,4 +108,4 @@
throw (Exception)ite.getTargetException ();
 }
  }
  -}
  \ No newline at end of file
  +}
  
  
  

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



[JBoss-dev] CVS update: jbossmx/src/main/org/jboss/ha HARMIServerImpl.java HARMIServer.java HARMIResponse.java HARMIClient.java HARMITarget.java

2001-09-20 Thread Bill Burke

  User: patriot1burke
  Date: 01/09/20 00:57:41

  Modified:src/main/org/jboss/ha HARMITarget.java
  Added:   src/main/org/jboss/ha HARMIServerImpl.java HARMIServer.java
HARMIResponse.java HARMIClient.java
  Log:
  work in progress
  
  Revision  ChangesPath
  1.3   +1 -5  jbossmx/src/main/org/jboss/ha/HARMITarget.java
  
  Index: HARMITarget.java
  ===
  RCS file: /cvsroot/jboss/jbossmx/src/main/org/jboss/ha/HARMITarget.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HARMITarget.java  2001/09/19 23:57:43 1.2
  +++ HARMITarget.java  2001/09/20 07:57:41 1.3
  @@ -22,7 +22,7 @@
*
*   @author a href=mailto:[EMAIL PROTECTED];Sacha Labourey/a
*   @author a href=mailto:[EMAIL PROTECTED];Bill Burke/a
  - *   @version $Revision: 1.2 $
  + *   @version $Revision: 1.3 $
*
*   pbRevisions:/b
*
  @@ -224,10 +224,6 @@
   {
  // ignore
  System.out.println(Connection failure);
  -}
  -else if (targetException instanceof RemoteException)
  -{
  -   System.out.println(RemoteException called:  + 
targetException.getClass().getName());
   }
   else
   {
  
  
  
  1.1  jbossmx/src/main/org/jboss/ha/HARMIServerImpl.java
  
  Index: HARMIServerImpl.java
  ===
  package org.jboss.ha;
  
  import java.util.Vector;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Collection;
  import java.rmi.Remote;
  import java.rmi.server.RemoteStub;
  import java.rmi.server.UnicastRemoteObject;
  import java.io.Serializable;
  import java.rmi.RemoteException;
  
  import org.jboss.logging.Logger;
  import org.jboss.ejb.plugins.jrmp.interfaces.RemoteMethodInvocation;
  import java.rmi.MarshalledObject;
  import java.lang.reflect.Method;
  import java.lang.reflect.InvocationTargetException;
  
  public class HARMIServerImpl
 implements HARMIServer, DistributedReplicantManager.ReplicantListener
  {
 protected String replicantName;
 protected long lastSet = 0;
 protected ArrayList replicants;
 protected Object handler;
 protected HashMap invokerMap = new HashMap();
 public HARMIServerImpl(HAPartition partition, String replicantName, Object 
handler) throws Exception
 {
this.replicantName = replicantName;
this.handler = handler;
Method[] methods = handler.getClass().getMethods();
for (int i = 0; i  methods.length; i++)
{
   invokerMap.put(new Long(RemoteMethodInvocation.calculateHash(methods[i])), 
methods[i]);
}
RemoteStub stub = UnicastRemoteObject.exportObject(this);
partition.getDistributedReplicantManager().registerListener(replicantName, 
this);
partition.getDistributedReplicantManager().add(replicantName, stub);
 }
  
 public long getTag()
 {
return lastSet;
 }
  
 public void replicantsChanged(String key, ArrayList newReplicants)
 {
replicants = newReplicants;
lastSet = System.currentTimeMillis();
 }
  
 public HARMIResponse invoke(long tag, MarshalledObject mimo) throws Exception
 {
RemoteMethodInvocation rmi = (RemoteMethodInvocation)mimo.get();
rmi.setMethodMap(invokerMap);
Method method = rmi.getMethod();
try
{
   HARMIResponse rsp = new HARMIResponse();
   if (tag  lastSet)
   {
  rsp.newReplicants = replicants.toArray();
  rsp.tag = lastSet;
   }
   rsp.response = method.invoke(handler, rmi.getArguments());
   return rsp;
}
catch (IllegalAccessException iae)
{
   throw iae;
}
catch (IllegalArgumentException iae)
{
   throw iae;
}
catch (InvocationTargetException ite)
{
   throw (Exception)ite.getTargetException();
}
 }
  }
  
  
  
  
  
  1.1  jbossmx/src/main/org/jboss/ha/HARMIServer.java
  
  Index: HARMIServer.java
  ===
  package org.jboss.ha;
  
  import java.util.Vector;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Collection;
  import java.rmi.Remote;
  import java.rmi.server.RemoteStub;
  import java.rmi.server.UnicastRemoteObject;
  import java.io.Serializable;
  import java.rmi.RemoteException;
  
  import org.jboss.logging.Logger;
  import org.jboss.ejb.plugins.jrmp.interfaces.RemoteMethodInvocation;
  import java.rmi.MarshalledObject;
  import java.lang.reflect.Method;
  import java.lang.reflect.InvocationTargetException;
  
  public interface HARMIServer