Documentation
¶
Index ¶
- Constants
- Variables
- func GetGPUCount() (int, error)
- func GetGPUModel() (string, error)
- func GetTaskId(cfg TaskConfig) string
- func InitGPUMonitor() error
- func NewResourceManager(totalCPU float64, totalMem int, hasGPU bool) *resourceManager
- func NewResourceMonitor(hasGPU bool) *resourceMonitor
- func ShutdownGPUMonitor() error
- type DockerTask
- type DockerTaskFactory
- type GPUUtil
- type LocalDockerRepo
- type MecaExecutor
- func (meca *MecaExecutor) Execute(ctx context.Context, taskCfg TaskConfig, input []byte) ([]byte, error)
- func (meca *MecaExecutor) Pause()
- func (meca *MecaExecutor) Start()
- func (meca *MecaExecutor) Stats() ResourceStats
- func (meca *MecaExecutor) Stop()
- func (meca *MecaExecutor) UnPause()
- func (meca *MecaExecutor) UpdateConfig(cfg MecaExecutorConfigReq) (string, error)
- type MecaExecutorConfig
- type MecaExecutorConfigReq
- type MecaRequestHandle
- type ResourceLimit
- type ResourceManager
- type ResourceMonitor
- type ResourceStats
- type SGXConfig
- type Task
- type TaskConfig
- type TaskFactory
- type TaskRepo
Constants ¶
View Source
const ( SGXBindDevice = "/dev/sgx/enclave" SGXBindAesmd = "/var/run/aesmd" )
View Source
const ( TaskTypeMicroVM = "microVM" TaskTypeContainer = "container" )
View Source
const (
SGXRAREQUEST = "SGXRAREQUEST"
)
Variables ¶
Functions ¶
func GetGPUCount ¶
func GetTaskId ¶
func GetTaskId(cfg TaskConfig) string
func InitGPUMonitor ¶
func InitGPUMonitor() error
func NewResourceManager ¶
func NewResourceMonitor ¶
func NewResourceMonitor(hasGPU bool) *resourceMonitor
func ShutdownGPUMonitor ¶
func ShutdownGPUMonitor() error
Types ¶
type DockerTask ¶
type DockerTask struct {
// contains filtered or unexported fields
}
func NewDockerTask ¶
func NewDockerTask(taskId string, cfg TaskConfig, cli *client.Client) *DockerTask
func (*DockerTask) CleanUp ¶
func (t *DockerTask) CleanUp() error
func (*DockerTask) GetId ¶
func (t *DockerTask) GetId() string
func (*DockerTask) GetResource ¶
func (t *DockerTask) GetResource() ResourceLimit
type DockerTaskFactory ¶
type DockerTaskFactory struct {
// contains filtered or unexported fields
}
func NewDockerTaskFactory ¶
func NewDockerTaskFactory(cli *client.Client) *DockerTaskFactory
func (*DockerTaskFactory) Build ¶
func (f *DockerTaskFactory) Build(taskId string, cfg TaskConfig) (Task, error)
type GPUUtil ¶
type GPUUtil struct {
// contains filtered or unexported fields
}
func GetGPUUtilization ¶
type LocalDockerRepo ¶
type LocalDockerRepo struct {
// contains filtered or unexported fields
}
func NewLocalDockerRepo ¶
func NewLocalDockerRepo(cli *client.Client) *LocalDockerRepo
func (*LocalDockerRepo) Fetch ¶
func (r *LocalDockerRepo) Fetch(id, remote, version string) error
type MecaExecutor ¶
type MecaExecutor struct {
// contains filtered or unexported fields
}
func NewMecaExecutorFromConfig ¶
func NewMecaExecutorFromConfig(cfg MecaExecutorConfig) *MecaExecutor
func (*MecaExecutor) Execute ¶
func (meca *MecaExecutor) Execute(ctx context.Context, taskCfg TaskConfig, input []byte) ([]byte, error)
func (*MecaExecutor) Pause ¶
func (meca *MecaExecutor) Pause()
func (*MecaExecutor) Start ¶
func (meca *MecaExecutor) Start()
will launch cleaner goroutine to remove tasks after timeout
func (*MecaExecutor) Stats ¶
func (meca *MecaExecutor) Stats() ResourceStats
func (*MecaExecutor) Stop ¶
func (meca *MecaExecutor) Stop()
func (*MecaExecutor) UnPause ¶
func (meca *MecaExecutor) UnPause()
func (*MecaExecutor) UpdateConfig ¶
func (meca *MecaExecutor) UpdateConfig(cfg MecaExecutorConfigReq) (string, error)
type MecaExecutorConfig ¶
type MecaExecutorConfig struct {
Type string `yaml:"type"`
Timeout int `yaml:"timeout"`
Cpu float64 `yaml:"cpu"`
Mem int `yaml:"mem"`
HasGPU bool `yaml:"has_gpu"`
MicroVMRuntime string `yaml:"microVM_runtime"`
SGX SGXConfig `yaml:"sgx"`
}
func ParseMecaExecutorConfig ¶
func ParseMecaExecutorConfig(filename string) (MecaExecutorConfig, error)
type MecaExecutorConfigReq ¶
type MecaRequestHandle ¶
type MecaRequestHandle struct {
// contains filtered or unexported fields
}
func NewMecaRequestHandle ¶
func NewMecaRequestHandle(ctx context.Context, taskCfg TaskConfig, input []byte) *MecaRequestHandle
func (*MecaRequestHandle) Done ¶
func (h *MecaRequestHandle) Done()
func (*MecaRequestHandle) Wait ¶
func (h *MecaRequestHandle) Wait()
type ResourceLimit ¶
type ResourceLimit struct {
CPU int64 `json:"cpu"` // core
MEM int64 `json:"mem"` // MB
UseGPU bool `json:"use_gpu"`
GPUCount int64 `json:"gpu_count"`
}
func (ResourceLimit) String ¶
func (l ResourceLimit) String() string
type ResourceManager ¶
type ResourceManager interface {
Start() bool
Stop()
UpdateConfig(cpu float64, mem int) string
Reserve(cpu float64, mem int) error
Release(cpu float64, mem int) error
GetMaxCPUAndMem() (float64, uint64)
GetGPUCount() int
ReserveGPU(count int, utilLimit int) ([]int, error)
ReleaseGPU([]int) error
Stats() ResourceStats
}
controls the allocation of resources to tasks.
type ResourceMonitor ¶
type ResourceMonitor interface {
Start() bool // start monitoring
Stop() // stop monitoring
GetCPU() int // in core count
GetMEM() int // in MB
GetCPUUsed() float64 // in core count
GetMEMUsed() float64 // in MB
GetCPUAvail() float64 // in core count
GetMEMAvail() float64 // in MB
GetGPUCount() int // in count
GetGPUModel() string // in string
GetGPUUtils() []GPUUtil // in list of GPUUtil (% pair)
}
monitor the availble resource on the host
type ResourceStats ¶
type ResourceStats struct {
TotalCPU int `json:"total_cpu"` // core
TotalMEM int `json:"total_mem"` // MB
UsedCPU float64 `json:"used_cpu"` // %
UsedMEM float64 `json:"used_mem"` // %
TaskCPU float64 `json:"task_cpu"` // core
TaskMEM int `json:"task_mem"` // MB
TaskUsedCPU float64 `json:"task_used_cpu"` // %
TaskUsedMEM float64 `json:"task_used_mem"` // %
GPUModel string `json:"gpu_model"`
TaskGPU int `json:"task_gpu"` // count
TaskUsedGPU int `json:"task_used_gpu"` // count
}
func (*ResourceStats) IsEmpty ¶
func (rs *ResourceStats) IsEmpty() bool
type TaskConfig ¶
type TaskConfig struct {
ImageId string `json:"imageid"`
Runtime string `json:"runtime"`
Rsrc ResourceLimit `json:"resource_limit"`
UseSGX bool `json:"use_sgx"`
// contains filtered or unexported fields
}
func NewTaskConfig ¶
func NewTaskConfig(id, rt string, rsrc ResourceLimit, sgx bool, sgxCfg *SGXConfig) TaskConfig
func (TaskConfig) String ¶
func (c TaskConfig) String() string
type TaskFactory ¶
type TaskFactory interface {
// a task is specified by its id, the runtime and the amount of resource intended to use
Build(taskId string, cfg TaskConfig) (Task, error)
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.