swift

package
v0.0.0-...-a0bb070 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ONE_WEEK                = 604800
	METADATA_CHUNK_SIZE     = 65536
	HASH_FILE               = "hashes.pkl"
	HASH_INVALIDATIONS_FILE = "hashes.invalid"
)

Variables

View Source
var (
	ErrLockPath                = errors.New("Error locking path")
	ErrPathNotDir              = errors.New("Path is not a directory")
	ErrMalformedPickleFile     = errors.New("pickle file is malformed")
	ErrTempFileNotCreated      = errors.New("unable to create temp file")
	ErrTimestampNotFoundInMeta = errors.New("unable to find x-timestamp")
	ErrMetaCorruption          = errors.New("metadata corrupted")
	ErrFileCorruption          = errors.New("file corrupted")
	ErrConfigNotLoaded         = errors.New("unable to read config")
	ErrDriveFull               = errors.New("Drive Full")
)

Functions

func ConsolidateHashes

func ConsolidateHashes(pklPath, invalidPath string) (map[string]string, error)

func GetFileMTime

func GetFileMTime(filePath string) (int64, error)

func HashCleanupListDir

func HashCleanupListDir(hashDir string, reclaimAge int64) ([]string, error)

func InvalidateHash

func InvalidateHash(hashDir string) error

InvalidateHash invalidates the hashdir's suffix hash, indicating it needs to be recalculated.

func IsFileNotExist

func IsFileNotExist(path string) bool

func LoadInvalidSuffixes

func LoadInvalidSuffixes(invalidPath string) ([]string, error)

Load hash list from hashes.invalid

func LoadPklHashes

func LoadPklHashes(pklPath string) (map[string]string, error)

Load hash list from hashes.pkl TODO: need to remove corrupted hashes.pkl file

func ObjectFiles

func ObjectFiles(directory string) (string, string)

func ObjectMetadata

func ObjectMetadata(dataFile string, metaFile string) (map[string]string, error)

func OpenObjectMetadata

func OpenObjectMetadata(fd uintptr, metaFile string) (map[string]string, error)

func PolicyDir

func PolicyDir(policy int) string

func QuarantineHash

func QuarantineHash(hashDir string) error

func RawReadMetadata

func RawReadMetadata(fileNameOrFd interface{}) ([]byte, error)

func RawWriteMetadata

func RawWriteMetadata(fd uintptr, buf []byte) error

func ReadMetadata

func ReadMetadata(fileNameOrFd interface{}) (map[string]string, error)

func RecalculateSuffixHash

func RecalculateSuffixHash(suffixDir string, reclaimAge int64) (string, error)

func SaveHashesPkl

func SaveHashesPkl(hashes map[string]string, pklPath, tempDir, partitionDir string) error

func SwiftEngineConstructor

func SwiftEngineConstructor(config conf.Config, policy *conf.Policy,
	flags *flag.FlagSet, wg *sync.WaitGroup) (engine.ObjectEngine, error)

creates a SwiftEngine given the object server configs.

func TempDir

func TempDir(driveRoot string, device string) string

func UnPolicyDir

func UnPolicyDir(dir string) (int, error)

func WriteMetadata

func WriteMetadata(fd uintptr, v map[string]string) error

Types

type SwiftEngine

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

func (*SwiftEngine) Close

func (f *SwiftEngine) Close() error

func (*SwiftEngine) GetHashes

func (f *SwiftEngine) GetHashes(
	device, partition string, recalculate []string) (map[string]string, error)

func (*SwiftEngine) New

func (f *SwiftEngine) New(vars map[string]string,
	needData bool) (engine.Object, error)

New returns an instance of SwiftObject with the given parameters. Metadata is read in and if needData is true, the file is opened. AsyncWG is a waitgroup if the object spawns any async operations

type SwiftObject

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

SwiftObject implements an Object that is compatible with Swift's object server.

func (*SwiftObject) Close

func (o *SwiftObject) Close() error

Close releases any resources used by the instance of SwiftObject

func (*SwiftObject) Commit

func (o *SwiftObject) Commit(metadata map[string]string) error

Commit commits an open data file to disk, given the metadata.

func (*SwiftObject) CommitMeta

func (o *SwiftObject) CommitMeta(metadata map[string]string) error

func (*SwiftObject) ContentLength

func (o *SwiftObject) ContentLength() int64

ContentLength parses and returns the Content-Length for the object.

func (*SwiftObject) Copy

func (o *SwiftObject) Copy(dsts ...io.Writer) (written int64, err error)

Copy copies all data from the underlying .data file to the given writers.

func (*SwiftObject) CopyRange

func (o *SwiftObject) CopyRange(
	w io.Writer, start int64, end int64) (int64, error)

CopyRange copies data in the range of start to end from the underlying .data file to the writer.

func (*SwiftObject) Delete

func (o *SwiftObject) Delete(metadata map[string]string) error

Delete deletes the object.

func (*SwiftObject) Exists

func (o *SwiftObject) Exists() bool

Exists returns true if the object exists, that is if it has a .data file.

func (*SwiftObject) Metadata

func (o *SwiftObject) Metadata() map[string]string

Metadata returns the object's metadata.

func (*SwiftObject) Quarantine

func (o *SwiftObject) Quarantine() error

Quarantine removes the object's underlying files to the Quarantined directory on the device.

func (*SwiftObject) Repr

func (o *SwiftObject) Repr() string

Repr returns a string that identifies the object in some useful way, used for logging.

func (*SwiftObject) SetData

func (o *SwiftObject) SetData(size int64) (io.Writer, error)

SetData is called to set the object's data. It takes a size (if available, otherwise set to zero).

Jump to

Keyboard shortcuts

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