Search in sources :

Example 1 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();
        getClientTransactions().put(clientTransaction.getTransactionId(), metaData);
        // app data
        final Object transactionAppData = haClientTransaction.getApplicationDataToReplicate();
        if (transactionAppData != null) {
            getClientTransactionsApp().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 2 with SipCacheException

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;
}
Also used : MobicentsHASIPClientTransaction(gov.nist.javax.sip.stack.MobicentsHASIPClientTransaction) MessageChannel(gov.nist.javax.sip.stack.MessageChannel) PeerUnavailableException(javax.sip.PeerUnavailableException) MessageProcessor(gov.nist.javax.sip.stack.MessageProcessor) SIPTransactionStack(gov.nist.javax.sip.stack.SIPTransactionStack) SipCacheException(org.mobicents.ha.javax.sip.cache.SipCacheException) IOException(java.io.IOException) ParseException(java.text.ParseException) InetAddress(java.net.InetAddress)

Example 3 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>) getServerTransactions().get(txId);
        final Object txAppData = getServerTransactionsApp().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) 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 4 with SipCacheException

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;
}
Also used : MobicentsHASIPServerTransaction(gov.nist.javax.sip.stack.MobicentsHASIPServerTransaction) MessageChannel(gov.nist.javax.sip.stack.MessageChannel) PeerUnavailableException(javax.sip.PeerUnavailableException) MessageProcessor(gov.nist.javax.sip.stack.MessageProcessor) SIPTransactionStack(gov.nist.javax.sip.stack.SIPTransactionStack) SipCacheException(org.mobicents.ha.javax.sip.cache.SipCacheException) IOException(java.io.IOException) ParseException(java.text.ParseException) InetAddress(java.net.InetAddress)

Example 5 with SipCacheException

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

the class SIPDialogCacheData method updateDialog.

public void updateDialog(HASipDialog haSipDialog, Map<String, Object> dialogMetaData, Object dialogAppData) throws SipCacheException {
    if (dialogMetaData != null) {
        final long currentVersion = haSipDialog.getVersion();
        final Long cacheVersion = ((Long) dialogMetaData.get(AbstractHASipDialog.VERSION));
        if (cacheVersion != null && currentVersion < cacheVersion.longValue()) {
            if (clusteredlogger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
                clusteredlogger.logDebug("HA SIP Dialog " + haSipDialog + " with dialogId " + haSipDialog.getDialogIdToReplicate() + " is older " + currentVersion + " than the one in the cache " + cacheVersion + " updating it");
            }
            try {
                final String lastResponseStringified = (String) dialogMetaData.get(AbstractHASipDialog.LAST_RESPONSE);
                final SIPResponse lastResponse = (SIPResponse) SipFactory.getInstance().createMessageFactory().createResponse(lastResponseStringified);
                haSipDialog.setLastResponse(lastResponse);
                updateDialogMetaData(dialogMetaData, dialogAppData, haSipDialog, false);
            } catch (PeerUnavailableException e) {
                throw new SipCacheException("A problem occured while retrieving the following dialog " + haSipDialog.getDialogIdToReplicate() + " from the TreeCache", e);
            } catch (ParseException e) {
                throw new SipCacheException("A problem occured while retrieving the following dialog " + haSipDialog.getDialogIdToReplicate() + " from the TreeCache", e);
            }
        } else {
            if (clusteredlogger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
                clusteredlogger.logDebug("HA SIP Dialog " + haSipDialog + " with dialogId " + haSipDialog.getDialogIdToReplicate() + " is not older " + currentVersion + " than the one in the cache " + cacheVersion + ", not updating it");
            }
        }
    }
}
Also used : SIPResponse(gov.nist.javax.sip.message.SIPResponse) PeerUnavailableException(javax.sip.PeerUnavailableException) SipCacheException(org.mobicents.ha.javax.sip.cache.SipCacheException) ParseException(java.text.ParseException)

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