FRODO Version 2.19.1
An open-source framework for Distributed Constraint Optimization (DCOP)
Loading...
Searching...
No Matches
frodo2.communication.mailer.CentralMailer Class Reference

Centralized mail man that enforces that only one agent is awake at a time, which is useful to measure distributed runtime. More...

Inheritance diagram for frodo2.communication.mailer.CentralMailer:

Classes

class  FakeQueue
 The queue associated with a specific agent. More...
class  TimestampComparator
 A comparator used in the PriorityQueue to order messages according to their timestamps. More...
class  DelayGenerator
 Abstract class that defines the functions needed in a delay generator. More...
class  NegativeExponentialDistribution
 This class is used to generate message delay according to the negative exponential distribution. More...

Public Member Functions

 CentralMailer (boolean measureMsgs, boolean useDelayGenerator, Element parameters)
 Constructor.
 CentralMailer (ProblemInterface<?, ?> problem, Element agentConfig)
 Constructor.
void start ()
boolean execute ()
 Executes the algorithm.
boolean execute (long timeout)
 Executes the algorithm.
void run ()
 Waits for a message to be available and then delivers it.
void end ()
 Kills the CentralMailer.
Queue newQueue (String agent)
 Creates a new queue for the given agent.
Queue newQueue (String agent, boolean updateTime)
 Creates a new queue for the given agent.

Static Public Attributes

static final MessageType ERROR_MSG = MessageType.SYSTEM.newChild("CentralMailer", "CentralMailerError")
 Type of messages sent when an exception occurs.
static final MessageType OutOfMemMsg = MessageType.SYSTEM.newChild("CentralMailer", "OutOfMem")
 Type of out of memory message.

Protected Member Functions

boolean checkTimestamp (long time)
 Checks that the input time is higher than the last timestamp.

Protected Attributes

HashMap< String, FakeQueuequeues
 Each agent's queue.
PriorityQueue< MessageWrapperorderedQueue
 The ordered repository of messages.
long lastTimeStamp = Long.MIN_VALUE
 The time stamp of the last message that has been released.
LinkedList< MessageWrapperoutbox = new LinkedList<MessageWrapper> ()
 Buffer of messages waiting to be put into the priority queue.
final DelayGenerator delayGenerator
 Used to generate random delays.
final boolean measuringMsgs
 Whether to measure the number of messages and the total amount of information sent.
ReentrantLock lock = new ReentrantLock()
 The lock used for synchronization.
Condition msgReady = this.lock.newCondition()
 The condition on which the timed thread awaits to deliver a message.
Condition msgDone = this.lock.newCondition()
 The condition on which execute() awaits to proceed to the next message.
FakeQueue currentQueue
 The currently active queue.
volatile MessageWrapper currentMsg
 The message delivered to the currently active Queue.
boolean stop = true
 Flag used to tell the CentralMailer that it should terminate.
boolean idleMsgsSent = false
 Whether the agents have already been notified that they are all idle.

Private Attributes

HashMap< MessageType, Collection< IncomingMsgPolicyInterface< MessageType > > > eavesdroppersIn
 The eavesdroppers for incoming messages, per message type.
HashMap< MessageType, Collection< OutgoingMsgPolicyInterface< MessageType > > > eavesdroppersOut
 The eavesdroppers for outgoing messages.

Detailed Description

Centralized mail man that enforces that only one agent is awake at a time, which is useful to measure distributed runtime.

Author
Thomas Leaute

Constructor & Destructor Documentation

◆ CentralMailer() [1/2]

frodo2.communication.mailer.CentralMailer.CentralMailer ( boolean measureMsgs,
boolean useDelayGenerator,
Element parameters )

Constructor.

Parameters
measureMsgswhether to measure the number and sizes of messages
useDelayGeneratortrue when the DelayGenerator is to be used
parametersparameters of the CentralMailer (not used in this implementation)

References delayGenerator, orderedQueue, and frodo2.communication.MessageType.ROOT.

◆ CentralMailer() [2/2]

frodo2.communication.mailer.CentralMailer.CentralMailer ( ProblemInterface<?, ?> problem,
Element agentConfig )

Constructor.

Parameters
problemthe problem instance
agentConfigthe agent configuration

References frodo2.algorithms.Eavesdroppable< T >.getEavesdropper(), frodo2.communication.MessageListener< T >.getMsgTypes(), and frodo2.communication.MessageType.ROOT.

Here is the call graph for this function:

Member Function Documentation

◆ checkTimestamp()

boolean frodo2.communication.mailer.CentralMailer.checkTimestamp ( long time)
protected

Checks that the input time is higher than the last timestamp.

Parameters
timeinput time
Returns
true iff the test passed

Referenced by run().

◆ end()

void frodo2.communication.mailer.CentralMailer.end ( )

Kills the CentralMailer.

References lock, and stop.

◆ execute() [1/2]

boolean frodo2.communication.mailer.CentralMailer.execute ( )

Executes the algorithm.

Returns
true if the algorithm correctly terminated; false if it timed out

References frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.DEFAULT_TIMEOUT, and execute().

Referenced by execute(), frodo2.communication.mailer.tests.testCentralMailer.testNext(), frodo2.algorithms.adopt.test.ADOPTagentTest< V extends Addable< V >, U extends Addable< U > >.testRandom(), frodo2.algorithms.asodpop.tests.ASODPOPagentTest< V extends Addable< V >, U extends Addable< U > >.testRandom(), frodo2.algorithms.asodpop.tests.ASODPOPBinaryAgentTest< V extends Addable< V >, U extends Addable< U > >.testRandom(), frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.testRandom(), frodo2.algorithms.duct.tests.DUCTagentTest.testRandom(), frodo2.algorithms.localSearch.dsa.tests.DSAagentTest< V extends Addable< V >, U extends Addable< U > >.testRandom(), frodo2.algorithms.localSearch.mgm.mgm2.tests.MGM2agentTest< V extends Addable< V >, U extends Addable< U > >.testRandom(), frodo2.algorithms.localSearch.mgm.tests.MGMagentTest< V extends Addable< V >, U extends Addable< U > >.testRandom(), frodo2.algorithms.odpop.tests.ODPOPagentTest< V extends Addable< V >, U extends Addable< U > >.testRandom(), frodo2.algorithms.odpop.tests.ODPOPagentTestBinaryDomains< V extends Addable< V >, U extends Addable< U > >.testRandom(), frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.testRandom(), and frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.waitForEnd().

Here is the call graph for this function:

◆ execute() [2/2]

◆ newQueue() [1/2]

Queue frodo2.communication.mailer.CentralMailer.newQueue ( String agent)

Creates a new queue for the given agent.

Parameters
agentagent name
Returns
a queue

References newQueue().

Referenced by newQueue().

Here is the call graph for this function:

◆ newQueue() [2/2]

Queue frodo2.communication.mailer.CentralMailer.newQueue ( String agent,
boolean updateTime )

Creates a new queue for the given agent.

Parameters
agentagent name
updateTimeIf false, this queue's time will always remain frozen at its initial value
Returns
a queue

References frodo2.controller.Controller.CONTROLLER, frodo2.daemon.Daemon.DAEMON, and frodo2.algorithms.AgentInterface< V extends Addable< V > >.STATS_MONITOR.

◆ run()

◆ start()

void frodo2.communication.mailer.CentralMailer.start ( )
See also
java.lang.Thread#start()

Referenced by execute().

Member Data Documentation

◆ currentMsg

volatile MessageWrapper frodo2.communication.mailer.CentralMailer.currentMsg
protected

The message delivered to the currently active Queue.

◆ currentQueue

FakeQueue frodo2.communication.mailer.CentralMailer.currentQueue
protected

The currently active queue.

◆ delayGenerator

final DelayGenerator frodo2.communication.mailer.CentralMailer.delayGenerator
protected

Used to generate random delays.

Todo
Add message delays toXML configuration files.

Referenced by CentralMailer().

◆ eavesdroppersIn

HashMap< MessageType, Collection< IncomingMsgPolicyInterface<MessageType> > > frodo2.communication.mailer.CentralMailer.eavesdroppersIn
private
Initial value:
=
new HashMap< MessageType, Collection< IncomingMsgPolicyInterface<MessageType> > > ()

The eavesdroppers for incoming messages, per message type.

◆ eavesdroppersOut

HashMap< MessageType, Collection< OutgoingMsgPolicyInterface<MessageType> > > frodo2.communication.mailer.CentralMailer.eavesdroppersOut
private
Initial value:
=
new HashMap< MessageType, Collection< OutgoingMsgPolicyInterface<MessageType> > > ()

The eavesdroppers for outgoing messages.

◆ ERROR_MSG

final MessageType frodo2.communication.mailer.CentralMailer.ERROR_MSG = MessageType.SYSTEM.newChild("CentralMailer", "CentralMailerError")
static

Type of messages sent when an exception occurs.

Referenced by execute(), frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.getMsgTypes(), and run().

◆ idleMsgsSent

boolean frodo2.communication.mailer.CentralMailer.idleMsgsSent = false
protected

Whether the agents have already been notified that they are all idle.

◆ lastTimeStamp

long frodo2.communication.mailer.CentralMailer.lastTimeStamp = Long.MIN_VALUE
protected

The time stamp of the last message that has been released.

Referenced by execute().

◆ lock

ReentrantLock frodo2.communication.mailer.CentralMailer.lock = new ReentrantLock()
protected

The lock used for synchronization.

Referenced by end(), and run().

◆ measuringMsgs

final boolean frodo2.communication.mailer.CentralMailer.measuringMsgs
protected

Whether to measure the number of messages and the total amount of information sent.

Referenced by frodo2.communication.mailer.CentralMailer.FakeQueue.FakeQueue().

◆ msgDone

Condition frodo2.communication.mailer.CentralMailer.msgDone = this.lock.newCondition()
protected

The condition on which execute() awaits to proceed to the next message.

◆ msgReady

Condition frodo2.communication.mailer.CentralMailer.msgReady = this.lock.newCondition()
protected

The condition on which the timed thread awaits to deliver a message.

◆ orderedQueue

PriorityQueue<MessageWrapper> frodo2.communication.mailer.CentralMailer.orderedQueue
protected

◆ outbox

LinkedList<MessageWrapper> frodo2.communication.mailer.CentralMailer.outbox = new LinkedList<MessageWrapper> ()
protected

◆ OutOfMemMsg

final MessageType frodo2.communication.mailer.CentralMailer.OutOfMemMsg = MessageType.SYSTEM.newChild("CentralMailer", "OutOfMem")
static

◆ queues

HashMap<String, FakeQueue> frodo2.communication.mailer.CentralMailer.queues
protected

◆ stop

boolean frodo2.communication.mailer.CentralMailer.stop = true
protected

Flag used to tell the CentralMailer that it should terminate.

Referenced by end(), and execute().


The documentation for this class was generated from the following file: