[jboss-cvs] JBoss Messaging SVN: r5088 - trunk/src/main/org/jboss/messaging/util.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 8 15:26:59 EDT 2008
Author: clebert.suconic at jboss.com
Date: 2008-10-08 15:26:58 -0400 (Wed, 08 Oct 2008)
New Revision: 5088
Modified:
trunk/src/main/org/jboss/messaging/util/TimeAndCounterIDGenerator.java
Log:
Changing IDGenerator to take 4 extra bits from time
Modified: trunk/src/main/org/jboss/messaging/util/TimeAndCounterIDGenerator.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/TimeAndCounterIDGenerator.java 2008-10-08 17:15:41 UTC (rev 5087)
+++ trunk/src/main/org/jboss/messaging/util/TimeAndCounterIDGenerator.java 2008-10-08 19:26:58 UTC (rev 5088)
@@ -27,7 +27,7 @@
/**
* A TimeAndCounterIDGenerator
* <p>
- * This IDGenerator doesn't support more than 268435455 IDs per 250 millisecond. It would throw an exception if this happens.
+ * This IDGenerator doesn't support more than 16777215 IDs per 16 millisecond. It would throw an exception if this happens.
* </p>
*
* @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
@@ -42,11 +42,11 @@
*/
private static final int BITS_TO_MOVE = 20;
- public static final long MASK_TIME = 0xeffffffff00l;
+ public static final long MASK_TIME = 0x7fffffffff0l;
- public static final long ID_MASK = 0xfffffffl;
+ public static final long ID_MASK = 0xffffffl;
- private static final long TIME_ID_MASK = 0xeffffffff0000000l;
+ private static final long TIME_ID_MASK = 0x7fffffffff000000l;
// Attributes ----------------------------------------------------
@@ -73,7 +73,7 @@
{
long idReturn = counter.incrementAndGet();
- if ((idReturn & ID_MASK) == ID_MASK)
+ if ((idReturn & ID_MASK) == 0)
{
final long timePortion = idReturn & TIME_ID_MASK;
@@ -97,11 +97,11 @@
if (wrapped)
{
- // This will only happen if a computer can generate more than ID_MASK ids (268.43 million IDs per 250
+ // This will only happen if a computer can generate more than ID_MASK ids (16 million IDs per 16
// milliseconds)
// If this wrapping code starts to happen, it needs revision
- throw new IllegalStateException("The IDGenerator is being overlaped, and it needs revision as the system generated more than " + (idReturn & ID_MASK) +
- " ids per 250 milliseconds which exceeded the IDgenerator limit");
+ throw new IllegalStateException("The IDGenerator is being overlaped, and it needs revision as the system generated more than " + ID_MASK +
+ " ids per 16 milliseconds which exceeded the IDgenerator limit");
}
return idReturn;
@@ -112,7 +112,14 @@
return counter.get();
}
+
// for use in testcases
+ public long getInternalTimeMark()
+ {
+ return tmMark;
+ }
+
+ // for use in testcases
public void setInternalID(final long id)
{
counter.set(tmMark | id);
More information about the jboss-cvs-commits
mailing list