[jboss-svn-commits] JBL Code SVN: r37508 - labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP_JBTM-522/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Oct 6 06:18:08 EDT 2011
Author: mmusgrov
Date: 2011-10-06 06:18:07 -0400 (Thu, 06 Oct 2011)
New Revision: 37508
Modified:
labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP_JBTM-522/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/Uid.java
Log:
Backport ipv6 changes
Modified: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP_JBTM-522/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/Uid.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP_JBTM-522/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/Uid.java 2011-10-06 09:28:44 UTC (rev 37507)
+++ labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP_JBTM-522/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/Uid.java 2011-10-06 10:18:07 UTC (rev 37508)
@@ -168,8 +168,6 @@
ByteArrayInputStream ba = new ByteArrayInputStream(byteForm);
DataInputStream ds = new DataInputStream(ba);
- _ipv6 = Utility.isIPv6();
-
if (_ipv6) {
hostAddr[0] = ds.readLong();
hostAddr[1] = ds.readLong();
@@ -200,7 +198,7 @@
public Uid (String uidString)
{
- this(uidString, true);
+ this(uidString, false);
}
/**
@@ -232,8 +230,6 @@
try
{
- _ipv6 = Utility.isIPv6();
-
while (uidString.charAt(endIndex) != theBreakChar)
endIndex++;
@@ -325,7 +321,6 @@
else
{
this.copy(Uid.nullUid());
- _ipv6 = false;
}
if (!_valid)
@@ -334,6 +329,7 @@
{
try
{
+ // this call assumes that "0:0:0:0:0" always parses correctly
this.copy(Uid.nullUid());
_valid = false;
@@ -347,7 +343,8 @@
}
throw new FatalError(
- tsLogger.log_mesg.getString("com.arjuna.ats.arjuna.common.Uid_2"));
+ tsLogger.log_mesg.getString("com.arjuna.ats.arjuna.common.Uid_2")
+ + e.getMessage());
}
}
else
@@ -372,7 +369,6 @@
hostAddr = new long[2];
hostAddr[0] = addr[0];
hostAddr[1] = addr[1];
- _ipv6 = true;
process = processId;
sec = time;
@@ -870,8 +866,6 @@
private volatile long[] hostAddr; // representation of ipv6 address (and
// ipv4)
- private volatile boolean _ipv6;
-
private volatile int process;
private volatile int sec;
@@ -886,6 +880,8 @@
private volatile byte[] _byteForm;
+ private static volatile boolean _ipv6; // cannot mix ipv4 and ipv6 (hence use a static)
+
private static final AtomicInteger uidsCreated = new AtomicInteger();
private static volatile int initTime ;
@@ -894,13 +890,33 @@
private static final char fileBreakChar = '_';
- private static final Uid NIL_UID = new Uid("0:0:0:0:0") ;
+ private static final Uid NIL_UID;
- private static final Uid LAST_RESOURCE_UID = new Uid("0:0:0:0:1") ;
+ private static final Uid LAST_RESOURCE_UID;
- private static final Uid MAX_UID = new Uid("7fffffff:7fffffff:7fffffff:7fffffff:7fffffff") ;
+ private static final Uid MAX_UID;
- private static final Uid MIN_UID = new Uid("-80000000:-80000000:-80000000:-80000000:-80000000") ;
+ private static final Uid MIN_UID;
- private static final int UID_SIZE = 2*8 + 3*4; // in bytes
+ private static final int UID_SIZE;
+
+ static {
+ try {
+ _ipv6 = Utility.isIPv6();
+ } catch (UnknownHostException e) {
+ if (tsLogger.arjLoggerI18N.isWarnEnabled())
+ tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.common.Uid_1");
+
+ throw new FatalError(tsLogger.log_mesg.getString("com.arjuna.ats.arjuna.common.Uid_1" +
+ e.getMessage() ));
+ }
+
+ NIL_UID = _ipv6 ? new Uid("0:0:0:0:0") : new Uid("0:0:0:0");
+ LAST_RESOURCE_UID = _ipv6 ? new Uid("0:0:0:0:1") : new Uid("0:0:0:1");
+ MAX_UID = _ipv6 ? new Uid("7fffffff:7fffffff:7fffffff:7fffffff:7fffffff") :
+ new Uid("7fffffff:7fffffff:7fffffff:7fffffff");
+ MIN_UID = _ipv6 ? new Uid("-80000000:-80000000:-80000000:-80000000:-80000000") :
+ new Uid("-80000000:-80000000:-80000000:-80000000");
+ UID_SIZE = _ipv6 ? 2*8 + 3*4 : 4*4; // in bytes
+ }
}
More information about the jboss-svn-commits
mailing list