Compare commits

...
15 Commits
Author SHA1 Message Date
fengzeroz f0b746a1ab Merge pull request #2482 from fengzeroz/v2.12
fix: filter error crash
2025-06-11 15:38:32 +08:00
fengzero afaddb8066 fix: filter error crash 2025-06-11 03:02:38 +00:00
fengzeroz 9957771212 Merge pull request #2478 from ZhouBox/v2.12
[v2.12]startup optimization
2025-06-11 10:19:56 +08:00
xiang.zhou 89e1a7da3f startup optimization 2025-06-10 14:37:04 +08:00
fengzeroz 41c737ba4b Merge pull request #2474 from ZhouBox/v2.12
[v2.12]adapter:check state when do with trans data
2025-06-09 16:35:37 +08:00
xiang.zhou 6a7bea735f adapter:check state when do with trans data 2025-06-09 16:24:50 +08:00
fengzeroz 20098f3845 Merge pull request #2469 from hxy7yx/v2.12-1
start datalayers plugin without check
2025-05-29 09:41:04 +08:00
hxy7yx 91c3b39e5f start datalayers plugin without check 2025-05-27 20:36:39 -07:00
fengzeroz 50771e55b4 Merge pull request #2466 from hxy7yx/v2.12-1
datalayers:cancel verifying connections before configuration
2025-05-28 10:04:21 +08:00
hxy7yx d1abf23335 datalayers:cancel verifying connections before configuration 2025-05-27 00:12:25 -07:00
fengzeroz 552827dc16 Merge pull request #2463 from hxy7yx/v2.12-1
[v2.12]update ci.yml
2025-05-26 17:58:28 +08:00
hxy7yx 86271ecca8 update api:sub info of datalayers plugin 2025-05-26 02:49:30 -07:00
hxy7yx 9db3a8e521 update ci.yml 2025-05-25 20:10:51 -07:00
fengzeroz 7e2ee821b2 Merge pull request #2460 from fengzeroz/v2.12
branch v2.12
2025-05-23 14:51:37 +08:00
fengzero 39564dce45 branch v2.12 2025-05-23 06:51:13 +00:00
23 changed files with 388 additions and 92 deletions
+4 -4
View File
@@ -27,7 +27,7 @@ jobs:
cppcheck:
runs-on: ubuntu-24.04
container: ghcr.io/neugates/build:x86_64-main
container: ghcr.io/neugates/build:x86_64-v2.12
steps:
- uses: actions/checkout@v4
@@ -42,7 +42,7 @@ jobs:
build:
runs-on: ubuntu-24.04
container: ghcr.io/neugates/build:x86_64-main
container: ghcr.io/neugates/build:x86_64-v2.12
steps:
- uses: actions/checkout@v4
@@ -65,7 +65,7 @@ jobs:
ut:
runs-on: ubuntu-24.04
container: ghcr.io/neugates/build:x86_64-main
container: ghcr.io/neugates/build:x86_64-v2.12
needs: [build]
steps:
@@ -103,7 +103,7 @@ jobs:
pft:
runs-on: ubuntu-24.04
container: ghcr.io/neugates/build:x86_64-main
container: ghcr.io/neugates/build:x86_64-v2.12
needs: [build]
strategy:
matrix:
+3 -3
View File
@@ -10,7 +10,7 @@ on:
env:
VERSION: 2.12.0
UI_VERSION: 2.6.1
BRANCH: main
BRANCH: v2.12
jobs:
cross-build:
@@ -19,7 +19,7 @@ jobs:
matrix:
arch:
- [x86_64-linux-gnu, x86_64, amd64]
container: ghcr.io/neugates/build:${{ matrix.arch[1] }}-main
container: ghcr.io/neugates/build:${{ matrix.arch[1] }}-v2.12
steps:
- uses: actions/checkout@v4
@@ -62,7 +62,7 @@ jobs:
matrix:
arch:
- [x86_64-linux-gnu, x86_64, amd64]
container: ghcr.io/neugates/build:${{ matrix.arch[1] }}-main
container: ghcr.io/neugates/build:${{ matrix.arch[1] }}-v2.12
steps:
- uses: actions/checkout@v4
+1 -1
View File
@@ -1,7 +1,7 @@
set(CMAKE_SYSTEM_NAME Linux)
set(COMPILER_PREFIX aarch64-linux-gnu)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(LIBRARY_DIR /home/neuron/main/libs)
set(LIBRARY_DIR /home/neuron/v2.12/libs)
set(CMAKE_C_COMPILER ${COMPILER_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${COMPILER_PREFIX}-g++)
+1 -1
View File
@@ -1,7 +1,7 @@
set(CMAKE_SYSTEM_NAME Linux)
set(COMPILER_PREFIX arm-linux-gnueabi)
set(CMAKE_SYSTEM_PROCESSOR armv5tejl)
set(LIBRARY_DIR /home/neuron/main/libs)
set(LIBRARY_DIR /home/neuron/v2.12/libs)
set(CMAKE_C_COMPILER ${COMPILER_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${COMPILER_PREFIX}-g++)
+1 -1
View File
@@ -1,7 +1,7 @@
set(CMAKE_SYSTEM_NAME Linux)
set(COMPILER_PREFIX arm-linux-gnueabihf)
set(CMAKE_SYSTEM_PROCESSOR armv7l)
set(LIBRARY_DIR /home/neuron/main/libs)
set(LIBRARY_DIR /home/neuron/v2.12/libs)
set(CMAKE_C_COMPILER ${COMPILER_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${COMPILER_PREFIX}-g++)
+1 -1
View File
@@ -1,7 +1,7 @@
set(CMAKE_SYSTEM_NAME Linux)
set(COMPILER_PREFIX x86_64-linux-gnu)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(LIBRARY_DIR /home/neuron/main/libs)
set(LIBRARY_DIR /home/neuron/v2.12/libs)
set(CMAKE_C_COMPILER ${COMPILER_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${COMPILER_PREFIX}-g++)
+7
View File
@@ -68,6 +68,8 @@ typedef enum neu_reqresp_type {
NEU_RESP_GET_DATALAYERS_GROUPS,
NEU_REQ_GET_DATALAYERS_TAGS,
NEU_RESP_GET_DATALAYERS_TAGS,
NEU_REQ_GET_DATALAYERS_TAG,
NEU_RESP_GET_DATALAYERS_TAG,
NEU_REQ_NODE_INIT,
NEU_REQ_NODE_UNINIT,
@@ -199,6 +201,8 @@ static const char *neu_reqresp_type_string_t[] = {
[NEU_RESP_GET_DATALAYERS_GROUPS] = "NEU_RESP_GET_DATALAYERS_GROUPS",
[NEU_REQ_GET_DATALAYERS_TAGS] = "NEU_REQ_GET_DATALAYERS_TAGS",
[NEU_RESP_GET_DATALAYERS_TAGS] = "NEU_RESP_GET_DATALAYERS_TAGS",
[NEU_REQ_GET_DATALAYERS_TAG] = "NEU_REQ_GET_DATALAYERS_TAG",
[NEU_RESP_GET_DATALAYERS_TAG] = "NEU_RESP_GET_DATALAYERS_TAG",
[NEU_REQ_NODE_INIT] = "NEU_REQ_NODE_INIT",
[NEU_REQ_NODE_UNINIT] = "NEU_REQ_NODE_UNINIT",
@@ -697,6 +701,9 @@ typedef struct neu_req_get_subscribe_group {
typedef struct {
char app[NEU_NODE_NAME_LEN];
char driver[NEU_NODE_NAME_LEN];
char group[NEU_GROUP_NAME_LEN];
char tag[NEU_TAG_NAME_LEN];
} neu_req_get_sub_driver_tags_t;
typedef struct neu_resp_subscribe_info {
+2
View File
@@ -42,6 +42,8 @@ neu_otel_trace_ctx neu_otel_find_trace2(void *req_ctx);
void neu_otel_trace_set_final(neu_otel_trace_ctx ctx);
void neu_otel_trace_set_expected_span_num(neu_otel_trace_ctx ctx, uint32_t num);
void neu_otel_trace_reduce_expected_span_num(neu_otel_trace_ctx ctx,
uint32_t num);
uint8_t *neu_otel_get_trace_id(neu_otel_trace_ctx ctx);
neu_otel_trace_ctx neu_otel_find_trace_by_id(const char *trace_id);
+4 -3
View File
@@ -135,10 +135,10 @@ static int config_datalayers_client(neu_plugin_t * plugin,
if (NULL == plugin->client) {
plog_error(plugin, "datalayers client_create failed");
plugin->common.link_state = NEU_NODE_LINK_STATE_DISCONNECTED;
return NEU_ERR_DATALAYERS_CONNECT_FAILURE;
} else {
plugin->common.link_state = NEU_NODE_LINK_STATE_CONNECTED;
}
plugin->common.link_state = NEU_NODE_LINK_STATE_CONNECTED;
return NEU_ERR_SUCCESS;
}
@@ -185,7 +185,8 @@ int datalayers_plugin_start(neu_plugin_t *plugin)
int ret = config_datalayers_client(plugin, &plugin->config);
if (ret != 0) {
plog_error(plugin, "datalayers started failed");
return NEU_ERR_DATALAYERS_CONNECT_FAILURE;
plugin->common.link_state = NEU_NODE_LINK_STATE_DISCONNECTED;
return NEU_ERR_SUCCESS;
}
}
+42 -40
View File
@@ -43,15 +43,28 @@ static void to_traceparent(uint8_t *trace_id, char *span_id, char *out)
}
static int tag_values_to_json(UT_array *tags, mqtt_static_vt_t *s_tags,
size_t n_s_tags, neu_json_read_resp_t *json)
size_t n_s_tags, neu_json_read_resp_t *json,
bool filter_error)
{
int index = 0;
int index = 0;
int n_valid = 0;
if (0 == utarray_len(tags)) {
if (filter_error) {
utarray_foreach(tags, neu_resp_tag_value_meta_t *, tag_value)
{
if (tag_value->value.type != NEU_TYPE_ERROR) {
n_valid += 1;
}
}
} else {
n_valid = utarray_len(tags);
}
if (n_valid == 0) {
return 0;
}
json->n_tag = utarray_len(tags) + n_s_tags;
json->n_tag = n_valid + n_s_tags;
json->tags = (neu_json_read_resp_tag_t *) calloc(
json->n_tag, sizeof(neu_json_read_resp_tag_t));
if (NULL == json->tags) {
@@ -60,8 +73,15 @@ static int tag_values_to_json(UT_array *tags, mqtt_static_vt_t *s_tags,
utarray_foreach(tags, neu_resp_tag_value_meta_t *, tag_value)
{
neu_tag_value_to_json(tag_value, &json->tags[index]);
index += 1;
if (filter_error) {
if (tag_value->value.type != NEU_TYPE_ERROR) {
neu_tag_value_to_json(tag_value, &json->tags[index]);
index += 1;
}
} else {
neu_tag_value_to_json(tag_value, &json->tags[index]);
index += 1;
}
}
if (s_tags != NULL) {
@@ -77,27 +97,6 @@ static int tag_values_to_json(UT_array *tags, mqtt_static_vt_t *s_tags,
return 0;
}
void filter_error_tags(neu_reqresp_trans_data_t *data)
{
if (!data || !data->tags) {
return;
}
UT_array *filtered_tags;
utarray_new(filtered_tags, neu_resp_tag_value_meta_icd());
neu_resp_tag_value_meta_t *tag_ptr = NULL;
while ((tag_ptr = (neu_resp_tag_value_meta_t *) utarray_next(data->tags,
tag_ptr))) {
if (tag_ptr->value.type != NEU_TYPE_ERROR) {
utarray_push_back(filtered_tags, tag_ptr);
}
}
utarray_free(data->tags);
data->tags = filtered_tags;
}
char *generate_upload_json(neu_plugin_t *plugin, neu_reqresp_trans_data_t *data,
mqtt_upload_format_e format, mqtt_schema_vt_t *vts,
size_t n_vts, mqtt_static_vt_t *s_tags,
@@ -109,29 +108,32 @@ char *generate_upload_json(neu_plugin_t *plugin, neu_reqresp_trans_data_t *data,
.timestamp = global_timestamp };
neu_json_read_resp_t json = { 0 };
if (!plugin->config.upload_err && skip != NULL) {
filter_error_tags(data);
if (utarray_len(data->tags) == 0) {
*skip = true;
return NULL;
}
}
if (format == MQTT_UPLOAD_FORMAT_CUSTOM) {
if (0 != tag_values_to_json(data->tags, NULL, 0, &json)) {
if (0 !=
tag_values_to_json(data->tags, NULL, 0, &json,
!plugin->config.upload_err)) {
plog_error(plugin, "tag_values_to_json fail");
return NULL;
}
} else {
if (0 != tag_values_to_json(data->tags, s_tags, n_s_tags, &json)) {
if (0 !=
tag_values_to_json(data->tags, s_tags, n_s_tags, &json,
!plugin->config.upload_err)) {
plog_error(plugin, "tag_values_to_json fail");
return NULL;
}
}
int ret;
if (json.n_tag == 0) {
plog_warn(plugin, "driver:%s group:%s, no valid tags", data->driver,
data->group);
if (skip != NULL) {
*skip = true;
}
return NULL;
}
int ret;
switch (format) {
case MQTT_UPLOAD_FORMAT_VALUES:
neu_json_encode_with_mqtt(&json, neu_json_encode_read_resp1, &header,
@@ -186,7 +188,7 @@ static char *generate_read_resp_json(neu_plugin_t * plugin,
char * json_str = NULL;
neu_json_read_resp_t json = { 0 };
if (0 != tag_values_to_json(data->tags, NULL, 0, &json)) {
if (0 != tag_values_to_json(data->tags, NULL, 0, &json, false)) {
plog_error(plugin, "tag_values_to_json fail");
return NULL;
}
+73 -20
View File
@@ -41,27 +41,8 @@ void handle_datalayers_get_groups(nng_aio *aio)
NEU_VALIDATE_JWT(aio);
// required parameter
snprintf(cmd.app, sizeof(cmd.app), "%s", "DataStorage");
// optional parameter
ret = neu_http_get_param_str(aio, "driver", cmd.driver, sizeof(cmd.driver));
if (-1 == ret || (size_t) ret == sizeof(cmd.driver)) {
NEU_JSON_RESPONSE_ERROR(NEU_ERR_PARAM_IS_WRONG, {
neu_http_response(aio, error_code.error, result_error);
})
return;
}
// optional parameter
ret = neu_http_get_param_str(aio, "group", cmd.group, sizeof(cmd.group));
if (-1 == ret || (size_t) ret == sizeof(cmd.driver)) {
NEU_JSON_RESPONSE_ERROR(NEU_ERR_PARAM_IS_WRONG, {
neu_http_response(aio, error_code.error, result_error);
})
return;
}
ret = neu_plugin_op(plugin, header, &cmd);
if (ret != 0) {
NEU_JSON_RESPONSE_ERROR(NEU_ERR_IS_BUSY, {
@@ -111,7 +92,22 @@ void handle_datalayers_get_tags(nng_aio *aio)
NEU_VALIDATE_JWT(aio);
// required parameter
ret = neu_http_get_param_str(aio, "driver", cmd.driver, sizeof(cmd.driver));
if (ret <= 0 || (size_t) ret == sizeof(cmd.driver)) {
NEU_JSON_RESPONSE_ERROR(NEU_ERR_PARAM_IS_WRONG, {
neu_http_response(aio, error_code.error, result_error);
})
return;
}
ret = neu_http_get_param_str(aio, "group", cmd.group, sizeof(cmd.group));
if (ret <= 0 || (size_t) ret == sizeof(cmd.group)) {
NEU_JSON_RESPONSE_ERROR(NEU_ERR_PARAM_IS_WRONG, {
neu_http_response(aio, error_code.error, result_error);
})
return;
}
snprintf(cmd.app, sizeof(cmd.app), "%s", "DataStorage");
ret = neu_plugin_op(plugin, header, &cmd);
@@ -137,6 +133,63 @@ void handle_datalayers_get_tags_resp(nng_aio * aio,
neu_http_ok(aio, result);
free(result);
if (tags) {
utarray_foreach(tags->infos, neu_resp_get_sub_driver_tags_info_t *,
info)
{
utarray_free(info->tags);
}
utarray_free(tags->infos);
}
}
void handle_datalayers_get_tag(nng_aio *aio)
{
int ret = 0;
neu_plugin_t * plugin = neu_rest_get_plugin();
neu_req_get_sub_driver_tags_t cmd = { 0 };
neu_reqresp_head_t header = {
.ctx = aio,
.type = NEU_REQ_GET_DATALAYERS_TAG,
.otel_trace_type = NEU_OTEL_TRACE_TYPE_REST_COMM,
};
NEU_VALIDATE_JWT(aio);
ret = neu_http_get_param_str(aio, "tag", cmd.tag, sizeof(cmd.tag));
if (ret <= 0 || (size_t) ret == sizeof(cmd.tag)) {
NEU_JSON_RESPONSE_ERROR(NEU_ERR_PARAM_IS_WRONG, {
neu_http_response(aio, error_code.error, result_error);
})
return;
}
snprintf(cmd.app, sizeof(cmd.app), "%s", "DataStorage");
ret = neu_plugin_op(plugin, header, &cmd);
if (ret != 0) {
NEU_JSON_RESPONSE_ERROR(NEU_ERR_IS_BUSY, {
neu_http_response(aio, NEU_ERR_IS_BUSY, result_error);
});
}
}
void handle_datalayers_get_tag_resp(nng_aio * aio,
neu_resp_get_sub_driver_tags_t *tags)
{
char *result = NULL;
int ret = neu_json_encode_by_fn(
tags, neu_json_encode_datalayers_get_tag_resp, &result);
if (ret != 0 || result == NULL) {
neu_http_response(
aio, 500, "{\"error\":4200,\"reason\":\"failed to encode tags\"}");
return;
}
neu_http_ok(aio, result);
free(result);
if (tags) {
utarray_foreach(tags->infos, neu_resp_get_sub_driver_tags_info_t *,
+4
View File
@@ -32,4 +32,8 @@ void handle_datalayers_get_tags(nng_aio *aio);
void handle_datalayers_get_tags_resp(nng_aio * aio,
neu_resp_get_sub_driver_tags_t *tags);
void handle_datalayers_get_tag(nng_aio *aio);
void handle_datalayers_get_tag_resp(nng_aio * aio,
neu_resp_get_sub_driver_tags_t *tags);
#endif
+9
View File
@@ -155,6 +155,9 @@ static struct neu_http_handler cors_handler[] = {
{
.url = "/api/v2/datalayers/tags",
},
{
.url = "/api/v2/datalayers/tag",
},
};
static struct neu_http_handler rest_handlers[] = {
@@ -513,6 +516,12 @@ static struct neu_http_handler rest_handlers[] = {
.url = "/api/v2/datalayers/tags",
.value.handler = handle_datalayers_get_tags,
},
{
.method = NEU_HTTP_METHOD_GET,
.type = NEU_HTTP_HANDLER_FUNCTION,
.url = "/api/v2/datalayers/tag",
.value.handler = handle_datalayers_get_tag,
},
};
void neu_rest_handler(const struct neu_http_handler **handlers, uint32_t *size)
+7
View File
@@ -298,6 +298,13 @@ static int dashb_plugin_request(neu_plugin_t * plugin,
neu_otel_scope_set_status_code2(scope, NEU_OTEL_STATUS_OK, 0);
}
break;
case NEU_RESP_GET_DATALAYERS_TAG:
handle_datalayers_get_tag_resp(header->ctx,
(neu_resp_get_sub_driver_tags_t *) data);
if (neu_otel_control_is_started() && trace) {
neu_otel_scope_set_status_code2(scope, NEU_OTEL_STATUS_OK, 0);
}
break;
case NEU_RESP_GET_NODE_SETTING:
handle_get_node_setting_resp(header->ctx,
(neu_resp_get_node_setting_t *) data);
+14 -2
View File
@@ -123,8 +123,19 @@ static void *adapter_consumer(void *arg)
nlog_debug("adapter(%s) recv msg from: %s %p, type: %s, %u",
adapter->name, header->sender, header->ctx,
neu_reqresp_type_string(header->type), n);
adapter->module->intf_funs->request(
adapter->plugin, (neu_reqresp_head_t *) header, &header[1]);
if (adapter->state == NEU_NODE_RUNNING_STATE_RUNNING) {
adapter->module->intf_funs->request(
adapter->plugin, (neu_reqresp_head_t *) header, &header[1]);
} else {
void *ctx = ((neu_reqresp_trans_data_t *) &header[1])->trace_ctx;
if (neu_otel_data_is_started() && ctx) {
neu_otel_trace_ctx trace = neu_otel_find_trace(ctx);
if (trace) {
neu_otel_trace_reduce_expected_span_num(trace, 1);
}
}
}
neu_trans_data_free((neu_reqresp_trans_data_t *) &header[1]);
neu_msg_free(msg);
}
@@ -757,6 +768,7 @@ static int adapter_loop(enum neu_event_io_type type, int fd, void *usr_data)
case NEU_RESP_GET_SUBSCRIBE_GROUP:
case NEU_RESP_GET_DATALAYERS_GROUPS:
case NEU_RESP_GET_DATALAYERS_TAGS:
case NEU_RESP_GET_DATALAYERS_TAG:
case NEU_RESP_ADD_TAG:
case NEU_RESP_ADD_GTAG:
case NEU_RESP_UPDATE_TAG:
-14
View File
@@ -2289,20 +2289,6 @@ static int report_callback(void *usr_data)
utarray_foreach(group->apps, sub_app_t *, app)
{
neu_adapter_t *sub_app =
neu_node_manager_find(g_manager->node_manager, app->app);
if (sub_app != NULL) {
if (sub_app->state != NEU_NODE_RUNNING_STATE_RUNNING) {
neu_trans_data_free(data);
continue;
}
} else {
nlog_error("sub app %s not exist", app->app);
neu_trans_data_free(data);
continue;
}
if (group->driver->adapter.cb_funs.responseto(
&group->driver->adapter, &header, data, app->addr) !=
0) {
+3 -1
View File
@@ -135,7 +135,9 @@ extern "C" {
XX(NEU_REQ_GET_DATALAYERS_GROUPS, neu_req_get_subscribe_group_t) \
XX(NEU_RESP_GET_DATALAYERS_GROUPS, neu_resp_get_subscribe_group_t) \
XX(NEU_REQ_GET_DATALAYERS_TAGS, neu_req_get_sub_driver_tags_t) \
XX(NEU_RESP_GET_DATALAYERS_TAGS, neu_resp_get_sub_driver_tags_t)
XX(NEU_RESP_GET_DATALAYERS_TAGS, neu_resp_get_sub_driver_tags_t) \
XX(NEU_REQ_GET_DATALAYERS_TAG, neu_req_get_sub_driver_tags_t) \
XX(NEU_RESP_GET_DATALAYERS_TAG, neu_resp_get_sub_driver_tags_t)
static inline size_t neu_reqresp_size(neu_reqresp_type_e t)
{
+78
View File
@@ -1056,10 +1056,18 @@ static int manager_loop(enum neu_event_io_type type, int fd, void *usr_data)
(neu_req_get_sub_driver_tags_t *) &header[1];
neu_resp_get_sub_driver_tags_t resp = { 0 };
UT_array *groups = neu_manager_get_sub_group(manager, cmd->app);
bool found = false;
utarray_new(resp.infos, neu_resp_get_sub_driver_tags_info_icd());
utarray_foreach(groups, neu_resp_subscribe_info_t *, info)
{
if (strcmp(info->driver, cmd->driver) != 0 ||
strcmp(info->group, cmd->group) != 0) {
continue;
}
found = true;
neu_resp_get_sub_driver_tags_info_t in = { 0 };
neu_adapter_t * driver =
neu_node_manager_find(manager->node_manager, info->driver);
@@ -1074,12 +1082,82 @@ static int manager_loop(enum neu_event_io_type type, int fd, void *usr_data)
}
utarray_free(groups);
if (!found) {
utarray_free(resp.infos);
neu_resp_error_t e = { .error = NEU_ERR_GROUP_NOT_EXIST };
header->type = NEU_RESP_ERROR;
neu_msg_exchange(header);
reply(manager, header, &e);
break;
}
strcpy(header->receiver, header->sender);
header->type = NEU_RESP_GET_DATALAYERS_TAGS;
reply(manager, header, &resp);
break;
}
case NEU_REQ_GET_DATALAYERS_TAG: {
neu_req_get_sub_driver_tags_t *cmd =
(neu_req_get_sub_driver_tags_t *) &header[1];
neu_resp_get_sub_driver_tags_t resp = { 0 };
UT_array *groups = neu_manager_get_sub_group(manager, cmd->app);
bool found = false;
utarray_new(resp.infos, neu_resp_get_sub_driver_tags_info_icd());
utarray_foreach(groups, neu_resp_subscribe_info_t *, info)
{
neu_resp_get_sub_driver_tags_info_t in = { 0 };
neu_adapter_t * driver =
neu_node_manager_find(manager->node_manager, info->driver);
assert(driver != NULL);
neu_adapter_driver_get_value_tag((neu_adapter_driver_t *) driver,
info->group, &in.tags);
if (in.tags) {
UT_array *filtered_tags = NULL;
utarray_new(filtered_tags, neu_tag_get_icd());
utarray_foreach(in.tags, neu_datatag_t *, tag)
{
if (strstr(tag->name, cmd->tag) != NULL) {
utarray_push_back(filtered_tags, tag);
}
}
utarray_free(in.tags);
if (utarray_len(filtered_tags) > 0) {
strcpy(in.driver, info->driver);
strcpy(in.group, info->group);
in.tags = filtered_tags;
utarray_push_back(resp.infos, &in);
found = true;
} else {
utarray_free(filtered_tags);
}
}
}
utarray_free(groups);
if (!found) {
utarray_free(resp.infos);
neu_resp_error_t e = { .error = NEU_ERR_TAG_NOT_EXIST };
header->type = NEU_RESP_ERROR;
neu_msg_exchange(header);
reply(manager, header, &e);
break;
}
strcpy(header->receiver, header->sender);
header->type = NEU_RESP_GET_DATALAYERS_TAG;
reply(manager, header, &resp);
break;
}
case NEU_REQ_GET_NODES_STATE: {
neu_resp_get_nodes_state_t resp = { 0 };
UT_array *states = neu_node_manager_get_state(manager->node_manager);
+13
View File
@@ -18,6 +18,7 @@
**/
#include "errcodes.h"
#include "utils/log.h"
#include "utils/time.h"
#include "adapter/storage.h"
#include "storage.h"
@@ -140,6 +141,8 @@ int manager_load_node(neu_manager_t *manager)
return -1;
}
int i = 0;
utarray_foreach(node_infos, neu_persist_node_info_t *, node_info)
{
rv = neu_manager_add_node(manager, node_info->name,
@@ -149,6 +152,10 @@ int manager_load_node(neu_manager_t *manager)
nlog_notice("load adapter %s type:%d, name:%s plugin:%s state:%d",
ok_or_err, node_info->type, node_info->name,
node_info->plugin_name, node_info->state);
i++;
if (i % 10 == 0) {
neu_msleep(10);
}
}
utarray_free(node_infos);
@@ -160,6 +167,8 @@ int manager_load_subscribe(neu_manager_t *manager)
UT_array *nodes =
neu_node_manager_get(manager->node_manager, NEU_NA_TYPE_APP);
int i = 0;
utarray_foreach(nodes, neu_resp_node_info_t *, node)
{
int rv = 0;
@@ -186,6 +195,10 @@ int manager_load_subscribe(neu_manager_t *manager)
info->group_name, app_port,
info->params, info->static_tags);
}
i++;
if (i % 10 == 0) {
neu_msleep(10);
}
}
utarray_free(sub_infos);
+10
View File
@@ -540,6 +540,16 @@ void neu_otel_trace_set_expected_span_num(neu_otel_trace_ctx ctx, uint32_t num)
trace_ctx->expected_span_num = num;
}
void neu_otel_trace_reduce_expected_span_num(neu_otel_trace_ctx ctx,
uint32_t num)
{
trace_ctx_t *trace_ctx = (trace_ctx_t *) ctx;
trace_ctx->expected_span_num -= num;
if (trace_ctx->expected_span_num <= 0) {
trace_ctx->final = true;
}
}
uint8_t *neu_otel_get_trace_id(neu_otel_trace_ctx ctx)
{
trace_ctx_t *trace_ctx = (trace_ctx_t *) ctx;
+108
View File
@@ -163,6 +163,7 @@ int neu_json_encode_datalayers_get_tags_resp(void *json_object_param,
json_object_set_new(tag_obj, "name", json_string(tag->name));
json_object_set_new(tag_obj, "type", json_integer(tag->type));
json_object_set_new(tag_obj, "category", json_integer(3));
json_object_set_new(tag_obj, "leaf", json_true());
json_object_set_new(tag_obj, "children", json_array());
json_array_append_new(tag_array, tag_obj);
@@ -183,6 +184,113 @@ int neu_json_encode_datalayers_get_tags_resp(void *json_object_param,
.v.val_object = final_obj,
} };
int ret = neu_json_encode_field(json_object_param, elems,
NEU_JSON_ELEM_SIZE(elems));
json_decref(final_obj);
return ret;
}
int neu_json_encode_datalayers_get_tag_resp(void *json_object_param,
void *param)
{
neu_resp_get_sub_driver_tags_t *resp =
(neu_resp_get_sub_driver_tags_t *) param;
json_t *node_array = json_array();
for (unsigned int i = 0; i < utarray_len(resp->infos); i++) {
neu_resp_get_sub_driver_tags_info_t *info =
(neu_resp_get_sub_driver_tags_info_t *) utarray_eltptr(resp->infos,
i);
char node_id[37];
char node_uuid_input[128];
snprintf(node_uuid_input, sizeof(node_uuid_input), "%s", info->driver);
generate_fixed_uuid(node_uuid_input, node_id);
json_t *node_obj = NULL;
for (size_t j = 0; j < json_array_size(node_array); j++) {
node_obj = json_array_get(node_array, j);
if (strcmp(json_string_value(json_object_get(node_obj, "id")),
node_id) == 0) {
break;
}
node_obj = NULL;
}
if (!node_obj) {
node_obj = json_object();
json_object_set_new(node_obj, "id", json_string(node_id));
json_object_set_new(node_obj, "name", json_string(info->driver));
json_object_set_new(node_obj, "category", json_integer(1));
json_t *node_children = json_array();
json_object_set_new(node_obj, "children", node_children);
json_array_append_new(node_array, node_obj);
}
json_t *group_obj = NULL;
char group_id[37];
char group_uuid_input[256];
snprintf(group_uuid_input, sizeof(group_uuid_input), "%s-%s",
info->driver, info->group);
generate_fixed_uuid(group_uuid_input, group_id);
json_t *children_array = json_object_get(node_obj, "children");
for (size_t k = 0; k < json_array_size(children_array); k++) {
group_obj = json_array_get(children_array, k);
if (strcmp(json_string_value(json_object_get(group_obj, "id")),
group_id) == 0) {
break;
}
group_obj = NULL;
}
if (!group_obj) {
group_obj = json_object();
json_object_set_new(group_obj, "id", json_string(group_id));
json_object_set_new(group_obj, "name", json_string(info->group));
json_object_set_new(group_obj, "category", json_integer(2));
json_t *group_children = json_array();
json_object_set_new(group_obj, "children", group_children);
json_array_append_new(children_array, group_obj);
}
json_t *tag_array = json_object_get(group_obj, "children");
if (info->tags) {
for (unsigned int j = 0; j < utarray_len(info->tags); j++) {
neu_datatag_t *tag =
(neu_datatag_t *) utarray_eltptr(info->tags, j);
char tag_id[37];
char tag_uuid_input[512];
snprintf(tag_uuid_input, sizeof(tag_uuid_input), "%s-%s-%s",
info->driver, info->group, tag->name);
generate_fixed_uuid(tag_uuid_input, tag_id);
json_t *tag_obj = json_object();
json_object_set_new(tag_obj, "id", json_string(tag_id));
json_object_set_new(tag_obj, "name", json_string(tag->name));
json_object_set_new(tag_obj, "type", json_integer(tag->type));
json_object_set_new(tag_obj, "category", json_integer(3));
json_object_set_new(tag_obj, "leaf", json_true());
json_object_set_new(tag_obj, "children", json_array());
json_array_append_new(tag_array, tag_obj);
}
}
}
json_t *final_obj = json_object();
json_object_set_new(final_obj, "error", json_integer(0));
json_object_set_new(final_obj, "children", node_array);
neu_json_elem_t elems[] = { {
.name = NULL,
.t = NEU_JSON_OBJECT,
.v.val_object = final_obj,
} };
int ret = neu_json_encode_field(json_object_param, elems,
NEU_JSON_ELEM_SIZE(elems));
json_decref(final_obj);
+2
View File
@@ -47,6 +47,8 @@ int neu_json_encode_datalayers_get_groups_resp(void *json_object, void *param);
int neu_json_encode_datalayers_get_tags_resp(void *json_object, void *param);
int neu_json_encode_datalayers_get_tag_resp(void *json_object, void *param);
#ifdef __cplusplus
}
#endif
+1 -1
View File
@@ -1 +1 @@
2.12.0-alpha
2.12.0