[jboss-cvs] JBoss Messaging SVN: r6741 - in branches/Branch_1_4: tests/src/org/jboss/test/messaging/jms/server and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue May 12 10:32:33 EDT 2009


Author: gaohoward
Date: 2009-05-12 10:32:32 -0400 (Tue, 12 May 2009)
New Revision: 6741

Modified:
   branches/Branch_1_4/src/main/org/jboss/messaging/core/impl/NullPersistenceManager.java
   branches/Branch_1_4/src/main/org/jboss/messaging/core/impl/RotatingID.java
   branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/server/ServerPeerConfigurationTest.java
Log:
JBMESSAGING-1614


Modified: branches/Branch_1_4/src/main/org/jboss/messaging/core/impl/NullPersistenceManager.java
===================================================================
--- branches/Branch_1_4/src/main/org/jboss/messaging/core/impl/NullPersistenceManager.java	2009-05-12 12:59:24 UTC (rev 6740)
+++ branches/Branch_1_4/src/main/org/jboss/messaging/core/impl/NullPersistenceManager.java	2009-05-12 14:32:32 UTC (rev 6741)
@@ -35,14 +35,15 @@
  * A NullPersistenceManager
  * 
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:hgao at redhat.com">Howard Gao</a>
  */
 public class NullPersistenceManager implements PersistenceManager
 {
-   private static final int MAX_PEER_ID = 255;
+   private static final int MAX_PEER_ID = 65535;
 
    private ConcurrentMap<String, IDCounter> counters = new ConcurrentHashMap<String, IDCounter>();
 
-   private int peerID; // 0 - 255
+   private int peerID; // 0 - 65535
 
    private long timeMark;
 
@@ -146,7 +147,7 @@
    {
       if (peerID > MAX_PEER_ID)
       {
-         throw new Exception("ServerPeerID " + peerID + " exceeding 255");
+         throw new Exception("ServerPeerID " + peerID + " exceeding " + MAX_PEER_ID);
       }
       if (peerID < 0)
       {
@@ -228,13 +229,13 @@
       manager = pManager;
       counter = 0;
       tmMark = manager.getTimeMark() & MASK_TIME;
-      peerIDBit = (((long)manager.getPeerID()) & MASK_SERVER_PEER_ID) << 56;
+      peerIDBit = (((long)manager.getPeerID()) & MASK_SERVER_PEER_ID) << 48;
       recalculate();// avoid quick restart conflict
    }
 
    /**
     * for each named counter, we generate it using the following algorithm:
-    * <8-bit ServerPeerID> + <40-bit time bit> + <16-bit counter>
+    * <16-bit ServerPeerID> + <32-bit time bit> + <16-bit counter>
     * the 16-bit counter starts from zero and increases by 1. If the counter
     * wraps to zero, we re-calculate the time using current time. Check will be
     * performed when the calculated current time value is the same as the old
@@ -250,9 +251,9 @@
     * @param size : size of the block to be reserved. 
     * @return
     */
-   private static final long MASK_SERVER_PEER_ID = 0x00000000000000FFL;
+   private static final long MASK_SERVER_PEER_ID = 0x000000000000FFFFL;
 
-   private static final long MASK_TIME = 0x00000FFFFFFFFFF0L;
+   private static final long MASK_TIME = 0x0000000FFFFFFFF0L;
 
    public synchronized long reserveAndGetNextId(int size) throws Exception
    {

Modified: branches/Branch_1_4/src/main/org/jboss/messaging/core/impl/RotatingID.java
===================================================================
--- branches/Branch_1_4/src/main/org/jboss/messaging/core/impl/RotatingID.java	2009-05-12 12:59:24 UTC (rev 6740)
+++ branches/Branch_1_4/src/main/org/jboss/messaging/core/impl/RotatingID.java	2009-05-12 14:32:32 UTC (rev 6741)
@@ -27,8 +27,8 @@
  *
  * 64 bits, made up of:
  *
- * First 8 bits - node id
- * Next 42 bits - lowest 41 bits of system time
+ * First 16 bits - node id
+ * Next 34 bits - lowest 34 bits of system time
  * Next 14 bits - rotating counter
  *
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -44,9 +44,9 @@
 
    public RotatingID(final int nodeID)
    {
-      if (nodeID < 0 || nodeID > 255)
+      if (nodeID < 0 || nodeID > 65535)
       {
-         throw new IllegalArgumentException("node id must be between 0 to 255 inclusive");
+         throw new IllegalArgumentException("node id must be between 0 to 65535 inclusive");
       }
 
       this.nodeID = nodeID;
@@ -54,7 +54,7 @@
 
    public synchronized long getID()
    {
-      long id1 = nodeID << 54;
+      long id1 = nodeID << 48;
 
       long id2 = System.currentTimeMillis() << 14;
 

Modified: branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/server/ServerPeerConfigurationTest.java
===================================================================
--- branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/server/ServerPeerConfigurationTest.java	2009-05-12 12:59:24 UTC (rev 6740)
+++ branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/server/ServerPeerConfigurationTest.java	2009-05-12 14:32:32 UTC (rev 6741)
@@ -101,6 +101,27 @@
       }
    }
    
+   public void testServerPeerIDLimit() throws Exception
+   {
+      LocalTestServer server = new LocalTestServer();
+      ServiceAttributeOverrides overrides = new ServiceAttributeOverrides();
+      // Can't use server.getServerPeerObjectName() here since it's not known to the server yet.
+      overrides.put(ServiceContainer.SERVER_PEER_OBJECT_NAME, "ServerPeerID", "65535");
+      
+      try
+      {
+         server.start("all", overrides, false, true);
+      }
+      catch (RuntimeMBeanException rmbe)
+      {
+         fail("Large ServerPeerID should be allowed (0 - 65535)");
+      }
+      finally
+      {
+         server.stop();
+      }
+   }
+   
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------




More information about the jboss-cvs-commits mailing list