Example usage for javax.transaction.xa Xid toString

List of usage examples for javax.transaction.xa Xid toString

Introduction

In this page you can find the example usage for javax.transaction.xa Xid toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.apache.hadoop.hbase.client.transactional.JtaXAResource.java

public void commit(final Xid xid, final boolean onePhase) throws XAException {
    LOG.trace("commit [" + xid.toString() + "] " + (onePhase ? "one phase" : "two phase"));
    TransactionState state = xidToTransactionState.remove(xid);
    if (state == null) {
        throw new XAException(XAException.XAER_NOTA);
    }/*from ww w  . j a  v a  2 s.  com*/
    try {
        if (onePhase) {
            transactionManager.tryCommit(state);
        } else {
            transactionManager.doCommit(state);
        }
    } catch (CommitUnsuccessfulException e) {
        throw new XAException(XAException.XA_RBROLLBACK);
    } catch (UnsuccessfulDDLException e) {
        throw new XAException(XAException.XA_RBROLLBACK);
    } catch (IOException e) {
        XAException xae = new XAException(XAException.XAER_RMERR);
        xae.initCause(e);
        throw xae;
    } finally {
        threadLocalTransactionState.remove();
    }

}

From source file:org.apache.hadoop.hbase.client.transactional.JtaXAResource.java

public void end(final Xid xid, final int flags) throws XAException {
    LOG.trace("end [" + xid.toString() + "] ");
    threadLocalTransactionState.remove();
}

From source file:org.apache.hadoop.hbase.client.transactional.JtaXAResource.java

public void forget(final Xid xid) throws XAException {
    LOG.trace("forget [" + xid.toString() + "] ");
    threadLocalTransactionState.remove();
    TransactionState state = xidToTransactionState.remove(xid);
    if (state != null) {
        try {/*  w w  w.  ja v a  2 s .c  o  m*/
            transactionManager.abort(state);
        } catch (Exception e) {
            XAException xae = new XAException(XAException.XAER_RMERR);
            xae.initCause(e);
            throw xae;
        }
    }
}

From source file:org.apache.hadoop.hbase.client.transactional.JtaXAResource.java

public int prepare(final Xid xid) throws XAException {
    LOG.trace("prepare [" + xid.toString() + "] ");
    TransactionState state = xidToTransactionState.get(xid);
    int status;/*w  ww  . jav  a 2 s.  c om*/
    try {
        status = this.transactionManager.prepareCommit(state);
    } catch (CommitUnsuccessfulException e) {
        XAException xae = new XAException(XAException.XA_HEURRB);
        xae.initCause(e);
        throw xae;
    } catch (IOException e) {
        XAException xae = new XAException(XAException.XAER_RMERR);
        xae.initCause(e);
        throw xae;
    }

    switch (status) {
    case TransactionalReturn.COMMIT_OK:
        return XAResource.XA_OK;
    case TransactionalReturn.COMMIT_OK_READ_ONLY:
        return XAResource.XA_RDONLY;
    default:
        throw new XAException(XAException.XA_RBPROTO);
    }
}

From source file:org.apache.hadoop.hbase.client.transactional.JtaXAResource.java

public void rollback(final Xid xid) throws XAException {
    LOG.trace("rollback [" + xid.toString() + "] ");
    forget(xid);/*from   w  w  w .  j  av  a2 s  . c  o m*/
    threadLocalTransactionState.remove();
}

From source file:org.apache.hadoop.hbase.client.transactional.JtaXAResource.java

public void start(final Xid xid, final int flags) throws XAException {
    LOG.trace("start [" + xid.toString() + "] ");
    // TODO, check flags
    TransactionState state = this.transactionManager.beginTransaction();
    threadLocalTransactionState.set(state);
    xidToTransactionState.put(xid, state);
}