当前位置: 首页>>代码示例>>Golang>>正文


Golang metadata.Chunkserver类代码示例

本文整理汇总了Golang中github.com/jcloudpub/speedy/chunkmaster/metadata.Chunkserver的典型用法代码示例。如果您正苦于以下问题:Golang Chunkserver类的具体用法?Golang Chunkserver怎么用?Golang Chunkserver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Chunkserver类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: reportChunkserverInfo

func reportChunkserverInfo(key string, chunkserver *metadata.Chunkserver, oldChunkserver *metadata.Chunkserver) error {
	if oldChunkserver.Status == INIT_STATUS {
		err := mdDriver.UpdateChunkserverInfo(chunkserver, INIT_STATUS, RW_STATUS)
		if err != nil {
			return err
		}
		chunkserver.Status = RW_STATUS
	}

	if RW_STATUS == oldChunkserver.Status {
		err := mdDriver.UpdateChunkserverInfo(chunkserver, RW_STATUS, RW_STATUS)
		if err != nil {
			return err
		}
		chunkserver.Status = RW_STATUS
	}

	if RO_STATUS == oldChunkserver.Status {
		err := mdDriver.UpdateChunkserverInfo(chunkserver, RO_STATUS, RW_STATUS)
		if err != nil {
			return err
		}
		log.Infof("[reportChunkserverInfo] update RO_STATUS to RW_STATUS chunkserver: %v", key)
		chunkserver.Status = RW_STATUS
	}

	chunkserver.UpdateTime = time.Now()

	lock.Lock()
	_, ok := serverInfo[key]
	if !ok {
		lock.Unlock()
		return fmt.Errorf("do not exist: %v", chunkserver)
	}
	serverInfo[key] = chunkserver
	lock.Unlock()
	return nil
}
开发者ID:ule-lab,项目名称:speedy,代码行数:38,代码来源:chunkserver.go

示例2: addChunkserver

func addChunkserver(chunkserver *metadata.Chunkserver) error {
	chunkserver.Status = INIT_STATUS
	chunkserver.TotalFreeSpace = 0
	chunkserver.MaxFreeSpace = 0
	chunkserver.PendingWrites = 0
	chunkserver.WritingCount = 0
	chunkserver.DataDir = ""
	chunkserver.ReadingCount = 0
	chunkserver.TotalChunks = 0
	chunkserver.ConnectionsCount = 0

	err := mdDriver.AddChunkserver(chunkserver)
	if err != nil {
		return err
	}
	lock.Lock()
	defer lock.Unlock()

	key := fmt.Sprintf("%d:%s:%d", chunkserver.GroupId, chunkserver.Ip, chunkserver.Port)
	chunkserver.UpdateTime = time.Now()
	serverInfo[key] = chunkserver
	return nil
}
开发者ID:ule-lab,项目名称:speedy,代码行数:23,代码来源:chunkserver.go

示例3: TestUpdateChunkserver

func TestUpdateChunkserver(t *testing.T) {
	conn, err := getConn()
	chunkserver := new(metadata.Chunkserver)

	chunkserver.GroupId = uint16(1)
	chunkserver.Ip = "127.0.0.1"
	chunkserver.Port = 5444
	chunkserver.Status = 0
	chunkserver.TotalFreeSpace = int64(65)
	chunkserver.MaxFreeSpace = int64(1231231231231234534)

	err = conn.UpdateChunkserver(chunkserver)
	if err != nil {
		t.Fatal(err)
	}
}
开发者ID:ule-lab,项目名称:speedy,代码行数:16,代码来源:chunkserverdb_test.go

示例4: TestNotExistChunkserver

func TestNotExistChunkserver(t *testing.T) {
	conn, err := getConn()
	chunkserver := new(metadata.Chunkserver)

	chunkserver.GroupId = uint16(3)
	chunkserver.Ip = "127.0.0.1"
	chunkserver.Port = 5444
	chunkserver.Status = 0
	chunkserver.TotalFreeSpace = int64(45465465)
	chunkserver.MaxFreeSpace = int64(123123123123123)

	exist, err := conn.IsExistChunkserver(chunkserver)
	if err != nil {
		t.Fatal(err)
	}
	t.Log("exist:", exist)
}
开发者ID:ule-lab,项目名称:speedy,代码行数:17,代码来源:chunkserverdb_test.go

示例5: TestAddChunkserver

func TestAddChunkserver(t *testing.T) {
	conn, err := getConn()

	chunkserver := new(metadata.Chunkserver)
	chunkserver.GroupId = uint16(65535)
	chunkserver.Ip = "127.0.0.1"
	chunkserver.Port = 5444
	chunkserver.Status = 0
	chunkserver.TotalFreeSpace = int64(45465465)
	chunkserver.MaxFreeSpace = int64(123123123123123)
	chunkserver.PendingWrites = 1
	chunkserver.WritingCount = 1
	chunkserver.DataDir = "/export/"
	chunkserver.ReadingCount = 1
	chunkserver.TotalChunks = 1
	chunkserver.ConnectionsCount = 1

	err = conn.AddChunkserver(chunkserver)
	if err != nil {
		t.Fatal(err)
	}
}
开发者ID:ule-lab,项目名称:speedy,代码行数:22,代码来源:chunkserverdb_test.go

示例6: initChunkserverHandler

func initChunkserverHandler(resp http.ResponseWriter, req *http.Request) {
	reqData, err := ioutil.ReadAll(req.Body)
	defer req.Body.Close()
	if err != nil {
		util.HandleError(resp, "", err, http.StatusBadRequest)
		return
	}
	log.Infof("[initserverHandler] read reqData %v", string(reqData))

	var jsonMap map[string]interface{}
	err = json.Unmarshal(reqData, &jsonMap)
	if err != nil {
		util.HandleError(resp, "", err, http.StatusBadRequest)
		return
	}
	log.Infof("[initserverHandler] change json to map %v", jsonMap)

	groupId := uint16((jsonMap["GroupId"]).(float64))
	ip := jsonMap["Ip"].(string)
	port := int((jsonMap["Port"]).(float64))
	chunkserver := new(metadata.Chunkserver)
	chunkserver.GroupId = groupId
	chunkserver.Ip = ip
	chunkserver.Port = port
	chunkserver.Status = INIT_STATUS
	chunkserver.TotalFreeSpace = 0
	chunkserver.MaxFreeSpace = 0
	chunkserver.PendingWrites = 0
	chunkserver.WritingCount = 0
	chunkserver.DataDir = ""
	chunkserver.ReadingCount = 0
	chunkserver.TotalChunks = 0
	chunkserver.ConnectionsCount = 0

	err = addChunkserver(chunkserver)
	if err != nil {
		util.HandleError(resp, "", err, http.StatusInternalServerError)
		return
	}

	util.Response(nil, http.StatusOK, resp)
}
开发者ID:ule-lab,项目名称:speedy,代码行数:42,代码来源:chunkserver.go


注:本文中的github.com/jcloudpub/speedy/chunkmaster/metadata.Chunkserver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。