Qore ConnectionProvider Module Reference  1.7
ConnectionProvider::PollingConnectionMonitor Class Reference

Class for monitoring connection supporting the polling API. More...

Public Member Methods

 add (AbstractConnection conn)
 Adds a connection to be monitored. More...
 
 addOrUpdate (AbstractConnection conn)
 Adds or updates an existing connection that is already being monitored. More...
 
 constructor (*Logger logger)
 Creates the object.
 
 destructor ()
 Stops the monitoring thread and destroys the object.
 
bool removeConnection (string name)
 Removes the given connection. More...
 
 removeConnectionEx (string name)
 Removes the given connection. More...
 
bool running ()
 Returns True if the I/O thread is running.
 
 setLogger (Logger logger)
 Sets the logger.
 
 start ()
 Starts monitoring. More...
 
 stop ()
 Stops monitoring.
 

Private Member Methods

Queue cmdq ()
 I/O thread command queue.
 
Counter cnt ()
 I/O thread counter.
 
 handlePingFailed (string name, hash< ExceptionInfo > ex)
 Handles a failed ping.
 
 handlePingSuccess (string name)
 Handles a successful ping.
 
 handlePingTimeout (string name)
 Handles a poll timeout.
 
Mutex m ()
 Lock for atomic actions.
 
 restartPing (string name, *bool force_restart)
 Restarts a ping operation.
 

Private Attributes

hash< string, hash< PollInfo > > cache
 Connection cache; unique name -> connection object wrapper.
 
const DefaultPingRepeat = 1m
 Default ping repeat duration.
 
const DefaultPingTimeout = 30s
 Default ping timeout duration.
 
const IO_ADD = "add"
 I/O thread command: add.
 
const IO_QUIT = "quit"
 I/O thread command: quit.
 
const IO_REMOVE = "remove"
 I/O thread command: remove.
 
const IO_UPDATE = "update"
 I/O thread command: update.
 
*Logger logger
 Logger.
 
date ping_repeat = DefaultPingRepeat
 ping repeat duration
 
date ping_timeout = DefaultPingTimeout
 ping timeout duration
 
int tid
 I/O thread TID.
 

Private:Internal Attributes

hash< SocketPollInfo > sem_info
 Semaphore descriptor info.
 
ReadOnlyFile sem_read
 File to read in the I/O thread.
 
File sem_write
 File to signal the I/O thread.
 

Detailed Description

Class for monitoring connection supporting the polling API.

Since
ConnectionProvider 1.7

Member Function Documentation

◆ add()

ConnectionProvider::PollingConnectionMonitor::add ( AbstractConnection  conn)

Adds a connection to be monitored.

Parameters
connthe connection to be monitored; must support the connection polling API
Exceptions
MONITOR-CONNECTION-ERRORthe connection does not support the connection polling API
MONITOR-ADD-ERRORa different connection with this name is already being monitored

◆ addOrUpdate()

ConnectionProvider::PollingConnectionMonitor::addOrUpdate ( AbstractConnection  conn)

Adds or updates an existing connection that is already being monitored.

Parameters
connthe connection to be monitored; must support the connection polling API
Exceptions
MONITOR-CONNECTION-ERRORthe connection does not support the connection polling API

◆ removeConnection()

bool ConnectionProvider::PollingConnectionMonitor::removeConnection ( string  name)

Removes the given connection.

Parameters
namethe connection to be removed
Returns
True if the connection was removed, False if no such connection is being monitored
See also
removeConnectionEx()

◆ removeConnectionEx()

ConnectionProvider::PollingConnectionMonitor::removeConnectionEx ( string  name)

Removes the given connection.

Parameters
namethe connection to be removed
Exceptions
MONITOR-REMOVE-ERRORthrown if the named connection is not being monitored
See also
removeConnection()

◆ start()

ConnectionProvider::PollingConnectionMonitor::start ( )

Starts monitoring.

Exceptions
MONITOR-START-ERRORif the I/O thread is already running