Package com.facebook.openwifi.rrm
Class DeviceDataManager
- java.lang.Object
-
- com.facebook.openwifi.rrm.DeviceDataManager
-
public class DeviceDataManager extends Object
Device topology and config manager.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
DeviceDataManager.DeviceApConfigFunction
Device AP config layer update interface.static interface
DeviceDataManager.ZoneConfigFunction
Device zone config layer update interface.
-
Constructor Summary
Constructors Constructor Description DeviceDataManager()
Empty constructor without backing files (ex.DeviceDataManager(File topologyFile, File deviceLayeredConfigFile)
Initialize from the given files.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,DeviceConfig>
getAllDeviceConfigs(String zone)
Return config (with all config layers applied) for all devices in a given zone, or null if not present in the topology.DeviceConfig
getDeviceConfig(String serialNumber)
Return config for the given device with all config layers applied, or null if not present in the topology.DeviceConfig
getDeviceConfig(String serialNumber, String zone)
Return config for the given device with all config layers applied.String
getDeviceLayeredConfigJson()
Return the device config layers as a JSON string.String
getDeviceZone(String serialNumber)
Return the RF zone for the given device, or null if not found.DeviceTopology
getTopologyCopy()
Return a copy of the topology.String
getTopologyJson()
Return the topology as a JSON string.DeviceConfig
getZoneConfig(String zone)
Return config for the given zone with all config layers applied.List<String>
getZones()
Return all zones in the topology.boolean
isDeviceInTopology(String serialNumber)
Return true if the given device is present in the topology.boolean
isZoneInTopology(String zone)
Return true if the given RF zone is present in the topology.void
setDeviceApConfig(String serialNumber, DeviceConfig apConfig)
Set the device AP config for the given AP, or erase it if null.void
setDeviceLayeredConfig(DeviceLayeredConfig cfg)
Set the device layered config.void
setDeviceNetworkConfig(DeviceConfig networkConfig)
Set the device network config.void
setDeviceZoneConfig(String zone, DeviceConfig zoneConfig)
Set the device zone config for the given zone, or erase it if null.void
setTopology(DeviceTopology topo)
Set the topology.void
updateDeviceApConfig(DeviceDataManager.DeviceApConfigFunction fn)
Apply updates to the device AP config layer (under a write lock).void
updateZoneConfig(DeviceDataManager.ZoneConfigFunction fn)
Apply updates to the zone layer (under a write lock)
-
-
-
Constructor Detail
-
DeviceDataManager
public DeviceDataManager()
Empty constructor without backing files (ex. for unit tests).
-
DeviceDataManager
public DeviceDataManager(File topologyFile, File deviceLayeredConfigFile) throws IOException
Initialize from the given files.- Parameters:
topologyFile
- theDeviceTopology
filedeviceLayeredConfigFile
- theDeviceLayeredConfig
file- Throws:
IOException
- if file I/O fails
-
-
Method Detail
-
setTopology
public void setTopology(DeviceTopology topo)
Set the topology. May throw unchecked exceptions upon error.
-
getTopologyJson
public String getTopologyJson()
Return the topology as a JSON string.
-
getTopologyCopy
public DeviceTopology getTopologyCopy()
Return a copy of the topology.
-
getDeviceZone
public String getDeviceZone(String serialNumber)
Return the RF zone for the given device, or null if not found.
-
isDeviceInTopology
public boolean isDeviceInTopology(String serialNumber)
Return true if the given device is present in the topology.
-
isZoneInTopology
public boolean isZoneInTopology(String zone)
Return true if the given RF zone is present in the topology.
-
setDeviceLayeredConfig
public void setDeviceLayeredConfig(DeviceLayeredConfig cfg)
Set the device layered config. May throw unchecked exceptions upon error.
-
getDeviceLayeredConfigJson
public String getDeviceLayeredConfigJson()
Return the device config layers as a JSON string.
-
getDeviceConfig
public DeviceConfig getDeviceConfig(String serialNumber)
Return config for the given device with all config layers applied, or null if not present in the topology.
-
getDeviceConfig
public DeviceConfig getDeviceConfig(String serialNumber, String zone)
Return config for the given device with all config layers applied. This method will not check if the device is present in the topology, and uses the supplied zone directly.
-
getAllDeviceConfigs
public Map<String,DeviceConfig> getAllDeviceConfigs(String zone)
Return config (with all config layers applied) for all devices in a given zone, or null if not present in the topology.- Parameters:
zone
- the zone that will be looked up for devices- Returns:
- map of serial number to computed config
-
setDeviceNetworkConfig
public void setDeviceNetworkConfig(DeviceConfig networkConfig)
Set the device network config.
-
setDeviceZoneConfig
public void setDeviceZoneConfig(String zone, DeviceConfig zoneConfig)
Set the device zone config for the given zone, or erase it if null.
-
setDeviceApConfig
public void setDeviceApConfig(String serialNumber, DeviceConfig apConfig)
Set the device AP config for the given AP, or erase it if null.
-
updateZoneConfig
public void updateZoneConfig(DeviceDataManager.ZoneConfigFunction fn)
Apply updates to the zone layer (under a write lock)- Parameters:
fn
- The function to apply for the configs. The key of the argument is the zone name.
-
updateDeviceApConfig
public void updateDeviceApConfig(DeviceDataManager.DeviceApConfigFunction fn)
Apply updates to the device AP config layer (under a write lock).- Parameters:
fn
- The function to apply for the configs. The key of the argument is the serial number of the device.
-
getZoneConfig
public DeviceConfig getZoneConfig(String zone)
Return config for the given zone with all config layers applied. It is the caller's responsibility to ensure the zone exists in the topology.
-
-