Public Member Functions | Protected Member Functions | Friends

wosh::NetworkManager Class Reference
[Core-Modules]

CoreModule designed to manage host-discovery, networking and routing of wosh::Message. More...

#include <H:/WOSH/win32_vc2010/src/core/NetworkManager.h>

List of all members.

Public Member Functions

virtual ~NetworkManager ()
 Destructor. Channels, Protocols and Hosts datasets are destroyed.
Network Host related methods
WRESULT discoveredHost (const WoshDiscoveryInfo *discovery_info, const WoshDiscoveryData *discovery_data, bool *is_new_host=NULL)
 Update information of a WOSH Host (local-host or remote).
WoshHostgetLocalWoshHost (WoshHost *copy_into=NULL) const
 Get (a copy of) local-host object.
WoshHostgetWoshHost (const std::string &hostname, WoshHost *copy_into=NULL) const
bool isHost (const std::string &wosh_hostname, bool connected_only=false) const
WRESULT getWoshHosts (std::vector< WoshHost * > &hosts) const
WRESULT getWoshHostsNames (std::vector< std::string > &hosts_names) const
WRESULT getDiscoveryInfo (const std::string &wosh_hostname, WoshDiscoveryInfo *discovery_info, WoshDiscoveryData *discovery_data) const
const PropertiesProvidergetNetworkInfo () const
std::string getBriefNetwork () const
std::string getBriefConnections () const
Network Channel related methods
WRESULT createChannel (const std::string &protocol_string)
 create a channel
WRESULT getLocalConnections (std::vector< WoshConnection * > &connections) const
WRESULT getConnectionsAll (std::vector< WoshConnection * > &connections) const
WRESULT getConnectionsOf (const std::string &wosh_hostname, std::vector< WoshConnection * > &connections) const
WRESULT getConnectionsBetween (const std::string &host_a, const std::string &host_b, std::vector< WoshConnection * > &connections) const
Network Protocol related methods
WRESULT installProtocol (NetworkProtocol *channel_protocol)
NetworkProtocolloadProtocol (const std::string &network_protocol, double version=0.0)
Message Events (incoming message)
void busMessage (const Message &message, const Bus *source)
 Method raised by the Bus when it processes a new message. Implementations will probably analyze the message and perform actions.
IPropertiesProviderListener interface
virtual bool readingProperty (Property *property_curr, const PropertiesProvider *source)
NetworkChannel Events
void network_channel_incomingMessage (Message *message, NetworkChannel *channel)
void network_channel_connected (const WoshHost *remote_host, NetworkChannel *channel)
void network_channel_disconnected (NetworkChannel *channel)
void network_channel_update (const WoshHost *remote_host, NetworkChannel *channel)
void network_channel_error (int error_id, const std::string &error_description, NetworkChannel *channel)
NetworkProtocol Events
void network_protocol_supported (const std::string &protocol_string, NetworkChannel *channel, NetworkProtocol *source)
void network_protocol_new_channel (NetworkChannel *channel, NetworkProtocol *source)

Protected Member Functions

 NetworkManager (const WoshKernel *parent=NULL)
 Default constructor. Call base constructor and initialize some properties and hosted methods. Local host (WoshHost) is initialized.
WRESULT onKernelInitializing ()
 Event raised synchonously by the Kernel when switching to WoshKernel::STATE_INITIALIZING state.
WRESULT onKernelInitialized ()
 Event raised synchonously by the Kernel when switching to WoshKernel::STATE_INITIALIZED state.
WRESULT onKernelRunning ()
 Event raised synchonously by the Kernel when switching to WoshKernel::STATE_RUNNING state.
WRESULT onKernelStopping ()
 Event raised synchonously by the Kernel when switching to WoshKernel::STATE_STOPPING state.
WRESULT onKernelStopped ()
 Event raised synchonously by the Kernel when switching to WoshKernel::STATE_STOPPED state.

Friends

class wosh::WoshKernel

Internal Mehods and Events management

class wosh::NetworkChannel
class wosh::NetworkProtocol
class wosh::BusManager
class wosh::NetworkOutMessageHandler
class wosh::NetworkInMessageHandler
class wosh::NetworkManagerLooper
WoshHostlocalHost
 also included in map-list 'Hosts', index=0
tStrWoshHostMap Hosts
 all known hosts
URI HostsVirtualURI
 base URI for hosts (:/Network/Hosts)
int hostTimeout
 how long to keep a (lost) host alive
short HostsAutoConnect
 auto-connect new hosts (flag)
short HostsRegisterMultiHop
 register remote (multi-hop) hosts (claimed by beighbours)
tNetworkProtocolList Protocols
 whose handles protocols
URI ProtocolsVirtualURI
 base URI for protocols (:/Network/Protocols)
tLongNetworkChannelMap Channels
 (active) channels
URI ChannelsVirtualURI
 base URI for vonnections (:/Network/Channels)
tStrAutoConnectMap autoConnects
 cache (queue) of autoconnect operations (managed by NetworkManagerLooper)
long localhostNextPushTs
short realtimeRouting
 eval multi-hop routes in realtime
tStrStrMap staticRoutes
 static routes of pairs [target-host,proxy-host]
PropertiesProvider PropertiesNetworkInfo
NetworkOutMessageHandleroutgoingMsgHandler
 is the bridge of outgoing messages
NetworkInMessageHandlerincomingMsgHandler
 buffer queue for incoming messages
NetworkManagerLooperhostTimeOutLooper
 loops hosts to remove ones out of date
static NetworkManagergetInstance ()
static void push_to_BusManager (Message *message, NetworkChannel *channel)
static void push_message (const Message *message, const Bus *source)
static void busses_changed (const XX_MapT< std::string, wosh::Bus * > &busses)
WRESULT addHost_ (WoshHost *host, bool raise_event=true)
WRESULT removeHost_ (WoshHost *host, bool raise_event=true)
void updatedHosts_ ()
WRESULT updateWoshHost_ (const WoshHost *host, bool raise_event, bool never_connect, int hops=-2, bool *is_new_host=NULL)
WRESULT discoveredHost_ (const WoshDiscoveryInfo *discovery_info, const WoshDiscoveryData *discovery_data, bool *is_new_host=NULL)
WRESULT updateRemoteNeighbours_ (const WoshHost *host)
WRESULT addChannel_ (NetworkChannel *channel, bool auto_change_id=true, bool raise_event=true)
WRESULT removeChannel_ (NetworkChannel *channel, bool remove_from_list, bool remove_connections, bool raise_event)
void updatedChannels_ ()
WRESULT getChannelsOf_ (std::vector< NetworkChannel * > &channels, WoshHost *host, bool only_connected)
WRESULT queueAutoConnectHost_ (const std::string &hostname, bool is_new_host)
WRESULT autoConnect_ (const std::string &name, bool new_host)
NetworkProtocolfindBestProtocol_ (WoshHost *host, std::vector< std::string > &protocolsAvailable)
int isHostConnected_ (const std::string &hostname, bool only_connected) const
WRESULT pingHost_ (WoshHost *host, NetworkChannel *channel)
void busMessageHost_ (const Message &message, WoshHost *host)
ResponsemmDoList (const Request *request)
ResponsemmDoListConnections (const Message *requestMessage)
ResponsemmDoListNeighbours (const Request *request)
ResponsemmDoListNetworkTree (const Request *request)
ResponsemmDoListRoutesStatic (const Request *request)
ResponsemmDoListRoutesDynamic (const Request *request)
ResponsemmDoGetStats (const Request *request)
ResponsemmDoCreateChannel (const Request *request)
ResponsemmDoStatusSummary (const Request *request)

Detailed Description

CoreModule designed to manage host-discovery, networking and routing of wosh::Message.

NetworkManager.png

wosh::NetworkManager UML diagram

Initialization:
inline_mscgraph_5

Relations:

Setup:

NetworkManager -> IBusListener BusManager will register NetworkManager-Handler to busses. ...

Flows:

Outgoing Discovery: When new channels are available, localhost's protocols are updated (added). Moreover a (local-kernel) Fact is raised (notifiying the new channel)

See also:
NetworkManager::installChannel()

Incoming Discovery: When an Host is found (or updated),

See also:
NetworkManager::_updateWoshHost()
wosh::NetworkProtocol
wosh::NetworkChannel
Version:
0.6.030
Id:
NetworkManager.h 3775 2011-01-01 16:38:17Z alex
Author:
Alessandro Polo

Definition at line 199 of file NetworkManager.h.


Constructor & Destructor Documentation

wosh::NetworkManager::NetworkManager ( const WoshKernel parent = NULL ) [protected]

Default constructor. Call base constructor and initialize some properties and hosted methods. Local host (WoshHost) is initialized.

Parameters:
parent[in] WoshKernel singleton, passed to WoshModule constructor
Note:
Called by WoshKernel only. Static getter (gamma singleton) will return NULL until kernel is created.

Definition at line 66 of file NetworkManager.cpp.

References wosh::LOG_DEBUG, wosh::LOG_VERBOSE, and wosh::Object::setName().

wosh::NetworkManager::~NetworkManager (  ) [virtual]

Destructor. Channels, Protocols and Hosts datasets are destroyed.

Definition at line 171 of file NetworkManager.cpp.

References wosh::LOG_DEBUG, and wosh::LOG_VERBOSE.


Member Function Documentation

void wosh::NetworkManager::busMessage ( const Message message,
const Bus source 
) [virtual]

Method raised by the Bus when it processes a new message. Implementations will probably analyze the message and perform actions.

Parameters:
[in]messagethe incoming message
[in]sourcethe source Bus of the incoming message
Warning:
The current thread is own and managed by the caller Bus. Heavy, dangerous or time expensive operations should be executed asynchronously and not inline!

Reimplemented from wosh::WoshModule.

Definition at line 340 of file NetworkManager.cpp.

References wosh::MessageContent::asRequest(), BusCore, wosh::Message::getContent(), wosh::Message::getDestination(), wosh::Request::getMethod(), wosh::Message::isEmpty(), wosh::MessageContent::isRequest(), wosh::LOG_DEBUG, wosh::LOG_VERBOSE, wosh::LOG_WARNING, wosh::BusConnector::postMessage(), wosh::Request::replyResponse(), wosh::Message::replyTo(), wosh::Message::setSource(), and WRET_ERR_PARAM.

WRESULT wosh::NetworkManager::createChannel ( const std::string &  protocol_string )

create a channel

Parameters:
[in]protocol_stringconfiguration line (something like TCP://192.168.0.2:9797)
Returns:
WRET_OK

Definition at line 1117 of file NetworkManager.cpp.

References wosh::LOG_INFO, wosh::LOG_VERBOSE, and WRET_ERR_PARAM.

WRESULT wosh::NetworkManager::discoveredHost ( const WoshDiscoveryInfo *  discovery_info,
const WoshDiscoveryData *  discovery_data,
bool *  is_new_host = NULL 
)

Update information of a WOSH Host (local-host or remote).

Parameters:
host[in] the source WoshHost object
is_new_host[out] optional output flag, set to true when Host was unknown.
Returns:
WRET_ERR_PARAM when host is NULL; WRET_OK else.
Note:
used by Discovery service (as services::DiscoveryUdp)

Definition at line 719 of file NetworkManager.cpp.

WoshHost * wosh::NetworkManager::getLocalWoshHost ( WoshHost copy_into = NULL ) const

Get (a copy of) local-host object.

Parameters:
host[in] object to be updated (using = operator instead of cloning the original object)
Returns:
copy of the WoshHost object representing local-host (myself) or the input parameter (when != NULL)
Note:
used by Discovery service (as services::DiscoveryUdp)

Definition at line 963 of file NetworkManager.cpp.

void wosh::NetworkManager::network_channel_incomingMessage ( Message message,
NetworkChannel channel 
)
WRESULT wosh::NetworkManager::onKernelInitialized (  ) [protected, virtual]

Event raised synchonously by the Kernel when switching to WoshKernel::STATE_INITIALIZED state.

Returns:
WRET_OK on success, custom error code on errors

Reimplemented from wosh::WoshModule.

Definition at line 232 of file NetworkManager.cpp.

References wosh::LOG_INFO, wosh::LOG_WARNING, WRET_ERR_PARAM, and WRET_OK.

WRESULT wosh::NetworkManager::onKernelInitializing (  ) [protected, virtual]

Event raised synchonously by the Kernel when switching to WoshKernel::STATE_INITIALIZING state.

Returns:
WRET_OK on success, custom error code on errors

Reimplemented from wosh::WoshModule.

Definition at line 206 of file NetworkManager.cpp.

References wosh::LOG_INFO.

WRESULT wosh::NetworkManager::onKernelRunning (  ) [protected, virtual]

Event raised synchonously by the Kernel when switching to WoshKernel::STATE_RUNNING state.

Returns:
WRET_OK on success, custom error code on errors

Reimplemented from wosh::WoshModule.

Definition at line 258 of file NetworkManager.cpp.

References wosh::LOG_INFO, wosh::LOG_VERBOSE, wosh::LOG_WARNING, and WRET_OK.

WRESULT wosh::NetworkManager::onKernelStopped (  ) [protected, virtual]

Event raised synchonously by the Kernel when switching to WoshKernel::STATE_STOPPED state.

Returns:
WRET_OK on success, custom error code on errors

Reimplemented from wosh::WoshModule.

Definition at line 297 of file NetworkManager.cpp.

References wosh::LOG_INFO, wosh::LOG_VERBOSE, and WRET_OK.

WRESULT wosh::NetworkManager::onKernelStopping (  ) [protected, virtual]

Event raised synchonously by the Kernel when switching to WoshKernel::STATE_STOPPING state.

Returns:
WRET_OK on success, custom error code on errors

Reimplemented from wosh::WoshModule.

Definition at line 281 of file NetworkManager.cpp.

References wosh::LOG_DEBUG, and wosh::LOG_VERBOSE.

WRESULT wosh::NetworkManager::updateRemoteNeighbours_ ( const WoshHost host ) [private]

Member Data Documentation

cache (queue) of autoconnect operations (managed by NetworkManagerLooper)

Definition at line 416 of file NetworkManager.h.

(active) channels

Definition at line 413 of file NetworkManager.h.

Referenced by wosh::NetworkOutMessageHandler::sendMessage().

base URI for vonnections (:/Network/Channels)

Definition at line 414 of file NetworkManager.h.

all known hosts

Definition at line 404 of file NetworkManager.h.

Referenced by wosh::NetworkOutMessageHandler::sendMessage().

auto-connect new hosts (flag)

Definition at line 407 of file NetworkManager.h.

register remote (multi-hop) hosts (claimed by beighbours)

Definition at line 408 of file NetworkManager.h.

base URI for hosts (:/Network/Hosts)

Definition at line 405 of file NetworkManager.h.

how long to keep a (lost) host alive

Definition at line 406 of file NetworkManager.h.

loops hosts to remove ones out of date

Definition at line 427 of file NetworkManager.h.

buffer queue for incoming messages

Definition at line 426 of file NetworkManager.h.

also included in map-list 'Hosts', index=0

Definition at line 403 of file NetworkManager.h.

is the bridge of outgoing messages

Definition at line 425 of file NetworkManager.h.

whose handles protocols

Definition at line 410 of file NetworkManager.h.

base URI for protocols (:/Network/Protocols)

Definition at line 411 of file NetworkManager.h.

eval multi-hop routes in realtime

Definition at line 420 of file NetworkManager.h.

static routes of pairs [target-host,proxy-host]

Definition at line 421 of file NetworkManager.h.

Referenced by wosh::NetworkOutMessageHandler::sendMessage().


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

Generated on Tue Feb 8 2011 09:33:31 for WOSH system 0.8.888 [wolf] by Alessandro Polo, using DoxyGen 1.7.2 hosted by WOSH Framework