List of utility methods to do Transaction Xid Check
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); ... |
int | getXidSize(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); |
boolean | sameTransaction(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++) { ... |
boolean | sameXID(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++) { ... |
String | xidToString(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("")) { ... |