Browse Source

ckdb - allow turning marks generation on/off using the marks command actions genon/genoff

master
kanoi 9 years ago
parent
commit
7226734ab4
  1. 3
      src/ckdb.c
  2. 4
      src/ckdb.h
  3. 46
      src/ckdb_cmd.c

3
src/ckdb.c

@ -125,8 +125,7 @@ static char *status_chars = "|/-\\";
static char *restorefrom; static char *restorefrom;
// Only accessed in here bool markersummary_auto;
static bool markersummary_auto;
int switch_state = SWITCH_STATE_ALL; int switch_state = SWITCH_STATE_ALL;

4
src/ckdb.h

@ -55,7 +55,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "1.0.3" #define DB_VERSION "1.0.3"
#define CKDB_VERSION DB_VERSION"-1.330" #define CKDB_VERSION DB_VERSION"-1.331"
#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__
@ -95,6 +95,8 @@ extern int switch_state;
#define SWITCH_STATE_AUTHWORKERS 1 #define SWITCH_STATE_AUTHWORKERS 1
#define SWITCH_STATE_ALL 666666 #define SWITCH_STATE_ALL 666666
extern bool markersummary_auto;
#define BLANK " " #define BLANK " "
extern char *EMPTY; extern char *EMPTY;

46
src/ckdb_cmd.c

@ -5738,7 +5738,7 @@ static char *cmd_marks(PGconn *conn, char *cmd, char *id,
action = transfer_data(i_action); action = transfer_data(i_action);
if (strcasecmp(action, "add") == 0) { if (strcasecmp(action, "add") == 0) {
/* Add a mark, -m will automatically do this /* Add a mark, -m/genon will automatically do this
* Require marktype * Require marktype
* Require workinfoid for all but 'b' * Require workinfoid for all but 'b'
* If marktype is 'b' or 'p' then require height/block (number) * If marktype is 'b' or 'p' then require height/block (number)
@ -5944,7 +5944,7 @@ static char *cmd_marks(PGconn *conn, char *cmd, char *id,
trf_root); trf_root);
} }
} else if (strcasecmp(action, "generate") == 0) { } else if (strcasecmp(action, "generate") == 0) {
/* Generate workmarkers, -m will automatically do this /* Generate workmarkers, -m/genon will automatically do this
* No parameters */ * No parameters */
tmp[0] = '\0'; tmp[0] = '\0';
ok = workmarkers_generate(conn, tmp, sizeof(tmp), ok = workmarkers_generate(conn, tmp, sizeof(tmp),
@ -6005,7 +6005,7 @@ static char *cmd_marks(PGconn *conn, char *cmd, char *id,
} else if (strcasecmp(action, "sum") == 0) { } else if (strcasecmp(action, "sum") == 0) {
/* For the last available workmarker, /* For the last available workmarker,
* summarise it's sharesummaries into markersummaries * summarise it's sharesummaries into markersummaries
* -m will automatically do this * -m/genon will automatically do this
* No parameters */ * No parameters */
ok = make_markersummaries(true, by, code, inet, cd, trf_root); ok = make_markersummaries(true, by, code, inet, cd, trf_root);
if (!ok) { if (!ok) {
@ -6087,11 +6087,21 @@ static char *cmd_marks(PGconn *conn, char *cmd, char *id,
* markersummaries that were deleted * markersummaries that were deleted
* *
* WARNING ... if you do this after the workmarker has been * WARNING ... if you do this after the workmarker has been
* processed, there will no longer be any matching shares, * processed, after switching it to ready, there will no
* sharesummaries or workmarkers in ram, so you'd need to * longer be any matching shares or sharesummaries in ram
* restart ckdb to regenerate the markersummaries * to regenerate the markersummaries, so you'd need to restart
* ckdb to reload the shares to regenerate the markersummaries
* HOWEVER, ckdb wont reload the shares if there is a later * HOWEVER, ckdb wont reload the shares if there is a later
* workmarker that is processed * workmarker that is already processed
*
* To reprocess an already processed workmarker, you'd have
* to firstly turn off auto processing with genoff, then
* change the required workmarker, and all after it, to
* ready, then cancel them all, then finally restart ckdb
* which will reload all the necessary shares and regenerate
* the markersummaries
* Of course if you don't have ALL the necessary shares in
* the CCLs then you'd lose data doing this
* *
* SS_to_MS will complain if any markersummaries already exist * SS_to_MS will complain if any markersummaries already exist
* when processing a workmarker * when processing a workmarker
@ -6137,6 +6147,28 @@ static char *cmd_marks(PGconn *conn, char *cmd, char *id,
LOGERR("%s.%s", id, reply); LOGERR("%s.%s", id, reply);
return strdup(reply); return strdup(reply);
} }
} else if (strcasecmp(action, "genon") == 0) {
/* Turn on auto marker generation and processing
* and report the before/after status
* No parameters */
bool old = markersummary_auto;
markersummary_auto = true;
snprintf(msg, sizeof(msg), "mark generation state was %s,"
" now %s",
old ? "On" : "Off",
markersummary_auto ? "On" : "Off");
ok = true;
} else if (strcasecmp(action, "genoff") == 0) {
/* Turn off auto marker generation and processing
* and report the before/after status
* No parameters */
bool old = markersummary_auto;
markersummary_auto = false;
snprintf(msg, sizeof(msg), "mark generation state was %s,"
" now %s",
old ? "On" : "Off",
markersummary_auto ? "On" : "Off");
ok = true;
} else { } else {
snprintf(reply, siz, "unknown action '%s'", action); snprintf(reply, siz, "unknown action '%s'", action);
LOGERR("%s.%s", id, reply); LOGERR("%s.%s", id, reply);

Loading…
Cancel
Save