Search in sources :

Example 11 with FastList

use of javolution.util.FastList in project smscgateway by RestComm.

the class MProcManagement method resortRules.

private void resortRules(FastList<MProcRule> lst) {
    SortedMap<Integer, MProcRule> cur = new TreeMap<Integer, MProcRule>();
    for (FastList.Node<MProcRule> n = lst.head(), end = lst.tail(); (n = n.getNext()) != end; ) {
        MProcRule rule = n.getValue();
        cur.put(rule.getId(), rule);
    }
    FastList<MProcRule> res = new FastList<MProcRule>();
    res.addAll(cur.values());
    this.mprocs = res;
}
Also used : MProcRule(org.mobicents.smsc.mproc.MProcRule) FastList(javolution.util.FastList) TreeMap(java.util.TreeMap)

Example 12 with FastList

use of javolution.util.FastList in project smscgateway by RestComm.

the class MProcManagement method applyMProcDeliveryTempFailure.

public MProcResult applyMProcDeliveryTempFailure(final MProcRuleRaProvider anMProcRuleRa, Sms sms, ProcessingType processingType) {
    if (this.mprocs.size() == 0) {
        return new MProcResult();
    }
    FastList<MProcRule> cur = this.mprocs;
    PostDeliveryTempFailureProcessorImpl pap = new PostDeliveryTempFailureProcessorImpl(this.smscPropertiesManagement.getDefaultValidityPeriodHours(), this.smscPropertiesManagement.getMaxValidityPeriodHours(), logger);
    MProcMessage message = new MProcMessageImpl(sms, processingType, null);
    try {
        for (FastList.Node<MProcRule> n = cur.head(), end = cur.tail(); (n = n.getNext()) != end; ) {
            MProcRule rule = n.getValue();
            if (rule.isForPostDeliveryTempFailureState() && rule.matchesPostDeliveryTempFailure(message)) {
                if (logger.isDebugEnabled()) {
                    logger.debug("MRule matches at DeliveryTempFailure phase to a message: rule: " + rule + "message: " + sms);
                }
                rule.onPostDeliveryTempFailure(anMProcRuleRa, pap, message);
            }
        }
    } catch (Throwable e) {
        logger.error("Exception when invoking rule.matches(message) or onPostDeliveryTempFailure(): " + e.getMessage(), e);
        return new MProcResult();
    }
    FastList<MProcNewMessage> newMsgs = pap.getPostedMessages();
    MProcResult res = new MProcResult();
    FastList<Sms> res0 = new FastList<Sms>();
    for (FastList.Node<MProcNewMessage> n = newMsgs.head(), end = newMsgs.tail(); (n = n.getNext()) != end; ) {
        MProcNewMessageImpl newMsg = (MProcNewMessageImpl) n.getValue();
        res0.add(newMsg.getSmsContent());
    }
    res.setMessageList(res0);
    if (pap.isNeedDropMessages()) {
        res.setMessageDropped(true);
    }
    if (pap.isNeedRerouteMessages()) {
        res.setMessageIsRerouted(true);
        res.setNewNetworkId(pap.getNewNetworkId());
    }
    return res;
}
Also used : MProcRule(org.mobicents.smsc.mproc.MProcRule) MProcNewMessage(org.mobicents.smsc.mproc.MProcNewMessage) FastList(javolution.util.FastList) PostDeliveryTempFailureProcessorImpl(org.mobicents.smsc.mproc.impl.PostDeliveryTempFailureProcessorImpl) MProcNewMessageImpl(org.mobicents.smsc.mproc.impl.MProcNewMessageImpl) MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) MProcMessageImpl(org.mobicents.smsc.mproc.impl.MProcMessageImpl) Sms(org.mobicents.smsc.library.Sms) MProcMessage(org.mobicents.smsc.mproc.MProcMessage)

Example 13 with FastList

use of javolution.util.FastList in project smscgateway by RestComm.

the class MProcManagement method applyMProcPreDelivery.

public MProcResult applyMProcPreDelivery(final MProcRuleRaProvider anMProcRuleRa, Sms sms, ProcessingType processingType) {
    if (this.mprocs.size() == 0) {
        return new MProcResult();
    }
    FastList<MProcRule> cur = this.mprocs;
    PostPreDeliveryProcessorImpl pap = new PostPreDeliveryProcessorImpl(this.smscPropertiesManagement.getDefaultValidityPeriodHours(), this.smscPropertiesManagement.getMaxValidityPeriodHours(), logger);
    MProcMessage message = new MProcMessageImpl(sms, processingType, null);
    try {
        for (FastList.Node<MProcRule> n = cur.head(), end = cur.tail(); (n = n.getNext()) != end; ) {
            MProcRule rule = n.getValue();
            if (rule.isForPostPreDeliveryState() && rule.matchesPostPreDelivery(message)) {
                if (logger.isDebugEnabled()) {
                    logger.debug("MRule matches at PreDelivery phase to a message: rule: " + rule + "message: " + sms);
                }
                rule.onPostPreDelivery(anMProcRuleRa, pap, message);
            }
        }
    } catch (Throwable e) {
        logger.error("Exception when invoking rule.matches(message) or onPostPreDelivery(): " + e.getMessage(), e);
        return new MProcResult();
    }
    FastList<MProcNewMessage> newMsgs = pap.getPostedMessages();
    MProcResult res = new MProcResult();
    FastList<Sms> res0 = new FastList<Sms>();
    for (FastList.Node<MProcNewMessage> n = newMsgs.head(), end = newMsgs.tail(); (n = n.getNext()) != end; ) {
        MProcNewMessageImpl newMsg = (MProcNewMessageImpl) n.getValue();
        res0.add(newMsg.getSmsContent());
    }
    res.setMessageList(res0);
    if (pap.isNeedDropMessages()) {
        res.setMessageDropped(true);
    }
    if (pap.isNeedRerouteMessages()) {
        res.setMessageIsRerouted(true);
        res.setNewNetworkId(pap.getNewNetworkId());
    }
    return res;
}
Also used : MProcRule(org.mobicents.smsc.mproc.MProcRule) MProcNewMessage(org.mobicents.smsc.mproc.MProcNewMessage) FastList(javolution.util.FastList) MProcNewMessageImpl(org.mobicents.smsc.mproc.impl.MProcNewMessageImpl) PostPreDeliveryProcessorImpl(org.mobicents.smsc.mproc.impl.PostPreDeliveryProcessorImpl) MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) MProcMessageImpl(org.mobicents.smsc.mproc.impl.MProcMessageImpl) Sms(org.mobicents.smsc.library.Sms) MProcMessage(org.mobicents.smsc.mproc.MProcMessage)

Example 14 with FastList

use of javolution.util.FastList in project smscgateway by RestComm.

the class MProcManagement method applyMProcArrival.

public MProcResult applyMProcArrival(final MProcRuleRaProvider anMProcRuleRa, Sms sms, PersistenseCommonInterface persistence) {
    if (this.mprocs.size() == 0) {
        FastList<Sms> res0 = new FastList<Sms>();
        res0.add(sms);
        MProcResult res = new MProcResult();
        res.setMessageList(res0);
        return res;
    }
    FastList<MProcRule> cur = this.mprocs;
    PostArrivalProcessorImpl pap = new PostArrivalProcessorImpl(this.smscPropertiesManagement.getDefaultValidityPeriodHours(), this.smscPropertiesManagement.getMaxValidityPeriodHours(), logger);
    MProcMessage message = new MProcMessageImpl(sms, null, persistence);
    try {
        for (FastList.Node<MProcRule> n = cur.head(), end = cur.tail(); (n = n.getNext()) != end; ) {
            MProcRule rule = n.getValue();
            if (rule.isForPostArrivalState() && rule.matchesPostArrival(message)) {
                if (logger.isDebugEnabled()) {
                    logger.debug("MRule matches at Arrival phase to a message: rule: " + rule + "message: " + sms);
                }
                pap.setRuleIdInProcessing(rule.getId());
                rule.onPostArrival(anMProcRuleRa, pap, message);
            }
        }
    } catch (Throwable e) {
        logger.error("Exception when invoking rule.matches(message) or applyMProcArrival: " + e.getMessage(), e);
        MProcResult res = new MProcResult();
        res.setMessageDropped(true);
        return res;
    }
    MProcResult res = new MProcResult();
    FastList<Sms> res0 = new FastList<Sms>();
    res.setMessageList(res0);
    FastList<MProcNewMessage> newMsgs = pap.getPostedMessages();
    if (pap.isNeedDropMessage()) {
        res.setMessageDropped(true);
        res.setRuleIdDropReject(pap.getRuleIdDropReject());
    } else if (pap.isNeedRejectMessage()) {
        res.setMessageRejected(true);
        // res.setMprocRejectingRuleId(pap.);
        res.setMapErrorCode(pap.getMapErrorCode());
        res.setHttpErrorCode(pap.getHttpErrorCode());
        res.setSmppErrorCode(pap.getSmppErrorCode());
        res.setRuleIdDropReject(pap.getRuleIdDropReject());
    } else {
        res0.add(sms);
    }
    for (FastList.Node<MProcNewMessage> n = newMsgs.head(), end = newMsgs.tail(); (n = n.getNext()) != end; ) {
        MProcNewMessageImpl newMsg = (MProcNewMessageImpl) n.getValue();
        res0.add(newMsg.getSmsContent());
    }
    return res;
}
Also used : MProcRule(org.mobicents.smsc.mproc.MProcRule) MProcNewMessage(org.mobicents.smsc.mproc.MProcNewMessage) FastList(javolution.util.FastList) MProcNewMessageImpl(org.mobicents.smsc.mproc.impl.MProcNewMessageImpl) MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) MProcMessageImpl(org.mobicents.smsc.mproc.impl.MProcMessageImpl) PostArrivalProcessorImpl(org.mobicents.smsc.mproc.impl.PostArrivalProcessorImpl) Sms(org.mobicents.smsc.library.Sms) MProcMessage(org.mobicents.smsc.mproc.MProcMessage)

Example 15 with FastList

use of javolution.util.FastList in project smscgateway by RestComm.

the class SubmitCommonSbb method forwardMessage.

protected void forwardMessage(Sms sms0, boolean withCharging, SmscStatAggregator smscStatAggregator, String messageType, int seqNumber) throws SmscProcessingException {
    ChargingMedium chargingMedium = null;
    EventType eventTypeFailure = null;
    int statusCode = 0;
    switch(sms0.getOriginationType()) {
        case SMPP:
            chargingMedium = ChargingMedium.TxSmppOrig;
            eventTypeFailure = EventType.IN_SMPP_REJECT_MPROC;
            break;
        case SS7_MO:
        case SS7_HR:
            chargingMedium = ChargingMedium.MoOrig;
            break;
        case SIP:
            chargingMedium = ChargingMedium.TxSipOrig;
            break;
        case HTTP:
            chargingMedium = ChargingMedium.HttpOrig;
            eventTypeFailure = EventType.IN_HTTP_REJECT_MPROC;
            break;
    }
    if (withCharging) {
        ChargingSbbLocalObject chargingSbb = getChargingSbbObject();
        chargingSbb.setupChargingRequestInterface(chargingMedium, sms0);
    } else {
        // applying of MProc
        MProcResult mProcResult = MProcManagement.getInstance().applyMProcArrival(itsMProcRa, sms0, persistence);
        FastList<Sms> smss = mProcResult.getMessageList();
        if (smss != null) {
            for (FastList.Node<Sms> n = smss.head(), end = smss.tail(); (n = n.getNext()) != end; ) {
                Sms sms = n.getValue();
                TargetAddress ta = new TargetAddress(sms.getSmsSet());
                TargetAddress lock = persistence.obtainSynchroObject(ta);
                try {
                    sms.setTimestampC(System.currentTimeMillis());
                    synchronized (lock) {
                        boolean storeAndForwMode = MessageUtil.isStoreAndForward(sms);
                        if (!storeAndForwMode) {
                            try {
                                this.scheduler.injectSmsOnFly(sms.getSmsSet(), true);
                            } catch (Exception e) {
                                throw new SmscProcessingException("Exception when running injectSmsOnFly(): " + e.getMessage(), SmppConstants.STATUS_SYSERR, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e, SmscProcessingException.INTERNAL_ERROR_INJECT_STORE_AND_FORWARD_NOT_SET);
                            }
                        } else {
                            // store and forward
                            if (smscPropertiesManagement.getStoreAndForwordMode() == StoreAndForwordMode.fast && sms.getScheduleDeliveryTime() == null) {
                                try {
                                    sms.setStoringAfterFailure(true);
                                    this.scheduler.injectSmsOnFly(sms.getSmsSet(), true);
                                } catch (Exception e) {
                                    throw new SmscProcessingException("Exception when running injectSmsOnFly(): " + e.getMessage(), SmppConstants.STATUS_SYSERR, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e, SmscProcessingException.INTERNAL_ERROR_INJECT_STORE_AND_FORWARD_FAST);
                                }
                            } else {
                                try {
                                    sms.setStored(true);
                                    this.scheduler.setDestCluster(sms.getSmsSet());
                                    persistence.c2_scheduleMessage_ReschedDueSlot(sms, smscPropertiesManagement.getStoreAndForwordMode() == StoreAndForwordMode.fast, false);
                                } catch (PersistenceException e) {
                                    throw new SmscProcessingException("PersistenceException when storing LIVE_SMS : " + e.getMessage(), SmppConstants.STATUS_SUBMITFAIL, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e, SmscProcessingException.INTERNAL_ERROR_INJECT_STORE_AND_FORWARD_NORMAL);
                                }
                            }
                        }
                    }
                } finally {
                    persistence.releaseSynchroObject(lock);
                }
            }
        }
        if (mProcResult.isMessageRejected()) {
            sms0.setMessageDeliveryResultResponse(null);
            if (eventTypeFailure != null) {
                String sourceAddrAndPort = null;
                if (eventTypeFailure == EventType.IN_SMPP_REJECT_MPROC) {
                    EsmeManagement esmeManagement = EsmeManagement.getInstance();
                    if (esmeManagement != null) {
                        // for testing there is no EsmeManagement
                        Esme esme = esmeManagement.getEsmeByClusterName(sms0.getOrigEsmeName());
                        // null check is for testing
                        if (esme != null) {
                            sourceAddrAndPort = esme.getRemoteAddressAndPort();
                        }
                    }
                    statusCode = mProcResult.getSmppErrorCode();
                } else if (eventTypeFailure == EventType.IN_HTTP_REJECT_MPROC) {
                    statusCode = mProcResult.getHttpErrorCode();
                }
                generateMprocFailureDetailedCdr(sms0, eventTypeFailure, ErrorCode.REJECT_INCOMING_MPROC, messageType, statusCode, mProcResult.getRuleIdDropReject(), sourceAddrAndPort, seqNumber);
            }
            rejectSmsByMProc(sms0, "Message is rejected by MProc rules.", mProcResult);
        }
        if (mProcResult.isMessageDropped()) {
            sms0.setMessageDeliveryResultResponse(null);
            smscStatAggregator.updateMsgInFailedAll();
            if (eventTypeFailure != null) {
                String sourceAddrAndPort = null;
                if (eventTypeFailure == EventType.IN_SMPP_REJECT_MPROC) {
                    eventTypeFailure = EventType.IN_SMPP_DROP_MPROC;
                    EsmeManagement esmeManagement = EsmeManagement.getInstance();
                    if (esmeManagement != null) {
                        // for testing there is no EsmeManagement
                        Esme esme = esmeManagement.getEsmeByClusterName(sms0.getOrigEsmeName());
                        // null check is for testing
                        if (esme != null) {
                            sourceAddrAndPort = esme.getRemoteAddressAndPort();
                        }
                    }
                    statusCode = mProcResult.getSmppErrorCode();
                } else if (eventTypeFailure == EventType.IN_HTTP_REJECT_MPROC) {
                    eventTypeFailure = EventType.IN_HTTP_DROP_MPROC;
                    statusCode = mProcResult.getHttpErrorCode();
                }
                generateMprocFailureDetailedCdr(sms0, eventTypeFailure, ErrorCode.REJECT_INCOMING_MPROC, messageType, statusCode, mProcResult.getRuleIdDropReject(), sourceAddrAndPort, seqNumber);
            }
            rejectSmsByMProc(sms0, "Message is dropped by MProc rules.", mProcResult);
        }
        smscStatAggregator.updateMsgInReceivedAll();
        switch(sms0.getOriginationType()) {
            case SMPP:
                smscStatAggregator.updateMsgInReceivedSmpp();
                break;
            case SS7_MO:
                smscStatAggregator.updateMsgInReceivedSs7();
                smscStatAggregator.updateMsgInReceivedSs7Mo();
                break;
            case SS7_HR:
                smscStatAggregator.updateMsgInReceivedSs7();
                smscStatAggregator.updateMsgInReceivedSs7Hr();
                break;
            case SIP:
                smscStatAggregator.updateMsgInReceivedSip();
                break;
        }
    }
}
Also used : EsmeManagement(org.restcomm.smpp.EsmeManagement) EventType(org.mobicents.smsc.library.EventType) SmscProcessingException(org.mobicents.smsc.library.SmscProcessingException) Esme(org.restcomm.smpp.Esme) FastList(javolution.util.FastList) TargetAddress(org.mobicents.smsc.library.TargetAddress) SmscProcessingException(org.mobicents.smsc.library.SmscProcessingException) CreateException(javax.slee.CreateException) PersistenceException(org.mobicents.smsc.cassandra.PersistenceException) ChargingSbbLocalObject(org.mobicents.smsc.slee.services.charging.ChargingSbbLocalObject) ChargingMedium(org.mobicents.smsc.slee.services.charging.ChargingMedium) MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) Sms(org.mobicents.smsc.library.Sms) PersistenceException(org.mobicents.smsc.cassandra.PersistenceException)

Aggregations

FastList (javolution.util.FastList)18 MProcResult (org.mobicents.smsc.mproc.impl.MProcResult)12 Sms (org.mobicents.smsc.library.Sms)10 MProcRule (org.mobicents.smsc.mproc.MProcRule)9 TargetAddress (org.mobicents.smsc.library.TargetAddress)6 MProcMessage (org.mobicents.smsc.mproc.MProcMessage)6 MProcMessageImpl (org.mobicents.smsc.mproc.impl.MProcMessageImpl)5 XMLStreamException (javolution.xml.stream.XMLStreamException)4 MProcNewMessage (org.mobicents.smsc.mproc.MProcNewMessage)4 MProcNewMessageImpl (org.mobicents.smsc.mproc.impl.MProcNewMessageImpl)4 Esme (org.restcomm.smpp.Esme)4 EsmeManagement (org.restcomm.smpp.EsmeManagement)4 BoundStatement (com.datastax.driver.core.BoundStatement)2 PreparedStatement (com.datastax.driver.core.PreparedStatement)2 ResultSet (com.datastax.driver.core.ResultSet)2 Row (com.datastax.driver.core.Row)2 InvalidQueryException (com.datastax.driver.core.exceptions.InvalidQueryException)2 FileNotFoundException (java.io.FileNotFoundException)2 ArrayList (java.util.ArrayList)2 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)2