-
Notifications
You must be signed in to change notification settings - Fork 720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
*: Add a new way to store metadata of regions #1237
Merged
Merged
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
8aad56c
update kvproto
nolouch 1a741f7
*: save meta information about region in levelDB
nolouch abcb224
use stream to sync regions
nolouch cbcd851
add switch
nolouch d48d655
update kvproto
nolouch 308cdde
address comments
nolouch cb41f3d
address comments
nolouch 9a0360e
address comments
nolouch 54187e2
address comments
nolouch ed35f84
add keepalive
nolouch da984d2
Merge remote-tracking branch 'upstream/master' into save-goleveldb-ad…
nolouch 1241a98
use master kvproto
nolouch 9f31426
address comments
nolouch 547dd57
Merge branch 'master' into save-goleveldb
nolouch f50e3ca
address comments
nolouch 155ebb5
Merge branch 'master' into save-goleveldb
nolouch 81508b9
wrap the leveldb error
nolouch 4db127e
Merge remote-tracking branch 'origin/save-goleveldb' into save-goleve…
nolouch 1b02452
Merge branch 'master' into save-goleveldb
nolouch 454c27b
address comments
nolouch fa03500
Merge remote-tracking branch 'origin/save-goleveldb' into save-goleve…
nolouch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright 2018 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package integration | ||
|
||
import ( | ||
"time" | ||
|
||
. "github.com/pingcap/check" | ||
"github.com/pingcap/kvproto/pkg/metapb" | ||
|
||
"github.com/pingcap/pd/server" | ||
"github.com/pingcap/pd/server/core" | ||
) | ||
|
||
type idAllocator struct { | ||
id uint64 | ||
} | ||
|
||
func (alloc *idAllocator) Alloc() uint64 { | ||
alloc.id++ | ||
return alloc.id | ||
} | ||
|
||
func (s *integrationTestSuite) TestRegionSyncer(c *C) { | ||
c.Parallel() | ||
cluster, err := newTestCluster(3, func(conf *server.Config) { conf.PDServerCfg.EnableRegionStorage = true }) | ||
c.Assert(err, IsNil) | ||
defer cluster.Destroy() | ||
|
||
err = cluster.RunInitialServers() | ||
c.Assert(err, IsNil) | ||
cluster.WaitLeader() | ||
leaderServer := cluster.GetServer(cluster.GetLeader()) | ||
s.bootstrapCluster(leaderServer, c) | ||
rc := leaderServer.server.GetRaftCluster() | ||
c.Assert(rc, NotNil) | ||
regionLen := 110 | ||
id := &idAllocator{} | ||
regions := make([]*core.RegionInfo, 0, regionLen) | ||
for i := 0; i < regionLen; i++ { | ||
r := &metapb.Region{ | ||
Id: id.Alloc(), | ||
RegionEpoch: &metapb.RegionEpoch{ | ||
ConfVer: 1, | ||
Version: 1, | ||
}, | ||
StartKey: []byte{byte(i)}, | ||
EndKey: []byte{byte(i + 1)}, | ||
Peers: []*metapb.Peer{{Id: id.Alloc(), StoreId: uint64(0)}}, | ||
} | ||
regions = append(regions, core.NewRegionInfo(r, r.Peers[0])) | ||
} | ||
for _, region := range regions { | ||
err = rc.HandleRegionHeartbeat(region) | ||
c.Assert(err, IsNil) | ||
} | ||
// ensure flush to region kv | ||
time.Sleep(3 * time.Second) | ||
err = leaderServer.Stop() | ||
c.Assert(err, IsNil) | ||
cluster.WaitLeader() | ||
leaderServer = cluster.GetServer(cluster.GetLeader()) | ||
c.Assert(leaderServer, NotNil) | ||
loadRegions := leaderServer.server.GetRaftCluster().GetRegions() | ||
c.Assert(len(loadRegions), Equals, regionLen) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this? Can we put
EnableRegionStorage
intoConfig
directly?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use it to persist the config of
PD-server
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by persist to
PD-server
?