/*___INFO__MARK_BEGIN__*/ /************************************************************************* * * The Contents of this file are made available subject to the terms of * the Sun Industry Standards Source License Version 1.2 * * Sun Microsystems Inc., March, 2001 * * * Sun Industry Standards Source License Version 1.2 * ================================================= * The contents of this file are subject to the Sun Industry Standards * Source License Version 1.2 (the "License"); You may not use this file * except in compliance with the License. You may obtain a copy of the * License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html * * Software provided under this License is provided on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. * See the License for the specific provisions governing your rights and * obligations concerning the Software. * * The Initial Developer of the Original Code is: Sun Microsystems, Inc. * * Copyright: 2001 by Sun Microsystems, Inc. * * All Rights Reserved. * ************************************************************************/ /*___INFO__MARK_END__*/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "commlib.h" #include "sge_prog.h" #include "sge_all_listsL.h" #include "sge_log.h" #include "sge_unistd.h" #include "qm_name.h" #include "sge_hostname.h" #include "sgeobj/sge_answer.h" #include "gdi/sge_gdi.h" #include "gdi/sge_gdiP.h" #include "gdi/sge_gdi_ctx.h" #include "qmon_rmon.h" #include "qmon_init.h" #include "qmon_queue.h" #include "qmon_submit.h" #include "qmon_request.h" #include "qmon_job.h" #include "qmon_comm.h" #include "qmon_timer.h" #include "qmon_widgets.h" #include "qmon_matrix.h" #include "qmon_appres.h" #include "qmon_globals.h" #include "qmon_util.h" #include "qmon_signal.h" #include "msg_clients_common.h" #include "msg_common.h" #include "msg_gdilib.h" extern sge_gdi_ctx_class_t *ctx; static String icon_names[] = { "21cal", "21cal_ins", "shell", "shell_ins", "mailbox", "mailbox_ins", "env", "penv", "ar", "stderror", "stderror_ins", "stdoutput_ins", "script_file", "script_file_ins", "qsh_on", "qsh_on_ins", "qsh_off", "qsh_off_ins", "mcicon", "aclask", "dynamite", "days", "hours", "minutes", "seconds", "infinity", "memorybig", "int", "bool", "mem", "time", "str", "cstr", "host", "unknown", "resources", "resources_enabled", "logo", "toolbar_cluster", "toolbar_queue", "toolbar_pe", "toolbar_cplx", "toolbar_submit", "toolbar_user", "toolbar_job", "toolbar_host", "toolbar_browser", "toolbar_exit", "xterm", "xterm-axp", "xterm-sun", "xterm-hp", "xterm-dec", "xterm-sol", "xterm-linux", "xterm-sgi", "xterm-ibm", "xterm-cray", "leaf", "leaf_open", "leaf_plus", "leaf_minus" }; /*-------------------------------------------------------------------------*/ /* * some nice things * 1. Load and process all images * 2. Check User Permissions and set sensitivity for dialog parts * 3. Add Functionality to change User (qmon_su) -> change sensitivity * 4. Initialize What's Where's , default values for dialogs * */ /*-------------------------------------------------------------------------*/ void qmonLoadIcons(void) { int i; XmtImage *image; String pixmap_file; Arg args[10]; Cardinal ac; String pixmapFilePath; DENTER(GUI_LAYER, "qmonLoadIcons"); ac = 0; XtSetArg(args[ac], XmtNpixmapFilePath, &pixmapFilePath); ac++; XmtGetApplicationValues(AppShell, args, ac); for (i=0; iget_sge_root(ctx); sge_qmaster_port = ctx->get_sge_qmaster_port(ctx); } if (error != AE_OK) { answer_list_output(&alp); if ( mastername != NULL) { error=ctx->is_alive(ctx); /* For the default case, just print a simple message */ if (error == CL_RETVAL_CONNECT_ERROR || error == CL_RETVAL_CONNECTION_NOT_FOUND) { SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_GDI_UNABLE_TO_CONNECT_SUS, prognames[QMASTER], sge_qmaster_port, mastername)); } /* For unusual errors, give more detail */ else { SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_GDI_CANT_SEND_MSG_TO_PORT_ON_HOST_SUSS, prognames[QMASTER], sge_qmaster_port, mastername, cl_get_error_text(error))); } fprintf(stderr, "%s\n", SGE_EVENT); if (error != CL_RETVAL_OK) { /* ** re-read act_qmaster file */ ctx->get_master(ctx, true); } } if (endless_loop == 0) { qmonExitFunc(1); } } while (endless_loop > 0) { static int nr_of_errors = 0; error=ctx->is_alive(ctx); printf("checking isalive qmaster (errors=%d, frequency=%d) ...\n", nr_of_errors, endless_loop); if (do_qmon_shutdown()) { qmonExitFunc(0); } sleep(endless_loop); if (error != CL_RETVAL_OK) { /* ** re-read act_qmaster file */ ctx->get_master(ctx, true); } } log_state_set_log_gui(0); DEXIT; } /*------------------------------------------------------------------------- Function installed to be called just before exit() is called. clean up -------------------------------------------------------------------------*/ void qmonExitFunc( int i ) { DENTER(GUI_LAYER, "qmonExitFunc"); cl_com_cleanup_commlib(); DCLOSE; exit(i); } /*-------------------------------------------------------------------------*/ void qmonExitCB( Widget w, XtPointer cld, XtPointer cad ) { DENTER(GUI_LAYER, "qmonExitCB"); sge_gdi2_shutdown((void**)&ctx); DCLOSE; exit(0); DEXIT; } #if 1 /*------------------------------------------------------------------------- The following is the Intrinsics default language procedure, adapted to use only LC_MESSAGES instead of LC_ALL -------------------------------------------------------------------------*/ static String myXtDefaultLanguageProc( Display *dpy, /* unused */ String xnl, XtPointer closure /* unused */ ) { char *languste = NULL; if (getenv("XMTDEBUGFINDFILE")) { printf("xnl = '%s'\n", xnl); } if (!strcasecmp(xnl, "relabel")) xnl = "C"; if (! setlocale(LC_ALL, xnl)) XtWarning("locale not supported by C library, locale unchanged"); if (! XSupportsLocale()) { XtWarning("locale not supported by Xlib, locale set to C"); setlocale(LC_ALL, "C"); } setlocale(LC_NUMERIC, "C"); if (! XSetLocaleModifiers("")) XtWarning("X locale modifiers not supported, using default"); languste = setlocale(LC_MESSAGES, NULL); if (getenv("XMTDEBUGFINDFILE")) { printf("languste: '%s'\n", languste); } return languste; /* re-query in case overwritten */ } #endif /*----------------------------------------------------------------------------*/ Widget XmtInitialize( XtAppContext *app, String app_class, XrmOptionDescList options, Cardinal num_options, int *argc_in_out, String *argv_in_out, String *fallbacks, ArgList args, Cardinal num_args ) { Widget top; Display *dpy; Colormap colormap; int own_colormap = 0; int i; ArgList new_args = NULL; DENTER(GUI_LAYER, "XmtInitialize"); XtSetLanguageProc(NULL, myXtDefaultLanguageProc, NULL); for (i=0; i<*argc_in_out; i++) { if (!strcmp(argv_in_out[i], "-cmap")) { own_colormap = 1; DPRINTF(("-cmap set\n")); } if (!strcmp(argv_in_out[i], "-nologo")) { nologo = 1; DPRINTF(("-nologo set\n")); } if (!strcmp(argv_in_out[i], "-qmon_debug")) { qmon_debug = 1; DPRINTF(("-qmon_debug set\n")); } if (!strcmp(argv_in_out[i], "-help")) { DPRINTF(("-help set\n")); helpset = 1; } } if (own_colormap) { XmtPatchVisualInheritance(); /* first four initialization steps */ XtToolkitInitialize(); *app = XtCreateApplicationContext(); XtAppSetFallbackResources(*app, fallbacks); dpy = XtOpenDisplay(*app, NULL, NULL, app_class, NULL, 0, argc_in_out, argv_in_out); if (dpy == NULL) XtError("cannot open display"); /* get a new colormap */ colormap = XCopyColormapAndFree(dpy, DefaultColormap(dpy, DefaultScreen(dpy))); if (colormap) { new_args = (ArgList) XtMalloc(sizeof(Arg) *(num_args+1)); for(i=0; i