当前位置: 首页>>代码示例>>Java>>正文


Java CacheStoreSession.transaction方法代码示例

本文整理汇总了Java中org.apache.ignite.cache.store.CacheStoreSession.transaction方法的典型用法代码示例。如果您正苦于以下问题:Java CacheStoreSession.transaction方法的具体用法?Java CacheStoreSession.transaction怎么用?Java CacheStoreSession.transaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ignite.cache.store.CacheStoreSession的用法示例。


在下文中一共展示了CacheStoreSession.transaction方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onSessionEnd

import org.apache.ignite.cache.store.CacheStoreSession; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void onSessionEnd(CacheStoreSession ses, boolean commit) {
    if (ses.isWithinTransaction()) {
        TransactionStatus tx = ses.attach(null);

        if (tx != null) {
            try {
                if (commit)
                    txMgr.commit(tx);
                else
                    txMgr.rollback(tx);
            }
            catch (TransactionException e) {
                throw new CacheWriterException("Failed to end store session [tx=" + ses.transaction() + ']', e);
            }
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:19,代码来源:CacheSpringStoreSessionListener.java

示例2: onSessionStart

import org.apache.ignite.cache.store.CacheStoreSession; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void onSessionStart(CacheStoreSession ses) {
    if (ses.attachment() == null) {
        try {
            Session hibSes = sesFactory.openSession();

            ses.attach(hibSes);

            if (ses.isWithinTransaction())
                hibSes.beginTransaction();
        }
        catch (HibernateException e) {
            throw new CacheWriterException("Failed to start store session [tx=" + ses.transaction() + ']', e);
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:17,代码来源:CacheHibernateStoreSessionListener.java

示例3: onSessionEnd

import org.apache.ignite.cache.store.CacheStoreSession; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void onSessionEnd(CacheStoreSession ses, boolean commit) {
    Session hibSes = ses.attach(null);

    if (hibSes != null) {
        try {
            Transaction tx = hibSes.getTransaction();

            if (commit) {
                if (hibSes.isDirty())
                    hibSes.flush();

                if (tx.getStatus() == TransactionStatus.ACTIVE)
                    tx.commit();
            }
            else if (tx.getStatus().canRollback())
                tx.rollback();
        }
        catch (HibernateException e) {
            throw new CacheWriterException("Failed to end store session [tx=" + ses.transaction() + ']', e);
        }
        finally {
            hibSes.close();
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:27,代码来源:CacheHibernateStoreSessionListener.java

示例4: onSessionEnd

import org.apache.ignite.cache.store.CacheStoreSession; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void onSessionEnd(CacheStoreSession ses, boolean commit) {
    Session hibSes = ses.attach(null);

    if (hibSes != null) {
        try {
            Transaction tx = hibSes.getTransaction();

            if (commit) {
                hibSes.flush();

                if (tx.isActive())
                    tx.commit();
            }
            else if (tx.isActive())
                tx.rollback();
        }
        catch (HibernateException e) {
            throw new CacheWriterException("Failed to end store session [tx=" + ses.transaction() + ']', e);
        }
        finally {
            hibSes.close();
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:26,代码来源:CacheHibernateStoreSessionListener.java

示例5: connection

import org.apache.ignite.cache.store.CacheStoreSession; //导入方法依赖的package包/类
/**
 * @return Connection.
 * @throws SQLException In case of error.
 */
protected Connection connection() throws SQLException {
    CacheStoreSession ses = session();

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

        Connection conn = prop.get(ATTR_CONN_PROP);

        if (conn == null) {
            conn = openConnection(false);

            // Store connection in session to used it for other operations in the same session.
            prop.put(ATTR_CONN_PROP, conn);
        }

        return conn;
    }
    // Transaction can be null in case of simple load operation.
    else
        return openConnection(true);
}
 
开发者ID:apache,项目名称:ignite,代码行数:26,代码来源:CacheAbstractJdbcStore.java

示例6: onSessionEnd

import org.apache.ignite.cache.store.CacheStoreSession; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void onSessionEnd(CacheStoreSession ses, boolean commit) {
    Connection conn = ses.attach(null);

    if (conn != null) {
        try {
            if (commit)
                conn.commit();
            else
                conn.rollback();
        }
        catch (SQLException e) {
            throw new CacheWriterException("Failed to end store session [tx=" + ses.transaction() + ']', e);
        }
        finally {
            U.closeQuiet(conn);
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:20,代码来源:CacheJdbcStoreSessionListener.java

示例7: checkTx

import org.apache.ignite.cache.store.CacheStoreSession; //导入方法依赖的package包/类
/**
 * @param ses Session.
 * @param load {@code True} if {@link #loadAll} method is called.
 */
private void checkTx(@Nullable CacheStoreSession ses, boolean load) {
    Transaction tx = ses != null ? ses.transaction() : null;

    if (tx == null)
        return;

    txs.add(tx);

    IgniteInternalTx tx0 = GridTestUtils.getFieldValue(tx, "tx");

    if (!tx0.local())
        throw new IgniteException("Tx is not local: " + tx);

    if (tx0.dht() && !load)
        throw new IgniteException("Tx is DHT: " + tx);
}
 
开发者ID:apache,项目名称:ignite,代码行数:21,代码来源:GridCacheTestStore.java

示例8: onSessionStart

import org.apache.ignite.cache.store.CacheStoreSession; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void onSessionStart(CacheStoreSession ses) {
    if (ses.isWithinTransaction() && ses.attachment() == null) {
        try {
            TransactionDefinition def = definition(ses.transaction(), ses.cacheName());

            ses.attach(txMgr.getTransaction(def));
        }
        catch (TransactionException e) {
            throw new CacheWriterException("Failed to start store session [tx=" + ses.transaction() + ']', e);
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:14,代码来源:CacheSpringStoreSessionListener.java

示例9: closeConnection

import org.apache.ignite.cache.store.CacheStoreSession; //导入方法依赖的package包/类
/**
 * Closes connection.
 *
 * @param conn Connection to close.
 */
protected void closeConnection(@Nullable Connection conn) {
    CacheStoreSession ses = session();

    // Close connection right away if there is no transaction.
    if (ses.transaction() == null)
        U.closeQuiet(conn);
}
 
开发者ID:apache,项目名称:ignite,代码行数:13,代码来源:CacheAbstractJdbcStore.java

示例10: sessionEnd

import org.apache.ignite.cache.store.CacheStoreSession; //导入方法依赖的package包/类
/** {@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 + ']');
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:34,代码来源:CacheAbstractJdbcStore.java

示例11: onSessionStart

import org.apache.ignite.cache.store.CacheStoreSession; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void onSessionStart(CacheStoreSession ses) {
    if (ses.attachment() == null) {
        try {
            Connection conn = dataSrc.getConnection();

            conn.setAutoCommit(false);

            ses.attach(conn);
        }
        catch (SQLException e) {
            throw new CacheWriterException("Failed to start store session [tx=" + ses.transaction() + ']', e);
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:16,代码来源:CacheJdbcStoreSessionListener.java

示例12: transaction

import org.apache.ignite.cache.store.CacheStoreSession; //导入方法依赖的package包/类
/**
 * @return Current transaction.
 */
@Nullable private Transaction transaction() {
    CacheStoreSession ses = session();

    return ses != null ? ses.transaction() : null;
}
 
开发者ID:apache,项目名称:ignite,代码行数:9,代码来源:CacheHibernateBlobStore.java


注:本文中的org.apache.ignite.cache.store.CacheStoreSession.transaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。