VOL-1497 : Add more control to kv/memory access
- Added kv locking mechanism (etcd only)
- (watch) control path access whenever possible
- (watch) use a transaction for updates and merge with memory
- cleaned up vendoring
- misc changes to fix exceptions found along the way
Amendments:
- Copyright header got removed in auto-generated file
- Changed default locking to false for KV list operation
- Updated backend api to allow the passing of locking parameter
Change-Id: Ie1a55d3ca8b9d92ae71a85ce42bb22fcf1419e2c
diff --git a/rw_core/core/transaction.go b/rw_core/core/transaction.go
index 397299e..e7125d3 100644
--- a/rw_core/core/transaction.go
+++ b/rw_core/core/transaction.go
@@ -178,7 +178,7 @@
// Add a timeout here in case we miss an event from the KV
case <-time.After(time.Duration(duration) * time.Millisecond):
// In case of missing events, let's check the transaction key
- kvp, err := ctx.kvClient.Get(c.txnKey, ctx.kvOperationTimeout)
+ kvp, err := ctx.kvClient.Get(c.txnKey, ctx.kvOperationTimeout, false)
if err == nil && kvp == nil {
log.Debug("missed-deleted-event")
res = ABANDONED_BY_OTHER
@@ -228,16 +228,16 @@
log.Debugw("schedule-key-deletion", log.Fields{"key": c.txnKey})
time.Sleep(time.Duration(ctx.timeToDeleteCompletedKeys) * time.Second)
log.Debugw("background-key-deletion", log.Fields{"key": c.txnKey})
- ctx.kvClient.Delete(c.txnKey, ctx.kvOperationTimeout)
+ ctx.kvClient.Delete(c.txnKey, ctx.kvOperationTimeout, false)
}
func (c *KVTransaction) Close() error {
log.Debugw("close", log.Fields{"key": c.txnKey})
- return ctx.kvClient.Put(c.txnKey, TRANSACTION_COMPLETE, ctx.kvOperationTimeout)
+ return ctx.kvClient.Put(c.txnKey, TRANSACTION_COMPLETE, ctx.kvOperationTimeout, false)
}
func (c *KVTransaction) Delete() error {
log.Debugw("delete", log.Fields{"key": c.txnKey})
- err := ctx.kvClient.Delete(c.txnKey, ctx.kvOperationTimeout)
+ err := ctx.kvClient.Delete(c.txnKey, ctx.kvOperationTimeout, false)
return err
}