allocdir

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2016 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// The name of the directory that is shared across tasks in a task group.
	SharedAllocName = "alloc"

	// Name of the directory where logs of Tasks are written
	LogDirName = "logs"

	// The set of directories that exist inside eache shared alloc directory.
	SharedAllocDirs = []string{LogDirName, "tmp", "data"}

	// The name of the directory that exists inside each task directory
	// regardless of driver.
	TaskLocal = "local"

	// TaskDirs is the set of directories created in each tasks directory.
	TaskDirs = []string{"tmp"}
)
View Source
var (
	//Path inside container for mounted directory that is shared across tasks in a task group.
	SharedAllocContainerPath = filepath.Join("c:\\", SharedAllocName)

	//Path inside container for mounted directory for local storage.
	TaskLocalContainerPath = filepath.Join("c:\\", TaskLocal)
)

Functions

This section is empty.

Types

type AllocDir

type AllocDir struct {
	// AllocDir is the directory used for storing any state
	// of this allocation. It will be purged on alloc destroy.
	AllocDir string

	// The shared directory is available to all tasks within the same task
	// group.
	SharedDir string

	// TaskDirs is a mapping of task names to their non-shared directory.
	TaskDirs map[string]string
}

func NewAllocDir

func NewAllocDir(allocDir string) *AllocDir

func (*AllocDir) BlockUntilExists added in v0.4.1

func (d *AllocDir) BlockUntilExists(path string, t *tomb.Tomb) chan error

BlockUntilExists blocks until the passed file relative the allocation directory exists. The block can be cancelled with the passed tomb.

func (*AllocDir) Build

func (d *AllocDir) Build(tasks []*structs.Task) error

Given a list of a task build the correct alloc structure.

func (*AllocDir) ChangeEvents added in v0.4.1

func (d *AllocDir) ChangeEvents(path string, curOffset int64, t *tomb.Tomb) (*watch.FileChanges, error)

ChangeEvents watches for changes to the passed path relative to the allocation directory. The offset should be the last read offset. The tomb is used to clean up the watch.

func (*AllocDir) Destroy

func (d *AllocDir) Destroy() error

Tears down previously build directory structure.

func (*AllocDir) Embed

func (d *AllocDir) Embed(task string, entries map[string]string) error

Embed takes a mapping of absolute directory or file paths on the host to their intended, relative location within the task directory. Embed attempts hardlink and then defaults to copying. If the path exists on the host and can't be embedded an error is returned.

func (*AllocDir) List added in v0.3.0

func (d *AllocDir) List(path string) ([]*AllocFileInfo, error)

List returns the list of files at a path relative to the alloc dir

func (*AllocDir) LogDir added in v0.3.0

func (d *AllocDir) LogDir() string

LogDir returns the log dir in the current allocation directory

func (*AllocDir) MountSharedDir

func (d *AllocDir) MountSharedDir(task string) error

MountSharedDir mounts the shared directory into the specified task's directory. Mount is documented at an OS level in their respective implementation files.

func (*AllocDir) MountSpecialDirs added in v0.3.0

func (d *AllocDir) MountSpecialDirs(taskDir string) error

MountSpecialDirs mounts the dev and proc file system on the chroot of the task. It's a no-op on windows.

func (*AllocDir) ReadAt added in v0.3.0

func (d *AllocDir) ReadAt(path string, offset int64) (io.ReadCloser, error)

ReadAt returns a reader for a file at the path relative to the alloc dir

func (*AllocDir) Stat added in v0.3.0

func (d *AllocDir) Stat(path string) (*AllocFileInfo, error)

Stat returns information about the file at a path relative to the alloc dir

func (*AllocDir) UnmountAll added in v0.3.0

func (d *AllocDir) UnmountAll() error

type AllocDirFS added in v0.3.0

type AllocDirFS interface {
	List(path string) ([]*AllocFileInfo, error)
	Stat(path string) (*AllocFileInfo, error)
	ReadAt(path string, offset int64) (io.ReadCloser, error)
	BlockUntilExists(path string, t *tomb.Tomb) chan error
	ChangeEvents(path string, curOffset int64, t *tomb.Tomb) (*watch.FileChanges, error)
}

AllocDirFS exposes file operations on the alloc dir

type AllocFileInfo added in v0.3.0

type AllocFileInfo struct {
	Name     string
	IsDir    bool
	Size     int64
	FileMode string
	ModTime  time.Time
}

AllocFileInfo holds information about a file inside the AllocDir

Jump to

Keyboard shortcuts

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