Documentation
¶
Overview ¶
Log is disabled by default Specific logger can be passed to the library using a 'aostor.UseLogger(...)' call You can enable library log without importing Seelog with a 'aostor.SetLogWriter(writer)' call
Index ¶
- Constants
- Variables
- func AppendFile(tarfn string, info Info, fn string, compressMethod string) (pos uint64, err error)
- func AppendLink(tarfn string, info Info, src string, dst string) (err error)
- func BaseName(fn string) string
- func BytesToStr(buf []byte) string
- func CalculateLink(basedir, destfn string) string
- func CanonicalHeaderKey(key []byte) []byte
- func Compact(realm string, onChange NotifyFunc) error
- func CompactIndices(realm string, level uint, onChange func(), alreadyLocked bool) error
- func CreateTar(tarfn string, dirname string, sizeLimit uint64, alreadyLocked bool) error
- func DeDup(path string, hash string, alreadyLocked bool) int
- func DisableLog()
- func FhandleTarHeader(fh *os.File) (hdr *tar.Header, err error)
- func FileTarHeader(fn string) (hdr *tar.Header, err error)
- func FillCaches(force bool) error
- func FillHeader(hdr *tar.Header)
- func FindLinkOrigin(fn string, abs bool) string
- func FindTarEnd(r io.ReadSeeker, last_known uint64) (pos uint64, err error)
- func Finfo2Theader(fi os.FileInfo) (hdr *tar.Header, err error)
- func FlushLog()
- func GetLogger() seelog.LoggerInterface
- func LogIsDisabled() bool
- func ReadItem(tarfn string, pos int64) (ret io.Reader, err error)
- func SameFile(fn1, fn2 string) (bool, error)
- func SetLogWriter(writer io.Writer) error
- func StrToBytes(str string) []byte
- func UseLogger(newLogger seelog.LoggerInterface)
- func UseLoggerFromConfigFile(filename string)
- func Walk(root string, walkFn filepath.WalkFunc) error
- func WriteTar(tw *tar.Writer, hdr *tar.Header, r io.Reader) (err error)
- type Config
- type CountingWriter
- type Info
- func (info *Info) Add(key string, val string)
- func (info *Info) AddBytes(key, val []byte)
- func (info *Info) Bytes() []byte
- func (info *Info) Copy(header http.Header)
- func (info *Info) CopyFrom(header map[string][]string)
- func (info *Info) Get(key string) string
- func (info *Info) NewReader() (io.Reader, int)
- func (info *Info) Prepare() error
- func (info *Info) SetFilename(fn string, mime string)
- type NotifyFunc
- type ReadWriteSeekCloser
- type SymlinkError
- type UUID
Constants ¶
const ( MIN_CDB_SIZE = 2048 MAX_CDB_SIZE = (1 << 31) - 1 )
const ( DefaultConfigFile = "aostor.ini" DefaultTarThreshold = 1000 * (1 << 20) // 1000Mb DefaultIndexThreshold = 10 // How many index cdb should be merged DefaultContentHash = "sha1" DefaultCompressMethod = "gzip" DefaultHostport = ":8341" DefaultLogConfFile = "seelog.xml" TestConfig = `` /* 247-byte string literal not displayed */ )
const ( SuffInfo = "!" // suffix of info file SuffLink = "@" // suffix of link SuffData = "#" // suffix of data file (+ compression type) BS = 512 // tar blocksize )
const InfoPref = "X-Aostor-" // prefix of specific headers
Variables ¶
var ( ErrSymlink = errors.New("aodb/tarhelper: symlink") NotRegularFile = errors.New("aodb/tarhelper: not a regular file") ErrBadTarEnd = errors.New("aodb/tarhelper: bad tar end") )
var AlreadyLocked = errors.New("AlreadyLocked")
var (
ConfigFile = DefaultConfigFile
)
var DefaultLogConf = `` /* 261-byte string literal not displayed */
var MissingFilenameError = errors.New("Filename is missing!")
var (
NotFound = errors.New("Not Found")
)
var StopIteration = errors.New("StopIteration")
var UUIDMaker = uuid.NewUUID4
Functions ¶
func AppendFile ¶
appends file fn with info to tarfn, compressing with compressMethod
func AppendLink ¶
appends as link pointing at a previously written item
func CalculateLink ¶
CalculateLink calculates the symbolic link for destfn relative to basedir
func CanonicalHeaderKey ¶
func Compact ¶
func Compact(realm string, onChange NotifyFunc) error
compacts staging dir: moves info and data files to tar; calls CompactIndices
func CompactIndices ¶
Compact compacts the index cdbs
func DeDup ¶
deduplication: replace data with a symlink to a previous data with the same contant-hash-...
func FhandleTarHeader ¶
tar.Header for a file
func FileTarHeader ¶
tar.Header for a filename
func FillCaches ¶
fills caches (reads tar files and cdb files, caches path)
func FillHeader ¶
fills tar.Header missing information (uid/gid, username/groupname, times ...)
func FindLinkOrigin ¶
func FindTarEnd ¶
func FindTarEnd(r io.ReadSeeker, last_known uint64) (pos uint64, err error)
def _init_find_end(self, end_offset, name): '''Move to the end of the archive, before the first empty block.''' if not end_offset: end_offset = self.END_OFFSET_CACHE.get(name, 0) self.firstmember = None perf_mark() if end_offset > self.offset: self.fileobj.seek(0, 2) p = self.fileobj.tell() self.offset = min(p - tarfile.BLOCKSIZE, end_offset) self.fileobj.seek(self.offset) perf_print('%s end_offset > self.offset', name) if DEBUG_MEM: LOG.debug('before while: next() mem=%dKb', usedmem()) while True: if self.next() is None: if self.offset > 0: self.fileobj.seek(-tarfile.BLOCKSIZE, 1) break perf_print('find_end %s', name) self.END_OFFSET_CACHE[name] = self.offset if DEBUG_MEM: LOG.debug('after while: next() mem=%dKb', usedmem())
Move to the end of the archive, before the first empty block.
func Finfo2Theader ¶
create tar.Header from os.FileInfo
func GetLogger ¶
func GetLogger() seelog.LoggerInterface
func LogIsDisabled ¶
func LogIsDisabled() bool
func ReadItem ¶
Reads from tarfn at starting at pos returns a SymplinkError with the symlink information, if there is a symlink at the given position - to be able to retry with the symlink
func SetLogWriter ¶
SetLogWriter uses a specified io.Writer to output library log. Use this func if you are not using Seelog logging system in your app.
func UseLogger ¶
func UseLogger(newLogger seelog.LoggerInterface)
UseLogger uses a specified seelog.LoggerInterface to output library log. Use this func if you are using Seelog logging system in your app.
func UseLoggerFromConfigFile ¶
func UseLoggerFromConfigFile(filename string)
loads logger from config file
func Walk ¶
Walk walks the file tree rooted at root, calling walkFn for each file or directory in the tree, including root. All errors that arise visiting files and directories are filtered by walkFn. The files are walked in inode order, which makes the output indeterministic but means that even for very large directories Walk can be efficient.
Types ¶
type Config ¶
type Config struct {
StagingDir, IndexDir, TarDir string
IndexThreshold uint
TarThreshold uint64
Hostport string
Realms []string
ContentHash string
ContentHashFunc func() hash.Hash
LogConf string
CompressMethod string
}
configuration variables, parsed
type CountingWriter ¶
type CountingWriter struct {
Num uint64 // bytes written
}
A writer which counts bytes written into it
func NewCounter ¶
func NewCounter() *CountingWriter
type Info ¶
func Get ¶
returns the associated info and data of a given uuid in a given realm
- checks staging area
- checks level zero (symlinked cdbs in ndx/L00)
- checks higher level (older, too) cdbs in ndx/L01, ndx/L02...
The difference between level zero and higher is the following: at level zero, there are the tar files' cdbs (symlinked), and these cdbs contains the info (with the position information), ready to serve. At higher levels, the cdbs contains only "/%d" signs (which cdb, only a number) and that sign is which zero-level cdb. So at this level an additional lookup is required.
func GetFromCdb ¶
func InfoFromBytes ¶
func (*Info) SetFilename ¶
sets the filename and the mimetype, conditionally (if given)
type NotifyFunc ¶
type NotifyFunc func()
type ReadWriteSeekCloser ¶
type ReadWriteSeekCloser interface { io.ReadWriteSeeker io.Closer }
Reader + Writer + Seeker + Closer
func OpenForAppend ¶
Opens the tarfile for appending - seeks to the end
type SymlinkError ¶
type SymlinkError struct {
Linkname string
}
func (*SymlinkError) Error ¶
func (e *SymlinkError) Error() string
type UUID ¶
func Put ¶
puts file (info + data) into the given realm - returns the key if the key is in info, then uses that
func UUIDFromBytes ¶
func UUIDFromString ¶
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Append-Only Storage HTTP server
|
Append-Only Storage HTTP server |
uuid.go
|
uuid.go |