示例#1
0
文件: main.go 项目: bifeng/ledisdb
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
}
示例#2
0
文件: main.go 项目: Abioy/ledisdb
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
}
示例#3
0
文件: main.go 项目: Gohan/ledisdb
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)
}