(store RaftStore)
| 76 | } |
| 77 | |
| 78 | func printBasic(store RaftStore) (uint64, uint64) { |
| 79 | fmt.Println() |
| 80 | snap, err := store.Snapshot() |
| 81 | if err != nil { |
| 82 | fmt.Printf("Got error while retrieving snapshot: %v\n", err) |
| 83 | } else { |
| 84 | fmt.Printf("Snapshot Metadata: %+v\n", snap.Metadata) |
| 85 | var ds pb.Snapshot |
| 86 | var zs pb.ZeroSnapshot |
| 87 | if err := proto.Unmarshal(snap.Data, &ds); err == nil { |
| 88 | fmt.Printf("Snapshot Alpha: %+v\n", ds) |
| 89 | } else if err := proto.Unmarshal(snap.Data, &zs); err == nil { |
| 90 | for gid, group := range zs.State.GetGroups() { |
| 91 | fmt.Printf("\nGROUP: %d\n", gid) |
| 92 | for _, member := range group.GetMembers() { |
| 93 | fmt.Printf("Member: %+v .\n", member) |
| 94 | } |
| 95 | for _, tablet := range group.GetTablets() { |
| 96 | fmt.Printf("Tablet: %+v .\n", tablet) |
| 97 | } |
| 98 | group.Members = nil |
| 99 | group.Tablets = nil |
| 100 | fmt.Printf("Group: %d %+v .\n", gid, group) |
| 101 | } |
| 102 | zs.State.Groups = nil |
| 103 | fmt.Printf("\nSnapshot Zero: %+v\n", zs) |
| 104 | } else { |
| 105 | fmt.Printf("Unable to unmarshal Dgraph snapshot: %v", err) |
| 106 | } |
| 107 | } |
| 108 | fmt.Println() |
| 109 | |
| 110 | if hs, err := store.HardState(); err != nil { |
| 111 | fmt.Printf("Got error while retrieving hardstate: %v\n", err) |
| 112 | } else { |
| 113 | fmt.Printf("Hardstate: %+v\n", hs) |
| 114 | } |
| 115 | |
| 116 | if chk, err := store.Checkpoint(); err != nil { |
| 117 | fmt.Printf("Got error while retrieving checkpoint: %v\n", err) |
| 118 | } else { |
| 119 | fmt.Printf("Checkpoint: %d\n", chk) |
| 120 | } |
| 121 | |
| 122 | lastIdx, err := store.LastIndex() |
| 123 | if err != nil { |
| 124 | fmt.Printf("Got error while retrieving last index: %v\n", err) |
| 125 | } |
| 126 | startIdx := snap.Metadata.Index + 1 |
| 127 | fmt.Printf("Last Index: %d . Num Entries: %d .\n\n", lastIdx, lastIdx-startIdx) |
| 128 | return startIdx, lastIdx |
| 129 | } |
| 130 | |
| 131 | func printRaft(store *raftwal.DiskStorage) { |
| 132 | isZero := store.Uint(raftwal.GroupId) == 0 |
no test coverage detected