User: patriot1burke
  Date: 01/12/31 12:40:50

  Modified:    src/main/org/jboss/ha/framework/server HAPartitionImpl.java
  Log:
  MarshalledInvocation used now
  
  Revision  Changes    Path
  1.12      +127 -127  
jbossmx/src/main/org/jboss/ha/framework/server/HAPartitionImpl.java
  
  Index: HAPartitionImpl.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jbossmx/src/main/org/jboss/ha/framework/server/HAPartitionImpl.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- HAPartitionImpl.java      2001/12/29 16:20:13     1.11
  +++ HAPartitionImpl.java      2001/12/31 20:40:50     1.12
  @@ -33,7 +33,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Sacha Labourey</a>.
    * @author <a href="mailto:[EMAIL PROTECTED]";>Bill Burke</a>.
  - * @version $Revision: 1.11 $
  + * @version $Revision: 1.12 $
    *
    * <p><b>Revisions:</b><br>
    */
  @@ -44,13 +44,13 @@
   {
      // Constants -----------------------------------------------------
      
  -   final JavaGroups.MethodLookup method_lookup_clos=new JavaGroups.MethodLookupClos 
();
  +   final JavaGroups.MethodLookup method_lookup_clos=new 
JavaGroups.MethodLookupClos();
      
      // Attributes ----------------------------------------------------
      
  -   protected HashMap rpcHandlers = new HashMap ();
  -   protected HashMap stateHandlers = new HashMap ();
  -   protected ArrayList listeners = new ArrayList ();
  +   protected HashMap rpcHandlers = new HashMap();
  +   protected HashMap stateHandlers = new HashMap();
  +   protected ArrayList listeners = new ArrayList();
      protected Vector members = null;
      
      protected String partitionName;
  @@ -72,15 +72,15 @@
      
      // Constructors --------------------------------------------------
          
  -   public HAPartitionImpl (String partitionName, JavaGroups.JChannel channel, 
boolean deadlock_detection, MBeanServer server) throws Exception
  +   public HAPartitionImpl(String partitionName, JavaGroups.JChannel channel, 
boolean deadlock_detection, MBeanServer server) throws Exception
      {
  -      this (partitionName, channel, deadlock_detection);
  +      this(partitionName, channel, deadlock_detection);
         this.server = server;
      }
      
  -   public HAPartitionImpl (String partitionName, JavaGroups.JChannel channel, 
boolean deadlock_detection) throws Exception
  +   public HAPartitionImpl(String partitionName, JavaGroups.JChannel channel, 
boolean deadlock_detection) throws Exception
      {
  -      super(channel, null, null, new Object (), false); // init RpcDispatcher with 
a fake target object
  +      super(channel, null, null, new Object(), false); // init RpcDispatcher with a 
fake target object
         this.log = Logger.getLogger("HAPartition:" + partitionName);
         this.channel = channel;
         this.partitionName = partitionName;
  @@ -88,50 +88,50 @@
      
       // Public --------------------------------------------------------
      
  -   public void init () throws Exception
  +   public void init() throws Exception
      {
         // Subscribe to dHA events comming generated by the JavaGroups protocol stack
         //
  -      log.debug ("SetMembershipListener");
  -      SetMembershipListener (this);
  -      log.debug ("SetMessageListener");
  -      SetMessageListener (this);
  +      log.debug("SetMembershipListener");
  +      SetMembershipListener(this);
  +      log.debug("SetMessageListener");
  +      SetMessageListener(this);
         
         // Create the DRM and link it to this HAPartition
         //
  -      log.debug ("create replicant manager");
  -      this.replicantManager = new DistributedReplicantManagerImpl (this);
  -      log.debug ("init replicant manager");
  -      this.replicantManager.init ();
  -      log.debug ("bind replicant manager");
  +      log.debug("create replicant manager");
  +      this.replicantManager = new DistributedReplicantManagerImpl(this);
  +      log.debug("init replicant manager");
  +      this.replicantManager.init();
  +      log.debug("bind replicant manager");
         
         // Create the DS and link it to this HAPartition
         //
  -      log.debug ("create distributed state");
  -      this.dsManager = new DistributedStateImpl (this, this.server);
  -      log.debug ("init distributed state service");
  -      this.dsManager.init ();
  -      log.debug ("bind distributed state service");
  +      log.debug("create distributed state");
  +      this.dsManager = new DistributedStateImpl(this, this.server);
  +      log.debug("init distributed state service");
  +      this.dsManager.init();
  +      log.debug("bind distributed state service");
   
         
         // Bind ourself in the public JNDI space
         //
  -      Context ctx = new InitialContext ();
  -      this.bind ("/HAPartition/" + partitionName, this, HAPartitionImpl.class, ctx);
  +      Context ctx = new InitialContext();
  +      this.bind("/HAPartition/" + partitionName, this, HAPartitionImpl.class, ctx);
         
  -      log.info ("done initing..");
  +      log.info("done initing..");
      }
      
  -   public void start () throws Exception
  +   public void start() throws Exception
      {
         // get current JG group properties
         //
  -      log.debug ("get nodeName");
  -      this.nodeName = channel.GetLocalAddress ().toString ();
  -      log.debug ("Get current members");
  -      JavaGroups.View view = channel.GetView ();
  +      log.debug("get nodeName");
  +      this.nodeName = channel.GetLocalAddress().toString();
  +      log.debug("Get current members");
  +      JavaGroups.View view = channel.GetView();
         this.members = (Vector)view.GetMembers().clone();
  -      log.info ("Num cluster members: " + members.size ());
  +      log.info("Num cluster members: " + members.size());
         
         // Update the initial view id
         //
  @@ -139,107 +139,107 @@
         
         // We must now syncrhonize new state transfer subscriber
         //
  -      boolean rc = channel.GetState (null, 8000);
  +      boolean rc = channel.GetState(null, 8000);
         if (rc)
  -         log.info ("State was retrieved successfully");
  +         log.info("State was retrieved successfully");
         else
  -         log.info ("State could not be retrieved, (must be first member of group)");
  +         log.info("State could not be retrieved, (must be first member of group)");
         
         // We start now able to start our DRM and DS
         //
  -      this.replicantManager.start ();
  -      this.dsManager.start ();
  +      this.replicantManager.start();
  +      this.dsManager.start();
      }
      
  -   public void close () throws Exception
  +   public void close() throws Exception
      {
  -      log.info ("Closing partition " + partitionName);
  +      log.info("Closing partition " + partitionName);
         // Stop the DRM and DS services
         //
  -      try {this.replicantManager.stop ();} catch (Exception printed) 
{printed.printStackTrace ();}
  -      try {this.dsManager.stop ();} catch (Exception printed) 
{printed.printStackTrace ();}
  +      try {this.replicantManager.stop();} catch (Exception printed) 
{printed.printStackTrace ();}
  +      try {this.dsManager.stop();} catch (Exception printed) 
{printed.printStackTrace();}
         
  -      try {channel.Close ();} catch (Exception printed) {printed.printStackTrace 
();}
  +      try {channel.Close();} catch (Exception printed) {printed.printStackTrace();}
         
  -      new InitialContext ().unbind ("/HAPartition/" + partitionName);
  -      log.info ("Partition " + partitionName + " closed.");
  +      new InitialContext().unbind("/HAPartition/" + partitionName);
  +      log.info("Partition " + partitionName + " closed.");
      }
      
      // JavaGroups.MessageListener implementation 
----------------------------------------------
   
      // MessageListener methods
      //
  -   public Object GetState ()
  +   public Object GetState()
      {
  -      log.info ("GetState called.");
  +      log.info("GetState called.");
         try
         {
            // we now get the sub-state of each HAPartitionStateTransfer subscribers 
and
            // build a "macro" state
            //
  -         HashMap state = new HashMap ();
  -         java.util.Iterator keys = stateHandlers.keySet ().iterator ();
  -         while (keys.hasNext ())
  +         HashMap state = new HashMap();
  +         java.util.Iterator keys = stateHandlers.keySet().iterator();
  +         while (keys.hasNext())
            {
  -            String key = (String)keys.next ();
  -            HAPartition.HAPartitionStateTransfer subscriber = 
(HAPartition.HAPartitionStateTransfer)stateHandlers.get (key);
  -            log.debug ("GetState for " + key);
  -            state.put (key, subscriber.getCurrentState ());
  +            String key = (String)keys.next();
  +            HAPartition.HAPartitionStateTransfer subscriber = 
(HAPartition.HAPartitionStateTransfer)stateHandlers.get(key);
  +            log.debug("GetState for " + key);
  +            state.put(key, subscriber.getCurrentState());
            }
            return state;
         }
         catch (Exception ex)
         {
  -         log.error ("GetState failed", ex);
  +         log.error("GetState failed", ex);
         }
         return null;
      }
      
  -   public void SetState (Object obj)
  +   public void SetState(Object obj)
      {
         try
         {
  -         log.info ("SetState called");
  +         log.info("SetState called");
            if (obj == null)
            {
  -            log.info ("state is null");
  +            log.info("state is null");
               return;
            }
            
            HashMap state = (HashMap)obj;
  -         java.util.Iterator keys = state.keySet ().iterator ();
  -         while (keys.hasNext ())
  +         java.util.Iterator keys = state.keySet().iterator();
  +         while (keys.hasNext())
            {
  -            String key = (String)keys.next ();
  -            log.info ("SetState for " + key);
  -            Object someState = state.get (key);
  -            HAPartition.HAPartitionStateTransfer subscriber = 
(HAPartition.HAPartitionStateTransfer)stateHandlers.get (key);
  +            String key = (String)keys.next();
  +            log.info("SetState for " + key);
  +            Object someState = state.get(key);
  +            HAPartition.HAPartitionStateTransfer subscriber = 
(HAPartition.HAPartitionStateTransfer)stateHandlers.get(key);
               if (subscriber != null)
               {
  -               subscriber.setCurrentState ((java.io.Serializable)someState);
  +               subscriber.setCurrentState((java.io.Serializable)someState);
               }
               else
               {
  -               log.info ("There is no stateHandler for: " + key);
  +               log.info("There is no stateHandler for: " + key);
               }
            }
         }
         catch (Exception ex)
         {
  -         log.error ("SetState failed", ex);
  +         log.error("SetState failed", ex);
         }
      }
      
  -   public void Receive (JavaGroups.Message msg)
  +   public void Receive(JavaGroups.Message msg)
      { /* complete */}
      
      // JavaGroups.MembershipListener implementation 
----------------------------------------------
      
  -   public void Suspect (JavaGroups.Address suspected_mbr) { log.info ("Suspected 
member: " + suspected_mbr); /* complete */  }
  +   public void Suspect(JavaGroups.Address suspected_mbr) { log.info("Suspected 
member: " + suspected_mbr); /* complete */  }
      
  -   public void Block () {}
  +   public void Block() {}
      
  -   public void ViewAccepted (JavaGroups.View newView)
  +   public void ViewAccepted(JavaGroups.View newView)
      {
         try
         {
  @@ -257,10 +257,10 @@
               return;
            }
            Vector oldMembers = this.members;
  -         Vector allMembers = newView.GetMembers ();
  -         log.info ("membership changed from " + this.members.size () + " to " + 
allMembers.size ());
  -         Vector deadMembers = getDeadMembers (oldMembers, allMembers);
  -         Vector newMembers = getNewMembers (oldMembers, allMembers);
  +         Vector allMembers = newView.GetMembers();
  +         log.info("membership changed from " + this.members.size() + " to " + 
allMembers.size());
  +         Vector deadMembers = getDeadMembers(oldMembers, allMembers);
  +         Vector newMembers = getNewMembers(oldMembers, allMembers);
            this.members = (Vector)allMembers.clone();
            
            
  @@ -268,45 +268,45 @@
            //
            synchronized(this.listeners)
            {
  -            for (int i = 0; i < listeners.size (); i++)
  +            for (int i = 0; i < listeners.size(); i++)
               {
                  try
                  {
  -               ((HAPartition.HAMembershipListener)listeners.get 
(i)).membershipChanged (deadMembers, newMembers, allMembers);
  +               
((HAPartition.HAMembershipListener)listeners.get(i)).membershipChanged(deadMembers, 
newMembers, allMembers);
                  }
                  catch (Exception printed)
                  {
                     // a problem in a listener should not prevent other members to 
receive the new view
                     //
  -                  printed.printStackTrace ();
  +                  printed.printStackTrace();
                  }
               }
            }
         }
         catch (Exception ex)
         {
  -         log.error ("ViewAccepted failed", ex);
  +         log.error("ViewAccepted failed", ex);
         }
      }
      
      // HAPartition implementation ----------------------------------------------
      
  -   public String getNodeName ()
  +   public String getNodeName()
      {
         return nodeName;
      }
      
  -   public String getPartitionName ()
  +   public String getPartitionName()
      {
         return partitionName;
      }
      
  -   public DistributedReplicantManager getDistributedReplicantManager ()
  +   public DistributedReplicantManager getDistributedReplicantManager()
      {
         return replicantManager;
      }
      
  -   public DistributedState getDistributedStateService ()
  +   public DistributedState getDistributedStateService()
      {
         return this.dsManager;
      }
  @@ -316,7 +316,7 @@
         return this.currentViewId;
      }
      
  -   public Vector getCurrentView ()
  +   public Vector getCurrentView()
      {
         return this.members;      
      }
  @@ -327,34 +327,34 @@
      // ***************************
      // ***************************
      //
  -   public void registerRPCHandler (String objName, Object subscriber)
  +   public void registerRPCHandler(String objName, Object subscriber)
      {
  -      rpcHandlers.put (objName, subscriber);
  +      rpcHandlers.put(objName, subscriber);
      }
      
  -   public void unregisterRPCHandler (String objName, Object subscriber)
  +   public void unregisterRPCHandler(String objName, Object subscriber)
      {
  -      rpcHandlers.remove (objName);
  +      rpcHandlers.remove(objName);
      }
         
      /**
       * This function is an abstraction of RpcDispatcher.
       */
  -   public ArrayList callMethodOnCluster (String objName, String methodName, 
Object[] args, boolean excludeSelf) throws Exception
  +   public ArrayList callMethodOnCluster(String objName, String methodName, Object[] 
args, boolean excludeSelf) throws Exception
      {
  -      ArrayList rtn = new ArrayList ();
  -      MethodCall m = new MethodCall (objName + "." + methodName, args);
  -      JavaGroups.RspList rsp = this.CallRemoteMethods (null, m, 
JavaGroups.GroupRequest.GET_ALL, timeout);
  +      ArrayList rtn = new ArrayList();
  +      MethodCall m = new MethodCall(objName + "." + methodName, args);
  +      JavaGroups.RspList rsp = this.CallRemoteMethods(null, m, 
JavaGroups.GroupRequest.GET_ALL, timeout);
         if (rsp != null)
         {
  -         for (int i = 0; i < rsp.size (); i++)
  +         for (int i = 0; i < rsp.size(); i++)
            {
  -            Object item = rsp.elementAt (i);
  +            Object item = rsp.elementAt(i);
               if (item instanceof JavaGroups.Rsp)
               {
  -               item = ((JavaGroups.Rsp)item).GetValue ();
  +               item = ((JavaGroups.Rsp)item).GetValue();
               }
  -            rtn.add (item);
  +            rtn.add(item);
            }
         }
         
  @@ -371,16 +371,16 @@
      /**
       * This function is an abstraction of RpcDispatcher for asynchronous messages
       */
  -   public void callAsynchMethodOnCluster (String objName, String methodName, 
Object[] args, boolean excludeSelf) throws Exception
  +   public void callAsynchMethodOnCluster(String objName, String methodName, 
Object[] args, boolean excludeSelf) throws Exception
      {
  -      MethodCall m = new MethodCall (objName + "." + methodName, args);
  -      this.CallRemoteMethods (null, m, JavaGroups.GroupRequest.GET_NONE, timeout);
  +      MethodCall m = new MethodCall(objName + "." + methodName, args);
  +      this.CallRemoteMethods(null, m, JavaGroups.GroupRequest.GET_NONE, timeout);
   
         if (!excludeSelf)
         {
  -         m.SetName (methodName);
  -         Object handler = rpcHandlers.get (objName);
  -         m.Invoke (handler, method_lookup_clos);
  +         m.SetName(methodName);
  +         Object handler = rpcHandlers.get(objName);
  +         m.Invoke(handler, method_lookup_clos);
         }
      }
      
  @@ -390,14 +390,14 @@
      // *************************
      // *************************
      //      
  -   public void subscribeToStateTransferEvents (String objectName, 
HAPartitionStateTransfer subscriber)
  +   public void subscribeToStateTransferEvents(String objectName, 
HAPartitionStateTransfer subscriber)
      {
  -      stateHandlers.put (objectName, subscriber);
  +      stateHandlers.put(objectName, subscriber);
      }
      
  -   public void unsubscribeFromStateTransferEvents (String objectName, 
HAPartitionStateTransfer subscriber)
  +   public void unsubscribeFromStateTransferEvents(String objectName, 
HAPartitionStateTransfer subscriber)
      {
  -      stateHandlers.remove (objectName);
  +      stateHandlers.remove(objectName);
      }
      
      // *************************
  @@ -406,19 +406,19 @@
      // *************************
      // *************************
      //   
  -   public void registerMembershipListener (HAMembershipListener listener)
  +   public void registerMembershipListener(HAMembershipListener listener)
      {
         synchronized(this.listeners)
         {
  -         this.listeners.add (listener);
  +         this.listeners.add(listener);
         }
      }
      
  -   public void unregisterMembershipListener (HAMembershipListener listener)
  +   public void unregisterMembershipListener(HAMembershipListener listener)
      {
         synchronized(this.listeners)
         {
  -         this.listeners.remove (listener);
  +         this.listeners.remove(listener);
         }
      }
      
  @@ -432,51 +432,51 @@
       * @param req The JavaGroups representation of the method invocation
       * @return The serializable return value from the invocation
       */
  -   public Object Handle (JavaGroups.Message req)
  +   public Object Handle(JavaGroups.Message req)
      {
         Object body = null;
         Object retval = null;
         MethodCall  method_call = null;
         
  -      if(req == null || req.GetBuffer () == null)
  +      if(req == null || req.GetBuffer() == null)
         {
  -         log.warn ("RpcProtocol.Handle(): message or message buffer is null !");
  +         log.warn("RpcProtocol.Handle(): message or message buffer is null !");
            return null;
         }
         
         try
         {
  -         body=JavaGroups.Util.ObjectFromByteBuffer (req.GetBuffer ());
  +         body=JavaGroups.Util.ObjectFromByteBuffer(req.GetBuffer());
         }
         catch(Exception e)
         {
  -         log.warn ("RpcProtocol.Handle(): " + e);
  +         log.warn("RpcProtocol.Handle(): " + e);
            return null;
         }
         
         if(body == null || !(body instanceof MethodCall))
         {
  -         log.warn ("RpcProtocol.Handle(): message does not contain a MethodCall 
object !");
  +         log.warn("RpcProtocol.Handle(): message does not contain a MethodCall 
object !");
            return null;
         }
         
         // get method call informations
         //
         method_call=(MethodCall)body;
  -      String methodName = method_call.GetName ();      
  -      int idx = methodName.indexOf ('.');
  -      String handlerName = methodName.substring (0, idx);
  -      String newMethodName = methodName.substring (idx + 1);
  -      log.info ("Handle: " + methodName);
  +      String methodName = method_call.GetName();      
  +      int idx = methodName.indexOf('.');
  +      String handlerName = methodName.substring(0, idx);
  +      String newMethodName = methodName.substring(idx + 1);
  +      log.info("Handle: " + methodName);
         
         // prepare method call
         //
  -      method_call.SetName (newMethodName);
  -      Object handler = rpcHandlers.get (handlerName);
  +      method_call.SetName(newMethodName);
  +      Object handler = rpcHandlers.get(handlerName);
         
         // Invoke it
         //
  -      retval=method_call.Invoke (handler, method_lookup_clos);
  +      retval=method_call.Invoke(handler, method_lookup_clos);
         
         return retval;
      }
  @@ -493,12 +493,12 @@
       * @param ctx Naming context under which we bind the object
       * @throws Exception Thrown if a naming exception occurs during binding
       */   
  -   protected void bind (String jndiName, Object who, Class classType, Context ctx) 
throws Exception
  +   protected void bind(String jndiName, Object who, Class classType, Context ctx) 
throws Exception
      {
         // Ah ! This service isn't serializable, so we use a helper class
         //
  -      NonSerializableFactory.bind (jndiName, who);
  -      javax.naming.Name n = ctx.getNameParser ("").parse (jndiName);
  +      NonSerializableFactory.bind(jndiName, who);
  +      javax.naming.Name n = ctx.getNameParser("").parse(jndiName);
         while (n.size () > 1)
         {
            String ctxName = n.get (0);
  
  
  

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

Reply via email to