treeply

package module
v0.0.0-...-7bb844c Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: BSD-2-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const INVALID_FD = -1
View Source
const ReadChunkSize = 1024 * 1024
View Source
const UNALLOCATED_BLOCK_ID = 0

Variables

View Source
var FILE_CHANGED = errors.New("File changed")
View Source
var GCSPathRegEx = regexp.MustCompile("gs://([^/]+)/(.*)$")
View Source
var INVALID_HANDLE = errors.New("Invalid handle")
View Source
var INVALID_INODE = errors.New("Invalid INode")
View Source
var INVALID_NAME = errors.New("Invalid Name")
View Source
var IS_DIR = errors.New("Is directory")
View Source
var IS_NOT_DIR = errors.New("INode is not a directory")

Functions

func CreateListener

func CreateListener(socketName string, fs *FileService) error

func DispatchReq

func DispatchReq(client *FileClient, j []byte) interface{}

func InstallCleanup

func InstallCleanup(socketName string)

func Transfer

func Transfer(ctx context.Context, inode INode, blockSize int64, blockIndex int, tempDir string, completions chan interface{}, reader io.Reader, readChunkSize int) error

func TransferService

func TransferService(queue chan interface{}, INodes *INodes)

Types

type BlockCompletion

type BlockCompletion struct {
	Block    INodeBlock
	Filename string
}

type BlockError

type BlockError struct {
	Block INodeBlock
	Error error
}

type BlockID

type BlockID uint64

type BlockRequest

type BlockRequest struct {
	Block     INodeBlock
	BlockSize int64
	GetReader func(context.Context) (io.Reader, error)
	WorkDir   string
	Response  chan error
}

type BlockState

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

type Blocks

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

func (*Blocks) Allocate

func (b *Blocks) Allocate(filename string) BlockID

func (*Blocks) GetDiagnostics

func (b *Blocks) GetDiagnostics() *BlocksDiagnostics

func (*Blocks) ReadBlock

func (b *Blocks) ReadBlock(blockID BlockID, startOffsetWithinBlock int64, buffer []byte) (int, error)

func (*Blocks) UpdateRefCount

func (b *Blocks) UpdateRefCount(blockID BlockID, delta int) int

type BlocksDiagnostics

type BlocksDiagnostics struct {
	BlocksInUse  int
	FreeBlockIDs int
	Dir          string
}

type BoundedReader

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

func (*BoundedReader) Close

func (b *BoundedReader) Close() error

func (*BoundedReader) Read

func (b *BoundedReader) Read(buffer []byte) (int, error)

type CloseReq

type CloseReq struct {
	FD int
}

type CloseResp

type CloseResp struct {
}

type Command

type Command struct {
	Type           string
	ReqConstructor func() interface{}
	Invoke         func(interface{}) (interface{}, error)
}

type DiagReq

type DiagReq struct {
}

type DiagnosticRequest

type DiagnosticRequest struct {
	Response chan *TransferServiceStatus
}

type DirEntries

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

func NewDirEntries

func NewDirEntries(inode INode, parentINode INode) *DirEntries

func (*DirEntries) Get

func (d *DirEntries) Get() []ExtendedDirEntry

func (*DirEntries) IsPopulated

func (d *DirEntries) IsPopulated(name string) bool

func (*DirEntries) Lookup

func (d *DirEntries) Lookup(name string) (INode, error)

func (*DirEntries) Set

func (d *DirEntries) Set(entries []DirEntry)

func (*DirEntries) SetEntry

func (d *DirEntries) SetEntry(name string, inode INode)

type DirEntry

type DirEntry struct {
	Name  string
	INode INode
}

type DirRemoteProvider

type DirRemoteProvider struct {
	Root            string
	DirListingDelay time.Duration
	ReadDelay       time.Duration
}

func (*DirRemoteProvider) GetDiagnostics

func (d *DirRemoteProvider) GetDiagnostics() interface{}

func (*DirRemoteProvider) GetDirListing

func (d *DirRemoteProvider) GetDirListing(ctx context.Context, path string) ([]RemoteFile, error)

func (*DirRemoteProvider) GetReader

func (d *DirRemoteProvider) GetReader(ctx context.Context, path string, ETag string, Offset int64, Length int64) (io.Reader, error)

type DirRemoteProviderDiagnostics

type DirRemoteProviderDiagnostics struct {
	Root string
}

type ErrorResp

type ErrorResp struct {
	Message string
}

type ExtendedDirEntry

type ExtendedDirEntry struct {
	Name  string
	INode INode
	Size  int64
	IsDir bool
}

type FileClient

type FileClient struct {
	FileService *FileService

	FileHandles map[int]*FileHandle
	// contains filtered or unexported fields
}

Intended to be used by a single thread

func NewFileClient

func NewFileClient(fs *FileService) *FileClient

func (*FileClient) Close

func (fc *FileClient) Close(req *CloseReq) (*CloseResp, error)

func (*FileClient) Forget

func (fc *FileClient) Forget(req *ForgetReq) (*CloseResp, error)

func (*FileClient) GetDiagnostics

func (f *FileClient) GetDiagnostics() *FileClientDiagnostics

func (*FileClient) GetINodeForPath

func (fc *FileClient) GetINodeForPath(path string) (INode, error)

func (*FileClient) ListDir

func (fc *FileClient) ListDir(req *ListDirReq) (*ListDirResp, error)

func (*FileClient) Open

func (fc *FileClient) Open(req *OpenReq) (*OpenResp, error)

func (*FileClient) Read

func (fc *FileClient) Read(req *ReadReq) (*ReadResp, error)

type FileClientDiagnostics

type FileClientDiagnostics struct {
	FileService     *FileServiceDiagnostics
	OpenFiles       int
	FreeFileHandles int
}

type FileClientDirEntry

type FileClientDirEntry struct {
	Name  string
	Size  int64
	INode INode
	IsDir bool
}

type FileHandle

type FileHandle struct {
	INode  INode
	Offset int64
}

type FileService

type FileService struct {
	Remote               RemoteProvider
	INodes               *INodes
	Root                 INode
	TransferServiceQueue chan interface{}
}

func NewFileService

func NewFileService(Remote RemoteProvider, WorkDir string, BlockSize int) (*FileService, error)

func (*FileService) Forget

func (f *FileService) Forget(path string) error

func (*FileService) GetDiagnostics

func (f *FileService) GetDiagnostics() *FileServiceDiagnostics

func (*FileService) GetINodeForPath

func (f *FileService) GetINodeForPath(path string) (INode, error)

type FileServiceDiagnostics

type FileServiceDiagnostics struct {
	Remote                interface{}
	INodes                interface{}
	TransferServiceStatus interface{}
}

type ForgetReq

type ForgetReq struct {
	Path string
}

type GCSRemoteProvider

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

func NewGCSRemoteProvider

func NewGCSRemoteProvider(ctx context.Context, root string) *GCSRemoteProvider

func (*GCSRemoteProvider) GetDiagnostics

func (g *GCSRemoteProvider) GetDiagnostics() interface{}

func (*GCSRemoteProvider) GetDirListing

func (g *GCSRemoteProvider) GetDirListing(ctx context.Context, path string) ([]RemoteFile, error)

func (*GCSRemoteProvider) GetReader

func (g *GCSRemoteProvider) GetReader(ctx context.Context, path string, ETag string, Offset int64, Length int64) (io.Reader, error)

type GetDirCompletion

type GetDirCompletion struct {
	DirEntries []DirEntry
	DirINode   INode
}

type GetDirRequest

type GetDirRequest struct {
	GetDirListing          func(context.Context) ([]RemoteFile, error)
	DirINode               INode
	MakeDirEntriesCallback func(name string) func(inode INode)
	MakeFileCallback       func(name string, etag string) RequestCallback
	Response               chan error
}

type INode

type INode uint64

type INodeBlock

type INodeBlock struct {
	INode      INode
	BlockIndex int
}

type INodeStat

type INodeStat struct {
	Size  int64
	IsDir bool
}

type INodeState

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

type INodes

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

func NewINodes

func NewINodes(workDir string, blockSize int) (*INodes, error)

func (*INodes) CloneINodeDir

func (i *INodes) CloneINodeDir(inode INode) (INode, error)

func (*INodes) CreateLazyDir

func (i *INodes) CreateLazyDir(parentINode INode, callback *LazyDirectoryCallback) INode

func (*INodes) CreateLazyFile

func (i *INodes) CreateLazyFile(length int64, requestCallback RequestCallback) INode

func (*INodes) GetBlockIDs

func (in *INodes) GetBlockIDs(inode INode, startIndex int64, count int64) ([]BlockID, error)

func (*INodes) GetDiagnostics

func (inodes *INodes) GetDiagnostics() interface{}

func (*INodes) IsBlockPopulated

func (inodes *INodes) IsBlockPopulated(inode INode, blockIndex int) bool

func (*INodes) IsDirPopulated

func (inodes *INodes) IsDirPopulated(inode INode) bool

func (*INodes) LookupInDir

func (inodes *INodes) LookupInDir(dirINode INode, name string) INode

func (*INodes) LookupInDirWithErr

func (inodes *INodes) LookupInDirWithErr(dirINode INode, name string) (INode, error)

func (*INodes) MarkUnreadable

func (in *INodes) MarkUnreadable(inode INode, failure error)

func (*INodes) ReadDir

func (inodes *INodes) ReadDir(inode INode) []ExtendedDirEntry

func (*INodes) ReadDirWithErr

func (inodes *INodes) ReadDirWithErr(inode INode) ([]ExtendedDirEntry, error)

func (*INodes) ReadFile

func (inodes *INodes) ReadFile(inode INode, offset int64, buffer []byte) (int, error)

func (*INodes) RequestMissingBlocks

func (inodes *INodes) RequestMissingBlocks(inode INode, blockIndices []int)

func (*INodes) SetBlock

func (in *INodes) SetBlock(inode INode, index int, blockID BlockID)

func (*INodes) SetDirEntries

func (in *INodes) SetDirEntries(inode INode, dirEntries []DirEntry)

func (*INodes) SetDirEntry

func (in *INodes) SetDirEntry(inode INode, name string, _inode INode)

func (*INodes) Stat

func (i *INodes) Stat(inode INode) (*INodeStat, error)

func (*INodes) UpdateRefCount

func (i *INodes) UpdateRefCount(inode INode, delta int) int

type INodesDiagnostics

type INodesDiagnostics struct {
	NextINode   INode
	FreeINodes  int
	INodesInUse int
	Blocks      *BlocksDiagnostics
	BlockSize   int64
	WorkDir     string
}

type LazyDirectoryCallback

type LazyDirectoryCallback struct {
	RequestDirEntries func(inode INode)
	RequestDirEntry   func(inode INode, name string)
}

type ListDirReq

type ListDirReq struct {
	Path string
}

type ListDirResp

type ListDirResp struct {
	Entries []FileClientDirEntry
}

type OpenReq

type OpenReq struct {
	Path string
}

type OpenResp

type OpenResp struct {
	FD int
}

type ReadReq

type ReadReq struct {
	FD     int
	Length int
}

type ReadResp

type ReadResp struct {
	Data []byte
}

type RemoteFile

type RemoteFile struct {
	Name  string
	IsDir bool
	ETag  string
	Size  int64
}

type RemoteProvider

type RemoteProvider interface {
	GetDirListing(ctx context.Context, path string) ([]RemoteFile, error)
	GetReader(ctx context.Context, path string, ETag string, Offset int64, Length int64) (io.Reader, error)
	GetDiagnostics() interface{}
}

type ReqEnvelope

type ReqEnvelope struct {
	Type    string
	Payload json.RawMessage
}

type RequestCallback

type RequestCallback func(inode INode, blockIndices []int)

type RespEnvelope

type RespEnvelope struct {
	Type    string
	Payload interface{}
}

type Response

type Response interface{}

type SeekReq

type SeekReq struct {
	FD     int
	Offset int
	Whence string
}

type SeekResp

type SeekResp struct {
	Offset int
}

type TransferServiceStatus

type TransferServiceStatus struct {
	BlocksRequested         int
	ThreadsWaitingForBlocks int
	DirsRequested           int
	ThreadsWaitingForDirs   int
}

type WaitingThreads

type WaitingThreads struct {
	Waiting []chan error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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