Search in sources :

Example 1 with FastMap

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

the class DBOperations method c2_getLiveTableList.

public Date[] c2_getLiveTableList(String keyspace) {
    String[] ss = this.c2_getTableList(keyspace);
    FastMap<Date, Date> res = new FastMap<Date, Date>();
    for (String s : ss) {
        Date dt = null;
        // if (s.startsWith("DST_SLOT_TABLE_") && s.length() == 25) {
        if (s.startsWith(Schema.FAMILY_DST_SLOT_TABLE) && s.length() == 25) {
            String sYear = s.substring(15, 19);
            String sMon = s.substring(20, 22);
            String sDay = s.substring(23, 25);
            try {
                int year = Integer.parseInt(sYear);
                int mon = Integer.parseInt(sMon);
                int day = Integer.parseInt(sDay);
                dt = new Date(year - 1900, mon - 1, day);
            } catch (Exception e) {
            }
        }
        // if (s.startsWith("SLOT_MESSAGES_TABLE_") && s.length() == 30) {
        if (s.startsWith(Schema.FAMILY_SLOT_MESSAGES_TABLE) && s.length() == 30) {
            String sYear = s.substring(20, 24);
            String sMon = s.substring(25, 27);
            String sDay = s.substring(28, 30);
            try {
                int year = Integer.parseInt(sYear);
                int mon = Integer.parseInt(sMon);
                int day = Integer.parseInt(sDay);
                dt = new Date(year - 1900, mon - 1, day);
            } catch (Exception e) {
            }
        }
        if (dt != null) {
            res.put(dt, dt);
        }
    }
    Date[] dd = new Date[res.size()];
    int i1 = 0;
    for (Date dt : res.keySet()) {
        dd[i1++] = dt;
    }
    Arrays.sort(dd);
    return dd;
}
Also used : FastMap(javolution.util.FastMap) Date(java.util.Date) XMLStreamException(javolution.xml.stream.XMLStreamException) InvalidQueryException(com.datastax.driver.core.exceptions.InvalidQueryException)

Example 2 with FastMap

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

the class DBOperations method c2_sortRecordList.

public ArrayList<SmsSet> c2_sortRecordList(ArrayList<SmsSet> sourceLst) {
    FastMap<String, SmsSet> res = new FastMap<String, SmsSet>();
    // aggregating messages for one targetId
    for (SmsSet smsSet : sourceLst) {
        SmsSet smsSet2 = null;
        try {
            smsSet2 = res.get(smsSet.getTargetId());
        } catch (Throwable e) {
            int dd = 0;
        }
        if (smsSet2 != null) {
            smsSet2.addSms(smsSet.getSms(0));
            if (smsSet2.getCorrelationId() == null) {
                // filling correcationId if not all SmsSet are filled
                smsSet2.setCorrelationId(smsSet.getCorrelationId());
            }
        } else {
            res.put(smsSet.getTargetId(), smsSet);
        }
    }
    // adding into SmsSetCashe
    ArrayList<SmsSet> res2 = new ArrayList<SmsSet>();
    // 60 min timeout
    Date timeOutDate = new Date(new Date().getTime() - 1000 * 60 * 30);
    for (SmsSet smsSet : res.values()) {
        smsSet.resortSms();
        TargetAddress lock = SmsSetCache.getInstance().addSmsSet(new TargetAddress(smsSet));
        try {
            SmsSet smsSet2;
            synchronized (lock) {
                smsSet2 = SmsSetCache.getInstance().getProcessingSmsSet(smsSet.getTargetId());
                if (smsSet2 != null) {
                    if (smsSet2.getLastUpdateTime().after(timeOutDate)) {
                        smsSet2.addSmsSet(smsSet);
                    // for (int i1 = 0; i1 < smsSet.getSmsCount(); i1++) {
                    // Sms smsx = smsSet.getSms(i1);
                    // if (!smsSet2.checkSmsPresent(smsx)) {
                    // smsSet2.addSmsSet(smsx);
                    // }
                    // }
                    } else {
                        logger.warn("Timeout of SmsSet in ProcessingSmsSet: targetId=" + smsSet2.getTargetId() + ", messageCount=" + smsSet2.getSmsCount());
                        smsSet2 = smsSet;
                        SmsSetCache.getInstance().addProcessingSmsSet(smsSet2.getTargetId(), smsSet2, processingSmsSetTimeout);
                    }
                } else {
                    smsSet2 = smsSet;
                    SmsSetCache.getInstance().addProcessingSmsSet(smsSet2.getTargetId(), smsSet2, processingSmsSetTimeout);
                }
            }
            res2.add(smsSet2);
        } finally {
            SmsSetCache.getInstance().removeSmsSet(lock);
        }
    }
    return res2;
}
Also used : FastMap(javolution.util.FastMap) ArrayList(java.util.ArrayList) TargetAddress(org.mobicents.smsc.library.TargetAddress) SmsSet(org.mobicents.smsc.library.SmsSet) Date(java.util.Date)

Example 3 with FastMap

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

the class SMSCShellExecutor method getMapVersionCache.

/**
 * smsc mapcache get <msisdn>
 *
 * msisdn is optional
 *
 * @param args
 * @return
 */
private String getMapVersionCache(String[] args) throws Exception {
    if (args.length < 3 || args.length > 4) {
        return SMSCOAMMessages.INVALID_COMMAND;
    }
    if (args.length == 4) {
        String msisdn = args[3];
        MAPApplicationContextVersion mapApplicationContextVersion = mapVersionCache.getMAPApplicationContextVersion(msisdn);
        if (mapApplicationContextVersion != null) {
            return mapApplicationContextVersion.toString();
        } else {
            return SMSCOAMMessages.MAP_VERSION_CACHE_NOT_FOUND;
        }
    }
    FastMap<String, MapVersionNeg> cache = mapVersionCache.getMAPApplicationContextVersionCache();
    if (cache.size() == 0) {
        return SMSCOAMMessages.MAP_VERSION_CACHE_NOT_FOUND;
    }
    StringBuffer sb = new StringBuffer();
    for (FastMap.Entry<String, MapVersionNeg> e = cache.head(), end = cache.tail(); (e = e.getNext()) != end; ) {
        sb.append(e.getKey()).append(MAP_CACHE_KEY_VALUE_SEPARATOR).append(e.getValue().getCurVersion()).append(LINE_SEPARATOR);
    }
    return sb.toString();
}
Also used : FastMap(javolution.util.FastMap) MAPApplicationContextVersion(org.mobicents.protocols.ss7.map.api.MAPApplicationContextVersion)

Example 4 with FastMap

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

the class SmscStatProviderJmx method setupCounterList.

private void setupCounterList() {
    FastMap<String, CounterDefSet> lst = new FastMap<String, CounterDefSet>();
    CounterDefSetImpl cds = new CounterDefSetImpl(this.getCounterMediatorName() + "-Main");
    lst.put(cds.getName(), cds);
    CounterDef cd = new CounterDefImpl(CounterType.Minimal, "MinMessagesInProcess", "A min count of messages that are in progress during a period");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Maximal, "MaxMessagesInProcess", "A max count of messages that are in progress during a period");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "MsgInReceivedAll", "Messages received and accepted via all interfaces");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "MsgInRejectedAll", "Messages received and rejected because of charging reject via all interfaces");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "MsgInFailedAll", "Messages received and failed to process via all interfaces");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "MsgInReceivedSs7", "Messages received and accepted via SS7 interface");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "MsgInReceivedSs7Mo", "Messages received and accepted via SS7 interface (mobile originated)");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "MsgInReceivedSs7Hr", "Messages received and accepted via SS7 interface (home routing)");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "HomeRoutingCorrIdFail", "Home routing failures because of absent correlationId");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "SmppSecondRateOverlimitFail", "Rejecting of incoming SMPP messages case because of exceeding of a rate limit per a second");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "SmppMinuteRateOverlimitFail", "Rejecting of incoming SMPP messages case because of exceeding of a rate limit per a minute");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "SmppHourRateOverlimitFail", "Rejecting of incoming SMPP messages case because of exceeding of a rate limit per a hour");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "SmppDayRateOverlimitFail", "Rejecting of incoming SMPP messages case because of exceeding of a rate limit per a day");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "MsgInReceivedSmpp", "Messages received and accepted via SMPP interface");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "MsgInReceivedSip", "Messages received and accepted via SIP interface");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary_Cumulative, "MsgInReceivedAllCumulative", "Messages received and accepted via all interfaces cumulative");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "MsgInHrSriReq", "Home routing SRI messages received");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "MsgInHrSriPosReq", "Home routing SRI positive responses");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "MsgInHrSriHrByPass", "ByPass HomeRouting procedure after SRI to a local HLR");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "MsgInHrSriNegReq", "Home routing SRI negative responses");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "MsgOutTryAll", "Messages sending tries via all interfaces");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "MsgOutSentAll", "Messages sent via all interfaces");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary_Cumulative, "MsgOutTryAllCumulative", "Messages sending tries via all interfaces cumulative");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary_Cumulative, "MsgOutSentAllCumulative", "Messages sent via all interfaces cumulative");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "MsgOutFailedAll", "Messages failed to send via all interfaces");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Average, "MsgOutTryAllPerSec", "Messages sending tries via all interfaces per second");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Average, "MsgOutSentAllPerSec", "Messages sent via all interfaces per second");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "MsgOutTrySs7", "Messages sending tries via SS7 interface");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "MsgOutSentSs7", "Messages sent via SS7 interface");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "MsgOutTrySmpp", "Messages sending tries via SMPP interface");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "MsgOutSentSmpp", "Messages sent via SMPP interface");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "MsgOutTrySip", "Messages sending tries via SIP interface");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary, "MsgOutSentSip", "Messages sent via SIP interface");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Summary_Cumulative, "SmscDeliveringLag", "Lag of delivering messages by Smsc (in seconds)");
    cds.addCounterDef(cd);
    cd = new CounterDefImpl(CounterType.Maximal, "MsgPendingInDb", "Messages stored in database which are to be delivered yet");
    cds.addCounterDef(cd);
    lstCounters = lst;
}
Also used : CounterDefSet(org.mobicents.protocols.ss7.oam.common.statistics.api.CounterDefSet) FastMap(javolution.util.FastMap) CounterDefImpl(org.mobicents.protocols.ss7.oam.common.statistics.CounterDefImpl) CounterDefSetImpl(org.mobicents.protocols.ss7.oam.common.statistics.CounterDefSetImpl) CounterDef(org.mobicents.protocols.ss7.oam.common.statistics.api.CounterDef)

Example 5 with FastMap

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

the class CdrParser method load.

private void load(String fileName, String outName) {
    String dest = "";
    FastMap<String, ArrayList<Cdr>> al1 = new FastMap<String, ArrayList<Cdr>>();
    TreeMap<String, Cdr> sl2 = new TreeMap<String, Cdr>();
    try (BufferedReader fileOut = new BufferedReader(new InputStreamReader(new FileInputStream(fileName)))) {
        for (String line; (line = fileOut.readLine()) != null; ) {
            String[] ss = line.split(",");
            if (ss.length >= 10) {
                Cdr cdr = new Cdr();
                cdr.a_from = ss[3];
                cdr.a_to = ss[6];
                cdr.cause = ss[9];
                cdr.date = ss[0];
                cdr.esme = ss[10];
                if (ss.length >= 17)
                    cdr.reason = ss[16];
                if (cdr.cause.equals("failed") || cdr.cause.equals("success") || cdr.cause.equals("partial")) {
                    String from_to = cdr.a_from + "_" + cdr.a_to;
                    ArrayList<Cdr> al = al1.get(from_to);
                    if (al == null) {
                        al = new ArrayList<Cdr>();
                        al1.put(from_to, al);
                    }
                    al.add(cdr);
                } else if (cdr.cause.equals("success_esme")) {
                    String from_to = cdr.a_to + "_" + cdr.a_from;
                    ArrayList<Cdr> al = al1.get(from_to);
                    if (al != null && !al.isEmpty()) {
                        Cdr cdr2 = al.remove(0);
                        if (cdr2.a_from.startsWith(dest))
                            sl2.put(cdr2.date, cdr2);
                    } else {
                        int gg = 0;
                        gg++;
                    }
                } else if (cdr.cause.equals("temp_failed") || cdr.cause.equals("temp_failed_esme")) {
                } else {
                    int gg = 0;
                    gg++;
                }
            }
        }
        fileOut.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    ArrayList<String> toDel = new ArrayList<String>();
    for (String s : al1.keySet()) {
        ArrayList<Cdr> al = al1.get(s);
        if (al.isEmpty())
            toDel.add(s);
    }
    for (String s : toDel) {
        al1.remove(s);
    }
    try {
        BufferedWriter fileOut = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outName)));
        TreeMap<String, Cdr> sl = new TreeMap<String, Cdr>();
        for (String s : al1.keySet()) {
            ArrayList<Cdr> al = al1.get(s);
            for (Cdr cdr : al) {
                if (cdr.a_from.startsWith(dest)) {
                    sl.put(cdr.date, cdr);
                }
            }
        }
        for (Cdr cdr : sl.values()) {
            fileOut.write(cdr.toString());
            fileOut.newLine();
        }
        fileOut.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        BufferedWriter fileOut = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outName + "2")));
        for (Cdr cdr : sl2.values()) {
            fileOut.write(cdr.toString());
            fileOut.newLine();
        }
        fileOut.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    int gg = 0;
    gg++;
}
Also used : FastMap(javolution.util.FastMap) InputStreamReader(java.io.InputStreamReader) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) FileInputStream(java.io.FileInputStream) BufferedWriter(java.io.BufferedWriter) FileOutputStream(java.io.FileOutputStream) BufferedReader(java.io.BufferedReader) OutputStreamWriter(java.io.OutputStreamWriter)

Aggregations

FastMap (javolution.util.FastMap)6 Date (java.util.Date)3 InvalidQueryException (com.datastax.driver.core.exceptions.InvalidQueryException)2 ArrayList (java.util.ArrayList)2 XMLStreamException (javolution.xml.stream.XMLStreamException)2 BufferedReader (java.io.BufferedReader)1 BufferedWriter (java.io.BufferedWriter)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStreamReader (java.io.InputStreamReader)1 OutputStreamWriter (java.io.OutputStreamWriter)1 TreeMap (java.util.TreeMap)1 MAPApplicationContextVersion (org.mobicents.protocols.ss7.map.api.MAPApplicationContextVersion)1 CounterDefImpl (org.mobicents.protocols.ss7.oam.common.statistics.CounterDefImpl)1 CounterDefSetImpl (org.mobicents.protocols.ss7.oam.common.statistics.CounterDefSetImpl)1 CounterDef (org.mobicents.protocols.ss7.oam.common.statistics.api.CounterDef)1 CounterDefSet (org.mobicents.protocols.ss7.oam.common.statistics.api.CounterDefSet)1 SmsSet (org.mobicents.smsc.library.SmsSet)1 TargetAddress (org.mobicents.smsc.library.TargetAddress)1