repository

package
v1.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Copyright (C) 2022 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) 2022 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) 2022 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) 2022 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) 2022 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) 2022 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) 2022 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) 2022 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) 2022 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

View Source
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
);`
View Source
const Version uint = 4

Variables

View Source
var ErrForbidden = errors.New("not authorized")
View Source
var ErrNotFound = errors.New("no such jobname, project or user")

Functions

func BuildWhereClause

func BuildWhereClause(filter *model.JobFilter, query sq.SelectBuilder) sq.SelectBuilder

Build a sq.SelectBuilder out of a schema.JobFilter.

func Connect

func Connect(driver string, db string)

func MigrateDB

func MigrateDB(backend string, db string) error

func SecurityCheck

func SecurityCheck(ctx context.Context, query sq.SelectBuilder) (queryOut sq.SelectBuilder, err error)

Types

type DBConnection

type DBConnection struct {
	DB     *sqlx.DB
	Driver string
}

func GetConnection

func GetConnection() *DBConnection

type DatabaseOptions

type DatabaseOptions struct {
	URL                   string
	MaxOpenConnections    int
	MaxIdleConnections    int
	ConnectionMaxLifetime time.Duration
	ConnectionMaxIdleTime time.Duration
}

type Hooks

type Hooks struct{}

Hooks satisfies the sqlhook.Hooks interface

func (*Hooks) After

func (h *Hooks) After(ctx context.Context, query string, args ...interface{}) (context.Context, error)

After hook will get the timestamp registered on the Before hook and print the elapsed time

func (*Hooks) Before

func (h *Hooks) Before(ctx context.Context, query string, args ...interface{}) (context.Context, error)

Before hook will print the query with it's args and return the context with the timestamp

type JobRepository

type JobRepository struct {
	DB *sqlx.DB
	// contains filtered or unexported fields
}

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) AddTag

func (r *JobRepository) AddTag(job int64, tag int64) ([]*schema.Tag, error)

Add the tag with id `tagId` to the job with the database id `jobId`.

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

func (r *JobRepository) AllocatedNodes(cluster string) (map[string]map[string]int, error)

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) CountGroupedJobs

func (r *JobRepository) CountGroupedJobs(
	ctx context.Context,
	aggreg model.Aggregate,
	filters []*model.JobFilter,
	weight *model.Weights,
	limit *int) (map[string]int, error)

TODO: Use node hours instead: SELECT job.user, sum(job.num_nodes * (CASE WHEN job.job_state = "running" THEN CAST(strftime('%s', 'now') AS INTEGER) - job.start_time ELSE job.duration END)) as x FROM job GROUP BY user ORDER BY x DESC;

func (*JobRepository) CountJobs

func (r *JobRepository) CountJobs(
	ctx context.Context,
	filters []*model.JobFilter) (int, error)

Public function with added securityCheck, calls private countJobs function above

func (*JobRepository) CountTags

func (r *JobRepository) CountTags(user *auth.User) (tags []schema.Tag, counts map[string]int, err error)

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 (r *JobRepository) FetchMetadata(job *schema.Job) (map[string]string, error)

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 (r *JobRepository) FindColumnValue(user *auth.User, searchterm string, table string, selectColumn string, whereColumn string, isLike bool) (result string, err error)

func (*JobRepository) FindColumnValues

func (r *JobRepository) FindColumnValues(user *auth.User, query string, table string, selectColumn string, whereColumn string) (results []string, err error)

func (*JobRepository) FindJobsBetween

func (r *JobRepository) FindJobsBetween(startTimeBegin int64, startTimeEnd int64) ([]*schema.Job, error)

func (*JobRepository) FindUserOrProjectOrJobname

func (r *JobRepository) FindUserOrProjectOrJobname(ctx context.Context, searchterm string) (username string, project string, metasnip string, err error)

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) InsertJob

func (r *JobRepository) InsertJob(job *schema.Job) (int64, error)

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,
	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 (r *JobRepository) QueryJobLinks(
	ctx context.Context,
	filters []*model.JobFilter) ([]*model.JobLink, error)

func (*JobRepository) QueryJobs

func (r *JobRepository) QueryJobs(
	ctx context.Context,
	filters []*model.JobFilter,
	page *model.PageRequest,
	order *model.OrderByInput) ([]*schema.Job, error)

Public function with added securityCheck, calls private queryJobs function above

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

type UserCfgRepo struct {
	DB     *sqlx.DB
	Lookup *sqlx.Stmt
	// contains filtered or unexported fields
}

func GetUserCfgRepo

func GetUserCfgRepo() *UserCfgRepo

func (*UserCfgRepo) GetUIConfig

func (uCfg *UserCfgRepo) GetUIConfig(user *auth.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 *auth.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.

Jump to

Keyboard shortcuts

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