Public Member Functions | |
def | __init__ (self, ip, port, whitelist, blacklist) |
def | advertise (self, connection) |
Posting Information to the Hub. More... | |
def | get_flip_request_status (self, remote_rule) |
def | get_local_advertisements (self) |
def | get_multiple_flip_request_status (self, remote_rules) |
def | get_remote_connection_state (self, remote_gateway) |
def | get_remote_gateway_firewall_flag (self, gateway) |
def | get_unblocked_flipped_in_connections (self) |
def | is_gateway_registered (self) |
def | is_named_gateway_registered (self, gateway_key) |
def | list_remote_gateway_names (self) |
def | mark_named_gateway_available (self, gateway_key, available=True, time_since_last_seen=0.0) |
def | matches_remote_gateway_basename (self, gateway) |
def | matches_remote_gateway_name (self, gateway) |
def | post_flip_details (self, gateway, name, connection_type, node) |
def | post_pull_details (self, gateway, name, connection_type, node) |
def | publish_network_statistics (self, statistics) |
def | register_gateway (self, firewall, unique_gateway_name, hub_connection_lost_gateway_hook, gateway_ip) |
Hub Connections. More... | |
def | remote_gateway_info (self, gateway) |
Hub Data Retrieval. More... | |
def | remove_flip_details (self, gateway, name, connection_type, node) |
def | remove_pull_details (self, gateway, name, connection_type, node) |
def | rule_assemble (self, rule_list) |
def | rule_explode (self, rule_list) |
def | send_flip_request (self, remote_gateway, connection, timeout=15.0) |
def | send_unflip_request (self, remote_gateway, rule) |
def | unadvertise (self, connection) |
def | unregister_named_gateway (self, gateway_key) |
def | update_flip_request_status (self, registration_with_status) |
def | update_multiple_flip_request_status (self, registrations_with_status) |
def | update_named_gateway_latency_stats (self, gateway_name, latency_stats) |
Public Attributes | |
connection_lost_lock | |
hub_connection_checker_thread | |
Private Member Functions | |
def | _hub_connection_lost_hook (self) |
def | _parse_redis_bool (self, val) |
def | _parse_redis_float (self, val) |
def | _parse_redis_int (self, val) |
def | _resend_all_flip_ins (self) |
Flip specific communication. More... | |
def | _send_unflip_request (self, remote_gateway, rule) |
Private Attributes | |
_firewall | |
_hub_connection_lost_gateway_hook | |
_unique_gateway_name | |
Manages the Hub data. This is used both by HubManager for the gateway node, and by the rocon hub watcher.
Definition at line 75 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.__init__ | ( | self, | |
ip, | |||
port, | |||
whitelist, | |||
blacklist | |||
) |
@param remote_gateway_request_callbacks : to handle redis responses @type list of function pointers (back to GatewaySync class @param ip : redis server ip @param port : redis server port @raise HubNameNotFoundError, HubNotFoundError
Definition at line 80 of file gateway_hub.py.
|
private |
This gets triggered by the redis connection checker thread when the hub connection is lost. It then passes the trigger to the gateway who needs to remove the hub.
Definition at line 180 of file gateway_hub.py.
|
private |
Definition at line 543 of file gateway_hub.py.
|
private |
Definition at line 531 of file gateway_hub.py.
|
private |
Definition at line 537 of file gateway_hub.py.
|
private |
Flip specific communication.
Marks all flip ins to be resent. Until these flips are resent, they will not be processed
Definition at line 658 of file gateway_hub.py.
|
private |
Unflip a previously flipped registration. If the flip request does not exist (for instance, in the case where this hub was not used to send the request), then False is returned @return True if the flip existed and was removed, False otherwise @rtype Boolean
Definition at line 908 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.advertise | ( | self, | |
connection | |||
) |
Posting Information to the Hub.
Places a topic, service or action on the public interface. On the redis server, this representation will always be: - topic : a triple { name, type, xmlrpc node uri } - service : a triple { name, rosrpc uri, xmlrpc node uri } - action : ??? @param connection: representation of a connection (topic, service, action) @type connection: str @raise .exceptions.ConnectionTypeError: if connection arg is invalid.
Definition at line 553 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.get_flip_request_status | ( | self, | |
remote_rule | |||
) |
Get the status of a flipped registration. If the flip request does not exist (for instance, in the case where this hub was not used to send the request), then None is returned @return the flip status or None @rtype same as gateway_msgs.msg.RemoteRuleWithStatus.status or None
Definition at line 768 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.get_local_advertisements | ( | self | ) |
Retrieves the local list of advertisements from the hub. This gets used to sync across multiple hubs. @return dictionary of remote advertisements @rtype dictionary of connection type keyed connection values
Definition at line 511 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.get_multiple_flip_request_status | ( | self, | |
remote_rules | |||
) |
Get the status of multiple flipped registration. If the flip request does not exist (for instance, in the case where this hub was not used to send the request), then None is returned. Multiple requests are batched together for efficiency. @return the flip status, ordered as per the input remote rules @rtype list of gateway_msgs.msg.RemoteRuleWithStatus.status or None
Definition at line 780 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.get_remote_connection_state | ( | self, | |
remote_gateway | |||
) |
Equivalent to get_connection_state, but generates it from the public interface of a remote gateway @param remote_gateway : hash name for a remote gateway @type str @return dictionary of remote advertisements @rtype dictionary of connection type keyed connection values
Definition at line 470 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.get_remote_gateway_firewall_flag | ( | self, | |
gateway | |||
) |
Returns the value of the remote gateway's firewall (flip) flag. @param gateway : gateway string id @param string @return state of the flag @rtype Bool @raise GatewayUnavailableError when specified gateway is not on the hub
Definition at line 492 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.get_unblocked_flipped_in_connections | ( | self | ) |
Gets all the flipped in connections listed on the hub that are interesting for this gateway (i.e. all unblocked/pending). This is used by the watcher loop to work out how it needs to update the local registrations. :returns: the flipped in registration strings and status. :rtype: list of (utils.Registration, FlipStatus.XXX) tuples.
Definition at line 680 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.is_gateway_registered | ( | self | ) |
Checks if gateway info is on the hub. @return: success or failure of the operation @rtype: bool
Definition at line 193 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.is_named_gateway_registered | ( | self, | |
gateway_key | |||
) |
Check if the gateway exists in this hub because sometimes the gateway ping can be there but all info has been wiped by the hub
Definition at line 270 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.list_remote_gateway_names | ( | self | ) |
Return a list of the gateways (name list, not redis keys). e.g. ['gateway32adcda32','pirate21fasdf']. If not connected, just returns an empty list.
Definition at line 416 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.mark_named_gateway_available | ( | self, | |
gateway_key, | |||
available = True , |
|||
time_since_last_seen = 0.0 |
|||
) |
This function is used by the hub to mark if a gateway can be pinged. If a gateway cannot be pinged, the hub indicates how longs has it been since the hub was last seen @param gateway_key : The gateway key (not the name) @type str @param available: If the gateway can be pinged right now @type bool @param time_since_last_seen: If available is false, how long has it been since the gateway was last seen (in seconds) @type float
Definition at line 302 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.matches_remote_gateway_basename | ( | self, | |
gateway | |||
) |
Use this when gateway can be a regular expression and we need to check it off against list_remote_gateway_names()
Definition at line 456 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.matches_remote_gateway_name | ( | self, | |
gateway | |||
) |
Use this when gateway can be a regular expression and we need to check it off against list_remote_gateway_names() @return a list of matches (higher level decides on action for duplicates). @rtype list[str] : list of remote gateway names.
Definition at line 439 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.post_flip_details | ( | self, | |
gateway, | |||
name, | |||
connection_type, | |||
node | |||
) |
Post flip details to the redis server. This has no actual functionality, it is just useful for debugging with the remote_gateway_info service. @param gateway : the target of the flip @type string @param name : the name of the connection @type string @param type : the type of the connection (one of ConnectionType.xxx @type string @param node : the node name it was pulled from @type string
Definition at line 582 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.post_pull_details | ( | self, | |
gateway, | |||
name, | |||
connection_type, | |||
node | |||
) |
Post pull details to the hub. This has no actual functionality, it is just useful for debugging with the remote_gateway_info service. @param gateway : the gateway it is pulling from @type string @param name : the name of the connection @type string @param type : the type of the connection (one of ConnectionType.xxx @type string @param node : the node name it was pulled from @type string
Definition at line 618 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.publish_network_statistics | ( | self, | |
statistics | |||
) |
Publish network interface information to the hub @param statistics @type gateway_msgs.RemoteGateway
Definition at line 214 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.register_gateway | ( | self, | |
firewall, | |||
unique_gateway_name, | |||
hub_connection_lost_gateway_hook, | |||
gateway_ip | |||
) |
Hub Connections.
Register a gateway with the hub. @param firewall @param unique_gateway_name @param hub_connection_lost_gateway_hook : used to trigger Gateway.disengage_hub(hub) on lost hub connections in redis pubsub listener thread. @gateway_ip @raise HubConnectionLostError if for some reason, the redis server has become unavailable.
Definition at line 108 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.remote_gateway_info | ( | self, | |
gateway | |||
) |
Hub Data Retrieval.
Return remote gateway information for the specified gateway string id. @param gateways : gateway id string to search for @type string @return remote gateway information @rtype gateway_msgs.RemotGateway or None
Definition at line 332 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.remove_flip_details | ( | self, | |
gateway, | |||
name, | |||
connection_type, | |||
node | |||
) |
Post flip details to the redis server. This has no actual functionality, it is just useful for debugging with the remote_gateway_info service. @param gateway : the target of the flip @type string @param name : the name of the connection @type string @param type : the type of the connection (one of ConnectionType.xxx @type string @param node : the node name it was pulled from @type string
Definition at line 600 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.remove_pull_details | ( | self, | |
gateway, | |||
name, | |||
connection_type, | |||
node | |||
) |
Post pull details to the hub. This has no actual functionality, it is just useful for debugging with the remote_gateway_info service. @param gateway : the gateway it was pulling from @type string @param name : the name of the connection @type string @param type : the type of the connection (one of ConnectionType.xxx @type string @param node : the node name it was pulled from @type string
Definition at line 636 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.rule_assemble | ( | self, | |
rule_list | |||
) |
Definition at line 970 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.rule_explode | ( | self, | |
rule_list | |||
) |
Definition at line 937 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.send_flip_request | ( | self, | |
remote_gateway, | |||
connection, | |||
timeout = 15.0 |
|||
) |
Sends a message to the remote gateway via redis pubsub channel. This is called from the watcher thread, when a flip rule gets activated. - redis channel name: rocon:<remote_gateway_name> - data : list of [ command, gateway, rule type, type, xmlrpc_uri ] - [0] - command : in this case 'flip' - [1] - gateway : the name of this gateway, i.e. the flipper - [2] - name : local name - [3] - node : local node name - [4] - connection_type : one of ConnectionType.PUBLISHER etc - [5] - type_info : a ros format type (e.g. std_msgs/String or service api) - [6] - xmlrpc_uri : the xmlrpc node uri @param command : string command name - either 'flip' or 'unflip' @type str @param flip_rule : the flip to send @type gateway_msgs.RemoteRule @param type_info : topic type (e.g. std_msgs/String) @param str @param xmlrpc_uri : the node uri @param str
Definition at line 844 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.send_unflip_request | ( | self, | |
remote_gateway, | |||
rule | |||
) |
Definition at line 901 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.unadvertise | ( | self, | |
connection | |||
) |
Removes a topic, service or action from the public interface. @param connection: representation of a connection (topic, service, action) @type connection: str @raise .exceptions.ConnectionTypeError: if connectionarg is invalid.
Definition at line 570 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.unregister_named_gateway | ( | self, | |
gateway_key | |||
) |
Remove all gateway info for given gateway key from the hub.
Definition at line 257 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.update_flip_request_status | ( | self, | |
registration_with_status | |||
) |
Updates the flip request status for this hub @param registration_with_status : the flip registration for which we are updating status @type (utils.Registration, str) where str is the status @param status : pending/accepted/blocked @type same as gateway_msgs.msg.RemoteRuleWithStatus.status @return True if this hub was used to send the flip request, and the status was updated. False otherwise. @rtype Boolean
Definition at line 707 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.update_multiple_flip_request_status | ( | self, | |
registrations_with_status | |||
) |
Updates the flip request status for multiple registrations on this hub @param registrations_with_status : the flip registration for which we are updating status @type list of (utils.Registration, str) where str is the status @param status : pending/accepted/blocked @type same as gateway_msgs.msg.RemoteRuleWithStatus.status @return True if this hub was used to send the flip request, false otherwise. @rtype Boolean
Definition at line 723 of file gateway_hub.py.
def rocon_gateway.gateway_hub.GatewayHub.update_named_gateway_latency_stats | ( | self, | |
gateway_name, | |||
latency_stats | |||
) |
For a given gateway, update the latency statistics #param gateway_name : gateway name, not the redis key @type str @param latency_stats : ping statistics to the gateway from the hub @type list : 4-tuple of float values [min, avg, max, mean deviation]
Definition at line 280 of file gateway_hub.py.
|
private |
Definition at line 97 of file gateway_hub.py.
|
private |
Definition at line 96 of file gateway_hub.py.
|
private |
Definition at line 101 of file gateway_hub.py.
rocon_gateway.gateway_hub.GatewayHub.connection_lost_lock |
Definition at line 178 of file gateway_hub.py.
rocon_gateway.gateway_hub.GatewayHub.hub_connection_checker_thread |
Definition at line 102 of file gateway_hub.py.