1
/*************************************************************************
3
* The Contents of this file are made available subject to the terms of
4
* the Sun Industry Standards Source License Version 1.2
6
* Sun Microsystems Inc., March, 2001
9
* Sun Industry Standards Source License Version 1.2
10
* =================================================
11
* The contents of this file are subject to the Sun Industry Standards
12
* Source License Version 1.2 (the "License"); You may not use this file
13
* except in compliance with the License. You may obtain a copy of the
14
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
16
* Software provided under this License is provided on an "AS IS" basis,
17
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
18
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
19
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
20
* See the License for the specific provisions governing your rights and
21
* obligations concerning the Software.
23
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
25
* Copyright: 2003 by Sun Microsystems, Inc.
27
* All Rights Reserved.
29
************************************************************************/
30
/*___INFO__MARK_END__*/
38
#include "basis_types.h"
39
#include "sge_qmaster_threads.h"
41
#include "sge_mt_init.h"
44
#include "sge_unistd.h"
45
#include "sge_answer.h"
46
#include "setup_qmaster.h"
47
#include "sge_security.h"
48
#include "sge_manop.h"
49
#include "sge_mtutil.h"
51
#include "sge_qmaster_process_message.h"
52
#include "sge_event_master.h"
53
#include "sge_persistence_qmaster.h"
54
#include "sge_reporting_qmaster.h"
55
#include "sge_qmaster_timed_event.h"
56
#include "sge_host_qmaster.h"
57
#include "sge_userprj_qmaster.h"
58
#include "sge_give_jobs.h"
59
#include "sge_all_listsL.h"
60
#include "sge_calendar_qmaster.h"
63
#include "qmaster_heartbeat.h"
65
#include "sge_spool.h"
66
#include "cl_commlib.h"
67
#include "sge_uidgid.h"
68
#include "sge_bootstrap.h"
69
#include "msg_common.h"
70
#include "msg_qmaster.h"
71
#include "msg_daemons_common.h"
72
#include "msg_utilib.h" /* remove once 'sge_daemonize_qmaster' did become 'sge_daemonize' */
74
#include "sge_qmod_qmaster.h"
75
#include "reschedule.h"
76
#include "sge_job_qmaster.h"
77
#include "sge_profiling.h"
78
#include "sgeobj/sge_conf.h"
80
#include "setup_path.h"
81
#include "sge_advance_reservation_qmaster.h"
82
#include "sge_sched_process_events.h"
83
#include "sge_follow.h"
85
#include "gdi/sge_gdi_packet.h"
87
#include "uti/sge_os.h"
88
#include "uti/sge_thread_ctrl.h"
90
#include "sge_thread_main.h"
91
#include "sge_thread_timer.h"
92
#include "sge_thread_event_master.h"
93
#include "sge_qmaster_timed_event.h"
94
#include "sge_qmaster_heartbeat.h"
95
#include "sge_persistence_qmaster.h"
98
sge_event_master_cleanup_monitor(monitoring_t *monitor)
100
DENTER(TOP_LAYER, "sge_event_master_cleanup_monitor");
101
sge_monitor_free(monitor);
106
sge_event_master_cleanup_report_list(lList **list)
108
DENTER(TOP_LAYER, "sge_event_master_cleanup_monitor");
114
sge_event_master_initialize(sge_gdi_ctx_class_t *ctx)
116
cl_thread_settings_t* dummy_thread_p = NULL;
117
dstring thread_name = DSTRING_INIT;
119
DENTER(TOP_LAYER, "sge_event_master_initialize");
121
DPRINTF(("event master functionality has been initialized\n"));
123
sge_dstring_sprintf(&thread_name, "%s%03d", threadnames[DELIVERER_THREAD], 0);
124
cl_thread_list_setup(&(Main_Control.event_master_thread_pool), "event master thread pool");
125
cl_thread_list_create_thread(Main_Control.event_master_thread_pool, &dummy_thread_p,
126
NULL, sge_dstring_get_string(&thread_name), 0,
127
sge_event_master_main, NULL, NULL);
128
sge_dstring_free(&thread_name);
133
sge_event_master_terminate(void)
135
cl_thread_settings_t* thread = NULL;
137
DENTER(TOP_LAYER, "sge_event_master_terminate");
139
thread = cl_thread_list_get_first_thread(Main_Control.event_master_thread_pool);
140
while (thread != NULL) {
141
DPRINTF((SFN" gets canceled\n", thread->thread_name));
142
cl_thread_list_delete_thread(Main_Control.event_master_thread_pool, thread);
143
thread = cl_thread_list_get_first_thread(Main_Control.event_master_thread_pool);
145
DPRINTF(("all "SFN" threads terminated\n", threadnames[DELIVERER_THREAD]));
151
sge_event_master_main(void *arg)
153
bool do_endlessly = true;
154
cl_thread_settings_t *thread_config = (cl_thread_settings_t*)arg;
155
sge_gdi_ctx_class_t *ctx = NULL;
156
monitoring_t monitor;
158
lListElem *report = NULL;
159
lList *report_list = NULL;
160
time_t next_prof_output = 0;
162
DENTER(TOP_LAYER, "sge_event_master_main");
164
DPRINTF(("started"));
165
cl_thread_func_startup(thread_config);
166
sge_monitor_init(&monitor, thread_config->thread_name, EDT_EXT, EMT_WARNING, EMT_ERROR);
167
sge_qmaster_thread_init(&ctx, QMASTER, DELIVERER_THREAD, true);
169
/* register at profiling module */
170
set_thread_name(pthread_self(), "Deliver Thread");
171
conf_update_thread_profiling("Deliver Thread");
173
report_list = lCreateListHash("report list", REP_Type, false);
174
report = lCreateElem(REP_Type);
175
lSetUlong(report, REP_type, NUM_REP_REPORT_EVENTS);
176
lSetHost(report, REP_host, ctx->get_qualified_hostname(ctx));
177
lAppendElem(report_list, report);
179
while (do_endlessly) {
182
thread_start_stop_profiling();
185
* did a new event arrive which has a flush time of 0 seconds?
187
MONITOR_IDLE_TIME(sge_event_master_wait_next(), (&monitor), mconf_get_monitor_time(),
188
mconf_is_monitor_message());
190
MONITOR_MESSAGES((&monitor));
191
MONITOR_EDT_COUNT((&monitor));
192
MONITOR_CLIENT_COUNT((&monitor), lGetNumberOfElem(Event_Master_Control.clients));
194
sge_event_master_process_requests(&monitor);
195
sge_event_master_send_events(ctx, report, report_list, &monitor);
196
sge_monitor_output(&monitor);
198
thread_output_profiling("event master thread profiling summary:\n",
201
/* pthread cancelation point */
202
pthread_cleanup_push((void (*)(void *))sge_event_master_cleanup_monitor,
204
pthread_cleanup_push((void (*)(void *))sge_event_master_cleanup_report_list,
205
(void *)&report_list);
206
cl_thread_func_testcancel(thread_config);
207
pthread_cleanup_pop(execute);
208
pthread_cleanup_pop(execute);
209
if (sge_thread_has_shutdown_started()) {
210
DPRINTF(("waiting for termination\n"));
216
* Don't add cleanup code here. It will never be executed. Instead register
217
* a cleanup function with pthread_cleanup_push()/pthread_cleanup_pop() before
218
* and after the call of cl_thread_func_testcancel()