Search in sources :

Example 1 with HASipDialog

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;
}
Also used : SIPResponse(gov.nist.javax.sip.message.SIPResponse) SipProviderImpl(gov.nist.javax.sip.SipProviderImpl) PeerUnavailableException(javax.sip.PeerUnavailableException) HASipDialog(org.mobicents.ha.javax.sip.HASipDialog) AbstractHASipDialog(gov.nist.javax.sip.stack.AbstractHASipDialog) SIPDialog(gov.nist.javax.sip.stack.SIPDialog) SipCacheException(org.mobicents.ha.javax.sip.cache.SipCacheException) ParseException(java.text.ParseException)

Example 2 with 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);
    }
}
Also used : HASipDialog(org.mobicents.ha.javax.sip.HASipDialog) AbstractHASipDialog(gov.nist.javax.sip.stack.AbstractHASipDialog) Map(java.util.Map)

Example 3 with HASipDialog

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;
}
Also used : SIPResponse(gov.nist.javax.sip.message.SIPResponse) SipProviderImpl(gov.nist.javax.sip.SipProviderImpl) PeerUnavailableException(javax.sip.PeerUnavailableException) HASipDialog(org.mobicents.ha.javax.sip.HASipDialog) AbstractHASipDialog(gov.nist.javax.sip.stack.AbstractHASipDialog) ParseException(java.text.ParseException)

Example 4 with 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);
}
Also used : HASipDialog(org.mobicents.ha.javax.sip.HASipDialog) AbstractHASipDialog(gov.nist.javax.sip.stack.AbstractHASipDialog)

Example 5 with HASipDialog

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;
}
Also used : SIPResponse(gov.nist.javax.sip.message.SIPResponse) SipProviderImpl(gov.nist.javax.sip.SipProviderImpl) PeerUnavailableException(javax.sip.PeerUnavailableException) HASipDialog(org.mobicents.ha.javax.sip.HASipDialog) AbstractHASipDialog(gov.nist.javax.sip.stack.AbstractHASipDialog) SIPDialog(gov.nist.javax.sip.stack.SIPDialog) SipCacheException(org.mobicents.ha.javax.sip.cache.SipCacheException) ParseException(java.text.ParseException)

Aggregations

AbstractHASipDialog (gov.nist.javax.sip.stack.AbstractHASipDialog)10 HASipDialog (org.mobicents.ha.javax.sip.HASipDialog)10 ParseException (java.text.ParseException)6 PeerUnavailableException (javax.sip.PeerUnavailableException)6 SipProviderImpl (gov.nist.javax.sip.SipProviderImpl)3 SIPResponse (gov.nist.javax.sip.message.SIPResponse)3 SIPDialog (gov.nist.javax.sip.stack.SIPDialog)3 RollbackException (javax.transaction.RollbackException)3 TransactionManager (javax.transaction.TransactionManager)3 Cache (org.jboss.cache.Cache)3 CacheException (org.jboss.cache.CacheException)3 MobicentsCache (org.mobicents.cache.MobicentsCache)3 Map (java.util.Map)2 Configuration (org.jboss.cache.config.Configuration)2 SipCacheException (org.mobicents.ha.javax.sip.cache.SipCacheException)2 IMap (com.hazelcast.core.IMap)1 Node (org.jboss.cache.Node)1