Skip to content

Commit

Permalink
move Tikv conf to Titan struct
Browse files Browse the repository at this point in the history
  • Loading branch information
zhs committed Jan 10, 2019
1 parent bed519a commit 1aa1d59
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
4 changes: 2 additions & 2 deletions bin/titan/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func main() {
os.Exit(1)
}
if pdAddrs != "" {
config.Server.Tikv.PdAddrs = pdAddrs
config.Tikv.PdAddrs = pdAddrs
}

if err := ConfigureZap(config.Logger.Name, config.Logger.Path, config.Logger.Level,
Expand All @@ -60,7 +60,7 @@ func main() {
os.Exit(1)
}

store, err := db.Open(&config.Server.Tikv)
store, err := db.Open(&config.Tikv)
if err != nil {
zap.L().Fatal("open db failed", zap.Error(err))
os.Exit(1)
Expand Down
4 changes: 3 additions & 1 deletion command/hashes.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,13 @@ func HMSet(ctx *Context, txn *db.Transaction) (OnCommit, error) {
return nil, errors.New("ERR wrong number of arguments for HMSET")
}

// filter repeate fields
// When there are multiple groups of the same field/val,
// take the last valid fields/val pair and save it in mapping
for i := 0; i < len(kvs)-1; i += 2 {
mapping[kvs[i]] = []byte(kvs[i+1])
}

// Iterate mapping to get the field and value after de-duplication
for field, val := range mapping {
fields = append(fields, []byte(field))
values = append(values, val)
Expand Down
2 changes: 1 addition & 1 deletion conf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "time"
type Titan struct {
Server Server `cfg:"server"`
Status Status `cfg:"status"`
Tikv Tikv `cfg:"tikv"`
TikvLog TikvLogger `cfg:"tikv-logger"`
Logger Logger `cfg:"logger"`
PIDFileName string `cfg:"pid-filename; titan.pid; ; the file name to record connd PID"`
Expand All @@ -21,7 +22,6 @@ type Hash struct {

//Server config is the config of titan server
type Server struct {
Tikv Tikv `cfg:"tikv"`
Auth string `cfg:"auth;;;client connetion auth"`
Listen string `cfg:"listen; 0.0.0.0:7369; netaddr; address to listen"`
MaxConnection int64 `cfg:"max-connection;1000;numeric;client connection count"`
Expand Down
27 changes: 14 additions & 13 deletions conf/titan.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,26 @@ auth = ""
#default: 1000
#max-connection = 1000

[server.tikv]

[status]

#type: string
#rules: nonempty
#description: listen address of http server
#default: 0.0.0.0:7345
#listen = "0.0.0.0:7345"


[tikv]

#type: string
#description: pd address in tidb
#required
pd-addrs = ""

[server.tikv.db]
[tikv.db]

[server.tikv.db.hash]
[tikv.db.hash]

#type: int64
#rules: numeric
Expand All @@ -39,7 +49,7 @@ pd-addrs = ""
#meta-slot = 0


[server.tikv.zt]
[tikv.zt]

#type: int
#rules: numeric
Expand All @@ -65,15 +75,6 @@ pd-addrs = ""
#interval = "1s"


[status]

#type: string
#rules: nonempty
#description: listen address of http server
#default: 0.0.0.0:7345
#listen = "0.0.0.0:7345"


[tikv-logger]

#type: string
Expand Down
8 changes: 4 additions & 4 deletions tools/integration/titan.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ var (
Listen: ServerAddr,
MaxConnection: 10000,
Auth: "",
Tikv: conf.Tikv{
PdAddrs: "mocktikv://",
},
}
tikvConf = conf.Tikv{
PdAddrs: "mocktikv://",
}

//ServerAddr default server addr
Expand All @@ -41,7 +41,7 @@ func SetAuth(auth string) {
func Start() {
zap.ReplaceGlobals(zap.NewNop())
var err error
store, err := db.Open(&cfg.Tikv)
store, err := db.Open(&tikvConf)
if err != nil {
log.Fatalln(err)
}
Expand Down

0 comments on commit 1aa1d59

Please sign in to comment.