VOL-4413 Apply port-number changes in voltha-lib to components
 (Needs to be merged with VOL-4411 changes.)

Change-Id: Ic3ee8f519e04b8b03b8bd09dd497417658ec2ccd
diff --git a/go.mod b/go.mod
index ae14ec3..a46c141 100644
--- a/go.mod
+++ b/go.mod
@@ -17,7 +17,7 @@
 	github.com/golang/mock v1.6.0
 	github.com/golang/protobuf v1.5.2
 	github.com/google/uuid v1.3.0
-	github.com/opencord/voltha-lib-go/v7 v7.0.0
+	github.com/opencord/voltha-lib-go/v7 v7.0.4
 	github.com/opencord/voltha-protos/v5 v5.0.0
 	github.com/opentracing/opentracing-go v1.2.0
 	github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
diff --git a/go.sum b/go.sum
index 30fd463..16f79bd 100644
--- a/go.sum
+++ b/go.sum
@@ -191,8 +191,8 @@
 github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
 github.com/onsi/gomega v1.14.0 h1:ep6kpPVwmr/nTbklSx2nrLNSIO62DoYAhnPNIMhK8gI=
 github.com/onsi/gomega v1.14.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0=
-github.com/opencord/voltha-lib-go/v7 v7.0.0 h1:xDMFbXdku7GOsJeMlsxw8WHAZINBZhy+8m9Hyqt+zdk=
-github.com/opencord/voltha-lib-go/v7 v7.0.0/go.mod h1:iZueJRS4XJ3rpm3iy0Zdnhz1lG5bWx2pZoPormwgUKk=
+github.com/opencord/voltha-lib-go/v7 v7.0.4 h1:nVVRkEZyfEkGYewfgmO3NzIAIVdm8G/vVyEaCUwYW6g=
+github.com/opencord/voltha-lib-go/v7 v7.0.4/go.mod h1:iZueJRS4XJ3rpm3iy0Zdnhz1lG5bWx2pZoPormwgUKk=
 github.com/opencord/voltha-protos/v5 v5.0.0 h1:US2k7qYPMnOueOCrprq9LjuMT3wK9uyxPwAVwjMmKhc=
 github.com/opencord/voltha-protos/v5 v5.0.0/go.mod h1:uVKXQB499Ir6G+rc47dSThNja1S4Vy3h9JLSDuJGmzI=
 github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/grpc/client.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/grpc/client.go
index de649d6..a3dec75 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/grpc/client.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/grpc/client.go
@@ -228,8 +228,8 @@
 			isGrpcMonitorKeyPresentInContext(ctx) {
 			c.stateLock.Lock()
 			if c.state == stateConnected {
-				logger.Warnw(context.Background(), "sending-disconnect-event", log.Fields{"endpoint": c.apiEndPoint, "error": err})
 				c.state = stateDisconnected
+				logger.Warnw(context.Background(), "sending-disconnect-event", log.Fields{"endpoint": c.apiEndPoint, "error": err, "curr-state": stateConnected, "new-state": c.state})
 				c.events <- eventDisconnected
 			}
 			c.stateLock.Unlock()
@@ -290,6 +290,9 @@
 	c.activeCh = make(chan struct{}, 10)
 	c.activeChMutex.Unlock()
 
+	grpcMonitorCheckRunning := false
+	var grpcMonitorCheckRunningLock sync.RWMutex
+
 	// Interval to wait for no activity before probing the connection
 	timeout := c.monitorInterval
 loop:
@@ -298,11 +301,14 @@
 		select {
 
 		case <-c.activeCh:
-			logger.Debugw(ctx, "received-active-notification", log.Fields{"endpoint": c.apiEndPoint})
+			logger.Debugw(ctx, "endpoint-reachable", log.Fields{"endpoint": c.apiEndPoint})
 
 			// Reset timer
 			if !timeoutTimer.Stop() {
-				<-timeoutTimer.C
+				select {
+				case <-timeoutTimer.C:
+				default:
+				}
 			}
 
 		case <-ctx.Done():
@@ -312,10 +318,21 @@
 			// Trigger an activity check if the state is connected.  If the state is not connected then there is already
 			// a backoff retry mechanism in place to retry establishing connection.
 			c.stateLock.RLock()
-			runCheck := c.state == stateConnected
+			grpcMonitorCheckRunningLock.RLock()
+			runCheck := (c.state == stateConnected) && !grpcMonitorCheckRunning
+			grpcMonitorCheckRunningLock.RUnlock()
 			c.stateLock.RUnlock()
 			if runCheck {
 				go func() {
+					grpcMonitorCheckRunningLock.Lock()
+					if grpcMonitorCheckRunning {
+						grpcMonitorCheckRunningLock.Unlock()
+						logger.Debugw(ctx, "connection-check-already-in-progress", log.Fields{"api-endpoint": c.apiEndPoint})
+						return
+					}
+					grpcMonitorCheckRunning = true
+					grpcMonitorCheckRunningLock.Unlock()
+
 					logger.Debugw(ctx, "connection-check-start", log.Fields{"api-endpoint": c.apiEndPoint})
 					subCtx, cancel := context.WithTimeout(ctx, c.backoffMaxInterval)
 					defer cancel()
@@ -326,6 +343,9 @@
 						response := handler(subCtx, c.connection)
 						logger.Debugw(ctx, "connection-check-response", log.Fields{"api-endpoint": c.apiEndPoint, "up": response != nil})
 					}
+					grpcMonitorCheckRunningLock.Lock()
+					grpcMonitorCheckRunning = false
+					grpcMonitorCheckRunningLock.Unlock()
 				}()
 			}
 		}
@@ -362,9 +382,8 @@
 			logger.Debugw(ctx, "received-event", log.Fields{"event": event, "endpoint": c.apiEndPoint})
 			switch event {
 			case eventConnecting:
-				logger.Debugw(ctx, "connection-start", log.Fields{"endpoint": c.apiEndPoint, "attempts": attempt})
-
 				c.stateLock.Lock()
+				logger.Debugw(ctx, "connection-start", log.Fields{"endpoint": c.apiEndPoint, "attempts": attempt, "curr-state": c.state})
 				if c.state == stateConnected {
 					c.state = stateDisconnected
 				}
@@ -393,9 +412,9 @@
 				c.stateLock.Unlock()
 
 			case eventConnected:
-				logger.Debugw(ctx, "endpoint-connected", log.Fields{"endpoint": c.apiEndPoint})
 				attempt = 1
 				c.stateLock.Lock()
+				logger.Debugw(ctx, "endpoint-connected", log.Fields{"endpoint": c.apiEndPoint, "curr-state": c.state})
 				if c.state != stateConnected {
 					c.state = stateConnected
 					if initialConnection {
@@ -418,7 +437,9 @@
 				if p != nil {
 					p.UpdateStatus(ctx, c.apiEndPoint, probe.ServiceStatusNotReady)
 				}
-				logger.Debugw(ctx, "endpoint-disconnected", log.Fields{"endpoint": c.apiEndPoint, "status": c.state})
+				c.stateLock.RLock()
+				logger.Debugw(ctx, "endpoint-disconnected", log.Fields{"endpoint": c.apiEndPoint, "curr-state": c.state})
+				c.stateLock.RUnlock()
 
 				// Try to connect again
 				c.events <- eventConnecting
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 812e53b..384ab62 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -211,7 +211,7 @@
 github.com/modern-go/concurrent
 # github.com/modern-go/reflect2 v1.0.1
 github.com/modern-go/reflect2
-# github.com/opencord/voltha-lib-go/v7 v7.0.0
+# github.com/opencord/voltha-lib-go/v7 v7.0.4
 ## explicit
 github.com/opencord/voltha-lib-go/v7/pkg/adapters/common
 github.com/opencord/voltha-lib-go/v7/pkg/config