shamrickus commented on a change in pull request #5924: URL: https://github.com/apache/trafficcontrol/pull/5924#discussion_r648792209
########## File path: tools/traffic_vault_migrate/traffic_vault_migrate.go ########## @@ -0,0 +1,448 @@ +package main + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import ( + "encoding/json" + "errors" + "flag" + "fmt" + "io/ioutil" + "log" + "os" + "reflect" + "sort" + "strings" + "time" + + "github.com/apache/trafficcontrol/lib/go-tc" +) + +var ( + fromType string + toType string + fromCfg string + toCfg string + dry bool + compare bool + confirm bool + dump bool + + riakBE RiakBackend = RiakBackend{} + pgBE PGBackend = PGBackend{} +) + +func init() { + flag.StringVar(&fromType, "from_type", riakBE.Name(), fmt.Sprintf("From server types (%v)", strings.Join(supportedTypes(), "|"))) + flag.StringVar(&toType, "to_type", pgBE.Name(), fmt.Sprintf("From server types (%v)", strings.Join(supportedTypes(), "|"))) + flag.StringVar(&toCfg, "to_cfg", "pg.json", "To server config file") + flag.StringVar(&fromCfg, "from_cfg", "riak.json", "From server config file") + flag.BoolVar(&dry, "dry", false, "Do not perform writes") + flag.BoolVar(&compare, "compare", false, "Compare to and from server records") + flag.BoolVar(&confirm, "confirm", true, "Requires confirmation before inserting records") + flag.BoolVar(&dump, "dump", false, "Write keys (from 'from' server) to disk") +} + +func supportedBackends() []TVBackend { + return []TVBackend{ + &riakBE, &pgBE, + } +} + +func main() { + flag.Parse() + var fromSrv TVBackend + var toSrv TVBackend + + toSrvUsed := !dump && !dry + + if !validateType(fromType) { + log.Fatal("Unknown fromType " + fromType) + } + if toSrvUsed && !validateType(toType) { + log.Fatal("Unknown toType " + toType) + } + + fromSrv = getBackendFromType(fromType) + if toSrvUsed { + toSrv = getBackendFromType(toType) + } + + var toTimer time.Time + var toTime float64 + var fromTimer time.Time + var fromTime float64 + + log.Println("Reading configs...") + fromTimer = time.Now() + if err := fromSrv.ReadConfig(fromCfg); err != nil { + log.Fatalf("Unable to read fromSrv cfg: %v", err) + } + fromTime = time.Now().Sub(fromTimer).Seconds() + + if toSrvUsed { + toTimer = time.Now() + if err := toSrv.ReadConfig(toCfg); err != nil { + log.Fatalf("Unable to read toSrv cfg: %v", err) + } + toTime := time.Now().Sub(toTimer).Seconds() Review comment: You are correct, I removed them. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
