This commit is contained in:
huiqing zhou 2017-12-07 13:50:14 -08:00
Родитель 646945d98c
Коммит 482cf3e2a8
15 изменённых файлов: 233 добавлений и 106 удалений

Просмотреть файл

@ -41,6 +41,9 @@ type TabletStatsCache struct {
// Note we keep track of all master tablets in all cells.
cell string
// cell to region mapping function
cellToRegion func(cell string) string
// mu protects the entries map. It does not protect individual
// entries in the map.
mu sync.RWMutex
@ -65,8 +68,8 @@ type tabletStatsCacheEntry struct {
// Note we do the registration in this code to guarantee we call
// SetListener with sendDownEvents=true, as we need these events
// to maintain the integrity of our cache.
func NewTabletStatsCache(hc HealthCheck, cell string) *TabletStatsCache {
return newTabletStatsCache(hc, cell, true /* setListener */)
func NewTabletStatsCache(hc HealthCheck, cell string, cellToRegion func(cell string) string) *TabletStatsCache {
return newTabletStatsCache(hc, cell, cellToRegion, true /* setListener */)
}
// NewTabletStatsCacheDoNotSetListener is identical to NewTabletStatsCache
@ -76,14 +79,22 @@ func NewTabletStatsCache(hc HealthCheck, cell string) *TabletStatsCache {
// When the caller sets its own listener on "hc", they must make sure that they
// set the parameter "sendDownEvents" to "true" or this cache won't properly
// remove tablets whose tablet type changes.
func NewTabletStatsCacheDoNotSetListener(cell string) *TabletStatsCache {
return newTabletStatsCache(nil, cell, false /* setListener */)
func NewTabletStatsCacheDoNotSetListener(cell string, cellToRegion func(cell string) string) *TabletStatsCache {
return newTabletStatsCache(nil, cell, cellToRegion, false /* setListener */)
}
func newTabletStatsCache(hc HealthCheck, cell string, setListener bool) *TabletStatsCache {
// UpdateCellsToRegions is mainly for testing purpose, the `cellsToRegions` mapping should be provided in the constructor
func (tc *TabletStatsCache) UpdateCellsToRegions(cellsToRegions map[string]string) {
tc.cellToRegion = func(cell string) string {
return cellsToRegions[cell]
}
}
func newTabletStatsCache(hc HealthCheck, cell string, cellToRegion func(cell string) string, setListener bool) *TabletStatsCache {
tc := &TabletStatsCache{
cell: cell,
entries: make(map[string]map[string]map[topodatapb.TabletType]*tabletStatsCacheEntry),
cell: cell,
cellToRegion: cellToRegion,
entries: make(map[string]map[string]map[topodatapb.TabletType]*tabletStatsCacheEntry),
}
if setListener {
@ -144,8 +155,8 @@ func (tc *TabletStatsCache) getOrCreateEntry(target *querypb.Target) *tabletStat
// StatsUpdate is part of the HealthCheckStatsListener interface.
func (tc *TabletStatsCache) StatsUpdate(ts *TabletStats) {
if ts.Target.TabletType != topodatapb.TabletType_MASTER && ts.Tablet.Alias.Cell != tc.cell {
// this is for a non-master tablet in a different cell, drop it
if ts.Target.TabletType != topodatapb.TabletType_MASTER && ts.Tablet.Alias.Cell != tc.cell && tc.cellToRegion(ts.Tablet.Alias.Cell) != tc.cellToRegion(tc.cell) {
// this is for a non-master tablet in a different cell and a different region, drop it
return
}

Просмотреть файл

@ -131,7 +131,7 @@ func TestWaitForTablets(t *testing.T) {
createFakeConn(tablet, input)
hc := NewHealthCheck(1*time.Millisecond, 1*time.Hour)
tsc := NewTabletStatsCache(hc, "cell")
tsc := NewTabletStatsCache(hc, "cell", func(cell string) string { return cell })
hc.AddTablet(tablet, "")
// this should time out

Просмотреть файл

@ -755,6 +755,8 @@ type CellInfo struct {
// Root is the path to store data in. It is only used when talking
// to server_address.
Root string `protobuf:"bytes,2,opt,name=root" json:"root,omitempty"`
// Region is a group this cell belongs to
Region string `protobuf:"bytes,3,opt,name=region" json:"region,omitempty"`
}
func (m *CellInfo) Reset() { *m = CellInfo{} }
@ -776,6 +778,13 @@ func (m *CellInfo) GetRoot() string {
return ""
}
func (m *CellInfo) GetRegion() string {
if m != nil {
return m.Region
}
return ""
}
func init() {
proto.RegisterType((*KeyRange)(nil), "topodata.KeyRange")
proto.RegisterType((*TabletAlias)(nil), "topodata.TabletAlias")
@ -800,75 +809,76 @@ func init() {
func init() { proto.RegisterFile("topodata.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 1115 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 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xfe, 0xdd, 0x7c, 0x51, 0x54, 0x7f, 0x5e, 0xfc, 0x1d, 0x00, 0x00, 0xff,
0xff, 0xc7, 0x53, 0xa5, 0x90, 0x50, 0x0b, 0x00, 0x00,
}

Просмотреть файл

@ -80,6 +80,16 @@ func (ts *Server) GetCellInfo(ctx context.Context, cell string, strongRead bool)
return ci, nil
}
// GetRegionByCell gets the region from a given cell
func (ts *Server) GetRegionByCell(ctx context.Context, cell string) (string, error) {
cellInfo, err := ts.GetCellInfo(ctx, cell, false)
if err == nil {
return cellInfo.Region, nil
}
return "", err
}
// CreateCellInfo creates a new CellInfo with the provided content.
func (ts *Server) CreateCellInfo(ctx context.Context, cell string, ci *topodatapb.CellInfo) error {
// Pack the content.

Просмотреть файл

@ -294,6 +294,28 @@ func (ts *Server) ConnForCell(ctx context.Context, cell string) (Conn, error) {
return conn, nil
}
// CellToRegionMapper function is a wrapper around topo.Server#GetRegionByCell with caching and error handling
func (ts *Server) CellToRegionMapper() func(cell string) string {
memoize := make(map[string]string)
ctx := context.Background()
return func(cell string) string {
if ts == nil {
return cell
}
if region, ok := memoize[cell]; ok {
return region
}
if region, err := ts.GetRegionByCell(ctx, cell); err == nil {
memoize[cell] = region
return region
}
// for backward compatibility, when region isn't available, it's the same as given cell
return cell
}
}
// Close will close all connections to underlying topo Server.
// It will nil all member variables, so any further access will panic.
func (ts *Server) Close() {

Просмотреть файл

@ -70,6 +70,7 @@ func init() {
func commandAddCellInfo(ctx context.Context, wr *wrangler.Wrangler, subFlags *flag.FlagSet, args []string) error {
serverAddress := subFlags.String("server_address", "", "The address the topology server is using for that cell.")
root := subFlags.String("root", "", "The root path the topology server is using for that cell.")
region := subFlags.String("region", "", "The region this cell belongs to.")
if err := subFlags.Parse(args); err != nil {
return err
}
@ -81,12 +82,14 @@ func commandAddCellInfo(ctx context.Context, wr *wrangler.Wrangler, subFlags *fl
return wr.TopoServer().CreateCellInfo(ctx, cell, &topodatapb.CellInfo{
ServerAddress: *serverAddress,
Root: *root,
Region: *region,
})
}
func commandUpdateCellInfo(ctx context.Context, wr *wrangler.Wrangler, subFlags *flag.FlagSet, args []string) error {
serverAddress := subFlags.String("server_address", "", "The address the topology server is using for that cell.")
root := subFlags.String("root", "", "The root path the topology server is using for that cell.")
region := subFlags.String("region", "", "The region this cell belongs to.")
if err := subFlags.Parse(args); err != nil {
return err
}
@ -97,7 +100,8 @@ func commandUpdateCellInfo(ctx context.Context, wr *wrangler.Wrangler, subFlags
return wr.TopoServer().UpdateCellInfoFields(ctx, cell, func(ci *topodatapb.CellInfo) error {
if (*serverAddress == "" || ci.ServerAddress == *serverAddress) &&
(*root == "" || ci.Root == *root) {
(*root == "" || ci.Root == *root) &&
(*region == "" || ci.Region == *region) {
return topo.ErrNoUpdateNeeded
}
if *serverAddress != "" {
@ -106,6 +110,9 @@ func commandUpdateCellInfo(ctx context.Context, wr *wrangler.Wrangler, subFlags
if *root != "" {
ci.Root = *root
}
if *region != "" {
ci.Region = *region
}
return nil
})
}

Просмотреть файл

@ -86,7 +86,7 @@ type discoveryGateway struct {
func createDiscoveryGateway(hc discovery.HealthCheck, topoServer *topo.Server, serv topo.SrvTopoServer, cell string, retryCount int) Gateway {
dg := &discoveryGateway{
hc: hc,
tsc: discovery.NewTabletStatsCacheDoNotSetListener(cell),
tsc: discovery.NewTabletStatsCacheDoNotSetListener(cell, topoServer.CellToRegionMapper()),
topoServer: topoServer,
srvTopoServer: serv,
localCell: cell,
@ -228,7 +228,7 @@ func (dg *discoveryGateway) withRetry(ctx context.Context, target *querypb.Targe
err = vterrors.New(vtrpcpb.Code_UNAVAILABLE, "no valid tablet")
break
}
shuffleTablets(tablets)
shuffleTablets(dg.localCell, tablets)
// skip tablets we tried before
var ts *discovery.TabletStats
@ -273,13 +273,51 @@ func (dg *discoveryGateway) withRetry(ctx context.Context, target *querypb.Targe
return NewShardError(err, target, tabletLastUsed, inTransaction)
}
func shuffleTablets(tablets []discovery.TabletStats) {
index := 0
func shuffleTablets(cell string, tablets []discovery.TabletStats) {
sameCell, diffCell, sameCellMax := 0, 0, -1
length := len(tablets)
for i := length - 1; i > 0; i-- {
index = rand.Intn(i + 1)
tablets[i], tablets[index] = tablets[index], tablets[i]
//move all same cell tablets to the front, this is O(n)
for {
sameCellMax = diffCell - 1
sameCell := nextTablet(cell, tablets, sameCell, length, true)
diffCell := nextTablet(cell, tablets, diffCell, length, false)
// either no more diffs or no more same cells should stop the iteration
if sameCell < 0 || diffCell < 0 {
break
}
if sameCell < diffCell {
// fast forward the `sameCell` lookup to `diffCell + 1`, `diffCell` unchanged
sameCell = diffCell + 1
} else {
// sameCell > diffCell, swap needed
tablets[sameCell], tablets[diffCell] = tablets[diffCell], tablets[sameCell]
sameCell++
diffCell++
}
}
//shuffle in same cell tablets
for i := sameCellMax; i > 0; i-- {
swap := rand.Intn(i + 1)
tablets[i], tablets[swap] = tablets[swap], tablets[i]
}
//shuffle in diff cell tablets
for i, diffCellMin := length-1, sameCellMax+1; i > diffCellMin; i-- {
swap := rand.Intn(i-sameCellMax) + diffCellMin
tablets[i], tablets[swap] = tablets[swap], tablets[i]
}
}
func nextTablet(cell string, tablets []discovery.TabletStats, offset, length int, sameCell bool) int {
for ; offset < length; offset++ {
if (tablets[offset].Tablet.Alias.Cell == cell) == sameCell {
return offset
}
}
return -1
}
func (dg *discoveryGateway) updateStats(target *querypb.Target, startTime time.Time, err error) {

Просмотреть файл

@ -127,6 +127,30 @@ func TestDiscoveryGatewayGetTablets(t *testing.T) {
}
}
func TestDiscoveryGatewayGetTabletsWithRegion(t *testing.T) {
keyspace := "ks"
shard := "0"
hc := discovery.NewFakeHealthCheck()
dg := createDiscoveryGateway(hc, nil, nil, "local", 2).(*discoveryGateway)
dg.tsc.UpdateCellsToRegions(map[string]string{
"local-west": "local",
"local-east": "local",
"local": "local",
"remote": "remote",
})
// replica should only use local ones
hc.Reset()
dg.tsc.ResetForTesting()
hc.AddTestTablet("remote", "1.1.1.1", 1001, keyspace, shard, topodatapb.TabletType_REPLICA, true, 10, nil)
ep1 := hc.AddTestTablet("local-west", "2.2.2.2", 1001, keyspace, shard, topodatapb.TabletType_REPLICA, true, 10, nil).Tablet()
ep2 := hc.AddTestTablet("local-east", "3.3.3.3", 1001, keyspace, shard, topodatapb.TabletType_REPLICA, true, 10, nil).Tablet()
tsl := dg.tsc.GetHealthyTabletStats(keyspace, shard, topodatapb.TabletType_REPLICA)
if len(tsl) != 2 || (!topo.TabletEquality(tsl[0].Tablet, ep1) && !topo.TabletEquality(tsl[0].Tablet, ep2)) {
t.Errorf("want %+v or %+v, got %+v", ep1, ep2, tsl)
}
}
func testDiscoveryGatewayGeneric(t *testing.T, streaming bool, f func(dg Gateway, target *querypb.Target) error) {
keyspace := "ks"
shard := "0"

Просмотреть файл

@ -131,7 +131,7 @@ func newBinlogPlayerController(ts *topo.Server, vtClientFactory func() binlogpla
// of whether the BinlogPlayerController is Start()'d or Stop()'d.
// Use Close() after Stop() to finally close them and free their resources.
healthCheck: healthCheck,
tabletStatsCache: discovery.NewTabletStatsCache(healthCheck, cell),
tabletStatsCache: discovery.NewTabletStatsCache(healthCheck, cell, ts.CellToRegionMapper()),
shardReplicationWatcher: discovery.NewShardReplicationWatcher(ts, healthCheck, cell, sourceShard.Keyspace, sourceShard.Shard, *healthCheckTopologyRefresh, discovery.DefaultTopoReadConcurrency),
}
}

Просмотреть файл

@ -374,7 +374,7 @@ func (scw *LegacySplitCloneWorker) findTargets(ctx context.Context) error {
// Initialize healthcheck and add destination shards to it.
scw.healthCheck = discovery.NewHealthCheck(*healthcheckRetryDelay, *healthCheckTimeout)
scw.tsc = discovery.NewTabletStatsCache(scw.healthCheck, scw.cell)
scw.tsc = discovery.NewTabletStatsCache(scw.healthCheck, scw.cell, scw.wr.TopoServer().CellToRegionMapper())
for _, si := range scw.destinationShards {
watcher := discovery.NewShardReplicationWatcher(scw.wr.TopoServer(), scw.healthCheck,
scw.cell, si.Keyspace(), si.ShardName(),

Просмотреть файл

@ -555,7 +555,7 @@ func (scw *SplitCloneWorker) init(ctx context.Context) error {
// Initialize healthcheck and add destination shards to it.
scw.healthCheck = discovery.NewHealthCheck(*healthcheckRetryDelay, *healthCheckTimeout)
scw.tsc = discovery.NewTabletStatsCacheDoNotSetListener(scw.cell)
scw.tsc = discovery.NewTabletStatsCacheDoNotSetListener(scw.cell, scw.wr.TopoServer().CellToRegionMapper())
// We set sendDownEvents=true because it's required by TabletStatsCache.
scw.healthCheck.SetListener(scw, true /* sendDownEvents */)

Просмотреть файл

@ -50,7 +50,7 @@ func FindHealthyRdonlyTablet(ctx context.Context, wr *wrangler.Wrangler, tsc *di
if tsc == nil {
// No healthcheck instance provided. Create one.
healthCheck := discovery.NewHealthCheck(*healthcheckRetryDelay, *healthCheckTimeout)
tsc = discovery.NewTabletStatsCache(healthCheck, cell)
tsc = discovery.NewTabletStatsCache(healthCheck, cell, wr.TopoServer().CellToRegionMapper())
watcher := discovery.NewShardReplicationWatcher(wr.TopoServer(), healthCheck, cell, keyspace, shard, *healthCheckTopologyRefresh, discovery.DefaultTopoReadConcurrency)
defer watcher.Stop()
defer healthCheck.Close()

Просмотреть файл

@ -507,7 +507,7 @@ func (wr *Wrangler) waitForDrainInCell(ctx context.Context, cell, keyspace, shar
// Create the healthheck module, with a cache.
hc := discovery.NewHealthCheck(healthcheckRetryDelay, healthCheckTimeout)
defer hc.Close()
tsc := discovery.NewTabletStatsCache(hc, cell)
tsc := discovery.NewTabletStatsCache(hc, cell, wr.TopoServer().CellToRegionMapper())
// Create a tablet watcher.
watcher := discovery.NewShardReplicationWatcher(wr.TopoServer(), hc, cell, keyspace, shard, healthCheckTopologyRefresh, discovery.DefaultTopoReadConcurrency)

Просмотреть файл

@ -323,4 +323,7 @@ message CellInfo {
// Root is the path to store data in. It is only used when talking
// to server_address.
string root = 2;
// Region is a group this cell belongs to
string region = 3;
}

Просмотреть файл

@ -20,9 +20,8 @@ DESCRIPTOR = _descriptor.FileDescriptor(
name='topodata.proto',
package='topodata',
syntax='proto3',
serialized_pb=_b('\n\x0etopodata.proto\x12\x08topodata\"&\n\x08KeyRange\x12\r\n\x05start\x18\x01 \x01(\x0c\x12\x0b\n\x03\x65nd\x18\x02 \x01(\x0c\"(\n\x0bTabletAlias\x12\x0c\n\x04\x63\x65ll\x18\x01 \x01(\t\x12\x0b\n\x03uid\x18\x02 \x01(\r\"\xb6\x03\n\x06Tablet\x12$\n\x05\x61lias\x18\x01 \x01(\x0b\x32\x15.topodata.TabletAlias\x12\x10\n\x08hostname\x18\x02 \x01(\t\x12/\n\x08port_map\x18\x04 \x03(\x0b\x32\x1d.topodata.Tablet.PortMapEntry\x12\x10\n\x08keyspace\x18\x05 \x01(\t\x12\r\n\x05shard\x18\x06 \x01(\t\x12%\n\tkey_range\x18\x07 \x01(\x0b\x32\x12.topodata.KeyRange\x12\"\n\x04type\x18\x08 \x01(\x0e\x32\x14.topodata.TabletType\x12\x18\n\x10\x64\x62_name_override\x18\t \x01(\t\x12(\n\x04tags\x18\n \x03(\x0b\x32\x1a.topodata.Tablet.TagsEntry\x12\x16\n\x0emysql_hostname\x18\x0c \x01(\t\x12\x12\n\nmysql_port\x18\r \x01(\x05\x1a.\n\x0cPortMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05:\x02\x38\x01\x1a+\n\tTagsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01J\x04\x08\x03\x10\x04J\x04\x08\x0b\x10\x0c\"\xcb\x04\n\x05Shard\x12+\n\x0cmaster_alias\x18\x01 \x01(\x0b\x32\x15.topodata.TabletAlias\x12%\n\tkey_range\x18\x02 \x01(\x0b\x32\x12.topodata.KeyRange\x12\x30\n\x0cserved_types\x18\x03 \x03(\x0b\x32\x1a.topodata.Shard.ServedType\x12\x32\n\rsource_shards\x18\x04 \x03(\x0b\x32\x1b.topodata.Shard.SourceShard\x12\r\n\x05\x63\x65lls\x18\x05 \x03(\t\x12\x36\n\x0ftablet_controls\x18\x06 \x03(\x0b\x32\x1d.topodata.Shard.TabletControl\x1a\x46\n\nServedType\x12)\n\x0btablet_type\x18\x01 \x01(\x0e\x32\x14.topodata.TabletType\x12\r\n\x05\x63\x65lls\x18\x02 \x03(\t\x1ar\n\x0bSourceShard\x12\x0b\n\x03uid\x18\x01 \x01(\r\x12\x10\n\x08keyspace\x18\x02 \x01(\t\x12\r\n\x05shard\x18\x03 \x01(\t\x12%\n\tkey_range\x18\x04 \x01(\x0b\x32\x12.topodata.KeyRange\x12\x0e\n\x06tables\x18\x05 \x03(\t\x1a\x84\x01\n\rTabletControl\x12)\n\x0btablet_type\x18\x01 \x01(\x0e\x32\x14.topodata.TabletType\x12\r\n\x05\x63\x65lls\x18\x02 \x03(\t\x12\x1d\n\x15\x64isable_query_service\x18\x03 \x01(\x08\x12\x1a\n\x12\x62lacklisted_tables\x18\x04 \x03(\t\"\xf5\x01\n\x08Keyspace\x12\x1c\n\x14sharding_column_name\x18\x01 \x01(\t\x12\x36\n\x14sharding_column_type\x18\x02 \x01(\x0e\x32\x18.topodata.KeyspaceIdType\x12\x33\n\x0cserved_froms\x18\x04 \x03(\x0b\x32\x1d.topodata.Keyspace.ServedFrom\x1aX\n\nServedFrom\x12)\n\x0btablet_type\x18\x01 \x01(\x0e\x32\x14.topodata.TabletType\x12\r\n\x05\x63\x65lls\x18\x02 \x03(\t\x12\x10\n\x08keyspace\x18\x03 \x01(\tJ\x04\x08\x03\x10\x04\"w\n\x10ShardReplication\x12.\n\x05nodes\x18\x01 \x03(\x0b\x32\x1f.topodata.ShardReplication.Node\x1a\x33\n\x04Node\x12+\n\x0ctablet_alias\x18\x01 \x01(\x0b\x32\x15.topodata.TabletAlias\"E\n\x0eShardReference\x12\x0c\n\x04name\x18\x01 \x01(\t\x12%\n\tkey_range\x18\x02 \x01(\x0b\x32\x12.topodata.KeyRange\"\x9c\x03\n\x0bSrvKeyspace\x12;\n\npartitions\x18\x01 \x03(\x0b\x32\'.topodata.SrvKeyspace.KeyspacePartition\x12\x1c\n\x14sharding_column_name\x18\x02 \x01(\t\x12\x36\n\x14sharding_column_type\x18\x03 \x01(\x0e\x32\x18.topodata.KeyspaceIdType\x12\x35\n\x0bserved_from\x18\x04 \x03(\x0b\x32 .topodata.SrvKeyspace.ServedFrom\x1ar\n\x11KeyspacePartition\x12)\n\x0bserved_type\x18\x01 \x01(\x0e\x32\x14.topodata.TabletType\x12\x32\n\x10shard_references\x18\x02 \x03(\x0b\x32\x18.topodata.ShardReference\x1aI\n\nServedFrom\x12)\n\x0btablet_type\x18\x01 \x01(\x0e\x32\x14.topodata.TabletType\x12\x10\n\x08keyspace\x18\x02 \x01(\tJ\x04\x08\x05\x10\x06\"0\n\x08\x43\x65llInfo\x12\x16\n\x0eserver_address\x18\x01 \x01(\t\x12\x0c\n\x04root\x18\x02 \x01(\t*2\n\x0eKeyspaceIdType\x12\t\n\x05UNSET\x10\x00\x12\n\n\x06UINT64\x10\x01\x12\t\n\x05\x42YTES\x10\x02*\x90\x01\n\nTabletType\x12\x0b\n\x07UNKNOWN\x10\x00\x12\n\n\x06MASTER\x10\x01\x12\x0b\n\x07REPLICA\x10\x02\x12\n\n\x06RDONLY\x10\x03\x12\t\n\x05\x42\x41TCH\x10\x03\x12\t\n\x05SPARE\x10\x04\x12\x10\n\x0c\x45XPERIMENTAL\x10\x05\x12\n\n\x06\x42\x41\x43KUP\x10\x06\x12\x0b\n\x07RESTORE\x10\x07\x12\x0b\n\x07\x44RAINED\x10\x08\x1a\x02\x10\x01\x42\x11\n\x0fio.vitess.protob\x06proto3')
serialized_pb=_b('\n\x0etopodata.proto\x12\x08topodata\"&\n\x08KeyRange\x12\r\n\x05start\x18\x01 \x01(\x0c\x12\x0b\n\x03\x65nd\x18\x02 \x01(\x0c\"(\n\x0bTabletAlias\x12\x0c\n\x04\x63\x65ll\x18\x01 \x01(\t\x12\x0b\n\x03uid\x18\x02 \x01(\r\"\xb6\x03\n\x06Tablet\x12$\n\x05\x61lias\x18\x01 \x01(\x0b\x32\x15.topodata.TabletAlias\x12\x10\n\x08hostname\x18\x02 \x01(\t\x12/\n\x08port_map\x18\x04 \x03(\x0b\x32\x1d.topodata.Tablet.PortMapEntry\x12\x10\n\x08keyspace\x18\x05 \x01(\t\x12\r\n\x05shard\x18\x06 \x01(\t\x12%\n\tkey_range\x18\x07 \x01(\x0b\x32\x12.topodata.KeyRange\x12\"\n\x04type\x18\x08 \x01(\x0e\x32\x14.topodata.TabletType\x12\x18\n\x10\x64\x62_name_override\x18\t \x01(\t\x12(\n\x04tags\x18\n \x03(\x0b\x32\x1a.topodata.Tablet.TagsEntry\x12\x16\n\x0emysql_hostname\x18\x0c \x01(\t\x12\x12\n\nmysql_port\x18\r \x01(\x05\x1a.\n\x0cPortMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05:\x02\x38\x01\x1a+\n\tTagsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01J\x04\x08\x03\x10\x04J\x04\x08\x0b\x10\x0c\"\xcb\x04\n\x05Shard\x12+\n\x0cmaster_alias\x18\x01 \x01(\x0b\x32\x15.topodata.TabletAlias\x12%\n\tkey_range\x18\x02 \x01(\x0b\x32\x12.topodata.KeyRange\x12\x30\n\x0cserved_types\x18\x03 \x03(\x0b\x32\x1a.topodata.Shard.ServedType\x12\x32\n\rsource_shards\x18\x04 \x03(\x0b\x32\x1b.topodata.Shard.SourceShard\x12\r\n\x05\x63\x65lls\x18\x05 \x03(\t\x12\x36\n\x0ftablet_controls\x18\x06 \x03(\x0b\x32\x1d.topodata.Shard.TabletControl\x1a\x46\n\nServedType\x12)\n\x0btablet_type\x18\x01 \x01(\x0e\x32\x14.topodata.TabletType\x12\r\n\x05\x63\x65lls\x18\x02 \x03(\t\x1ar\n\x0bSourceShard\x12\x0b\n\x03uid\x18\x01 \x01(\r\x12\x10\n\x08keyspace\x18\x02 \x01(\t\x12\r\n\x05shard\x18\x03 \x01(\t\x12%\n\tkey_range\x18\x04 \x01(\x0b\x32\x12.topodata.KeyRange\x12\x0e\n\x06tables\x18\x05 \x03(\t\x1a\x84\x01\n\rTabletControl\x12)\n\x0btablet_type\x18\x01 \x01(\x0e\x32\x14.topodata.TabletType\x12\r\n\x05\x63\x65lls\x18\x02 \x03(\t\x12\x1d\n\x15\x64isable_query_service\x18\x03 \x01(\x08\x12\x1a\n\x12\x62lacklisted_tables\x18\x04 \x03(\t\"\xf5\x01\n\x08Keyspace\x12\x1c\n\x14sharding_column_name\x18\x01 \x01(\t\x12\x36\n\x14sharding_column_type\x18\x02 \x01(\x0e\x32\x18.topodata.KeyspaceIdType\x12\x33\n\x0cserved_froms\x18\x04 \x03(\x0b\x32\x1d.topodata.Keyspace.ServedFrom\x1aX\n\nServedFrom\x12)\n\x0btablet_type\x18\x01 \x01(\x0e\x32\x14.topodata.TabletType\x12\r\n\x05\x63\x65lls\x18\x02 \x03(\t\x12\x10\n\x08keyspace\x18\x03 \x01(\tJ\x04\x08\x03\x10\x04\"w\n\x10ShardReplication\x12.\n\x05nodes\x18\x01 \x03(\x0b\x32\x1f.topodata.ShardReplication.Node\x1a\x33\n\x04Node\x12+\n\x0ctablet_alias\x18\x01 \x01(\x0b\x32\x15.topodata.TabletAlias\"E\n\x0eShardReference\x12\x0c\n\x04name\x18\x01 \x01(\t\x12%\n\tkey_range\x18\x02 \x01(\x0b\x32\x12.topodata.KeyRange\"\x9c\x03\n\x0bSrvKeyspace\x12;\n\npartitions\x18\x01 \x03(\x0b\x32\'.topodata.SrvKeyspace.KeyspacePartition\x12\x1c\n\x14sharding_column_name\x18\x02 \x01(\t\x12\x36\n\x14sharding_column_type\x18\x03 \x01(\x0e\x32\x18.topodata.KeyspaceIdType\x12\x35\n\x0bserved_from\x18\x04 \x03(\x0b\x32 .topodata.SrvKeyspace.ServedFrom\x1ar\n\x11KeyspacePartition\x12)\n\x0bserved_type\x18\x01 \x01(\x0e\x32\x14.topodata.TabletType\x12\x32\n\x10shard_references\x18\x02 \x03(\x0b\x32\x18.topodata.ShardReference\x1aI\n\nServedFrom\x12)\n\x0btablet_type\x18\x01 \x01(\x0e\x32\x14.topodata.TabletType\x12\x10\n\x08keyspace\x18\x02 \x01(\tJ\x04\x08\x05\x10\x06\"@\n\x08\x43\x65llInfo\x12\x16\n\x0eserver_address\x18\x01 \x01(\t\x12\x0c\n\x04root\x18\x02 \x01(\t\x12\x0e\n\x06region\x18\x03 \x01(\t*2\n\x0eKeyspaceIdType\x12\t\n\x05UNSET\x10\x00\x12\n\n\x06UINT64\x10\x01\x12\t\n\x05\x42YTES\x10\x02*\x90\x01\n\nTabletType\x12\x0b\n\x07UNKNOWN\x10\x00\x12\n\n\x06MASTER\x10\x01\x12\x0b\n\x07REPLICA\x10\x02\x12\n\n\x06RDONLY\x10\x03\x12\t\n\x05\x42\x41TCH\x10\x03\x12\t\n\x05SPARE\x10\x04\x12\x10\n\x0c\x45XPERIMENTAL\x10\x05\x12\n\n\x06\x42\x41\x43KUP\x10\x06\x12\x0b\n\x07RESTORE\x10\x07\x12\x0b\n\x07\x44RAINED\x10\x08\x1a\x02\x10\x01\x42\x11\n\x0fio.vitess.protob\x06proto3')
)
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
_KEYSPACEIDTYPE = _descriptor.EnumDescriptor(
name='KeyspaceIdType',
@ -45,8 +44,8 @@ _KEYSPACEIDTYPE = _descriptor.EnumDescriptor(
],
containing_type=None,
options=None,
serialized_start=2046,
serialized_end=2096,
serialized_start=2062,
serialized_end=2112,
)
_sym_db.RegisterEnumDescriptor(_KEYSPACEIDTYPE)
@ -100,8 +99,8 @@ _TABLETTYPE = _descriptor.EnumDescriptor(
],
containing_type=None,
options=_descriptor._ParseOptions(descriptor_pb2.EnumOptions(), _b('\020\001')),
serialized_start=2099,
serialized_end=2243,
serialized_start=2115,
serialized_end=2259,
)
_sym_db.RegisterEnumDescriptor(_TABLETTYPE)
@ -920,6 +919,13 @@ _CELLINFO = _descriptor.Descriptor(
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
_descriptor.FieldDescriptor(
name='region', full_name='topodata.CellInfo.region', index=2,
number=3, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
],
extensions=[
],
@ -933,7 +939,7 @@ _CELLINFO = _descriptor.Descriptor(
oneofs=[
],
serialized_start=1996,
serialized_end=2044,
serialized_end=2060,
)
_TABLET_PORTMAPENTRY.containing_type = _TABLET
@ -981,6 +987,7 @@ DESCRIPTOR.message_types_by_name['SrvKeyspace'] = _SRVKEYSPACE
DESCRIPTOR.message_types_by_name['CellInfo'] = _CELLINFO
DESCRIPTOR.enum_types_by_name['KeyspaceIdType'] = _KEYSPACEIDTYPE
DESCRIPTOR.enum_types_by_name['TabletType'] = _TABLETTYPE
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
KeyRange = _reflection.GeneratedProtocolMessageType('KeyRange', (_message.Message,), dict(
DESCRIPTOR = _KEYRANGE,
@ -1126,9 +1133,4 @@ _TABLET_PORTMAPENTRY.has_options = True
_TABLET_PORTMAPENTRY._options = _descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001'))
_TABLET_TAGSENTRY.has_options = True
_TABLET_TAGSENTRY._options = _descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001'))
import grpc
from grpc.beta import implementations as beta_implementations
from grpc.beta import interfaces as beta_interfaces
from grpc.framework.common import cardinality
from grpc.framework.interfaces.face import utilities as face_utilities
# @@protoc_insertion_point(module_scope)