Exemplo n.º 1
0
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
}
Exemplo n.º 2
0
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
}
Exemplo n.º 3
0
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)
}