|
Lines 36-44
Link Here
|
| 36 |
/* Collection of data for printing reports. Like data is combined here */ |
36 |
/* Collection of data for printing reports. Like data is combined here */ |
| 37 |
typedef struct { |
37 |
typedef struct { |
| 38 |
int color_inx; |
38 |
int color_inx; |
|
|
39 |
char *front_end_name; |
| 39 |
front_end_info_t *front_end_ptr; |
40 |
front_end_info_t *front_end_ptr; |
|
|
41 |
GtkTreeIter iter_ptr; |
| 42 |
bool iter_set; |
| 40 |
char *boot_time; |
43 |
char *boot_time; |
| 41 |
int node_inx[3]; |
44 |
int node_inx[3]; |
|
|
45 |
int pos; |
| 42 |
char *reason; |
46 |
char *reason; |
| 43 |
char *slurmd_start_time; |
47 |
char *slurmd_start_time; |
| 44 |
char *state; |
48 |
char *state; |
|
Lines 68-73
enum {
Link Here
|
| 68 |
SORTID_REASON, |
72 |
SORTID_REASON, |
| 69 |
SORTID_SLURMD_START_TIME, |
73 |
SORTID_SLURMD_START_TIME, |
| 70 |
SORTID_STATE, |
74 |
SORTID_STATE, |
|
|
75 |
SORTID_UPDATED, |
| 71 |
SORTID_CNT |
76 |
SORTID_CNT |
| 72 |
}; |
77 |
}; |
| 73 |
|
78 |
|
|
Lines 109-114
static display_data_t display_data_front_end[] = {
Link Here
|
| 109 |
refresh_front_end, create_model_front_end, admin_edit_front_end}, |
114 |
refresh_front_end, create_model_front_end, admin_edit_front_end}, |
| 110 |
{G_TYPE_POINTER, SORTID_NODE_INX, NULL, FALSE, EDIT_NONE, |
115 |
{G_TYPE_POINTER, SORTID_NODE_INX, NULL, FALSE, EDIT_NONE, |
| 111 |
refresh_front_end, create_model_front_end, admin_edit_front_end}, |
116 |
refresh_front_end, create_model_front_end, admin_edit_front_end}, |
|
|
117 |
{G_TYPE_INT, SORTID_UPDATED, NULL, FALSE, EDIT_NONE, |
| 118 |
refresh_resv, create_model_resv, admin_edit_resv}, |
| 112 |
{G_TYPE_NONE, -1, NULL, FALSE, EDIT_NONE} |
119 |
{G_TYPE_NONE, -1, NULL, FALSE, EDIT_NONE} |
| 113 |
}; |
120 |
}; |
| 114 |
|
121 |
|
|
Lines 132-147
static void _admin_front_end(GtkTreeModel *model, GtkTreeIter *iter, char *type,
Link Here
|
| 132 |
static void _process_each_front_end(GtkTreeModel *model, GtkTreePath *path, |
139 |
static void _process_each_front_end(GtkTreeModel *model, GtkTreePath *path, |
| 133 |
GtkTreeIter*iter, gpointer userdata); |
140 |
GtkTreeIter*iter, gpointer userdata); |
| 134 |
|
141 |
|
| 135 |
static void _front_end_info_list_del(void *object) |
142 |
static void _front_end_info_free(sview_front_end_info_t *sview_front_end_info) |
| 136 |
{ |
143 |
{ |
| 137 |
sview_front_end_info_t *sview_front_end_info; |
|
|
| 138 |
|
| 139 |
sview_front_end_info = (sview_front_end_info_t *)object; |
| 140 |
if (sview_front_end_info) { |
144 |
if (sview_front_end_info) { |
| 141 |
xfree(sview_front_end_info->boot_time); |
145 |
xfree(sview_front_end_info->boot_time); |
| 142 |
xfree(sview_front_end_info->reason); |
146 |
xfree(sview_front_end_info->reason); |
| 143 |
xfree(sview_front_end_info->slurmd_start_time); |
147 |
xfree(sview_front_end_info->slurmd_start_time); |
| 144 |
xfree(sview_front_end_info->state); |
148 |
xfree(sview_front_end_info->state); |
|
|
149 |
} |
| 150 |
} |
| 151 |
|
| 152 |
static void _front_end_info_list_del(void *object) |
| 153 |
{ |
| 154 |
sview_front_end_info_t *sview_front_end_info; |
| 155 |
|
| 156 |
sview_front_end_info = (sview_front_end_info_t *)object; |
| 157 |
if (sview_front_end_info) { |
| 158 |
_front_end_info_free(sview_front_end_info); |
| 145 |
xfree(sview_front_end_info); |
159 |
xfree(sview_front_end_info); |
| 146 |
} |
160 |
} |
| 147 |
} |
161 |
} |
|
Lines 210-224
static void _layout_front_end_record(GtkTreeView *treeview,
Link Here
|
| 210 |
|
224 |
|
| 211 |
static void _update_front_end_record( |
225 |
static void _update_front_end_record( |
| 212 |
sview_front_end_info_t *sview_front_end_info_ptr, |
226 |
sview_front_end_info_t *sview_front_end_info_ptr, |
| 213 |
GtkTreeStore *treestore, |
227 |
GtkTreeStore *treestore) |
| 214 |
GtkTreeIter *iter) |
|
|
| 215 |
{ |
228 |
{ |
| 216 |
front_end_info_t *front_end_ptr; |
229 |
front_end_info_t *front_end_ptr; |
| 217 |
|
230 |
|
| 218 |
front_end_ptr = sview_front_end_info_ptr->front_end_ptr; |
231 |
front_end_ptr = sview_front_end_info_ptr->front_end_ptr; |
| 219 |
|
232 |
|
| 220 |
/* Combining these records provides a slight performance improvement */ |
233 |
/* Combining these records provides a slight performance improvement */ |
| 221 |
gtk_tree_store_set(treestore, iter, |
234 |
gtk_tree_store_set(treestore, &sview_front_end_info_ptr->iter_ptr, |
| 222 |
SORTID_ALLOW_GROUPS, front_end_ptr->allow_groups, |
235 |
SORTID_ALLOW_GROUPS, front_end_ptr->allow_groups, |
| 223 |
SORTID_ALLOW_USERS, front_end_ptr->allow_users, |
236 |
SORTID_ALLOW_USERS, front_end_ptr->allow_users, |
| 224 |
SORTID_BOOT_TIME, |
237 |
SORTID_BOOT_TIME, |
|
Lines 236-241
static void _update_front_end_record(
Link Here
|
| 236 |
SORTID_SLURMD_START_TIME, |
249 |
SORTID_SLURMD_START_TIME, |
| 237 |
sview_front_end_info_ptr->slurmd_start_time, |
250 |
sview_front_end_info_ptr->slurmd_start_time, |
| 238 |
SORTID_STATE, sview_front_end_info_ptr->state, |
251 |
SORTID_STATE, sview_front_end_info_ptr->state, |
|
|
252 |
SORTID_UPDATED, 1, |
| 239 |
-1); |
253 |
-1); |
| 240 |
|
254 |
|
| 241 |
return; |
255 |
return; |
|
Lines 243-319
static void _update_front_end_record(
Link Here
|
| 243 |
|
257 |
|
| 244 |
static void _append_front_end_record( |
258 |
static void _append_front_end_record( |
| 245 |
sview_front_end_info_t *sview_front_end_info_ptr, |
259 |
sview_front_end_info_t *sview_front_end_info_ptr, |
| 246 |
GtkTreeStore *treestore, GtkTreeIter *iter, |
260 |
GtkTreeStore *treestore) |
| 247 |
int line) |
|
|
| 248 |
{ |
261 |
{ |
| 249 |
gtk_tree_store_append(treestore, iter, NULL); |
262 |
gtk_tree_store_append(treestore, &sview_front_end_info_ptr->iter_ptr, |
| 250 |
gtk_tree_store_set(treestore, iter, SORTID_POS, line, -1); |
263 |
NULL); |
| 251 |
_update_front_end_record(sview_front_end_info_ptr, treestore, iter); |
264 |
gtk_tree_store_set(treestore, &sview_front_end_info_ptr->iter_ptr, |
|
|
265 |
SORTID_POS, sview_front_end_info_ptr->pos, -1); |
| 266 |
_update_front_end_record(sview_front_end_info_ptr, treestore); |
| 252 |
} |
267 |
} |
| 253 |
|
268 |
|
| 254 |
static void _update_info_front_end(List info_list, GtkTreeView *tree_view) |
269 |
static void _update_info_front_end(List info_list, GtkTreeView *tree_view) |
| 255 |
{ |
270 |
{ |
| 256 |
GtkTreePath *path = gtk_tree_path_new_first(); |
|
|
| 257 |
GtkTreeModel *model = gtk_tree_view_get_model(tree_view); |
271 |
GtkTreeModel *model = gtk_tree_view_get_model(tree_view); |
| 258 |
GtkTreeIter iter; |
272 |
static GtkTreeModel *last_model = NULL; |
| 259 |
front_end_info_t *front_end_ptr = NULL; |
273 |
char *name; |
| 260 |
int line = 0; |
|
|
| 261 |
char *host = NULL, *front_end_name = NULL; |
| 262 |
ListIterator itr = NULL; |
274 |
ListIterator itr = NULL; |
| 263 |
sview_front_end_info_t *sview_front_end_info = NULL; |
275 |
sview_front_end_info_t *sview_front_end_info = NULL; |
| 264 |
|
276 |
|
| 265 |
/* get the iter, or find out the list is empty goto add */ |
277 |
set_for_update(model, SORTID_UPDATED); |
| 266 |
if (gtk_tree_model_get_iter(model, &iter, path)) { |
|
|
| 267 |
/* make sure all the reserves are still here */ |
| 268 |
while (1) { |
| 269 |
if (!gtk_tree_model_iter_next(model, &iter)) { |
| 270 |
break; |
| 271 |
} |
| 272 |
} |
| 273 |
} |
| 274 |
|
278 |
|
| 275 |
itr = list_iterator_create(info_list); |
279 |
itr = list_iterator_create(info_list); |
| 276 |
while ((sview_front_end_info = list_next(itr))) { |
280 |
while ((sview_front_end_info = list_next(itr))) { |
| 277 |
front_end_ptr = sview_front_end_info->front_end_ptr; |
281 |
/* This means the tree_store changed (added new column |
| 278 |
/* get the iter, or find out the list is empty goto add */ |
282 |
or something). */ |
| 279 |
if (!gtk_tree_model_get_iter(model, &iter, path)) { |
283 |
if (last_model != model) |
| 280 |
goto adding; |
284 |
sview_front_end_info->iter_set = false; |
| 281 |
} |
285 |
|
| 282 |
line = 0; |
286 |
if (sview_front_end_info->iter_set) { |
| 283 |
while (1) { |
287 |
gtk_tree_model_get(model, |
| 284 |
/* search for the jobid and check to see if |
288 |
&sview_front_end_info->iter_ptr, |
| 285 |
it is in the list */ |
289 |
SORTID_NAME, &name, -1); |
| 286 |
gtk_tree_model_get(model, &iter, SORTID_NAME, |
290 |
if (strcmp(name, |
| 287 |
&front_end_name, -1); |
291 |
sview_front_end_info->front_end_name)) { |
| 288 |
if (!strcmp(front_end_name, front_end_ptr->name)) { |
292 |
/* Bad pointer */ |
| 289 |
/* update with new info */ |
293 |
sview_front_end_info->iter_set = false; |
| 290 |
g_free(front_end_name); |
294 |
//g_print("bad front_end iter pointer\n"); |
| 291 |
_update_front_end_record(sview_front_end_info, |
|
|
| 292 |
GTK_TREE_STORE(model), |
| 293 |
&iter); |
| 294 |
goto found; |
| 295 |
} |
| 296 |
g_free(front_end_name); |
| 297 |
|
| 298 |
line++; |
| 299 |
if (!gtk_tree_model_iter_next(model, &iter)) { |
| 300 |
break; |
| 301 |
} |
295 |
} |
|
|
296 |
g_free(name); |
| 297 |
} |
| 298 |
if (sview_front_end_info->iter_set) |
| 299 |
_update_front_end_record(sview_front_end_info, |
| 300 |
GTK_TREE_STORE(model)); |
| 301 |
else { |
| 302 |
_append_front_end_record(sview_front_end_info, |
| 303 |
GTK_TREE_STORE(model)); |
| 304 |
sview_front_end_info->iter_set = true; |
| 302 |
} |
305 |
} |
| 303 |
adding: |
|
|
| 304 |
_append_front_end_record(sview_front_end_info, |
| 305 |
GTK_TREE_STORE(model), |
| 306 |
&iter, line); |
| 307 |
found: |
| 308 |
; |
| 309 |
} |
306 |
} |
| 310 |
list_iterator_destroy(itr); |
307 |
list_iterator_destroy(itr); |
| 311 |
if (host) |
|
|
| 312 |
free(host); |
| 313 |
|
308 |
|
| 314 |
gtk_tree_path_free(path); |
309 |
/* remove all old front_ends */ |
| 315 |
|
310 |
remove_old(model, SORTID_UPDATED); |
| 316 |
return; |
311 |
last_model = model; |
| 317 |
} |
312 |
} |
| 318 |
|
313 |
|
| 319 |
static List _create_front_end_info_list( |
314 |
static List _create_front_end_info_list( |
|
Lines 322-327
static List _create_front_end_info_list(
Link Here
|
| 322 |
char *upper = NULL; |
317 |
char *upper = NULL; |
| 323 |
char user[32], time_str[32]; |
318 |
char user[32], time_str[32]; |
| 324 |
static List info_list = NULL; |
319 |
static List info_list = NULL; |
|
|
320 |
List last_list = NULL; |
| 321 |
ListIterator last_list_itr = NULL; |
| 325 |
int i = 0; |
322 |
int i = 0; |
| 326 |
sview_front_end_info_t *sview_front_end_info_ptr = NULL; |
323 |
sview_front_end_info_t *sview_front_end_info_ptr = NULL; |
| 327 |
front_end_info_t *front_end_ptr = NULL; |
324 |
front_end_info_t *front_end_ptr = NULL; |
|
Lines 330-348
static List _create_front_end_info_list(
Link Here
|
| 330 |
goto update_color; |
327 |
goto update_color; |
| 331 |
|
328 |
|
| 332 |
if (info_list) |
329 |
if (info_list) |
| 333 |
list_flush(info_list); |
330 |
last_list = info_list; |
| 334 |
else |
|
|
| 335 |
info_list = list_create(_front_end_info_list_del); |
| 336 |
|
331 |
|
|
|
332 |
info_list = list_create(_front_end_info_list_del); |
| 337 |
if (!info_list) { |
333 |
if (!info_list) { |
| 338 |
g_print("malloc error\n"); |
334 |
g_print("malloc error\n"); |
| 339 |
return NULL; |
335 |
return NULL; |
| 340 |
} |
336 |
} |
| 341 |
|
337 |
|
|
|
338 |
if (last_list) |
| 339 |
last_list_itr = list_iterator_create(last_list); |
| 342 |
for (i = 0; i < front_end_info_ptr->record_count; i++) { |
340 |
for (i = 0; i < front_end_info_ptr->record_count; i++) { |
| 343 |
front_end_ptr = &(front_end_info_ptr->front_end_array[i]); |
341 |
front_end_ptr = &(front_end_info_ptr->front_end_array[i]); |
| 344 |
sview_front_end_info_ptr = |
342 |
|
| 345 |
xmalloc(sizeof(sview_front_end_info_t)); |
343 |
sview_front_end_info_ptr = NULL; |
|
|
344 |
|
| 345 |
if (last_list_itr) { |
| 346 |
while ((sview_front_end_info_ptr = |
| 347 |
list_next(last_list_itr))) { |
| 348 |
if (!strcmp(sview_front_end_info_ptr-> |
| 349 |
front_end_name, |
| 350 |
front_end_ptr->name)) { |
| 351 |
list_remove(last_list_itr); |
| 352 |
_front_end_info_free( |
| 353 |
sview_front_end_info_ptr); |
| 354 |
break; |
| 355 |
} |
| 356 |
} |
| 357 |
list_iterator_reset(last_list_itr); |
| 358 |
} |
| 359 |
if (!sview_front_end_info_ptr) |
| 360 |
sview_front_end_info_ptr = |
| 361 |
xmalloc(sizeof(sview_front_end_info_t)); |
| 362 |
sview_front_end_info_ptr->pos = i; |
| 363 |
sview_front_end_info_ptr->front_end_name = front_end_ptr->name; |
| 346 |
sview_front_end_info_ptr->front_end_ptr = front_end_ptr; |
364 |
sview_front_end_info_ptr->front_end_ptr = front_end_ptr; |
| 347 |
sview_front_end_info_ptr->color_inx = i % sview_colors_cnt; |
365 |
sview_front_end_info_ptr->color_inx = i % sview_colors_cnt; |
| 348 |
if (g_node_info_ptr) { |
366 |
if (g_node_info_ptr) { |
|
Lines 390-395
static List _create_front_end_info_list(
Link Here
|
| 390 |
list_append(info_list, sview_front_end_info_ptr); |
408 |
list_append(info_list, sview_front_end_info_ptr); |
| 391 |
} |
409 |
} |
| 392 |
|
410 |
|
|
|
411 |
if (last_list) { |
| 412 |
list_iterator_destroy(last_list_itr); |
| 413 |
list_destroy(last_list); |
| 414 |
} |
| 415 |
|
| 393 |
update_color: |
416 |
update_color: |
| 394 |
return info_list; |
417 |
return info_list; |
| 395 |
} |
418 |
} |