VOL-1946: Use uuid to generate transaction ids for grpc request metadata to core instead of a running integer.
This will make it safe across restarts when core uses it to reserve transaction with etcd.
Change-Id: I0bac145f414327215e916857e2b2a936097876fb
diff --git a/afrouter/afrouter/cluster.go b/afrouter/afrouter/cluster.go
index bb95183..859d92f 100644
--- a/afrouter/afrouter/cluster.go
+++ b/afrouter/afrouter/cluster.go
@@ -19,9 +19,9 @@
import (
"errors"
"fmt"
+ "github.com/google/uuid"
"github.com/opencord/voltha-go/common/log"
"google.golang.org/grpc"
- "sync/atomic"
)
var clusters = make(map[string]*cluster)
@@ -30,9 +30,8 @@
type cluster struct {
name string
//backends map[string]*backend
- backends []*backend
- backendIDMap map[*backend]int
- serialNoCounter uint64
+ backends []*backend
+ backendIDMap map[*backend]int
}
//TODO: Move the backend type (active/active etc) to the cluster
@@ -80,8 +79,8 @@
return nil
}
-func (c *cluster) allocateSerialNumber() uint64 {
- return atomic.AddUint64(&c.serialNoCounter, 1) - 1
+func (c *cluster) allocateSerialNumber() string {
+ return uuid.New().String()
}
func (c *cluster) nextBackend(be *backend, seq backendSequence) (*backend, error) {