Skip to content

Commit 39bf25d

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 e5b53a9 commit 39bf25d

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
@@ -11,7 +11,8 @@ AM_CPPFLAGS = \
1111
-I$(top_srcdir)/src/common/libccan \
1212
-I$(top_builddir)/src/common/libflux \
1313
$(FLUX_SECURITY_CFLAGS) \
14-
$(JANSSON_CFLAGS)
14+
$(JANSSON_CFLAGS) \
15+
$(SQLITE_CFLAGS)
1516

1617
fluxmod_LTLIBRARIES = job-list.la
1718

@@ -22,14 +23,18 @@ job_list_la_SOURCES = \
2223
job_state.c \
2324
job_data.h \
2425
job_data.c \
26+
job_db.h \
27+
job_db.c \
2528
list.h \
2629
list.c \
2730
job_util.h \
2831
job_util.c \
2932
idsync.h \
3033
idsync.c \
3134
stats.h \
32-
stats.c
35+
stats.c \
36+
util.h \
37+
util.c
3338

3439
job_list_la_LDFLAGS = $(fluxmod_ldflags) -module
3540
job_list_la_LIBADD = \
@@ -39,4 +44,5 @@ job_list_la_LIBADD = \
3944
$(top_builddir)/src/common/libflux-optparse.la \
4045
$(top_builddir)/src/common/librlist/librlist.la \
4146
$(JANSSON_LIBS) \
42-
$(HWLOC_LIBS)
47+
$(HWLOC_LIBS) \
48+
$(SQLITE_LIBS)

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,16 @@ static void list_ctx_destroy (struct list_ctx *ctx)
160160
flux_msg_handler_delvec (ctx->handlers);
161161
if (ctx->jsctx)
162162
job_state_destroy (ctx->jsctx);
163+
if (ctx->dbctx)
164+
job_db_ctx_destroy (ctx->dbctx);
163165
if (ctx->idsync_lookups)
164166
idsync_cleanup (ctx);
165167
free (ctx);
166168
errno = saved_errno;
167169
}
168170
}
169171

170-
static struct list_ctx *list_ctx_create (flux_t *h)
172+
static struct list_ctx *list_ctx_create (flux_t *h, int argc, char **argv)
171173
{
172174
struct list_ctx *ctx = calloc (1, sizeof (*ctx));
173175
if (!ctx)
@@ -179,6 +181,10 @@ static struct list_ctx *list_ctx_create (flux_t *h)
179181
goto error;
180182
if (!(ctx->jsctx = job_state_create (ctx)))
181183
goto error;
184+
if (!(ctx->dbctx = job_db_setup (h, argc, argv))) {
185+
if (errno != ENOTBLK)
186+
goto error;
187+
}
182188
if (idsync_setup (ctx) < 0)
183189
goto error;
184190
return ctx;
@@ -192,7 +198,7 @@ int mod_main (flux_t *h, int argc, char **argv)
192198
struct list_ctx *ctx;
193199
int rc = -1;
194200

195-
if (!(ctx = list_ctx_create (h))) {
201+
if (!(ctx = list_ctx_create (h, argc, argv))) {
196202
flux_log_error (h, "initialization error");
197203
goto done;
198204
}

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)