diff --git a/src/frontend/query.c b/src/frontend/query.c
index 34b35839e03c3d00835e449710f5fffaec5d76fc..35ff1026d1d84686d10468b9fe5046d5a14d7a41 100644 (file)
--- a/src/frontend/query.c
+++ b/src/frontend/query.c
sdb_conn_node_t *node = NULL;
int status = 0;
sdb_conn_node_t *node = NULL;
int status = 0;
- if ((! conn) || (conn->cmd != CONNECTION_QUERY))
+ if ((! conn) || (conn->cmd != SDB_CONNECTION_QUERY))
return -1;
parsetree = sdb_fe_parse(sdb_strbuf_string(conn->buf),
return -1;
parsetree = sdb_fe_parse(sdb_strbuf_string(conn->buf),
switch (sdb_llist_len(parsetree)) {
case 0:
/* skipping empty command; send back an empty reply */
switch (sdb_llist_len(parsetree)) {
case 0:
/* skipping empty command; send back an empty reply */
- sdb_connection_send(conn, CONNECTION_DATA, 0, NULL);
+ sdb_connection_send(conn, SDB_CONNECTION_DATA, 0, NULL);
break;
case 1:
node = SDB_CONN_NODE(sdb_llist_get(parsetree, 0));
break;
case 1:
node = SDB_CONN_NODE(sdb_llist_get(parsetree, 0));
char name[conn->cmd_len + 1];
int type;
char name[conn->cmd_len + 1];
int type;
- if ((! conn) || (conn->cmd != CONNECTION_FETCH))
+ if ((! conn) || (conn->cmd != SDB_CONNECTION_FETCH))
return -1;
if (conn->cmd_len < sizeof(uint32_t)) {
return -1;
if (conn->cmd_len < sizeof(uint32_t)) {
{
int type = SDB_HOST;
{
int type = SDB_HOST;
- if ((! conn) || (conn->cmd != CONNECTION_LIST))
+ if ((! conn) || (conn->cmd != SDB_CONNECTION_LIST))
return -1;
if (conn->cmd_len == sizeof(uint32_t))
return -1;
if (conn->cmd_len == sizeof(uint32_t))
int status;
conn_matcher_t m_node = {
int status;
conn_matcher_t m_node = {
- { SDB_OBJECT_INIT, CONNECTION_MATCHER }, NULL
+ { SDB_OBJECT_INIT, SDB_CONNECTION_MATCHER }, NULL
};
conn_lookup_t node = {
};
conn_lookup_t node = {
- { SDB_OBJECT_INIT, CONNECTION_LOOKUP },
+ { SDB_OBJECT_INIT, SDB_CONNECTION_LOOKUP },
-1, &m_node, NULL
};
-1, &m_node, NULL
};
- if ((! conn) || (conn->cmd != CONNECTION_LOOKUP))
+ if ((! conn) || (conn->cmd != SDB_CONNECTION_LOOKUP))
return -1;
if (conn->cmd_len < sizeof(uint32_t)) {
return -1;
if (conn->cmd_len < sizeof(uint32_t)) {
return -1;
switch (node->cmd) {
return -1;
switch (node->cmd) {
- case CONNECTION_FETCH:
+ case SDB_CONNECTION_FETCH:
if (CONN_FETCH(node)->filter)
filter = CONN_FETCH(node)->filter->matcher;
return sdb_fe_exec_fetch(conn, CONN_FETCH(node)->type,
CONN_FETCH(node)->host, CONN_FETCH(node)->name, filter);
if (CONN_FETCH(node)->filter)
filter = CONN_FETCH(node)->filter->matcher;
return sdb_fe_exec_fetch(conn, CONN_FETCH(node)->type,
CONN_FETCH(node)->host, CONN_FETCH(node)->name, filter);
- case CONNECTION_LIST:
+ case SDB_CONNECTION_LIST:
if (CONN_LIST(node)->filter)
filter = CONN_LIST(node)->filter->matcher;
return sdb_fe_exec_list(conn, CONN_LIST(node)->type, filter);
if (CONN_LIST(node)->filter)
filter = CONN_LIST(node)->filter->matcher;
return sdb_fe_exec_list(conn, CONN_LIST(node)->type, filter);
- case CONNECTION_LOOKUP:
+ case SDB_CONNECTION_LOOKUP:
if (CONN_LOOKUP(node)->matcher)
m = CONN_LOOKUP(node)->matcher->matcher;
if (CONN_LOOKUP(node)->filter)
filter = CONN_LOOKUP(node)->filter->matcher;
return sdb_fe_exec_lookup(conn,
CONN_LOOKUP(node)->type, m, filter);
if (CONN_LOOKUP(node)->matcher)
m = CONN_LOOKUP(node)->matcher->matcher;
if (CONN_LOOKUP(node)->filter)
filter = CONN_LOOKUP(node)->filter->matcher;
return sdb_fe_exec_lookup(conn,
CONN_LOOKUP(node)->type, m, filter);
- case CONNECTION_TIMESERIES:
+ case SDB_CONNECTION_TIMESERIES:
return sdb_fe_exec_timeseries(conn,
CONN_TS(node)->hostname, CONN_TS(node)->metric,
&CONN_TS(node)->opts);
return sdb_fe_exec_timeseries(conn,
CONN_TS(node)->hostname, CONN_TS(node)->metric,
&CONN_TS(node)->opts);
sdb_fe_exec_fetch(sdb_conn_t *conn, int type,
const char *hostname, const char *name, sdb_store_matcher_t *filter)
{
sdb_fe_exec_fetch(sdb_conn_t *conn, int type,
const char *hostname, const char *name, sdb_store_matcher_t *filter)
{
- uint32_t res_type = htonl(CONNECTION_FETCH);
+ uint32_t res_type = htonl(SDB_CONNECTION_FETCH);
sdb_store_obj_t *host;
sdb_store_obj_t *obj;
sdb_store_obj_t *host;
sdb_store_obj_t *obj;
}
sdb_store_json_finish(f);
}
sdb_store_json_finish(f);
- sdb_connection_send(conn, CONNECTION_DATA,
+ sdb_connection_send(conn, SDB_CONNECTION_DATA,
(uint32_t)sdb_strbuf_len(buf), sdb_strbuf_string(buf));
sdb_strbuf_destroy(buf);
free(f);
(uint32_t)sdb_strbuf_len(buf), sdb_strbuf_string(buf));
sdb_strbuf_destroy(buf);
free(f);
int
sdb_fe_exec_list(sdb_conn_t *conn, int type, sdb_store_matcher_t *filter)
{
int
sdb_fe_exec_list(sdb_conn_t *conn, int type, sdb_store_matcher_t *filter)
{
- uint32_t res_type = htonl(CONNECTION_LIST);
+ uint32_t res_type = htonl(SDB_CONNECTION_LIST);
sdb_store_json_formatter_t *f;
sdb_strbuf_t *buf;
sdb_store_json_formatter_t *f;
sdb_strbuf_t *buf;
}
sdb_store_json_finish(f);
}
sdb_store_json_finish(f);
- sdb_connection_send(conn, CONNECTION_DATA,
+ sdb_connection_send(conn, SDB_CONNECTION_DATA,
(uint32_t)sdb_strbuf_len(buf), sdb_strbuf_string(buf));
sdb_strbuf_destroy(buf);
free(f);
(uint32_t)sdb_strbuf_len(buf), sdb_strbuf_string(buf));
sdb_strbuf_destroy(buf);
free(f);
sdb_fe_exec_lookup(sdb_conn_t *conn, int type,
sdb_store_matcher_t *m, sdb_store_matcher_t *filter)
{
sdb_fe_exec_lookup(sdb_conn_t *conn, int type,
sdb_store_matcher_t *m, sdb_store_matcher_t *filter)
{
- uint32_t res_type = htonl(CONNECTION_LOOKUP);
+ uint32_t res_type = htonl(SDB_CONNECTION_LOOKUP);
sdb_store_json_formatter_t *f;
sdb_strbuf_t *buf;
sdb_store_json_formatter_t *f;
sdb_strbuf_t *buf;
- /* XXX: support other types */
- if (type != SDB_HOST) {
- sdb_log(SDB_LOG_ERR, "frontend: Invalid object type %d "
- "in LOOKUP command", type);
- sdb_strbuf_sprintf(conn->errbuf,
- "LOOKUP: Invalid object type %d", type);
- return -1;
- }
-
buf = sdb_strbuf_create(1024);
if (! buf) {
char errbuf[1024];
buf = sdb_strbuf_create(1024);
if (! buf) {
char errbuf[1024];
sdb_strbuf_memcpy(buf, &res_type, sizeof(uint32_t));
sdb_strbuf_memcpy(buf, &res_type, sizeof(uint32_t));
- if (sdb_store_scan(SDB_HOST, m, filter, lookup_tojson, f)) {
- sdb_log(SDB_LOG_ERR, "frontend: Failed to lookup hosts");
- sdb_strbuf_sprintf(conn->errbuf, "Failed to lookup hosts");
+ if (sdb_store_scan(type, m, filter, lookup_tojson, f)) {
+ sdb_log(SDB_LOG_ERR, "frontend: Failed to lookup %ss",
+ SDB_STORE_TYPE_TO_NAME(type));
+ sdb_strbuf_sprintf(conn->errbuf, "Failed to lookup %ss",
+ SDB_STORE_TYPE_TO_NAME(type));
sdb_strbuf_destroy(buf);
free(f);
return -1;
}
sdb_store_json_finish(f);
sdb_strbuf_destroy(buf);
free(f);
return -1;
}
sdb_store_json_finish(f);
- sdb_connection_send(conn, CONNECTION_DATA,
+ sdb_connection_send(conn, SDB_CONNECTION_DATA,
(uint32_t)sdb_strbuf_len(buf), sdb_strbuf_string(buf));
sdb_strbuf_destroy(buf);
free(f);
(uint32_t)sdb_strbuf_len(buf), sdb_strbuf_string(buf));
sdb_strbuf_destroy(buf);
free(f);
sdb_timeseries_opts_t *opts)
{
sdb_strbuf_t *buf;
sdb_timeseries_opts_t *opts)
{
sdb_strbuf_t *buf;
- uint32_t res_type = htonl(CONNECTION_TIMESERIES);
+ uint32_t res_type = htonl(SDB_CONNECTION_TIMESERIES);
buf = sdb_strbuf_create(1024);
if (! buf) {
buf = sdb_strbuf_create(1024);
if (! buf) {
return -1;
}
return -1;
}
- sdb_connection_send(conn, CONNECTION_DATA,
+ sdb_connection_send(conn, SDB_CONNECTION_DATA,
(uint32_t)sdb_strbuf_len(buf), sdb_strbuf_string(buf));
sdb_strbuf_destroy(buf);
return 0;
(uint32_t)sdb_strbuf_len(buf), sdb_strbuf_string(buf));
sdb_strbuf_destroy(buf);
return 0;