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

2002-04-13 Thread Sacha Labourey

  User: slaboure
  Date: 02/04/13 05:44:58

  Modified:src/main/org/jboss/ha/framework/server
DistributedStateImpl.java
  Log:
  Nice bug, and vive strong-typing: the remove method call were not distributed
  
  Revision  ChangesPath
  1.9   +2 -2  
jbossmx/src/main/org/jboss/ha/framework/server/DistributedStateImpl.java
  
  Index: DistributedStateImpl.java
  ===
  RCS file: 
/cvsroot/jboss/jbossmx/src/main/org/jboss/ha/framework/server/DistributedStateImpl.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DistributedStateImpl.java 12 Jan 2002 16:52:08 -  1.8
  +++ DistributedStateImpl.java 13 Apr 2002 12:44:58 -  1.9
  @@ -29,7 +29,7 @@
*
*   @author  a href=mailto:[EMAIL PROTECTED];Sacha Labourey/a.
*   @author  a href=mailto:[EMAIL PROTECTED];Bill Burke/a.
  - *   @version $Revision: 1.8 $
  + *   @version $Revision: 1.9 $
*
* pbRevisions:/bbr
* pb2001/11/26: Sacha Labourey/b
  @@ -297,7 +297,7 @@
 }
  }
  
  -   public void _remove (String category, String key, boolean local) throws Exception
  +   public void _remove (String category, String key) throws Exception
  {
 Serializable removed = this._removeInternal (category, key);
 notifyKeyListenersOfRemove (category, key, removed, false);
  
  
  

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



[JBoss-dev] CVS update: jbossmx/src/main/org/jboss/ha/framework/server DistributedStateImpl.java DistributedStateImplMBean.java

2002-01-12 Thread Sacha Labourey

  User: slaboure
  Date: 02/01/12 08:52:09

  Modified:src/main/org/jboss/ha/framework/server
DistributedStateImpl.java
DistributedStateImplMBean.java
  Log:
  Provide a listContent and listXmlContent for debugging purposes (useful with 
HTTP/JMX)
  
  Revision  ChangesPath
  1.8   +72 -7 
jbossmx/src/main/org/jboss/ha/framework/server/DistributedStateImpl.java
  
  Index: DistributedStateImpl.java
  ===
  RCS file: 
/cvsroot/jboss/jbossmx/src/main/org/jboss/ha/framework/server/DistributedStateImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DistributedStateImpl.java 2002/01/03 04:00:52 1.7
  +++ DistributedStateImpl.java 2002/01/12 16:52:08 1.8
  @@ -29,7 +29,7 @@
*
*   @author  a href=mailto:[EMAIL PROTECTED];Sacha Labourey/a.
*   @author  a href=mailto:[EMAIL PROTECTED];Bill Burke/a.
  - *   @version $Revision: 1.7 $
  + *   @version $Revision: 1.8 $
*
* pbRevisions:/bbr
* pb2001/11/26: Sacha Labourey/b
  @@ -54,6 +54,7 @@
  protected org.jboss.logging.Logger log = null;
  
  protected MBeanServer mbeanServer = null;
  +   protected String name = null;
  
  // Static c
  
  @@ -83,11 +84,11 @@
 // we will need to redesign the way HAPartitions and its sub-protocols are
 // registered with JMX. They will most probably be independant JMX services.
 //
  -  String name = jboss:service= + SERVICE_NAME + 
  +  this.name = jboss:service= + SERVICE_NAME + 
   ,partitionName= + this.partition.getPartitionName();
  -  ObjectName jmxName = new ObjectName(name);
  +  ObjectName jmxName = new ObjectName(this.name);
 mbeanServer.registerMBean(this, jmxName);
  -  org.jboss.system.Registry.bind (name, this);
  +  org.jboss.system.Registry.bind (this.name, this);
  }
  
  public void start () throws Exception
  @@ -96,9 +97,73 @@
  
  public void stop () throws Exception
  {
  -  String name = jboss:service= + SERVICE_NAME + 
  -,partitionName= + this.partition.getPartitionName();
  -  org.jboss.system.Registry.unbind (name);
  +  org.jboss.system.Registry.unbind (this.name);
  +  ObjectName jmxName = new ObjectName(this.name);
  +  mbeanServer.unregisterMBean (jmxName);
  +   }
  +   
  +   public String listContent () throws Exception
  +   {
  +  StringBuffer result = new StringBuffer ();
  +  Collection cats = this.getAllCategories ();
  +  java.util.Iterator catsIter = cats.iterator ();
  +  while (catsIter.hasNext ())
  +  {
  + String category = (String)catsIter.next ();
  + java.util.Iterator keysIter = this.getAllKeys(category).iterator ();
  + 
  + result.append (---\n);
  + result.append (Category : ).append (category).append (\n\n);
  + result.append (KEY\t:\tVALUE\n);
  +
  + while (keysIter.hasNext ())
  + {
  +String key = (String)keysIter.next ();
  +String value = this.get (category, key).toString ();
  +result.append (\).append(key).append (\\t:\t\).append 
(value).append(\\n);
  + }
  + 
  + result.append (\n);
  + 
  +  }
  +  
  +  return result.toString ();
  +   }
  +   
  +   public String listXmlContent () throws Exception
  +   {
  +  StringBuffer result = new StringBuffer ();
  +  Collection cats = this.getAllCategories ();
  +  java.util.Iterator catsIter = cats.iterator ();
  +  
  +  result.append (DistributedState\n);
  +  
  +  while (catsIter.hasNext ())
  +  {
  + String category = (String)catsIter.next ();
  + java.util.Iterator keysIter = this.getAllKeys(category).iterator ();
  + 
  + result.append (\tCategory\n);
  + result.append (\t\tCategoryName).append (category).append 
(/CategoryName\n);
  +
  + while (keysIter.hasNext ())
  + {
  +String key = (String)keysIter.next ();
  +String value = this.get (category, key).toString ();
  +result.append (\t\tEntry\n);
  +result.append (\t\t\tKey).append (key).append (/Key\n);
  +result.append (\t\t\tValue).append (value).append (/Value\n);
  +result.append (\t\t/Entry\n);
  +result.append (\).append(key).append (\\t:\t\).append 
(value).append(\\n);
  + }
  + 
  + result.append (\t/Category\n);
  + 
  +  }
  +
  +  result.append (/DistributedState\n);
  +  
  +  return result.toString ();
  }
  
  // DistributedState implementation --
  
  
  
  

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

2001-12-31 Thread Sacha Labourey

  User: slaboure
  Date: 01/12/31 07:15:11

  Modified:src/main/org/jboss/ha/framework/server
DistributedStateImpl.java
  Log:
  New set/remove methods to mimic optional parameter to indicate if the cluster call 
must be made (a-)synchronous.
  
  Revision  ChangesPath
  1.6   +18 -3 
jbossmx/src/main/org/jboss/ha/framework/server/DistributedStateImpl.java
  
  Index: DistributedStateImpl.java
  ===
  RCS file: 
/cvsroot/jboss/jbossmx/src/main/org/jboss/ha/framework/server/DistributedStateImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DistributedStateImpl.java 2001/12/29 16:11:43 1.5
  +++ DistributedStateImpl.java 2001/12/31 15:15:11 1.6
  @@ -29,7 +29,7 @@
*
*   @author  a href=mailto:[EMAIL PROTECTED];Sacha Labourey/a.
*   @author  a href=mailto:[EMAIL PROTECTED];Bill Burke/a.
  - *   @version $Revision: 1.5 $
  + *   @version $Revision: 1.6 $
*
* pbRevisions:/bbr
* pb2001/11/26: Sacha Labourey/b
  @@ -105,18 +105,33 @@
   
  public void set (String category, String key, Serializable value) throws 
Exception
  {
  +  set (category, key, value, true);
  +   }
  +   public void set (String category, String key, Serializable value, boolean 
asynchronousCall) throws Exception
  +   {
 Object[] args =
 {category, key, value};
  -  partition.callMethodOnCluster (SERVICE_NAME, _set, args, true);
  +  if (asynchronousCall)
  + partition.callAsynchMethodOnCluster (SERVICE_NAME, _set, args, true);
  +  else
  + partition.callMethodOnCluster (SERVICE_NAME, _set, args, true);
 this._setInternal (category, key, value);
 notifyKeyListeners (category, key, value, true);
  }
  
  public Serializable remove (String category, String key) throws Exception
  {
  +  return remove (category, key, true);
  +   }
  +   
  +   public Serializable remove (String category, String key, boolean 
asynchronousCall) throws Exception
  +   {
 Object[] args =
 {category, key};
  -  partition.callMethodOnCluster (SERVICE_NAME, _remove, args, true);
  +  if (asynchronousCall)
  + partition.callAsynchMethodOnCluster (SERVICE_NAME, _remove, args, true);
  +  else
  + partition.callMethodOnCluster (SERVICE_NAME, _remove, args, true);
   
 Serializable removed = this._removeInternal (category, key);
 notifyKeyListenersOfRemove (category, key, removed , true);
  
  
  

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



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

2001-12-29 Thread Sacha Labourey

  User: slaboure
  Date: 01/12/29 08:11:43

  Modified:src/main/org/jboss/ha/framework/server
DistributedStateImpl.java
  Log:
  - possibility to know if a modification has been done locally or initiated from 
another node
  - remove now returns the old value
  - DistributedStateImpl is now registred as a standard MBean
  - we no more use asynch calls (usefull for HTTPSession clustering). This should be 
made optional by the user code
  
  Revision  ChangesPath
  1.5   +55 -16
jbossmx/src/main/org/jboss/ha/framework/server/DistributedStateImpl.java
  
  Index: DistributedStateImpl.java
  ===
  RCS file: 
/cvsroot/jboss/jbossmx/src/main/org/jboss/ha/framework/server/DistributedStateImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DistributedStateImpl.java 2001/11/26 15:04:50 1.4
  +++ DistributedStateImpl.java 2001/12/29 16:11:43 1.5
  @@ -15,6 +15,9 @@
   import java.util.Vector;
   import java.rmi.server.UnicastRemoteObject;
   
  +import javax.management.MBeanServer;
  +import javax.management.ObjectName;
  +
   import org.jboss.ha.framework.interfaces.DistributedState.DSListener;
   import org.jboss.ha.framework.interfaces.HAPartition.HAPartitionStateTransfer;
   import org.jboss.ha.framework.interfaces.HAPartition.HAMembershipListener;
  @@ -26,7 +29,7 @@
*
*   @author  a href=mailto:[EMAIL PROTECTED];Sacha Labourey/a.
*   @author  a href=mailto:[EMAIL PROTECTED];Bill Burke/a.
  - *   @version $Revision: 1.4 $
  + *   @version $Revision: 1.5 $
*
* pbRevisions:/bbr
* pb2001/11/26: Sacha Labourey/b
  @@ -36,7 +39,7 @@
* /ol
*/
   public class DistributedStateImpl
  -implements DistributedState, HAPartitionStateTransfer
  +implements DistributedStateImplMBean, HAPartitionStateTransfer
   {
  // Constants -
  
  @@ -49,14 +52,19 @@
  protected HAPartition partition;
  
  protected org.jboss.logging.Logger log = null;
  +   
  +   protected MBeanServer mbeanServer = null;
  
  -   // Static 
  +   // Static c
  
  // Constructors --
  
  -   public DistributedStateImpl (HAPartition partition)
  +   public DistributedStateImpl () {} // for JMX checks
  +   
  +   public DistributedStateImpl (HAPartition partition, MBeanServer server)
  {
 this.partition = partition;
  +  this.mbeanServer = server;
 this.log = org.jboss.logging.Logger.getLogger (this.getClass ());
  }
  
  @@ -68,7 +76,18 @@
 // this service.
 //
 partition.subscribeToStateTransferEvents (SERVICE_NAME, this);
  -  partition.registerRPCHandler (SERVICE_NAME, this);  
  +  partition.registerRPCHandler (SERVICE_NAME, this);  
  +  
  +  // subscribed this sub-service of HAPartition with JMX
  +  // TODO: In the future (when state transfer issues will be completed), 
  +  // we will need to redesign the way HAPartitions and its sub-protocols are
  +  // registered with JMX. They will most probably be independant JMX services.
  +  //
  +  String name = JBOSS-SYSTEM:service= + SERVICE_NAME + 
  +,partitionName= + this.partition.getPartitionName();
  +  ObjectName jmxName = new ObjectName(name);
  +  mbeanServer.registerMBean(this, jmxName);
  +  org.jboss.system.Registry.bind (name, this);
  }
  
  public void start () throws Exception
  @@ -77,6 +96,9 @@
  
  public void stop () throws Exception
  {
  +  String name = JBOSS-SYSTEM:service= + SERVICE_NAME + 
  +,partitionName= + this.partition.getPartitionName();
  +  org.jboss.system.Registry.unbind (name);
  }
  
  // DistributedState implementation --
  @@ -85,15 +107,21 @@
  {
 Object[] args =
 {category, key, value};
  -  partition.callAsynchMethodOnCluster (SERVICE_NAME, _set, args, false);
  +  partition.callMethodOnCluster (SERVICE_NAME, _set, args, true);
  +  this._setInternal (category, key, value);
  +  notifyKeyListeners (category, key, value, true);
  }
  
  -   public void remove (String category, String key) throws Exception
  +   public Serializable remove (String category, String key) throws Exception
  {
 Object[] args =
 {category, key};
  -  partition.callAsynchMethodOnCluster (SERVICE_NAME, _remove, args, false);
  +  partition.callMethodOnCluster (SERVICE_NAME, _remove, args, true);
  +
  +  Serializable removed = this._removeInternal (category, key);
  +  notifyKeyListenersOfRemove (category, key, removed , true);
 
  +  

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

2001-11-26 Thread Sacha Labourey

  User: slaboure
  Date: 01/11/26 07:04:50

  Modified:src/main/org/jboss/ha/framework/server
DistributedStateImpl.java
  Log:
  No more remote, no more RMI exported.
  No more listening for membership changes.
  Added javadoc comments.
  Added Asynchronous calls to the partition when possible.
  Reordered content to fit in JBoss coding conventions.
  
  Revision  ChangesPath
  1.4   +107 -105  
jbossmx/src/main/org/jboss/ha/framework/server/DistributedStateImpl.java
  
  Index: DistributedStateImpl.java
  ===
  RCS file: 
/cvsroot/jboss/jbossmx/src/main/org/jboss/ha/framework/server/DistributedStateImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DistributedStateImpl.java 2001/11/26 03:24:51 1.3
  +++ DistributedStateImpl.java 2001/11/26 15:04:50 1.4
  @@ -1,160 +1,98 @@
  +/*
  + * JBoss, the OpenSource J2EE WebOS
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
  +
   package org.jboss.ha.framework.server;
   
   
  -import java.util.Vector;
  +import java.io.Serializable;
   import java.util.ArrayList;
  -import java.util.HashMap;
  -import java.util.Iterator;
   import java.util.Collection;
  -
  -import java.rmi.server.RemoteStub;
  -import java.rmi.Remote;
  +import java.util.HashMap;
  +import java.util.Vector;
   import java.rmi.server.UnicastRemoteObject;
   
  -import java.io.Serializable;
  -
  -import org.jboss.logging.Logger;
  -
  +import org.jboss.ha.framework.interfaces.DistributedState.DSListener;
  +import org.jboss.ha.framework.interfaces.HAPartition.HAPartitionStateTransfer;
  +import org.jboss.ha.framework.interfaces.HAPartition.HAMembershipListener;
   import org.jboss.ha.framework.interfaces.DistributedState;
   import org.jboss.ha.framework.interfaces.HAPartition;
   
  -/** 
  +/**
*   This class manages distributed state across the cluster.
*
  - *   @author [EMAIL PROTECTED]
  - *   @author [EMAIL PROTECTED]
  - *   @version $Revision: 1.3 $
  + *   @author  a href=mailto:[EMAIL PROTECTED];Sacha Labourey/a.
  + *   @author  a href=mailto:[EMAIL PROTECTED];Bill Burke/a.
  + *   @version $Revision: 1.4 $
*
* pbRevisions:/bbr
  + * pb2001/11/26: Sacha Labourey/b
  + * ol
  + *   liNo more a remote object/li
  + *   liNo more listening for Membership changes (was doing nothing with the 
callback)/li
  + * /ol
*/
  -public class DistributedStateImpl 
  -   implements Remote, DistributedState,
  -  HAPartition.HAPartitionStateTransfer,
  -  HAPartition.HAMembershipListener
  +public class DistributedStateImpl
  +implements DistributedState, HAPartitionStateTransfer
   {
  +   // Constants -
  +   
  +   protected final static String SERVICE_NAME = DistributedState;
  +   
  +   // Attributes 
  +   
  protected HashMap categories = new HashMap ();
  protected HashMap keyListeners = new HashMap ();
  protected HAPartition partition;
  
  -   protected final static String SERVICE_NAME = DistributedState;
  +   protected org.jboss.logging.Logger log = null;
  
  -   protected Logger log = null;
  +   // Static 
  
  +   // Constructors --
  
  public DistributedStateImpl (HAPartition partition)
  {
 this.partition = partition;
  -  this.log = Logger.getLogger (this.getClass ());
  +  this.log = org.jboss.logging.Logger.getLogger (this.getClass ());
  }
  
  +   // Public 
  +   
  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);
  -  partition.registerRPCHandler (SERVICE_NAME, this);
  -  
  +  partition.registerRPCHandler (SERVICE_NAME, this);  
  }
  
  public void start () throws Exception
  {
  -  // Export myself as an RMI server
  -  //
  -  RemoteStub stub = UnicastRemoteObject.exportObject (this);
  -  
  -  // bind myself as a replicant service
  -  //
  -  partition.getDistributedReplicantManager ().add (SERVICE_NAME, stub);
  }
  
  public void stop () throws Exception
  {
  -  //partition.getDistributedReplicantManager ().remove (SERVICE_NAME); 
  -  UnicastRemoteObject.unexportObject (this, true);
  -   }
  -   
  -   /
  -   // State transfer API
  -   /
  -   public Serializable getCurrentState ()
  -   {
  -  return categories;
  }