debug.go 947 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package cluster
  2. import (
  3. "bytes"
  4. "fmt"
  5. "time"
  6. )
  7. /*
  8. msmap is a map of all know memory-only memberStorages.
  9. */
  10. var msmap = make(map[*DistributedStorage]*memberStorage)
  11. /*
  12. ClearMSMap clears the current map of known memory-only memberStorages.
  13. */
  14. func ClearMSMap() {
  15. msmap = make(map[*DistributedStorage]*memberStorage)
  16. }
  17. /*
  18. DumpMemoryClusterLayout returns the current storage layout in a memory-only cluster
  19. for a given storage manager (e.g. mainPerson.nodes for Person nodes of partition main).
  20. */
  21. func DumpMemoryClusterLayout(smname string) string {
  22. buf := new(bytes.Buffer)
  23. for _, ms := range msmap {
  24. buf.WriteString(fmt.Sprintf("MemoryStorage: %s\n", ms.gs.Name()))
  25. buf.WriteString(ms.dump(smname))
  26. }
  27. return buf.String()
  28. }
  29. /*
  30. WaitForTransfer waits for the datatransfer to happen.
  31. */
  32. func WaitForTransfer() {
  33. for _, ms := range msmap {
  34. ms.transferWorker()
  35. for ms.transferRunning {
  36. time.Sleep(time.Millisecond)
  37. }
  38. }
  39. }