MasterInfo rename to BinLogAnchor

This commit is contained in:
siddontang 2014-09-04 22:43:56 +08:00
parent 138be8fb06
commit dad6478c12
6 changed files with 12 additions and 12 deletions

View File

@ -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 {

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 {