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

This is a queue output pipe that sends messages through TCP. More...

Inheritance diagram for frodo2.communication.tcp.QueueOutputPipeTCP:

Classes

class  RawDataInfo
 A convenience class used to store information about raw data. More...
class  RawDataSender
 A thread that listens for requests to serialize or discard raw data. More...
class  RawDataServer
 The thread responsible for waiting for requests for raw data. More...

Public Member Functions

void pushMessage (MessageWrapper msgWrap)
void close ()
 Close all pipes, and tells the thread to stop.
void run ()
 Continuously checks if there are messages to be sent and sends them.
String toDOT ()

Package Functions

 QueueOutputPipeTCP (String address, int port, String rawDataIP, int rawDataPort) throws UnknownHostException, IOException
 Constructor.
 QueueOutputPipeTCP (String address, int port) throws UnknownHostException, IOException
 Constructor.

Private Member Functions

void init (ObjectOutputStream output, String address, int port, String rawDataIP, int rawDataPort)
 Initializes the output pipe.

Private Attributes

LinkedList< Messagemessages = new LinkedList <Message> ()
 List into which pushed messages should be added, until they are sent.
String rawDataIP
 IP address to which recipients should connect to request raw data.
int rawDataPort
 Port number on which the pipe should wait for requests for raw data.
boolean keepGoing = true
 Used to tell the thread to stop.
ObjectOutputStream output
 Output stream to which outgoing messages should be written.
Socket socket
 The output socket.
String name
 The name of this pipe, used only by QueueOutputPipeTCP.toDOT().
Integer rawDataID = 0
 The ID incremented each time a message with raw data is sent.
final ReentrantLock rawDataID_lock = new ReentrantLock()
 Lock for the rawDataID field.
final ReentrantLock rawDataInfos_lock = new ReentrantLock()
 Lock for the rawDataInfos field.
final ReentrantLock messages_lock = new ReentrantLock()
 Lock for the messages field.
final Condition messageReceived = messages_lock.newCondition()
 Condition used to signal that the messages list is not empty.
HashMap< Integer, RawDataInforawDataInfos = new HashMap<Integer, RawDataInfo> ()
 For each raw data ID, the information about the corresponding raw data.
RawDataServer rawDataServer
 The thread responsible for waiting for requests for raw data.
Thread myThread
 The QueueOutputPipeTCP's thread.

Static Private Attributes

static String myThreadName = "QueueOutputPipeTCP"
 The name of this QueueOutputPipeTCP's thread.

Detailed Description

This is a queue output pipe that sends messages through TCP.

Author
Thomas Leaute
Todo
Use ZIP streams to reduce information exchange?...

Constructor & Destructor Documentation

◆ QueueOutputPipeTCP() [1/2]

frodo2.communication.tcp.QueueOutputPipeTCP.QueueOutputPipeTCP ( String address,
int port,
String rawDataIP,
int rawDataPort ) throws UnknownHostException, IOException
package

Constructor.

Parameters
addressIP address of the recipient
portport number of the recipient
rawDataIPIP address to which recipients should connect to request raw data
rawDataPortport number on which the pipe should wait for requests for raw data
Exceptions
IOExceptionthrown if an I/O error occurs while setting up the connection
UnknownHostExceptionthrown if the provided address does not work

References init(), rawDataIP, and rawDataPort.

Here is the call graph for this function:

◆ QueueOutputPipeTCP() [2/2]

frodo2.communication.tcp.QueueOutputPipeTCP.QueueOutputPipeTCP ( String address,
int port ) throws UnknownHostException, IOException
package

Constructor.

Sets the raw data port to \ port + 1 and the raw data IP to "localhost."

Parameters
addressIP address of the recipient
portport number of the recipient
Exceptions
IOExceptionthrown if an I/O error occurs while setting up the connection
UnknownHostExceptionthrown if the provided address does not work

References init().

Here is the call graph for this function:

Member Function Documentation

◆ close()

void frodo2.communication.tcp.QueueOutputPipeTCP.close ( )

Close all pipes, and tells the thread to stop.

Implements frodo2.communication.QueueOutputPipeInterface.

References keepGoing, myThread, and rawDataServer.

◆ init()

void frodo2.communication.tcp.QueueOutputPipeTCP.init ( ObjectOutputStream output,
String address,
int port,
String rawDataIP,
int rawDataPort )
private

Initializes the output pipe.

Parameters
outputoutput stream to which outgoing messages should be written
addressIP address of the recipient (only used by QueueOutputPipeTCP.toDOT())
portport number of the recipient (only used by QueueOutputPipeTCP.toDOT())
rawDataIPIP address to which recipients should connect to request raw data
rawDataPortport number on which the pipe should wait for requests for raw data

References myThread, myThreadName, output, rawDataIP, and rawDataPort.

Referenced by QueueOutputPipeTCP(), and QueueOutputPipeTCP().

◆ pushMessage()

void frodo2.communication.tcp.QueueOutputPipeTCP.pushMessage ( MessageWrapper msgWrap)

◆ run()

void frodo2.communication.tcp.QueueOutputPipeTCP.run ( )

Continuously checks if there are messages to be sent and sends them.

Todo
There is a privacy issue when the raw data is already serialized: the recipients learn the IP address of the sender of the raw data
Todo
Reset the streams regularly to get rid of references to previously sent objects that prevent garbage collection?

References frodo2.communication.MessageWithRawData.getHandler(), keepGoing, messageReceived, messages, messages_lock, output, rawDataID, rawDataID_lock, rawDataInfos, rawDataInfos_lock, rawDataIP, rawDataPort, rawDataServer, frodo2.communication.MessageWithRawData.setHandler(), and frodo2.communication.Message.writeExternal().

Here is the call graph for this function:

◆ toDOT()

String frodo2.communication.tcp.QueueOutputPipeTCP.toDOT ( )

Member Data Documentation

◆ keepGoing

boolean frodo2.communication.tcp.QueueOutputPipeTCP.keepGoing = true
private

Used to tell the thread to stop.

Referenced by close(), and run().

◆ messageReceived

final Condition frodo2.communication.tcp.QueueOutputPipeTCP.messageReceived = messages_lock.newCondition()
private

Condition used to signal that the messages list is not empty.

Referenced by pushMessage(), and run().

◆ messages

LinkedList<Message> frodo2.communication.tcp.QueueOutputPipeTCP.messages = new LinkedList <Message> ()
private

List into which pushed messages should be added, until they are sent.

Referenced by pushMessage(), and run().

◆ messages_lock

final ReentrantLock frodo2.communication.tcp.QueueOutputPipeTCP.messages_lock = new ReentrantLock()
private

Lock for the messages field.

Referenced by pushMessage(), and run().

◆ myThread

Thread frodo2.communication.tcp.QueueOutputPipeTCP.myThread
private

The QueueOutputPipeTCP's thread.

Referenced by close(), and init().

◆ myThreadName

String frodo2.communication.tcp.QueueOutputPipeTCP.myThreadName = "QueueOutputPipeTCP"
staticprivate

The name of this QueueOutputPipeTCP's thread.

Referenced by init().

◆ name

String frodo2.communication.tcp.QueueOutputPipeTCP.name
private

The name of this pipe, used only by QueueOutputPipeTCP.toDOT().

Referenced by toDOT().

◆ output

ObjectOutputStream frodo2.communication.tcp.QueueOutputPipeTCP.output
private

Output stream to which outgoing messages should be written.

Referenced by init(), and run().

◆ rawDataID

Integer frodo2.communication.tcp.QueueOutputPipeTCP.rawDataID = 0
private

The ID incremented each time a message with raw data is sent.

Referenced by frodo2.communication.tcp.QueueOutputPipeTCP.RawDataSender.run(), and run().

◆ rawDataID_lock

final ReentrantLock frodo2.communication.tcp.QueueOutputPipeTCP.rawDataID_lock = new ReentrantLock()
private

Lock for the rawDataID field.

Referenced by run().

◆ rawDataInfos

HashMap<Integer, RawDataInfo> frodo2.communication.tcp.QueueOutputPipeTCP.rawDataInfos = new HashMap<Integer, RawDataInfo> ()
private

For each raw data ID, the information about the corresponding raw data.

Referenced by frodo2.communication.tcp.QueueOutputPipeTCP.RawDataSender.run(), and run().

◆ rawDataInfos_lock

final ReentrantLock frodo2.communication.tcp.QueueOutputPipeTCP.rawDataInfos_lock = new ReentrantLock()
private

Lock for the rawDataInfos field.

Referenced by frodo2.communication.tcp.QueueOutputPipeTCP.RawDataSender.run(), and run().

◆ rawDataIP

String frodo2.communication.tcp.QueueOutputPipeTCP.rawDataIP
private

IP address to which recipients should connect to request raw data.

Referenced by init(), QueueOutputPipeTCP(), and run().

◆ rawDataPort

int frodo2.communication.tcp.QueueOutputPipeTCP.rawDataPort
private

Port number on which the pipe should wait for requests for raw data.

Referenced by init(), QueueOutputPipeTCP(), frodo2.communication.tcp.QueueOutputPipeTCP.RawDataServer.RawDataServer(), and run().

◆ rawDataServer

RawDataServer frodo2.communication.tcp.QueueOutputPipeTCP.rawDataServer
private

The thread responsible for waiting for requests for raw data.

Referenced by close(), and run().

◆ socket

Socket frodo2.communication.tcp.QueueOutputPipeTCP.socket
private

The output socket.


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