-
Notifications
You must be signed in to change notification settings - Fork 726
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
Changes from 7 commits
8aad56c
1a741f7
abcb224
cbcd851
d48d655
308cdde
cb41f3d
9a0360e
54187e2
ed35f84
da984d2
1241a98
9f31426
547dd57
f50e3ca
155ebb5
81508b9
4db127e
1b02452
454c27b
fa03500
File filter
Filter by extension
Conversations
Jump to
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.
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 ( | ||
"fmt" | ||
"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) | ||
|
||
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 { | ||
rc.HandleRegionHeartbeat(region) | ||
} | ||
// ensure flush to region kv | ||
time.Sleep(3 * time.Second) | ||
leaderServer.Stop() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check error? |
||
leader := cluster.WaitLeader() | ||
fmt.Println("leader:", leader) | ||
leaderServer = cluster.GetServer(cluster.GetLeader()) | ||
c.Assert(leaderServer, NotNil) | ||
loadRegions := leaderServer.server.GetRaftCluster().GetRegions() | ||
c.Assert(len(loadRegions), Equals, regionLen) | ||
cluster.Destroy() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe use |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,8 @@ type Config struct { | |
|
||
Namespace map[string]NamespaceConfig `json:"namespace"` | ||
|
||
PDServerCfg PDServerConfig `toml:"pd-server" json:"pd-server"` | ||
|
||
ClusterVersion semver.Version `json:"cluster-version"` | ||
|
||
// QuotaBackendBytes Raise alarms when backend size exceeds the given quota. 0 means use the default quota. | ||
|
@@ -633,6 +635,12 @@ func (s SecurityConfig) ToTLSConfig() (*tls.Config, error) { | |
return tlsConfig, nil | ||
} | ||
|
||
// PDServerConfig is the configuration for pd server. | ||
type PDServerConfig struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need this? Can we put There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use it to persist the config of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean by persist to |
||
// EnableRegionStorage enables the independent region storage. | ||
EnableRegionStorage bool `toml:"enable-region-storage" json:"enable-region-storage"` | ||
} | ||
|
||
// StoreLabel is the config item of LabelPropertyConfig. | ||
type StoreLabel struct { | ||
Key string `toml:"key" json:"key"` | ||
|
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.
check error?