Skip to content

Commit ca8faed

Browse files
committed
job-list: add job db
Problem: We would like to store inactive jobs on disk for retrieval at a later time. Solution: Add an sqlite job db to the job-list module. If the job-list module is configured with a database path or if the flux broker is configured with a statedir, store all inactive job data to the db.
1 parent 09243b4 commit ca8faed

File tree

10 files changed

+561
-6
lines changed

10 files changed

+561
-6
lines changed

src/modules/job-list/Makefile.am

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ AM_CPPFLAGS = \
1010
-I$(top_srcdir)/src/include \
1111
-I$(top_builddir)/src/common/libflux \
1212
$(FLUX_SECURITY_CFLAGS) \
13-
$(JANSSON_CFLAGS)
13+
$(JANSSON_CFLAGS) \
14+
$(SQLITE_CFLAGS)
1415

1516
fluxmod_LTLIBRARIES = job-list.la
1617

@@ -21,14 +22,18 @@ job_list_la_SOURCES = \
2122
job_state.c \
2223
job_data.h \
2324
job_data.c \
25+
job_db.h \
26+
job_db.c \
2427
list.h \
2528
list.c \
2629
job_util.h \
2730
job_util.c \
2831
idsync.h \
2932
idsync.c \
3033
stats.h \
31-
stats.c
34+
stats.c \
35+
util.h \
36+
util.c
3237

3338
job_list_la_LDFLAGS = $(fluxmod_ldflags) -module
3439
job_list_la_LIBADD = \
@@ -38,4 +43,5 @@ job_list_la_LIBADD = \
3843
$(top_builddir)/src/common/libflux-optparse.la \
3944
$(top_builddir)/src/common/librlist/librlist.la \
4045
$(JANSSON_LIBS) \
41-
$(HWLOC_LIBS)
46+
$(HWLOC_LIBS) \
47+
$(SQLITE_LIBS)

src/modules/job-list/job-list.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,16 @@ static void list_ctx_destroy (struct list_ctx *ctx)
165165
flux_msg_handler_delvec (ctx->handlers);
166166
if (ctx->jsctx)
167167
job_state_destroy (ctx->jsctx);
168+
if (ctx->dbctx)
169+
job_db_ctx_destroy (ctx->dbctx);
168170
if (ctx->idsync_lookups)
169171
idsync_cleanup (ctx);
170172
free (ctx);
171173
errno = saved_errno;
172174
}
173175
}
174176

175-
static struct list_ctx *list_ctx_create (flux_t *h)
177+
static struct list_ctx *list_ctx_create (flux_t *h, int argc, char **argv)
176178
{
177179
struct list_ctx *ctx = calloc (1, sizeof (*ctx));
178180
if (!ctx)
@@ -184,6 +186,10 @@ static struct list_ctx *list_ctx_create (flux_t *h)
184186
goto error;
185187
if (!(ctx->jsctx = job_state_create (ctx)))
186188
goto error;
189+
if (!(ctx->dbctx = job_db_setup (h, argc, argv))) {
190+
if (errno != ENOTBLK)
191+
goto error;
192+
}
187193
if (idsync_setup (ctx) < 0)
188194
goto error;
189195
return ctx;
@@ -197,7 +203,7 @@ int mod_main (flux_t *h, int argc, char **argv)
197203
struct list_ctx *ctx;
198204
int rc = -1;
199205

200-
if (!(ctx = list_ctx_create (h))) {
206+
if (!(ctx = list_ctx_create (h, argc, argv))) {
201207
flux_log_error (h, "initialization error");
202208
goto done;
203209
}

src/modules/job-list/job-list.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
#include "src/common/libczmqcontainers/czmq_containers.h"
1717

1818
#include "job_state.h"
19+
#include "job_db.h"
1920

2021
struct list_ctx {
2122
flux_t *h;
2223
flux_msg_handler_t **handlers;
2324
struct job_state_ctx *jsctx;
25+
struct job_db_ctx *dbctx;
2426
zlistx_t *idsync_lookups;
2527
zhashx_t *idsync_waits;
2628
};

0 commit comments

Comments
 (0)