Browse Source

ckdb - add a share status console report command shsta

master
kanoi 10 years ago
parent
commit
19bce29d1c
  1. 9
      src/ckdb.c
  2. 3
      src/ckdb.h
  3. 19
      src/ckdb_cmd.c

9
src/ckdb.c

@ -3674,10 +3674,10 @@ static void *socketer(__maybe_unused void *arg)
case CMD_HEARTBEAT: case CMD_HEARTBEAT:
// First message from the pool // First message from the pool
if (want_first) { if (want_first) {
want_first = false;
ck_wlock(&fpm_lock); ck_wlock(&fpm_lock);
first_pool_message = strdup(buf); first_pool_message = strdup(buf);
ck_wunlock(&fpm_lock); ck_wunlock(&fpm_lock);
want_first = false;
} }
case CMD_CHKPASS: case CMD_CHKPASS:
case CMD_ADDUSER: case CMD_ADDUSER:
@ -3693,6 +3693,7 @@ static void *socketer(__maybe_unused void *arg)
case CMD_NEWID: case CMD_NEWID:
case CMD_STATS: case CMD_STATS:
case CMD_USERSTATUS: case CMD_USERSTATUS:
case CMD_SHSTA:
ans = ckdb_cmds[which_cmds].func(NULL, cmd, id, &now, ans = ckdb_cmds[which_cmds].func(NULL, cmd, id, &now,
by_default, by_default,
(char *)__func__, (char *)__func__,
@ -3816,10 +3817,10 @@ static void *socketer(__maybe_unused void *arg)
case CMD_BLOCK: case CMD_BLOCK:
// First message from the pool // First message from the pool
if (want_first) { if (want_first) {
want_first = false;
ck_wlock(&fpm_lock); ck_wlock(&fpm_lock);
first_pool_message = strdup(buf); first_pool_message = strdup(buf);
ck_wunlock(&fpm_lock); ck_wunlock(&fpm_lock);
want_first = false;
} }
snprintf(reply, sizeof(reply), snprintf(reply, sizeof(reply),
@ -3982,7 +3983,8 @@ static bool reload_line(PGconn *conn, char *filename, uint64_t count, char *buf)
case CMD_USERSTATUS: case CMD_USERSTATUS:
case CMD_MARKS: case CMD_MARKS:
case CMD_PSHIFT: case CMD_PSHIFT:
LOGERR("%s() Message line %"PRIu64" '%s' - invalid - ignored", case CMD_SHSTA:
LOGERR("%s() INVALID message line %"PRIu64" '%s' - ignored",
__func__, count, cmd); __func__, count, cmd);
break; break;
case CMD_AUTH: case CMD_AUTH:
@ -4348,6 +4350,7 @@ static void *listener(void *arg)
K_RUNLOCK(workqueue_store); K_RUNLOCK(workqueue_store);
LOGWARNING("reload shares OoO %s", ooo_status(ooo_buf, sizeof(ooo_buf))); LOGWARNING("reload shares OoO %s", ooo_status(ooo_buf, sizeof(ooo_buf)));
sequence_report(true);
LOGWARNING("%s(): ckdb ready, queue %d", __func__, wqcount); LOGWARNING("%s(): ckdb ready, queue %d", __func__, wqcount);

3
src/ckdb.h

@ -55,7 +55,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "1.0.0" #define DB_VERSION "1.0.0"
#define CKDB_VERSION DB_VERSION"-1.074" #define CKDB_VERSION DB_VERSION"-1.075"
#define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__ #define WHERE_FFL_HERE __FILE__, __func__, __LINE__
@ -402,6 +402,7 @@ enum cmd_values {
CMD_USERSTATUS, CMD_USERSTATUS,
CMD_MARKS, CMD_MARKS,
CMD_PSHIFT, CMD_PSHIFT,
CMD_SHSTA,
CMD_END CMD_END
}; };

19
src/ckdb_cmd.c

@ -5844,6 +5844,24 @@ static char *cmd_pshift(__maybe_unused PGconn *conn, char *cmd, char *id,
return(buf); return(buf);
} }
/* Show a share status report on the console
* Currently: sequence status and OoO info */
static char *cmd_shsta(__maybe_unused PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *notcd, __maybe_unused K_TREE *trf_root)
{
char ooo_buf[256];
char buf[256];
LOGWARNING("OoO %s", ooo_status(ooo_buf, sizeof(ooo_buf)));
sequence_report(true);
snprintf(buf, sizeof(buf), "ok.%s", cmd);
LOGDEBUG("%s.%s", id, buf);
return strdup(buf);
}
// TODO: limit access by having seperate sockets for each // TODO: limit access by having seperate sockets for each
#define ACCESS_POOL "p" #define ACCESS_POOL "p"
#define ACCESS_SYSTEM "s" #define ACCESS_SYSTEM "s"
@ -5955,5 +5973,6 @@ struct CMDS ckdb_cmds[] = {
{ CMD_USERSTATUS,"userstatus", false, false, cmd_userstatus, SEQ_NONE, ACCESS_SYSTEM ACCESS_WEB }, { CMD_USERSTATUS,"userstatus", false, false, cmd_userstatus, SEQ_NONE, ACCESS_SYSTEM ACCESS_WEB },
{ CMD_MARKS, "marks", false, false, cmd_marks, SEQ_NONE, ACCESS_SYSTEM }, { CMD_MARKS, "marks", false, false, cmd_marks, SEQ_NONE, ACCESS_SYSTEM },
{ CMD_PSHIFT, "pshift", false, false, cmd_pshift, SEQ_NONE, ACCESS_SYSTEM ACCESS_WEB }, { CMD_PSHIFT, "pshift", false, false, cmd_pshift, SEQ_NONE, ACCESS_SYSTEM ACCESS_WEB },
{ CMD_SHSTA, "shsta", true, false, cmd_shsta, SEQ_NONE, ACCESS_SYSTEM },
{ CMD_END, NULL, false, false, NULL, SEQ_NONE, NULL } { CMD_END, NULL, false, false, NULL, SEQ_NONE, NULL }
}; };

Loading…
Cancel
Save