コード例 #1
0
ファイル: fdfsclient.go プロジェクト: chenbk85/nephele
func (this *fdfsClient) downloadToBufferByOffset(fileId string, offset int64, downloadSize int64, catInstance cat.Cat) ([]byte, error) {
	//split file id to two parts: group name and file name
	tmp, err := splitRemoteFileId(fileId)
	if err != nil || len(tmp) != 2 {
		return nil, err
	}
	groupName := tmp[0]
	fileName := tmp[1]

	//query a download server from tracker
	storeInfo, err := this.tracker.trackerQueryStorageFetch(groupName, fileName)
	if err != nil {
		return nil, err
	}
	if catInstance != nil {
		event := catInstance.NewEvent("ImgFromStorage", fmt.Sprintf("%s:%s", storeInfo.groupName, storeInfo.ipAddr))
		event.SetStatus("0")
		event.Complete()
	}

	//get a storage client from storage map, if not exist, create a new storage client
	storeClient, err := this.getStorage(storeInfo.ipAddr, storeInfo.port)
	if err != nil {
		return nil, err
	}
	return storeClient.storageDownload(storeInfo, offset, downloadSize, fileName)
}
コード例 #2
0
ファイル: digital_watermark.go プロジェクト: chenbk85/nephele
func logEvent(cat cat.Cat, title string, name string, data map[string]string) {
	event := cat.NewEvent(title, name)
	if data != nil {
		for k, v := range data {
			event.AddData(k, v)
		}
	}
	event.SetStatus("0")
	event.Complete()
}