示例#1
0
文件: router.go 项目: ule-lab/speedy
func (s *Server) GetFidRange(mergeWait bool) error {
	if !s.fids.IsShortage() {
		return nil
	}

	byteData, statusCode, err := util.Call("GET", s.masterUrl, "/v1/chunkmaster/fid", nil, nil)
	if err != nil {
		log.Errorf("GetChunkServerInfo response code: %d, err: %s", statusCode, err)
		return err
	}

	if statusCode != http.StatusOK {
		log.Errorf("response code: %d", statusCode)
		return fmt.Errorf("statusCode error: %d", statusCode)
	}

	log.Infof("GetFidRange data: %s", string(byteData))

	newFids := chunkserver.NewFids()
	err = json.Unmarshal(byteData, &newFids)
	if err != nil {
		log.Errorf("GetFidRange json.Unmarshal response data error: %s", err)
		return err
	}

	s.fids.Merge(newFids.Start, newFids.End, mergeWait)
	return nil
}
示例#2
0
文件: router.go 项目: ule-lab/speedy
func NewServer(masterUrl, ip string, port int, num int, metadbIp string, metadbPort int, metadbUser, metadbPassword, metaDatabase string, connPoolCapacity int) *Server {
	return &Server{
		masterUrl:         masterUrl,
		Ip:                ip,
		Port:              port,
		fids:              chunkserver.NewFids(),
		chunkServerGroups: nil,
		connectionPools:   nil,
		limitNum:          num,
		connPoolCapacity:  connPoolCapacity,
		getFidRetryCount:  0,
		metadbIp:          metadbIp,
		metadbPort:        metadbPort,
		metadbUser:        metadbUser,
		metadbPassword:    metadbPassword,
		metaDatabase:      metaDatabase,
	}
}