use of org.jboss.cache.CacheException in project jain-sip.ha by RestComm.
the class ServerTransactionCacheData method getServerTransaction.
public SIPServerTransaction getServerTransaction(String txId) throws SipCacheException {
SIPServerTransaction haSipServerTransaction = null;
final Cache jbossCache = getMobicentsCache().getJBossCache();
Configuration config = jbossCache.getConfiguration();
final boolean isBuddyReplicationEnabled = config.getBuddyReplicationConfig() != null && config.getBuddyReplicationConfig().isEnabled();
TransactionManager transactionManager = config.getRuntimeConfig().getTransactionManager();
boolean doTx = false;
try {
if (clusteredlogger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
clusteredlogger.logDebug("transaction manager :" + transactionManager);
}
if (transactionManager != null && transactionManager.getTransaction() == null) {
if (clusteredlogger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
clusteredlogger.logDebug("transaction manager begin transaction");
}
transactionManager.begin();
doTx = true;
}
// Adding code to handle Buddy replication to force data gravitation
if (isBuddyReplicationEnabled) {
if (clusteredlogger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
clusteredlogger.logDebug("forcing data gravitation since buddy replication is enabled");
}
jbossCache.getInvocationContext().getOptionOverrides().setForceDataGravitation(true);
}
final Node<String, Object> childNode = getNode().getChild(txId);
if (childNode != null) {
try {
final Map<String, Object> transactionMetaData = childNode.getData();
final Object dialogAppData = childNode.get(APPDATA);
haSipServerTransaction = createServerTransaction(txId, transactionMetaData, dialogAppData);
} catch (CacheException e) {
throw new SipCacheException("A problem occured while retrieving the following server transaction " + txId + " from the Cache", e);
}
} else {
if (clusteredlogger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
clusteredlogger.logDebug("no child node found for transactionId " + txId);
}
}
} catch (Exception ex) {
try {
if (transactionManager != null) {
// Let's set it no matter what.
transactionManager.setRollbackOnly();
}
} catch (Exception exn) {
clusteredlogger.logError("Problem rolling back session mgmt transaction", exn);
}
} finally {
if (doTx) {
try {
if (transactionManager.getTransaction().getStatus() != Status.STATUS_MARKED_ROLLBACK) {
if (clusteredlogger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
clusteredlogger.logDebug("transaction manager committing transaction");
}
transactionManager.commit();
} else {
if (clusteredlogger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
clusteredlogger.logDebug("endBatch(): rolling back batch");
}
transactionManager.rollback();
}
} catch (RollbackException re) {
// Do nothing here since cache may rollback automatically.
clusteredlogger.logWarning("endBatch(): rolling back transaction with exception: " + re);
} catch (RuntimeException re) {
throw re;
} catch (Exception e) {
throw new RuntimeException("endTransaction(): Caught Exception ending batch: ", e);
}
}
}
return haSipServerTransaction;
}
use of org.jboss.cache.CacheException in project jain-sip.ha by RestComm.
the class SIPDialogCacheData method getSIPDialog.
public SIPDialog getSIPDialog(String dialogId) throws SipCacheException {
HASipDialog haSipDialog = null;
final Cache jbossCache = getMobicentsCache().getJBossCache();
Configuration config = jbossCache.getConfiguration();
final boolean isBuddyReplicationEnabled = config.getBuddyReplicationConfig() != null && config.getBuddyReplicationConfig().isEnabled();
TransactionManager transactionManager = config.getRuntimeConfig().getTransactionManager();
boolean doTx = false;
try {
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug("transaction manager :" + transactionManager);
}
if (transactionManager != null && transactionManager.getTransaction() == null) {
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug("transaction manager begin transaction");
}
transactionManager.begin();
doTx = true;
}
// Adding code to handle Buddy replication to force data gravitation
if (isBuddyReplicationEnabled) {
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug("forcing data gravitation since buddy replication is enabled");
}
jbossCache.getInvocationContext().getOptionOverrides().setForceDataGravitation(true);
}
final Node<String, Object> childNode = getNode().getChild(dialogId);
if (childNode != null) {
try {
final Map<String, Object> dialogMetaData = childNode.getData();
final Object dialogAppData = childNode.get(APPDATA);
haSipDialog = createDialog(dialogId, dialogMetaData, dialogAppData);
} catch (CacheException e) {
throw new SipCacheException("A problem occured while retrieving the following dialog " + dialogId + " from the Cache", e);
}
}
} catch (Exception ex) {
try {
logger.logError("Problem taking dialog from cache. We will try to rollback the transction is any.", ex);
if (transactionManager != null) {
// Let's set it no matter what.
transactionManager.setRollbackOnly();
}
} catch (Exception exn) {
logger.logError("Problem rolling back session mgmt transaction", exn);
}
} finally {
if (doTx) {
try {
if (transactionManager.getTransaction().getStatus() != Status.STATUS_MARKED_ROLLBACK) {
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug("transaction manager committing transaction");
}
transactionManager.commit();
} else {
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug("endBatch(): rolling back batch");
}
transactionManager.rollback();
}
} catch (RollbackException re) {
// Do nothing here since cache may rollback automatically.
logger.logWarning("endBatch(): rolling back transaction with exception: " + re);
} catch (RuntimeException re) {
throw re;
} catch (Exception e) {
throw new RuntimeException("endTransaction(): Caught Exception ending batch: ", e);
}
}
}
return (SIPDialog) haSipDialog;
}
use of org.jboss.cache.CacheException in project jain-sip.ha by RestComm.
the class SIPDialogCacheData method updateSIPDialog.
/*
* (non-Javadoc)
* @see org.mobicents.ha.javax.sip.cache.SipCache#updateDialog(gov.nist.javax.sip.stack.SIPDialog)
*/
public void updateSIPDialog(SIPDialog sipDialog) throws SipCacheException {
final String dialogId = sipDialog.getDialogId();
final Cache jbossCache = getMobicentsCache().getJBossCache();
Configuration config = jbossCache.getConfiguration();
final boolean isBuddyReplicationEnabled = config.getBuddyReplicationConfig() != null && config.getBuddyReplicationConfig().isEnabled();
TransactionManager transactionManager = config.getRuntimeConfig().getTransactionManager();
boolean doTx = false;
try {
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug("transaction manager :" + transactionManager);
}
if (transactionManager != null && transactionManager.getTransaction() == null) {
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug("transaction manager begin transaction");
}
transactionManager.begin();
doTx = true;
}
// Adding code to handle Buddy replication to force data gravitation
if (isBuddyReplicationEnabled) {
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug("forcing data gravitation since buddy replication is enabled");
}
jbossCache.getInvocationContext().getOptionOverrides().setForceDataGravitation(true);
}
final Node<String, Object> childNode = getNode().getChild(dialogId);
if (childNode != null) {
try {
final Map<String, Object> dialogMetaData = childNode.getData();
final HASipDialog haSipDialog = (HASipDialog) sipDialog;
final Object dialogAppData = childNode.get(APPDATA);
updateDialog(haSipDialog, dialogMetaData, dialogAppData);
} catch (CacheException e) {
throw new SipCacheException("A problem occured while retrieving the following dialog " + dialogId + " from the Cache", e);
}
}
} catch (Exception ex) {
try {
if (transactionManager != null) {
// Let's set it no matter what.
transactionManager.setRollbackOnly();
}
} catch (Exception exn) {
logger.logError("Problem rolling back session mgmt transaction", exn);
}
} finally {
if (doTx) {
try {
if (transactionManager.getTransaction().getStatus() != Status.STATUS_MARKED_ROLLBACK) {
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug("transaction manager committing transaction");
}
transactionManager.commit();
} else {
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug("endBatch(): rolling back batch");
}
transactionManager.rollback();
}
} catch (RollbackException re) {
// Do nothing here since cache may rollback automatically.
logger.logWarning("endBatch(): rolling back transaction with exception: " + re);
} catch (RuntimeException re) {
throw re;
} catch (Exception e) {
throw new RuntimeException("endTransaction(): Caught Exception ending batch: ", e);
}
}
}
}
use of org.jboss.cache.CacheException in project jain-sip.ha by RestComm.
the class ClientTransactionCacheData method getClientTransaction.
public SIPClientTransaction getClientTransaction(String txId) throws SipCacheException {
SIPClientTransaction haSipClientTransaction = null;
final Cache jbossCache = getMobicentsCache().getJBossCache();
Configuration config = jbossCache.getConfiguration();
final boolean isBuddyReplicationEnabled = config.getBuddyReplicationConfig() != null && config.getBuddyReplicationConfig().isEnabled();
TransactionManager transactionManager = config.getRuntimeConfig().getTransactionManager();
boolean doTx = false;
try {
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug("transaction manager :" + transactionManager);
}
if (transactionManager != null && transactionManager.getTransaction() == null) {
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug("transaction manager begin transaction");
}
transactionManager.begin();
doTx = true;
}
// Adding code to handle Buddy replication to force data gravitation
if (isBuddyReplicationEnabled) {
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug("forcing data gravitation since buddy replication is enabled");
}
jbossCache.getInvocationContext().getOptionOverrides().setForceDataGravitation(true);
}
final Node<String, Object> childNode = getNode().getChild(txId);
if (childNode != null) {
try {
final Map<String, Object> transactionMetaData = childNode.getData();
final Object dialogAppData = childNode.get(APPDATA);
haSipClientTransaction = createClientTransaction(txId, transactionMetaData, dialogAppData);
} catch (CacheException e) {
throw new SipCacheException("A problem occured while retrieving the following client transaction " + txId + " from the Cache", e);
}
} else {
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug("no child node found for transactionId " + txId);
}
}
} catch (Exception ex) {
try {
if (transactionManager != null) {
// Let's set it no matter what.
transactionManager.setRollbackOnly();
}
} catch (Exception exn) {
logger.logError("Problem rolling back session mgmt transaction", exn);
}
} finally {
if (doTx) {
try {
if (transactionManager.getTransaction().getStatus() != Status.STATUS_MARKED_ROLLBACK) {
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug("transaction manager committing transaction");
}
transactionManager.commit();
} else {
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug("endBatch(): rolling back batch");
}
transactionManager.rollback();
}
} catch (RollbackException re) {
// Do nothing here since cache may rollback automatically.
logger.logWarning("endBatch(): rolling back transaction with exception: " + re);
} catch (RuntimeException re) {
throw re;
} catch (Exception e) {
throw new RuntimeException("endTransaction(): Caught Exception ending batch: ", e);
}
}
}
return haSipClientTransaction;
}
Aggregations