Skip to content

Commit

Permalink
further yao-requested cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
slyphon committed Jul 4, 2018
1 parent e92977c commit 093c713
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 164 deletions.
133 changes: 4 additions & 129 deletions src/server/cdb/data/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@
#define CMD_ERR_MSG "command not supported"
#define OTHER_ERR_MSG "unknown server error"


typedef enum put_rstatus {
PUT_OK,
PUT_PARTIAL,
PUT_ERROR,
} put_rstatus_t;

static bool process_init = false;
static process_metrics_st *process_metrics = NULL;
static bool allow_flush = ALLOW_FLUSH;
Expand Down Expand Up @@ -161,93 +154,12 @@ _process_gets(struct response *rsp, struct request *req)
}

static void
_process_delete(struct response *rsp, struct request *req)
{
INCR(process_metrics, delete);
rsp->type = RSP_CLIENT_ERROR;
rsp->vstr = str2bstr(CMD_ERR_MSG);
log_verb("delete req %p processed, rsp type %d", req, rsp->type);
}

/*
* for set/add/replace/cas, we have to recover key from the reserved item,
* because the keys field in the request are only valid for the first segment
* of the request buffer. Once we move to later segments, the areas pointed to
* by these pointers will be overwritten.
*/
static void
_process_set(struct response *rsp, struct request *req)
{
INCR(process_metrics, set);
INCR(process_metrics, set_ex);
rsp->type = RSP_CLIENT_ERROR;
rsp->vstr = str2bstr(CMD_ERR_MSG);
log_verb("set req %p processed, rsp type %d", req, rsp->type);
}

static void
_process_add(struct response *rsp, struct request *req)
{
INCR(process_metrics, add_ex);
rsp->type = RSP_CLIENT_ERROR;
rsp->vstr = str2bstr(CMD_ERR_MSG);
log_verb("add req %p processed, rsp type %d", req, rsp->type);
}

static void
_process_replace(struct response *rsp, struct request *req)
{
INCR(process_metrics, replace_ex);
rsp->type = RSP_CLIENT_ERROR;
rsp->vstr = str2bstr(CMD_ERR_MSG);
log_verb("replace req %p processed, rsp type %d", req, rsp->type);
}

static void
_process_cas(struct response *rsp, struct request *req)
{
INCR(process_metrics, cas_ex);
rsp->type = RSP_CLIENT_ERROR;
rsp->vstr = str2bstr(CMD_ERR_MSG);
log_verb("cas req %p processed, rsp type %d", req, rsp->type);
}

static void
_process_incr(struct response *rsp, struct request *req)
{
INCR(process_metrics, incr);
INCR(process_metrics, incr_ex);
rsp->type = RSP_CLIENT_ERROR;
rsp->vstr = str2bstr(CMD_ERR_MSG);
log_verb("incr req %p processed, rsp type %d", req, rsp->type);
}

static void
_process_decr(struct response *rsp, struct request *req)
_process_invalid(struct response *rsp, struct request *req)
{
INCR(process_metrics, decr);
INCR(process_metrics, decr_ex);
INCR(process_metrics, invalid);
rsp->type = RSP_CLIENT_ERROR;
rsp->vstr = str2bstr(CMD_ERR_MSG);
log_verb("decr req %p processed, rsp type %d", req, rsp->type);
}

static void
_process_append(struct response *rsp, struct request *req)
{
INCR(process_metrics, append_ex);
rsp->type = RSP_CLIENT_ERROR;
rsp->vstr = str2bstr(CMD_ERR_MSG);
log_verb("append req %p processed, rsp type %d", req, rsp->type);
}

static void
_process_prepend(struct response *rsp, struct request *req)
{
INCR(process_metrics, prepend_ex);
rsp->type = RSP_CLIENT_ERROR;
rsp->vstr = str2bstr(CMD_ERR_MSG);
log_verb("prepend req %p processed, rsp type %d", req, rsp->type);
log_verb("req %p processed, rsp type %d", req, rsp->type);
}

static void
Expand All @@ -274,49 +186,12 @@ process_request(struct response *rsp, struct request *req)
_process_gets(rsp, req);
break;

case REQ_DELETE:
_process_delete(rsp, req);
break;

case REQ_SET:
_process_set(rsp, req);
break;

case REQ_ADD:
_process_add(rsp, req);
break;

case REQ_REPLACE:
_process_replace(rsp, req);
break;

case REQ_CAS:
_process_cas(rsp, req);
break;

case REQ_INCR:
_process_incr(rsp, req);
break;

case REQ_DECR:
_process_decr(rsp, req);
break;

case REQ_APPEND:
_process_append(rsp, req);
break;

case REQ_PREPEND:
_process_prepend(rsp, req);
break;

case REQ_FLUSH:
_process_flush(rsp, req);
break;

default:
rsp->type = RSP_CLIENT_ERROR;
rsp->vstr = str2bstr(CMD_ERR_MSG);
_process_invalid(rsp, req);
break;
}
}
Expand Down
36 changes: 1 addition & 35 deletions src/server/cdb/data/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,41 +32,7 @@ typedef struct {
ACTION( gets_key_hit, METRIC_COUNTER, "# key hits by gets" )\
ACTION( gets_key_miss, METRIC_COUNTER, "# key misses by gets" )\
ACTION( gets_ex, METRIC_COUNTER, "# gets errors" )\
ACTION( delete, METRIC_COUNTER, "# delete requests" )\
ACTION( delete_deleted, METRIC_COUNTER, "# delete successes" )\
ACTION( delete_notfound, METRIC_COUNTER, "# delete not_founds" )\
ACTION( set, METRIC_COUNTER, "# set requests" )\
ACTION( set_stored, METRIC_COUNTER, "# set successes" )\
ACTION( set_ex, METRIC_COUNTER, "# set errors" )\
ACTION( add, METRIC_COUNTER, "# add requests" )\
ACTION( add_stored, METRIC_COUNTER, "# add successes" )\
ACTION( add_notstored, METRIC_COUNTER, "# add failures" )\
ACTION( add_ex, METRIC_COUNTER, "# add errors" )\
ACTION( replace, METRIC_COUNTER, "# replace requests" )\
ACTION( replace_stored, METRIC_COUNTER, "# replace successes" )\
ACTION( replace_notstored, METRIC_COUNTER, "# replace failures" )\
ACTION( replace_ex, METRIC_COUNTER, "# replace errors" )\
ACTION( cas, METRIC_COUNTER, "# cas requests" )\
ACTION( cas_stored, METRIC_COUNTER, "# cas successes" )\
ACTION( cas_exists, METRIC_COUNTER, "# cas bad values" )\
ACTION( cas_notfound, METRIC_COUNTER, "# cas not_founds" )\
ACTION( cas_ex, METRIC_COUNTER, "# cas errors" )\
ACTION( incr, METRIC_COUNTER, "# incr requests" )\
ACTION( incr_stored, METRIC_COUNTER, "# incr successes" )\
ACTION( incr_notfound, METRIC_COUNTER, "# incr not_founds" )\
ACTION( incr_ex, METRIC_COUNTER, "# incr errors" )\
ACTION( decr, METRIC_COUNTER, "# decr requests" )\
ACTION( decr_stored, METRIC_COUNTER, "# decr successes" )\
ACTION( decr_notfound, METRIC_COUNTER, "# decr not_founds" )\
ACTION( decr_ex, METRIC_COUNTER, "# decr errors" )\
ACTION( append, METRIC_COUNTER, "# append requests" )\
ACTION( append_stored, METRIC_COUNTER, "# append successes" )\
ACTION( append_notstored, METRIC_COUNTER, "# append not_founds" )\
ACTION( append_ex, METRIC_COUNTER, "# append errors" )\
ACTION( prepend, METRIC_COUNTER, "# prepend requests" )\
ACTION( prepend_stored, METRIC_COUNTER, "# prepend successes" )\
ACTION( prepend_notstored, METRIC_COUNTER, "# prepend not_founds" )\
ACTION( prepend_ex, METRIC_COUNTER, "# prepend errors" )\
ACTION( invalid, METRIC_COUNTER, "# invalid command" )\
ACTION( flush, METRIC_COUNTER, "# flush_all requests" )

typedef struct {
Expand Down

0 comments on commit 093c713

Please sign in to comment.