Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nolouch committed Sep 27, 2018
1 parent cb41f3d commit db433ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
9 changes: 4 additions & 5 deletions pkg/integration_test/region_syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package integration

import (
"fmt"
"time"

. "github.com/pingcap/check"
Expand Down Expand Up @@ -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()
Expand Down
10 changes: 4 additions & 6 deletions server/core/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -108,7 +106,7 @@ type KV struct {
func NewKV(base KVBase) *KV {
return &KV{
KVBase: base,
proxy: NewKVProxy(base, nil),
proxy: NewKVProxy(base),
}
}

Expand Down

0 comments on commit db433ff

Please sign in to comment.