use of org.mobicents.ha.javax.sip.cache.SipCacheException in project jain-sip.ha by RestComm.
the class SIPDialogCacheData method createDialog.
private HASipDialog createDialog(String dialogId, Map<String, Object> dialogMetaData, Object dialogAppData) throws SipCacheException {
HASipDialog haSipDialog = null;
if (dialogMetaData != null) {
if (clusteredlogger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
clusteredlogger.logDebug("sipStack " + this + " dialog " + dialogId + " is present in the distributed cache, recreating it locally");
}
final String lastResponseStringified = (String) dialogMetaData.get(AbstractHASipDialog.LAST_RESPONSE);
try {
final SIPResponse lastResponse = (SIPResponse) SipFactory.getInstance().createMessageFactory().createResponse(lastResponseStringified);
haSipDialog = HASipDialogFactory.createHASipDialog(stack.getReplicationStrategy(), (SipProviderImpl) stack.getSipProviders().next(), lastResponse);
haSipDialog.setDialogId(dialogId);
updateDialogMetaData(dialogMetaData, dialogAppData, haSipDialog, true);
// setLastResponse won't be called on recreation since version will be null on recreation
haSipDialog.setLastResponse(lastResponse);
if (clusteredlogger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
clusteredlogger.logDebug("HA SIP Dialog " + dialogId + " localTag = " + haSipDialog.getLocalTag());
clusteredlogger.logDebug("HA SIP Dialog " + dialogId + " remoteTag = " + haSipDialog.getRemoteTag());
clusteredlogger.logDebug("HA SIP Dialog " + dialogId + " localParty = " + haSipDialog.getLocalParty());
clusteredlogger.logDebug("HA SIP Dialog " + dialogId + " remoteParty = " + haSipDialog.getRemoteParty());
clusteredlogger.logDebug("HA SIP Dialog " + dialogId + " state = " + ((SIPDialog) haSipDialog).getState());
}
} catch (PeerUnavailableException e) {
throw new SipCacheException("A problem occured while retrieving the following dialog " + dialogId + " from the Cache", e);
} catch (ParseException e) {
throw new SipCacheException("A problem occured while retrieving the following dialog " + dialogId + " from the Cache", e);
}
}
return haSipDialog;
}
use of org.mobicents.ha.javax.sip.cache.SipCacheException in project jain-sip.ha by RestComm.
the class SIPClientTransactionCacheData method getClientTransaction.
public SIPClientTransaction getClientTransaction(String txId) throws SipCacheException {
SIPClientTransaction haSipClientTransaction = null;
if (logger.isLoggingEnabled(StackLogger.TRACE_TRACE))
logger.logDebug("getServerTransaction(" + txId + ")");
try {
final Map<String, Object> transactionMetaData = (Map<String, Object>) getClientTransactions().get(txId);
final Object txAppData = getClientTransactionsApp().get(txId);
haSipClientTransaction = createClientTransaction(txId, transactionMetaData, txAppData);
} catch (Exception e) {
throw new SipCacheException(e);
}
return haSipClientTransaction;
}
use of org.mobicents.ha.javax.sip.cache.SipCacheException in project jain-sip.ha by RestComm.
the class SIPServerTransactionCacheData method putServerTransaction.
public void putServerTransaction(SIPServerTransaction serverTransaction) throws SipCacheException {
if (logger.isLoggingEnabled(StackLogger.TRACE_TRACE))
logger.logDebug("putServerTransaction(" + serverTransaction.getTransactionId() + ")");
try {
final MobicentsHASIPServerTransaction haServerTransaction = (MobicentsHASIPServerTransaction) serverTransaction;
// meta data
Map<String, Object> metaData = haServerTransaction.getMetaDataToReplicate();
getServerTransactions().put(serverTransaction.getTransactionId(), metaData);
// app data
final Object transactionAppData = haServerTransaction.getApplicationDataToReplicate();
if (transactionAppData != null) {
getServerTransactionsApp().put(serverTransaction.getTransactionId(), transactionAppData);
}
} catch (Exception e) {
throw new SipCacheException(e);
}
}
use of org.mobicents.ha.javax.sip.cache.SipCacheException in project jain-sip.ha by RestComm.
the class SIPClientTransactionCacheData method createClientTransaction.
public MobicentsHASIPClientTransaction createClientTransaction(String txId, Map<String, Object> transactionMetaData, Object transactionAppData) throws SipCacheException {
MobicentsHASIPClientTransaction haClientTransaction = null;
if (transactionMetaData != null) {
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug("sipStack " + this + " client transaction " + txId + " is present in the distributed cache, recreating it locally");
}
String channelTransport = (String) transactionMetaData.get(MobicentsHASIPClientTransaction.TRANSPORT);
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug(txId + " : transport " + channelTransport);
}
InetAddress channelIp = (InetAddress) transactionMetaData.get(MobicentsHASIPClientTransaction.PEER_IP);
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug(txId + " : channel peer Ip address " + channelIp);
}
Integer channelPort = (Integer) transactionMetaData.get(MobicentsHASIPClientTransaction.PEER_PORT);
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug(txId + " : channel peer port " + channelPort);
}
Integer myPort = (Integer) transactionMetaData.get(MobicentsHASIPClientTransaction.MY_PORT);
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug(txId + " : my port " + myPort);
}
MessageChannel messageChannel = null;
MessageProcessor[] messageProcessors = stack.getStackMessageProcessors();
for (MessageProcessor messageProcessor : messageProcessors) {
if (messageProcessor.getTransport().equalsIgnoreCase(channelTransport)) {
try {
messageChannel = messageProcessor.createMessageChannel(channelIp, channelPort);
} catch (IOException e) {
logger.logError("couldn't recreate the message channel on ip address " + channelIp + " and port " + channelPort, e);
}
break;
}
}
haClientTransaction = new MobicentsHASIPClientTransaction((SIPTransactionStack) stack, messageChannel);
haClientTransaction.setBranch(txId);
try {
updateClientTransactionMetaData(transactionMetaData, transactionAppData, haClientTransaction, true);
} catch (PeerUnavailableException e) {
throw new SipCacheException("A problem occured while retrieving the following transaction " + txId + " from the Cache", e);
} catch (ParseException e) {
throw new SipCacheException("A problem occured while retrieving the following transaction " + txId + " from the Cache", e);
}
} else {
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug("sipStack " + this + " client transaction " + txId + " not found in the distributed cache");
}
}
return haClientTransaction;
}
use of org.mobicents.ha.javax.sip.cache.SipCacheException in project jain-sip.ha by RestComm.
the class SIPServerTransactionCacheData method createServerTransaction.
public MobicentsHASIPServerTransaction createServerTransaction(String txId, Map<String, Object> transactionMetaData, Object transactionAppData) throws SipCacheException {
MobicentsHASIPServerTransaction haServerTransaction = null;
if (transactionMetaData != null) {
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug("sipStack " + this + " server transaction " + txId + " is present in the distributed cache, recreating it locally");
}
String channelTransport = (String) transactionMetaData.get(MobicentsHASIPServerTransaction.TRANSPORT);
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug(txId + " : transport " + channelTransport);
}
InetAddress channelIp = (InetAddress) transactionMetaData.get(MobicentsHASIPServerTransaction.PEER_IP);
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug(txId + " : channel peer Ip address " + channelIp);
}
Integer channelPort = (Integer) transactionMetaData.get(MobicentsHASIPServerTransaction.PEER_PORT);
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug(txId + " : channel peer port " + channelPort);
}
Integer myPort = (Integer) transactionMetaData.get(MobicentsHASIPServerTransaction.MY_PORT);
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug(txId + " : my port " + myPort);
}
MessageChannel messageChannel = null;
MessageProcessor[] messageProcessors = stack.getStackMessageProcessors();
for (MessageProcessor messageProcessor : messageProcessors) {
if (messageProcessor.getTransport().equalsIgnoreCase(channelTransport)) {
try {
messageChannel = messageProcessor.createMessageChannel(channelIp, channelPort);
} catch (IOException e) {
logger.logError("couldn't recreate the message channel on ip address " + channelIp + " and port " + channelPort, e);
}
break;
}
}
haServerTransaction = new MobicentsHASIPServerTransaction((SIPTransactionStack) stack, messageChannel);
haServerTransaction.setBranch(txId);
try {
updateServerTransactionMetaData(transactionMetaData, transactionAppData, haServerTransaction, true);
} catch (PeerUnavailableException e) {
throw new SipCacheException("A problem occured while retrieving the following transaction " + txId + " from the Cache", e);
} catch (ParseException e) {
throw new SipCacheException("A problem occured while retrieving the following transaction " + txId + " from the Cache", e);
}
} else {
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug("sipStack " + this + " server transaction " + txId + " not found in the distributed cache");
}
}
return haServerTransaction;
}
Aggregations