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


Java CacheStoreSession.attach方法代码示例

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


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

示例6: onSessionEnd

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

  if (table != null) {
    try {
      table.close();
    } catch (IOException e) {
      String msg = "Failed to close table connection";
      logger.warning(msg, e);
      throw new CacheException(msg, e);
    }
  }

}
 
开发者ID:bakdata,项目名称:ignite-hbase,代码行数:16,代码来源:HBaseCacheStoreSessionListener.java

示例7: onSessionStart

import org.apache.ignite.cache.store.CacheStoreSession; //导入方法依赖的package包/类
@Override
public void onSessionStart(CacheStoreSession ses) {
  if (ses.attachment() == null) {
    String familyName = ses.cacheName();
    verifyIntegrity(familyName);
    try {
      Table table = conn.getTable(TableName.valueOf(tableName));
      ses.attach(table);
    } catch (IOException e) {
      logger.warning("Error preparing session", e);
      throw new CacheException(e);
    }
  }
}
 
开发者ID:bakdata,项目名称:ignite-hbase,代码行数:15,代码来源:HBaseCacheStoreSessionListener.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: 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


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