func loadDump(cfg *config.Config, ldb *ledis.Ledis) error { var err error if err = ldb.FlushAll(); err != nil { return err } _, err = ldb.LoadDumpFile(*dumpPath) return err }
func newClient(c net.Conn, ldb *ledis.Ledis) { co := new(client) co.ldb = ldb //use default db co.db, _ = ldb.Select(0) co.c = c co.rb = bufio.NewReaderSize(c, 256) co.wb = bufio.NewWriterSize(c, 256) co.reqC = make(chan error, 1) go co.run() }
func loadDump(cfg *config.Config, ldb *ledis.Ledis) error { var err error if err = ldb.FlushAll(); err != nil { return err } var head *ledis.BinLogAnchor head, err = ldb.LoadDumpFile(*dumpPath) if err != nil { return err } //master enable binlog, here output this like mysql if head.LogFileIndex != 0 && head.LogPos != 0 { format := "MASTER_LOG_FILE='binlog.%07d', MASTER_LOG_POS=%d;\n" fmt.Printf(format, head.LogFileIndex, head.LogPos) } return nil }
func loadDump(cfg *ledis.Config, ldb *ledis.Ledis) error { var err error if err = ldb.FlushAll(); err != nil { return err } var head *ledis.MasterInfo head, err = ldb.LoadDumpFile(*dumpPath) if err != nil { return err } info := new(server.MasterInfo) info.Addr = *masterAddr info.LogFileIndex = head.LogFileIndex info.LogPos = head.LogPos infoFile := path.Join(cfg.DataDir, "master.info") return info.Save(infoFile) }