public boolean c2_checkProcessingSmsSet(SmsSet smsSet) { Date timeOutDate = new Date(new Date().getTime() - 1000 * 60 * 30); TargetAddress lock = SmsSetCache.getInstance().addSmsSet(new TargetAddress(smsSet)); try { synchronized (lock) { SmsSet smsSet2 = SmsSetCache.getInstance().getProcessingSmsSet(smsSet.getTargetId()); if (smsSet2 != null) { if (smsSet2.getLastUpdateTime().after(timeOutDate)) { logger.warn("Timeout of SmsSet in ProcessingSmsSet: targetId=" + smsSet2.getTargetId() + ", messageCount=" + smsSet2.getSmsCount()); smsSet2 = smsSet; SmsSetCache.getInstance().addProcessingSmsSet(smsSet2.getTargetId(), smsSet2, processingSmsSetTimeout); SmsSetCache.getInstance().addProcessingSmsSet(smsSet2.getTargetId(), smsSet2, processingSmsSetTimeout); SmsSetCache.getInstance().removeSmsSet(lock);
public int getMessageInProcess() { return smsSetCashe.getProcessingSmsSetSize(); }
@Override public void releaseSynchroObject(TargetAddress ta) { SmsSetCache.getInstance().removeSmsSet(ta); }
@Override public TargetAddress obtainSynchroObject(TargetAddress ta) { return SmsSetCache.getInstance().addSmsSet(ta); }
public SmscStatAggregator() { SmsSetCache.getInstance().setUpdateMessagesInProcessListener(this); }
if (garbageCollectionTime.before(current)) { garbageCollectionTime = new Date(); SmsSetCache.getInstance().garbadeCollectProcessingSmsSet(); int maxCnt; int fetchMaxRows = smscPropertiesManagement.getFetchMaxRows(); int activityCount = SmsSetCache.getInstance().getProcessingSmsSetSize(); int fetchAvailRows = smscPropertiesManagement.getMaxActivityCount() - activityCount; maxCnt = Math.min(fetchMaxRows, fetchAvailRows);
SmsSetCache.getInstance().clearProcessingSmsSet(); SmsSetCache.start(this.smscPropertiesManagement.getCorrelationIdLiveTime(), this.smscPropertiesManagement.getSriResponseLiveTime(), 30); ConcurrentHashMap<Long, AtomicLong> storedMessages = DBOperations.getInstance().c2_getStoredMessagesCounter(date); ConcurrentHashMap<Long, AtomicLong> sentMessages = DBOperations.getInstance().c2_getSentMessagesCounter(date); SmsSetCache.getInstance().loadMessagesCountersFromDatabase(storedMessages, sentMessages);
@Override public void raInactive() { if (tracer.isInfoEnabled()) { tracer.info("Starting of inactivating SchedulerResourceAdaptor RA Entity " + this.raContext.getEntityName()); } SmscPropertiesManagement smscPropertiesManagement = SmscPropertiesManagement.getInstance(); smscPropertiesManagement.setSmscStopped(true); for (int i1 = 0; i1 < 60; i1++) { try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (SmsSetCache.getInstance().getProcessingSmsSetSize() == 0) break; } if (tracer.isInfoEnabled()) { tracer.info("Finishing of inactivating SchedulerResourceAdaptor RA Entity " + this.raContext.getEntityName()); } }
public static void stop() { SmsSetCache ssc = SmsSetCache.getInstance(); ssc.isStarted = false; ssc.executor.shutdown(); }
try { SmsSetCache.getInstance().putDeliveredMsgValue(sms, 30); try { SmsSetCache.getInstance().putDeliveredRemoteMsgIdValue(dlvMessageId, dlvDestId, sms.getMessageId(), 30);
smsSet0.setNetworkId(networkId); SmsSet smsSet1 = SmsSetCache.getInstance().getProcessingSmsSet(smsSet0.getTargetId()); if (smsSet1 != null) {
public Long c2_getMessageIdByRemoteMessageId(String remoteMessageId, String destId) throws PersistenceException { Long result = null; result = SmsSetCache.getInstance().getDeliveredRemoteMsgIdValue(remoteMessageId, destId); if (result != null) return result; try { // first step - today search Date date = new Date(); PreparedStatementCollection psc = getStatementCollection(date); result = this.doGetMessageIdByRemoteMessageId(remoteMessageId, destId, psc); if (result == null) { // second step - yesterday search Date date2 = new Date(date.getTime() - 1000 * 3600 * 24); psc = getStatementCollection(date2); result = this.doGetMessageIdByRemoteMessageId(remoteMessageId, destId, psc); } } catch (Exception e1) { String msg = "Failed c2_getMessageIdByRemoteMessageId()"; throw new PersistenceException(msg, e1); } return result; }
sb.append(smscStatProvider.getSmscStartTime()); String s1 = SmsSetCache.getInstance().getLstSmsSetWithBigMessageCountState(); if (s1 != null) { sb.append("\nLstSmsSetWithBigMessageCountState:\n");
public Sms c2_getRecordArchiveForMessageId(long messageId) throws PersistenceException { Sms sms = SmsSetCache.getInstance().getDeliveredMsgValue(messageId); if (sms != null) return sms; SmsSet result = null; try { // first step - today search Date date = new Date(); PreparedStatementCollection psc = getStatementCollection(date); result = this.doGetArchiveMsg(messageId, psc); if (result == null) { // second step - yesterday search Date date2 = new Date(date.getTime() - 1000 * 3600 * 24); psc = getStatementCollection(date2); result = this.doGetArchiveMsg(messageId, psc); } } catch (Exception e1) { String msg = "Failed getRecordArchiveForMessageId()"; throw new PersistenceException(msg, e1); } if (result != null) return result.getSms(0); else return null; }
SmsSetCache.getInstance().registerSmsSetWithBigMessageCount(this.getTargetId(), this);
boundStatement.bind(DATE_FORMAT.format(scheduledDeliveryDate)); res = session.execute(boundStatement); SmsSetCache.getInstance().incrementStoredMessagesCounter(calendar.getTimeInMillis()); } catch (Exception e1) { String msg = "Failed updateStoredMessagesCount !" + e1.getMessage();
boundStatement.bind(DATE_FORMAT.format(scheduledDeliveryDate)); ResultSet res = session.execute(boundStatement); SmsSetCache.getInstance().incrementSentMessagesCounter(calendar.getTimeInMillis()); } catch (Exception e1) { String msg = "Failed to execute updatePendingMessagesCount() !";
SmsSetCache.getInstance().putCorrelationIdCacheElement(correlationIdValue, smscPropertiesManagement.getCorrelationIdLiveTime()); } catch (Exception e1) {
public static void start(int correlationIdLiveTime, int sriResponseLiveTime, int deliveredMsgLiveTime) { SmsSetCache ssc = SmsSetCache.getInstance(); ssc.correlationIdLiveTime = correlationIdLiveTime; ssc.sriResponseLiveTime = sriResponseLiveTime; ssc.deliveredMsgLiveTime = deliveredMsgLiveTime; ssc.executor = Executors.newScheduledThreadPool(1); ssc.isStarted = true; CacheManTask t = ssc.new CacheManTask(); ssc.executor.schedule(t, correlationIdLiveTime, TimeUnit.SECONDS); CacheManTask_SRI_Resp t2 = ssc.new CacheManTask_SRI_Resp(); ssc.executor.schedule(t2, sriResponseLiveTime, TimeUnit.SECONDS); CacheManTask_Delivered_Msg t3 = ssc.new CacheManTask_Delivered_Msg(); ssc.executor.schedule(t3, deliveredMsgLiveTime, TimeUnit.SECONDS); CacheManTask_Delivered_RemoteMsgId t4 = ssc.new CacheManTask_Delivered_RemoteMsgId(); ssc.executor.schedule(t4, deliveredMsgLiveTime, TimeUnit.SECONDS); }
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)) { + ", messageCount=" + smsSet2.getSmsCount()); smsSet2 = smsSet; SmsSetCache.getInstance().addProcessingSmsSet(smsSet2.getTargetId(), smsSet2, processingSmsSetTimeout); SmsSetCache.getInstance().addProcessingSmsSet(smsSet2.getTargetId(), smsSet2, processingSmsSetTimeout); SmsSetCache.getInstance().removeSmsSet(lock);