Skip to content

Commit

Permalink
FEATURE: Add ready command
Browse files Browse the repository at this point in the history
  • Loading branch information
namsic committed Nov 1, 2023
1 parent 399c368 commit d7da9e7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions arcus_zk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1833,6 +1833,7 @@ void arcus_zk_get_confs(arcus_zk_confs *confs)
void arcus_zk_get_stats(arcus_zk_stats *stats)
{
stats->zk_connected = (main_zk != NULL && main_zk->zh != NULL) ? true : false;
stats->zk_ready = arcus_conf.znode_created;
#ifdef ENABLE_ZK_RECONFIG
stats->zk_reconfig_needed = zk_reconfig.needed;
stats->zk_reconfig_enabled = zk_reconfig.enabled;
Expand Down
1 change: 1 addition & 0 deletions arcus_zk.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ typedef struct {

typedef struct {
bool zk_connected; // ZooKeeper-memcached connection state
bool zk_ready; // cache-list znode created?
#ifdef ENABLE_ZK_RECONFIG
bool zk_reconfig_needed; // ZK dynamic reconfig is needed?
bool zk_reconfig_enabled; // ZK dynamic reconfig enabled in ZK?
Expand Down
15 changes: 15 additions & 0 deletions memcached.c
Original file line number Diff line number Diff line change
Expand Up @@ -8174,6 +8174,7 @@ static void process_stats_zookeeper(ADD_STAT add_stats, void *c)
APPEND_STAT("zk_timeout", "%u", zk_confs.zk_timeout);
APPEND_STAT("zk_failstop", "%s", zk_confs.zk_failstop ? "on" : "off");
APPEND_STAT("zk_connected", "%s", zk_stats.zk_connected ? "true" : "false");
APPEND_STAT("zk_ready", "%s", zk_stats.zk_ready ? "true" : "false");
#ifdef ENABLE_ZK_RECONFIG
APPEND_STAT("zk_reconfig_needed", "%s", zk_stats.zk_reconfig_needed ? "on" : "off");
if (zk_stats.zk_reconfig_needed) {
Expand Down Expand Up @@ -13240,6 +13241,20 @@ static void process_command_ascii(conn *c, char *command, int cmdlen)
process_lqdetect_command(c, tokens, ntokens);
}
#endif
else if ((ntokens == 2) && (strcmp(tokens[COMMAND_TOKEN].value, "ready") == 0))
{
#ifdef ENABLE_ZK_INTEGRATION
if (!arcus_zk_cfg) {
out_string(c, "READY");
} else {
arcus_zk_stats zk_stats;
arcus_zk_get_stats(&zk_stats);
out_string(c, zk_stats.zk_ready ? "READY" : "NOT_READY");
}
#else
out_string(c, "READY");
#endif
}
else /* no matching command */
{
if (settings.extensions.ascii != NULL) {
Expand Down

0 comments on commit d7da9e7

Please sign in to comment.