From 9a17c455f08a942ccf3d82f910ca931df077d849 Mon Sep 17 00:00:00 2001 From: Tobias Schottdorf Date: Thu, 23 Jun 2016 11:11:10 -0400 Subject: [PATCH] cli: parse values for more range keys Add those which were not decoded while looking at #7389. --- cli/debug.go | 16 ++++++++++++++++ keys/constants.go | 8 ++++---- keys/keys.go | 8 ++++---- keys/printer.go | 8 ++++---- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/cli/debug.go b/cli/debug.go index 4899b559672f..422c3d26a759 100644 --- a/cli/debug.go +++ b/cli/debug.go @@ -300,6 +300,22 @@ func tryRangeIDKey(kv engine.MVCCKeyValue) (string, error) { case bytes.Equal(suffix, keys.LocalRangeStatsSuffix): msg = &enginepb.MVCCStats{} + case bytes.Equal(suffix, keys.LocalRaftHardStateSuffix): + msg = &raftpb.HardState{} + + case bytes.Equal(suffix, keys.LocalRaftLastIndexSuffix): + i, err := value.GetInt() + if err != nil { + return "", err + } + return fmt.Sprintf("%d", i), nil + + case bytes.Equal(suffix, keys.LocalRangeLastVerificationTimestampSuffix): + msg = &hlc.Timestamp{} + + case bytes.Equal(suffix, keys.LocalRangeLastReplicaGCTimestampSuffix): + msg = &hlc.Timestamp{} + default: return "", fmt.Errorf("unknown raft id key %s", suffix) } diff --git a/keys/constants.go b/keys/constants.go index 24362b215c0c..4aad3fd04fca 100644 --- a/keys/constants.go +++ b/keys/constants.go @@ -114,17 +114,17 @@ var ( // together or individually in a single scan. localRangeIDUnreplicatedInfix = []byte("u") // localRaftHardStateSuffix is the Suffix for the raft HardState. - localRaftHardStateSuffix = []byte("rfth") + LocalRaftHardStateSuffix = []byte("rfth") // localRaftLastIndexSuffix is the suffix for raft's last index. - localRaftLastIndexSuffix = []byte("rfti") + LocalRaftLastIndexSuffix = []byte("rfti") // LocalRaftLogSuffix is the suffix for the raft log. LocalRaftLogSuffix = []byte("rftl") // localRangeLastReplicaGCTimestampSuffix is the suffix for a range's // last replica GC timestamp (for GC of old replicas). - localRangeLastReplicaGCTimestampSuffix = []byte("rlrt") + LocalRangeLastReplicaGCTimestampSuffix = []byte("rlrt") // localRangeLastVerificationTimestampSuffix is the suffix for a range's // last verification timestamp (for checking integrity of on-disk data). - localRangeLastVerificationTimestampSuffix = []byte("rlvt") + LocalRangeLastVerificationTimestampSuffix = []byte("rlvt") // LocalRangePrefix is the prefix identifying per-range data indexed // by range key (either start key, or some key in the range). The diff --git a/keys/keys.go b/keys/keys.go index 2534362aa7dd..5f4424b5d6b8 100644 --- a/keys/keys.go +++ b/keys/keys.go @@ -218,13 +218,13 @@ func MakeRangeIDUnreplicatedKey(rangeID roachpb.RangeID, suffix roachpb.RKey, de // RaftHardStateKey returns a system-local key for a Raft HardState. func RaftHardStateKey(rangeID roachpb.RangeID) roachpb.Key { - return MakeRangeIDUnreplicatedKey(rangeID, localRaftHardStateSuffix, nil) + return MakeRangeIDUnreplicatedKey(rangeID, LocalRaftHardStateSuffix, nil) } // RaftLastIndexKey returns a system-local key for the last index of the // Raft log. func RaftLastIndexKey(rangeID roachpb.RangeID) roachpb.Key { - return MakeRangeIDUnreplicatedKey(rangeID, localRaftLastIndexSuffix, nil) + return MakeRangeIDUnreplicatedKey(rangeID, LocalRaftLastIndexSuffix, nil) } // RaftLogPrefix returns the system-local prefix shared by all entries @@ -243,13 +243,13 @@ func RaftLogKey(rangeID roachpb.RangeID, logIndex uint64) roachpb.Key { // RangeLastReplicaGCTimestampKey returns a range-local key for // the range's last replica GC timestamp. func RangeLastReplicaGCTimestampKey(rangeID roachpb.RangeID) roachpb.Key { - return MakeRangeIDUnreplicatedKey(rangeID, localRangeLastReplicaGCTimestampSuffix, nil) + return MakeRangeIDUnreplicatedKey(rangeID, LocalRangeLastReplicaGCTimestampSuffix, nil) } // RangeLastVerificationTimestampKey returns a range-local key for // the range's last verification timestamp. func RangeLastVerificationTimestampKey(rangeID roachpb.RangeID) roachpb.Key { - return MakeRangeIDUnreplicatedKey(rangeID, localRangeLastVerificationTimestampSuffix, nil) + return MakeRangeIDUnreplicatedKey(rangeID, LocalRangeLastVerificationTimestampSuffix, nil) } // MakeRangeKey creates a range-local key based on the range diff --git a/keys/printer.go b/keys/printer.go index 37bf196da7ea..137e3ddb6619 100644 --- a/keys/printer.go +++ b/keys/printer.go @@ -130,7 +130,7 @@ var ( }{ {name: "AbortCache", suffix: LocalAbortCacheSuffix, ppFunc: abortCacheKeyPrint, psFunc: abortCacheKeyParse}, {name: "RaftTombstone", suffix: LocalRaftTombstoneSuffix}, - {name: "RaftHardState", suffix: localRaftHardStateSuffix}, + {name: "RaftHardState", suffix: LocalRaftHardStateSuffix}, {name: "RaftAppliedIndex", suffix: LocalRaftAppliedIndexSuffix}, {name: "LeaseAppliedIndex", suffix: LocalLeaseAppliedIndexSuffix}, {name: "RaftLog", suffix: LocalRaftLogSuffix, @@ -138,9 +138,9 @@ var ( psFunc: raftLogKeyParse, }, {name: "RaftTruncatedState", suffix: LocalRaftTruncatedStateSuffix}, - {name: "RaftLastIndex", suffix: localRaftLastIndexSuffix}, - {name: "RangeLastReplicaGCTimestamp", suffix: localRangeLastReplicaGCTimestampSuffix}, - {name: "RangeLastVerificationTimestamp", suffix: localRangeLastVerificationTimestampSuffix}, + {name: "RaftLastIndex", suffix: LocalRaftLastIndexSuffix}, + {name: "RangeLastReplicaGCTimestamp", suffix: LocalRangeLastReplicaGCTimestampSuffix}, + {name: "RangeLastVerificationTimestamp", suffix: LocalRangeLastVerificationTimestampSuffix}, {name: "RangeLeaderLease", suffix: LocalRangeLeaderLeaseSuffix}, {name: "RangeStats", suffix: LocalRangeStatsSuffix}, }