VOL-1173 : Removed hash based storage; replaced with per device protobuf
- Ensured proxies issue callbacks instead of forcing with goroutines
- Fixed mutex issue with proxy component
Change-Id: Idabd3257c6d264c0f607ee228e406810304dab43
diff --git a/db/model/proxy.go b/db/model/proxy.go
index 65da561..402731a 100644
--- a/db/model/proxy.go
+++ b/db/model/proxy.go
@@ -55,56 +55,50 @@
// Proxy holds the information for a specific location with the data model
type Proxy struct {
sync.RWMutex
- Root *root
- Node *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
}
// NewProxy instantiates a new proxy to a specific location
-func NewProxy(root *root, node *node, path string, fullPath string, exclusive bool) *Proxy {
+func NewProxy(root *root, node *node, parentNode *node, path string, fullPath string, exclusive bool) *Proxy {
callbacks := make(map[CallbackType]map[string]*CallbackTuple)
if fullPath == "/" {
fullPath = ""
}
p := &Proxy{
- Root: root,
- Node: node,
- Exclusive: exclusive,
- Path: path,
- FullPath: fullPath,
- Callbacks: callbacks,
+ Root: root,
+ Node: node,
+ ParentNode: parentNode,
+ Exclusive: exclusive,
+ Path: path,
+ FullPath: fullPath,
+ Callbacks: callbacks,
}
return p
}
// GetRoot returns the root attribute of the proxy
func (p *Proxy) GetRoot() *root {
- p.Lock()
- defer p.Unlock()
return p.Root
}
// getPath returns the path attribute of the proxy
func (p *Proxy) getPath() string {
- p.Lock()
- defer p.Unlock()
return p.Path
}
// getFullPath returns the full path attribute of the proxy
func (p *Proxy) getFullPath() string {
- p.Lock()
- defer p.Unlock()
return p.FullPath
}
// getCallbacks returns the full list of callbacks associated to the proxy
func (p *Proxy) getCallbacks(callbackType CallbackType) map[string]*CallbackTuple {
- p.Lock()
- defer p.Unlock()
if cb, exists := p.Callbacks[callbackType]; exists {
return cb
}
@@ -113,8 +107,6 @@
// getCallback returns a specific callback matching the type and function hash
func (p *Proxy) getCallback(callbackType CallbackType, funcHash string) *CallbackTuple {
- p.Lock()
- defer p.Unlock()
if tuple, exists := p.Callbacks[callbackType][funcHash]; exists {
return tuple
}
@@ -146,7 +138,10 @@
// for locations that need to be access controlled.
func (p *Proxy) parseForControlledPath(path string) (pathLock string, controlled bool) {
// TODO: Add other path prefixes that may need control
- if strings.HasPrefix(path, "/devices") || strings.HasPrefix(path, "/logical_devices"){
+ if strings.HasPrefix(path, "/devices") ||
+ strings.HasPrefix(path, "/logical_devices") ||
+ strings.HasPrefix(path, "/adapters") {
+
split := strings.SplitN(path, "/", -1)
switch len(split) {
case 2: