Documentation ¶
Overview ¶
Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.
Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.
Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.
Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.
Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.
Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.
Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.
Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.
Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.
Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.
Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.
Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.
Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.
Index ¶
- Constants
- Variables
- func BuildWhereClause(filter *model.JobFilter, query sq.SelectBuilder) sq.SelectBuilder
- func Connect(driver string, db string)
- func ForceDB(backend string, db string) error
- func GetUserFromContext(ctx context.Context) *schema.User
- func LoadJobStat(job *schema.JobMeta, metric string, statType string) float64
- func MigrateDB(backend string, db string) error
- func RevertDB(backend string, db string) error
- func SecurityCheck(ctx context.Context, query sq.SelectBuilder) (sq.SelectBuilder, error)
- func SecurityCheckWithUser(user *schema.User, query sq.SelectBuilder) (sq.SelectBuilder, error)
- func TriggerJobStart(req JobWithUser)
- func WaitForJobStart()
- type ContextKey
- type DBConnection
- type DatabaseOptions
- type Hooks
- type JobRepository
- func (r *JobRepository) AddHistograms(ctx context.Context, filter []*model.JobFilter, stat *model.JobsStatistics) (*model.JobsStatistics, error)
- func (r *JobRepository) AddJobCount(ctx context.Context, filter []*model.JobFilter, stats []*model.JobsStatistics, ...) ([]*model.JobsStatistics, error)
- func (r *JobRepository) AddJobCountGrouped(ctx context.Context, filter []*model.JobFilter, groupBy *model.Aggregate, ...) ([]*model.JobsStatistics, error)
- func (r *JobRepository) AddMetricHistograms(ctx context.Context, filter []*model.JobFilter, metrics []string, ...) (*model.JobsStatistics, error)
- func (r *JobRepository) AddTag(user *schema.User, job int64, tag int64) ([]*schema.Tag, error)
- func (r *JobRepository) AddTagOrCreate(user *schema.User, jobId int64, tagType string, tagName string, ...) (tagId int64, err error)
- func (r *JobRepository) AllocatedNodes(cluster string) (map[string]map[string]int, error)
- func (r *JobRepository) CountJobs(ctx context.Context, filters []*model.JobFilter) (int, error)
- func (r *JobRepository) CountTags(user *schema.User) (tags []schema.Tag, counts map[string]int, err error)
- func (r *JobRepository) CreateTag(tagType string, tagName string, tagScope string) (tagId int64, err error)
- func (r *JobRepository) DeleteJobById(id int64) error
- func (r *JobRepository) DeleteJobsBefore(startTime int64) (int, error)
- func (r *JobRepository) Execute(stmt sq.UpdateBuilder) error
- func (r *JobRepository) FetchEnergyFootprint(job *schema.Job) (map[string]float64, error)
- func (r *JobRepository) FetchFootprint(job *schema.Job) (map[string]float64, error)
- func (r *JobRepository) FetchMetadata(job *schema.Job) (map[string]string, error)
- func (r *JobRepository) Find(jobId *int64, cluster *string, startTime *int64) (*schema.Job, error)
- func (r *JobRepository) FindAll(jobId *int64, cluster *string, startTime *int64) ([]*schema.Job, error)
- func (r *JobRepository) FindById(ctx context.Context, jobId int64) (*schema.Job, error)
- func (r *JobRepository) FindByIdDirect(jobId int64) (*schema.Job, error)
- func (r *JobRepository) FindByIdWithUser(user *schema.User, jobId int64) (*schema.Job, error)
- func (r *JobRepository) FindByJobId(ctx context.Context, jobId int64, startTime int64, cluster string) (*schema.Job, error)
- func (r *JobRepository) FindColumnValue(user *schema.User, searchterm string, table string, selectColumn string, ...) (result string, err error)
- func (r *JobRepository) FindColumnValues(user *schema.User, query string, table string, selectColumn string, ...) (results []string, err error)
- func (r *JobRepository) FindConcurrentJobs(ctx context.Context, job *schema.Job) (*model.JobLinkResultList, error)
- func (r *JobRepository) FindJobsBetween(startTimeBegin int64, startTimeEnd int64) ([]*schema.Job, error)
- func (r *JobRepository) FindRunningJobs(cluster string) ([]*schema.Job, error)
- func (r *JobRepository) FindUserOrProjectOrJobname(user *schema.User, searchterm string) (jobid string, username string, project string, jobname string)
- func (r *JobRepository) Flush() error
- func (r *JobRepository) GetTags(user *schema.User, job *int64) ([]*schema.Tag, error)
- func (r *JobRepository) ImportTag(jobId int64, tagType string, tagName string, tagScope string) (err error)
- func (r *JobRepository) InsertJob(job *schema.JobMeta) (int64, error)
- func (r *JobRepository) IsJobOwner(jobId int64, startTime int64, user string, cluster string) bool
- func (r *JobRepository) JobCountGrouped(ctx context.Context, filter []*model.JobFilter, groupBy *model.Aggregate) ([]*model.JobsStatistics, error)
- func (r *JobRepository) JobsStats(ctx context.Context, filter []*model.JobFilter) ([]*model.JobsStatistics, error)
- func (r *JobRepository) JobsStatsGrouped(ctx context.Context, filter []*model.JobFilter, page *model.PageRequest, ...) ([]*model.JobsStatistics, error)
- func (r *JobRepository) MarkArchived(stmt sq.UpdateBuilder, monitoringStatus int32) sq.UpdateBuilder
- func (r *JobRepository) Optimize() error
- func (r *JobRepository) Partitions(cluster string) ([]string, error)
- func (r *JobRepository) QueryJobs(ctx context.Context, filters []*model.JobFilter, page *model.PageRequest, ...) ([]*schema.Job, error)
- func (r *JobRepository) RemoveTag(user *schema.User, job, tag int64) ([]*schema.Tag, error)
- func (r *JobRepository) Start(job *schema.JobMeta) (id int64, err error)
- func (r *JobRepository) Stop(jobId int64, duration int32, state schema.JobState, monitoringStatus int32) (err error)
- func (r *JobRepository) StopJobsExceedingWalltimeBy(seconds int) error
- func (r *JobRepository) TagId(tagType string, tagName string, tagScope string) (tagId int64, exists bool)
- func (r *JobRepository) TransactionAdd(t *Transaction, query string, args ...interface{}) (int64, error)
- func (r *JobRepository) TransactionAddNamed(t *Transaction, query string, args ...interface{}) (int64, error)
- func (r *JobRepository) TransactionCommit(t *Transaction) error
- func (r *JobRepository) TransactionEnd(t *Transaction) error
- func (r *JobRepository) TransactionInit() (*Transaction, error)
- func (r *JobRepository) UpdateDuration() error
- func (r *JobRepository) UpdateEnergy(stmt sq.UpdateBuilder, jobMeta *schema.JobMeta) (sq.UpdateBuilder, error)
- func (r *JobRepository) UpdateFootprint(stmt sq.UpdateBuilder, jobMeta *schema.JobMeta) (sq.UpdateBuilder, error)
- func (r *JobRepository) UpdateMetadata(job *schema.Job, key, val string) (err error)
- func (r *JobRepository) UpdateMonitoringStatus(job int64, monitoringStatus int32) (err error)
- type JobWithUser
- type Transaction
- type UserCfgRepo
- type UserRepository
- func (r *UserRepository) AddProject(ctx context.Context, username string, project string) error
- func (r *UserRepository) AddRole(ctx context.Context, username string, queryrole string) error
- func (r *UserRepository) AddUser(user *schema.User) error
- func (r *UserRepository) DelUser(username string) error
- func (r *UserRepository) FetchUserInCtx(ctx context.Context, username string) (*model.User, error)
- func (r *UserRepository) GetLdapUsernames() ([]string, error)
- func (r *UserRepository) GetUser(username string) (*schema.User, error)
- func (r *UserRepository) ListUsers(specialsOnly bool) ([]*schema.User, error)
- func (r *UserRepository) RemoveProject(ctx context.Context, username string, project string) error
- func (r *UserRepository) RemoveRole(ctx context.Context, username string, queryrole string) error
- func (r *UserRepository) UpdateUser(dbUser *schema.User, user *schema.User) error
Constants ¶
const NamedJobInsert string = `` /* 563-byte string literal not displayed */
const Version uint = 8
Variables ¶
var ( ErrNotFound = errors.New("no such jobname, project or user") ErrForbidden = errors.New("not authorized") )
Functions ¶
func BuildWhereClause ¶
func BuildWhereClause(filter *model.JobFilter, query sq.SelectBuilder) sq.SelectBuilder
Build a sq.SelectBuilder out of a schema.JobFilter.
func LoadJobStat ¶ added in v1.4.0
func SecurityCheck ¶
func SecurityCheck(ctx context.Context, query sq.SelectBuilder) (sq.SelectBuilder, error)
func SecurityCheckWithUser ¶ added in v1.4.0
func SecurityCheckWithUser(user *schema.User, query sq.SelectBuilder) (sq.SelectBuilder, error)
func TriggerJobStart ¶ added in v1.4.0
func TriggerJobStart(req JobWithUser)
Trigger async archiving
func WaitForJobStart ¶ added in v1.4.0
func WaitForJobStart()
Wait for background thread to finish pending archiving operations
Types ¶
type DBConnection ¶
func GetConnection ¶
func GetConnection() *DBConnection
type DatabaseOptions ¶
type Hooks ¶
type Hooks struct{}
Hooks satisfies the sqlhook.Hooks interface
type JobRepository ¶
func GetJobRepository ¶
func GetJobRepository() *JobRepository
func (*JobRepository) AddHistograms ¶
func (r *JobRepository) AddHistograms( ctx context.Context, filter []*model.JobFilter, stat *model.JobsStatistics, ) (*model.JobsStatistics, error)
func (*JobRepository) AddJobCount ¶
func (r *JobRepository) AddJobCount( ctx context.Context, filter []*model.JobFilter, stats []*model.JobsStatistics, kind string, ) ([]*model.JobsStatistics, error)
func (*JobRepository) AddJobCountGrouped ¶
func (r *JobRepository) AddJobCountGrouped( ctx context.Context, filter []*model.JobFilter, groupBy *model.Aggregate, stats []*model.JobsStatistics, kind string, ) ([]*model.JobsStatistics, error)
func (*JobRepository) AddMetricHistograms ¶ added in v1.3.0
func (r *JobRepository) AddMetricHistograms( ctx context.Context, filter []*model.JobFilter, metrics []string, stat *model.JobsStatistics, ) (*model.JobsStatistics, error)
Requires thresholds for metric from config for cluster? Of all clusters and use largest? split to 10 + 1 for artifacts?
func (*JobRepository) AddTagOrCreate ¶
func (r *JobRepository) AddTagOrCreate(user *schema.User, jobId int64, tagType string, tagName string, tagScope string) (tagId int64, err error)
AddTagOrCreate adds the tag with the specified type and name to the job with the database id `jobId`. If such a tag does not yet exist, it is created.
func (*JobRepository) AllocatedNodes ¶
AllocatedNodes returns a map of all subclusters to a map of hostnames to the amount of jobs running on that host. Hosts with zero jobs running on them will not show up!
func (*JobRepository) CreateTag ¶
func (r *JobRepository) CreateTag(tagType string, tagName string, tagScope string) (tagId int64, err error)
CreateTag creates a new tag with the specified type and name and returns its database id.
func (*JobRepository) DeleteJobById ¶
func (r *JobRepository) DeleteJobById(id int64) error
func (*JobRepository) DeleteJobsBefore ¶
func (r *JobRepository) DeleteJobsBefore(startTime int64) (int, error)
func (*JobRepository) Execute ¶ added in v1.4.0
func (r *JobRepository) Execute(stmt sq.UpdateBuilder) error
func (*JobRepository) FetchEnergyFootprint ¶ added in v1.4.0
func (*JobRepository) FetchFootprint ¶ added in v1.4.0
func (*JobRepository) FetchMetadata ¶
func (*JobRepository) Find ¶
func (r *JobRepository) Find( jobId *int64, cluster *string, startTime *int64, ) (*schema.Job, error)
Find executes a SQL query to find a specific batch job. The job is queried using the batch job id, the cluster name, and the start time of the job in UNIX epoch time seconds. It returns a pointer to a schema.Job data structure and an error variable. To check if no job was found test err == sql.ErrNoRows
func (*JobRepository) FindAll ¶
func (r *JobRepository) FindAll( jobId *int64, cluster *string, startTime *int64, ) ([]*schema.Job, error)
Find executes a SQL query to find a specific batch job. The job is queried using the batch job id, the cluster name, and the start time of the job in UNIX epoch time seconds. It returns a pointer to a schema.Job data structure and an error variable. To check if no job was found test err == sql.ErrNoRows
func (*JobRepository) FindById ¶
FindById executes a SQL query to find a specific batch job. The job is queried using the database id. It returns a pointer to a schema.Job data structure and an error variable. To check if no job was found test err == sql.ErrNoRows
func (*JobRepository) FindByIdDirect ¶ added in v1.4.0
func (r *JobRepository) FindByIdDirect(jobId int64) (*schema.Job, error)
FindByIdDirect executes a SQL query to find a specific batch job. The job is queried using the database id. It returns a pointer to a schema.Job data structure and an error variable. To check if no job was found test err == sql.ErrNoRows
func (*JobRepository) FindByIdWithUser ¶ added in v1.4.0
FindByIdWithUser executes a SQL query to find a specific batch job. The job is queried using the database id. The user is passed directly, instead as part of the context. It returns a pointer to a schema.Job data structure and an error variable. To check if no job was found test err == sql.ErrNoRows
func (*JobRepository) FindByJobId ¶ added in v1.4.0
func (r *JobRepository) FindByJobId(ctx context.Context, jobId int64, startTime int64, cluster string) (*schema.Job, error)
FindByJobId executes a SQL query to find a specific batch job. The job is queried using the slurm id and the clustername. It returns a pointer to a schema.Job data structure and an error variable. To check if no job was found test err == sql.ErrNoRows
func (*JobRepository) FindColumnValue ¶
func (*JobRepository) FindColumnValues ¶
func (*JobRepository) FindConcurrentJobs ¶
func (r *JobRepository) FindConcurrentJobs( ctx context.Context, job *schema.Job, ) (*model.JobLinkResultList, error)
func (*JobRepository) FindJobsBetween ¶
func (*JobRepository) FindRunningJobs ¶ added in v1.4.0
func (r *JobRepository) FindRunningJobs(cluster string) ([]*schema.Job, error)
func (*JobRepository) FindUserOrProjectOrJobname ¶
func (*JobRepository) Flush ¶
func (r *JobRepository) Flush() error
func (*JobRepository) GetTags ¶
GetTags returns a list of all scoped tags if job is nil or of the tags that the job with that database ID has.
func (*JobRepository) InsertJob ¶
func (r *JobRepository) InsertJob(job *schema.JobMeta) (int64, error)
func (*JobRepository) IsJobOwner ¶ added in v1.4.0
IsJobOwner executes a SQL query to find a specific batch job. The job is queried using the slurm id,a username and the cluster. It returns a bool. If job was found, user is owner: test err != sql.ErrNoRows
func (*JobRepository) JobCountGrouped ¶
func (r *JobRepository) JobCountGrouped( ctx context.Context, filter []*model.JobFilter, groupBy *model.Aggregate, ) ([]*model.JobsStatistics, error)
func (*JobRepository) JobsStats ¶
func (r *JobRepository) JobsStats( ctx context.Context, filter []*model.JobFilter, ) ([]*model.JobsStatistics, error)
func (*JobRepository) JobsStatsGrouped ¶
func (r *JobRepository) JobsStatsGrouped( ctx context.Context, filter []*model.JobFilter, page *model.PageRequest, sortBy *model.SortByAggregate, groupBy *model.Aggregate, ) ([]*model.JobsStatistics, error)
func (*JobRepository) MarkArchived ¶
func (r *JobRepository) MarkArchived( stmt sq.UpdateBuilder, monitoringStatus int32, ) sq.UpdateBuilder
func (*JobRepository) Optimize ¶
func (r *JobRepository) Optimize() error
func (*JobRepository) Partitions ¶
func (r *JobRepository) Partitions(cluster string) ([]string, error)
func (*JobRepository) QueryJobs ¶
func (r *JobRepository) QueryJobs( ctx context.Context, filters []*model.JobFilter, page *model.PageRequest, order *model.OrderByInput, ) ([]*schema.Job, error)
func (*JobRepository) Start ¶
func (r *JobRepository) Start(job *schema.JobMeta) (id int64, err error)
Start inserts a new job in the table, returning the unique job ID. Statistics are not transfered!
func (*JobRepository) Stop ¶
func (r *JobRepository) Stop( jobId int64, duration int32, state schema.JobState, monitoringStatus int32, ) (err error)
Stop updates the job with the database id jobId using the provided arguments.
func (*JobRepository) StopJobsExceedingWalltimeBy ¶
func (r *JobRepository) StopJobsExceedingWalltimeBy(seconds int) error
func (*JobRepository) TagId ¶
func (r *JobRepository) TagId(tagType string, tagName string, tagScope string) (tagId int64, exists bool)
TagId returns the database id of the tag with the specified type and name.
func (*JobRepository) TransactionAdd ¶
func (r *JobRepository) TransactionAdd(t *Transaction, query string, args ...interface{}) (int64, error)
func (*JobRepository) TransactionAddNamed ¶ added in v1.4.0
func (r *JobRepository) TransactionAddNamed( t *Transaction, query string, args ...interface{}, ) (int64, error)
func (*JobRepository) TransactionCommit ¶
func (r *JobRepository) TransactionCommit(t *Transaction) error
func (*JobRepository) TransactionEnd ¶
func (r *JobRepository) TransactionEnd(t *Transaction) error
func (*JobRepository) TransactionInit ¶
func (r *JobRepository) TransactionInit() (*Transaction, error)
func (*JobRepository) UpdateDuration ¶ added in v1.4.0
func (r *JobRepository) UpdateDuration() error
func (*JobRepository) UpdateEnergy ¶ added in v1.4.0
func (r *JobRepository) UpdateEnergy( stmt sq.UpdateBuilder, jobMeta *schema.JobMeta, ) (sq.UpdateBuilder, error)
func (*JobRepository) UpdateFootprint ¶ added in v1.4.0
func (r *JobRepository) UpdateFootprint( stmt sq.UpdateBuilder, jobMeta *schema.JobMeta, ) (sq.UpdateBuilder, error)
func (*JobRepository) UpdateMetadata ¶
func (r *JobRepository) UpdateMetadata(job *schema.Job, key, val string) (err error)
func (*JobRepository) UpdateMonitoringStatus ¶
func (r *JobRepository) UpdateMonitoringStatus(job int64, monitoringStatus int32) (err error)
type JobWithUser ¶ added in v1.4.0
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
type UserCfgRepo ¶
func GetUserCfgRepo ¶
func GetUserCfgRepo() *UserCfgRepo
func (*UserCfgRepo) GetUIConfig ¶
func (uCfg *UserCfgRepo) GetUIConfig(user *schema.User) (map[string]interface{}, error)
Return the personalised UI config for the currently authenticated user or return the plain default config.
func (*UserCfgRepo) UpdateConfig ¶
func (uCfg *UserCfgRepo) UpdateConfig( key, value string, user *schema.User, ) error
If the context does not have a user, update the global ui configuration without persisting it! If there is a (authenticated) user, update only his configuration.
type UserRepository ¶ added in v1.2.0
func GetUserRepository ¶ added in v1.2.0
func GetUserRepository() *UserRepository
func (*UserRepository) AddProject ¶ added in v1.2.0
func (*UserRepository) AddUser ¶ added in v1.2.0
func (r *UserRepository) AddUser(user *schema.User) error
func (*UserRepository) DelUser ¶ added in v1.2.0
func (r *UserRepository) DelUser(username string) error
func (*UserRepository) FetchUserInCtx ¶ added in v1.2.0
func (*UserRepository) GetLdapUsernames ¶ added in v1.2.0
func (r *UserRepository) GetLdapUsernames() ([]string, error)
func (*UserRepository) GetUser ¶ added in v1.2.0
func (r *UserRepository) GetUser(username string) (*schema.User, error)
func (*UserRepository) ListUsers ¶ added in v1.2.0
func (r *UserRepository) ListUsers(specialsOnly bool) ([]*schema.User, error)