~ubuntu-branches/ubuntu/precise/slurm-llnl/precise

« back to all changes in this revision

Viewing changes to src/slurmctld/licenses.c

  • Committer: Bazaar Package Importer
  • Author(s): Gennaro Oliva
  • Date: 2011-04-08 11:21:17 UTC
  • mfrom: (3.3.16 sid)
  • Revision ID: james.westby@ubuntu.com-20110408112117-nfnyq9dtm55hqoaw
Tags: 2.2.4-1
* New upstream releases 
* Cleaning spare file and directories, not belonging to the sources
  generated by the building process and not removed by distclean.
  Added debian/clean with spare files and rm -rf inside debian/rules
  for directories.
* Added new packages libslurm-perl, libslurmdb-perl, slurm-llnl-torque
  (Closes: #575822) thanks to Julien Blache

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************\
2
2
 *  licenses.c - Functions for handling cluster-wide consumable resources
3
3
 *****************************************************************************
4
 
 *  Copyright (C) 2008-2009 Lawrence Livermore National Security.
 
4
 *  Copyright (C) 2008-2010 Lawrence Livermore National Security.
5
5
 *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
6
6
 *  Written by Morris Jette <jette@llnl.gov>, et. al.
7
7
 *  CODE-OCEC-09-009. All rights reserved.
52
52
#include "src/slurmctld/reservation.h"
53
53
#include "src/slurmctld/slurmctld.h"
54
54
 
55
 
#define _DEBUG 0
56
 
 
57
55
List license_list = (List) NULL;
58
56
static pthread_mutex_t license_mutex = PTHREAD_MUTEX_INITIALIZER;
59
57
 
60
58
/* Print all licenses on a list */
61
 
static inline void _licenses_print(char *header, List licenses)
 
59
static inline void _licenses_print(char *header, List licenses, int job_id)
62
60
{
63
 
#if _DEBUG
64
61
        ListIterator iter;
65
62
        licenses_t *license_entry;
66
63
 
67
 
        info("licenses: %s", header);
68
64
        if (licenses == NULL)
69
65
                return;
70
66
 
71
67
        iter = list_iterator_create(licenses);
72
68
        if (iter == NULL)
73
69
                fatal("malloc failure from list_iterator_create");
74
 
        while ((license_entry = (licenses_t *) list_next(iter))) {
75
 
                info("name:%s total:%u used:%u", license_entry->name,
76
 
                     license_entry->total, license_entry->used);
 
70
        while ((license_entry = (licenses_t *) list_next(iter))) {
 
71
                if (job_id == 0) {
 
72
                        info("licenses: %s=%s total=%u used=%u", 
 
73
                             header, license_entry->name,
 
74
                             license_entry->total, license_entry->used);
 
75
                } else {
 
76
                        info("licenses: %s=%s job_id=%u available=%u used=%u", 
 
77
                             header, license_entry->name, job_id, 
 
78
                             license_entry->total, license_entry->used);
 
79
                }
77
80
        }
78
81
        list_iterator_destroy(iter);
79
 
#endif
80
82
}
81
83
 
82
84
/* Free a license_t record (for use by list_destroy) */
162
164
        if (!valid)
163
165
                fatal("Invalid configured licenses: %s", licenses);
164
166
 
165
 
        _licenses_print("licences_init", license_list);
 
167
        _licenses_print("init_license", license_list, 0);
166
168
        slurm_mutex_unlock(&license_mutex);
167
169
        return SLURM_SUCCESS;
168
170
}
209
211
 
210
212
        list_destroy(license_list);
211
213
        license_list = new_list;
212
 
        _licenses_print("licences_update", license_list);
 
214
        _licenses_print("update_license", license_list, 0);
213
215
        slurm_mutex_unlock(&license_mutex);
214
216
        return SLURM_SUCCESS;
215
217
}
239
241
        List job_license_list;
240
242
 
241
243
        job_license_list = _build_license_list(licenses, valid);
242
 
        _licenses_print("job_validate", job_license_list);
243
244
        if (!job_license_list)
244
245
                return job_license_list;
245
246
 
246
247
        slurm_mutex_lock(&license_mutex);
 
248
        _licenses_print("request_license", job_license_list, 0);
247
249
        iter = list_iterator_create(job_license_list);
248
250
        if (iter == NULL)
249
251
                fatal("malloc failure from list_iterator_create");
358
360
                }
359
361
        }
360
362
        list_iterator_destroy(iter);
361
 
        _licenses_print("licences_job_get", license_list);
 
363
        _licenses_print("acquire_license", license_list, job_ptr->job_id);
362
364
        slurm_mutex_unlock(&license_mutex);
363
365
        return rc;
364
366
}
401
403
                }
402
404
        }
403
405
        list_iterator_destroy(iter);
404
 
        _licenses_print("licences_job_return", license_list);
 
406
        _licenses_print("return_license", license_list, job_ptr->job_id);
405
407
        slurm_mutex_unlock(&license_mutex);
406
408
        return rc;
407
409
}