Mail Archive Home | jotm-commits List | May 2004 Index
| <-- Date Index --> | <-- Thread Index --> |
Date: Wednesday, May 5, 2004 @ 22:18:30
Author: tonyortiz
Path: /cvsroot/jotm/jotm/src/main/org/objectweb/jotm
Modified: XidImpl.java
support branch id generation in XID
--------------+
XidImpl.java | 181 +++++++++++++++++++++++++++++++++++----------------------
1 files changed, 113 insertions(+), 68 deletions(-)
Index: jotm/src/main/org/objectweb/jotm/XidImpl.java
diff -u jotm/src/main/org/objectweb/jotm/XidImpl.java:1.17
jotm/src/main/org/objectweb/jotm/XidImpl.java:1.18
--- jotm/src/main/org/objectweb/jotm/XidImpl.java:1.17 Sat Apr 3 21:31:26
2004
+++ jotm/src/main/org/objectweb/jotm/XidImpl.java Wed May 5 22:18:29
2004
@@ -37,7 +37,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* --------------------------------------------------------------------------
- * $Id: XidImpl.java,v 1.17 2004/04/03 19:31:26 tonyortiz Exp $
+ * $Id: XidImpl.java,v 1.18 2004/05/05 20:18:29 tonyortiz Exp $
* --------------------------------------------------------------------------
*/
package org.objectweb.jotm;
@@ -54,7 +54,7 @@
* XID has the following format as defined by X/Open Specification:
*
* XID
- * long formatID format identifier
+ * long formatId format identifier
* long gtrid_length value 1-64
* long bqual_length value 1-64
* byte data [XIDDATASIZE] where XIDDATASIZE = 128
@@ -88,6 +88,18 @@
private int formatId;
/**
+ * format id
+ * @serial
+ */
+ private int gtrid_length;
+
+ /**
+ * format id
+ * @serial
+ */
+ private int bqual_length;
+
+ /**
* global transaction id
* @serial
*/
@@ -134,9 +146,11 @@
}
gtrid = s.getBytes();
+ gtrid_length = gtrid.length;
// XXX bqual is equal to gtrid in this constructor
bqual = s.getBytes();
+ bqual_length = bqual.length;
TraceTm.jotm.debug("new Xid (uuid= " + Long.toHexString(uuid) + ")");
@@ -160,6 +174,13 @@
// bqual
bqual = new byte[bqualsz];
System.arraycopy(tid, 0, bqual, 0, bqualsz);
+
+ // gtrid_length
+ gtrid_length = gtridsz;
+
+ // bqual_length
+ bqual_length = bqualsz;
+
}
/**
@@ -171,6 +192,8 @@
this.formatId = formatId;
this.gtrid = gtrid;
this.bqual = bqual;
+ this.gtrid_length = gtrid.length;
+ this.bqual_length = bqual.length;
}
/**
@@ -181,8 +204,10 @@
formatId = JOTM_FORMAT_ID;
//
gtrid = makeGtrid();
+ gtrid_length = gtrid.length;
//
bqual = new byte[0];
+ bqual_length = bqual.length;
}
@@ -194,22 +219,58 @@
*/
public XidImpl( Xid oldXid, int index )
{
-
TraceTm.jotm.debug("old XID= " + oldXid);
TraceTm.jotm.debug("index= " + index);
+
formatId = oldXid.getFormatId();
- //
+
gtrid = oldXid.getGlobalTransactionId();
- //
makeGtridBase();
+ gtrid_length = gtrid.length;
+
bqual = new byte[MAXBQUALSIZE];
ByteBuffer bb = ByteBuffer.wrap(bqual);
bb.put(gtrid_base);
bb.putLong(0L); // (time stamp not used on bqual)
bb.putLong(index+0L); // and this makes the bqual unique
+ bqual_length = bqual.length;
}
+ /**
+ * The xid was passed from an external EIS (inflow transaction).
+ * Need to store the formatId, gtrid.length, bqual.length, gtrid,
+ * and bqual from the passed xid.
+ */
+
+ public XidImpl( Xid passedXid) {
+
+ byte[] pa_xid_base = null;
+ int pa_format_id;
+ int pa_gtrid_length;
+ int pa_bqual_length;
+
+ byte pa_gtrid [] = new byte [MAXGTRIDSIZE];
+ byte pa_bqual [] = new byte [MAXBQUALSIZE];
+
+ pa_xid_base = new byte[1+1+1+MAXGTRIDSIZE+MAXBQUALSIZE];
+ ByteBuffer pa = ByteBuffer.wrap(pa_xid_base);
+
+ pa_format_id = pa.getInt(); // FORMAT ID
+ pa_gtrid_length = pa.getInt(); // VALUE 1-64
+ pa_bqual_length = pa.getInt(); // VALUE 1-64
+ pa.get(pa_gtrid,0,pa_gtrid_length); // GTRID
+ pa.get(pa_bqual,0,pa_bqual_length); // BQUAL
+
+ formatId = pa_format_id;
+ gtrid_length = pa_gtrid_length;
+ bqual_length = pa_bqual_length;
+ gtrid = pa_gtrid;
+ bqual = pa_bqual;
+
+ TraceTm.jotm.debug("passed XID= " + passedXid);
+ }
+
// -------------------------------------------------------------------
// Xid implementation
// -------------------------------------------------------------------
@@ -248,78 +309,62 @@
public String toString() {
+ int spaceChar = 0x20;
+ int tildeChar = 0x7E;
+
byte[] my_gtrid_base = null;
- byte my_vers;
- long my_uuid0;
- long my_uuid1;
- long my_time;
- byte my_host [] = new byte [16];
- byte my_serv [] = new byte [15];
-
- byte[] bq_bqual_base = null;
- int bq_fmt;
- byte bq_vers;
- long bq_uuid0;
- long bq_uuid1;
- long bq_time;
- byte bq_host [] = new byte [16];
- byte bq_serv [] = new byte [15];
+ byte[] my_bqual_base = null;
+ StringBuffer str_buff_gtrid = new StringBuffer();
+ StringBuffer str_buff_bqual = new StringBuffer();
- my_gtrid_base = new byte[1+8+8+16+15+8];
+ byte by_hold;
+ char ch_hold;
+
+ my_gtrid_base = new byte[MAXGTRIDSIZE];
ByteBuffer aa = ByteBuffer.wrap(my_gtrid_base);
- System.arraycopy(gtrid, 0, my_gtrid_base, 0, gtrid.length);
+
+ System.arraycopy(gtrid, 0, my_gtrid_base, 0, gtrid_length);
+
+ for (int i=0; i<gtrid_length; i++) {
+ by_hold = aa.get();
- my_vers = aa.get();
- my_uuid0 = aa.getLong();
- my_uuid1 = aa.getLong();
- aa.get(my_host,0,16);
- aa.get(my_serv,0,15);
- my_time = aa.getLong();
+ if ((by_hold >= spaceChar) && (by_hold <= tildeChar)) {
+ ch_hold = (char)by_hold;
+ str_buff_gtrid.append(Character.toString(ch_hold));
+ } else {
+ str_buff_gtrid.append(Long.toHexString(by_hold));
+ }
+ }
if (bqual.length == 0) {
- return Long.toHexString(formatId) + // FORMAT ID
- Long.toHexString(gtrid.length) + // VALUE 1-64
- Long.toHexString(bqual.length) + // VALUE 1-64
- Long.toHexString(my_vers) + // INTERNAL VERSION
ID
- Long.toHexString(my_uuid0) + // UNIQUE USERID
PART 1
- Long.toHexString(my_uuid1) + // UNIQUE USERID
PART 2
- new String(my_host) + // HOST NAME
- new String(my_serv) + // SERVER NAME
- Long.toHexString(my_time) + // TIMESTAMP
- new String(bqual);
- } else {
- bq_bqual_base = new byte[1+8+8+16+15+8];
- ByteBuffer bq = ByteBuffer.wrap(bq_bqual_base);
+ return Long.toHexString(formatId) +
+ Long.toHexString(gtrid_length) +
+ Long.toHexString(bqual_length) +
+ str_buff_gtrid.toString() +
+ new String (bqual);
+ }
- if (bq_bqual_base.length > bqual.length) {
- System.arraycopy(bqual, 0, bq_bqual_base, 0, bqual.length);
+ my_bqual_base = new byte[MAXBQUALSIZE];
+ ByteBuffer bb = ByteBuffer.wrap(my_bqual_base);
+
+ System.arraycopy(bqual, 0, my_bqual_base, 0, bqual_length);
+
+ for (int i=0; i<bqual_length; i++) {
+ by_hold = bb.get();
+
+ if ((by_hold >= spaceChar) && (by_hold <= tildeChar)) {
+ ch_hold = (char)by_hold;
+ str_buff_bqual.append(Character.toString(ch_hold));
} else {
- System.arraycopy(bqual, 0, bq_bqual_base, 0,
bq_bqual_base.length);
+ str_buff_bqual.append(Long.toHexString(by_hold));
}
-
- bq_vers = bq.get();
- bq_uuid0 = bq.getLong();
- bq_uuid1 = bq.getLong();
- bq.get(bq_host,0,16);
- bq.get(bq_serv,0,15);
- bq_time = bq.getLong();
-
- return Long.toHexString(formatId) + // FORMAT ID
- Long.toHexString(gtrid.length) + // VALUE 1-64
- Long.toHexString(bqual.length) + // VALUE 1-64
- Long.toHexString(my_vers) + // INTERNAL VERSION
ID
- Long.toHexString(my_uuid0) + // UNIQUE USERID
PART 1
- Long.toHexString(my_uuid1) + // UNIQUE USERID
PART 2
- new String(my_host) + // HOST NAME
- new String(my_serv) + // SERVER NAME
- Long.toHexString(my_time) + // TIMESTAMP
- Long.toHexString(bq_vers) + // INTERNAL VERSION
ID
- Long.toHexString(bq_uuid0) + // UNIQUE USERID
PART 1
- Long.toHexString(bq_uuid1) + // UNIQUE USERID
PART 2
- new String(bq_host) + // HOST NAME
- new String(bq_serv) + // SERVER NAME
- Long.toHexString(bq_time); // TIMESTAMP
}
+
+ return Long.toHexString(formatId) +
+ Long.toHexString(gtrid_length) +
+ Long.toHexString(bqual_length) +
+ str_buff_gtrid.toString() +
+ str_buff_bqual.toString();
}
/*
@@ -380,7 +425,7 @@
server = (server+"
").substring(0,14);
gtrid_base = new byte[1+8+8+16+15];
ByteBuffer bb =
ByteBuffer.wrap(gtrid_base);
- bb.putLong(internalVersId);
+ bb.put(internalVersId);
bb.putLong(uuid0);
bb.putLong(uuid1);
bb.put(host.getBytes());
| <-- Date Index --> | <-- Thread Index --> |
Powered by MHonArc.
Copyright © 2006-2007, OW2 Consortium | contact | webmaster.