mirror of https://github.com/ledisdb/ledisdb.git
MasterInfo rename to BinLogAnchor
This commit is contained in:
parent
138be8fb06
commit
dad6478c12
|
@ -57,7 +57,7 @@ func loadDump(cfg *config.Config, ldb *ledis.Ledis) error {
|
|||
return err
|
||||
}
|
||||
|
||||
var head *ledis.MasterInfo
|
||||
var head *ledis.BinLogAnchor
|
||||
head, err = ldb.LoadDumpFile(*dumpPath)
|
||||
|
||||
if err != nil {
|
||||
|
|
|
@ -15,12 +15,12 @@ import (
|
|||
//
|
||||
//key and value are both compressed for fast transfer dump on network using snappy
|
||||
|
||||
type MasterInfo struct {
|
||||
type BinLogAnchor struct {
|
||||
LogFileIndex int64
|
||||
LogPos int64
|
||||
}
|
||||
|
||||
func (m *MasterInfo) WriteTo(w io.Writer) error {
|
||||
func (m *BinLogAnchor) WriteTo(w io.Writer) error {
|
||||
if err := binary.Write(w, binary.BigEndian, m.LogFileIndex); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ func (m *MasterInfo) WriteTo(w io.Writer) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (m *MasterInfo) ReadFrom(r io.Reader) error {
|
||||
func (m *BinLogAnchor) ReadFrom(r io.Reader) error {
|
||||
err := binary.Read(r, binary.BigEndian, &m.LogFileIndex)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -56,7 +56,7 @@ func (l *Ledis) DumpFile(path string) error {
|
|||
}
|
||||
|
||||
func (l *Ledis) Dump(w io.Writer) error {
|
||||
var m *MasterInfo = new(MasterInfo)
|
||||
m := new(BinLogAnchor)
|
||||
|
||||
var err error
|
||||
|
||||
|
@ -118,7 +118,7 @@ func (l *Ledis) Dump(w io.Writer) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (l *Ledis) LoadDumpFile(path string) (*MasterInfo, error) {
|
||||
func (l *Ledis) LoadDumpFile(path string) (*BinLogAnchor, error) {
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -128,11 +128,11 @@ func (l *Ledis) LoadDumpFile(path string) (*MasterInfo, error) {
|
|||
return l.LoadDump(f)
|
||||
}
|
||||
|
||||
func (l *Ledis) LoadDump(r io.Reader) (*MasterInfo, error) {
|
||||
func (l *Ledis) LoadDump(r io.Reader) (*BinLogAnchor, error) {
|
||||
l.wLock.Lock()
|
||||
defer l.wLock.Unlock()
|
||||
|
||||
info := new(MasterInfo)
|
||||
info := new(BinLogAnchor)
|
||||
|
||||
rb := bufio.NewReaderSize(r, 4096)
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ func (l *Ledis) ReplicateFromBinLog(filePath string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func (l *Ledis) ReadEventsTo(info *MasterInfo, w io.Writer) (n int, err error) {
|
||||
func (l *Ledis) ReadEventsTo(info *BinLogAnchor, w io.Writer) (n int, err error) {
|
||||
n = 0
|
||||
if l.binlog == nil {
|
||||
//binlog not supported
|
||||
|
|
|
@ -106,7 +106,7 @@ func TestReplication(t *testing.T) {
|
|||
tx.Rollback()
|
||||
}
|
||||
|
||||
info := new(MasterInfo)
|
||||
info := new(BinLogAnchor)
|
||||
info.LogFileIndex = 1
|
||||
info.LogPos = 0
|
||||
var buf bytes.Buffer
|
||||
|
|
|
@ -94,7 +94,7 @@ func syncCommand(c *client) error {
|
|||
return err
|
||||
}
|
||||
|
||||
m := &ledis.MasterInfo{logIndex, logPos}
|
||||
m := &ledis.BinLogAnchor{logIndex, logPos}
|
||||
|
||||
if _, err := c.app.ldb.ReadEventsTo(m, &c.syncBuf); err != nil {
|
||||
return err
|
||||
|
|
|
@ -271,7 +271,7 @@ func (m *master) fullSync() error {
|
|||
return err
|
||||
}
|
||||
|
||||
var head *ledis.MasterInfo
|
||||
var head *ledis.BinLogAnchor
|
||||
head, err = m.app.ldb.LoadDumpFile(dumpPath)
|
||||
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue