Skip to content

Commit

Permalink
Merge branch 'mxqsub'
Browse files Browse the repository at this point in the history
* mxqsub:
  mxq: Remove obsolete mxq.h
  mxqsub: Improve handling of mysql config defaults
  mxqsub: Cleanup missing includes and dependencies
  mxqsub: Remove build dependency to mxq_mysql
  • Loading branch information
mariux committed May 21, 2015
2 parents 238bf36 + ab0776b commit 129852c
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 114 deletions.
24 changes: 10 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,14 @@ endif

##############################################################################

MXQ_MYSQL_DEFAULT_FILE = ${SYSCONFDIR}/mxq/mysql.cnf
MXQ_MYSQL_DEFAULT_FILE = ${SYSCONFDIR}/mxq/mysql.cnf
MXQ_MYSQL_DEFAULT_GROUP = mxqclient

MXQ_INITIAL_PATH = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin

CFLAGS_MXQ_MYSQL_DEFAULT_FILE = -DMXQ_MYSQL_DEFAULT_FILE=\"$(MXQ_MYSQL_DEFAULT_FILE)\"
CFLAGS_MXQ_INITIAL_PATH = -DMXQ_INITIAL_PATH=\"$(MXQ_INITIAL_PATH)\"
CFLAGS_MXQ_MYSQL_DEFAULT_FILE = -DMXQ_MYSQL_DEFAULT_FILE=\"$(MXQ_MYSQL_DEFAULT_FILE)\"
CFLAGS_MXQ_MYSQL_DEFAULT_GROUP = -DMXQ_MYSQL_DEFAULT_GROUP=\"$(MXQ_MYSQL_DEFAULT_GROUP)\"
CFLAGS_MXQ_INITIAL_PATH = -DMXQ_INITIAL_PATH=\"$(MXQ_INITIAL_PATH)\"

MYSQL_CONFIG = mysql_config

Expand Down Expand Up @@ -177,12 +180,6 @@ mx_flock.h += mx_flock.h
mx_mysql.h += mx_mysql.h
mx_mysql.h += $(mx_util.h)

### mxq.h --------------------------------------------------------------

mxq.h += mxq.h
mxq.h += $(mxq_group.h)
mxq.h += $(mxq_job.h)

### mxq_mysql.h --------------------------------------------------------

mxq_mysql.h += mxq_mysql.h
Expand All @@ -192,7 +189,6 @@ mxq_mysql.h += $(mxq_util.h)

mxq_util.h += mxq_util.h
mxq_util.h += $(mx_log.h)
mxq_util.h += $(mxq.h)

### mxq_group.h --------------------------------------------------------

Expand Down Expand Up @@ -314,7 +310,6 @@ clean: CLEAN += mxq_group.o

mxq_job.o: $(mx_util.h)
mxq_job.o: $(mx_log.h)
mxq_job.o: $(mxq.h)
mxq_job.o: $(mxq_job.h)
mxq_job.o: $(mxq_group.h)
mxq_job.o: $(mxq_mysql.h)
Expand Down Expand Up @@ -342,13 +337,15 @@ clean: CLEAN += mxqd.o
### mxqsub.o -------------------------------------------------------

mxqsub.o: $(mx_getopt.h)
mxqsub.o: $(mxq_util.h)
mxqsub.o: $(mx_util.h)
mxqsub.o: $(mx_log.h)
mxqsub.o: $(mxq_mysql.h)
mxqsub.o: $(mx_mysql.h)
mxqsub.o: $(mxq_group.h)
mxqsub.o: $(mxq_job.h)
mxqsub.o: $(mxq_util.h)
mxqsub.o: CFLAGS += $(CFLAGS_MYSQL)
mxqsub.o: CFLAGS += $(CFLAGS_MXQ_MYSQL_DEFAULT_FILE)
mxqsub.o: CFLAGS += $(CFLAGS_MXQ_MYSQL_DEFAULT_GROUP)

clean: CLEAN += mxqsub.o

Expand Down Expand Up @@ -377,7 +374,6 @@ install:: mxqd
### mxqsub ------------------------------------------------------------

mxqsub: mx_getopt.o
mxqsub: mxq_mysql.o
mxqsub: mxq_util.o
mxqsub: mx_util.o
mxqsub: mx_log.o
Expand Down
78 changes: 0 additions & 78 deletions mxq.h

This file was deleted.

1 change: 1 addition & 0 deletions mxq_group.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "mx_log.h"

#include "mxq_group.h"
#include "mxq_job.h"
#include "mxq_mysql.h"

#define MXQ_GROUP_FIELDS "group_id," \
Expand Down
1 change: 0 additions & 1 deletion mxq_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "mxq_group.h"
#include "mxq_job.h"
#include "mxq_mysql.h"
#include "mxq.h"

#define MXQ_JOB_FIELDS "job_id, " \
"job_status, " \
Expand Down
3 changes: 3 additions & 0 deletions mxq_job.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#include <stdint.h>
#include <mysql.h>

#include <sys/time.h>
#include <sys/resource.h>

#include "mxq_group.h"

struct mxq_job {
Expand Down
3 changes: 3 additions & 0 deletions mxq_job_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#include "mxq_util.h"
#include "mxq_mysql.h"

#include "mxq_group.h"
#include "mxq_job.h"


struct result {
struct mxq_job job;
Expand Down
8 changes: 0 additions & 8 deletions mxq_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,6 @@ void *realloc_forever(void *ptr, size_t size)
} while (1);
}

void mxq_free_job(struct mxq_job_full *job)
{
if (!job)
return;

free(job);
}

char **strvec_new(void)
{
char **strvec;
Expand Down
4 changes: 0 additions & 4 deletions mxq_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@
#include <string.h>
#include <mysql.h>

#include "mxq.h"

char *mxq_hostname(void);

void mxq_free_job(struct mxq_job_full *job);

char **stringtostringvec(int argc, char *s);
char *stringvectostring(int argc, char *argv[]);
int chrcnt(char *s, char c);
Expand Down
1 change: 0 additions & 1 deletion mxqd.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "mx_util.h"
#include "mx_log.h"

#include "mxq.h"
#include "mxq_group.h"
#include "mxq_job.h"
#include "mxq_mysql.h"
Expand Down
2 changes: 2 additions & 0 deletions mxqdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "mxq_mysql.h"
#include "mx_getopt.h"

#include "mxq_group.h"

#ifndef MXQ_VERSION
#define MXQ_VERSION "0.00"
#endif
Expand Down
3 changes: 3 additions & 0 deletions mxqkill.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#include "mxq_mysql.h"
#include "mx_getopt.h"

#include "mxq_group.h"
#include "mxq_job.h"

#ifndef MXQ_VERSION
#define MXQ_VERSION "0.00"
#endif
Expand Down
38 changes: 30 additions & 8 deletions mxqsub.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,17 @@

#include <inttypes.h>

#include <sys/time.h>
#include <sys/resource.h>

#include <string.h>

#include "mxq_util.h"

#include "mxq_group.h"
#include "mxq_job.h"

#include "mx_log.h"
#include "mx_util.h"
#include "mx_getopt.h"
#include "mx_mysql.h"
Expand All @@ -45,8 +54,18 @@
#define MXQ_VERSIONDATE "2015"
#endif

#define MYSQL_DEFAULT_FILE MXQ_MYSQL_DEFAULT_FILE
#define MYSQL_DEFAULT_GROUP "mxqsub"
#ifndef MXQ_MYSQL_DEFAULT_FILE
# define MXQ_MYSQL_DEFAULT_FILE NULL
# define MXQ_MYSQL_DEFAULT_FILE_STR "\"MySQL defaults\""
#else
# define MXQ_MYSQL_DEFAULT_FILE_STR MXQ_MYSQL_DEFAULT_FILE
#endif

#ifndef MXQ_MYSQL_DEFAULT_GROUP
# define MXQ_MYSQL_DEFAULT_GROUP program_invocation_short_name
#endif
#define MXQ_MYSQL_DEFAULT_GROUP_STR MXQ_MYSQL_DEFAULT_GROUP


static void print_version(void)
{
Expand All @@ -63,7 +82,7 @@ static void print_usage(void)
printf(
"\n"
"Usage:\n"
" mxqsub [mxqsub-options] <command> [command options and arguments ..]\n"
" %s [mxqsub-options] <command> [command options and arguments ..]\n"
"\n"
"Synopsis:\n"
" queue a job to be executed on a cluster node.\n"
Expand Down Expand Up @@ -106,13 +125,16 @@ static void print_usage(void)
"\n"
"Change how to connect to the mysql server:\n"
"\n"
" -M | --mysql-default-file [mysql-file] (default: " MYSQL_DEFAULT_FILE ")\n"
" -S | --mysql-default-group [mysql-group] (default: " MYSQL_DEFAULT_GROUP ")\n"
" -M | --mysql-default-file [mysql-file] (default: %s)\n"
" -S | --mysql-default-group [mysql-group] (default: %s)\n"
"\n"
"Environment:\n"
" MXQ_MYSQL_DEFAULT_FILE change default for [mysql-file]\n"
" MXQ_MYSQL_DEFAULT_GROUP change default for [mysql-group]\n"
"\n"
"\n",
program_invocation_short_name,
MXQ_MYSQL_DEFAULT_FILE_STR,
MXQ_MYSQL_DEFAULT_GROUP_STR
);
}

Expand Down Expand Up @@ -472,11 +494,11 @@ int main(int argc, char *argv[])

arg_mysql_default_group = getenv("MXQ_MYSQL_DEFAULT_GROUP");
if (!arg_mysql_default_group)
arg_mysql_default_group = MYSQL_DEFAULT_GROUP;
arg_mysql_default_group = MXQ_MYSQL_DEFAULT_GROUP;

arg_mysql_default_file = getenv("MXQ_MYSQL_DEFAULT_FILE");
if (!arg_mysql_default_file)
arg_mysql_default_file = MYSQL_DEFAULT_FILE;
arg_mysql_default_file = MXQ_MYSQL_DEFAULT_FILE;

/******************************************************************/

Expand Down

0 comments on commit 129852c

Please sign in to comment.