General afrouter cleanup.
- Separated backend.go into multiple files.
- Replaced array indexing hack with enum pattern.
- Various renaming for better consistency.
- Removed a few unused structs.
- Replaced a thread with an atomic operation.
Change-Id: I2239692cac21ddb7f513b6d8c247ffa8789714ac
diff --git a/afrouter/arouter.json b/afrouter/arouter.json
index 329a7d4..c1530a7 100644
--- a/afrouter/arouter.json
+++ b/afrouter/arouter.json
@@ -1,225 +1,279 @@
{
- "servers": [
- {
- "name": "grpc_command",
- "port": 55555,
- "address":"",
- "type": "grpc",
- "routers": [
- {
- "_TODO":"Suport a router list, remove the package and service from the router",
- "package":"voltha",
- "service":"VolthaService",
- "router":"vcore"
- }
- ]
- }
- ],
- "routers": [
- {
- "name":"vcore",
- "package": "voltha",
- "service": "VolthaService",
- "routes": [
- {
- "name":"dev_manager",
- "proto_descriptor":"voltha.pb",
- "type":"rpc_affinity_message",
- "association":"round_robin",
- "routing_field": "id",
- "backend_cluster":"vcore",
- "_COMMENT":"Methods are naturally southbound affinity binding unless otherwise specified below",
- "methods":[ "CreateDevice",
- "GetCoreInstance",
- "EnableLogicalDevicePort",
- "DisableLogicalDevicePort",
- "EnableDevice",
- "DisableDevice",
- "RebootDevice",
- "DeleteDevice",
- "DownloadImage",
- "CancelImageDownload",
- "ActivateImageUpdate",
- "RevertImageUpdate",
- "UpdateDevicePmConfigs",
- "CreateAlarmFilter",
- "UpdateAlarmFilter",
- "DeleteAlarmFilter",
- "SelfTest"],
- "_COMMENT":"If a method is northbound affinity binding then association is used to route",
- "_COMMENT":"but affinity is not set southbound but only based on the response",
- "_COMMENT":"Methods here MUST be specified above, this overrides thier default beahvior",
- "nb_binding_methods":["CreateDevice"],
- "_TODO":"Overrides not implemented yet, config ignored",
- "overrides": [
- {"methods":["abc","def"], "routing_field":"id"},
- {"methods":["ghi","jkl"]},
- {"method":"mno", "routing_field":"id"},
- {"method":"pqr"}
- ]
- },
- {
- "name":"read_only",
- "type":"round_robin",
- "association":"round_robin",
- "backend_cluster":"ro_vcore",
- "methods":[ "ListDevicePorts",
- "ListDevicePmConfigs",
- "GetImages",
- "GetImageDownloadStatus",
- "GetImageDownload",
- "ListImageDownloads",
- "ListDeviceFlows",
- "ListDeviceFlowGroups",
- "ListLogicalDeviceFlows",
- "ListLogicalDeviceFlowGroups",
- "ListDevices",
- "GetDevice",
- "ListLogicalDevices",
- "GetLogicalDevices",
- "GetDeviceType",
- "GetDeviceGroup",
- "GetLogicalDevice",
- "GetAlarmFilter",
- "ListLogicalDevicePorts",
- "GetLogicalDevicePort"
- ]
- },
- {
- "name":"dev_manager_ofagent",
- "type":"binding",
- "_association":"round_robin",
- "binding": {
- "type":"header",
- "field":"voltha_backend_name",
- "method":"Subscribe",
- "association":"round_robin"
- },
- "backend_cluster":"vcore",
- "methods":["StreamPacketsOut",
- "ReceivePacketsIn",
- "ReceiveChangeEvents",
- "Subscribe",
- "UpdateLogicalDeviceFlowTable",
- "UpdateLogicalDeviceFlowGroupTable",
- "GetLogicalDevice",
- "GetLogicalDevicePort",
- "EnableLogicalDevicePort",
- "DisableLogicalDevicePort",
- "ListLogicalDevices",
- "ListLogicalDeviceFlows",
- "ListLogicalDeviceFlowGroups",
- "ListLogicalDevicePorts"
- ],
- "_TODO":"Overrides not implemented yet, config ignored",
- "overrides": [
- {"methods":["abc","def"], "routing_field":"id"},
- {"methods":["ghi","jkl"]},
- {"method":"mno", "routing_field":"id"},
- {"method":"pqr"}
- ]
- }
- ]
- }
- ],
- "backend_clusters": [
- {
- "name":"vcore",
- "backends":[ {
- "name":"vcore1",
- "type":"active_active",
- "association": {
- "strategy":"serial_number",
- "location":"header",
- "_TODO":"The key below needs to be implemented, currently hard coded",
- "key":"voltha_serial_number"
- },
- "connections": [ {
- "name":"vcore11",
- "addr":"",
- "port":""
- },
- {
- "name":"vcore12",
- "addr":"",
- "port":""
- }]
- },
- {
- "name":"vcore2",
- "type":"active_active",
- "association": {
- "strategy":"serial_number",
- "location":"header",
- "_TODO":"The key below needs to be implemented, currently hard coded",
- "key":"voltha_serial_number"
- },
- "connections": [ {
- "name":"vcore21",
- "addr":"",
- "port":""
- },
- {
- "name":"vcore22",
- "addr":"",
- "port":""
- }]
- },
- {
- "name":"vcore3",
- "type":"active_active",
- "association": {
- "strategy":"serial_number",
- "location":"header",
- "_TODO":"The key below needs to be implemented, currently hard coded",
- "key":"voltha_serial_number"
- },
- "connections": [ {
- "name":"vcore31",
- "addr":"",
- "port":""
- },
- {
- "name":"vcore32",
- "addr":"",
- "port":""
- }]
- }]
- },
- {
- "name":"ro_vcore",
- "backends":[ {
- "name":"ro_vcore1",
- "type":"server",
- "connections": [ {
- "name":"ro_vcore11",
- "addr":"",
- "port":""
- }]
- },
- {
- "name":"ro_vcore2",
- "type":"server",
- "connections": [ {
- "name":"ro_vcore21",
- "addr":"",
- "port":""
- }]
- },
- {
- "name":"ro_vcore3",
- "type":"server",
- "connections": [ {
- "name":"ro_vcore31",
- "addr":"",
- "port":""
- }]
- }]
- }
- ],
- "api": {
- "_comment":"If this isn't defined then no api is available for dynamic configuration and queries",
- "address":"",
- "port":55554
- }
+ "servers": [
+ {
+ "name": "grpc_command",
+ "port": 55555,
+ "address": "",
+ "type": "grpc",
+ "routers": [
+ {
+ "_TODO": "Suport a router list, remove the package and service from the router",
+ "package": "voltha",
+ "service": "VolthaService",
+ "router": "vcore"
+ }
+ ]
+ }
+ ],
+ "routers": [
+ {
+ "name": "vcore",
+ "package": "voltha",
+ "service": "VolthaService",
+ "routes": [
+ {
+ "name": "dev_manager",
+ "proto_descriptor": "voltha.pb",
+ "type": "rpc_affinity_message",
+ "association": "round_robin",
+ "routing_field": "id",
+ "backend_cluster": "vcore",
+ "_COMMENT": "Methods are naturally southbound affinity binding unless otherwise specified below",
+ "methods": [
+ "CreateDevice",
+ "GetCoreInstance",
+ "EnableLogicalDevicePort",
+ "DisableLogicalDevicePort",
+ "EnableDevice",
+ "DisableDevice",
+ "RebootDevice",
+ "DeleteDevice",
+ "DownloadImage",
+ "CancelImageDownload",
+ "ActivateImageUpdate",
+ "RevertImageUpdate",
+ "UpdateDevicePmConfigs",
+ "CreateAlarmFilter",
+ "UpdateAlarmFilter",
+ "DeleteAlarmFilter",
+ "SelfTest"
+ ],
+ "_COMMENT": "If a method is northbound affinity binding then association is used to route",
+ "_COMMENT": "but affinity is not set southbound but only based on the response",
+ "_COMMENT": "Methods here MUST be specified above, this overrides thier default beahvior",
+ "nb_binding_methods": [
+ "CreateDevice"
+ ],
+ "_TODO": "Overrides not implemented yet, config ignored",
+ "overrides": [
+ {
+ "methods": [
+ "abc",
+ "def"
+ ],
+ "routing_field": "id"
+ },
+ {
+ "methods": [
+ "ghi",
+ "jkl"
+ ]
+ },
+ {
+ "method": "mno",
+ "routing_field": "id"
+ },
+ {
+ "method": "pqr"
+ }
+ ]
+ },
+ {
+ "name": "read_only",
+ "type": "round_robin",
+ "association": "round_robin",
+ "backend_cluster": "ro_vcore",
+ "methods": [
+ "ListDevicePorts",
+ "ListDevicePmConfigs",
+ "GetImages",
+ "GetImageDownloadStatus",
+ "GetImageDownload",
+ "ListImageDownloads",
+ "ListDeviceFlows",
+ "ListDeviceFlowGroups",
+ "ListLogicalDeviceFlows",
+ "ListLogicalDeviceFlowGroups",
+ "ListDevices",
+ "GetDevice",
+ "ListLogicalDevices",
+ "GetLogicalDevices",
+ "GetDeviceType",
+ "GetDeviceGroup",
+ "GetLogicalDevice",
+ "GetAlarmFilter",
+ "ListLogicalDevicePorts",
+ "GetLogicalDevicePort"
+ ]
+ },
+ {
+ "name": "dev_manager_ofagent",
+ "type": "binding",
+ "_association": "round_robin",
+ "binding": {
+ "type": "header",
+ "field": "voltha_backend_name",
+ "method": "Subscribe",
+ "association": "round_robin"
+ },
+ "backend_cluster": "vcore",
+ "methods": [
+ "StreamPacketsOut",
+ "ReceivePacketsIn",
+ "ReceiveChangeEvents",
+ "Subscribe",
+ "UpdateLogicalDeviceFlowTable",
+ "UpdateLogicalDeviceFlowGroupTable",
+ "GetLogicalDevice",
+ "GetLogicalDevicePort",
+ "EnableLogicalDevicePort",
+ "DisableLogicalDevicePort",
+ "ListLogicalDevices",
+ "ListLogicalDeviceFlows",
+ "ListLogicalDeviceFlowGroups",
+ "ListLogicalDevicePorts"
+ ],
+ "_TODO": "Overrides not implemented yet, config ignored",
+ "overrides": [
+ {
+ "methods": [
+ "abc",
+ "def"
+ ],
+ "routing_field": "id"
+ },
+ {
+ "methods": [
+ "ghi",
+ "jkl"
+ ]
+ },
+ {
+ "method": "mno",
+ "routing_field": "id"
+ },
+ {
+ "method": "pqr"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "backend_clusters": [
+ {
+ "name": "vcore",
+ "backends": [
+ {
+ "name": "vcore1",
+ "type": "active_active",
+ "association": {
+ "strategy": "serial_number",
+ "location": "header",
+ "_TODO": "The key below needs to be implemented, currently hard coded",
+ "key": "voltha_serial_number"
+ },
+ "connections": [
+ {
+ "name": "vcore11",
+ "addr": "",
+ "port": ""
+ },
+ {
+ "name": "vcore12",
+ "addr": "",
+ "port": ""
+ }
+ ]
+ },
+ {
+ "name": "vcore2",
+ "type": "active_active",
+ "association": {
+ "strategy": "serial_number",
+ "location": "header",
+ "_TODO": "The key below needs to be implemented, currently hard coded",
+ "key": "voltha_serial_number"
+ },
+ "connections": [
+ {
+ "name": "vcore21",
+ "addr": "",
+ "port": ""
+ },
+ {
+ "name": "vcore22",
+ "addr": "",
+ "port": ""
+ }
+ ]
+ },
+ {
+ "name": "vcore3",
+ "type": "active_active",
+ "association": {
+ "strategy": "serial_number",
+ "location": "header",
+ "_TODO": "The key below needs to be implemented, currently hard coded",
+ "key": "voltha_serial_number"
+ },
+ "connections": [
+ {
+ "name": "vcore31",
+ "addr": "",
+ "port": ""
+ },
+ {
+ "name": "vcore32",
+ "addr": "",
+ "port": ""
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "name": "ro_vcore",
+ "backends": [
+ {
+ "name": "ro_vcore1",
+ "type": "server",
+ "connections": [
+ {
+ "name": "ro_vcore11",
+ "addr": "",
+ "port": ""
+ }
+ ]
+ },
+ {
+ "name": "ro_vcore2",
+ "type": "server",
+ "connections": [
+ {
+ "name": "ro_vcore21",
+ "addr": "",
+ "port": ""
+ }
+ ]
+ },
+ {
+ "name": "ro_vcore3",
+ "type": "server",
+ "connections": [
+ {
+ "name": "ro_vcore31",
+ "addr": "",
+ "port": ""
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "api": {
+ "_comment": "If this isn't defined then no api is available for dynamic configuration and queries",
+ "address": "",
+ "port": 55554
+ }
}