func (fs *fileMetaStorage) RetrieveReader(fileName string) (diskQueueEndInfo, diskQueueEndInfo, error) {
	var f *os.File
	var err error
	var confirmed diskQueueEndInfo
	var queueEnd diskQueueEndInfo
	f, err = os.OpenFile(fileName, os.O_RDONLY, 0644)
	if err != nil {
		return confirmed, queueEnd, err
	}
	defer f.Close()
	_, err = fmt.Fscanf(f, "%d\n%d\n%d,%d,%d\n%d,%d,%d\n",
		&confirmed.totalMsgCnt,
		&queueEnd.totalMsgCnt,
		&confirmed.EndOffset.FileNum, &confirmed.EndOffset.Pos, &confirmed.virtualEnd,
		&queueEnd.EndOffset.FileNum, &queueEnd.EndOffset.Pos, &queueEnd.virtualEnd)
	if err != nil {
		nsqLog.Infof("fscanf new meta file err : %v", err)
		return confirmed, queueEnd, err
	}
	err = checkMetaFileEnd(f)
	if err != nil {
		nsqLog.Errorf("reader (%v) meta invalid, need fix: %v", fileName, err.Error())
	}
	return confirmed, queueEnd, err
}
retrieveMetaData initializes state from the filesystem
package nsqd
import (
	"bytes"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"math/rand"
	"os"
	"path"
	"strconv"
	"sync"
	"sync/atomic"
	"time"
	"github.com/absolute8511/bolt"
	"github.com/twmb/murmur3"
	"github.com/youzan/nsq/internal/util"
)
const (
	metaDataBucket = "meta_data_bucket"
)
var errMetaNotFound = errors.New("meta not found")
var alwaysEnableFileMetaWriter = int32(1)
func SwitchEnableFileMetaWriter(on bool) {
	if on {
		atomic.StoreInt32(&alwaysEnableFileMetaWriter, 1)
	} else {
		atomic.StoreInt32(&alwaysEnableFileMetaWriter, 0)
	}
}
type IMetaStorage interface {
	PersistReader(key string, fsync bool, confirmed diskQueueEndInfo, queueEndInfo diskQueueEndInfo) error
	RetrieveReader(key string) (diskQueueEndInfo, diskQueueEndInfo, error)
	Remove(key string)
	PersistWriter(key string, fsync bool, wend diskQueueEndInfo) error
	RetrieveWriter(key string, readOnly bool) (diskQueueEndInfo, error)
	RemoveWriter(key string)
	LoadChannelMeta(key string) ([]*ChannelMetaInfo, error)
	SaveChannelMeta(key string, fsync bool, channels []*ChannelMetaInfo) error
	RemoveChannelMeta(key string)
	Sync()
	Close()
}
func IsMetaNotFound(err error) bool {
	if os.IsNotExist(err) {
		return true
	}
	if err == errMetaNotFound {
		return true
	}
	return false
}
type fileMetaStorage struct {
	metaLock sync.Mutex
}
func checkMetaFileEnd(f *os.File) error {
	endFlag := make([]byte, len(diskMagicEndBytes))
	n, err := f.Read(endFlag)
	if err != nil {
		if err == io.EOF {
		} else {
			nsqLog.Errorf("reader meta end error, need fix: %v", err.Error())
			return errInvalidMetaFileData
		}
	} else if !bytes.Equal(endFlag[:n], diskMagicEndBytes) {
		nsqLog.Errorf("reader meta end data invalid: %v need fix: %v", n, endFlag)
		return errInvalidMetaFileData
	}
	return nil
}
func (fs *fileMetaStorage) Sync() {
}
func (fs *fileMetaStorage) Close() {
}