зеркало из https://github.com/github/vitess-gh.git
Now using ShardReferences fields in a few places instead of
Shards in the Keyspace.Partitions map.
This commit is contained in:
Родитель
e99a7bf79f
Коммит
16807a416e
|
@ -1,19 +1,13 @@
|
|||
{
|
||||
"/zk/testing/vt/ns/test_keyspace": {
|
||||
"Shards": [
|
||||
"ShardReferences": [
|
||||
{
|
||||
"KeyRange": {
|
||||
"Start": "",
|
||||
"End": ""
|
||||
},
|
||||
"AddrsByType": null,
|
||||
"ReadOnly": false
|
||||
"Name": "0"
|
||||
}
|
||||
],
|
||||
"TabletTypes": [
|
||||
"rdonly",
|
||||
"replica",
|
||||
"master"
|
||||
]
|
||||
},
|
||||
"/zk/testing": {
|
||||
|
|
|
@ -75,19 +75,16 @@ func getSrvKeyspace(rpcClient *rpcplus.Client, cell, keyspace string, verbose bo
|
|||
}
|
||||
if verbose {
|
||||
tabletTypes := make([]string, 0, len(reply.Partitions))
|
||||
for t, _ := range reply.Partitions {
|
||||
for t := range reply.Partitions {
|
||||
tabletTypes = append(tabletTypes, string(t))
|
||||
}
|
||||
sort.Strings(tabletTypes)
|
||||
for _, t := range tabletTypes {
|
||||
println(fmt.Sprintf("Partitions[%v] =", t))
|
||||
for i, s := range reply.Partitions[topo.TabletType(t)].Shards {
|
||||
println(fmt.Sprintf(" Shards[%v]=%v", i, s.KeyRange.String()))
|
||||
for i, s := range reply.Partitions[topo.TabletType(t)].ShardReferences {
|
||||
println(fmt.Sprintf(" ShardReferences[%v]=%v", i, s.KeyRange.String()))
|
||||
}
|
||||
}
|
||||
for i, t := range reply.TabletTypes {
|
||||
println(fmt.Sprintf("TabletTypes[%v] = %v", i, t))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -124,15 +124,15 @@ func (sc *ShardedConn) readKeyspace() error {
|
|||
return fmt.Errorf("vt: GetSrvKeyspace failed %v", err)
|
||||
}
|
||||
|
||||
sc.conns = make([]*tablet.VtConn, len(sc.srvKeyspace.Partitions[sc.tabletType].Shards))
|
||||
sc.shardMaxKeys = make([]key.KeyspaceId, len(sc.srvKeyspace.Partitions[sc.tabletType].Shards))
|
||||
sc.conns = make([]*tablet.VtConn, len(sc.srvKeyspace.Partitions[sc.tabletType].ShardReferences))
|
||||
sc.shardMaxKeys = make([]key.KeyspaceId, len(sc.srvKeyspace.Partitions[sc.tabletType].ShardReferences))
|
||||
|
||||
for i, srvShard := range sc.srvKeyspace.Partitions[sc.tabletType].Shards {
|
||||
sc.shardMaxKeys[i] = srvShard.KeyRange.End
|
||||
for i, shardReference := range sc.srvKeyspace.Partitions[sc.tabletType].ShardReferences {
|
||||
sc.shardMaxKeys[i] = shardReference.KeyRange.End
|
||||
}
|
||||
|
||||
// Disabled for now.
|
||||
// sc.connByType = make([]map[string]*Conn, len(sc.srvKeyspace.Shards))
|
||||
// sc.connByType = make([]map[string]*Conn, len(sc.srvKeyspace.ShardReferences))
|
||||
// for i := 0; i < len(sc.connByType); i++ {
|
||||
// sc.connByType[i] = make(map[string]*Conn, 8)
|
||||
// }
|
||||
|
@ -526,13 +526,8 @@ func (sc *ShardedConn) ExecuteBatch(queryList []ClientQuery, keyVal interface{})
|
|||
*/
|
||||
|
||||
func (sc *ShardedConn) dial(shardIdx int) (conn *tablet.VtConn, err error) {
|
||||
srvShard := &(sc.srvKeyspace.Partitions[sc.tabletType].Shards[shardIdx])
|
||||
shard := fmt.Sprintf("%v-%v", srvShard.KeyRange.Start.Hex(), srvShard.KeyRange.End.Hex())
|
||||
// Hack to handle non-range based shards.
|
||||
if !srvShard.KeyRange.IsPartial() {
|
||||
shard = fmt.Sprintf("%v", shardIdx)
|
||||
}
|
||||
addrs, err := sc.ts.GetEndPoints(sc.cell, sc.keyspace, shard, sc.tabletType)
|
||||
shardReference := &(sc.srvKeyspace.Partitions[sc.tabletType].ShardReferences[shardIdx])
|
||||
addrs, err := sc.ts.GetEndPoints(sc.cell, sc.keyspace, shardReference.Name, sc.tabletType)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("vt: GetEndPoints failed %v", err)
|
||||
}
|
||||
|
@ -544,7 +539,7 @@ func (sc *ShardedConn) dial(shardIdx int) (conn *tablet.VtConn, err error) {
|
|||
|
||||
// Try to connect to any address.
|
||||
for _, srv := range srvs {
|
||||
name := topo.SrvAddr(srv) + "/" + sc.keyspace + "/" + shard
|
||||
name := topo.SrvAddr(srv) + "/" + sc.keyspace + "/" + shardReference.Name
|
||||
conn, err = tablet.DialVtdb(name, sc.stream, tablet.DefaultTimeout)
|
||||
if err == nil {
|
||||
return conn, nil
|
||||
|
|
|
@ -268,7 +268,7 @@ func DbServingGraph(ts topo.Server, cell string) (servingGraph *ServingGraph) {
|
|||
if !ok {
|
||||
continue
|
||||
}
|
||||
for _, srvShard := range kp.Shards {
|
||||
for _, srvShard := range kp.ShardReferences {
|
||||
shard := srvShard.Name
|
||||
if displayedShards[shard] {
|
||||
continue
|
||||
|
@ -278,7 +278,6 @@ func DbServingGraph(ts topo.Server, cell string) (servingGraph *ServingGraph) {
|
|||
sn := &ShardNodes{
|
||||
Name: shard,
|
||||
TabletNodes: make(TabletNodesByType),
|
||||
ServedTypes: srvShard.ServedTypes,
|
||||
}
|
||||
kn.ShardNodes = append(kn.ShardNodes, sn)
|
||||
wg.Add(1)
|
||||
|
|
|
@ -171,26 +171,24 @@ func createShardedSrvKeyspace(shardSpec, servedFromKeyspace string) (*topo.SrvKe
|
|||
return nil, err
|
||||
}
|
||||
allTabletTypes := []topo.TabletType{topo.TYPE_MASTER, topo.TYPE_REPLICA, topo.TYPE_RDONLY}
|
||||
shards := make([]topo.SrvShard, 0, len(shardKrArray))
|
||||
shards := make([]topo.ShardReference, 0, len(shardKrArray))
|
||||
for i := 0; i < len(shardKrArray); i++ {
|
||||
shard := topo.SrvShard{
|
||||
Name: getKeyRangeName(shardKrArray[i]),
|
||||
KeyRange: shardKrArray[i],
|
||||
ServedTypes: allTabletTypes,
|
||||
TabletTypes: allTabletTypes,
|
||||
shard := topo.ShardReference{
|
||||
Name: getKeyRangeName(shardKrArray[i]),
|
||||
KeyRange: shardKrArray[i],
|
||||
}
|
||||
shards = append(shards, shard)
|
||||
}
|
||||
shardedSrvKeyspace := &topo.SrvKeyspace{
|
||||
Partitions: map[topo.TabletType]*topo.KeyspacePartition{
|
||||
topo.TYPE_MASTER: &topo.KeyspacePartition{
|
||||
Shards: shards,
|
||||
ShardReferences: shards,
|
||||
},
|
||||
topo.TYPE_REPLICA: &topo.KeyspacePartition{
|
||||
Shards: shards,
|
||||
ShardReferences: shards,
|
||||
},
|
||||
topo.TYPE_RDONLY: &topo.KeyspacePartition{
|
||||
Shards: shards,
|
||||
ShardReferences: shards,
|
||||
},
|
||||
},
|
||||
TabletTypes: allTabletTypes,
|
||||
|
@ -205,24 +203,21 @@ func createShardedSrvKeyspace(shardSpec, servedFromKeyspace string) (*topo.SrvKe
|
|||
}
|
||||
|
||||
func createUnshardedKeyspace() (*topo.SrvKeyspace, error) {
|
||||
allTabletTypes := []topo.TabletType{topo.TYPE_MASTER, topo.TYPE_REPLICA, topo.TYPE_RDONLY}
|
||||
shard := topo.SrvShard{
|
||||
Name: "0",
|
||||
KeyRange: key.KeyRange{Start: "", End: ""},
|
||||
ServedTypes: allTabletTypes,
|
||||
TabletTypes: allTabletTypes,
|
||||
shard := topo.ShardReference{
|
||||
Name: "0",
|
||||
KeyRange: key.KeyRange{Start: "", End: ""},
|
||||
}
|
||||
|
||||
unshardedSrvKeyspace := &topo.SrvKeyspace{
|
||||
Partitions: map[topo.TabletType]*topo.KeyspacePartition{
|
||||
topo.TYPE_MASTER: &topo.KeyspacePartition{
|
||||
Shards: []topo.SrvShard{shard},
|
||||
ShardReferences: []topo.ShardReference{shard},
|
||||
},
|
||||
topo.TYPE_REPLICA: &topo.KeyspacePartition{
|
||||
Shards: []topo.SrvShard{shard},
|
||||
ShardReferences: []topo.ShardReference{shard},
|
||||
},
|
||||
topo.TYPE_RDONLY: &topo.KeyspacePartition{
|
||||
Shards: []topo.SrvShard{shard},
|
||||
ShardReferences: []topo.ShardReference{shard},
|
||||
},
|
||||
},
|
||||
TabletTypes: []topo.TabletType{topo.TYPE_MASTER},
|
||||
|
|
|
@ -99,7 +99,7 @@ func (stc *ScatterConn) InitializeConnections(ctx context.Context) error {
|
|||
errRecorder.RecordError(fmt.Errorf("%v.%v is not in SrvKeyspace.Partitions", keyspace, string(tabletType)))
|
||||
continue
|
||||
}
|
||||
for _, shard := range ksPartition.Shards {
|
||||
for _, shard := range ksPartition.ShardReferences {
|
||||
wg.Add(1)
|
||||
go func(shardName string, tabletType topo.TabletType) {
|
||||
defer wg.Done()
|
||||
|
|
|
@ -511,7 +511,7 @@ func (st *SrvKeyspaceCacheStatus) StatusAsHTML() template.HTML {
|
|||
result := "<b>Partitions:</b><br>"
|
||||
for tabletType, keyspacePartition := range st.Value.Partitions {
|
||||
result += " <b>" + string(tabletType) + "</b>"
|
||||
for _, shard := range keyspacePartition.Shards {
|
||||
for _, shard := range keyspacePartition.ShardReferences {
|
||||
result += " " + shard.Name
|
||||
}
|
||||
result += "<br>"
|
||||
|
|
|
@ -33,7 +33,7 @@ func mapKeyspaceIdsToShards(ctx context.Context, topoServ SrvTopoServer, cell, k
|
|||
return keyspace, res, nil
|
||||
}
|
||||
|
||||
func getKeyspaceShards(ctx context.Context, topoServ SrvTopoServer, cell, keyspace string, tabletType topo.TabletType) (string, []topo.SrvShard, error) {
|
||||
func getKeyspaceShards(ctx context.Context, topoServ SrvTopoServer, cell, keyspace string, tabletType topo.TabletType) (string, []topo.ShardReference, error) {
|
||||
srvKeyspace, err := topoServ.GetSrvKeyspace(ctx, cell, keyspace)
|
||||
if err != nil {
|
||||
return "", nil, fmt.Errorf("keyspace %v fetch error: %v", keyspace, err)
|
||||
|
@ -52,17 +52,17 @@ func getKeyspaceShards(ctx context.Context, topoServ SrvTopoServer, cell, keyspa
|
|||
if !ok {
|
||||
return "", nil, fmt.Errorf("No partition found for tabletType %v in keyspace %v", tabletType, keyspace)
|
||||
}
|
||||
return keyspace, partition.Shards, nil
|
||||
return keyspace, partition.ShardReferences, nil
|
||||
}
|
||||
|
||||
func getShardForKeyspaceId(allShards []topo.SrvShard, keyspaceId key.KeyspaceId) (string, error) {
|
||||
func getShardForKeyspaceId(allShards []topo.ShardReference, keyspaceId key.KeyspaceId) (string, error) {
|
||||
if len(allShards) == 0 {
|
||||
return "", fmt.Errorf("No shards found for this tabletType")
|
||||
}
|
||||
|
||||
for _, srvShard := range allShards {
|
||||
if srvShard.KeyRange.Contains(keyspaceId) {
|
||||
return srvShard.Name, nil
|
||||
for _, shardReference := range allShards {
|
||||
if shardReference.KeyRange.Contains(keyspaceId) {
|
||||
return shardReference.Name, nil
|
||||
}
|
||||
}
|
||||
return "", fmt.Errorf("KeyspaceId %v didn't match any shards %+v", keyspaceId, allShards)
|
||||
|
@ -110,7 +110,7 @@ func mapKeyRangesToShards(ctx context.Context, topoServ SrvTopoServer, cell, key
|
|||
}
|
||||
|
||||
// This maps a list of keyranges to shard names.
|
||||
func resolveKeyRangeToShards(allShards []topo.SrvShard, kr key.KeyRange) ([]string, error) {
|
||||
func resolveKeyRangeToShards(allShards []topo.ShardReference, kr key.KeyRange) ([]string, error) {
|
||||
shards := make([]string, 0, 1)
|
||||
|
||||
if !kr.IsPartial() {
|
||||
|
|
|
@ -255,7 +255,7 @@ func TestFromFile(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Errorf("conn.Get(/zk/testing/vt/ns/test_keyspace): %v", err)
|
||||
}
|
||||
if !strings.Contains(data, "TabletTypes") {
|
||||
if !strings.Contains(data, "ShardReferences") {
|
||||
t.Errorf("conn.Get(/zk/testing/vt/ns/test_keyspace) returned bad value: %v", data)
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class Keyspace(object):
|
|||
if not db_type:
|
||||
raise ValueError('db_type is not set')
|
||||
try:
|
||||
return self.partitions[db_type]['Shards']
|
||||
return self.partitions[db_type]['ShardReferences']
|
||||
except KeyError:
|
||||
return []
|
||||
|
||||
|
|
|
@ -275,8 +275,8 @@ class FakeZkOccConnection(object):
|
|||
result = json.loads(data)
|
||||
# for convenience, we store the KeyRange as hex, but we need to
|
||||
# decode it here, as BSON RPC sends it as binary.
|
||||
if 'Shards' in result:
|
||||
for shard in result['Shards']:
|
||||
if 'ShardReferences' in result:
|
||||
for shard in result['ShardReferences']:
|
||||
shard['KeyRange']['Start'] = shard['KeyRange']['Start'].decode('hex')
|
||||
shard['KeyRange']['End'] = shard['KeyRange']['End'].decode('hex')
|
||||
return result
|
||||
|
|
|
@ -160,8 +160,8 @@ def start_tablets():
|
|||
if ks_type == shard_constants.RANGE_SHARDED:
|
||||
utils.check_srv_keyspace('test_nj', ks_name,
|
||||
'Partitions(master): -80 80-\n' +
|
||||
'Partitions(replica): -80 80-\n' +
|
||||
'TabletTypes: master,replica')
|
||||
'Partitions(rdonly): -80 80-\n' +
|
||||
'Partitions(replica): -80 80-\n')
|
||||
|
||||
|
||||
def get_connection(user=None, password=None):
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
{
|
||||
"/zk/testing/vt/ns/test_keyspace": {
|
||||
"Shards": [
|
||||
"ShardReferences": [
|
||||
{
|
||||
"KeyRange": {
|
||||
"Start": "c0",
|
||||
"End": "d0"
|
||||
},
|
||||
"AddrsByType": null,
|
||||
"ReadOnly": false
|
||||
"Name": "c0-d0"
|
||||
}
|
||||
],
|
||||
"TabletTypes": [
|
||||
|
|
|
@ -342,8 +342,7 @@ index by_msg (msg)
|
|||
utils.check_srv_keyspace('test_nj', 'test_keyspace',
|
||||
'Partitions(master): -\n' +
|
||||
'Partitions(rdonly): -\n' +
|
||||
'Partitions(replica): -\n' +
|
||||
'TabletTypes: master,rdonly,replica',
|
||||
'Partitions(replica): -\n',
|
||||
keyspace_id_type=keyspace_id_type)
|
||||
|
||||
# we need to create the schema, and the worker will do data copying
|
||||
|
@ -418,8 +417,7 @@ index by_msg (msg)
|
|||
utils.check_srv_keyspace('test_nj', 'test_keyspace',
|
||||
'Partitions(master): -\n' +
|
||||
'Partitions(rdonly): -80 80-\n' +
|
||||
'Partitions(replica): -\n' +
|
||||
'TabletTypes: master,rdonly,replica',
|
||||
'Partitions(replica): -\n',
|
||||
keyspace_id_type=keyspace_id_type)
|
||||
|
||||
# then serve replica from the split shards
|
||||
|
@ -431,8 +429,7 @@ index by_msg (msg)
|
|||
utils.check_srv_keyspace('test_nj', 'test_keyspace',
|
||||
'Partitions(master): -\n' +
|
||||
'Partitions(rdonly): -80 80-\n' +
|
||||
'Partitions(replica): -80 80-\n' +
|
||||
'TabletTypes: master,rdonly,replica',
|
||||
'Partitions(replica): -80 80-\n',
|
||||
keyspace_id_type=keyspace_id_type)
|
||||
|
||||
# move replica back and forth
|
||||
|
@ -444,8 +441,7 @@ index by_msg (msg)
|
|||
utils.check_srv_keyspace('test_nj', 'test_keyspace',
|
||||
'Partitions(master): -\n' +
|
||||
'Partitions(rdonly): -80 80-\n' +
|
||||
'Partitions(replica): -\n' +
|
||||
'TabletTypes: master,rdonly,replica',
|
||||
'Partitions(replica): -\n',
|
||||
keyspace_id_type=keyspace_id_type)
|
||||
|
||||
utils.run_vtctl(['MigrateServedTypes', 'test_keyspace/0', 'replica'],
|
||||
|
@ -456,8 +452,7 @@ index by_msg (msg)
|
|||
utils.check_srv_keyspace('test_nj', 'test_keyspace',
|
||||
'Partitions(master): -\n' +
|
||||
'Partitions(rdonly): -80 80-\n' +
|
||||
'Partitions(replica): -80 80-\n' +
|
||||
'TabletTypes: master,rdonly,replica',
|
||||
'Partitions(replica): -80 80-\n',
|
||||
keyspace_id_type=keyspace_id_type)
|
||||
|
||||
|
||||
|
@ -467,8 +462,7 @@ index by_msg (msg)
|
|||
utils.check_srv_keyspace('test_nj', 'test_keyspace',
|
||||
'Partitions(master): -80 80-\n' +
|
||||
'Partitions(rdonly): -80 80-\n' +
|
||||
'Partitions(replica): -80 80-\n' +
|
||||
'TabletTypes: master,rdonly,replica',
|
||||
'Partitions(replica): -80 80-\n',
|
||||
keyspace_id_type=keyspace_id_type)
|
||||
|
||||
# check the binlog players are gone now
|
||||
|
|
|
@ -145,8 +145,8 @@ def setup_sharded_keyspace():
|
|||
|
||||
utils.check_srv_keyspace('test_nj', SHARDED_KEYSPACE,
|
||||
'Partitions(master): -80 80-\n' +
|
||||
'Partitions(replica): -80 80-\n' +
|
||||
'TabletTypes: master,replica')
|
||||
'Partitions(rdonly): -80 80-\n' +
|
||||
'Partitions(replica): -80 80-\n')
|
||||
|
||||
|
||||
def setup_unsharded_keyspace():
|
||||
|
@ -174,8 +174,8 @@ def setup_unsharded_keyspace():
|
|||
|
||||
utils.check_srv_keyspace('test_nj', UNSHARDED_KEYSPACE,
|
||||
'Partitions(master): -\n' +
|
||||
'Partitions(replica): -\n' +
|
||||
'TabletTypes: master,replica')
|
||||
'Partitions(rdonly): -\n' +
|
||||
'Partitions(replica): -\n')
|
||||
|
||||
|
||||
ALL_DB_TYPES = ['master', 'replica']
|
||||
|
|
|
@ -515,8 +515,7 @@ primary key (name)
|
|||
utils.check_srv_keyspace('test_nj', 'test_keyspace',
|
||||
'Partitions(master): -80 80-\n' +
|
||||
'Partitions(rdonly): -80 80-\n' +
|
||||
'Partitions(replica): -80 80-\n' +
|
||||
'TabletTypes: master,rdonly,replica',
|
||||
'Partitions(replica): -80 80-\n',
|
||||
keyspace_id_type=keyspace_id_type)
|
||||
|
||||
# the worker will do everything. We test with source_reader_count=10
|
||||
|
@ -633,12 +632,12 @@ primary key (name)
|
|||
utils.check_srv_keyspace('test_nj', 'test_keyspace',
|
||||
'Partitions(master): -80 80-\n' +
|
||||
'Partitions(rdonly): -80 80-c0 c0-\n' +
|
||||
'Partitions(replica): -80 80-\n' +
|
||||
'TabletTypes: master,rdonly,replica',
|
||||
'Partitions(replica): -80 80-\n',
|
||||
keyspace_id_type=keyspace_id_type)
|
||||
utils.check_srv_keyspace('test_ny', 'test_keyspace',
|
||||
'Partitions(master): -80 80-\n' +
|
||||
'Partitions(rdonly): -80 80-\n' +
|
||||
'TabletTypes: rdonly',
|
||||
'Partitions(replica): -80 80-\n',
|
||||
keyspace_id_type=keyspace_id_type)
|
||||
utils.check_tablet_query_service(self, shard_0_ny_rdonly, True, False)
|
||||
utils.check_tablet_query_service(self, shard_1_ny_rdonly, True, False)
|
||||
|
@ -650,12 +649,12 @@ primary key (name)
|
|||
utils.check_srv_keyspace('test_nj', 'test_keyspace',
|
||||
'Partitions(master): -80 80-\n' +
|
||||
'Partitions(rdonly): -80 80-c0 c0-\n' +
|
||||
'Partitions(replica): -80 80-\n' +
|
||||
'TabletTypes: master,rdonly,replica',
|
||||
'Partitions(replica): -80 80-\n',
|
||||
keyspace_id_type=keyspace_id_type)
|
||||
utils.check_srv_keyspace('test_ny', 'test_keyspace',
|
||||
'Partitions(master): -80 80-\n' +
|
||||
'Partitions(rdonly): -80 80-c0 c0-\n' +
|
||||
'TabletTypes: rdonly',
|
||||
'Partitions(replica): -80 80-\n',
|
||||
keyspace_id_type=keyspace_id_type)
|
||||
utils.check_tablet_query_service(self, shard_0_ny_rdonly, True, False)
|
||||
utils.check_tablet_query_service(self, shard_1_ny_rdonly, False, True)
|
||||
|
@ -670,8 +669,7 @@ primary key (name)
|
|||
utils.check_srv_keyspace('test_nj', 'test_keyspace',
|
||||
'Partitions(master): -80 80-\n' +
|
||||
'Partitions(rdonly): -80 80-c0 c0-\n' +
|
||||
'Partitions(replica): -80 80-c0 c0-\n' +
|
||||
'TabletTypes: master,rdonly,replica',
|
||||
'Partitions(replica): -80 80-c0 c0-\n',
|
||||
keyspace_id_type=keyspace_id_type)
|
||||
utils.check_tablet_query_service(self, shard_1_slave2, False, True)
|
||||
|
||||
|
@ -686,8 +684,7 @@ primary key (name)
|
|||
utils.check_srv_keyspace('test_nj', 'test_keyspace',
|
||||
'Partitions(master): -80 80-\n' +
|
||||
'Partitions(rdonly): -80 80-c0 c0-\n' +
|
||||
'Partitions(replica): -80 80-\n' +
|
||||
'TabletTypes: master,rdonly,replica',
|
||||
'Partitions(replica): -80 80-\n',
|
||||
keyspace_id_type=keyspace_id_type)
|
||||
|
||||
utils.run_vtctl(['MigrateServedTypes', 'test_keyspace/80-', 'replica'],
|
||||
|
@ -700,8 +697,7 @@ primary key (name)
|
|||
utils.check_srv_keyspace('test_nj', 'test_keyspace',
|
||||
'Partitions(master): -80 80-\n' +
|
||||
'Partitions(rdonly): -80 80-c0 c0-\n' +
|
||||
'Partitions(replica): -80 80-c0 c0-\n' +
|
||||
'TabletTypes: master,rdonly,replica',
|
||||
'Partitions(replica): -80 80-c0 c0-\n',
|
||||
keyspace_id_type=keyspace_id_type)
|
||||
|
||||
# reparent shard_2 to shard_2_replica1, then insert more data and
|
||||
|
@ -751,8 +747,7 @@ primary key (name)
|
|||
utils.check_srv_keyspace('test_nj', 'test_keyspace',
|
||||
'Partitions(master): -80 80-c0 c0-\n' +
|
||||
'Partitions(rdonly): -80 80-c0 c0-\n' +
|
||||
'Partitions(replica): -80 80-c0 c0-\n' +
|
||||
'TabletTypes: master,rdonly,replica',
|
||||
'Partitions(replica): -80 80-c0 c0-\n',
|
||||
keyspace_id_type=keyspace_id_type)
|
||||
utils.check_tablet_query_service(self, shard_1_master, False, True)
|
||||
|
||||
|
|
|
@ -571,14 +571,13 @@ def wait_db_read_only(uid):
|
|||
def check_srv_keyspace(cell, keyspace, expected, keyspace_id_type='uint64'):
|
||||
ks = run_vtctl_json(['GetSrvKeyspace', cell, keyspace])
|
||||
result = ""
|
||||
for tablet_type in sorted(ks['TabletTypes']):
|
||||
for tablet_type in sorted(ks['Partitions'].keys()):
|
||||
result += "Partitions(%s):" % tablet_type
|
||||
partition = ks['Partitions'][tablet_type]
|
||||
for shard in partition['Shards']:
|
||||
for shard in partition['ShardReferences']:
|
||||
result = result + " %s-%s" % (shard['KeyRange']['Start'],
|
||||
shard['KeyRange']['End'])
|
||||
result += "\n"
|
||||
result += "TabletTypes: " + ",".join(sorted(ks['TabletTypes']))
|
||||
logging.debug("Cell %s keyspace %s has data:\n%s", cell, keyspace, result)
|
||||
if expected != result:
|
||||
raise Exception("Mismatch in srv keyspace for cell %s keyspace %s, expected:\n%s\ngot:\n%s" % (
|
||||
|
|
|
@ -145,8 +145,8 @@ def setup_tablets():
|
|||
|
||||
utils.check_srv_keyspace('test_nj', 'test_keyspace',
|
||||
'Partitions(master): -80 80-\n' +
|
||||
'Partitions(replica): -80 80-\n' +
|
||||
'TabletTypes: master,replica')
|
||||
'Partitions(rdonly): -80 80-\n' +
|
||||
'Partitions(replica): -80 80-\n')
|
||||
|
||||
vtgate_server, vtgate_port = utils.vtgate_start()
|
||||
vtgate_client = zkocc.ZkOccConnection("localhost:%u" % vtgate_port,
|
||||
|
|
|
@ -163,8 +163,8 @@ def setup_tablets():
|
|||
|
||||
utils.check_srv_keyspace('test_nj', KEYSPACE_NAME,
|
||||
'Partitions(master): -80 80-\n' +
|
||||
'Partitions(replica): -80 80-\n' +
|
||||
'TabletTypes: master,replica')
|
||||
'Partitions(rdonly): -80 80-\n' +
|
||||
'Partitions(replica): -80 80-\n')
|
||||
|
||||
vtgate_server, vtgate_port = utils.vtgate_start()
|
||||
|
||||
|
|
|
@ -76,12 +76,11 @@ class TopoOccTest(unittest.TestCase):
|
|||
# vtgate zk API test
|
||||
out, err = utils.run(environment.binary_argstr('zkclient2')+' -server localhost:%u -mode getSrvKeyspace test_nj test_keyspace' % self.vtgate_zk_port, trap_output=True)
|
||||
self.assertEqual(err, "Partitions[master] =\n" +
|
||||
" Shards[0]={Start: , End: }\n" +
|
||||
" ShardReferences[0]={Start: , End: }\n" +
|
||||
"Partitions[rdonly] =\n" +
|
||||
" Shards[0]={Start: , End: }\n" +
|
||||
" ShardReferences[0]={Start: , End: }\n" +
|
||||
"Partitions[replica] =\n" +
|
||||
" Shards[0]={Start: , End: }\n" +
|
||||
"TabletTypes[0] = master\n",
|
||||
" ShardReferences[0]={Start: , End: }\n",
|
||||
"Got wrong content: %s" % err)
|
||||
|
||||
def test_get_end_points(self):
|
||||
|
@ -148,10 +147,9 @@ class TestTopo(unittest.TestCase):
|
|||
self.assertEqual(keyspaces, ["test_keyspace"], "get_srv_keyspace_names doesn't work")
|
||||
keyspace = fkc.get_srv_keyspace('testing', 'test_keyspace')
|
||||
self.assertEqual({
|
||||
'Shards': [{
|
||||
'AddrsByType': None,
|
||||
'ShardReferences': [{
|
||||
'KeyRange': {'End': '\xd0', 'Start': '\xc0'},
|
||||
'ReadOnly': False}],
|
||||
'Name': 'c0-d0'}],
|
||||
'TabletTypes': ['rdonly', 'replica', 'master']},
|
||||
keyspace, "keyspace reading is wrong")
|
||||
end_points = fkc.get_end_points("testing", "test_keyspace", "0", "master")
|
||||
|
|
Загрузка…
Ссылка в новой задаче