diff --git a/arcus_zk.c b/arcus_zk.c index 584d1cfbc..d4218a51c 100644 --- a/arcus_zk.c +++ b/arcus_zk.c @@ -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; diff --git a/arcus_zk.h b/arcus_zk.h index d1038e3c9..ce9ee6e90 100644 --- a/arcus_zk.h +++ b/arcus_zk.h @@ -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? diff --git a/memcached.c b/memcached.c index 2493d25fc..72f970b0e 100644 --- a/memcached.c +++ b/memcached.c @@ -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) { @@ -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) {