#ifndef ZENTIFIC_SCHEDULER #define ZENTIFIC_SCHEDULER #include #include #include #include #include #include #include #include #include #include #include #include #include "zentific/adts.h" #include "zentific/utility.h" #include "Zentific-types.h" #include "sources.h" /* * Signals that are used for IPC by the scheduler */ #define SIG_NEW_JOB SIGUSR1 #define SIG_CANCEL_JOB SIGUSR2 /* * Exit Codes */ #define INIT_ERROR -1 #define RUN_ERROR -2 #define EXIT_ERROR -3 /* * Configuration Options */ #define CONFIG_ERROR -1 struct t_ZentificSchedulerConfig { char *pid_file; /* full path to the PID file */ int max_jobs; /* maximum number of jobs to have executing at once */ int max_slow; /* maximum number of slow jobs to run at any point */ int max_default; /* maximum number of default speed jobs to run at any point */ int min_fast; /* minimum # of slots to have reserved for fast jobs at all times */ int debug; /* one of the DBG_ flags */ char *config_file; /* full path to the config file */ char *log_file; /* full path to the file to log to */ char *db_modules_path; char *db_module_name; }; /** * Sets all of the default configuration options for the given config structure */ int setDefaults(struct t_ZentificSchedulerConfig *config); /** * Parses the command line parameters into the given config file */ int parseCommandOptions(int argc, char **argv, struct t_ZentificSchedulerConfig *config); /** * Reads the config file option in the config set and then parses the config file */ int parseConfigFile(struct t_ZentificSchedulerConfig *config); /** * Re-reads the config file to over-ride config options and reload new config. * * Then closes all sources and reloads them. */ void reparseConfigFile(int signum); /** * Called on SIGQUIT to exit cleanly */ void cleanExit(int signum); /** * A job process thread. This thread handles execution of a single job. When it starts, it grabs * whichever job is supposed to run next, executes it and then waits for the response so that it * can send a SIG_JOB_COMPLETE back to the main program. */ void *t_jobProcess(void *thread_id); /** * Handles a SIG_CANCEL_JOB signal inside child processes for addon jobs */ void jobCancelHandler(int signum); /** * Fetches jobs from the sources. If fetch_all is 1, this includes jobs that have been fetched * before and may be in various stages of execution */ int jobFetch(int fetch_all); /** * Reads the next available job with the given or faster speed. */ zJob* readNextJob(zList *jobList, int max_speed); /** * Handles the signals that inform us of new jobs in the database */ void fetchJobHandler(int signum); #endif // ZENTIFIC_SCHEDULER