VOL-1509 : Partial fix for merging issue
- Changed channel map in etcd to a sync.Map
- Changed graph boundaryPorts to sync.Map
- Added logic to check if proxy access is currently reserved
- Changed watch logic to exit when proxy access in progress
- Fixed UpdateAllChildren method
- Commented out the Drop operation again in node.go
Change-Id: I8a61798e907be0ff6b0785dcc70721708308611d
diff --git a/db/model/proxy.go b/db/model/proxy.go
index be48ded..86d426a 100644
--- a/db/model/proxy.go
+++ b/db/model/proxy.go
@@ -55,13 +55,14 @@
// Proxy holds the information for a specific location with the data model
type Proxy struct {
sync.RWMutex
- Root *root
- Node *node
- ParentNode *node
- Path string
- FullPath string
- Exclusive bool
- Callbacks map[CallbackType]map[string]*CallbackTuple
+ Root *root
+ Node *node
+ ParentNode *node
+ Path string
+ FullPath string
+ Exclusive bool
+ Callbacks map[CallbackType]map[string]*CallbackTuple
+ Operation ProxyOperation
}
// NewProxy instantiates a new proxy to a specific location
@@ -71,13 +72,13 @@
fullPath = ""
}
p := &Proxy{
- Root: root,
- Node: node,
- ParentNode: parentNode,
- Exclusive: exclusive,
- Path: path,
- FullPath: fullPath,
- Callbacks: callbacks,
+ Root: root,
+ Node: node,
+ ParentNode: parentNode,
+ Exclusive: exclusive,
+ Path: path,
+ FullPath: fullPath,
+ Callbacks: callbacks,
}
return p
}
@@ -136,6 +137,18 @@
delete(p.Callbacks[callbackType], funcHash)
}
+// CallbackType is an enumerated value to express when a callback should be executed
+type ProxyOperation uint8
+
+// Enumerated list of callback types
+const (
+ PROXY_GET ProxyOperation = iota
+ PROXY_LIST
+ PROXY_ADD
+ PROXY_UPDATE
+ PROXY_REMOVE
+)
+
// parseForControlledPath verifies if a proxy path matches a pattern
// for locations that need to be access controlled.
func (p *Proxy) parseForControlledPath(path string) (pathLock string, controlled bool) {
@@ -183,7 +196,6 @@
return rv
}
-
// Get will retrieve information from the data model at the specified path location
func (p *Proxy) Get(path string, depth int, deep bool, txid string) interface{} {
var effectivePath string
@@ -228,8 +240,12 @@
pac := PAC().ReservePath(effectivePath, p, pathLock)
defer PAC().ReleasePath(pathLock)
+
+ p.Operation = PROXY_UPDATE
pac.SetProxy(p)
+ log.Debugw("proxy-operation--update", log.Fields{"operation":p.Operation})
+
return pac.Update(fullPath, data, strict, txid, controlled)
}
@@ -257,8 +273,12 @@
pac := PAC().ReservePath(path, p, pathLock)
defer PAC().ReleasePath(pathLock)
+
+ p.Operation = PROXY_ADD
pac.SetProxy(p)
+ log.Debugw("proxy-operation--add", log.Fields{"operation":p.Operation})
+
return pac.Add(fullPath, data, txid, controlled)
}
@@ -284,8 +304,12 @@
pac := PAC().ReservePath(path, p, pathLock)
defer PAC().ReleasePath(pathLock)
+
+ p.Operation = PROXY_ADD
pac.SetProxy(p)
+ log.Debugw("proxy-operation--add", log.Fields{"operation":p.Operation})
+
return pac.Add(fullPath, data, txid, controlled)
}
@@ -311,8 +335,12 @@
pac := PAC().ReservePath(effectivePath, p, pathLock)
defer PAC().ReleasePath(pathLock)
+
+ p.Operation = PROXY_REMOVE
pac.SetProxy(p)
+ log.Debugw("proxy-operation--remove", log.Fields{"operation":p.Operation})
+
return pac.Remove(fullPath, txid, controlled)
}