Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bug 1366 - simplified moxi cmd-line

./moxi http://127.0.0.1:8080/pools/default/bucketsStreamingConfig/default

and, all those -z and -Z cmd-line parameter overrides are still there.

Also, updated the usage string, and updated the default listen ports
to be more membase friendly.  The default listen ports now have
define's for...

MOXI_DEFAULT_LISTEN_PORT
MEMCACHED_DEFAULT_LISTEN_PORT

Change-Id: I4c3d2ce7ab86562b0d868891baa547ea3955a607
Reviewed-on: http://review.northscale.com/976
Reviewed-by: Dustin Sallings <dustin@spy.net>
Tested-by: Dustin Sallings <dustin@spy.net>
  • Loading branch information...
commit 91951d5d951334d02fb793237f26d00ad335a63d 1 parent c6f4989
@steveyen steveyen authored dustin committed
Showing with 36 additions and 9 deletions.
  1. +13 −1 agent_config.c
  2. +6 −2 cproxy_config.c
  3. +7 −1 mcs.h
  4. +10 −5 memcached.c
View
14 agent_config.c
@@ -80,6 +80,14 @@ static void init_extensions(void)
* Only the apikey is needed, so it can also look like...
*
* jidname@jhostname%jpassword
+ *
+ * Or...
+ *
+ * http://host:port/default/pools/bucketsStreamingConfig/default
+ * url=http://host:port/default/pools/bucketsStreamingConfig/default
+ * auth=,url=http://host:port/default/pools/bucketsStreamingConfig/default
+ * auth=USER%PSWD,url=http://host:port/default/pools/bucketsStreamingConfig/default
+ * auth=Administrator%password,url=http://host:port/default/pools/bucketsStreamingConfig/default
*/
int cproxy_init_agent(char *cfg_str,
proxy_behavior behavior,
@@ -106,7 +114,11 @@ int cproxy_init_agent(char *cfg_str,
} else {
buff = calloc(cfg_len + 50, sizeof(char));
if (buff != NULL) {
- snprintf(buff, cfg_len + 50, "apikey=%s", cfg_str);
+ if (strncmp(cfg_str, "http://", 7) == 0) {
+ snprintf(buff, cfg_len + 50, "url=%s", cfg_str);
+ } else {
+ snprintf(buff, cfg_len + 50, "apikey=%s", cfg_str);
+ }
}
buff = trimstr(buff);
}
View
8 cproxy_config.c
@@ -64,7 +64,7 @@ proxy_behavior behavior_default_g = {
.bucket = {0},
.usr = {0},
.pwd = {0},
- .port_listen = 0
+ .port_listen = MOXI_DEFAULT_LISTEN_PORT
};
/** Length of key that may be zero or space terminated.
@@ -289,7 +289,11 @@ int cproxy_init(char *cfg_str,
msec_clockevent_base = main_base;
msec_clock_handler(0, 0, NULL);
- if (strchr(cfg_str, '@') == NULL) { // Not jid format.
+ // Not jid format and not a URL, so it must be a simple cmd-line
+ // or file-based config.
+ //
+ if (strchr(cfg_str, '@') == NULL &&
+ strstr(cfg_str, "http://") == NULL) {
return cproxy_init_string(cfg_str,
behavior,
nthreads);
View
8 mcs.h
@@ -33,7 +33,13 @@ typedef struct {
mcs_server_st *servers; // Array, size == vbucket_config_get_num_servers(vch);
} mcs_st;
-#else // !MOXI_US_VBUCKET
+#define MOXI_DEFAULT_LISTEN_PORT 11211
+#define MEMCACHED_DEFAULT_LISTEN_PORT 0
+
+#else // !MOXI_USE_VBUCKET
+
+#define MOXI_DEFAULT_LISTEN_PORT 0
+#define MEMCACHED_DEFAULT_LISTEN_PORT 11210
#include <libmemcached/memcached.h>
View
15 memcached.c
@@ -3993,18 +3993,20 @@ static void clock_handler(const int fd, const short which, void *arg) {
static void usage(int argc, char **argv) {
printf(PACKAGE " " VERSION "\n");
printf("\n");
-#ifdef HAVE_CONFLATE_H
- printf(" %s [flags] apikey=<APIKEY>\n", argv[0]);
+#ifdef MOXI_USE_VBUCKET
+ printf(" %s [flags] http://host:port/some/vBucketMapJson\n", argv[0]);
printf(" or\n");
-#endif
+ printf(" %s [flags] -z ./path/to/configFile\n", argv[0]);
+#else
printf(" %s [flags] -z <port=<mc_host:mc_port(,*)>\n\n", argv[0]);
printf(" moxi listens on the given port and forwards to\n"
" downstream memcached servers running at\n"
" mc_host:mc_port. More than one mc_host:mc_port\n"
" can be listed, separated by commas.\n"
" For example, -z 11211=server1:11211,server2:11211\n");
+#endif
printf("\nThe optional [flags] are...\n\n"
- "-p <num> TCP port number to listen on (default: 11211)\n"
+ "-p <num> TCP port number to listen on (default: 11210)\n"
" to have moxi be a memcached server\n"
"-U <num> UDP port number to listen on (default: 11211, 0 is off)\n"
" to have moxi be a memcached server\n"
@@ -4053,6 +4055,8 @@ static void usage(int argc, char **argv) {
printf("-C Disable use of CAS\n");
printf("-b Set the backlog queue limit (default: 1024)\n");
printf("-B Binding protocol - one of ascii, binary, or auto (default)\n");
+ printf("-Z <key=val*> Optional comma-separated key=value behaviors, such as...\n");
+ printf(" port_listen=11211,downstream_max=1,downstream_protocol=binary\n");
return;
}
@@ -4455,7 +4459,7 @@ int main (int argc, char **argv) {
// Default behavior when we're a proxy is to also
// behave as a memcached on port 11210.
//
- settings.port = 11210;
+ settings.port = MEMCACHED_DEFAULT_LISTEN_PORT;
}
if (maxcore != 0) {
@@ -4651,6 +4655,7 @@ int main (int argc, char **argv) {
int i = argc - 1;
while (i > 0) {
if (strncmp(argv[i], "apikey=", 7) == 0 ||
+ strncmp(argv[i], "http://", 7) == 0 ||
strchr(argv[i], '@') != NULL) {
cproxy_init(argv[i], cproxy_behavior,
settings.num_threads,
Please sign in to comment.
Something went wrong with that request. Please try again.