Java Code Examples for org.apache.ignite.transactions.Transaction#xid()

The following examples show how to use org.apache.ignite.transactions.Transaction#xid() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CacheHibernateBlobStore.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void sessionEnd(boolean commit) {
    init();

    Transaction tx = transaction();

    Map<String, Session> props = session().properties();

    Session ses = props.remove(ATTR_SES);

    if (ses != null) {
        org.hibernate.Transaction hTx = ses.getTransaction();

        if (hTx != null) {
            try {
                if (commit) {
                    ses.flush();

                    hTx.commit();
                }
                else
                    hTx.rollback();

                if (log.isDebugEnabled())
                    log.debug("Transaction ended [xid=" + tx.xid() + ", commit=" + commit + ']');
            }
            catch (HibernateException e) {
                throw new CacheWriterException("Failed to end transaction [xid=" + tx.xid() +
                    ", commit=" + commit + ']', e);
            }
            finally {
                ses.close();
            }
        }
    }
}
 
Example 2
Source File: CacheHibernateBlobStore.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void sessionEnd(boolean commit) {
    init();

    Transaction tx = transaction();

    Map<String, Session> props = session().properties();

    Session ses = props.remove(ATTR_SES);

    if (ses != null) {
        org.hibernate.Transaction hTx = ses.getTransaction();

        if (hTx != null) {
            try {
                if (commit) {
                    ses.flush();

                    hTx.commit();
                }
                else
                    hTx.rollback();

                if (log.isDebugEnabled())
                    log.debug("Transaction ended [xid=" + tx.xid() + ", commit=" + commit + ']');
            }
            catch (HibernateException e) {
                throw new CacheWriterException("Failed to end transaction [xid=" + tx.xid() +
                    ", commit=" + commit + ']', e);
            }
            finally {
                ses.close();
            }
        }
    }
}
 
Example 3
Source File: CacheHibernateBlobStore.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void sessionEnd(boolean commit) {
    init();

    Transaction tx = transaction();

    Map<String, Session> props = session().properties();

    Session ses = props.remove(ATTR_SES);

    if (ses != null) {
        org.hibernate.Transaction hTx = ses.getTransaction();

        if (hTx != null) {
            try {
                if (commit) {
                    ses.flush();

                    hTx.commit();
                }
                else
                    hTx.rollback();

                if (log.isDebugEnabled())
                    log.debug("Transaction ended [xid=" + tx.xid() + ", commit=" + commit + ']');
            }
            catch (HibernateException e) {
                throw new CacheWriterException("Failed to end transaction [xid=" + tx.xid() +
                    ", commit=" + commit + ']', e);
            }
            finally {
                ses.close();
            }
        }
    }
}
 
Example 4
Source File: CacheAbstractJdbcStore.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void sessionEnd(boolean commit) throws CacheWriterException {
    CacheStoreSession ses = session();

    Transaction tx = ses.transaction();

    if (tx != null) {
        Map<String, Connection> sesProps = ses.properties();

        Connection conn = sesProps.get(ATTR_CONN_PROP);

        if (conn != null) {
            sesProps.remove(ATTR_CONN_PROP);

            try {
                if (commit)
                    conn.commit();
                else
                    conn.rollback();
            }
            catch (SQLException e) {
                throw new CacheWriterException(
                        "Failed to end transaction [xid=" + tx.xid() + ", commit=" + commit + ']', e);
            }
            finally {
                U.closeQuiet(conn);
            }
        }

        if (log.isDebugEnabled())
            log.debug("Transaction ended [xid=" + tx.xid() + ", commit=" + commit + ']');
    }
}
 
Example 5
Source File: CacheJdbcBlobStore.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void sessionEnd(boolean commit) {
    init();

    Transaction tx = transaction();

    Map<String, Connection> props = session().properties();

    Connection conn = props.remove(ATTR_CONN);

    if (conn != null) {
        try {
            if (commit)
                conn.commit();
            else
                conn.rollback();
        }
        catch (SQLException e) {
            throw new CacheWriterException("Failed to end transaction [xid=" + tx.xid() + ", commit=" + commit + ']', e);
        }
        finally {
            closeConnection(conn);
        }
    }

    if (log.isDebugEnabled())
        log.debug("Transaction ended [xid=" + tx.xid() + ", commit=" + commit + ']');
}