зеркало из https://github.com/github/vitess-gh.git
Removing unused SessionParams attributes.
The python code only uses Keyspace and Shard. That also allows me to remove KeyRange from dbconfigs, was only used to validate against the connection params. (the other one, Dbname, is used in other places).
This commit is contained in:
Родитель
0f65068b43
Коммит
ed32fa48db
|
@ -13,7 +13,6 @@ import (
|
|||
log "github.com/golang/glog"
|
||||
"github.com/youtube/vitess/go/jscfg"
|
||||
"github.com/youtube/vitess/go/mysql"
|
||||
"github.com/youtube/vitess/go/vt/key"
|
||||
)
|
||||
|
||||
// Offer a sample config - probably should load this when file isn't set.
|
||||
|
@ -47,7 +46,6 @@ type DBConfig struct {
|
|||
UnixSocket string `json:"unix_socket"`
|
||||
Charset string `json:"charset"`
|
||||
Memcache string `json:"memcache"`
|
||||
KeyRange key.KeyRange `json:"keyrange"`
|
||||
Keyspace string `json:"keyspace"`
|
||||
Shard string `json:"shard"`
|
||||
}
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
// Copyright 2013, Google Inc. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package dbconfigs
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDbConfigLoad(t *testing.T) {
|
||||
|
||||
data := "{\n" +
|
||||
" \"keyrange\": {\n" +
|
||||
" \"Start\": \"4000\",\n" +
|
||||
" \"End\": \"8000\"\n" +
|
||||
" }\n" +
|
||||
"}"
|
||||
|
||||
val := &DBConfig{}
|
||||
if err := json.Unmarshal([]byte(data), val); err != nil {
|
||||
t.Errorf("json.Unmarshal error: %v", err)
|
||||
}
|
||||
if string(val.KeyRange.Start.Hex()) != "4000" {
|
||||
t.Errorf("Invalid Start: %v", val.KeyRange.Start.Hex())
|
||||
}
|
||||
if string(val.KeyRange.End.Hex()) != "8000" {
|
||||
t.Errorf("Invalid End: %v", val.KeyRange.End.Hex())
|
||||
}
|
||||
}
|
|
@ -6,12 +6,9 @@ package proto
|
|||
|
||||
import (
|
||||
mproto "github.com/youtube/vitess/go/mysql/proto"
|
||||
"github.com/youtube/vitess/go/vt/key"
|
||||
)
|
||||
|
||||
type SessionParams struct {
|
||||
DbName string
|
||||
KeyRange key.KeyRange
|
||||
Keyspace string
|
||||
Shard string
|
||||
}
|
||||
|
|
|
@ -218,21 +218,12 @@ func (sq *SqlQuery) checkState(sessionId int64, allowShutdown bool) {
|
|||
}
|
||||
|
||||
func (sq *SqlQuery) GetSessionId(sessionParams *proto.SessionParams, sessionInfo *proto.SessionInfo) error {
|
||||
if sessionParams.DbName == "" {
|
||||
if sessionParams.Keyspace != sq.dbconfig.Keyspace {
|
||||
return NewTabletError(FATAL, "Keyspace mismatch, expecting %v, received %v", sq.dbconfig.Keyspace, sessionParams.Keyspace)
|
||||
}
|
||||
if sessionParams.Shard != sq.dbconfig.Shard {
|
||||
return NewTabletError(FATAL, "Shard mismatch, expecting %v, received %v", sq.dbconfig.Shard, sessionParams.Shard)
|
||||
}
|
||||
} else {
|
||||
if sessionParams.DbName != sq.dbconfig.Dbname {
|
||||
return NewTabletError(FATAL, "db name mismatch, expecting %v, received %v", sq.dbconfig.Dbname, sessionParams.DbName)
|
||||
}
|
||||
if sessionParams.KeyRange != sq.dbconfig.KeyRange {
|
||||
return NewTabletError(FATAL, "KeyRange mismatch, expecting %v, received %v", sq.dbconfig.KeyRange.String(), sessionParams.KeyRange.String())
|
||||
}
|
||||
}
|
||||
sessionInfo.SessionId = sq.sessionId
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -80,7 +80,6 @@ func InitAgent(
|
|||
if dbcfgs.App.Dbname == "" {
|
||||
dbcfgs.App.Dbname = newTablet.DbName()
|
||||
}
|
||||
dbcfgs.App.KeyRange = newTablet.KeyRange
|
||||
dbcfgs.App.Keyspace = newTablet.Keyspace
|
||||
dbcfgs.App.Shard = newTablet.Shard
|
||||
// Transitioning from replica to master, first disconnect
|
||||
|
@ -90,10 +89,10 @@ func InitAgent(
|
|||
ts.DisallowQueries(false)
|
||||
}
|
||||
qrs := ts.LoadCustomRules()
|
||||
if dbcfgs.App.KeyRange.IsPartial() {
|
||||
if newTablet.KeyRange.IsPartial() {
|
||||
qr := ts.NewQueryRule("enforce keyspace_id range", "keyspace_id_not_in_range", ts.QR_FAIL_QUERY)
|
||||
qr.AddPlanCond(sqlparser.PLAN_INSERT_PK)
|
||||
err = qr.AddBindVarCond("keyspace_id", true, true, ts.QR_NOTIN, dbcfgs.App.KeyRange)
|
||||
err = qr.AddBindVarCond("keyspace_id", true, true, ts.QR_NOTIN, newTablet.KeyRange)
|
||||
if err != nil {
|
||||
log.Warningf("Unable to add keyspace rule: %v", err)
|
||||
} else {
|
||||
|
|
Загрузка…
Ссылка в новой задаче