1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
#include <string.h>
#include "sge.h"
#include "sgermon.h"
#include "cull.h"
#include "sge_ulong.h"
#include "sge_serf.h"
#include "sge_schedd_conf.h"
/****** SERF/-SERF_Implementation *******************************************
* NAME
* SERF_Implementation -- Functions that implement a generic schedule
* entry recording facility (SERF)
*
* SEE ALSO
* SERF/serf_init()
* SERF/serf_record_entry()
* SERF/serf_new_interval()
* SERF/serf_get_active()
* SERF/serf_set_active()
* SERF/serf_exit()
*******************************************************************************/
typedef struct {
record_schedule_entry_func_t record_schedule_entry;
new_schedule_func_t new_schedule;
} sge_serf_t;
static sge_serf_t current_serf = { NULL, NULL }; /* thread local */
/****** sge_resource_utilization/serf_init() ***********************************
* NAME
* serf_init() -- Initializes SERF
*
* SYNOPSIS
* void serf_init(record_schedule_entry_func_t write, new_schedule_func_t
* newline)
*
* NOTES
* MT-NOTE: serf_init() is not MT safe
*******************************************************************************/
void serf_init(record_schedule_entry_func_t write, new_schedule_func_t newline)
{
current_serf.record_schedule_entry = write;
current_serf.new_schedule = newline;
}
/****** sge_resource_utilization/serf_record_entry() ***************************
* NAME
* serf_record_entry() -- Add a new schedule entry record
*
* SYNOPSIS
* void serf_record_entry(u_long32 job_id, u_long32 ja_taskid, const char
* *state, u_long32 start_time, u_long32 end_time, char level_char, const
* char *object_name, const char *name, double utilization)
*
* FUNCTION
* The entirety of all information passed to this function describes
* the schedule that was created during a scheduling interval of a
* Grid Engine scheduler. To reflect multiple resource debitations
* of a job multiple calls to serf_record_entry() are required. For
* parallel jobs the serf_record_entry() is called one times with a
* 'P' as level_char.
*
* INPUTS
* u_long32 job_id - The job id
* u_long32 ja_taskid - The task id
* const char *type - A string indicating the reason why the
* utilization was put into the schedule:
*
* RUNNING - Job was running before scheduling run
* SUSPENDED - Job was suspended before scheduling run
* PREEMPTING - Job gets preempted currently
* STARTING - Job will be started
* RESERVING - Job reserves resources
*
* u_long32 start_time - Start of the resource utilization
*
* u_long32 end_time - End of the resource utilization
*
* char level_char - Q - Queue
* H - Host
* G - Global
* P - Parallel Environment (PE)
*
* const char *object_name - Name of Queue/Host/Global/PE
*
* const char *name - Resource name
*
* double utilization - Utilization amount
*
* NOTES
* MT-NOTE: (1) serf_record_entry() is MT safe if no recording function
* MT-NOTE: was registered via serf_init().
* MT-NOTE: (2) Otherwise MT safety of serf_record_entry() depends on
* MT-NOTE: MT safety of registered recording function
*******************************************************************************/
void serf_record_entry(u_long32 job_id, u_long32 ja_taskid,
const char *type, u_long32 start_time, u_long32 end_time, char level_char,
const char *object_name, const char *name, double utilization)
{
DENTER(TOP_LAYER, "serf_record_entry");
/* human readable format */
DPRINTF(("J="sge_U32CFormat"."sge_U32CFormat" T=%s S="sge_U32CFormat" E="sge_U32CFormat" L=%c O=%s R=%s U=%f\n",
job_id, ja_taskid, type, start_time, end_time,
level_char, object_name, name, utilization));
if (current_serf.record_schedule_entry && serf_get_active()) {
(current_serf.record_schedule_entry)(job_id, ja_taskid, type, start_time, end_time,
level_char, object_name, name, utilization);
}
DRETURN_VOID;
}
/****** sge_resource_utilization/serf_new_interval() ***************************
* NAME
* serf_new_interval() -- Indicate a new scheduling run
*
* SYNOPSIS
* void serf_new_interval(u_long32 time)
*
* FUNCTION
* When a new scheduling run is started serf_new_interval() shall be
* called to indicate this. This allows assigning of schedule entry
* records to different schedule runs.
*
* INPUTS
* u_long32 time - The time when the schedule run was started.
*
* NOTES
* MT-NOTE: (1) serf_new_interval() is MT safe if no recording function
* MT-NOTE: was registered via serf_init().
* MT-NOTE: (2) Otherwise MT safety of serf_new_interval() depends on
* MT-NOTE: MT safety of registered recording function
*******************************************************************************/
void serf_new_interval(u_long32 time)
{
DENTER(TOP_LAYER, "serf_new_interval");
DPRINTF(("================[SCHEDULING-EPOCH]==================\n"));
if (current_serf.new_schedule && serf_get_active()) {
(current_serf.new_schedule)(time);
}
DEXIT;
}
/****** sge_resource_utilization/serf_exit() ***********************************
* NAME
* serf_exit() -- Closes SERF
*
* SYNOPSIS
* void serf_exit(void)
*
* FUNCTION
* All operations requited to cleanly shutdown the SERF are done.
*
* NOTES
* MT-NOTE: serf_exit() is MT safe
*******************************************************************************/
void serf_exit(void)
{
memset(¤t_serf, 0, sizeof(sge_serf_t));
}
|