Class MariaDbXid

  • All Implemented Interfaces:
    javax.transaction.xa.Xid

    public class MariaDbXid
    extends java.lang.Object
    implements javax.transaction.xa.Xid
    MariaDB XID implementation
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private byte[] branchQualifier  
      private int formatId  
      private byte[] globalTransactionId  
      • Fields inherited from interface javax.transaction.xa.Xid

        MAXBQUALSIZE, MAXGTRIDSIZE
    • Constructor Summary

      Constructors 
      Constructor Description
      MariaDbXid​(int formatId, byte[] globalTransactionId, byte[] branchQualifier)
      Global transaction identifier.
    • Field Detail

      • formatId

        private final int formatId
      • globalTransactionId

        private final byte[] globalTransactionId
      • branchQualifier

        private final byte[] branchQualifier
    • Constructor Detail

      • MariaDbXid

        public MariaDbXid​(int formatId,
                          byte[] globalTransactionId,
                          byte[] branchQualifier)
        Global transaction identifier.
        Parameters:
        formatId - the format identifier part of the XID.
        globalTransactionId - the global transaction identifier part of XID as an array of bytes.
        branchQualifier - the transaction branch identifier part of XID as an array of bytes.
    • Method Detail

      • fromRecoverRow

        public static MariaDbXid fromRecoverRow​(int formatId,
                                                int gtridLength,
                                                int bqualLength,
                                                byte[] data)
                                         throws javax.transaction.xa.XAException
        Build an XID from an XA RECOVER row. The row carries the gtrid and bqual concatenated in a single data column, split according to the gtrid_length and bqual_length columns. Those lengths come from the server, so they are validated against the XA specification bounds and the actual payload before any allocation or copy: a rogue or man-in-the-middle server must not be able to drive the client into a huge allocation or an undeclared runtime exception.
        Parameters:
        formatId - the format identifier part of the XID
        gtridLength - server-declared global transaction identifier length
        bqualLength - server-declared branch qualifier length
        data - concatenated gtrid + bqual bytes
        Returns:
        the parsed XID
        Throws:
        javax.transaction.xa.XAException - with XAER_RMFAIL when the lengths are negative, exceed Xid.MAXGTRIDSIZE/Xid.MAXBQUALSIZE, or do not fit the payload
      • equals

        public boolean equals​(java.lang.Object obj)
        Equal implementation.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - object to compare
        Returns:
        true if object is MariaDbXi and as same parameters
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getFormatId

        public int getFormatId()
        Get format id from XID
        Specified by:
        getFormatId in interface javax.transaction.xa.Xid
        Returns:
        format id
      • getGlobalTransactionId

        public byte[] getGlobalTransactionId()
        Get global transaction id from XID
        Specified by:
        getGlobalTransactionId in interface javax.transaction.xa.Xid
        Returns:
        global transaction id
      • getBranchQualifier

        public byte[] getBranchQualifier()
        Get branch qualifier from XID
        Specified by:
        getBranchQualifier in interface javax.transaction.xa.Xid
        Returns:
        branch qualifier