Java Utililty Methods Transaction Xid Check

List of utility methods to do Transaction Xid Check

Description

The list of methods to do Transaction Xid Check are organized into topic(s).

Method

byte[]getRedisKey(String keyPrefix, Xid xid)
get Redis Key
byte[] prefix = keyPrefix.getBytes();
byte[] globalTransactionId = xid.getGlobalTransactionId();
byte[] branchQualifier = xid.getBranchQualifier();
byte[] key = new byte[prefix.length + globalTransactionId.length + branchQualifier.length];
System.arraycopy(prefix, 0, key, 0, prefix.length);
System.arraycopy(globalTransactionId, 0, key, prefix.length, globalTransactionId.length);
System.arraycopy(branchQualifier, 0, key, prefix.length + globalTransactionId.length,
        branchQualifier.length);
...
intgetXidSize(Xid xid)
The byte[]'s in Xid's are known to be 255 or less in length.
byte[] gid = xid.getGlobalTransactionId();
byte[] bqual = xid.getBranchQualifier();
return INT_BYTES + 
        1 + 
        1 + 
        (gid == null ? 0 : gid.length) + 
        (bqual == null ? 0 : bqual.length); 
booleansameTransaction(Xid x1, Xid x2)
Compares two Xid instances at the gtid level only.
if (x1 == x2)
    return true;
else {
    if (x1.getFormatId() == x2.getFormatId()) {
        byte[] gtrid1 = x1.getGlobalTransactionId();
        byte[] gtrid2 = x2.getGlobalTransactionId();
        if (gtrid1.length == gtrid2.length) {
            for (int i = 0; i < gtrid1.length; i++) {
...
booleansameXID(Xid x1, Xid x2)
Compares two Xid instances.
if (x1 == x2)
    return true;
else {
    if (x1.getFormatId() == x2.getFormatId()) {
        byte[] gtrid1 = x1.getGlobalTransactionId();
        byte[] gtrid2 = x2.getGlobalTransactionId();
        if (gtrid1.length == gtrid2.length) {
            for (int i = 0; i < gtrid1.length; i++) {
...
StringxidToString(Xid xid, boolean includeBranchQualifier)
xid To String
if (xid == null)
    return "";
StringBuffer sb = new StringBuffer()
        .append(Integer.toHexString(xid.getFormatId()).toUpperCase(Locale.ENGLISH)).append("-")
        .append(byteArrayToString(xid.getGlobalTransactionId()));
if (includeBranchQualifier) {
    String bqual = byteArrayToString(xid.getBranchQualifier());
    if (!bqual.equals("")) {
...