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.
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 MigrateDB(backend string, db string) error
- func RevertDB(backend string, db string) error
- func SecurityCheck(ctx context.Context, query sq.SelectBuilder) (sq.SelectBuilder, error)
- 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(job int64, tag int64) ([]*schema.Tag, error)
- func (r *JobRepository) AddTagOrCreate(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) (tagId int64, err error)
- func (r *JobRepository) DeleteJobById(id int64) error
- func (r *JobRepository) DeleteJobsBefore(startTime int64) (int, 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(jobId int64) (*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) FindUserOrProjectOrJobname(user *schema.User, searchterm string) (jobid string, username string, project string, jobname string)
- func (r *JobRepository) Flush() error
- func (r *JobRepository) GetTags(job *int64) ([]*schema.Tag, error)
- func (r *JobRepository) InsertJob(job *schema.Job) (int64, error)
- 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(jobId int64, monitoringStatus int32, ...) error
- 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(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) (tagId int64, exists bool)
- func (r *JobRepository) TransactionAdd(t *Transaction, job schema.Job) (int64, error)
- func (r *JobRepository) TransactionAddTag(t *Transaction, tag *schema.Tag) (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) TransactionSetTag(t *Transaction, jobId int64, tagId int64) error
- func (r *JobRepository) TriggerArchiving(job *schema.Job)
- func (r *JobRepository) UpdateMetadata(job *schema.Job, key, val string) (err error)
- func (r *JobRepository) UpdateMonitoringStatus(job int64, monitoringStatus int32) (err error)
- func (r *JobRepository) WaitForArchiving()
- 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
Constants ¶
const NamedJobInsert string = `INSERT INTO job (
job_id, user, project, cluster, subcluster, ` + "`partition`" + `, array_job_id, num_nodes, num_hwthreads, num_acc,
exclusive, monitoring_status, smt, job_state, start_time, duration, walltime, resources, meta_data,
mem_used_max, flops_any_avg, mem_bw_avg, load_avg, net_bw_avg, net_data_vol_total, file_bw_avg, file_data_vol_total
) VALUES (
:job_id, :user, :project, :cluster, :subcluster, :partition, :array_job_id, :num_nodes, :num_hwthreads, :num_acc,
:exclusive, :monitoring_status, :smt, :job_state, :start_time, :duration, :walltime, :resources, :meta_data,
:mem_used_max, :flops_any_avg, :mem_bw_avg, :load_avg, :net_bw_avg, :net_data_vol_total, :file_bw_avg, :file_data_vol_total
);`
const Version uint = 7
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 SecurityCheck ¶
func SecurityCheck(ctx context.Context, query sq.SelectBuilder) (sq.SelectBuilder, error)
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(jobId int64, tagType string, tagName 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) (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) 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 ¶
func (r *JobRepository) FindById(jobId int64) (*schema.Job, error)
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) 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) FindUserOrProjectOrJobname ¶
func (*JobRepository) Flush ¶
func (r *JobRepository) Flush() error
func (*JobRepository) GetTags ¶
func (r *JobRepository) GetTags(job *int64) ([]*schema.Tag, error)
GetTags returns a list of all tags if job is nil or of the tags that the job with that database ID has.
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( jobId int64, monitoringStatus int32, metricStats map[string]schema.JobStatistics, ) error
Stop updates the job with the database id jobId using the provided arguments.
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) RemoveTag ¶
func (r *JobRepository) RemoveTag(job, tag int64) ([]*schema.Tag, error)
Removes a tag from a job
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) (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, job schema.Job) (int64, error)
func (*JobRepository) TransactionAddTag ¶
func (r *JobRepository) TransactionAddTag(t *Transaction, tag *schema.Tag) (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) TransactionSetTag ¶
func (r *JobRepository) TransactionSetTag(t *Transaction, jobId int64, tagId int64) error
func (*JobRepository) TriggerArchiving ¶
func (r *JobRepository) TriggerArchiving(job *schema.Job)
Trigger async archiving
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)
func (*JobRepository) WaitForArchiving ¶
func (r *JobRepository) WaitForArchiving()
Wait for background thread to finish pending archiving operations
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)