本文整理汇总了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);
}
}
}
}
示例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);
}
}
}
示例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();
}
}
}
示例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();
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}