summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author[email protected] <[email protected]>2021-08-10 10:02:22 +0800
committer[email protected] <[email protected]>2021-08-10 10:02:22 +0800
commit67bafbefc972158f9ddd4fb9e45dc76ff2c8a540 (patch)
tree41d7b45a3c8306bb2d43fa9e8f2ca4bde6223d30
parent730a744229cb3bbf9f34e90520e4896e36d45aba (diff)
增加获取版本号API0.2
-rw-r--r--server/doris_server_http.cpp41
-rw-r--r--server/doris_server_scandir.cpp2
2 files changed, 42 insertions, 1 deletions
diff --git a/server/doris_server_http.cpp b/server/doris_server_http.cpp
index 8a82518..6c2dad1 100644
--- a/server/doris_server_http.cpp
+++ b/server/doris_server_http.cpp
@@ -329,6 +329,46 @@ void doris_http_server_file_cb(struct evhttp_request *req, void *arg)
evhttp_clear_headers(&params);
}
+void doris_http_server_version_cb(struct evhttp_request *req, void *arg)
+{
+ struct evkeyvalq params;
+ const char *bizname;
+ struct doris_business *business;
+ map<string, struct doris_business*>::iterator iter;
+ char verbuf[32];
+
+ if(evhttp_parse_query(evhttp_request_get_uri(req), &params))
+ {
+ FS_operate(g_doris_server_info.fsstat_handle, g_doris_server_info.fsstat_field[DRS_FSSTAT_CLIENT_INVALID_REQ], 0, FS_OP_ADD, 1);
+ evhttp_send_error(req, HTTP_BADREQUEST, "Parameters invalid");
+ return;
+ }
+
+ if(NULL == (bizname = evhttp_find_header(&params, "business")))
+ {
+ FS_operate(g_doris_server_info.fsstat_handle, g_doris_server_info.fsstat_field[DRS_FSSTAT_CLIENT_INVALID_REQ], 0, FS_OP_ADD, 1);
+ evhttp_clear_headers(&params);
+ evhttp_send_error(req, HTTP_BADREQUEST, "Parameters invalid, no business found");
+ return;
+ }
+ if((iter = g_doris_server_info.name2business->find(string(bizname)))==g_doris_server_info.name2business->end())
+ {
+ FS_operate(g_doris_server_info.fsstat_handle, g_doris_server_info.fsstat_field[DRS_FSSTAT_CLIENT_INVALID_REQ], 0, FS_OP_ADD, 1);
+ evhttp_clear_headers(&params);
+ evhttp_send_error(req, HTTP_BADREQUEST, "Parameters invalid, business invalid");
+ return;
+ }
+ evhttp_clear_headers(&params);
+ business = iter->second;
+
+ pthread_rwlock_rdlock(&business->rwlock);
+ sprintf(verbuf, "%lu", business->cfgver_head->latest_version);
+ pthread_rwlock_unlock(&business->rwlock);
+
+ evhttp_add_header(evhttp_request_get_output_headers(req), "X-Latest-Version", verbuf);
+ evhttp_send_reply(req, HTTP_OK, "OK", NULL);
+}
+
void doris_http_server_generic_cb(struct evhttp_request *req, void *arg)
{
evhttp_send_error(req, HTTP_BADREQUEST, "Not Supported.");
@@ -448,6 +488,7 @@ void* thread_doris_http_server(void *arg)
evhttp_set_cb(worker_http, "/configmeta", doris_http_server_meta_cb, NULL);
evhttp_set_cb(worker_http, "/configfile", doris_http_server_file_cb, NULL);
+ evhttp_set_cb(worker_http, "/latestversion", doris_http_server_version_cb, NULL);
evhttp_set_gencb(worker_http, doris_http_server_generic_cb, NULL);
evhttp_set_allowed_methods(worker_http, EVHTTP_REQ_GET|EVHTTP_REQ_HEAD);
diff --git a/server/doris_server_scandir.cpp b/server/doris_server_scandir.cpp
index 85c276e..8840b64 100644
--- a/server/doris_server_scandir.cpp
+++ b/server/doris_server_scandir.cpp
@@ -317,7 +317,7 @@ enum DORIS_UPDATE_TYPE doris_index_file_traverse(struct doris_idxfile_scanner *s
table_num=cm_read_cfg_index_file(idx_path_array[i].path, table_array, CM_MAX_TABLE_NUM, logger);
if(table_num<0)
{
- MESA_RUNTIME_LOGV4(logger,RLOG_LV_INFO, "load %s faild, abandon udpate.", idx_path_array[i].path);
+ MESA_RUNTIME_LOGV4(logger,RLOG_LV_FATAL, "load %s faild, abandon udpate.", idx_path_array[i].path);
update_type = CFG_UPDATE_TYPE_ERR;
break;
}