VOL-1173 : Removed hash based storage; replaced with per device protobuf
- Ensured proxies issue callbacks instead of forcing with goroutines
- Fixed mutex issue with proxy component
Change-Id: Idabd3257c6d264c0f607ee228e406810304dab43
diff --git a/rw_core/core/device_agent.go b/rw_core/core/device_agent.go
index 784b506..9e8710b 100644
--- a/rw_core/core/device_agent.go
+++ b/rw_core/core/device_agent.go
@@ -51,7 +51,9 @@
var agent DeviceAgent
agent.adapterProxy = ap
cloned := (proto.Clone(device)).(*voltha.Device)
- cloned.Id = CreateDeviceId()
+ if cloned.Id == "" {
+ cloned.Id = CreateDeviceId()
+ }
cloned.AdminState = voltha.AdminState_PREPROVISIONED
cloned.FlowGroups = &ofp.FlowGroups{Items: nil}
cloned.Flows = &ofp.Flows{Items: nil}
@@ -180,15 +182,13 @@
} else {
oldData = proto.Clone(storedData.Flows).(*voltha.Flows)
log.Debugw("updateFlows", log.Fields{"deviceId": agent.deviceId, "flows": flows, "old": oldData})
+
// store the changed data
- storedData.Flows.Items = flows
- afterUpdate := agent.clusterDataProxy.Update("/devices/"+agent.deviceId, storedData, false, "")
+ afterUpdate := agent.flowProxy.Update("/", &ofp.Flows{Items: flows}, false, "")
if afterUpdate == nil {
return status.Errorf(codes.Internal, "%s", agent.deviceId)
}
- // For now, force the callback to occur
- go agent.flowTableUpdated(oldData, &ofp.Flows{Items: flows})
return nil
}
}
@@ -196,21 +196,16 @@
func (agent *DeviceAgent) updateGroups(groups []*ofp.OfpGroupEntry) error {
agent.lockDevice.Lock()
defer agent.lockDevice.Unlock()
- var oldData *voltha.FlowGroups
log.Debugw("updateGroups", log.Fields{"deviceId": agent.deviceId, "groups": groups})
- if storedData, err := agent.getDeviceWithoutLock(); err != nil {
+ if _, err := agent.getDeviceWithoutLock(); err != nil {
return status.Errorf(codes.NotFound, "%s", agent.deviceId)
} else {
- oldData = proto.Clone(storedData.FlowGroups).(*voltha.FlowGroups)
// store the changed data
- storedData.FlowGroups.Items = groups
- afterUpdate := agent.clusterDataProxy.Update("/devices/"+agent.deviceId, storedData, false, "")
+ afterUpdate := agent.groupProxy.Update("/", &ofp.FlowGroups{Items: groups}, false, "")
if afterUpdate == nil {
return status.Errorf(codes.Internal, "%s", agent.deviceId)
}
- // For now, force the callback to occur
- go agent.groupTableUpdated(oldData, &ofp.FlowGroups{Items: groups})
return nil
}
}