Search in sources :

Example 6 with SipCacheException

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;
}
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 7 with SipCacheException

use of org.mobicents.ha.javax.sip.cache.SipCacheException in project jain-sip.ha by RestComm.

the class SIPClientTransactionCacheData method putClientTransaction.

public void putClientTransaction(SIPClientTransaction clientTransaction) throws SipCacheException {
    if (logger.isLoggingEnabled(StackLogger.TRACE_TRACE))
        logger.logDebug("putClientTransaction(" + clientTransaction.getTransactionId() + ")");
    try {
        final MobicentsHASIPClientTransaction haClientTransaction = (MobicentsHASIPClientTransaction) clientTransaction;
        // metadata
        Map<String, Object> metaData = haClientTransaction.getMetaDataToReplicate();
        clientTransactions.put(clientTransaction.getTransactionId(), metaData);
        // app data
        final Object transactionAppData = haClientTransaction.getApplicationDataToReplicate();
        if (transactionAppData != null) {
            clientTransactionsApp.put(clientTransaction.getTransactionId(), transactionAppData);
        }
    } catch (Exception e) {
        throw new SipCacheException(e);
    }
}
Also used : MobicentsHASIPClientTransaction(gov.nist.javax.sip.stack.MobicentsHASIPClientTransaction) SipCacheException(org.mobicents.ha.javax.sip.cache.SipCacheException) SipCacheException(org.mobicents.ha.javax.sip.cache.SipCacheException) IOException(java.io.IOException) ParseException(java.text.ParseException) PeerUnavailableException(javax.sip.PeerUnavailableException)

Example 8 with SipCacheException

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>) clientTransactions.get(txId);
        final Object txAppData = clientTransactionsApp.get(txId);
        haSipClientTransaction = createClientTransaction(txId, transactionMetaData, txAppData);
    } catch (Exception e) {
        throw new SipCacheException(e);
    }
    return haSipClientTransaction;
}
Also used : SIPClientTransaction(gov.nist.javax.sip.stack.SIPClientTransaction) MobicentsHASIPClientTransaction(gov.nist.javax.sip.stack.MobicentsHASIPClientTransaction) SipCacheException(org.mobicents.ha.javax.sip.cache.SipCacheException) IMap(com.hazelcast.core.IMap) Map(java.util.Map) SipCacheException(org.mobicents.ha.javax.sip.cache.SipCacheException) IOException(java.io.IOException) ParseException(java.text.ParseException) PeerUnavailableException(javax.sip.PeerUnavailableException)

Example 9 with SipCacheException

use of org.mobicents.ha.javax.sip.cache.SipCacheException in project jain-sip.ha by RestComm.

the class SIPServerTransactionCacheData method getServerTransaction.

public SIPServerTransaction getServerTransaction(String txId) throws SipCacheException {
    SIPServerTransaction haSipServerTransaction = null;
    if (logger.isLoggingEnabled(StackLogger.TRACE_TRACE))
        logger.logDebug("getServerTransaction(" + txId + ")");
    try {
        final Map<String, Object> transactionMetaData = (Map<String, Object>) serverTransactions.get(txId);
        final Object txAppData = serverTransactionsApp.get(txId);
        haSipServerTransaction = createServerTransaction(txId, transactionMetaData, txAppData);
    } catch (Exception e) {
        throw new SipCacheException(e);
    }
    return haSipServerTransaction;
}
Also used : SipCacheException(org.mobicents.ha.javax.sip.cache.SipCacheException) MobicentsHASIPServerTransaction(gov.nist.javax.sip.stack.MobicentsHASIPServerTransaction) SIPServerTransaction(gov.nist.javax.sip.stack.SIPServerTransaction) IMap(com.hazelcast.core.IMap) Map(java.util.Map) SipCacheException(org.mobicents.ha.javax.sip.cache.SipCacheException) IOException(java.io.IOException) ParseException(java.text.ParseException) PeerUnavailableException(javax.sip.PeerUnavailableException)

Example 10 with SipCacheException

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();
        serverTransactions.put(serverTransaction.getTransactionId(), metaData);
        // app data
        final Object transactionAppData = haServerTransaction.getApplicationDataToReplicate();
        if (transactionAppData != null) {
            serverTransactionsApp.put(serverTransaction.getTransactionId(), transactionAppData);
        }
    } catch (Exception e) {
        throw new SipCacheException(e);
    }
}
Also used : MobicentsHASIPServerTransaction(gov.nist.javax.sip.stack.MobicentsHASIPServerTransaction) SipCacheException(org.mobicents.ha.javax.sip.cache.SipCacheException) SipCacheException(org.mobicents.ha.javax.sip.cache.SipCacheException) IOException(java.io.IOException) ParseException(java.text.ParseException) PeerUnavailableException(javax.sip.PeerUnavailableException)

Aggregations

SipCacheException (org.mobicents.ha.javax.sip.cache.SipCacheException)20 ParseException (java.text.ParseException)16 PeerUnavailableException (javax.sip.PeerUnavailableException)16 IOException (java.io.IOException)12 MobicentsHASIPClientTransaction (gov.nist.javax.sip.stack.MobicentsHASIPClientTransaction)7 MobicentsHASIPServerTransaction (gov.nist.javax.sip.stack.MobicentsHASIPServerTransaction)6 SIPResponse (gov.nist.javax.sip.message.SIPResponse)5 MessageChannel (gov.nist.javax.sip.stack.MessageChannel)4 MessageProcessor (gov.nist.javax.sip.stack.MessageProcessor)4 SIPTransactionStack (gov.nist.javax.sip.stack.SIPTransactionStack)4 InetAddress (java.net.InetAddress)4 Map (java.util.Map)4 SIPClientTransaction (gov.nist.javax.sip.stack.SIPClientTransaction)3 SIPDialog (gov.nist.javax.sip.stack.SIPDialog)3 SIPServerTransaction (gov.nist.javax.sip.stack.SIPServerTransaction)3 IMap (com.hazelcast.core.IMap)2 SipProviderImpl (gov.nist.javax.sip.SipProviderImpl)2 AbstractHASipDialog (gov.nist.javax.sip.stack.AbstractHASipDialog)2 HASipDialog (org.mobicents.ha.javax.sip.HASipDialog)2 ResponseExt (gov.nist.javax.sip.message.ResponseExt)1