operation

package
v0.0.0-...-2206af0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2022 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// when the remote server does not allow range requests (Accept-Ranges was not set)
	ErrRangeRequestsNotSupported = errors.New("Range requests are not supported by the remote server")
	// ErrInvalidRange is returned by Read when trying to read past the end of the file
	ErrInvalidRange = errors.New("Invalid range")
)
View Source
var ErrorNotFound = errors.New("not found")

Functions

func DeleteFiles

func DeleteFiles(master string, usePublicUrl bool, grpcDialOption grpc.DialOption, fileIds []string) ([]*volume_server_pb.DeleteResult, error)

DeleteFiles batch deletes a list of fileIds

func DeleteFilesAtOneVolumeServer

func DeleteFilesAtOneVolumeServer(volumeServer string, grpcDialOption grpc.DialOption, fileIds []string, includeCookie bool) (ret []*volume_server_pb.DeleteResult, err error)

DeleteFilesAtOneVolumeServer deletes a list of files that is on one volume server via gRpc

func DeleteFilesWithLookupVolumeId

func DeleteFilesWithLookupVolumeId(grpcDialOption grpc.DialOption, fileIds []string, lookupFunc func(vid []string) (map[string]LookupResult, error)) ([]*volume_server_pb.DeleteResult, error)

func GetVolumeSyncStatus

func GetVolumeSyncStatus(server string, grpcDialOption grpc.DialOption, vid uint32) (resp *volume_server_pb.VolumeSyncStatusResponse, err error)

func LookupFileId

func LookupFileId(server string, fileId string) (fullUrl string, err error)

func LookupJwt

func LookupJwt(master string, fileId string) security.EncodedJwt

func LookupVolumeIds

func LookupVolumeIds(server string, grpcDialOption grpc.DialOption, vids []string) (map[string]LookupResult, error)

LookupVolumeIds find volume locations by cache and actual lookup

func ParseFileId

func ParseFileId(fid string) (vid string, key_cookie string, err error)

func TailVolume

func TailVolume(master string, grpcDialOption grpc.DialOption, vid needle.VolumeId, sinceNs uint64, timeoutSeconds int, fn func(n *needle.Needle) error) error

func TailVolumeFromSource

func TailVolumeFromSource(volumeServer string, grpcDialOption grpc.DialOption, vid needle.VolumeId, sinceNs uint64, idleTimeoutSeconds int, fn func(n *needle.Needle) error) error

func WithFilerServerClient

func WithFilerServerClient(filerServer string, grpcDialOption grpc.DialOption, fn func(masterClient filer_pb.SeaweedFilerClient) error) error

func WithMasterServerClient

func WithMasterServerClient(masterServer string, grpcDialOption grpc.DialOption, fn func(masterClient master_pb.SeaweedClient) error) error

func WithVolumeServerClient

func WithVolumeServerClient(volumeServer string, grpcDialOption grpc.DialOption, fn func(volume_server_pb.VolumeServerClient) error) error

Types

type AssignResult

type AssignResult struct {
	Fid       string              `json:"fid,omitempty"`
	Url       string              `json:"url,omitempty"`
	PublicUrl string              `json:"publicUrl,omitempty"`
	Count     uint64              `json:"count,omitempty"`
	Error     string              `json:"error,omitempty"`
	Auth      security.EncodedJwt `json:"auth,omitempty"`
}

func Assign

func Assign(server string, grpcDialOption grpc.DialOption, primaryRequest *VolumeAssignRequest, alternativeRequests ...*VolumeAssignRequest) (*AssignResult, error)

type ChunkInfo

type ChunkInfo struct {
	Fid    string `json:"fid"`
	Offset int64  `json:"offset"`
	Size   int64  `json:"size"`
}

type ChunkList

type ChunkList []*ChunkInfo

func (ChunkList) Len

func (s ChunkList) Len() int

func (ChunkList) Less

func (s ChunkList) Less(i, j int) bool

func (ChunkList) Swap

func (s ChunkList) Swap(i, j int)

type ChunkManifest

type ChunkManifest struct {
	Name   string    `json:"name,omitempty"`
	Mime   string    `json:"mime,omitempty"`
	Size   int64     `json:"size,omitempty"`
	Chunks ChunkList `json:"chunks,omitempty"`
}

func LoadChunkManifest

func LoadChunkManifest(buffer []byte, isCompressed bool) (*ChunkManifest, error)

func (*ChunkManifest) DeleteChunks

func (cm *ChunkManifest) DeleteChunks(master string, usePublicUrl bool, grpcDialOption grpc.DialOption) error

func (*ChunkManifest) Marshal

func (cm *ChunkManifest) Marshal() ([]byte, error)

type ChunkedFileReader

type ChunkedFileReader struct {
	// contains filtered or unexported fields
}

seekable chunked file reader

func NewChunkedFileReader

func NewChunkedFileReader(chunkList []*ChunkInfo, master string) *ChunkedFileReader

func (*ChunkedFileReader) Close

func (cf *ChunkedFileReader) Close() (e error)

func (*ChunkedFileReader) Read

func (cf *ChunkedFileReader) Read(p []byte) (int, error)

func (*ChunkedFileReader) ReadAt

func (cf *ChunkedFileReader) ReadAt(p []byte, off int64) (n int, err error)

func (*ChunkedFileReader) Seek

func (cf *ChunkedFileReader) Seek(offset int64, whence int) (int64, error)

func (*ChunkedFileReader) WriteTo

func (cf *ChunkedFileReader) WriteTo(w io.Writer) (n int64, err error)

type DeleteResult

type DeleteResult struct {
	Fid    string `json:"fid"`
	Size   int    `json:"size"`
	Status int    `json:"status"`
	Error  string `json:"error,omitempty"`
}

type FilePart

type FilePart struct {
	Reader      io.Reader
	FileName    string
	FileSize    int64
	MimeType    string
	ModTime     int64 //in seconds
	Replication string
	Collection  string
	DataCenter  string
	Ttl         string
	Server      string //this comes from assign result
	Fid         string //this comes from assign result, but customizable
	Fsync       bool
}

func NewFileParts

func NewFileParts(fullPathFilenames []string) (ret []FilePart, err error)

func (FilePart) Upload

func (fi FilePart) Upload(maxMB int, master string, usePublicUrl bool, jwt security.EncodedJwt, grpcDialOption grpc.DialOption) (retSize uint32, err error)

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient interface for testing

var (
	HttpClient HTTPClient
)

type JoinResult

type JoinResult struct {
	VolumeSizeLimit uint64 `json:"VolumeSizeLimit,omitempty"`
	Error           string `json:"error,omitempty"`
}

type Location

type Location struct {
	Url       string `json:"url,omitempty"`
	PublicUrl string `json:"publicUrl,omitempty"`
}

type LookupResult

type LookupResult struct {
	VolumeId  string     `json:"volumeId,omitempty"`
	Locations []Location `json:"locations,omitempty"`
	Error     string     `json:"error,omitempty"`
}

func Lookup

func Lookup(server string, vid string) (ret *LookupResult, err error)

func (*LookupResult) String

func (lr *LookupResult) String() string

type SubmitResult

type SubmitResult struct {
	FileName string `json:"fileName,omitempty"`
	FileUrl  string `json:"fileUrl,omitempty"`
	Fid      string `json:"fid,omitempty"`
	Size     uint32 `json:"size,omitempty"`
	Error    string `json:"error,omitempty"`
}

func SubmitFiles

func SubmitFiles(master string, grpcDialOption grpc.DialOption, files []FilePart, replication string, collection string, dataCenter string, ttl string, maxMB int, usePublicUrl bool) ([]SubmitResult, error)

type UploadResult

type UploadResult struct {
	Name       string `json:"name,omitempty"`
	Size       uint32 `json:"size,omitempty"`
	Error      string `json:"error,omitempty"`
	ETag       string `json:"eTag,omitempty"`
	CipherKey  []byte `json:"cipherKey,omitempty"`
	Mime       string `json:"mime,omitempty"`
	Gzip       uint32 `json:"gzip,omitempty"`
	ContentMd5 string `json:"contentMd5,omitempty"`
}

func Upload

func Upload(uploadUrl string, filename string, cipher bool, reader io.Reader, isInputCompressed bool, mtype string, pairMap map[string]string, jwt security.EncodedJwt) (uploadResult *UploadResult, err error, data []byte)

Upload sends a POST request to a volume server to upload the content with fast compression

func UploadData

func UploadData(uploadUrl string, filename string, cipher bool, data []byte, isInputCompressed bool, mtype string, pairMap map[string]string, jwt security.EncodedJwt) (uploadResult *UploadResult, err error)

Upload sends a POST request to a volume server to upload the content with adjustable compression level

func (*UploadResult) ToPbFileChunk

func (uploadResult *UploadResult) ToPbFileChunk(fileId string, offset int64) *filer_pb.FileChunk

type VidCache

type VidCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*VidCache) Get

func (vc *VidCache) Get(vid string) ([]Location, error)

func (*VidCache) Set

func (vc *VidCache) Set(vid string, locations []Location, duration time.Duration)

type VidInfo

type VidInfo struct {
	Locations       []Location
	NextRefreshTime time.Time
}

type VolumeAssignRequest

type VolumeAssignRequest struct {
	Count               uint64
	Replication         string
	Collection          string
	Ttl                 string
	DataCenter          string
	Rack                string
	DataNode            string
	WritableVolumeCount uint32
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL