filer2

package
v0.0.0-...-d8c34b0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OS_UID = uint32(os.Getuid())
	OS_GID = uint32(os.Getgid())
)
View Source
var ErrNotFound = errors.New("filer: no entry is found in filer store")
View Source
var (
	Stores []FilerStore
)

Functions

func CompactFileChunks

func CompactFileChunks(chunks []*filer_pb.FileChunk) (compacted, garbage []*filer_pb.FileChunk)

func ETag

func ETag(chunks []*filer_pb.FileChunk) (etag string)

func EntryAttributeToPb

func EntryAttributeToPb(entry *Entry) *filer_pb.FuseAttributes

func EqualEntry

func EqualEntry(a, b *Entry) bool

func GetEntry

func GetEntry(ctx context.Context, filerClient FilerClient, fullFilePath string) (entry *filer_pb.Entry, err error)

func MinusChunks

func MinusChunks(as, bs []*filer_pb.FileChunk) (delta []*filer_pb.FileChunk)

func ReadDirAllEntries

func ReadDirAllEntries(ctx context.Context, filerClient FilerClient, fullDirPath string, fn func(entry *filer_pb.Entry)) (err error)

func ReadIntoBuffer

func ReadIntoBuffer(ctx context.Context, filerClient FilerClient, fullFilePath string, buff []byte, chunkViews []*ChunkView, baseOffset int64) (totalRead int64, err error)

func StreamContent

func StreamContent(masterClient *wdclient.MasterClient, w io.Writer, chunks []*filer_pb.FileChunk, offset int64, size int) error

func TotalSize

func TotalSize(chunks []*filer_pb.FileChunk) (size uint64)

func VolumeId

func VolumeId(fileId string) string

Types

type Attr

type Attr struct {
	Mtime         time.Time   // time of last modification
	Crtime        time.Time   // time of creation (OS X only)
	Mode          os.FileMode // file mode
	Uid           uint32      // owner uid
	Gid           uint32      // group gid
	Mime          string      // mime type
	Replication   string      // replication
	Collection    string      // collection name
	TtlSec        int32       // ttl in seconds
	UserName      string
	GroupNames    []string
	SymlinkTarget string
}

func PbToEntryAttribute

func PbToEntryAttribute(attr *filer_pb.FuseAttributes) Attr

func (Attr) IsDirectory

func (attr Attr) IsDirectory() bool

type ChunkView

type ChunkView struct {
	FileId      string
	Offset      int64
	Size        uint64
	LogicOffset int64
	IsFullChunk bool
}

func ViewFromChunks

func ViewFromChunks(chunks []*filer_pb.FileChunk, offset int64, size int) (views []*ChunkView)

func ViewFromVisibleIntervals

func ViewFromVisibleIntervals(visibles []VisibleInterval, offset int64, size int) (views []*ChunkView)

type Entry

type Entry struct {
	FullPath

	Attr

	// the following is for files
	Chunks []*filer_pb.FileChunk `json:"chunks,omitempty"`
}

func (*Entry) DecodeAttributesAndChunks

func (entry *Entry) DecodeAttributesAndChunks(blob []byte) error

func (*Entry) EncodeAttributesAndChunks

func (entry *Entry) EncodeAttributesAndChunks() ([]byte, error)

func (*Entry) Size

func (entry *Entry) Size() uint64

func (*Entry) Timestamp

func (entry *Entry) Timestamp() time.Time

func (*Entry) ToProtoEntry

func (entry *Entry) ToProtoEntry() *filer_pb.Entry

func (*Entry) ToProtoFullEntry

func (entry *Entry) ToProtoFullEntry() *filer_pb.FullEntry

type Filer

type Filer struct {
	MasterClient *wdclient.MasterClient

	GrpcDialOption grpc.DialOption
	// contains filtered or unexported fields
}

func NewFiler

func NewFiler(masters []string, grpcDialOption grpc.DialOption) *Filer

func (*Filer) BeginTransaction

func (f *Filer) BeginTransaction(ctx context.Context) (context.Context, error)

func (*Filer) CommitTransaction

func (f *Filer) CommitTransaction(ctx context.Context) error

func (*Filer) CreateEntry

func (f *Filer) CreateEntry(ctx context.Context, entry *Entry) error

func (*Filer) DeleteChunks

func (f *Filer) DeleteChunks(fullpath FullPath, chunks []*filer_pb.FileChunk)

func (*Filer) DeleteEntryMetaAndData

func (f *Filer) DeleteEntryMetaAndData(ctx context.Context, p FullPath, isRecursive bool, ignoreRecursiveError, shouldDeleteChunks bool) (err error)

func (*Filer) DeleteFileByFileId

func (f *Filer) DeleteFileByFileId(fileId string)

DeleteFileByFileId direct delete by file id. Only used when the fileId is not being managed by snapshots.

func (*Filer) DisableDirectoryCache

func (f *Filer) DisableDirectoryCache()

func (*Filer) FindEntry

func (f *Filer) FindEntry(ctx context.Context, p FullPath) (entry *Entry, err error)

func (*Filer) GetMaster

func (fs *Filer) GetMaster() string

func (*Filer) KeepConnectedToMaster

func (fs *Filer) KeepConnectedToMaster()

func (*Filer) ListDirectoryEntries

func (f *Filer) ListDirectoryEntries(ctx context.Context, p FullPath, startFileName string, inclusive bool, limit int) ([]*Entry, error)

func (*Filer) LoadConfiguration

func (f *Filer) LoadConfiguration(config *viper.Viper)

func (*Filer) NotifyUpdateEvent

func (f *Filer) NotifyUpdateEvent(oldEntry, newEntry *Entry, deleteChunks bool)

func (*Filer) RollbackTransaction

func (f *Filer) RollbackTransaction(ctx context.Context) error

func (*Filer) SetStore

func (f *Filer) SetStore(store FilerStore)

func (*Filer) UpdateEntry

func (f *Filer) UpdateEntry(ctx context.Context, oldEntry, entry *Entry) (err error)

type FilerClient

type FilerClient interface {
	WithFilerClient(ctx context.Context, fn func(filer_pb.SeaweedFilerClient) error) error
}

type FilerStore

type FilerStore interface {
	// GetName gets the name to locate the configuration in filer.toml file
	GetName() string
	// Initialize initializes the file store
	Initialize(configuration util.Configuration) error
	InsertEntry(context.Context, *Entry) error
	UpdateEntry(context.Context, *Entry) (err error)
	// err == filer2.ErrNotFound if not found
	FindEntry(context.Context, FullPath) (entry *Entry, err error)
	DeleteEntry(context.Context, FullPath) (err error)
	ListDirectoryEntries(ctx context.Context, dirPath FullPath, startFileName string, includeStartFile bool, limit int) ([]*Entry, error)

	BeginTransaction(ctx context.Context) (context.Context, error)
	CommitTransaction(ctx context.Context) error
	RollbackTransaction(ctx context.Context) error
}

type FilerStoreWrapper

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

func NewFilerStoreWrapper

func NewFilerStoreWrapper(store FilerStore) *FilerStoreWrapper

func (*FilerStoreWrapper) BeginTransaction

func (fsw *FilerStoreWrapper) BeginTransaction(ctx context.Context) (context.Context, error)

func (*FilerStoreWrapper) CommitTransaction

func (fsw *FilerStoreWrapper) CommitTransaction(ctx context.Context) error

func (*FilerStoreWrapper) DeleteEntry

func (fsw *FilerStoreWrapper) DeleteEntry(ctx context.Context, fp FullPath) (err error)

func (*FilerStoreWrapper) FindEntry

func (fsw *FilerStoreWrapper) FindEntry(ctx context.Context, fp FullPath) (entry *Entry, err error)

func (*FilerStoreWrapper) GetName

func (fsw *FilerStoreWrapper) GetName() string

func (*FilerStoreWrapper) Initialize

func (fsw *FilerStoreWrapper) Initialize(configuration util.Configuration) error

func (*FilerStoreWrapper) InsertEntry

func (fsw *FilerStoreWrapper) InsertEntry(ctx context.Context, entry *Entry) error

func (*FilerStoreWrapper) ListDirectoryEntries

func (fsw *FilerStoreWrapper) ListDirectoryEntries(ctx context.Context, dirPath FullPath, startFileName string, includeStartFile bool, limit int) ([]*Entry, error)

func (*FilerStoreWrapper) RollbackTransaction

func (fsw *FilerStoreWrapper) RollbackTransaction(ctx context.Context) error

func (*FilerStoreWrapper) UpdateEntry

func (fsw *FilerStoreWrapper) UpdateEntry(ctx context.Context, entry *Entry) error

type FullPath

type FullPath string

func NewFullPath

func NewFullPath(dir, name string) FullPath

func (FullPath) Child

func (fp FullPath) Child(name string) FullPath

func (FullPath) DirAndName

func (fp FullPath) DirAndName() (string, string)

func (FullPath) Name

func (fp FullPath) Name() string

type VisibleInterval

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

func MergeIntoVisibles

func MergeIntoVisibles(visibles, newVisibles []VisibleInterval, chunk *filer_pb.FileChunk) []VisibleInterval

func NonOverlappingVisibleIntervals

func NonOverlappingVisibleIntervals(chunks []*filer_pb.FileChunk) (visibles []VisibleInterval)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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