From 6312a3c244d121f146a147f3466c4e08cf505775 Mon Sep 17 00:00:00 2001 From: Tobias Schottdorf Date: Wed, 6 Jul 2016 11:58:13 -0400 Subject: [PATCH] storage: stringer for snapshotType --- storage/replica_raftstorage.go | 11 ++++++----- storage/snapshottype_string.go | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 storage/snapshottype_string.go diff --git a/storage/replica_raftstorage.go b/storage/replica_raftstorage.go index 7d1b67928819..498181f6f8ae 100644 --- a/storage/replica_raftstorage.go +++ b/storage/replica_raftstorage.go @@ -512,6 +512,7 @@ func (r *Replica) updateRangeInfo(desc *roachpb.RangeDescriptor) error { return nil } +//go:generate stringer -type snapshotType type snapshotType int const ( @@ -542,13 +543,13 @@ func (r *Replica) applySnapshot(snap raftpb.Snapshot, typ snapshotType) (uint64, replicaID := r.mu.replicaID r.mu.Unlock() - log.Infof("replica %d received snapshot for range %d at index %d. "+ - "encoded size=%d, %d KV pairs, %d log entries", - replicaID, desc.RangeID, snap.Metadata.Index, + log.Infof("replica %d applying %s for range %d at index %d "+ + "(encoded size=%d, %d KV pairs, %d log entries)", + replicaID, typ, desc.RangeID, snap.Metadata.Index, len(snap.Data), len(snapData.KV), len(snapData.LogEntries)) defer func(start time.Time) { - log.Infof("replica %d applied snapshot for range %d in %s", - replicaID, desc.RangeID, timeutil.Since(start)) + log.Infof("replica %d applied %s for range %d in %s", + replicaID, typ, desc.RangeID, timeutil.Since(start)) }(timeutil.Now()) // Delete everything in the range and recreate it from the snapshot. diff --git a/storage/snapshottype_string.go b/storage/snapshottype_string.go new file mode 100644 index 000000000000..ba3060bbf9e0 --- /dev/null +++ b/storage/snapshottype_string.go @@ -0,0 +1,16 @@ +// Code generated by "stringer -type snapshotType"; DO NOT EDIT + +package storage + +import "fmt" + +const _snapshotType_name = "normalSnapshotpreemptiveSnapshot" + +var _snapshotType_index = [...]uint8{0, 14, 32} + +func (i snapshotType) String() string { + if i < 0 || i >= snapshotType(len(_snapshotType_index)-1) { + return fmt.Sprintf("snapshotType(%d)", i) + } + return _snapshotType_name[_snapshotType_index[i]:_snapshotType_index[i+1]] +}