User: patriot1burke
  Date: 01/09/16 08:29:07

  Modified:    src/main/org/jboss/ha HAPartitionImpl.java
                        DistributedReplicantManagerImpl.java
                        ClusterPartition.java
  Log:
  still a work in progress, but I'm progressing...Still doesn't work yet!!!
  
  Revision  Changes    Path
  1.3       +53 -34    jbossmx/src/main/org/jboss/ha/HAPartitionImpl.java
  
  Index: HAPartitionImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbossmx/src/main/org/jboss/ha/HAPartitionImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HAPartitionImpl.java      2001/09/15 15:53:57     1.2
  +++ HAPartitionImpl.java      2001/09/16 15:29:07     1.3
  @@ -28,6 +28,8 @@
   import java.io.Serializable;
   import javax.naming.InitialContext;
   
  +import org.jboss.logging.Logger;
  +
   public class HAPartitionImpl extends RpcDispatcher implements HAPartition, 
MembershipListener, MessageListener
   {
      protected HashMap rpcHandlers = new HashMap();
  @@ -39,32 +41,33 @@
      protected JChannel channel = null;
      protected DistributedReplicantManagerImpl replicantManager;
      protected String nodeName;
  +   protected Logger log = null;
      final MethodLookup  method_lookup_clos=new MethodLookupClos();
   
      public HAPartitionImpl(String partitionName, JChannel channel,
                             boolean deadlock_detection) throws Exception
      {
         super(channel, null, null, new Object(), false);
  -      System.out.println("called super");
  +      this.log = Logger.create("HAPartition:" + partitionName);
         this.channel = channel;
         this.partitionName = partitionName;
      }
   
      public void init() throws Exception
      {
  -      System.out.println("SetMembershipListener");
  +      log.info("SetMembershipListener");
         SetMembershipListener(this);
  -      System.out.println("SetMessageListener");
  +      log.info("SetMessageListener");
         SetMessageListener(this);
  -      System.out.println("get nodeName");
  +      log.info("get nodeName");
         this.nodeName = channel.GetLocalAddress().toString();
  -      System.out.println("create replicant manager");
  +      log.info("create replicant manager");
         this.replicantManager = new DistributedReplicantManagerImpl(this);
  -      System.out.println("init replicant manager");
  +      log.info("init replicant manager");
         this.replicantManager.init();
  -      System.out.println("bind replicant manager");
  +      log.info("bind replicant manager");
         new InitialContext().bind("/HAPartition/" + partitionName, this);
  -      System.out.println("done initing..");
  +      log.info("done initing..");
      }
   
      public void close() throws Exception
  @@ -111,17 +114,20 @@
       */
      public ArrayList callMethodOnCluster(String objName, String methodName, Object[] 
args, boolean excludeSelf) throws Exception
      {
  +      ArrayList rtn = new ArrayList();
         MethodCall m = new MethodCall(objName + "." + methodName, args);
         RspList rsp = this.CallRemoteMethods(null, m, GroupRequest.GET_ALL, timeout);
  -      ArrayList rtn = new ArrayList(rsp.size());
  -      for (int i = 0; i < rsp.size(); i++)
  -         rtn.add(rsp.elementAt(i));
  +      if (rsp != null)
  +      {
  +         for (int i = 0; i < rsp.size(); i++)
  +            rtn.add(rsp.elementAt(i));
  +      }
         
         if (!excludeSelf)
         {
            Object handler = rpcHandlers.get(objName);
            Object retval=m.Invoke(handler, method_lookup_clos);
  -         rtn.add(retval);
  +         if (retval != null) rtn.add(retval);
         }
         return rtn;
      }
  @@ -139,10 +145,8 @@
         stateHandlers.put(objectName, subscriber);
         // We must now syncrhonize new state transfer subscriber 
         boolean rc = channel.GetState(null, 8000);
  -      /* 
  -         if (rc) System.out.println("State was retrieved successfully");
  -         else System.out.println("State could not be retrieved, (must be first 
member of group)");
  -      */
  +      if (rc) log.info("State was retrieved successfully");
  +      else log.info("State could not be retrieved, (must be first member of 
group)");
      }
   
      public void unsubscribeFromStateTransferEvents(String objectName, 
HAPartition.HAPartitionStateTransfer subscriber)
  @@ -154,15 +158,23 @@
      // MessageLister methods
      public Object GetState()
      {
  -      HashMap state = new HashMap();
  -      Iterator keys = stateHandlers.keySet().iterator();
  -      while (keys.hasNext())
  -      {
  -         String key = (String)keys.next();
  -         HAPartition.HAPartitionStateTransfer subscriber = 
(HAPartition.HAPartitionStateTransfer)stateHandlers.get(key);
  -         state.put(key, subscriber.getCurrentState());
  +      try
  +      {
  +         HashMap state = new HashMap();
  +         Iterator keys = stateHandlers.keySet().iterator();
  +         while (keys.hasNext())
  +         {
  +            String key = (String)keys.next();
  +            HAPartition.HAPartitionStateTransfer subscriber = 
(HAPartition.HAPartitionStateTransfer)stateHandlers.get(key);
  +            state.put(key, subscriber.getCurrentState());
  +         }
  +         return state;
         }
  -      return state;
  +      catch (Exception ex)
  +      {
  +         log.error("GetState failed", ex);
  +      }
  +      return null;
      }
   
      public void SetState(Object obj)
  @@ -171,7 +183,7 @@
         {
            if (obj == null) 
            {
  -            System.out.println("state is null");
  +            log.info("state is null");
               return;
            }
            HashMap state = (HashMap)obj;
  @@ -186,7 +198,7 @@
         }
         catch (Exception ex)
         {
  -         ex.printStackTrace();
  +         log.error("SetState failed", ex);
         }
      }
   
  @@ -228,17 +240,24 @@
   
      public void ViewAccepted(View newView)
      {
  -      Vector oldMembers = this.members;
  -      Vector allMembers = newView.GetMembers();
  -      Vector deadMembers = getDeadMembers(oldMembers, allMembers);
  -      Vector newMembers = getNewMembers(oldMembers, allMembers);
  -      this.members = allMembers;
  -      synchronized(this.listeners)
  +      try
         {
  -         for (int i = 0; i < listeners.size(); i++)
  +         Vector oldMembers = this.members;
  +         Vector allMembers = newView.GetMembers();
  +         Vector deadMembers = getDeadMembers(oldMembers, allMembers);
  +         Vector newMembers = getNewMembers(oldMembers, allMembers);
  +         this.members = allMembers;
  +         synchronized(this.listeners)
            {
  -            
((HAPartition.HAMembershipListener)listeners.get(i)).membershipChanged(deadMembers, 
newMembers, allMembers);
  +            for (int i = 0; i < listeners.size(); i++)
  +            {
  +               
((HAPartition.HAMembershipListener)listeners.get(i)).membershipChanged(deadMembers, 
newMembers, allMembers);
  +            }
            }
  +      }
  +      catch (Exception ex)
  +      {
  +         log.error("ViewAccepted failed", ex);
         }
      }
   
  
  
  
  1.3       +62 -32    
jbossmx/src/main/org/jboss/ha/DistributedReplicantManagerImpl.java
  
  Index: DistributedReplicantManagerImpl.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jbossmx/src/main/org/jboss/ha/DistributedReplicantManagerImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DistributedReplicantManagerImpl.java      2001/09/15 15:53:57     1.2
  +++ DistributedReplicantManagerImpl.java      2001/09/16 15:29:07     1.3
  @@ -9,6 +9,8 @@
   import java.rmi.server.UnicastRemoteObject;
   import java.io.Serializable;
   
  +import org.jboss.logging.Logger;
  +
   public class DistributedReplicantManagerImpl extends RemoteServer
      implements DistributedReplicantManager,
                 HAPartition.HAPartitionStateTransfer,
  @@ -17,26 +19,33 @@
      protected HashMap replicants = new HashMap();
      protected HashMap keyListeners = new HashMap();
      protected HAPartition partition;
  +   protected Logger log = null;
   
      protected final static String SERVICE_NAME = "DistributedReplicantManager";
   
      public DistributedReplicantManagerImpl(HAPartition partition)
      {
         this.partition = partition;
  +      this.log = Logger.create(partition.getPartitionName() + ":ReplicantManager");
      }
   
      public void init() throws Exception
      {
         // When we subscribe to state transfer events, GetState will be called to 
initialize
         // this service.
  -      partition.subscribeToStateTransferEvents(SERVICE_NAME, this);
  -      partition.registerMembershipListener(this);
  +      log.info("registerRPCHandler");
         partition.registerRPCHandler(SERVICE_NAME, this);
  +      log.info("registerMembershipListener");
  +      partition.registerMembershipListener(this);
  +      log.info("subscribeToStateTransferEvents");
  +      partition.subscribeToStateTransferEvents(SERVICE_NAME, this);
   
         // Export myself as an RMI server
  +      log.info("Export myself as an RMI server");
         UnicastRemoteObject.exportObject(this, 0);
   
         // Register myself as a replicant of DistributedReplicantManager
  +      log.info("Register myself as a replicant of DistributedReplicantManager");
         add(SERVICE_NAME, this);
      }
   
  @@ -69,26 +78,33 @@
         // Here we only care about deadMembers.  Purge all replicant lists of 
deadMembers
         // and then notify all listening nodes.
   
  -      synchronized (this.replicants)
  +      try
         {
  -         Iterator keys = replicants.keySet().iterator();
  -         while (keys.hasNext())
  +         synchronized (this.replicants)
            {
  -            String key = (String)keys.next();
  -            HashMap replicant = (HashMap)replicants.get(key);
  -            boolean modified = false;
  -            for (int i = 0; i < deadMembers.size(); i++)
  +            Iterator keys = replicants.keySet().iterator();
  +            while (keys.hasNext())
               {
  -               String node = deadMembers.elementAt(i).toString();
  -               Object removed = replicant.remove(node);
  -               if (removed != null) modified = true;
  +               String key = (String)keys.next();
  +               HashMap replicant = (HashMap)replicants.get(key);
  +               boolean modified = false;
  +               for (int i = 0; i < deadMembers.size(); i++)
  +               {
  +                  String node = deadMembers.elementAt(i).toString();
  +                  Object removed = replicant.remove(node);
  +                  if (removed != null) modified = true;
  +               }
  +               if (modified)
  +               {
  +                  notifyKeyListeners(key, new ArrayList(replicant.values()));
  +               }
               }
  -            if (modified)
  -            {
  -               notifyKeyListeners(key, new ArrayList(replicant.values()));
  -            }
            }
         }
  +      catch (Exception ex)
  +      {
  +         log.error("membershipChanged failed", ex);
  +      }
      }
   
      ///////////////
  @@ -97,16 +113,23 @@
   
      public void _add(String key, String nodeName, Serializable replicant)
      {
  -      synchronized(this.replicants)
  +      try
         {
  -         HashMap rep = (HashMap)replicants.get(key);
  -         if (rep == null)
  +         synchronized(this.replicants)
            {
  -             rep = new HashMap();
  -             replicants.put (key, rep);
  +            HashMap rep = (HashMap)replicants.get(key);
  +            if (rep == null)
  +            {
  +               rep = new HashMap();
  +               replicants.put (key, rep);
  +            }
  +            rep.put(nodeName, replicant);
  +            notifyKeyListeners(key, new ArrayList(rep.values()));
            }
  -         rep.put(nodeName, replicant);
  -         notifyKeyListeners(key, new ArrayList(rep.values()));
  +      }
  +      catch (Exception ex)
  +      {
  +         log.error("_add failed", ex);
         }
      }
   
  @@ -118,20 +141,27 @@
   
      public void _remove(String key, String nodeName)
      {
  -      synchronized(this.replicants)
  +      try
         {
  -         HashMap replicant = (HashMap)replicants.get(key);
  -         if (replicant == null) return;
  -         Object removed = replicant.remove(nodeName);
  -         if (removed != null)
  +         synchronized(this.replicants)
            {
  -            Collection values = replicant.values();
  -            notifyKeyListeners(key, new ArrayList(values));
  -            if (values.size() == 0)
  +            HashMap replicant = (HashMap)replicants.get(key);
  +            if (replicant == null) return;
  +            Object removed = replicant.remove(nodeName);
  +            if (removed != null)
               {
  -               replicants.remove(key);
  +               Collection values = replicant.values();
  +               notifyKeyListeners(key, new ArrayList(values));
  +               if (values.size() == 0)
  +               {
  +                  replicants.remove(key);
  +            }
               }
            }
  +      }
  +      catch (Exception ex)
  +      {
  +         log.error("_remove failed", ex);
         }
      }
   
  
  
  
  1.3       +2 -0      jbossmx/src/main/org/jboss/ha/ClusterPartition.java
  
  Index: ClusterPartition.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbossmx/src/main/org/jboss/ha/ClusterPartition.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ClusterPartition.java     2001/09/15 15:53:57     1.2
  +++ ClusterPartition.java     2001/09/16 15:29:07     1.3
  @@ -77,6 +77,8 @@
         JChannel channel = new JChannel(jgProps);
         channel.SetOpt(Channel.LOCAL, new Boolean(false));
         channel.SetOpt(Channel.GET_STATE_EVENTS, new Boolean(true));       
  +      channel.SetOpt(Channel.AUTO_RECONNECT, new Boolean(true));
  +      channel.SetOpt(Channel.AUTO_GETSTATE, new Boolean(true));
         log.info("Creating Partition");
         partition = new HAPartitionImpl(partitionName, channel, deadlock_detection);
         log.info("Connecting to channel");
  
  
  

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

Reply via email to