Search in sources :

Example 6 with FastList

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

the class MProcManagement method destroyMProcRule.

@Override
public MProcRule destroyMProcRule(int mProcRuleId) throws Exception {
    logger.info("destroyMProcRule: id=" + mProcRuleId);
    MProcRule mProcRule = this.getMProcRuleById(mProcRuleId);
    if (mProcRule == null) {
        throw new Exception(String.format(MProcRuleOamMessages.DESTROY_MPROC_RULE_FAIL_NOT_EXIST, mProcRuleId));
    }
    FastList<MProcRule> lstTag = new FastList<MProcRule>(this.mprocs);
    lstTag.remove(mProcRule);
    this.resortRules(lstTag);
    this.store();
    this.unregisterMProcRuleMbean(mProcRule.getId());
    return mProcRule;
}
Also used : MProcRule(org.mobicents.smsc.mproc.MProcRule) FastList(javolution.util.FastList) XMLStreamException(javolution.xml.stream.XMLStreamException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) InstanceNotFoundException(javax.management.InstanceNotFoundException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) FileNotFoundException(java.io.FileNotFoundException) MalformedObjectNameException(javax.management.MalformedObjectNameException)

Example 7 with FastList

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

the class DBOperations method c2_getSipSmsRoutingRulesRange.

/**
 * Returns 100 rows of SIP_SMS_ROUTING_RULE starting from passed lastAdress. If lastAdress, first 100 rows are returned
 *
 * @param lastAdress
 * @return
 * @throws PersistenceException
 */
public List<DbSmsRoutingRule> c2_getSipSmsRoutingRulesRange(String lastAdress) throws PersistenceException {
    List<DbSmsRoutingRule> ress = new FastList<DbSmsRoutingRule>();
    try {
        PreparedStatement ps = lastAdress != null ? getSipSmsRoutingRulesRange : getSipSmsRoutingRulesRange2;
        BoundStatement boundStatement = new BoundStatement(ps);
        if (lastAdress != null) {
            boundStatement.bind(lastAdress);
        }
        ResultSet result = session.execute(boundStatement);
        int i1 = 0;
        for (Row row : result) {
            String address = row.getString(Schema.COLUMN_ADDRESS);
            String name = row.getString(Schema.COLUMN_CLUSTER_NAME);
            int networkId = row.getInt(Schema.COLUMN_NETWORK_ID);
            DbSmsRoutingRule res = new DbSmsRoutingRule(SmsRoutingRuleType.SIP, address, networkId, name);
            if (i1 == 0) {
                i1 = 1;
                if (lastAdress == null)
                    ress.add(res);
            } else {
                ress.add(res);
            }
        }
        return ress;
    } catch (Exception e) {
        String msg = "Failed to getSmsRoutingRule DbSmsRoutingRule for all records: " + e;
        throw new PersistenceException(msg, e);
    }
}
Also used : FastList(javolution.util.FastList) ResultSet(com.datastax.driver.core.ResultSet) PreparedStatement(com.datastax.driver.core.PreparedStatement) Row(com.datastax.driver.core.Row) DbSmsRoutingRule(org.mobicents.smsc.library.DbSmsRoutingRule) BoundStatement(com.datastax.driver.core.BoundStatement) XMLStreamException(javolution.xml.stream.XMLStreamException) InvalidQueryException(com.datastax.driver.core.exceptions.InvalidQueryException)

Example 8 with FastList

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

the class DeliveryCommonSbb method applyMProcPreDelivery.

private boolean applyMProcPreDelivery(Sms sms, ProcessingType processingType) {
    MProcResult mProcResult = MProcManagement.getInstance().applyMProcPreDelivery(itsMProcRa, sms, processingType);
    if (mProcResult.isMessageIsRerouted()) {
        // firstly we check if rerouting attempts was not too many
        if (sms.getReroutingCount() >= MAX_POSSIBLE_REROUTING) {
            StringBuilder sb = new StringBuilder();
            sb.append("Rerouting message attempt in PreDelivery, but we have already rerouted ");
            sb.append(MAX_POSSIBLE_REROUTING);
            sb.append(" times before: targetId=");
            sb.append(sms.getSmsSet().getTargetId());
            sb.append(", newNetworkId=");
            sb.append(mProcResult.getNewNetworkId());
            sb.append(", sms=");
            sb.append(sms);
            this.logger.warning(sb.toString());
            return false;
        } else if (mProcResult.getNewNetworkId() == sms.getSmsSet().getNetworkId()) {
            // we do not reroute for the same networkId
            return true;
        } else {
            ArrayList<Sms> lstRerouted = new ArrayList<Sms>();
            ArrayList<Integer> lstNewNetworkId = new ArrayList<Integer>();
            lstRerouted.add(sms);
            lstNewNetworkId.add(mProcResult.getNewNetworkId());
            if (this.logger.isInfoEnabled()) {
                StringBuilder sb = new StringBuilder();
                sb.append("Rerouting message in PreDelivery: targetId=");
                sb.append(sms.getSmsSet().getTargetId());
                sb.append(", newNetworkId=");
                sb.append(mProcResult.getNewNetworkId());
                sb.append(", sms=");
                sb.append(sms);
                this.logger.info(sb.toString());
            }
            postProcessRerouted(lstRerouted, lstNewNetworkId);
            return false;
        }
    } else if (mProcResult.isMessageDropped()) {
        if (this.logger.isInfoEnabled()) {
            StringBuilder sb = new StringBuilder();
            sb.append("Dropping message after in PreDelivery: targetId=");
            sb.append(sms.getSmsSet().getTargetId());
            sb.append(", sms=");
            sb.append(sms);
            this.logger.info(sb.toString());
        }
        ArrayList<Sms> lstPermFailured = new ArrayList<Sms>();
        lstPermFailured.add(sms);
        ErrorCode smStatus = ErrorCode.MPROC_PRE_DELIVERY_DROP;
        ErrorAction errorAction = ErrorAction.permanentFailure;
        String reason = "Message drop in PreDelivery";
        sms.getSmsSet().setStatus(smStatus);
        // sending of a failure response for transactional mode
        this.sendTransactionalResponseFailure(lstPermFailured, null, errorAction, null);
        // Processing messages that were temp or permanent failed or rerouted
        this.postProcessPermFailures(lstPermFailured, null, null);
        // generating CDRs for permanent failure messages
        this.generateCDRs(lstPermFailured, CdrGenerator.CDR_MPROC_DROP_PRE_DELIVERY, reason);
        EsmeManagement esmeManagement = EsmeManagement.getInstance();
        Esme esme = esmeManagement.getEsmeByClusterName(smsSet.getDestClusterName());
        String messageType = esme.getSmppSessionType() == Type.CLIENT ? CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITSM : CdrDetailedGenerator.CDR_MSG_TYPE_DELIVERSM;
        this.generateDetailedCDRs(lstPermFailured, EventType.OUT_SMPP_ERROR, smStatus, messageType, esme.getRemoteAddressAndPort(), -1);
        // sending of failure delivery receipts
        this.generateFailureReceipts(sms.getSmsSet(), lstPermFailured, null);
        return false;
    }
    FastList<Sms> addedMessages = mProcResult.getMessageList();
    if (addedMessages != null) {
        for (FastList.Node<Sms> n = addedMessages.head(), end = addedMessages.tail(); (n = n.getNext()) != end; ) {
            Sms smst = n.getValue();
            TargetAddress ta = new TargetAddress(smst.getSmsSet().getDestAddrTon(), smst.getSmsSet().getDestAddrNpi(), smst.getSmsSet().getDestAddr(), smst.getSmsSet().getNetworkId());
            this.sendNewGeneratedMessage(smst, ta);
            if (this.logger.isInfoEnabled()) {
                StringBuilder sb = new StringBuilder();
                sb.append("Posting of a new message after PreDelivery: targetId=");
                sb.append(smst.getSmsSet().getTargetId());
                sb.append(", sms=");
                sb.append(smst);
                this.logger.info(sb.toString());
            }
        }
    }
    return true;
}
Also used : EsmeManagement(org.restcomm.smpp.EsmeManagement) Esme(org.restcomm.smpp.Esme) ArrayList(java.util.ArrayList) FastList(javolution.util.FastList) TargetAddress(org.mobicents.smsc.library.TargetAddress) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) ErrorAction(org.mobicents.smsc.library.ErrorAction) MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) Sms(org.mobicents.smsc.library.Sms) ErrorCode(org.mobicents.smsc.library.ErrorCode)

Example 9 with FastList

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

the class DeliveryCommonSbb method applyMprocRulesOnFailure.

/**
 * mproc rules applying for delivery phase for failure case
 *
 * @param lstPermFailured
 * @param lstTempFailured
 * @param lstPermFailuredNew
 * @param lstTempFailuredNew
 * @param lstRerouted
 * @param lstNewNetworkId
 * @param processingType
 */
protected void applyMprocRulesOnFailure(ArrayList<Sms> lstPermFailured, ArrayList<Sms> lstTempFailured, ArrayList<Sms> lstPermFailuredNew, ArrayList<Sms> lstTempFailuredNew, ArrayList<Sms> lstRerouted, ArrayList<Integer> lstNewNetworkId, ProcessingType processingType) {
    // TempFailureProcessor
    for (Sms sms : lstTempFailured) {
        MProcResult mProcResult = MProcManagement.getInstance().applyMProcDeliveryTempFailure(itsMProcRa, sms, processingType);
        if (mProcResult.isMessageIsRerouted()) {
            // firstly we check if rerouting attempts was not too many
            if (sms.getReroutingCount() >= MAX_POSSIBLE_REROUTING) {
                StringBuilder sb = new StringBuilder();
                sb.append("Rerouting message attempt after TempFailure, but we have already rerouted ");
                sb.append(MAX_POSSIBLE_REROUTING);
                sb.append(" times before: targetId=");
                sb.append(sms.getSmsSet().getTargetId());
                sb.append(", newNetworkId=");
                sb.append(mProcResult.getNewNetworkId());
                sb.append(", sms=");
                sb.append(sms);
                this.logger.warning(sb.toString());
                lstTempFailuredNew.add(sms);
            } else if (mProcResult.getNewNetworkId() == sms.getSmsSet().getNetworkId()) {
                // we do not reroute for the same networkId
                lstTempFailuredNew.add(sms);
            } else {
                lstRerouted.add(sms);
                lstNewNetworkId.add(mProcResult.getNewNetworkId());
                if (this.logger.isInfoEnabled()) {
                    StringBuilder sb = new StringBuilder();
                    sb.append("Rerouting message after TempFailure: targetId=");
                    sb.append(sms.getSmsSet().getTargetId());
                    sb.append(", newNetworkId=");
                    sb.append(mProcResult.getNewNetworkId());
                    sb.append(", sms=");
                    sb.append(sms);
                    this.logger.info(sb.toString());
                }
            }
        } else if (mProcResult.isMessageDropped()) {
            lstPermFailuredNew.add(sms);
            if (this.logger.isInfoEnabled()) {
                StringBuilder sb = new StringBuilder();
                sb.append("Dropping message after TempFailure: targetId=");
                sb.append(sms.getSmsSet().getTargetId());
                sb.append(", sms=");
                sb.append(sms);
                this.logger.info(sb.toString());
            }
        } else {
            lstTempFailuredNew.add(sms);
        }
        FastList<Sms> addedMessages = mProcResult.getMessageList();
        if (addedMessages != null) {
            for (FastList.Node<Sms> n = addedMessages.head(), end = addedMessages.tail(); (n = n.getNext()) != end; ) {
                Sms smst = n.getValue();
                TargetAddress ta = new TargetAddress(smst.getSmsSet().getDestAddrTon(), smst.getSmsSet().getDestAddrNpi(), smst.getSmsSet().getDestAddr(), smst.getSmsSet().getNetworkId());
                this.sendNewGeneratedMessage(smst, ta);
                if (this.logger.isInfoEnabled()) {
                    StringBuilder sb = new StringBuilder();
                    sb.append("Posting of a new message after TempFailure: targetId=");
                    sb.append(smst.getSmsSet().getTargetId());
                    sb.append(", sms=");
                    sb.append(smst);
                    this.logger.info(sb.toString());
                }
            }
        }
    }
    // PostDeliveryProcessor - failure case
    for (Sms sms : lstPermFailured) {
        MProcResult mProcResult = MProcManagement.getInstance().applyMProcDelivery(itsMProcRa, sms, true, processingType);
        if (mProcResult.isMessageIsRerouted()) {
            if (sms.getReroutingCount() >= MAX_POSSIBLE_REROUTING) {
                StringBuilder sb = new StringBuilder();
                sb.append("Rerouting message attempt after PermFailure, but we have already rerouted ");
                sb.append(MAX_POSSIBLE_REROUTING);
                sb.append(" times before: targetId=");
                sb.append(sms.getSmsSet().getTargetId());
                sb.append(", newNetworkId=");
                sb.append(mProcResult.getNewNetworkId());
                sb.append(", sms=");
                sb.append(sms);
                this.logger.warning(sb.toString());
                lstPermFailuredNew.add(sms);
            } else if (mProcResult.getNewNetworkId() == sms.getSmsSet().getNetworkId()) {
                // we do not reroute for the same networkId
                lstPermFailuredNew.add(sms);
            } else {
                lstRerouted.add(sms);
                lstNewNetworkId.add(mProcResult.getNewNetworkId());
                if (this.logger.isInfoEnabled()) {
                    StringBuilder sb = new StringBuilder();
                    sb.append("Rerouting message after PermFailure: targetId=");
                    sb.append(sms.getSmsSet().getTargetId());
                    sb.append(", newNetworkId=");
                    sb.append(mProcResult.getNewNetworkId());
                    sb.append(", sms=");
                    sb.append(sms);
                    this.logger.info(sb.toString());
                }
            }
        } else {
            lstPermFailuredNew.add(sms);
        }
        FastList<Sms> addedMessages = mProcResult.getMessageList();
        if (addedMessages != null) {
            for (FastList.Node<Sms> n = addedMessages.head(), end = addedMessages.tail(); (n = n.getNext()) != end; ) {
                Sms smst = n.getValue();
                TargetAddress ta = new TargetAddress(smst.getSmsSet().getDestAddrTon(), smst.getSmsSet().getDestAddrNpi(), smst.getSmsSet().getDestAddr(), smst.getSmsSet().getNetworkId());
                this.sendNewGeneratedMessage(smst, ta);
                if (this.logger.isInfoEnabled()) {
                    StringBuilder sb = new StringBuilder();
                    sb.append("Posting of a new message after PermFailure: targetId=");
                    sb.append(smst.getSmsSet().getTargetId());
                    sb.append(", sms=");
                    sb.append(smst);
                    this.logger.info(sb.toString());
                }
            }
        }
    }
}
Also used : MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) Sms(org.mobicents.smsc.library.Sms) FastList(javolution.util.FastList) TargetAddress(org.mobicents.smsc.library.TargetAddress)

Example 10 with FastList

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

the class DeliveryCommonSbb method applyMprocRulesOnSuccess.

// *********
// applying of mproc rules
/**
 * mproc rules applying for delivery phase for success case
 *
 * @param sms
 * @param processingType
 */
protected void applyMprocRulesOnSuccess(Sms sms, ProcessingType processingType) {
    // PostDeliveryProcessor - success case
    MProcResult mProcResult = MProcManagement.getInstance().applyMProcDelivery(itsMProcRa, sms, false, processingType);
    FastList<Sms> addedMessages = mProcResult.getMessageList();
    if (addedMessages != null) {
        for (FastList.Node<Sms> n = addedMessages.head(), end = addedMessages.tail(); (n = n.getNext()) != end; ) {
            Sms smst = n.getValue();
            TargetAddress ta = new TargetAddress(smst.getSmsSet().getDestAddrTon(), smst.getSmsSet().getDestAddrNpi(), smst.getSmsSet().getDestAddr(), smst.getSmsSet().getNetworkId());
            this.sendNewGeneratedMessage(smst, ta);
            if (this.logger.isInfoEnabled()) {
                StringBuilder sb = new StringBuilder();
                sb.append("Posting of a new message after DeliverySuccess: targetId=");
                sb.append(smst.getSmsSet().getTargetId());
                sb.append(", sms=");
                sb.append(smst);
                this.logger.info(sb.toString());
            }
        }
    }
}
Also used : MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) Sms(org.mobicents.smsc.library.Sms) FastList(javolution.util.FastList) TargetAddress(org.mobicents.smsc.library.TargetAddress)

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