~ubuntu-branches/ubuntu/vivid/slurm-llnl/vivid

« back to all changes in this revision

Viewing changes to src/common/slurm_accounting_storage.h

  • Committer: Bazaar Package Importer
  • Author(s): Gennaro Oliva
  • Date: 2009-09-24 23:28:15 UTC
  • mfrom: (1.1.11 upstream) (3.2.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090924232815-enh65jn32q1ebg07
Tags: 2.0.5-1
* New upstream release 
* Changed dependecy from lib-mysqlclient15 to lib-mysqlclient 
* Added Default-Start for runlevel 2 and 4 and $remote_fs requirement in
  init.d scripts (Closes: #541252)
* Postinst checks for wrong runlevels 2 and 4 links
* Upgraded to standard version 3.8.3
* Add lintian overrides for missing slurm-llnl-configurator.html in doc
  base registration
* modified postrm scripts to ignore pkill return value in order to avoid
  postrm failure when no slurm process is running
* Checking for slurmctld.pid before cancelling running and pending
  jobs during package removal 

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 *  slurm_accounting_storage.h - Define accounting storage plugin functions.
3
3
 *****************************************************************************
4
4
 *  Copyright (C) 2004-2007 The Regents of the University of California.
5
 
 *  Copyright (C) 2008 Lawrence Livermore National Security.
 
5
 *  Copyright (C) 2008-2009 Lawrence Livermore National Security.
6
6
 *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
7
7
 *  Written by Danny Auble <da@llnl.gov>
8
 
 *  LLNL-CODE-402394.
 
8
 *  CODE-OCEC-09-009. All rights reserved.
9
9
 *  
10
10
 *  This file is part of SLURM, a resource management program.
11
 
 *  For details, see <http://www.llnl.gov/linux/slurm/>.
 
11
 *  For details, see <https://computing.llnl.gov/linux/slurm/>.
 
12
 *  Please also read the included file: DISCLAIMER.
12
13
 *  
13
14
 *  SLURM is free software; you can redistribute it and/or modify it under
14
15
 *  the terms of the GNU General Public License as published by the Free
71
72
        ACCT_MODIFY_WCKEY,
72
73
} acct_update_type_t;
73
74
 
 
75
typedef enum {
 
76
        ACCT_CLASS_NONE, /* no class given */
 
77
        ACCT_CLASS_CAPABILITY, /* capability cluster */
 
78
        ACCT_CLASS_CAPACITY, /* capacity cluster */
 
79
        ACCT_CLASS_CAPAPACITY, /* a cluster that is both capability
 
80
                                * and capacity */
 
81
} acct_classification_type_t;
 
82
 
 
83
#define ACCT_CLASSIFIED_FLAG 0x0100
 
84
#define ACCT_CLASS_BASE      0x00ff
 
85
 
74
86
/* Association conditions used for queries of the database */
75
87
typedef struct {
76
88
        List acct_list;         /* list of char * */
99
111
 
100
112
        List qos_list; /* list of char * */     
101
113
 
102
 
        uint32_t usage_end; 
103
 
        uint32_t usage_start; 
 
114
        time_t usage_end; 
 
115
        time_t usage_start; 
104
116
 
105
117
        List user_list;         /* list of char * */
106
118
 
134
146
typedef struct {
135
147
        uint64_t alloc_secs; /* number of cpu seconds allocated */
136
148
        uint32_t id;    /* association/wckey ID         */
137
 
        time_t period_start; 
 
149
        time_t period_start; /* when this record was started */
138
150
} acct_accounting_rec_t;
139
151
 
140
152
typedef struct acct_association_rec {
141
153
        List accounting_list;   /* list of acct_accounting_rec_t *'s */
142
154
        char *acct;             /* account/project associated to association */
 
155
        List childern_list;     /* list of childern associations
 
156
                                 * (DON'T PACK) */
143
157
        char *cluster;          /* cluster associated to association
144
158
                                 * */
145
159
 
146
 
        uint32_t fairshare;     /* fairshare number */
147
 
 
148
 
        uint64_t grp_cpu_mins; /* max number of cpu hours the
149
 
                                     * underlying group of
150
 
                                     * associations can run for */
 
160
        uint64_t grp_cpu_mins; /* max number of cpu minutes the
 
161
                                * underlying group of
 
162
                                * associations can run for */
151
163
        uint32_t grp_cpus; /* max number of cpus the
152
 
                                * underlying group of 
153
 
                                * associations can allocate at one time */
 
164
                            * underlying group of 
 
165
                            * associations can allocate at one time */
154
166
        uint32_t grp_jobs;      /* max number of jobs the
155
167
                                 * underlying group of associations can run
156
168
                                 * at one time */
157
169
        uint32_t grp_nodes; /* max number of nodes the
158
 
                                 * underlying group of
159
 
                                 * associations can allocate at once */
 
170
                             * underlying group of
 
171
                             * associations can allocate at once */
160
172
        uint32_t grp_submit_jobs; /* max number of jobs the
161
 
                                       * underlying group of
162
 
                                       * associations can submit at
163
 
                                       * one time */
 
173
                                   * underlying group of
 
174
                                   * associations can submit at
 
175
                                   * one time */
164
176
        uint32_t grp_wall; /* total time in hours the 
165
177
                            * underlying group of
166
178
                            * associations can run for */
167
 
 
168
 
        uint32_t grp_used_cpu_mins; /* cpu mins the
169
 
                                      * underlying group of
170
 
                                      * associations has ran for 
171
 
                                      * (DON'T PACK) */
 
179
        
172
180
        uint32_t grp_used_cpus; /* count of active jobs in the group
173
181
                                 * (DON'T PACK) */
174
182
        uint32_t grp_used_nodes; /* count of active jobs in the group
175
183
                                  * (DON'T PACK) */
176
 
        uint32_t grp_used_wall; /* group count of time used in
177
 
                                     * running jobs (DON'T PACK) */
 
184
        double grp_used_wall;   /* group count of time used in
 
185
                                 * running jobs (DON'T PACK) */
178
186
        
179
187
        uint32_t id;            /* id identifing a combination of
180
188
                                 * user-account-cluster(-partition) */
181
 
 
 
189
        
182
190
        uint32_t level_shares;  /* number of shares on this level of
183
191
                                 * the tree (DON'T PACK) */
184
192
        
189
197
        uint64_t max_cpu_mins_pj; /* max number of cpu seconds this 
190
198
                                   * association can have per job */
191
199
        uint32_t max_cpus_pj; /* max number of cpus this 
192
 
                                    * association can allocate per job */
 
200
                               * association can allocate per job */
193
201
        uint32_t max_jobs;      /* max number of jobs this association can run
194
202
                                 * at one time */
195
203
        uint32_t max_nodes_pj; /* max number of nodes this
196
 
                                     * association can allocate per job */
 
204
                                * association can allocate per job */
197
205
        uint32_t max_submit_jobs; /* max number of jobs that can be
198
206
                                     submitted by association */
199
207
        uint32_t max_wall_pj; /* longest time this
207
215
        uint32_t parent_id;     /* id of parent account */
208
216
        char *partition;        /* optional partition in a cluster 
209
217
                                 * associated to association */
210
 
 
 
218
        
211
219
        List qos_list;          /* list of char * */
212
 
 
 
220
        
213
221
        uint32_t rgt;           /* rgt used for grouping sub
214
222
                                 * associations and jobs as a right
215
223
                                 * most container used with lft */
 
224
 
 
225
        double shares_norm;     /* normalized shares (DON'T PACK) */
 
226
        uint32_t shares_raw;    /* number of shares allocated to association */
 
227
 
216
228
        uint32_t uid;           /* user ID */
217
229
        
 
230
        long double usage_efctv;/* effective, normalized usage (DON'T PACK) */
 
231
        long double usage_norm; /* normalized usage (DON'T PACK) */
 
232
        long double usage_raw;  /* measure of resource usage (DON'T PACK) */
 
233
 
218
234
        uint32_t used_jobs;     /* count of active jobs (DON'T PACK) */
219
 
        uint32_t used_shares;   /* measure of resource usage */
220
235
        uint32_t used_submit_jobs; /* count of jobs pending or running
221
236
                                    * (DON'T PACK) */
222
237
        
224
239
} acct_association_rec_t;
225
240
 
226
241
typedef struct {
 
242
        uint16_t classification; /* how this machine is classified */
227
243
        List cluster_list; /* list of char * */
228
 
        uint32_t usage_end; 
229
 
        uint32_t usage_start; 
 
244
        time_t usage_end; 
 
245
        time_t usage_start; 
230
246
        uint16_t with_deleted; 
231
247
        uint16_t with_usage; 
232
248
} acct_cluster_cond_t;
233
249
 
234
250
typedef struct {
235
251
        List accounting_list; /* list of cluster_accounting_rec_t *'s */
 
252
        uint16_t classification; /* how this machine is classified */
236
253
        char *control_host;
237
254
        uint32_t control_port;
 
255
        uint32_t cpu_count;
238
256
        char *name;
239
 
 
240
 
        List valid_qos_list;
 
257
        char *nodes;
241
258
        acct_association_rec_t *root_assoc; /* root association for cluster */
242
 
 
243
259
        uint16_t rpc_version; /* version of rpc this cluter is running */
244
260
} acct_cluster_rec_t;
245
261
 
255
271
        uint16_t duplicates;    /* report duplicate job entries */
256
272
        List groupid_list;      /* list of char * */
257
273
        List partition_list;    /* list of char * */
 
274
        List resv_list;         /* list of char * */
 
275
        List resvid_list;       /* list of char * */
258
276
        List step_list;         /* list of jobacct_selected_step_t */
259
277
        List state_list;        /* list of char * */
260
 
        uint32_t usage_end; 
261
 
        uint32_t usage_start; 
 
278
        time_t usage_end; 
 
279
        time_t usage_start; 
 
280
        char *used_nodes;       /* a ranged node string where jobs ran */
262
281
        List userid_list;               /* list of char * */
263
282
        List wckey_list;                /* list of char * */
264
283
        uint16_t without_steps; /* don't give me step info */
 
284
        uint16_t without_usage_truncation; /* give me the information
 
285
                                            * without truncating the
 
286
                                            * time to the usage_start
 
287
                                            * and usage_end */
265
288
} acct_job_cond_t;
266
289
 
267
290
typedef struct {
284
307
                                   * one time */
285
308
        uint32_t grp_wall; /* total time in hours this qos can run for */
286
309
 
287
 
        uint32_t grp_used_cpu_mins; /* cpu hours this qos has ran for 
288
 
                                      * (DON'T PACK) */
289
310
        uint32_t grp_used_cpus; /* count of cpus in use in this qos
290
311
                                 * (DON'T PACK) */
291
312
        uint32_t grp_used_jobs; /* count of active jobs (DON'T PACK) */
293
314
                                  * (DON'T PACK) */
294
315
        uint32_t grp_used_submit_jobs; /* count of jobs pending or running
295
316
                                    * (DON'T PACK) */
296
 
        uint32_t grp_used_wall; /* group count of time (minutes) used in
 
317
        double grp_used_wall;   /* group count of time (minutes) used in
297
318
                                 * running jobs (DON'T PACK) */
298
319
 
299
320
        uint64_t max_cpu_mins_pu; /* max number of cpu mins a user can
310
331
                               * qos can run a job */
311
332
 
312
333
        char *name;
 
334
        double norm_priority;/* normalized priority (DON'T PACK) */
313
335
        List preemptee_list; /* list of char * list of qos's that this
314
336
                                qos can preempt */
315
337
        List preemptor_list; /* list of char * list of qos's that this
316
338
                              * qos is preempted by */
317
339
        uint32_t priority;  /* ranged int needs to be a unint for
318
340
                             * heterogeneous systems */
 
341
        double usage_factor; /* factor to apply to usage in this qos */
 
342
        long double usage_raw;  /* measure of resource usage (DON'T PACK) */
 
343
 
319
344
        List user_limit_list; /* acct_used_limits_t's */
320
345
} acct_qos_rec_t;
321
346
 
326
351
        uint16_t with_deleted; 
327
352
} acct_qos_cond_t;
328
353
 
 
354
typedef struct {
 
355
        List cluster_list; /* cluster reservations are on list of
 
356
                            * char * */
 
357
        uint16_t flags; /* flags for reservation. */
 
358
        List id_list;   /* ids of reservations. list of char * */
 
359
        List name_list; /* name of reservations. list of char * */
 
360
        char *nodes; /* list of nodes in reservation */
 
361
        time_t time_end; /* end time of reservation */
 
362
        time_t time_start; /* start time of reservation */
 
363
        uint16_t with_usage; /* send usage for reservation */
 
364
} acct_reservation_cond_t;
 
365
 
 
366
typedef struct {
 
367
        uint64_t alloc_secs; /* number of cpu seconds allocated */
 
368
        char *assocs; /* comma seperated list of associations */
 
369
        char *cluster; /* cluster reservation is for */
 
370
        uint32_t cpus; /* how many cpus are in reservation */
 
371
        uint64_t down_secs; /* number of cpu seconds down */
 
372
        uint16_t flags; /* flags for reservation. */
 
373
        uint32_t id;   /* id of reservation. */
 
374
        char *name; /* name of reservation */
 
375
        char *nodes; /* list of nodes in reservation */
 
376
        char *node_inx; /* node index of nodes in reservation */
 
377
        time_t time_end; /* end time of reservation */
 
378
        time_t time_start; /* start time of reservation */
 
379
        time_t time_start_prev; /* If start time was changed this is
 
380
                                 * the pervious start time.  Needed
 
381
                                 * for accounting */    
 
382
} acct_reservation_rec_t;
 
383
 
329
384
/* Right now this is used in the acct_qos_rec_t structure.  In the
330
385
 * user_limit_list. */
331
386
typedef struct {
376
431
        List id_list; /* list of char * */
377
432
        List info_list; /* list of char * */
378
433
        List name_list; /* list of char * */
379
 
        uint32_t time_end; 
380
 
        uint32_t time_start; 
 
434
        time_t time_end; 
 
435
        time_t time_start; 
381
436
        List user_list; /* list of char * */
382
437
        uint16_t with_assoc_info;
383
438
} acct_txn_cond_t;
407
462
 
408
463
        List name_list;        /* list of char * */
409
464
 
410
 
        uint32_t usage_end; 
411
 
        uint32_t usage_start; 
 
465
        time_t usage_end; 
 
466
        time_t usage_start; 
412
467
 
413
468
        List user_list;         /* list of char * */
414
469
 
440
495
        uint64_t down_secs; /* number of cpu seconds down */
441
496
        uint64_t idle_secs; /* number of cpu seconds idle */
442
497
        uint64_t over_secs; /* number of cpu seconds overcommitted */
 
498
        uint64_t pdown_secs; /* number of cpu seconds planned down */
443
499
        time_t period_start; /* when this record was started */
444
500
        uint64_t resv_secs; /* number of cpu seconds reserved */        
445
501
} cluster_accounting_rec_t;
446
502
 
447
 
 
448
503
typedef struct {
449
504
        char *name;
450
505
        char *print_name;
451
506
        char *spaces;
452
 
        uint16_t user;
 
507
        uint16_t user; /* set to 1 if it is a user i.e. if name[0] is
 
508
                        * '|' */
453
509
} acct_print_tree_t;
454
510
 
455
511
typedef struct {
460
516
 
461
517
typedef struct {
462
518
        char *archive_dir;     /* location to place archive file */
 
519
        uint16_t archive_events; /* whether or not to keep an archive
 
520
                                    file of events that can be loaded
 
521
                                    later */
463
522
        uint16_t archive_jobs; /* whether or not to keep an archive
464
523
                                  file of jobs that can be loaded
465
524
                                  later */
468
527
        uint16_t archive_steps; /* whether or not to keep an archive
469
528
                                  file of steps that can be loaded
470
529
                                  later */
 
530
        uint16_t archive_suspend; /* whether or not to keep an archive
 
531
                                     file of suspend data that can be loaded
 
532
                                     later */
471
533
        acct_job_cond_t *job_cond; /* conditions for the jobs to archive */
472
 
        uint16_t job_purge; /* purge jobs older than this in months */
473
 
        uint16_t step_purge; /* purge steps older than this in months */
 
534
        uint16_t purge_event; /* purge events older than this in months */
 
535
        uint16_t purge_job; /* purge jobs older than this in months */
 
536
        uint16_t purge_step; /* purge steps older than this in months */
 
537
        uint16_t purge_suspend; /* purge suspend data older than this
 
538
                                 * in months */
474
539
} acct_archive_cond_t;
475
540
 
476
541
typedef struct {
480
545
                             insert of jobs since past */
481
546
} acct_archive_rec_t;
482
547
 
 
548
extern uint32_t qos_max_priority; /* max priority in all qos's */
 
549
 
483
550
extern void destroy_acct_user_rec(void *object);
484
551
extern void destroy_acct_account_rec(void *object);
485
552
extern void destroy_acct_coord_rec(void *object);
488
555
extern void destroy_acct_accounting_rec(void *object);
489
556
extern void destroy_acct_association_rec(void *object);
490
557
extern void destroy_acct_qos_rec(void *object);
 
558
extern void destroy_acct_reservation_rec(void *object);
491
559
extern void destroy_acct_txn_rec(void *object);
492
560
extern void destroy_acct_wckey_rec(void *object);
493
561
extern void destroy_acct_archive_rec(void *object);
498
566
extern void destroy_acct_association_cond(void *object);
499
567
extern void destroy_acct_job_cond(void *object);
500
568
extern void destroy_acct_qos_cond(void *object);
 
569
extern void destroy_acct_reservation_cond(void *object);
501
570
extern void destroy_acct_txn_cond(void *object);
502
571
extern void destroy_acct_wckey_cond(void *object);
503
572
extern void destroy_acct_archive_cond(void *object);
538
607
                                       Buf buffer);
539
608
extern void pack_acct_qos_rec(void *in, uint16_t rpc_version, Buf buffer);
540
609
extern int unpack_acct_qos_rec(void **object, uint16_t rpc_version, Buf buffer);
 
610
extern void pack_acct_reservation_rec(void *in, uint16_t rpc_version,
 
611
                                      Buf buffer);
 
612
extern int unpack_acct_reservation_rec(void **object, uint16_t rpc_version,
 
613
                                       Buf buffer);
541
614
extern void pack_acct_txn_rec(void *in, uint16_t rpc_version, Buf buffer);
542
615
extern int unpack_acct_txn_rec(void **object, uint16_t rpc_version, Buf buffer);
543
616
extern void pack_acct_wckey_rec(void *in, uint16_t rpc_version, Buf buffer);
566
639
extern void pack_acct_qos_cond(void *in, uint16_t rpc_version, Buf buffer);
567
640
extern int unpack_acct_qos_cond(void **object, uint16_t rpc_version,
568
641
                                Buf buffer);
 
642
extern void pack_acct_reservation_cond(void *in, uint16_t rpc_version,
 
643
                                       Buf buffer);
 
644
extern int unpack_acct_reservation_cond(void **object, uint16_t rpc_version,
 
645
                                        Buf buffer);
569
646
extern void pack_acct_txn_cond(void *in, uint16_t rpc_version, Buf buffer);
570
647
extern int unpack_acct_txn_cond(void **object, uint16_t rpc_version,
571
648
                                Buf buffer);
602
679
extern List get_acct_hierarchical_rec_list(List assoc_list);
603
680
 
604
681
/* IN/OUT: tree_list a list of acct_print_tree_t's */ 
605
 
extern char *get_tree_acct_name(char *name, char *parent, char *cluster, 
606
 
                                List tree_list);
 
682
extern char *get_tree_acct_name(char *name, char *parent, List tree_list);
607
683
 
608
684
extern char *get_qos_complete_str(List qos_list, List num_qos_list);
609
685
 
 
686
extern char *get_classification_str(uint16_t class);
 
687
extern uint16_t str_2_classification(char *class);
 
688
 
610
689
extern void log_assoc_rec(acct_association_rec_t *assoc_ptr, List qos_list);
611
690
 
612
691
extern int slurm_acct_storage_init(char *loc); /* load the plugin */
699
778
                                     List wckey_list);
700
779
 
701
780
/* 
 
781
 * add reservation's in accounting system 
 
782
 * IN:  acct_reservation_rec_t *resv reservation to be added.
 
783
 * RET: SLURM_SUCCESS on success SLURM_ERROR else
 
784
 */
 
785
extern int acct_storage_g_add_reservation(void *db_conn, 
 
786
                                          acct_reservation_rec_t *resv);
 
787
 
 
788
/* 
702
789
 * modify existing users in the accounting system 
703
790
 * IN:  acct_user_cond_t *user_cond
704
791
 * IN:  acct_user_rec_t *user
760
847
                                         acct_wckey_rec_t *wckey);
761
848
 
762
849
/* 
 
850
 * modify reservation's in accounting system 
 
851
 * IN:  acct_reservation_rec_t *resv 
 
852
 * RET: SLURM_SUCCESS on success SLURM_ERROR else
 
853
 */
 
854
extern int acct_storage_g_modify_reservation(void *db_conn, 
 
855
                                             acct_reservation_rec_t *resv);
 
856
/* 
763
857
 * remove users from accounting system 
764
858
 * IN:  acct_user_cond_t *user_cond
765
859
 * RET: List containing (char *'s) else NULL on error
818
912
        void *db_conn, uint32_t uid, acct_wckey_cond_t *wckey_cond);
819
913
 
820
914
/* 
 
915
 * remove reservation's in accounting system 
 
916
 * IN:  acct_reservation_rec_t *resv 
 
917
 * RET: SLURM_SUCCESS on success SLURM_ERROR else
 
918
 */
 
919
extern int acct_storage_g_remove_reservation(void *db_conn, 
 
920
                                             acct_reservation_rec_t *resv);
 
921
/* 
821
922
 * get info from the storage 
822
923
 * IN:  acct_user_cond_t *
823
924
 * IN:  params void *
847
948
extern List acct_storage_g_get_clusters(
848
949
        void *db_conn, uint32_t uid, acct_cluster_cond_t *cluster_cond);
849
950
 
 
951
 
 
952
/* 
 
953
 * get info from the storage 
 
954
 * RET: List of config_key_pairs_t *
 
955
 * note List needs to be freed when called
 
956
 */
 
957
extern List acct_storage_g_get_config(void *db_conn);
 
958
 
850
959
/* 
851
960
 * get info from the storage 
852
961
 * IN:  acct_association_cond_t *
856
965
extern List acct_storage_g_get_associations(
857
966
        void *db_conn, uint32_t uid, acct_association_cond_t *assoc_cond);
858
967
 
859
 
 
860
968
/* 
861
969
 * get info from the storage 
862
970
 * IN:  acct_qos_cond_t *
877
985
 
878
986
/* 
879
987
 * get info from the storage 
 
988
 * IN:  acct_reservation_cond_t *
 
989
 * RET: List of acct_reservation_rec_t *
 
990
 * note List needs to be freed when called
 
991
 */
 
992
extern List acct_storage_g_get_reservations(void *db_conn, uint32_t uid,
 
993
                                            acct_reservation_cond_t *resv_cond);
 
994
 
 
995
/* 
 
996
 * get info from the storage 
880
997
 * IN:  acct_txn_cond_t *
881
998
 * RET: List of acct_txn_rec_t *
882
999
 * note List needs to be freed when called
899
1016
/* 
900
1017
 * roll up data in the storage 
901
1018
 * IN: sent_start (option time to do a re-roll or start from this point)
 
1019
 * IN: sent_end (option time to do a re-roll or end at this point)
 
1020
 * IN: archive_data (if 0 old data is not archived in a monthly rollup)
902
1021
 * RET: SLURM_SUCCESS on success SLURM_ERROR else
903
1022
 */
904
1023
extern int acct_storage_g_roll_usage(void *db_conn, 
905
 
                                     time_t sent_start);
 
1024
                                     time_t sent_start, time_t sent_end,
 
1025
                                     uint16_t archive_data);
906
1026
/* 
907
1027
 * record shares used information for backup in case slurmctld restarts 
908
1028
 * IN:  account_list List of shares_used_object_t *
936
1056
 
937
1057
extern int clusteracct_storage_g_cluster_procs(void *db_conn, 
938
1058
                                               char *cluster,
 
1059
                                               char *cluster_nodes,
939
1060
                                               uint32_t procs,
940
1061
                                               time_t event_time);
941
1062