SmsSetCache { public TargetAddress addSmsSet(TargetAddress ta) { synchronized (lstSmsSetUnderAtomicOper) { TargetAddressContainer cont = lstSmsSetUnderAtomicOper.get(ta); if (cont != null) { cont.count++; return cont.targetAddress; } else { cont = new TargetAddressContainer(); lstSmsSetUnderAtomicOper.put(ta, cont); cont.count = 1; cont.targetAddress = ta; return ta; } } } private  SmsSetCache(); static SmsSetCache getInstance(); static void start(int correlationIdLiveTime, int sriResponseLiveTime, int deliveredMsgLiveTime); static void stop(); void setUpdateMessagesInProcessListener(UpdateMessagesInProcessListener smscStatAggregator); TargetAddress addSmsSet(TargetAddress ta); void removeSmsSet(TargetAddress ta); void incrementActivityCount(); void decrementActivityCount(); int getActivityCount(); SmsSet getProcessingSmsSet(String targetId); SmsSet addProcessingSmsSet(String targetId, SmsSet smsSet, int processingSmsSetTimeout); void registerSmsSetWithBigMessageCount(String targetId, SmsSet smsSet); SmsSet removeProcessingSmsSet(String targetId); int getProcessingSmsSetSize(); String getLstSmsSetWithBigMessageCountState(); void garbadeCollectProcessingSmsSet(); void clearProcessingSmsSet(); void putCorrelationIdCacheElement(CorrelationIdValue elem, int correlationIdLiveTime); CorrelationIdValue getCorrelationIdCacheElement(String correlationID); void putSriResponseValue(SriResponseValue elem, int sriResponseLiveTime); SriResponseValue getSriResponseValue(String targetID); void putDeliveredMsgValue(Sms sms, int deliveredMsgLiveTime); Sms getDeliveredMsgValue(Long messageId); static String generateRemoteMsgIdKey(String remoteMessageId, String destId); void putDeliveredRemoteMsgIdValue(String remoteMessageId, String destId, Long messageId, int deliveredMsgLiveTime); Long getDeliveredRemoteMsgIdValue(String remoteMessageId, String destId); void incrementStoredMessagesCounter(long date); void incrementSentMessagesCounter(long date); long getMessagesStoredInDatabase(); long getMessagesSentInDatabase(); void loadMessagesCountersFromDatabase(ConcurrentHashMap<Long, AtomicLong> storedMessages, 
            ConcurrentHashMap<Long, AtomicLong> sentMessages); static int SMSSET_MSG_PRO_SEGMENT_LIMIT; static int SMSSET_FREE_SEGMENT_CNT; }
@Test(groups = { "SmsSet" }) public void testAddSmsSet() throws Exception { DBOperations_C2_Proxy db = new DBOperations_C2_Proxy(); SmsSet smsSet1 = createEmptySmsSet(ta1); SmsSet smsSet2 = createEmptySmsSet(ta1); SmsSet smsSet3 = createEmptySmsSet(ta2); SmsDef sd1 = new SmsDef(); Sms sms1 = this.prepareSms(smsSet1, 1, sd1); smsSet1.addSms(sms1); Sms sms2 = this.prepareSms(smsSet2, 2, sd1); smsSet2.addSms(sms2); Sms sms3 = this.prepareSms(smsSet3, 3, sd1); smsSet3.addSms(sms3); assertEquals(smsSet1.getSmsCount(), 1); assertEquals(smsSet2.getSmsCount(), 1); assertEquals(smsSet3.getSmsCount(), 1); ArrayList<SmsSet> sourceLst1 = new ArrayList<SmsSet>(); sourceLst1.add(smsSet1); ArrayList<SmsSet> sourceLst2 = new ArrayList<SmsSet>(); sourceLst2.add(smsSet2); ArrayList<SmsSet> sourceLst3 = new ArrayList<SmsSet>(); sourceLst3.add(smsSet3); ArrayList<SmsSet> res1 = db.c2_sortRecordList(sourceLst1); ArrayList<SmsSet> res2 = db.c2_sortRecordList(sourceLst2); ArrayList<SmsSet> res3 = db.c2_sortRecordList(sourceLst3); assertEquals(smsSet1.getSmsCount(), 2); assertEquals(smsSet2.getSmsCount(), 1); assertEquals(smsSet3.getSmsCount(), 1); assertEquals(res1.size(), 1); assertEquals(res2.size(), 0); assertEquals(res3.size(), 1); SmsSetCache.getInstance().clearProcessingSmsSet(); }