use of org.mobicents.ha.javax.sip.HASipDialog 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.HASipDialog in project jain-sip.ha by RestComm.
the class SIPDialogCacheData method putDialog.
public void putDialog(SIPDialog dialog) throws SipCacheException {
if (clusteredlogger.isLoggingEnabled(StackLogger.TRACE_TRACE)) {
clusteredlogger.logDebug("putDialog(" + dialog.getDialogId() + ")");
}
final HASipDialog haSipDialog = (HASipDialog) dialog;
Object dialogMetaData = haSipDialog.getMetaDataToReplicate();
if (dialogMetaData != null) {
if (getDialogs().containsKey(dialog.getDialogId())) {
Map<String, Object> cachedMetaData = (Map<String, Object>) getDialogs().get(dialog.getDialogId());
Long currentVersion = (Long) ((Map<String, Object>) dialogMetaData).get(AbstractHASipDialog.VERSION);
Long cacheVersion = (Long) ((Map<String, Object>) cachedMetaData).get(AbstractHASipDialog.VERSION);
if (cacheVersion.longValue() < currentVersion.longValue()) {
for (Entry<String, Object> e : ((Map<String, Object>) dialogMetaData).entrySet()) {
cachedMetaData.put(e.getKey(), e.getValue());
}
getDialogs().replace(dialog.getDialogId(), cachedMetaData);
}
} else {
getDialogs().put(dialog.getDialogId(), dialogMetaData);
}
}
Object dialogAppData = haSipDialog.getApplicationDataToReplicate();
if (dialogAppData != null) {
if (getAppDataMap().containsKey(dialog.getDialogId()))
getAppDataMap().replace(dialog.getDialogId(), dialogAppData);
else
getAppDataMap().put(dialog.getDialogId(), dialogAppData);
}
}
use of org.mobicents.ha.javax.sip.HASipDialog in project jain-sip.ha by RestComm.
the class SIPDialogCacheData method createDialog.
public HASipDialog createDialog(String dialogId, Map<String, Object> dialogMetaData, Object dialogAppData) throws SipCacheException {
HASipDialog haSipDialog = null;
if (dialogMetaData != null) {
if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.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(clusteredSipStack.getReplicationStrategy(), (SipProviderImpl) clusteredSipStack.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 (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
logger.logDebug("HA SIP Dialog " + dialogId + " localTag = " + haSipDialog.getLocalTag());
logger.logDebug("HA SIP Dialog " + dialogId + " remoteTag = " + haSipDialog.getRemoteTag());
logger.logDebug("HA SIP Dialog " + dialogId + " localParty = " + haSipDialog.getLocalParty());
logger.logDebug("HA SIP Dialog " + dialogId + " remoteParty = " + haSipDialog.getRemoteParty());
}
} 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.HASipDialog in project jain-sip.ha by RestComm.
the class SIPDialogCacheData method updateDialog.
public void updateDialog(SIPDialog dialog) throws SipCacheException {
if (clusteredlogger.isLoggingEnabled(StackLogger.TRACE_TRACE))
clusteredlogger.logDebug("updateDialog(" + dialog.getDialogId() + ")");
final HASipDialog haSipDialog = (HASipDialog) dialog;
final Object dialogMetaData = dialogs.get(dialog.getDialogId());
final Object dialogAppData = appDataMap.get(dialog.getDialogId());
updateDialog(haSipDialog, (Map<String, Object>) dialogMetaData, dialogAppData);
}
use of org.mobicents.ha.javax.sip.HASipDialog 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;
}
Aggregations