Documentation
¶
Index ¶
- func LoadAllContestsAndProblems(contestDirs []string) (map[string]*Contest, map[string]*Problem, error)
- func RecoverAndCleanup(db *gorm.DB, cfg *config.Config) error
- func RequeuePendingSubmissions(db *gorm.DB, s *Scheduler, appState *AppState) error
- type AppState
- type ClusterState
- type Contest
- type Dispatcher
- type DockerManager
- func (m *DockerManager) CleanupContainer(containerID string)
- func (m *DockerManager) CopyToContainer(containerID string, srcDir string, dstDir string) error
- func (m *DockerManager) CreateContainer(image, workDir string, cpu int, cpusetCpus string, memory int64, asRoot bool, ...) (string, error)
- func (m *DockerManager) ExecInContainer(ctx context.Context, containerID string, cmd []string, ...) (ExecResult, error)
- func (m *DockerManager) StartContainer(containerID string) error
- type ExecResult
- type JudgeResult
- type Mount
- type NodeDetail
- type NodeState
- type Problem
- type QueuedSubmission
- type Scheduler
- func (s *Scheduler) GetClusterStates() map[string]ClusterState
- func (s *Scheduler) GetNodeDetails(clusterName, nodeName string) (*NodeDetail, error)
- func (s *Scheduler) GetQueueLengths() map[string]int
- func (s *Scheduler) PauseNode(clusterName, nodeName string) error
- func (s *Scheduler) ReleaseResources(clusterName, nodeName string, coresToRelease []int, memory int64)
- func (s *Scheduler) ResumeNode(clusterName, nodeName string) error
- func (s *Scheduler) Run()
- func (s *Scheduler) Submit(submission *models.Submission, problem *Problem)
- type ScoreConfig
- type UploadLimit
- type WorkflowStep
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RecoverAndCleanup ¶
RecoverAndCleanup handles the recovery process on application startup. It finds submissions and containers that were in a 'Running' state and cleans up their associated Docker containers before marking them as 'Failed' in the database.
Types ¶
type AppState ¶
type AppState struct {
sync.RWMutex
Contests map[string]*Contest
Problems map[string]*Problem
ProblemToContestMap map[string]*Contest
}
AppState holds the shared, reloadable state of contests and problems.
type ClusterState ¶
type Contest ¶
type Contest struct {
ID string `yaml:"id" json:"id"`
Name string `yaml:"name" json:"name"`
StartTime time.Time `yaml:"starttime" json:"starttime"`
EndTime time.Time `yaml:"endtime" json:"endtime"`
ProblemDirs []string `yaml:"problems" json:"problem_dirs"`
ProblemIDs []string `yaml:"problem_ids" json:"problem_ids"`
Description string `json:"description"`
BasePath string `json:"-"` // Store the base path to find assets
}
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
func NewDispatcher ¶
func (*Dispatcher) Dispatch ¶
func (d *Dispatcher) Dispatch(sub *models.Submission, prob *Problem, node *NodeState, allocatedCores []int)
type DockerManager ¶
type DockerManager struct {
// contains filtered or unexported fields
}
func NewDockerManager ¶
func NewDockerManager(cfg config.DockerConfig) (*DockerManager, error)
func (*DockerManager) CleanupContainer ¶
func (m *DockerManager) CleanupContainer(containerID string)
func (*DockerManager) CopyToContainer ¶
func (m *DockerManager) CopyToContainer(containerID string, srcDir string, dstDir string) error
func (*DockerManager) CreateContainer ¶
func (*DockerManager) ExecInContainer ¶
func (m *DockerManager) ExecInContainer(ctx context.Context, containerID string, cmd []string, outputCallback func(streamType string, data []byte)) (ExecResult, error)
func (*DockerManager) StartContainer ¶
func (m *DockerManager) StartContainer(containerID string) error
type ExecResult ¶
type JudgeResult ¶
type NodeDetail ¶
type Problem ¶
type Problem struct {
ID string `yaml:"id" json:"id"`
Name string `yaml:"name" json:"name"`
StartTime time.Time `yaml:"starttime" json:"starttime"`
EndTime time.Time `yaml:"endtime" json:"endtime"`
MaxSubmissions int `yaml:"max_submissions" json:"max_submissions"`
Cluster string `yaml:"cluster" json:"cluster"`
CPU int `yaml:"cpu" json:"cpu"`
Memory int64 `yaml:"memory" json:"memory"`
Upload UploadLimit `yaml:"upload" json:"upload"`
Workflow []WorkflowStep `yaml:"workflow" json:"workflow"`
Score ScoreConfig `yaml:"score" json:"score"`
Description string `json:"description"`
BasePath string `json:"-"` // Store the base path to find assets
}
type QueuedSubmission ¶
type QueuedSubmission struct {
Submission *models.Submission
Problem *Problem
}
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
func NewScheduler ¶
func (*Scheduler) GetClusterStates ¶
func (s *Scheduler) GetClusterStates() map[string]ClusterState
func (*Scheduler) GetNodeDetails ¶
func (s *Scheduler) GetNodeDetails(clusterName, nodeName string) (*NodeDetail, error)
func (*Scheduler) GetQueueLengths ¶
func (*Scheduler) ReleaseResources ¶
func (*Scheduler) ResumeNode ¶
type ScoreConfig ¶
type UploadLimit ¶
type WorkflowStep ¶
type WorkflowStep struct {
Name string `yaml:"name" json:"name"`
Image string `yaml:"image" json:"image"`
Root bool `yaml:"root" json:"root"`
Timeout int `yaml:"timeout" json:"timeout"`
Show bool `yaml:"show" json:"show"`
Steps [][]string `yaml:"steps" json:"steps"`
Mounts []Mount `yaml:"mounts" json:"mounts"`
Network bool `yaml:"network" json:"network"`
}
Click to show internal directories.
Click to hide internal directories.