Magentix2  2.1.1
es.upv.dsic.gti_ia.cAgents.PendingQueueRepository Class Reference

List of all members.

Public Member Functions

 PendingQueueRepository (long deltaToExpire, long intervalToClean)
void addMessage (ACLMessage msg)
ArrayList< QueueWithTimestamppopQueues (MessageFilter template)
Queue< ACLMessagepopQueue (String cid)
synchronized void cleanRepository (long delta)
synchronized HashMap< String,
QueueWithTimestamp
getQueueMap ()
long getDeltaToExpire ()
void setDeltaToExpire (long deltaToExpire)
long getIntervalToClean ()
void setIntervalToClean (long intervalToClean)

Detailed Description

Definition at line 11 of file PendingQueueRepository.java.


Constructor & Destructor Documentation

es.upv.dsic.gti_ia.cAgents.PendingQueueRepository.PendingQueueRepository ( long  deltaToExpire,
long  intervalToClean 
)

Definition at line 18 of file PendingQueueRepository.java.

                                                                                {
                this.deltaToExpire = deltaToExpire;
                this.intervalToClean = intervalToClean;
                queueMap = new HashMap<String, QueueWithTimestamp>();
                referenceDate = new Date();
        }

Member Function Documentation

Definition at line 25 of file PendingQueueRepository.java.

                                               {
                if (!hasQueueWithCid(msg)) {
                        queueMap.put(msg.getConversationId(), new QueueWithTimestamp());
                        queueMap.get(msg.getConversationId()).addMessage(msg);
                } else {
                        queueMap.get(msg.getConversationId()).addMessage(msg);
                }
                if(new Date().getTime()- referenceDate.getTime() > intervalToClean){
                        cleanRepository(getDeltaToExpire());
                        referenceDate = new Date();
                }
        }

Definition at line 78 of file PendingQueueRepository.java.

                                                             {
                ArrayList<String> cidsToClean = new ArrayList<String>();
                for (String cId : queueMap.keySet()) {
                        if (!queueMap.get(cId).checkTimestamp(delta)) {
                                cidsToClean.add(cId);
                        }
                }
                if (!cidsToClean.isEmpty()) {
                        for (String cid : cidsToClean) {
                                queueMap.remove(cid);
                        }
                }
        }

Definition at line 96 of file PendingQueueRepository.java.

                                       {
                return deltaToExpire;
        }

Definition at line 104 of file PendingQueueRepository.java.

                                         {
                return intervalToClean;
        }

Definition at line 92 of file PendingQueueRepository.java.

                                                                              {
                return queueMap;
        }

Definition at line 70 of file PendingQueueRepository.java.

                                                      {
                if (hasQueueWithCid(cid)) {
                        return getQueueMap().get(cid).getQueue();
                } else {
                        return null;
                }
        }

Definition at line 57 of file PendingQueueRepository.java.

                                                                               {
                ArrayList<QueueWithTimestamp> queuesWithTimestamp = new ArrayList<QueueWithTimestamp>(
                                queueMap.values());
                ArrayList<QueueWithTimestamp> matchingQueues = new ArrayList<QueueWithTimestamp>();

                for (QueueWithTimestamp theQueue : queuesWithTimestamp) {
                        if (template == null || template.compareHeaders(theQueue.getQueue().peek())) {
                                matchingQueues.add(theQueue);
                        }
                }
                return matchingQueues;
        }

Definition at line 100 of file PendingQueueRepository.java.

                                                         {
                this.deltaToExpire = deltaToExpire;
        }

Definition at line 108 of file PendingQueueRepository.java.

                                                             {
                this.intervalToClean = intervalToClean;
        }

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables