User: kimptoc 
  Date: 01/09/01 12:50:29

  Modified:    src/main/org/jboss/ha HAConfigNodeImpl.java
  Log:
  remove deprecated logging import, where possible, otherwise comment as needing 
replacement with log4j.... must find out how it is use.... would be good if the 
deprecation message pointed to an example to use...
  
  Revision  Changes    Path
  1.3       +102 -100  jbossmx/src/main/org/jboss/ha/HAConfigNodeImpl.java
  
  Index: HAConfigNodeImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbossmx/src/main/org/jboss/ha/HAConfigNodeImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HAConfigNodeImpl.java     2001/08/23 00:09:05     1.2
  +++ HAConfigNodeImpl.java     2001/09/01 19:50:29     1.3
  @@ -21,7 +21,9 @@
   import JavaGroups.Address;
   import JavaGroups.Common.Trace;
   
  +// TODO this needs to be replaced with the log4j logging
   import org.jboss.logging.Logger;
  +
   import org.jboss.ejb.plugins.jrmp.interfaces.ContainerRemote;
   
   /**
  @@ -29,7 +31,7 @@
    *
    *   @see HAConfigNode
    *   @author <a href="mailto:[EMAIL PROTECTED]";>Sacha Labourey</a>
  - *   @version $Revision: 1.2 $
  + *   @version $Revision: 1.3 $
    *
    *   <p><b>Revisions:</b>
    *
  @@ -41,19 +43,19 @@
   
   public class HAConfigNodeImpl implements HAConfigNode
   {
  -   
  +
      public interface HAEventsCallbackable
      {
         void beanReplicaModified (java.util.Vector newValue);
      }
  -   
  +
      public static final String REMOTE_TYPE = "remote";
      public static final String HOME_TYPE   = "home";
      public static final String CONFIG_ENTRY = "*config*";
  -   
  +
      // Constants -----------------------------------------------------
  -   
  -   
  +
  +
      final String          defConnection 
="UDP(mcast_addr=224.100.100.200;mcast_port=4567;ip_ttl=31;trace=true):" +
      "PING(timeout=3000;num_initial_members=10):" +
      "FD(trace=true;timeout=5000):" +
  @@ -79,7 +81,7 @@
         */
      private final String JNDI_PROVIDER_PREFIX = "jnp";
      private final String JNDI_PORT_NUMBER = "1099"; // read it from JMX config in a 
next version
  -   
  +
      // Attributes ----------------------------------------------------
      String                clusterName         = null;
      String                escClusterName      = null;
  @@ -90,21 +92,21 @@
      JavaGroups.Address    javaGropupsNodeName = null;
      EventDispatcher       dispatcher          = null;
      Hashtable             jndiProps           = null;
  -   
  +
      long                  proxyNormalRefresh  = 30000;
      long                  proxyDeathRefresh   = 5000;
  -   
  +
      // Static --------------------------------------------------------
  -   
  +
      // Constructors --------------------------------------------------
  -   
  +
      public HAConfigNodeImpl ()
      {
         super();
      }
  -   
  +
      // Public --------------------------------------------------------
  -   
  +
      public void init (String cluster, String node, String haConnection, long 
normalDelay, long deathDelay)
      {
         // set local values from our MBEAN service
  @@ -119,10 +121,10 @@
            this.haConnection = this.defConnection;
         else
            this.haConnection = haConnection;
  -      
  +
         // determine the URL of the locally used
      }
  -   
  +
      public void start ()
      throws Exception
      {
  @@ -134,30 +136,30 @@
            jndiProps = new Hashtable (2);
            jndiProps.put (Context.INITIAL_CONTEXT_FACTORY, 
"org.jnp.interfaces.NamingContextFactory");
            jndiProps.put (Context.PROVIDER_URL, java.net.InetAddress.getLocalHost 
().getHostName ()+ ":" + JNDI_PORT_NUMBER);
  -         
  +
            // This is the main distributed tree we use for sharing HA info. In the 
future, configuration such as
            // refresh delay (proxyDeathRefresh and proxyNormalRefresh) should also be 
shared this way.
            //
            beans = new DistributedTree ("JBossHA", haConnection);
  -         
  +
            // we want to be informed about any update of the shared tree ...
            //
            dispatcher = new EventDispatcher ();
            beans.AddDistributedTreeListener (dispatcher);
  -         
  +
            // ... and membership composition (to clean dead entries)
            //
            beans.AddMembershipListener (dispatcher);
            beans.Start ();
  -         
  +
            // we also remember our JavaGroups name
            //
            this.javaGropupsNodeName = (Address)beans.GetLocalAddress ();
  -         
  +
         } catch (Exception e)
         { e.printStackTrace (); }
      }
  -   
  +
      public void setNormalDelay (long normalDelay)
      {
         this.proxyNormalRefresh = normalDelay;
  @@ -166,7 +168,7 @@
      {
         this.proxyDeathRefresh = deathDelay;
      }
  -   
  +
      public long getNormalDelay ()
      {
         return this.proxyNormalRefresh;
  @@ -175,12 +177,12 @@
      {
         return this.proxyDeathRefresh;
      }
  -   
  +
      public void stop ()
      {
         beans = null;
      }
  -   
  +
      public void registerContainer (HAConfigNode.HAEventsCallbackable source, String 
application, String beanname, String type, HAConfigEntry settings)
      {
         if (beans != null)
  @@ -191,7 +193,7 @@
               settings.jndiServerProps = this.jndiProps;
               settings.javaGropupsNodeName = this.javaGropupsNodeName;
               this.addEntry (builtName, settings);
  -            
  +
               // Store local container reference responsible for this app name
               //
               synchronized (callbacks)
  @@ -202,7 +204,7 @@
         else
            Logger.debug ("registerContainer: called while distributed hashtable 
unavailble!");
      }
  -   
  +
      public void unregisterContainer (String application, String beanname, String 
type)
      {
         if (beans != null)
  @@ -218,18 +220,18 @@
         else
            Logger.debug ("unregisterContainer: called while distributed hashtable 
unavailble!");
      }
  -   
  +
      public Vector getReplicateContainers (String application, String beanname, 
String type)
      {
         String builtName = this.buildKey (application, beanname, type);
         return this.getReplicateContainers (builtName);
      }
  -   
  +
      public String getNodeName ()
      {
         return this.nodeName;
      }
  -   
  +
      public String getPresentation ()
      {
         try
  @@ -244,7 +246,7 @@
         }
         return "";
      }
  -   
  +
      // this creates a list of targets as small as possible (i.e. without any 
unusefull data)
      // (used to update proxies)
      //
  @@ -253,52 +255,52 @@
         java.util.Vector data = this.getReplicateContainers (path);
         int size = data.size ();
         HASmallConfigEntries result = new HASmallConfigEntries ();
  -      
  +
         result.containers = new ContainerRemote [size];
         result.jndiProps = new Hashtable[size];
  -      
  +
         for (int i=0; i < size; i++)
         {
            HAConfigEntry entry = (HAConfigEntry)data.elementAt (i);
            result.containers[i] = entry.targetContainer;
            result.jndiProps[i] = entry.jndiServerProps;
         }
  -      
  +
         result.delayForRefresh = this.proxyNormalRefresh;
         result.delayForResynchAfterDeath = this.proxyDeathRefresh;
  -      
  +
         return result;
      }
  -   
  +
      public Hashtable getLocalJndiProps ()
      {
         return this.jndiProps;
      }
  -   
  +
      public String getHaAppPath (String application, String beanname, String type)
      {
         return this.buildKey (application, beanname, type);
      }
  -   
  +
      // ************************** private 
**********************************************************
  -   
  +
      private String escapeChars (String source)
      {
         java.text.StringCharacterIterator strIter = new 
java.text.StringCharacterIterator (source);
         StringBuffer dest = new StringBuffer (source.length ());
  -      
  +
         for(char c = strIter.first (); c != java.text.CharacterIterator.DONE; c = 
strIter.next ())
            dest.append ( ((c=='/')? '*' : c ) );
  -         
  +
            return dest.toString ();
      }
  -   
  +
      private StringBuffer getPresentation (StringBuffer result, String name, int 
level, String spaces)
      {
         try
         {
            java.util.Vector sons = beans.GetChildrenNames (name);
  -         
  +
            int nbSons = sons.size ();
            Object value = null;
            String fqn = null;
  @@ -309,7 +311,7 @@
               value = beans.Get (fqn);
               if (value != null)
                  result.append (value.toString ());
  -            
  +
               getPresentation (result, fqn, level + 1, spaces + "   ");
            }
         }
  @@ -319,11 +321,11 @@
         }
         return result;
      }
  -   
  +
      private Vector getReplicateContainers (String builtName)
      {
         Vector result = null;
  -      
  +
         if (beans != null)
            result = this.getEntries (builtName);
         else
  @@ -331,10 +333,10 @@
            Logger.debug ("getReplicateContainers: called while distributed hashtable 
unavailble!");
            result = new Vector ();
         }
  -      
  +
         return result;
      }
  -   
  +
      private HAConfigNode.HAEventsCallbackable getLocalListenerForApp (String app)
      {
         synchronized (callbacks)
  @@ -342,29 +344,29 @@
            return (HAConfigNode.HAEventsCallbackable)callbacks.get (app);
         }
      }
  -   
  +
      // Private -----------------------------------------------------
  -   
  +
      private String buildKey (String app, String bean, String type)
      {
         return "/" + escClusterName + "/" + escapeChars (app) + "/" + escapeChars 
(bean) + "/" + escapeChars (type);
      }
  -   
  +
      private String buildConfigKey (String key)
      { // not used for now...
         return "/" + escClusterName + "/" + CONFIG_ENTRY + "/" + escapeChars (key);
      }
  -   
  +
      private void removeEntry (String key, String node)
      {
         try
         {
            String completePath = key + "/" + node;
  -         
  +
            if (beans.Exists (completePath))
            {
               beans.Remove (completePath);
  -            
  +
               // check if this is the last entry => cleanup
               //
               if (beans.GetChildrenNames (key).size () == 0)
  @@ -374,27 +376,27 @@
         catch (Exception e)
         { e.printStackTrace (); }
      }
  -   
  +
      private void addEntry (String key, HAConfigEntry settings)
      {
         try
         {
            String completePath = key + "/" + settings.node;
  -         
  +
            beans.Add (completePath, settings);
         }
         catch (Exception e)
         { e.printStackTrace (); }
      }
  -   
  +
      private Vector getEntries (String key)
      {
         java.util.Vector result = new java.util.Vector ();
  -      
  +
         try
         {
            java.util.Vector sons = beans.GetChildrenNames (key);
  -         
  +
            int nbSons = sons.size ();
            for (int i=0; i<nbSons; i++)
               result.add (beans.Get (key + "/" + (String)sons.elementAt (i)));
  @@ -405,18 +407,18 @@
         }
         return result;
      }
  -   
  +
      // 
***************************************************************************************
      // ********************** INNER CLASS (THREAD THAT DISPATCHES EVENTS) 
********************
      // 
***************************************************************************************
  -   
  +
      class EventDispatcher
         implements Runnable, DistributedTree.DistributedTreeListener, 
DistributedTree.MembershipListener
      {
         private java.util.Vector events = new java.util.Vector (20);
         private Thread dispatcherThread = null;
         private volatile boolean threadSuspended = false;
  -      
  +
         public EventDispatcher ()
         {
            super ();
  @@ -425,7 +427,7 @@
            dispatcherThread.setName ("HAConfigCallbacks");
            dispatcherThread.start ();
         }
  -      
  +
         public void run ()
         {
            while (true)
  @@ -443,7 +445,7 @@
                  }
               } catch (InterruptedException e)
               { }
  -            
  +
               // dispatch events
               //
               try
  @@ -451,7 +453,7 @@
                  if (events.size () > 0)
                  {
                     EventEntry anEvent = null;
  -                  
  +
                     synchronized (events)
                     {
                        anEvent = (EventEntry)events.remove (0);
  @@ -473,8 +475,8 @@
               {e.printStackTrace (); }
            }
         }
  -      
  -      
  +
  +
         public void addNodeAddedEvent (String fqn, Serializable content)
         {
            java.util.Vector splitName = getSplitName (fqn);
  @@ -485,7 +487,7 @@
               String beanName = (String)splitName.elementAt (2);
               String typeName = (String)splitName.elementAt (3);
               String concernedNode = (String)splitName.elementAt (4);
  -            
  +
               // only keep events from same cluster but originating from a different 
node
               //
               if (!nodeName.equalsIgnoreCase (concernedNode) && 
clusterName.equalsIgnoreCase (escClusterName))
  @@ -494,7 +496,7 @@
               {
                  Logger.debug ("Event will be forwarded : " + concernedNode + ", " + 
clusterName );
                  EventEntry entry = new EventEntry ();
  -               
  +
                  entry.eventType = EventEntry.ADD_EVENT;
                  entry.node = concernedNode;
                  entry.app = buildKey (appName, beanName, typeName);
  @@ -511,7 +513,7 @@
            else
               Logger.debug ("... event not forwarded locally.");
         }
  -      
  +
         public void addNodeModifiedEvent (String fqn, Serializable contentBefore, 
Serializable contentAfter)
         {
            java.util.Vector splitName = getSplitName (fqn);
  @@ -523,19 +525,19 @@
               String beanName = (String)splitName.elementAt (2);
               String typeName = (String)splitName.elementAt (3);
               String concernedNode = (String)splitName.elementAt (4);
  -            
  +
               if (!nodeName.equalsIgnoreCase (concernedNode) && 
clusterName.equalsIgnoreCase (escClusterName))
                  //we only propagate events for which we are not concerned
                  //
               {
                  EventEntry entry = new EventEntry ();
  -               
  +
                  entry.eventType = EventEntry.MODIFY_EVENT;
                  entry.node = concernedNode;
                  entry.app = buildKey (appName, beanName, typeName);
                  entry.contentBefore = contentBefore;
                  entry.contentAfter = contentAfter;
  -               
  +
                  synchronized (events)
                  {
                     events.add (entry);
  @@ -548,7 +550,7 @@
            else
               Logger.debug ("... event not forwarded locally.");
         }
  -      
  +
         public void addNodeRemovedEvent (String fqn)
         {
            java.util.Vector splitName = getSplitName (fqn);
  @@ -563,17 +565,17 @@
               String beanName = (String)splitName.elementAt (2);
               String typeName = (String)splitName.elementAt (3);
               String concernedNode = (String)splitName.elementAt (4);
  -            
  +
               if (!nodeName.equalsIgnoreCase (concernedNode) && 
clusterName.equalsIgnoreCase (escClusterName))
                  //we only propagate events for which we are not concerned
                  //
               {
                  EventEntry entry = new EventEntry ();
  -               
  +
                  entry.eventType = EventEntry.REMOVE_EVENT;
                  entry.node = concernedNode;
                  entry.app = buildKey (appName, beanName, typeName);
  -               
  +
                  synchronized (events)
                  {
                     events.add (entry);
  @@ -586,7 +588,7 @@
            else
               Logger.debug ("... event not forwarded locally.");
         }
  -      
  +
         private synchronized void wakeUpThread ()
         {
            if (threadSuspended)
  @@ -595,42 +597,42 @@
               this.notify ();
            }
         }
  -      
  +
         private java.util.Vector getSplitName (String nodeName)
         {
            StringTokenizer tokens = null;
            java.util.Vector names = new java.util.Vector (5);
  -         
  +
            if(nodeName != null)
            {
               tokens = new StringTokenizer (nodeName, "/");
  -            
  +
               while(tokens.hasMoreTokens ())
                  names.add (tokens.nextToken ());
            }
  -         
  +
            return names;
         }
  -      
  +
         private void cleanTreeAfterDeath (Vector addresses)
         {
            // we check if our containers are concerned about this change
            //
            Hashtable staticCopy = null; // need to be optimized...
  -         
  +
            synchronized (callbacks)
            { staticCopy = new Hashtable (callbacks); }
            Logger.debug ("Number of dead replicats: " + addresses.size ());
  -         
  +
            for (Enumeration e = staticCopy.keys () ; e.hasMoreElements () ;)
            {
               String path = (String)e.nextElement ();
               Vector replicas = getReplicateContainers (path);
  -            
  +
               for (int i=0; i<replicas.size (); i++)
               {
                  HAConfigEntry aReplica = (HAConfigEntry)replicas.elementAt (i);
  -               
  +
                  // ***********************
                  if (addresses.contains (aReplica.javaGropupsNodeName))
                  {
  @@ -639,38 +641,38 @@
                     // we do not inform our container because has the removing will 
be propagated, we will receive such
                     // information in a few time...
                  }
  -               
  +
               }
  -            
  +
            }
         }
  -      
  +
         public void NodeAdded (String fqn,Serializable element)
         {
            addNodeAddedEvent (fqn, element);
         }
  -      
  +
         public void NodeRemoved (String fqn)
         {
            addNodeRemovedEvent (fqn);
         }
  -      
  +
         public void NodeModified (String fqn,Serializable old_element,Serializable 
new_element)
         {
            addNodeModifiedEvent (fqn, old_element, new_element);
         }
  -      
  +
         public void ViewChange (Vector new_mbrs,Vector old_mbrs)
         {
            Logger.log  ("Information", "View changed message received : " + new_mbrs 
+ ", old members : " + old_mbrs);
  -         
  +
            if (old_mbrs.size () > 0)
            {
               EventEntry entry = new EventEntry ();
  -            
  +
               entry.eventType = EventEntry.VIEW_CHANGE_EVENT;
               entry.members = old_mbrs;
  -            
  +
               synchronized (events)
               {
                  events.add (entry);
  @@ -678,7 +680,7 @@
               wakeUpThread ();
            }
         }
  -      
  +
         // **************************************
         // **** our internal event structure ****
         // **************************************
  @@ -688,7 +690,7 @@
            static public final int MODIFY_EVENT = 2;
            static public final int REMOVE_EVENT = 3;
            static public final int VIEW_CHANGE_EVENT = 4;
  -         
  +
            public int eventType = 0;
            public String node = null;
            public String app = null;
  @@ -696,8 +698,8 @@
            public Serializable contentAfter = null;
            public Vector members = null;
         }
  -      
  -      
  +
  +
      }
  -   
  +
   }
  
  
  

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

Reply via email to