Skip to content

Commit

Permalink
Remove managed instance code. Extra options confuse newbies.
Browse files Browse the repository at this point in the history
We should come back and do this right, probably built on top of the binary protocol and SE stuff.
  • Loading branch information
dormando authored and dustin committed Dec 22, 2008
1 parent 810c13b commit 04319dd
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 154 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
@@ -1,3 +1,9 @@
2008-09-06

* Remove managed instance code. Incomplete/etc. (Dormando)

2008-07-29 [Version 1.2.6 released]

2008-07-24 [Version 1.2.6-rc1 released]

* Add support for newer automake (Facebook)
Expand Down
3 changes: 0 additions & 3 deletions doc/memcached.1
Expand Up @@ -61,9 +61,6 @@ Additions will not be possible until adequate space is freed up.
.B \-r
Raise the core file size limit to the maximum allowable.
.TP
.B \-b
Run a managed instanced (mnemonic: buckets)\n".
.TP
.B \-f <factor>
Use <factor> as the multiplier for computing the sizes of memory chunks that
items are stored in. A lower value may result in less wasted memory depending
Expand Down
134 changes: 1 addition & 133 deletions memcached.c
Expand Up @@ -112,8 +112,6 @@ static struct event_base *main_base;
#define TRANSMIT_SOFT_ERROR 2
#define TRANSMIT_HARD_ERROR 3

static int *buckets = 0; /* bucket->generation array for a managed instance */

#define REALTIME_MAXDELTA 60*60*24*30
/*
* given time value that's either unix time or delta from current unix time, return
Expand Down Expand Up @@ -174,7 +172,6 @@ static void settings_init(void) {
settings.oldest_live = 0;
settings.evict_to_free = 1; /* push old items out of cache when memory runs out */
settings.socketpath = NULL; /* by default, not using a unix socket */
settings.managed = false;
settings.factor = 1.25;
settings.chunk_size = 48; /* space for a modest key and value */
#ifdef USE_THREADS
Expand Down Expand Up @@ -366,8 +363,6 @@ conn *conn_new(const int sfd, const int init_state, const int event_flags,
c->write_and_go = conn_read;
c->write_and_free = 0;
c->item = 0;
c->bucket = -1;
c->gen = 0;

c->noreply = false;

Expand Down Expand Up @@ -1240,19 +1235,6 @@ static inline void process_get_command(conn *c, token_t *tokens, size_t ntokens,
int stats_get_misses = 0;
assert(c != NULL);

if (settings.managed) {
int bucket = c->bucket;
if (bucket == -1) {
out_string(c, "CLIENT_ERROR no BG data in managed mode");
return;
}
c->bucket = -1;
if (buckets[bucket] != c->gen) {
out_string(c, "ERROR_NOT_OWNER");
return;
}
}

do {
while(key_token->length != 0) {

Expand Down Expand Up @@ -1454,19 +1436,6 @@ static void process_update_command(conn *c, token_t *tokens, const size_t ntoken
stats_prefix_record_set(key);
}

if (settings.managed) {
int bucket = c->bucket;
if (bucket == -1) {
out_string(c, "CLIENT_ERROR no BG data in managed mode");
return;
}
c->bucket = -1;
if (buckets[bucket] != c->gen) {
out_string(c, "ERROR_NOT_OWNER");
return;
}
}

it = item_alloc(key, nkey, flags, realtime(exptime), vlen+2);

if (it == 0) {
Expand Down Expand Up @@ -1519,19 +1488,6 @@ static void process_arithmetic_command(conn *c, token_t *tokens, const size_t nt
key = tokens[KEY_TOKEN].value;
nkey = tokens[KEY_TOKEN].length;

if (settings.managed) {
int bucket = c->bucket;
if (bucket == -1) {
out_string(c, "CLIENT_ERROR no BG data in managed mode");
return;
}
c->bucket = -1;
if (buckets[bucket] != c->gen) {
out_string(c, "ERROR_NOT_OWNER");
return;
}
}

delta = strtoll(tokens[2].value, NULL, 10);

if(errno == ERANGE) {
Expand Down Expand Up @@ -1612,19 +1568,6 @@ static void process_delete_command(conn *c, token_t *tokens, const size_t ntoken

set_noreply_maybe(c, tokens, ntokens);

if (settings.managed) {
int bucket = c->bucket;
if (bucket == -1) {
out_string(c, "CLIENT_ERROR no BG data in managed mode");
return;
}
c->bucket = -1;
if (buckets[bucket] != c->gen) {
out_string(c, "ERROR_NOT_OWNER");
return;
}
}

key = tokens[KEY_TOKEN].value;
nkey = tokens[KEY_TOKEN].length;

Expand Down Expand Up @@ -1767,67 +1710,6 @@ static void process_command(conn *c, char *command) {

process_delete_command(c, tokens, ntokens);

} else if (ntokens == 3 && strcmp(tokens[COMMAND_TOKEN].value, "own") == 0) {
unsigned int bucket, gen;
if (!settings.managed) {
out_string(c, "CLIENT_ERROR not a managed instance");
return;
}

if (sscanf(tokens[1].value, "%u:%u", &bucket,&gen) == 2) {
if ((bucket < 0) || (bucket >= MAX_BUCKETS)) {
out_string(c, "CLIENT_ERROR bucket number out of range");
return;
}
buckets[bucket] = gen;
out_string(c, "OWNED");
return;
} else {
out_string(c, "CLIENT_ERROR bad format");
return;
}

} else if (ntokens == 3 && (strcmp(tokens[COMMAND_TOKEN].value, "disown")) == 0) {

int bucket;
if (!settings.managed) {
out_string(c, "CLIENT_ERROR not a managed instance");
return;
}
if (sscanf(tokens[1].value, "%u", &bucket) == 1) {
if ((bucket < 0) || (bucket >= MAX_BUCKETS)) {
out_string(c, "CLIENT_ERROR bucket number out of range");
return;
}
buckets[bucket] = 0;
out_string(c, "DISOWNED");
return;
} else {
out_string(c, "CLIENT_ERROR bad format");
return;
}

} else if (ntokens == 3 && (strcmp(tokens[COMMAND_TOKEN].value, "bg")) == 0) {
int bucket, gen;
if (!settings.managed) {
out_string(c, "CLIENT_ERROR not a managed instance");
return;
}
if (sscanf(tokens[1].value, "%u:%u", &bucket, &gen) == 2) {
/* we never write anything back, even if input's wrong */
if ((bucket < 0) || (bucket >= MAX_BUCKETS) || (gen <= 0)) {
/* do nothing, bad input */
} else {
c->bucket = bucket;
c->gen = gen;
}
conn_set_state(c, conn_read);
return;
} else {
out_string(c, "CLIENT_ERROR bad format");
return;
}

} else if (ntokens >= 2 && (strcmp(tokens[COMMAND_TOKEN].value, "stats") == 0)) {

process_stat(c, tokens, ntokens);
Expand Down Expand Up @@ -2755,7 +2637,6 @@ static void usage(void) {
"-vv very verbose (also print client commands/reponses)\n"
"-h print this help and exit\n"
"-i print memcached and libevent license\n"
"-b run a managed instanced (mnemonic: buckets)\n"
"-P <file> save PID in <file>, only used with -d option\n"
"-f <factor> chunk size growth factor, default 1.25\n"
"-n <bytes> minimum space allocated for key+value+flags, default 48\n"
Expand Down Expand Up @@ -2952,7 +2833,7 @@ int main (int argc, char **argv) {
setbuf(stderr, NULL);

/* process arguments */
while ((c = getopt(argc, argv, "a:bp:s:U:m:Mc:khirvdl:u:P:f:s:n:t:D:LR:")) != -1) {
while ((c = getopt(argc, argv, "a:p:s:U:m:Mc:khirvdl:u:P:f:s:n:t:D:LR:")) != -1) {
switch (c) {
case 'a':
/* access for unix domain socket, as octal mask (like chmod)*/
Expand All @@ -2962,9 +2843,6 @@ int main (int argc, char **argv) {
case 'U':
settings.udpport = atoi(optarg);
break;
case 'b':
settings.managed = true;
break;
case 'p':
settings.port = atoi(optarg);
break;
Expand Down Expand Up @@ -3154,16 +3032,6 @@ int main (int argc, char **argv) {
suffix_init();
slabs_init(settings.maxbytes, settings.factor, preallocate);

/* managed instance? alloc and zero a bucket array */
if (settings.managed) {
buckets = malloc(sizeof(int) * MAX_BUCKETS);
if (buckets == 0) {
fprintf(stderr, "failed to allocate the bucket array");
exit(EXIT_FAILURE);
}
memset(buckets, 0, sizeof(int) * MAX_BUCKETS);
}

/*
* ignore SIGPIPE signals; we can use errno==EPIPE if we
* need that information
Expand Down
7 changes: 0 additions & 7 deletions memcached.h
Expand Up @@ -87,7 +87,6 @@ struct settings {
char *inter;
int verbose;
rel_time_t oldest_live; /* ignore existing items older than this */
bool managed; /* if 1, a tracker manages virtual buckets */
int evict_to_free;
char *socketpath; /* path to unix socket if using local socket */
int access; /* access mask (a la chmod) for unix domain socket */
Expand Down Expand Up @@ -219,16 +218,10 @@ struct conn {
int hdrsize; /* number of headers' worth of space is allocated */

int binary; /* are we in binary mode */
int bucket; /* bucket number for the next command, if running as
a managed instance. -1 (_not_ 0) means invalid. */
int gen; /* generation requested for the bucket */
bool noreply; /* True if the reply should not be sent. */
conn *next; /* Used for generating a list of conn structures */
};

/* number of virtual buckets for a managed instance */
#define MAX_BUCKETS 32768

/* current time of day (updated periodically) */
extern volatile rel_time_t current_time;

Expand Down
11 changes: 0 additions & 11 deletions t/managed-buckets.t

This file was deleted.

0 comments on commit 04319dd

Please sign in to comment.