Registration Service API

The ai_nn_controller registration service maintains the registry of network nodes and AI control applications.

RegisterInterface

class register.RegisterInterface

Central registration interface for the ai_nn_controller framework.

This class manages registration of network nodes and AI applications, maintains state in Redis, and handles REQ/REP communication.

Initialization:

__init__()

Initialize the registration interface:

  • Load configuration from register.conf

  • Connect to Redis

  • Bind ZMQ REP socket for registrations

Network Node Methods:

register_network_node(node_id)

Register a new network node.

Parameters:

node_id – Unique node identifier

Raises:

Exception – If node already registered

register_available_pms(node_id, available_pms)

Register available performance measurements for a node.

Parameters:
  • node_id – Node identifier

  • available_pms – List of available PM names

Raises:

Exception – If node not registered

register_available_ctrls(node_id, available_ctrls)

Register available control functions for a node.

Parameters:
  • node_id – Node identifier

  • available_ctrls – List of available control function names

Raises:

Exception – If node not registered

get_network_nodes()

Get list of all registered network node IDs.

Returns:

List of registered node IDs

get_list_of_pm()

Get all registered performance measurements.

Returns:

Dict mapping node_id to list of PM names

get_list_of_ctrl()

Get all registered control functions.

Returns:

Dict mapping node_id to list of control names

AI Application Methods:

register_ai_app(node_id)

Register an AI application.

Parameters:

node_id – Application identifier

Raises:

Exception – If already registered (logs warning, doesn’t fail)

register_ai_app_actions(node_id, network_node_list, list_of_pm, list_of_ctrl)

Register AI app’s measurement and control access.

Parameters:
  • node_id – Application identifier

  • network_node_list – List of node IDs the app wants to access

  • list_of_pm – Dict mapping node_id to list of PM names

  • list_of_ctrl – Dict mapping node_id to list of control names

Raises:

Exception – If app not registered or requested access not available

Health Monitoring:

alive_network_node_update(node_id)

Update heartbeat for a network node.

Parameters:

node_id – Node identifier

Raises:

Exception – If node not registered

check_if_network_node_is_alive(node_id)

Check if a node is still alive, unregister if not.

Parameters:

node_id – Node identifier

Raises:

Exception – If node not responding or not registered

Communication:

read_msg()

Read a message from the ZMQ socket.

Returns:

Parsed JSON message dict

send_msg(msg)

Send a message on the ZMQ socket.

Parameters:

msg – Message dict to send

Registration Protocol

Node Registration

1. Node → Register: {"node_type": "network_node", "node_id": 3, "msg_type": "register"}
2. Register → Node: {"msg_type": "ack", "node_id": 0}
3. Node → Register: {"msg_type": "pm_availability", "node_id": 3, "available_pms": [...]}
4. Register → Node: {
     "msg_type": "ack",
     "databus_ip": "node_msg_broker",
     "send_pm_port": "5555",
     "recv_command_port": "5557"
   }

App Registration

1. App → Register: {"node_type": "aic_app", "node_id": -1, "msg_type": "register"}
2. Register → App: {
     "msg_type": "ack",
     "network_node_list": [...],
     "list_of_pm": {...},
     "list_of_ctrl": {...}
   }
3. App → Register: {
     "msg_type": "pm_ctrl_req",
     "node_id": -1,
     "network_node_list": [3, 8],
     "list_of_pm": {3: ["gain"], 8: ["preamp_gain"]},
     "list_of_ctrl": {8: ["SET_GAIN"]}
   }
4. Register → App: {
     "msg_type": "ack",
     "databus_ip": "node_msg_broker",
     "ai_app_listen_port": "5554",
     "ai_app_send_command_port": "5556"
   }

Message Templates

# Node registration acknowledgment
network_node_registration_ack = {
    'msg_type': 'ack',
    'node_id': 0
}

# PM availability acknowledgment
network_node_pm_availability_ack = {
    'msg_type': 'ack',
    'node_id': 0,
    'databus_ip': '',
    'send_pm_port': '',
    'recv_command_port': ''
}

# AI app registration acknowledgment
ai_app_registration_ack = {
    'msg_type': 'ack',
    'node_id': 0,
    'network_node_list': [],
    'list_of_pm': {},
    'list_of_ctrl': {}
}

# AI app access acknowledgment
ai_app_access_ack = {
    'msg_type': 'ack',
    'node_id': 0,
    'databus_ip': '',
    'ai_app_listen_port': '',
    'ai_app_send_command_port': ''
}

# Error message
err = {
    'msg_type': 'err',
    'node_id': 0,
    'msg_content': ''
}

Redis Data Structure

Redis Keys

Key Pattern

Description

network_nodes:network_node_list

Set of registered node IDs

network_nodes:network_node_pm_list:{node_id}

Set of available PMs for node

network_nodes:network_node_ctrl_list:{node_id}

Set of available controls for node

network_nodes:network_node_list:{node_id}

Heartbeat counter for node

ai_apps:ai_apps_list

Set of registered AI app IDs

ai_apps:ai_apps_info_list:{node_id}

JSON with app configuration

Configuration

register.conf format:

registration_ip_address = aic_register
ip_address = 0.0.0.0
databus_ip_address = node_msg_broker
recv_measurements = 5555
pub_measurements = 5554
recv_commands = 5556
pub_commands = 5557
register_sub = 5558