[VOL-2164] Update rw-core to use the Async Kafka API

This commit consists of the following:

1. Process per-device requests in the Core in the order they are
received. If there are lots of requests on a given device then
there will be some latencies introduced due to ordering.  With
recent changes in the model along with keeping the request lock
to a minimal then these latencies are reduced.  Testing did not
show and noticeable latencies.

2) Keep the request lock from the moment a request started
processing to the moment that request is sent to kafka (when
applicable).  Adapter responses are received and processed
asynchronously. Therefore, an adapter can takes all the time it
needs to process a transaction.  The Core still has a context
with timeout (configurable) to cater for cases where the adapter
does not return a response.

3) Adapter requests are processed to completion before sending a
reponse back to the adapter.  Previously, in some cases, a
separate go routine was created to process the request and a
successful response is sent to the adapter.  Now if the request
fails then the adapter will receive an error. The adapter
requests for a given device are therefore processed in the
order they are received.

4) Some changes are made when retrieving a handler to execute
a device state transition.  This was necessary as there was some
transition overlap found.

Update after multiple reviews.

Change-Id: I55a189efec1549a662f2d71e18e6eca9015a3a17
diff --git a/rw_core/mocks/adapter_onu.go b/rw_core/mocks/adapter_onu.go
index 73ee749..c31cb93 100644
--- a/rw_core/mocks/adapter_onu.go
+++ b/rw_core/mocks/adapter_onu.go
@@ -62,20 +62,12 @@
 			log.Fatalf("deviceUpdate-failed-%s", res)
 		}
 
-		// Updating the device states twice, once with oper status to discovered and followed by active may cause
-		// a failure for unit tests when these requests reaches the Core within a millisecond of each other (with real
-		// hardware will not happen as the time between these requests is much higher than 1 millisecond).  For
-		// some reasons this issue is seen on Jenkins but not when running the tests locally. The issue
-		// in the core is triggered when these requests are processed out of order (an issue in the Core that is
-		// being handled by https://jira.opencord.org/browse/VOL-2164).
-		// TODO:  Once the above change is completed then this code can be uncommented.
+		d.ConnectStatus = voltha.ConnectStatus_REACHABLE
+		d.OperStatus = voltha.OperStatus_DISCOVERED
 
-		//d.ConnectStatus = voltha.ConnectStatus_REACHABLE
-		//d.OperStatus = voltha.OperStatus_DISCOVERED
-
-		//if err := onuA.coreProxy.DeviceStateUpdate(context.TODO(), d.Id, d.ConnectStatus, d.OperStatus); err != nil {
-		//	log.Fatalf("device-state-update-failed-%s", err)
-		//}
+		if err := onuA.coreProxy.DeviceStateUpdate(context.TODO(), d.Id, d.ConnectStatus, d.OperStatus); err != nil {
+			log.Fatalf("device-state-update-failed-%s", err)
+		}
 
 		uniPortNo := uint32(2)
 		if device.ProxyAddress != nil {
@@ -163,14 +155,17 @@
 		cloned := proto.Clone(device).(*voltha.Device)
 		// Update the all ports state on that device to disable
 		if err := onuA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, voltha.OperStatus_UNKNOWN); err != nil {
-			log.Fatalf("updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
+			// Device may also have been deleted in the Core
+			log.Warnw("updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
+			return
 		}
 		//Update the device state
 		cloned.ConnectStatus = voltha.ConnectStatus_UNREACHABLE
 		cloned.OperStatus = voltha.OperStatus_UNKNOWN
 
 		if err := onuA.coreProxy.DeviceStateUpdate(context.TODO(), cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
-			log.Fatalf("device-state-update-failed", log.Fields{"deviceId": device.Id, "error": err})
+			log.Warnw("device-state-update-failed", log.Fields{"deviceId": device.Id, "error": err})
+			return
 		}
 		if err := onuA.updateDevice(cloned); err != nil {
 			log.Fatalf("saving-device-failed-%s", err)