[VOL-2688] Improve core model performance

This commit addresses the low-hanging performance hogs in the
core model.  In particular, the following changes are made:

1) Remove proto message comparision when it's possible.  The proto
message deep comparison is quite expensive.
2) Since the Core already has a lock on the device/logicaldevice/
adapters/etc before invoking the model proxy then there is no
need for the latter to create an additional lock on these artifacts
duting an update
3) The model creates a watch on every artifacts it adds to the KV
store.   Since in the next Voltha release we will not be using Voltha
Core in pairs then there is no point in keeping these watches (these
is only 1 Core that will ever update an artifact in the next
deployment).  This update removes these watch.
4) Additional unit tests has been created, mostly around flows, in an
attempt to exercise both the core and the model further.

Change-Id: Ieaf1f6b9b05c56e819600bc55b46a05f73b8efcf
diff --git a/rw_core/mocks/adapter_onu.go b/rw_core/mocks/adapter_onu.go
index ea02210..73ee749 100644
--- a/rw_core/mocks/adapter_onu.go
+++ b/rw_core/mocks/adapter_onu.go
@@ -20,6 +20,7 @@
 	"context"
 	"fmt"
 	"strings"
+	"sync"
 
 	"github.com/gogo/protobuf/proto"
 	"github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif"
@@ -32,15 +33,19 @@
 
 // ONUAdapter represent ONU adapter attributes
 type ONUAdapter struct {
-	coreProxy adapterif.CoreProxy
+	flows map[uint64]*voltha.OfpFlowStats
+	lock  sync.Mutex
 	Adapter
 }
 
 // NewONUAdapter creates ONU adapter
 func NewONUAdapter(cp adapterif.CoreProxy) *ONUAdapter {
-	a := &ONUAdapter{}
-	a.coreProxy = cp
-	return a
+	return &ONUAdapter{
+		flows: map[uint64]*voltha.OfpFlowStats{},
+		Adapter: Adapter{
+			coreProxy: cp,
+		},
+	}
 }
 
 // Adopt_device creates new handler for added device
@@ -200,3 +205,37 @@
 	}()
 	return nil
 }
+
+// Update_flows_incrementally mocks the incremental flow update
+func (onuA *ONUAdapter) Update_flows_incrementally(device *voltha.Device, flows *of.FlowChanges, groups *of.FlowGroupChanges, flowMetadata *voltha.FlowMetadata) error { // nolint
+	onuA.lock.Lock()
+	defer onuA.lock.Unlock()
+
+	if flows.ToAdd != nil {
+		for _, f := range flows.ToAdd.Items {
+			onuA.flows[f.Id] = f
+		}
+	}
+	if flows.ToRemove != nil {
+		for _, f := range flows.ToRemove.Items {
+			delete(onuA.flows, f.Id)
+		}
+	}
+	return nil
+}
+
+// GetFlowCount returns the total number of flows presently under this adapter
+func (onuA *ONUAdapter) GetFlowCount() int {
+	onuA.lock.Lock()
+	defer onuA.lock.Unlock()
+
+	return len(onuA.flows)
+}
+
+// ClearFlows removes all flows in this adapter
+func (onuA *ONUAdapter) ClearFlows() {
+	onuA.lock.Lock()
+	defer onuA.lock.Unlock()
+
+	onuA.flows = map[uint64]*voltha.OfpFlowStats{}
+}