Browse Source

fix: Small fix for debug code and better comments

Matthias Ladkau 4 years ago
parent
commit
3b68724d2a

+ 1 - 1
cluster/distributedstoragemanager.go

@@ -43,7 +43,7 @@ Root returns a root value.
 func (dsm *DistributedStorageManager) Root(root int) uint64 {
 	var ret uint64
 
-	// Do not do anything is the cluster is not operational
+	// Do not do anything if the cluster is not operational
 
 	distTable, distTableErr := dsm.ds.DistributionTable()
 

+ 1 - 1
cluster/memberstorage.go

@@ -721,7 +721,7 @@ func (ms *memberStorage) dump(smname string) string {
 				k, v := it.Next()
 				key := string(k)
 
-				if strings.HasPrefix(key, transPrefix) {
+				if strings.HasPrefix(key, fmt.Sprint(transPrefix, smname, "#")) {
 					key = string(key[len(fmt.Sprint(transPrefix, smname, "#")):])
 
 					locmap[v.(*translationRec).loc] = fmt.Sprintf("%v (v:%v)",

+ 7 - 2
storage/memorystoragemanager.go

@@ -71,7 +71,7 @@ type MemoryStorageManager struct {
 	Data  map[uint64]interface{} // Map of data
 	mutex *sync.Mutex            // Mutex to protect map operations
 
-	LocCount  uint64         // Counter for locations
+	LocCount  uint64         // Counter for locations - Must start > 0
 	AccessMap map[uint64]int // Special map to simulate access issues
 }
 
@@ -79,6 +79,11 @@ type MemoryStorageManager struct {
 NewMemoryStorageManager creates a new MemoryStorageManager
 */
 func NewMemoryStorageManager(name string) *MemoryStorageManager {
+
+	// LocCount must start > 0 - so they can be stored in a Root. Roots with
+	// the value 0 are considered empty. See also graph.getHTree which will
+	// keep creating new HTrees if a Root is 0.
+
 	return &MemoryStorageManager{name, make(map[int]uint64),
 		make(map[uint64]interface{}), &sync.Mutex{}, 1, make(map[uint64]int)}
 }
@@ -91,7 +96,7 @@ func (msm *MemoryStorageManager) Name() string {
 }
 
 /*
-Root returns a root value.
+Root returns a root value. Default (empty) value is 0.
 */
 func (msm *MemoryStorageManager) Root(root int) uint64 {
 	msm.mutex.Lock()