From db433ff749490516b388170b14046e2506b89cda Mon Sep 17 00:00:00 2001 From: nolouch Date: Thu, 27 Sep 2018 11:12:41 +0800 Subject: [PATCH] address comments --- pkg/integration_test/region_syncer_test.go | 9 ++++----- server/core/kv.go | 10 ++++------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/pkg/integration_test/region_syncer_test.go b/pkg/integration_test/region_syncer_test.go index 8245794c6593..779795661f4e 100644 --- a/pkg/integration_test/region_syncer_test.go +++ b/pkg/integration_test/region_syncer_test.go @@ -14,7 +14,6 @@ package integration import ( - "fmt" "time" . "github.com/pingcap/check" @@ -62,13 +61,13 @@ func (s *integrationTestSuite) TestRegionSyncer(c *C) { regions = append(regions, core.NewRegionInfo(r, r.Peers[0])) } for _, region := range regions { - rc.HandleRegionHeartbeat(region) + err = rc.HandleRegionHeartbeat(region) + c.Assert(err, IsNil) } // ensure flush to region kv time.Sleep(3 * time.Second) - leaderServer.Stop() - leader := cluster.WaitLeader() - fmt.Println("leader:", leader) + err = leaderServer.Stop() + c.Assert(err, IsNil) leaderServer = cluster.GetServer(cluster.GetLeader()) c.Assert(leaderServer, NotNil) loadRegions := leaderServer.server.GetRaftCluster().GetRegions() diff --git a/server/core/kv.go b/server/core/kv.go index 68612aeba9b2..0349adb81364 100644 --- a/server/core/kv.go +++ b/server/core/kv.go @@ -48,14 +48,12 @@ type KVProxy struct { } // NewKVProxy return a proxy of KV storage. -func NewKVProxy(defaultKV KVBase, regionKV *RegionKV) *KVProxy { - kv := &KVProxy{ - defaultKV: defaultKV, - regionKV: regionKV, - } +func NewKVProxy(defaultKV KVBase) *KVProxy { + kv := &KVProxy{defaultKV: defaultKV} kv.isDefault.Store(true) return kv } + func (kv *KVProxy) getKVBase() KVBase { isDefault := kv.isDefault.Load().(bool) if isDefault { @@ -108,7 +106,7 @@ type KV struct { func NewKV(base KVBase) *KV { return &KV{ KVBase: base, - proxy: NewKVProxy(base, nil), + proxy: NewKVProxy(base), } }