[VOL-1588] Improve Flow Add performance
This update consists of the following:
1) Update the performance when adding a flow to a logical device,
decomposing the flow into parent and child device and sending the
flow to the adapters.
2) Format a number of files as per GO fmt.
3) Ensure the device graph cache gets updated when a new port is
added to the graph that belongs to an existing device in cache.
The flow update/deletion performance will be addressed in a separate
commit.
Change-Id: I2eb663cc73eef9fc6172203ed88a35726f5fe008
diff --git a/adapters/common/core_proxy.go b/adapters/common/core_proxy.go
index 738a77a..11a22ab 100644
--- a/adapters/common/core_proxy.go
+++ b/adapters/common/core_proxy.go
@@ -34,7 +34,6 @@
coreTopic string
deviceIdCoreMap map[string]string
lockDeviceIdCoreMap sync.RWMutex
-
}
func NewCoreProxy(kafkaProxy *kafka.InterContainerProxy, adapterTopic string, coreTopic string) *CoreProxy {
@@ -185,7 +184,7 @@
}
func (ap *CoreProxy) ChildDeviceDetected(ctx context.Context, parentDeviceId string, parentPortNo int,
- childDeviceType string, channelId int, vendorId string, serialNumber string, onuId int64 ) error {
+ childDeviceType string, channelId int, vendorId string, serialNumber string, onuId int64) error {
log.Debugw("ChildDeviceDetected", log.Fields{"pPeviceId": parentDeviceId, "channelId": channelId})
rpc := "ChildDeviceDetected"
// Use a device specific topic to send the request. The adapter handling the device creates a device
diff --git a/adapters/common/request_handler.go b/adapters/common/request_handler.go
index d16ad95..dd8df8c 100644
--- a/adapters/common/request_handler.go
+++ b/adapters/common/request_handler.go
@@ -23,8 +23,8 @@
"github.com/opencord/voltha-go/common/log"
"github.com/opencord/voltha-go/kafka"
ic "github.com/opencord/voltha-protos/go/inter_container"
+ "github.com/opencord/voltha-protos/go/openflow_13"
"github.com/opencord/voltha-protos/go/voltha"
- "github.com/opencord/voltha-protos/go/openflow_13"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
@@ -33,7 +33,7 @@
TestMode bool
coreInstanceId string
adapter adapters.IAdapter
- coreProxy *CoreProxy
+ coreProxy *CoreProxy
}
func NewRequestHandlerProxy(coreInstanceId string, iadapter adapters.IAdapter, cProxy *CoreProxy) *RequestHandlerProxy {
@@ -135,7 +135,7 @@
}
func (rhp *RequestHandlerProxy) Update_flows_incrementally(args []*ic.Argument) (*empty.Empty, error) {
- log.Debug("Update_flows_incrementally")
+ log.Debug("Update_flows_incrementally")
if len(args) < 3 {
log.Warn("Update_flows_incrementally-invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
@@ -143,8 +143,8 @@
}
device := &voltha.Device{}
transactionID := &ic.StrType{}
- flows := &openflow_13.FlowChanges{}
- groups := &openflow_13.FlowGroupChanges{}
+ flows := &openflow_13.FlowChanges{}
+ groups := &openflow_13.FlowGroupChanges{}
for _, arg := range args {
switch arg.Key {
case "device":
@@ -169,11 +169,11 @@
}
}
}
- log.Debugw("Update_flows_incrementally",log.Fields{"flows":flows,"groups":groups})
- //Invoke the adopt device on the adapter
- if err := rhp.adapter.Update_flows_incrementally(device,flows,groups); err != nil {
- return nil, status.Errorf(codes.NotFound, "%s", err.Error())
- }
+ log.Debugw("Update_flows_incrementally", log.Fields{"flows": flows, "groups": groups})
+ //Invoke the adopt device on the adapter
+ if err := rhp.adapter.Update_flows_incrementally(device, flows, groups); err != nil {
+ return nil, status.Errorf(codes.NotFound, "%s", err.Error())
+ }
return new(empty.Empty), nil
}
diff --git a/adapters/common/utils.go b/adapters/common/utils.go
index 810a3d0..d3c562a 100644
--- a/adapters/common/utils.go
+++ b/adapters/common/utils.go
@@ -70,4 +70,4 @@
remain--
}
return string(b)
-}
\ No newline at end of file
+}
diff --git a/adapters/simulated_olt/adaptercore/simulated_olt.go b/adapters/simulated_olt/adaptercore/simulated_olt.go
index bc70a82..029f032 100644
--- a/adapters/simulated_olt/adaptercore/simulated_olt.go
+++ b/adapters/simulated_olt/adaptercore/simulated_olt.go
@@ -212,22 +212,22 @@
return errors.New("UnImplemented")
}
-func (so *SimulatedOLT) Download_image(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+func (so *SimulatedOLT) Download_image(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
return nil, errors.New("UnImplemented")
}
-func (so *SimulatedOLT) Get_image_download_status(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+func (so *SimulatedOLT) Get_image_download_status(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
return nil, errors.New("UnImplemented")
}
-func (so *SimulatedOLT) Cancel_image_download(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+func (so *SimulatedOLT) Cancel_image_download(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
return nil, errors.New("UnImplemented")
}
-func (so *SimulatedOLT) Activate_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+func (so *SimulatedOLT) Activate_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
return nil, errors.New("UnImplemented")
}
-func (so *SimulatedOLT) Revert_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+func (so *SimulatedOLT) Revert_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
return nil, errors.New("UnImplemented")
}
diff --git a/adapters/simulated_onu/adaptercore/device_handler.go b/adapters/simulated_onu/adaptercore/device_handler.go
index 217614c..ec00426 100644
--- a/adapters/simulated_onu/adaptercore/device_handler.go
+++ b/adapters/simulated_onu/adaptercore/device_handler.go
@@ -139,7 +139,7 @@
AdminState: voltha.AdminState_ENABLED,
OperStatus: voltha.OperStatus_ACTIVE,
Peers: []*voltha.Port_PeerPort{{DeviceId: cloned.ParentId, // Peer device is OLT
- PortNo: uni_port}}, // Peer port is UNI port
+ PortNo: uni_port}}, // Peer port is UNI port
}
// Synchronous call to update device - this method is run in its own go routine