rename o2o and object2object to object_group
This commit is contained in:
@@ -31,7 +31,7 @@ A complete use case consists of three parts:
|
||||
|
||||
### Case1
|
||||
|
||||
In the scanning scenario, it is necessary to configure the schema of multiple tables, including the item table, object2rule table, and rule table. If there is also object nesting involved, the schema of the object2object table needs to be configured.
|
||||
In the scanning scenario, it is necessary to configure the schema of multiple tables, including the item table, object2rule table, and rule table. If there is also object nesting involved, the schema of the object_group table needs to be configured.
|
||||
|
||||
**(1) table schema**
|
||||
|
||||
@@ -67,8 +67,8 @@ Table schema is stored in a json file(such as table_info.json), which is loaded
|
||||
},
|
||||
{
|
||||
"table_id":2,
|
||||
"table_name":"OBJECT2OBJECT",
|
||||
"table_type":"object2object",
|
||||
"table_name":"OBJECT_GROUP",
|
||||
"table_type":"object_group",
|
||||
"valid_column":4,
|
||||
"custom": {
|
||||
"object_id":1,
|
||||
@@ -100,7 +100,7 @@ Configurations are stored in a json file(such as maat_json.json), which is loade
|
||||
{
|
||||
"rule_table": "RULE",
|
||||
"object2rule_table": "OBJECT2RULE",
|
||||
"object2object_table": "OBJECT2OBJECT",
|
||||
"object_group_table": "OBJECT_GROUP",
|
||||
"rules": [
|
||||
{
|
||||
"rule_id": 123,
|
||||
@@ -217,7 +217,7 @@ In the callback scenario, only the schema of the corresponding table needs to be
|
||||
{
|
||||
"rule_table": "RULE",
|
||||
"object2rule_table": "OBJECT2RULE",
|
||||
"object2object_table": "OBJECT2OBJECT",
|
||||
"object_group_table": "OBJECT_GROUP",
|
||||
"plugin_table": {
|
||||
"table_name": "TEST_IP_PLUGIN_WITH_EXDATA",
|
||||
"table_content": [
|
||||
|
||||
@@ -13,7 +13,7 @@ The types of physical tables are as follows:
|
||||
- [item table](#11-item-table)
|
||||
- [rule table](#12-rule-table)
|
||||
- [object2rule table](#13-object2rule-table)
|
||||
- [object2object table](#14-object2object-table)
|
||||
- [object_group table](#14-object_group-table)
|
||||
- [plugin table](#15-plugin-table)
|
||||
- [ip_plugin table](#16-ip_plugin-table)
|
||||
- [fqdn_plugin table](#17-fqdn_plugin-table)
|
||||
@@ -52,7 +52,7 @@ Describe matching rules for strings.
|
||||
| **FieldName** | **type** | **constraint** |
|
||||
| ---------------- | -------------- | ------- |
|
||||
| **item_id** | LONG LONG | primary key |
|
||||
| **object_id** | LONG LONG | leaf object id, can be referenced by object2object & object2rule table |
|
||||
| **object_id** | LONG LONG | leaf object id, can be referenced by object_group & object2rule table |
|
||||
| **keywords** | VARCHAR2(1024) | field to match during scanning |
|
||||
| **expr_type** | INT | 0(keywords), 1(AND expr), 2(regular expr), 3(substring with offset)
|
||||
| **match_method** | INT | only useful when expr_type is 0. 0(sub), 1(suffix), 2(prefix), 3(exactly) |
|
||||
@@ -158,7 +158,7 @@ Describe extended matching rules for strings by adding the district column.
|
||||
| **FieldName** | **type** | **constraint** |
|
||||
| ---------------- | -------------- | ------- |
|
||||
| **item_id** | LONG LONG | primary key |
|
||||
| **object_id** | LONG LONG | leaf object id, can be referenced by object2object & object2rule table |
|
||||
| **object_id** | LONG LONG | leaf object id, can be referenced by object_group & object2rule table |
|
||||
| **district** | VARCHAR2(1024) | describe the effective position of the keywords |
|
||||
| **keywords** | VARCHAR2(1024) | field to match during scanning |
|
||||
| **expr_type** | INT | 0(keywords), 1(AND expr), 2(regular expr), 3(substring with offset)
|
||||
@@ -183,7 +183,7 @@ Describe matching rules for IP address. Both the address and port are represente
|
||||
| **FieldName** | **type** | **constraint** |
|
||||
| -------------- | ------------ | -------------- |
|
||||
| **item_id** | LONG LONG | primary key |
|
||||
| **object_id** | LONG LONG | leaf object id, can be referenced by object2object & object2rule table |
|
||||
| **object_id** | LONG LONG | leaf object id, can be referenced by object_group & object2rule table |
|
||||
| **addr_type** | INT | Ipv4 = 4 Ipv6 = 6 |
|
||||
| **addr_format**| VARCHAR2(40) | ip addr format, single/range/CIDR/mask |
|
||||
| **ip1** | VARCHAR2(40) | start ip |
|
||||
@@ -197,7 +197,7 @@ Determine whether an integer is within a certain numerical range.
|
||||
| **FieldName** | **type** | **constraint** |
|
||||
| ---------------- | -------- | -------------- |
|
||||
| **item_id** | INT | primary key |
|
||||
| **object_id** | INT | leaf object id, can be referenced by object2object & object2rule table |
|
||||
| **object_id** | INT | leaf object id, can be referenced by object_group & object2rule table |
|
||||
| **low_boundary** | INT | lower bound of the numerical range(including lb), 0 ~ (2^32 - 1)|
|
||||
| **up_boundary** | INT | upper bound of the numerical range(including ub), 0 ~ (2^32 - 1)|
|
||||
| **is_valid** | INT | 0(invalid), 1(valid) |
|
||||
@@ -209,7 +209,7 @@ Describe extended matching rules for integer by adding the district column.
|
||||
| **FieldName** | **type** | **constraint** |
|
||||
| ---------------- | -------- | -------------- |
|
||||
| **item_id** | INT | primary key |
|
||||
| **object_id** | INT | leaf object id, can be referenced by object2object & object2rule table |
|
||||
| **object_id** | INT | leaf object id, can be referenced by object_group & object2rule table |
|
||||
| **district** | VARCHAR2(1024)| describe the effective position of the keywords |
|
||||
| **low_boundary** | INT | lower bound of the numerical range(including lb), 0 ~ (2^32 - 1)|
|
||||
| **up_boundary** | INT | upper bound of the numerical range(including ub), 0 ~ (2^32 - 1)|
|
||||
@@ -220,7 +220,7 @@ Describe extended matching rules for integer by adding the district column.
|
||||
| **FieldName** | **type** | **constraint** |
|
||||
| ------------- | -------- | -------------- |
|
||||
| **item_id** | INT | primary key |
|
||||
| **object_id** | INT | leaf object id, can be referenced by object2object & object2rule table |
|
||||
| **object_id** | INT | leaf object id, can be referenced by object_group & object2rule table |
|
||||
| **flag** | INT | flag, 0 ~ (2^32 - 1)|
|
||||
| **flag_mask** | INT | flag_mask, 0 ~ (2^32 - 1)|
|
||||
| **is_valid** | INT | 0(invalid), 1(valid) |
|
||||
@@ -230,7 +230,7 @@ Describe extended matching rules for integer by adding the district column.
|
||||
| **FieldName** | **type** | **constraint** |
|
||||
| ------------- | -------- | -------------- |
|
||||
| **item_id** | INT | primary key |
|
||||
| **object_id** | INT | leaf object id, can be referenced by object2object & object2rule table |
|
||||
| **object_id** | INT | leaf object id, can be referenced by object_group & object2rule table |
|
||||
| **district** | INT | describe the effective position of the flag |
|
||||
| **flag** | INT | flag, 0 ~ (2^32 - 1)|
|
||||
| **flag_mask** | INT | flag_mask, 0 ~ (2^32 - 1)|
|
||||
@@ -262,7 +262,7 @@ Describe the relationship between object and rule.
|
||||
|
||||
NOTE: If object_id is invalid in xx_item table, it must be marked as invalid in this table.
|
||||
|
||||
### 1.4 <a name='Object2ObjectTable'></a> object2object table
|
||||
### 1.4 <a name='Object2ObjectTable'></a> object_group table
|
||||
|
||||
Describe the relationship between objects.
|
||||
|
||||
@@ -402,7 +402,7 @@ Configuration tags are tags stored on compilation configurations or object confi
|
||||
|
||||
Maat loads the configuration of different types of tables into memory to form the corresponding runtime for each table. We can see all table types from the table schema, and the runtime for the item table is similar, as it is an abstraction of the scanning engine. When we provide the data to be scanned and call the corresponding scanning interface, we can return whether the item is hit or not, and if it is hit, we can return the corresponding item’s object_id.
|
||||
|
||||
From the [configuration relationship](./overview.md#12-configuration-relationship) diagram, we can see how the hit object is referenced by other objects or rules. If a hit object is referenced by other objects or rules, there will be one or more hit paths that follow the `item_id -> object_id` {-> super object_id} `-> rule_id`. This requires two special runtimes: object2object_runtime and rule_runtime.
|
||||
From the [configuration relationship](./overview.md#12-configuration-relationship) diagram, we can see how the hit object is referenced by other objects or rules. If a hit object is referenced by other objects or rules, there will be one or more hit paths that follow the `item_id -> object_id` {-> super object_id} `-> rule_id`. This requires two special runtimes: object_group_runtime and rule_runtime.
|
||||
|
||||
Based on this, we can divide the runtime into the following three categories:
|
||||
|
||||
@@ -413,7 +413,7 @@ Based on this, we can divide the runtime into the following three categories:
|
||||
* interval_runtime
|
||||
|
||||
2. object & rule table runtime
|
||||
* object2object_runtime
|
||||
* object_group_runtime
|
||||
* rule_runtime
|
||||
|
||||
3. xx_plugin table runtime
|
||||
@@ -433,9 +433,9 @@ Among the four types of runtimes mentioned above, `expr_runtime` is relatively u
|
||||
|
||||
### 2.2 object & rule table runtime
|
||||
|
||||
#### 2.2.1 object2object runtime
|
||||
#### 2.2.1 object_group runtime
|
||||
|
||||
The `object2object_runtime` is a runtime that is built based on the reference relationships between objects, which are stored in the [object2object table](#14-object2object-table). From the [object hierarchy](./object_hierarchy.md), we can understand that if a hit occurs in a leaf object that is referenced by other objects, there may be certain super objects that are also hit. This is exactly the functionality provided by this runtime.
|
||||
The `object_group_runtime` is a runtime that is built based on the reference relationships between objects, which are stored in the [object_group table](#14-object_group-table). From the [object hierarchy](./object_hierarchy.md), we can understand that if a hit occurs in a leaf object that is referenced by other objects, there may be certain super objects that are also hit. This is exactly the functionality provided by this runtime.
|
||||
|
||||
#### 2.2.2 rule runtime
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ As mentioned in the readme, maat has two typical usage patterns:
|
||||
|
||||
Different types of configurations are stored in different tables. For all configuration types, please refer to the [table schema](./maat_table.md#1-table-schema).
|
||||
|
||||
The physical tables are mainly divided into three categories: the item table, object rule relationship table (rule table, object2rule table, object2object table), and xx_plugin table. The first two types of tables are used for maat traffic scanning, while the xx_plugin table is used as a callback table, which can obtain the detailed configuration information for a specific key.
|
||||
The physical tables are mainly divided into three categories: the item table, object rule relationship table (rule table, object2rule table, object_group table), and xx_plugin table. The first two types of tables are used for maat traffic scanning, while the xx_plugin table is used as a callback table, which can obtain the detailed configuration information for a specific key.
|
||||
|
||||
### 1.2 Configuration relationship
|
||||
|
||||
@@ -56,7 +56,7 @@ The diagram illustrates the overall architecture of maat, including the control
|
||||
|
||||
* **Data Plane**
|
||||
|
||||
When calling the maat scanning interface, it subsequently calls the table runtime of the corresponding table, then proceeds to the scanning engine. Upon the scanning engine returning a hit object, it further searches for the matching `rule_id` through object2object runtime, object2rule runtime, and rule runtime, which is then returned to the caller. In addition, if the caller is interested in the hit path, they can also retrieve it through the interfaces provided by maat.
|
||||
When calling the maat scanning interface, it subsequently calls the table runtime of the corresponding table, then proceeds to the scanning engine. Upon the scanning engine returning a hit object, it further searches for the matching `rule_id` through object_group runtime, object2rule runtime, and rule runtime, which is then returned to the caller. In addition, if the caller is interested in the hit path, they can also retrieve it through the interfaces provided by maat.
|
||||
|
||||
The scanning mentioned above all uses the `effective runtime`. If there are configuration changes, it will trigger the construction of `updating runtime`. Once this construction is completed, it will become effective runtime, and the original effective runtime will be put into the garbage collection queue waiting to be recycled.
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ A object defines a set that can contain different types of items and can also re
|
||||
|
||||
- A Object can be referenced by different rules.
|
||||
|
||||
The relationship between object and object is stored in the [object2object table](./maat_table.md#14-object2object-table).
|
||||
The relationship between object and object is stored in the [object_group table](./maat_table.md#14-object_group-table).
|
||||
|
||||
## Rule(Policy)
|
||||
|
||||
@@ -68,7 +68,7 @@ A Literal consists of `attribute_id(attribute id)` and `object_id`. During the r
|
||||
|
||||
## Physical table
|
||||
|
||||
Different rules are stored in different tables in the actual database, including [item table](./maat_table.md#11-item-table), [rule table](./maat_table.md#12-rule-table), [object2rule table](./maat_table.md#13-object2rule-table), [object2object table](./maat_table.md#14-object2object-table), and [xx_plugin table](./maat_table.md#15-plugin-table), and so on.
|
||||
Different rules are stored in different tables in the actual database, including [item table](./maat_table.md#11-item-table), [rule table](./maat_table.md#12-rule-table), [object2rule table](./maat_table.md#13-object2rule-table), [object_group table](./maat_table.md#14-object_group-table), and [xx_plugin table](./maat_table.md#15-plugin-table), and so on.
|
||||
|
||||
## Attribute
|
||||
|
||||
|
||||
@@ -23,33 +23,33 @@ extern "C"
|
||||
#include "maat_table.h"
|
||||
|
||||
struct maat_object;
|
||||
struct object2object_runtime;
|
||||
struct object_group_runtime;
|
||||
|
||||
/* object2object schema API */
|
||||
void *object2object_schema_new(cJSON *json, struct table_manager *tbl_mgr,
|
||||
/* object_group schema API */
|
||||
void *object_group_schema_new(cJSON *json, struct table_manager *tbl_mgr,
|
||||
const char *table_name, struct log_handle *logger);
|
||||
void object2object_schema_free(void *o2o_schema);
|
||||
void object_group_schema_free(void *object_group_schema);
|
||||
|
||||
/* object2object runtime API */
|
||||
void *object2object_runtime_new(void *o2o_schema, size_t max_thread_num,
|
||||
/* object_group runtime API */
|
||||
void *object_group_runtime_new(void *object_group_schema, size_t max_thread_num,
|
||||
struct maat_garbage_bin *garbage_bin,
|
||||
struct log_handle *logger);
|
||||
void object2object_runtime_free(void *o2o_runtime);
|
||||
void object_group_runtime_free(void *object_group_runtime);
|
||||
|
||||
int object2object_runtime_update(void *o2o_runtime, void *o2o_schema, const char *table_name,
|
||||
int object_group_runtime_update(void *object_group_runtime, void *object_group_schema, const char *table_name,
|
||||
const char *line, enum maat_operation op);
|
||||
|
||||
int object2object_runtime_commit(void *o2o_runtime, const char *table_name, long long maat_rt_version);
|
||||
int object_group_runtime_commit(void *object_group_runtime, const char *table_name, long long maat_rt_version);
|
||||
|
||||
size_t object2object_runtime_get_super_objects(void *o2o_runtime, uuid_t *object_uuids,
|
||||
size_t object_group_runtime_get_super_objects(void *object_group_runtime, uuid_t *object_uuids,
|
||||
size_t n_object_uuids, uuid_t *super_object_uuids,
|
||||
size_t super_object_uuids_size);
|
||||
|
||||
long long object2object_runtime_rule_count(void *o2o_runtime);
|
||||
long long object_group_runtime_rule_count(void *object_group_runtime);
|
||||
|
||||
long long object2object_runtime_exclude_rule_count(void *o2o_runtime);
|
||||
long long object_group_runtime_exclude_rule_count(void *object_group_runtime);
|
||||
|
||||
long long object2object_runtime_update_err_count(void *o2o_runtime);
|
||||
long long object_group_runtime_update_err_count(void *object_group_runtime);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ extern "C"
|
||||
struct rule_schema;
|
||||
struct rule_runtime;
|
||||
struct rule_state;
|
||||
struct object2object_runtime;
|
||||
struct object_group_runtime;
|
||||
|
||||
/* rule schema API */
|
||||
void *rule_schema_new(cJSON *json, struct table_manager *tbl_mgr,
|
||||
@@ -81,7 +81,7 @@ void rule_compile_state_not_logic_update(struct rule_compile_state *rule_compile
|
||||
|
||||
size_t rule_compile_state_get_internal_hit_paths(struct rule_compile_state *rule_compile_state,
|
||||
struct rule_runtime *rule_rt,
|
||||
struct object2object_runtime *o2o_rt,
|
||||
struct object_group_runtime *object_group_rt,
|
||||
struct maat_hit_path *hit_path_array,
|
||||
size_t array_size);
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ enum table_type {
|
||||
TABLE_TYPE_BOOL_PLUGIN,
|
||||
//above are physical table
|
||||
TABLE_TYPE_RULE,
|
||||
TABLE_TYPE_OBJECT2OBJECT,
|
||||
TABLE_TYPE_OBJECT_GROUP,
|
||||
TABLE_TYPE_MAX
|
||||
};
|
||||
|
||||
@@ -81,7 +81,7 @@ const char *table_manager_get_table_schema_tag(struct table_manager *tbl_mgr, in
|
||||
enum table_type table_manager_get_table_type(struct table_manager *tbl_mgr, int table_id);
|
||||
|
||||
int table_manager_get_default_rule_table_id(struct table_manager *tbl_mgr);
|
||||
int table_manager_get_object2object_table_id(struct table_manager *tbl_mgr);
|
||||
int table_manager_get_object_group_table_id(struct table_manager *tbl_mgr);
|
||||
|
||||
enum maat_expr_engine table_manager_get_expr_engine(struct table_manager *tbl_mgr);
|
||||
|
||||
|
||||
@@ -2033,13 +2033,13 @@ int maat_state_get_hit_paths(struct maat_state *state, struct maat_hit_path *pat
|
||||
return -1;
|
||||
}
|
||||
|
||||
int o2o_table_id = table_manager_get_object2object_table_id(maat_inst->tbl_mgr);
|
||||
void *o2o_runtime = table_manager_get_runtime(maat_inst->tbl_mgr, o2o_table_id);
|
||||
int object_group_table_id = table_manager_get_object_group_table_id(maat_inst->tbl_mgr);
|
||||
void *object_group_runtime = table_manager_get_runtime(maat_inst->tbl_mgr, object_group_table_id);
|
||||
|
||||
size_t hit_path_cnt =
|
||||
rule_compile_state_get_internal_hit_paths(state->rule_compile_state,
|
||||
(struct rule_runtime *)rule_rt,
|
||||
(struct object2object_runtime *)o2o_runtime,
|
||||
(struct object_group_runtime *)object_group_runtime,
|
||||
path_array, array_size);
|
||||
|
||||
return rule_runtime_get_hit_paths((struct rule_runtime *)rule_rt,
|
||||
|
||||
@@ -139,7 +139,7 @@ void config_monitor_traverse(long long current_version, const cJSON *json_root,
|
||||
|
||||
cJSON *tmp_obj = NULL;
|
||||
cJSON *rule_table = cJSON_GetObjectItem(json_root, "rule_table");
|
||||
cJSON *object2object_table = cJSON_GetObjectItem(json_root, "object2object_table");
|
||||
cJSON *object_group_table = cJSON_GetObjectItem(json_root, "object_group_table");
|
||||
cJSON *plugin_table = cJSON_GetObjectItem(json_root, "plugin_table");
|
||||
|
||||
tmp_obj = cJSON_GetObjectItem(json_root, "items");
|
||||
@@ -167,8 +167,8 @@ void config_monitor_traverse(long long current_version, const cJSON *json_root,
|
||||
}
|
||||
}
|
||||
|
||||
if (object2object_table) {
|
||||
config_load_json_content(json_root, object2object_table->valuestring, "object_groups", u_param, update_fn);
|
||||
if (object_group_table) {
|
||||
config_load_json_content(json_root, object_group_table->valuestring, "object_groups", u_param, update_fn);
|
||||
}
|
||||
if (rule_table) {
|
||||
config_load_json_content(json_root, rule_table->valuestring, "rules", u_param, update_fn);
|
||||
|
||||
@@ -22,13 +22,13 @@
|
||||
|
||||
#define MODULE_OBJECT module_name_str("maat.object")
|
||||
|
||||
struct object2object_item {
|
||||
struct object_group_item {
|
||||
uuid_t object_uuid;
|
||||
UT_array *incl_sub_object_uuids;
|
||||
UT_array *excl_sub_object_uuids;
|
||||
};
|
||||
|
||||
struct object2object_schema {
|
||||
struct object_group_schema {
|
||||
int table_id;
|
||||
struct table_manager *ref_tbl_mgr;
|
||||
};
|
||||
@@ -57,11 +57,11 @@ struct maat_object_topology {
|
||||
struct log_handle *logger;
|
||||
};
|
||||
|
||||
struct object2object_runtime {
|
||||
struct object_group_runtime {
|
||||
struct maat_object_topology *object_topo;
|
||||
struct maat_object_topology *updating_object_topo;
|
||||
long long rule_num;
|
||||
long long excl_rule_num; //exclude o2o rule num
|
||||
long long excl_rule_num; //exclude object_group rule num
|
||||
long long update_err_cnt;
|
||||
int updating_flag;
|
||||
|
||||
@@ -76,31 +76,31 @@ static inline int compare_object_uuid(const void *a, const void *b)
|
||||
return uuid_compare(*(uuid_t *)a, *(uuid_t *)b);
|
||||
}
|
||||
|
||||
void *object2object_schema_new(cJSON *json, struct table_manager *tbl_mgr,
|
||||
void *object_group_schema_new(cJSON *json, struct table_manager *tbl_mgr,
|
||||
const char *table_name, struct log_handle *logger)
|
||||
{
|
||||
struct object2object_schema *o2o_schema = ALLOC(struct object2object_schema, 1);
|
||||
struct object_group_schema *object_group_schema = ALLOC(struct object_group_schema, 1);
|
||||
|
||||
cJSON *item = cJSON_GetObjectItem(json, "table_id");
|
||||
if (item != NULL && item->type == cJSON_Number) {
|
||||
o2o_schema->table_id = item->valueint;
|
||||
object_group_schema->table_id = item->valueint;
|
||||
} else {
|
||||
log_fatal(logger, MODULE_OBJECT,
|
||||
"[%s:%d] o2o table:<%s> schema has no table_id column",
|
||||
"[%s:%d] object_group table:<%s> schema has no table_id column",
|
||||
__FUNCTION__, __LINE__, table_name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
o2o_schema->ref_tbl_mgr = tbl_mgr;
|
||||
return o2o_schema;
|
||||
object_group_schema->ref_tbl_mgr = tbl_mgr;
|
||||
return object_group_schema;
|
||||
error:
|
||||
FREE(o2o_schema);
|
||||
FREE(object_group_schema);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void object2object_schema_free(void *o2o_schema)
|
||||
void object_group_schema_free(void *object_group_schema)
|
||||
{
|
||||
FREE(o2o_schema);
|
||||
FREE(object_group_schema);
|
||||
}
|
||||
|
||||
static void object_vertex_free(struct maat_object *object)
|
||||
@@ -231,46 +231,46 @@ maat_object_topology_clone(struct maat_object_topology *object_topo)
|
||||
return object_topo_copy;
|
||||
}
|
||||
|
||||
void *object2object_runtime_new(void *o2o_schema, size_t max_thread_num,
|
||||
void *object_group_runtime_new(void *object_group_schema, size_t max_thread_num,
|
||||
struct maat_garbage_bin *garbage_bin,
|
||||
struct log_handle *logger)
|
||||
{
|
||||
if (NULL == o2o_schema) {
|
||||
if (NULL == object_group_schema) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct object2object_runtime *o2o_rt = ALLOC(struct object2object_runtime, 1);
|
||||
struct object_group_runtime *object_group_rt = ALLOC(struct object_group_runtime, 1);
|
||||
|
||||
o2o_rt->object_topo = maat_object_topology_new(logger);
|
||||
o2o_rt->ref_garbage_bin = garbage_bin;
|
||||
o2o_rt->logger = logger;
|
||||
object_group_rt->object_topo = maat_object_topology_new(logger);
|
||||
object_group_rt->ref_garbage_bin = garbage_bin;
|
||||
object_group_rt->logger = logger;
|
||||
|
||||
return o2o_rt;
|
||||
return object_group_rt;
|
||||
}
|
||||
|
||||
void object2object_runtime_free(void *o2o_runtime)
|
||||
void object_group_runtime_free(void *object_group_runtime)
|
||||
{
|
||||
if (NULL == o2o_runtime) {
|
||||
if (NULL == object_group_runtime) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct object2object_runtime *o2o_rt = (struct object2object_runtime *)o2o_runtime;
|
||||
struct object_group_runtime *object_group_rt = (struct object_group_runtime *)object_group_runtime;
|
||||
|
||||
if (o2o_rt->object_topo != NULL) {
|
||||
maat_object_topology_free(o2o_rt->object_topo);
|
||||
o2o_rt->object_topo = NULL;
|
||||
if (object_group_rt->object_topo != NULL) {
|
||||
maat_object_topology_free(object_group_rt->object_topo);
|
||||
object_group_rt->object_topo = NULL;
|
||||
}
|
||||
|
||||
if (o2o_rt->updating_object_topo != NULL) {
|
||||
maat_object_topology_free(o2o_rt->updating_object_topo);
|
||||
o2o_rt->updating_object_topo = NULL;
|
||||
if (object_group_rt->updating_object_topo != NULL) {
|
||||
maat_object_topology_free(object_group_rt->updating_object_topo);
|
||||
object_group_rt->updating_object_topo = NULL;
|
||||
}
|
||||
|
||||
FREE(o2o_rt);
|
||||
FREE(object_group_rt);
|
||||
}
|
||||
|
||||
static struct object2object_item *
|
||||
object2object_item_new(const char *line, struct object2object_schema *o2o_schema,
|
||||
static struct object_group_item *
|
||||
object_group_item_new(const char *line, struct object_group_schema *object_group_schema,
|
||||
const char *table_name, struct log_handle *logger)
|
||||
{
|
||||
cJSON *tmp_obj = NULL;
|
||||
@@ -278,29 +278,29 @@ object2object_item_new(const char *line, struct object2object_schema *o2o_schema
|
||||
|
||||
if (json == NULL) {
|
||||
log_fatal(logger, MODULE_OBJECT,
|
||||
"[%s:%d] o2o table:<%s> line:<%s> parse json failed",
|
||||
"[%s:%d] object_group table:<%s> line:<%s> parse json failed",
|
||||
__FUNCTION__, __LINE__, table_name, line);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct object2object_item *o2o_item = ALLOC(struct object2object_item, 1);
|
||||
utarray_new(o2o_item->incl_sub_object_uuids, &ut_object_uuid_icd);
|
||||
utarray_new(o2o_item->excl_sub_object_uuids, &ut_object_uuid_icd);
|
||||
struct object_group_item *object_group_item = ALLOC(struct object_group_item, 1);
|
||||
utarray_new(object_group_item->incl_sub_object_uuids, &ut_object_uuid_icd);
|
||||
utarray_new(object_group_item->excl_sub_object_uuids, &ut_object_uuid_icd);
|
||||
|
||||
tmp_obj = cJSON_GetObjectItem(json, "object_uuid");
|
||||
if (tmp_obj == NULL || tmp_obj->type != cJSON_String) {
|
||||
log_fatal(logger, MODULE_OBJECT,
|
||||
"[%s:%d] o2o table:<%s> has no object_uuid or format is not string in line:%s",
|
||||
"[%s:%d] object_group table:<%s> has no object_uuid or format is not string in line:%s",
|
||||
__FUNCTION__, __LINE__, table_name, line);
|
||||
goto error;
|
||||
}
|
||||
uuid_parse(tmp_obj->valuestring, o2o_item->object_uuid);
|
||||
uuid_parse(tmp_obj->valuestring, object_group_item->object_uuid);
|
||||
|
||||
tmp_obj = cJSON_GetObjectItem(json, "included_sub_object_uuids");
|
||||
if (tmp_obj) {
|
||||
if (tmp_obj->type != cJSON_Array) {
|
||||
log_fatal(logger, MODULE_OBJECT,
|
||||
"[%s:%d] o2o table:<%s> included_sub_object_ids format is not array in line:%s",
|
||||
"[%s:%d] object_group table:<%s> included_sub_object_ids format is not array in line:%s",
|
||||
__FUNCTION__, __LINE__, table_name, line);
|
||||
goto error;
|
||||
}
|
||||
@@ -309,16 +309,16 @@ object2object_item_new(const char *line, struct object2object_schema *o2o_schema
|
||||
cJSON *item = cJSON_GetArrayItem(tmp_obj, i);
|
||||
if (item == NULL || item->type != cJSON_String) {
|
||||
log_fatal(logger, MODULE_OBJECT,
|
||||
"[%s:%d] o2o table:<%s> included_sub_object_ids format error in line:%s",
|
||||
"[%s:%d] object_group table:<%s> included_sub_object_ids format error in line:%s",
|
||||
__FUNCTION__, __LINE__, table_name, line);
|
||||
goto error;
|
||||
}
|
||||
uuid_t object_uuid;
|
||||
uuid_parse(item->valuestring, object_uuid);
|
||||
utarray_push_back(o2o_item->incl_sub_object_uuids, &object_uuid);
|
||||
utarray_push_back(object_group_item->incl_sub_object_uuids, &object_uuid);
|
||||
}
|
||||
|
||||
if (utarray_len(o2o_item->incl_sub_object_uuids) > MAX_OBJECT_CNT) {
|
||||
if (utarray_len(object_group_item->incl_sub_object_uuids) > MAX_OBJECT_CNT) {
|
||||
log_fatal(logger, MODULE_OBJECT,
|
||||
"[%s:%d] o2r table:<%s> included_sub_object_ids exceed maximum:%d in line:%s",
|
||||
__FUNCTION__, __LINE__, table_name, MAX_OBJECT_CNT, line);
|
||||
@@ -330,7 +330,7 @@ object2object_item_new(const char *line, struct object2object_schema *o2o_schema
|
||||
if (tmp_obj) {
|
||||
if (tmp_obj->type != cJSON_Array) {
|
||||
log_fatal(logger, MODULE_OBJECT,
|
||||
"[%s:%d] o2o table:<%s> excluded_sub_object_ids format is not array in line:%s",
|
||||
"[%s:%d] object_group table:<%s> excluded_sub_object_ids format is not array in line:%s",
|
||||
__FUNCTION__, __LINE__, table_name, line);
|
||||
goto error;
|
||||
}
|
||||
@@ -339,16 +339,16 @@ object2object_item_new(const char *line, struct object2object_schema *o2o_schema
|
||||
cJSON *item = cJSON_GetArrayItem(tmp_obj, i);
|
||||
if (item == NULL || item->type != cJSON_String) {
|
||||
log_fatal(logger, MODULE_OBJECT,
|
||||
"[%s:%d] o2o table:<%s> excluded_sub_object_ids format error in line:%s",
|
||||
"[%s:%d] object_group table:<%s> excluded_sub_object_ids format error in line:%s",
|
||||
__FUNCTION__, __LINE__, table_name, line);
|
||||
goto error;
|
||||
}
|
||||
uuid_t object_uuid;
|
||||
uuid_parse(item->valuestring, object_uuid);
|
||||
utarray_push_back(o2o_item->excl_sub_object_uuids, &object_uuid);
|
||||
utarray_push_back(object_group_item->excl_sub_object_uuids, &object_uuid);
|
||||
}
|
||||
|
||||
if (utarray_len(o2o_item->excl_sub_object_uuids) > MAX_OBJECT_CNT) {
|
||||
if (utarray_len(object_group_item->excl_sub_object_uuids) > MAX_OBJECT_CNT) {
|
||||
log_fatal(logger, MODULE_OBJECT,
|
||||
"[%s:%d] o2r table:<%s> excluded_sub_object_ids exceed maximum:%d in line:%s",
|
||||
__FUNCTION__, __LINE__, table_name, MAX_OBJECT_CNT, line);
|
||||
@@ -358,32 +358,32 @@ object2object_item_new(const char *line, struct object2object_schema *o2o_schema
|
||||
|
||||
cJSON_Delete(json);
|
||||
|
||||
return o2o_item;
|
||||
return object_group_item;
|
||||
error:
|
||||
if (json) {
|
||||
cJSON_Delete(json);
|
||||
}
|
||||
FREE(o2o_item);
|
||||
FREE(object_group_item);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void object2object_item_free(struct object2object_item *o2o_item)
|
||||
static void object_group_item_free(struct object_group_item *object_group_item)
|
||||
{
|
||||
if (NULL == o2o_item) {
|
||||
if (NULL == object_group_item) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (o2o_item->incl_sub_object_uuids != NULL) {
|
||||
utarray_free(o2o_item->incl_sub_object_uuids);
|
||||
o2o_item->incl_sub_object_uuids = NULL;
|
||||
if (object_group_item->incl_sub_object_uuids != NULL) {
|
||||
utarray_free(object_group_item->incl_sub_object_uuids);
|
||||
object_group_item->incl_sub_object_uuids = NULL;
|
||||
}
|
||||
|
||||
if (o2o_item->excl_sub_object_uuids != NULL) {
|
||||
utarray_free(o2o_item->excl_sub_object_uuids);
|
||||
o2o_item->excl_sub_object_uuids = NULL;
|
||||
if (object_group_item->excl_sub_object_uuids != NULL) {
|
||||
utarray_free(object_group_item->excl_sub_object_uuids);
|
||||
object_group_item->excl_sub_object_uuids = NULL;
|
||||
}
|
||||
|
||||
FREE(o2o_item);
|
||||
FREE(object_group_item);
|
||||
}
|
||||
|
||||
static size_t print_igraph_vector(igraph_vector_t *v, char *buff, size_t sz) {
|
||||
@@ -725,29 +725,29 @@ static int object_topology_build_super_objects(struct maat_object_topology *obje
|
||||
return 0;
|
||||
}
|
||||
|
||||
int object2object_runtime_update(void *o2o_runtime, void *o2o_schema,
|
||||
int object_group_runtime_update(void *object_group_runtime, void *object_group_schema,
|
||||
const char *table_name, const char *line,
|
||||
enum maat_operation op)
|
||||
{
|
||||
if (NULL == o2o_runtime || NULL == o2o_schema ||
|
||||
if (NULL == object_group_runtime || NULL == object_group_schema ||
|
||||
NULL == line) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct object2object_schema *schema = (struct object2object_schema *)o2o_schema;
|
||||
struct object2object_runtime *o2o_rt = (struct object2object_runtime *)o2o_runtime;
|
||||
struct object_group_schema *schema = (struct object_group_schema *)object_group_schema;
|
||||
struct object_group_runtime *object_group_rt = (struct object_group_runtime *)object_group_runtime;
|
||||
|
||||
struct object2object_item *o2o_item = object2object_item_new(line, schema, table_name,
|
||||
o2o_rt->logger);
|
||||
if (NULL == o2o_item) {
|
||||
o2o_rt->update_err_cnt++;
|
||||
struct object_group_item *object_group_item = object_group_item_new(line, schema, table_name,
|
||||
object_group_rt->logger);
|
||||
if (NULL == object_group_item) {
|
||||
object_group_rt->update_err_cnt++;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (0 == o2o_rt->updating_flag) {
|
||||
assert(o2o_rt->updating_object_topo == NULL);
|
||||
o2o_rt->updating_object_topo = maat_object_topology_clone(o2o_rt->object_topo);
|
||||
o2o_rt->updating_flag = 1;
|
||||
if (0 == object_group_rt->updating_flag) {
|
||||
assert(object_group_rt->updating_object_topo == NULL);
|
||||
object_group_rt->updating_object_topo = maat_object_topology_clone(object_group_rt->object_topo);
|
||||
object_group_rt->updating_flag = 1;
|
||||
}
|
||||
|
||||
int ret = 0;
|
||||
@@ -756,62 +756,62 @@ int object2object_runtime_update(void *o2o_runtime, void *o2o_schema,
|
||||
uuid_t *sub_object_uuid = NULL;
|
||||
if (MAAT_OP_DEL == op) {
|
||||
//delete
|
||||
for (i = 0; i < utarray_len(o2o_item->incl_sub_object_uuids); i++) {
|
||||
sub_object_uuid = (uuid_t *)utarray_eltptr(o2o_item->incl_sub_object_uuids, i);
|
||||
ret = object_topology_del_object_from_object(o2o_rt->updating_object_topo,
|
||||
&o2o_item->object_uuid, sub_object_uuid, 0);
|
||||
for (i = 0; i < utarray_len(object_group_item->incl_sub_object_uuids); i++) {
|
||||
sub_object_uuid = (uuid_t *)utarray_eltptr(object_group_item->incl_sub_object_uuids, i);
|
||||
ret = object_topology_del_object_from_object(object_group_rt->updating_object_topo,
|
||||
&object_group_item->object_uuid, sub_object_uuid, 0);
|
||||
if (ret != 0) {
|
||||
err_flag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < utarray_len(o2o_item->excl_sub_object_uuids); i++) {
|
||||
sub_object_uuid = (uuid_t *)utarray_eltptr(o2o_item->excl_sub_object_uuids, i);
|
||||
ret = object_topology_del_object_from_object(o2o_rt->updating_object_topo,
|
||||
&o2o_item->object_uuid, sub_object_uuid, 1);
|
||||
for (i = 0; i < utarray_len(object_group_item->excl_sub_object_uuids); i++) {
|
||||
sub_object_uuid = (uuid_t *)utarray_eltptr(object_group_item->excl_sub_object_uuids, i);
|
||||
ret = object_topology_del_object_from_object(object_group_rt->updating_object_topo,
|
||||
&object_group_item->object_uuid, sub_object_uuid, 1);
|
||||
if (ret != 0) {
|
||||
err_flag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (1 == err_flag) {
|
||||
o2o_rt->update_err_cnt++;
|
||||
object_group_rt->update_err_cnt++;
|
||||
} else {
|
||||
if (utarray_len(o2o_item->excl_sub_object_uuids) > 0) {
|
||||
o2o_rt->excl_rule_num--;
|
||||
if (utarray_len(object_group_item->excl_sub_object_uuids) > 0) {
|
||||
object_group_rt->excl_rule_num--;
|
||||
}
|
||||
o2o_rt->rule_num--;
|
||||
object_group_rt->rule_num--;
|
||||
}
|
||||
} else {
|
||||
//add
|
||||
for (i = 0; i < utarray_len(o2o_item->incl_sub_object_uuids); i++) {
|
||||
sub_object_uuid = (uuid_t *)utarray_eltptr(o2o_item->incl_sub_object_uuids, i);
|
||||
ret = object_topology_add_object_to_object(o2o_rt->updating_object_topo,
|
||||
&o2o_item->object_uuid, sub_object_uuid, 0);
|
||||
for (i = 0; i < utarray_len(object_group_item->incl_sub_object_uuids); i++) {
|
||||
sub_object_uuid = (uuid_t *)utarray_eltptr(object_group_item->incl_sub_object_uuids, i);
|
||||
ret = object_topology_add_object_to_object(object_group_rt->updating_object_topo,
|
||||
&object_group_item->object_uuid, sub_object_uuid, 0);
|
||||
if (ret != 0) {
|
||||
err_flag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < utarray_len(o2o_item->excl_sub_object_uuids); i++) {
|
||||
sub_object_uuid = (uuid_t *)utarray_eltptr(o2o_item->excl_sub_object_uuids, i);
|
||||
ret = object_topology_add_object_to_object(o2o_rt->updating_object_topo,
|
||||
&o2o_item->object_uuid, sub_object_uuid, 1);
|
||||
for (i = 0; i < utarray_len(object_group_item->excl_sub_object_uuids); i++) {
|
||||
sub_object_uuid = (uuid_t *)utarray_eltptr(object_group_item->excl_sub_object_uuids, i);
|
||||
ret = object_topology_add_object_to_object(object_group_rt->updating_object_topo,
|
||||
&object_group_item->object_uuid, sub_object_uuid, 1);
|
||||
if (ret != 0) {
|
||||
err_flag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (1 == err_flag) {
|
||||
o2o_rt->update_err_cnt++;
|
||||
object_group_rt->update_err_cnt++;
|
||||
} else {
|
||||
if (utarray_len(o2o_item->excl_sub_object_uuids) > 0) {
|
||||
o2o_rt->excl_rule_num++;
|
||||
if (utarray_len(object_group_item->excl_sub_object_uuids) > 0) {
|
||||
object_group_rt->excl_rule_num++;
|
||||
}
|
||||
o2o_rt->rule_num++;
|
||||
object_group_rt->rule_num++;
|
||||
}
|
||||
}
|
||||
object2object_item_free(o2o_item);
|
||||
object_group_item_free(object_group_item);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -822,43 +822,43 @@ static void garbage_maat_object_topology_free(void *data, void *arg)
|
||||
maat_object_topology_free(object_topo);
|
||||
}
|
||||
|
||||
int object2object_runtime_commit(void *o2o_runtime, const char *table_name,
|
||||
int object_group_runtime_commit(void *object_group_runtime, const char *table_name,
|
||||
long long maat_rt_version)
|
||||
{
|
||||
if (NULL == o2o_runtime) {
|
||||
if (NULL == object_group_runtime) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct object2object_runtime *o2o_rt = (struct object2object_runtime *)o2o_runtime;
|
||||
if (0 == o2o_rt->updating_flag) {
|
||||
struct object_group_runtime *object_group_rt = (struct object_group_runtime *)object_group_runtime;
|
||||
if (0 == object_group_rt->updating_flag) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct timespec start, end;
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
int ret = object_topology_build_super_objects(o2o_rt->updating_object_topo);
|
||||
int ret = object_topology_build_super_objects(object_group_rt->updating_object_topo);
|
||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||
long long time_elapse_ms = (end.tv_sec - start.tv_sec) * 1000 +
|
||||
(end.tv_nsec - start.tv_nsec) / 1000000;
|
||||
|
||||
if (ret < 0) {
|
||||
log_fatal(o2o_rt->logger, MODULE_OBJECT,
|
||||
"[%s:%d] table[%s] object2object runtime commit failed",
|
||||
log_fatal(object_group_rt->logger, MODULE_OBJECT,
|
||||
"[%s:%d] table[%s] object_group runtime commit failed",
|
||||
__FUNCTION__, __LINE__, table_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct maat_object_topology *old_object_topo = o2o_rt->object_topo;
|
||||
o2o_rt->object_topo = o2o_rt->updating_object_topo;
|
||||
o2o_rt->updating_object_topo = NULL;
|
||||
o2o_rt->updating_flag = 0;
|
||||
struct maat_object_topology *old_object_topo = object_group_rt->object_topo;
|
||||
object_group_rt->object_topo = object_group_rt->updating_object_topo;
|
||||
object_group_rt->updating_object_topo = NULL;
|
||||
object_group_rt->updating_flag = 0;
|
||||
|
||||
maat_garbage_bagging(o2o_rt->ref_garbage_bin, old_object_topo, NULL,
|
||||
maat_garbage_bagging(object_group_rt->ref_garbage_bin, old_object_topo, NULL,
|
||||
garbage_maat_object_topology_free);
|
||||
|
||||
log_info(o2o_rt->logger, MODULE_OBJECT,
|
||||
"table[%s] commit %zu o2o rules and rebuild super_objects completed,"
|
||||
" version:%lld, consume:%lldms", table_name, o2o_rt->rule_num,
|
||||
log_info(object_group_rt->logger, MODULE_OBJECT,
|
||||
"table[%s] commit %zu object_group rules and rebuild super_objects completed,"
|
||||
" version:%lld, consume:%lldms", table_name, object_group_rt->rule_num,
|
||||
maat_rt_version, time_elapse_ms);
|
||||
|
||||
return 0;
|
||||
@@ -876,7 +876,7 @@ static void get_candidate_super_object_ids(struct maat_object_topology *object_t
|
||||
p = (uuid_t *)utarray_next(hit_object_uuids, p)) {
|
||||
struct maat_object *object = object_topology_find_object(object_topo, p);
|
||||
if (NULL == object) {
|
||||
//object_id not in object2object table
|
||||
//object_id not in object_group table
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1170,61 +1170,61 @@ static size_t object_topology_get_super_objects(struct maat_object_topology *obj
|
||||
return idx;
|
||||
}
|
||||
|
||||
size_t object2object_runtime_get_super_objects(void *o2o_runtime, uuid_t *object_uuids,
|
||||
size_t object_group_runtime_get_super_objects(void *object_group_runtime, uuid_t *object_uuids,
|
||||
size_t n_object_uuids, uuid_t *super_object_uuids,
|
||||
size_t super_object_uuids_size)
|
||||
{
|
||||
if (NULL == o2o_runtime || NULL == object_uuids || 0 == n_object_uuids) {
|
||||
if (NULL == object_group_runtime || NULL == object_uuids || 0 == n_object_uuids) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct object2object_runtime *o2o_rt = (struct object2object_runtime *)o2o_runtime;
|
||||
uuid_t o2o_object_uuids[n_object_uuids];
|
||||
size_t o2o_object_uuids_cnt = 0;
|
||||
struct object_group_runtime *object_group_rt = (struct object_group_runtime *)object_group_runtime;
|
||||
uuid_t object_group_object_uuids[n_object_uuids];
|
||||
size_t object_group_object_uuids_cnt = 0;
|
||||
|
||||
for (size_t i = 0; i < n_object_uuids; i++) {
|
||||
struct maat_object *object = object_topology_find_object(o2o_rt->object_topo, &object_uuids[i]);
|
||||
struct maat_object *object = object_topology_find_object(object_group_rt->object_topo, &object_uuids[i]);
|
||||
if (NULL == object) {
|
||||
continue;
|
||||
}
|
||||
|
||||
uuid_copy(o2o_object_uuids[o2o_object_uuids_cnt++], object_uuids[i]);
|
||||
uuid_copy(object_group_object_uuids[object_group_object_uuids_cnt++], object_uuids[i]);
|
||||
}
|
||||
|
||||
if (0 == o2o_object_uuids_cnt) {
|
||||
if (0 == object_group_object_uuids_cnt) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return object_topology_get_super_objects(o2o_rt->object_topo, o2o_object_uuids, o2o_object_uuids_cnt,
|
||||
return object_topology_get_super_objects(object_group_rt->object_topo, object_group_object_uuids, object_group_object_uuids_cnt,
|
||||
super_object_uuids, super_object_uuids_size);
|
||||
}
|
||||
|
||||
long long object2object_runtime_rule_count(void *o2o_runtime)
|
||||
long long object_group_runtime_rule_count(void *object_group_runtime)
|
||||
{
|
||||
if (NULL == o2o_runtime) {
|
||||
if (NULL == object_group_runtime) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct object2object_runtime *o2o_rt = (struct object2object_runtime *)o2o_runtime;
|
||||
return o2o_rt->rule_num;
|
||||
struct object_group_runtime *object_group_rt = (struct object_group_runtime *)object_group_runtime;
|
||||
return object_group_rt->rule_num;
|
||||
}
|
||||
|
||||
long long object2object_runtime_exclude_rule_count(void *o2o_runtime)
|
||||
long long object_group_runtime_exclude_rule_count(void *object_group_runtime)
|
||||
{
|
||||
if (NULL == o2o_runtime) {
|
||||
if (NULL == object_group_runtime) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct object2object_runtime *o2o_rt = (struct object2object_runtime *)o2o_runtime;
|
||||
return o2o_rt->excl_rule_num;
|
||||
struct object_group_runtime *object_group_rt = (struct object_group_runtime *)object_group_runtime;
|
||||
return object_group_rt->excl_rule_num;
|
||||
}
|
||||
|
||||
long long object2object_runtime_update_err_count(void *o2o_runtime)
|
||||
long long object_group_runtime_update_err_count(void *object_group_runtime)
|
||||
{
|
||||
if (NULL == o2o_runtime) {
|
||||
if (NULL == object_group_runtime) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct object2object_runtime *o2o_rt = (struct object2object_runtime *)o2o_runtime;
|
||||
return o2o_rt->update_err_cnt;
|
||||
struct object_group_runtime *object_group_rt = (struct object_group_runtime *)object_group_runtime;
|
||||
return object_group_rt->update_err_cnt;
|
||||
}
|
||||
@@ -1767,11 +1767,11 @@ int rule_compile_state_update(struct rule_compile_state *rule_compile_state, str
|
||||
utarray_push_back(rule_compile_state->last_hit_objects, &hit_object);
|
||||
}
|
||||
|
||||
int o2o_table_id = table_manager_get_object2object_table_id(maat_inst->tbl_mgr);
|
||||
void *o2o_rt = table_manager_get_runtime(maat_inst->tbl_mgr, o2o_table_id);
|
||||
int object_group_table_id = table_manager_get_object_group_table_id(maat_inst->tbl_mgr);
|
||||
void *object_group_rt = table_manager_get_runtime(maat_inst->tbl_mgr, object_group_table_id);
|
||||
|
||||
uuid_t super_object_uuids[MAX_HIT_OBJECT_NUM];
|
||||
size_t super_object_cnt = object2object_runtime_get_super_objects(o2o_rt, hit_object_uuids,
|
||||
size_t super_object_cnt = object_group_runtime_get_super_objects(object_group_rt, hit_object_uuids,
|
||||
hit_cnt, super_object_uuids,
|
||||
MAX_HIT_OBJECT_NUM);
|
||||
for (i = 0; i < super_object_cnt; i++) {
|
||||
@@ -1944,7 +1944,7 @@ size_t rule_compile_state_get_direct_hit_object_cnt(struct rule_compile_state *r
|
||||
|
||||
size_t rule_compile_state_get_internal_hit_paths(struct rule_compile_state *rule_compile_state,
|
||||
struct rule_runtime *rule_rt,
|
||||
struct object2object_runtime *o2o_rt,
|
||||
struct object_group_runtime *object_group_rt,
|
||||
struct maat_hit_path *hit_path_array,
|
||||
size_t array_size)
|
||||
{
|
||||
@@ -1962,7 +1962,7 @@ size_t rule_compile_state_get_internal_hit_paths(struct rule_compile_state *rule
|
||||
utarray_new(valid_super_object_uuids, &ut_rule_object_uuid_icd);
|
||||
|
||||
size_t super_object_cnt =
|
||||
object2object_runtime_get_super_objects(o2o_rt, &(internal_path->object_uuid), 1,
|
||||
object_group_runtime_get_super_objects(object_group_rt, &(internal_path->object_uuid), 1,
|
||||
super_object_uuids, MAX_HIT_OBJECT_NUM);
|
||||
for (size_t idx = 0; idx < super_object_cnt; idx++) {
|
||||
utarray_push_back(valid_super_object_uuids, &super_object_uuids[idx]);
|
||||
|
||||
@@ -244,7 +244,7 @@ static void fs_table_row_refresh(struct maat_stat *stat, int perf_on)
|
||||
long long total_rule_num = 0, total_scan_bytes = 0, total_update_err = 0;
|
||||
long long total_scan_times = 0, total_hit_times = 0, total_scan_cpu_time = 0;
|
||||
long long total_regv6_num = 0, total_hit_item_num = 0, total_hit_pattern_num = 0;
|
||||
long long o2r_not_condition_num = 0, o2o_excl_rule_num = 0;
|
||||
long long o2r_not_condition_num = 0, object_group_excl_rule_num = 0;
|
||||
struct field cell_tag = {
|
||||
.key = "TBL",
|
||||
.type = FIELD_VALUE_CSTRING
|
||||
@@ -272,8 +272,8 @@ static void fs_table_row_refresh(struct maat_stat *stat, int perf_on)
|
||||
plugin_cache_num += plugin_runtime_cached_row_count(runtime);
|
||||
plugin_rule_num += plugin_runtime_rule_count(runtime);
|
||||
break;
|
||||
case TABLE_TYPE_OBJECT2OBJECT:
|
||||
o2o_excl_rule_num += object2object_runtime_exclude_rule_count(runtime);
|
||||
case TABLE_TYPE_OBJECT_GROUP:
|
||||
object_group_excl_rule_num += object_group_runtime_exclude_rule_count(runtime);
|
||||
break;
|
||||
case TABLE_TYPE_EXPR:
|
||||
regex_rule_num = expr_runtime_regex_rule_count(runtime);
|
||||
@@ -414,7 +414,7 @@ static void fs_table_row_refresh(struct maat_stat *stat, int perf_on)
|
||||
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->g_metric_id[STATUS_OBJECT_REF_EXCL_NUM],
|
||||
NULL, 0, o2o_excl_rule_num);
|
||||
NULL, 0, object_group_excl_rule_num);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ struct table_manager {
|
||||
|
||||
enum expr_engine_type engine_type;
|
||||
int default_rule_table_id;
|
||||
int o2o_table_id;
|
||||
int object_group_table_id;
|
||||
struct maat_kv_store *tbl_name2id_map;
|
||||
struct maat_kv_store *conj_tbl_name2id_map;
|
||||
|
||||
@@ -233,15 +233,15 @@ struct table_operations table_ops[TABLE_TYPE_MAX] = {
|
||||
.update_err_count = rule_runtime_update_err_count
|
||||
},
|
||||
{
|
||||
.type = TABLE_TYPE_OBJECT2OBJECT,
|
||||
.new_schema = object2object_schema_new,
|
||||
.free_schema = object2object_schema_free,
|
||||
.new_runtime = object2object_runtime_new,
|
||||
.free_runtime = object2object_runtime_free,
|
||||
.update_runtime = object2object_runtime_update,
|
||||
.commit_runtime = object2object_runtime_commit,
|
||||
.rule_count = object2object_runtime_rule_count,
|
||||
.update_err_count = object2object_runtime_update_err_count
|
||||
.type = TABLE_TYPE_OBJECT_GROUP,
|
||||
.new_schema = object_group_schema_new,
|
||||
.free_schema = object_group_schema_free,
|
||||
.new_runtime = object_group_runtime_new,
|
||||
.free_runtime = object_group_runtime_free,
|
||||
.update_runtime = object_group_runtime_update,
|
||||
.commit_runtime = object_group_runtime_commit,
|
||||
.rule_count = object_group_runtime_rule_count,
|
||||
.update_err_count = object_group_runtime_update_err_count
|
||||
}
|
||||
};
|
||||
|
||||
@@ -433,7 +433,7 @@ static void maat_table_schema_free(void *schema, enum table_type table_type)
|
||||
static void register_reserved_word(struct maat_kv_store *reserved_word_map)
|
||||
{
|
||||
maat_kv_register(reserved_word_map, "rule", TABLE_TYPE_RULE);
|
||||
maat_kv_register(reserved_word_map, "object2object", TABLE_TYPE_OBJECT2OBJECT);
|
||||
maat_kv_register(reserved_word_map, "object_group", TABLE_TYPE_OBJECT_GROUP);
|
||||
maat_kv_register(reserved_word_map, "flag", TABLE_TYPE_FLAG);
|
||||
maat_kv_register(reserved_word_map, "expr", TABLE_TYPE_EXPR);
|
||||
maat_kv_register(reserved_word_map, "interval", TABLE_TYPE_INTERVAL);
|
||||
@@ -784,7 +784,7 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
|
||||
}
|
||||
|
||||
int default_rule_table_id = -1;
|
||||
int o2o_table_id = -1;
|
||||
int object_group_table_id = -1;
|
||||
struct maat_kv_store *reserved_word_map = maat_kv_store_new();
|
||||
register_reserved_word(reserved_word_map);
|
||||
|
||||
@@ -821,8 +821,8 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
|
||||
}
|
||||
}
|
||||
|
||||
if (maat_tbl->table_type == TABLE_TYPE_OBJECT2OBJECT) {
|
||||
o2o_table_id = maat_tbl->table_id;
|
||||
if (maat_tbl->table_type == TABLE_TYPE_OBJECT_GROUP) {
|
||||
object_group_table_id = maat_tbl->table_id;
|
||||
}
|
||||
|
||||
tbl_mgr->tbl[maat_tbl->table_id] = maat_tbl;
|
||||
@@ -835,10 +835,10 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
|
||||
}
|
||||
|
||||
tbl_mgr->default_rule_table_id = default_rule_table_id;
|
||||
tbl_mgr->o2o_table_id = o2o_table_id;
|
||||
tbl_mgr->object_group_table_id = object_group_table_id;
|
||||
|
||||
log_info(logger, MODULE_TABLE, "default rule table id: %d", default_rule_table_id);
|
||||
log_info(logger, MODULE_TABLE, "object2object table id: %d", o2o_table_id);
|
||||
log_info(logger, MODULE_TABLE, "object_group table id: %d", object_group_table_id);
|
||||
next:
|
||||
FREE(json_buff);
|
||||
maat_kv_store_free(reserved_word_map);
|
||||
@@ -1055,13 +1055,13 @@ int table_manager_get_default_rule_table_id(struct table_manager *tbl_mgr)
|
||||
return tbl_mgr->default_rule_table_id;
|
||||
}
|
||||
|
||||
int table_manager_get_object2object_table_id(struct table_manager *tbl_mgr)
|
||||
int table_manager_get_object_group_table_id(struct table_manager *tbl_mgr)
|
||||
{
|
||||
if (NULL == tbl_mgr) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return tbl_mgr->o2o_table_id;
|
||||
return tbl_mgr->object_group_table_id;
|
||||
}
|
||||
|
||||
void *table_manager_get_schema(struct table_manager *tbl_mgr, int table_id)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"rule_table": "RULE_DEFAULT",
|
||||
"object2object_table": "OBJECT2OBJECT",
|
||||
"object_group_table": "OBJECT_GROUP",
|
||||
"rules": [
|
||||
{
|
||||
"uuid": "9b0d44a1-1e9e-7988-6ab2-c619d5906818",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"rule_table": "RULE_DEFAULT",
|
||||
"object2object_table": "OBJECT2OBJECT",
|
||||
"object_group_table": "OBJECT_GROUP",
|
||||
"rules": [
|
||||
{
|
||||
"uuid": "9c5ee166-3af6-fb23-f8f8-8c7062ed3717",
|
||||
|
||||
@@ -7250,7 +7250,7 @@ TEST_F(MaatCmd, SubObject) {
|
||||
const char *table_name = "HTTP_URL";
|
||||
const char *attribute_name = "HTTP_URL";
|
||||
const char *rule_table_name = "RULE_DEFAULT";
|
||||
const char *o2o_table_name = "OBJECT2OBJECT";
|
||||
const char *object_group_table_name = "OBJECT_GROUP";
|
||||
const char *scan_data1 = "www.v2ex.com/t/573028#程序员的核心竞争力是什么";
|
||||
const char *keyword1 = "程序员&核心竞争力";
|
||||
const char *scan_data2 = "https://ask.leju.com/bj/detail/12189672562229248/?bi=tg&type=sina-pc"
|
||||
@@ -7269,7 +7269,7 @@ TEST_F(MaatCmd, SubObject) {
|
||||
long long object2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
|
||||
char object2_uuid_str[UUID_STR_LEN];
|
||||
snprintf(object2_uuid_str, UUID_STR_LEN, "00000000-0000-0000-0000-%012lld", object2_id);
|
||||
ret = object2object_table_set_line(maat_inst, o2o_table_name, MAAT_OP_ADD,
|
||||
ret = object_group_table_set_line(maat_inst, object_group_table_name, MAAT_OP_ADD,
|
||||
object1_uuid_str, &object2_uuid_str, 1, NULL, 0, 0);
|
||||
EXPECT_EQ(ret, 1);
|
||||
|
||||
@@ -7385,7 +7385,7 @@ TEST_F(MaatCmd, SubObject) {
|
||||
long long object3_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
|
||||
char object3_uuid_str[UUID_STR_LEN] = {0};
|
||||
snprintf(object3_uuid_str, UUID_STR_LEN, "00000000-0000-0000-0000-%012lld", object3_id);
|
||||
ret = object2object_table_set_line(maat_inst, o2o_table_name, MAAT_OP_ADD,
|
||||
ret = object_group_table_set_line(maat_inst, object_group_table_name, MAAT_OP_ADD,
|
||||
object1_uuid_str, &object3_uuid_str, 1, NULL, 0, 0);
|
||||
EXPECT_EQ(ret, 1);
|
||||
|
||||
@@ -8458,7 +8458,7 @@ TEST_F(MaatCmd, ObjectInMassRules) {
|
||||
|
||||
TEST_F(MaatCmd, HitObject) {
|
||||
const char *rule_table_name = "RULE_DEFAULT";
|
||||
const char *o2o_table_name = "OBJECT2OBJECT";
|
||||
const char *object_group_table_name = "OBJECT_GROUP";
|
||||
const char *http_sig_table_name = "HTTP_SIGNATURE";
|
||||
const char *http_req_attr_name = "HTTP_REQUEST_HEADER";
|
||||
const char *http_resp_attr_name = "HTTP_RESPONSE_HEADER";
|
||||
@@ -8520,7 +8520,7 @@ TEST_F(MaatCmd, HitObject) {
|
||||
long long object2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
|
||||
char object2_uuid_str[UUID_STR_LEN] = {0};
|
||||
snprintf(object2_uuid_str, UUID_STR_LEN, "00000000-0000-0000-0000-%012lld", object2_id);
|
||||
ret = object2object_table_set_line(maat_inst, o2o_table_name, MAAT_OP_ADD,
|
||||
ret = object_group_table_set_line(maat_inst, object_group_table_name, MAAT_OP_ADD,
|
||||
object21_uuid_str, &object2_uuid_str, 1, NULL, 0, 0);
|
||||
EXPECT_EQ(ret, 1);
|
||||
|
||||
@@ -8546,7 +8546,7 @@ TEST_F(MaatCmd, HitObject) {
|
||||
long long object11_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
|
||||
char object11_uuid_str[UUID_STR_LEN] = {0};
|
||||
snprintf(object11_uuid_str, UUID_STR_LEN, "00000000-0000-0000-0000-%012lld", object11_id);
|
||||
ret = object2object_table_set_line(maat_inst, o2o_table_name, MAAT_OP_ADD,
|
||||
ret = object_group_table_set_line(maat_inst, object_group_table_name, MAAT_OP_ADD,
|
||||
object11_uuid_str, &object1_uuid_str, 1, NULL, 0, 0);
|
||||
EXPECT_EQ(ret, 1);
|
||||
|
||||
@@ -8776,7 +8776,7 @@ TEST_F(MaatCmd, HitObject) {
|
||||
}
|
||||
|
||||
TEST_F(MaatCmd, HitPathBasic) {
|
||||
const char *o2o_table_name = "OBJECT2OBJECT";
|
||||
const char *object_group_table_name = "OBJECT_GROUP";
|
||||
const char *rule_table_name = "RULE_DEFAULT";
|
||||
const char *http_sig_table_name = "HTTP_SIGNATURE";
|
||||
const char *http_req_attr_name = "HTTP_REQUEST_HEADER";
|
||||
@@ -8837,7 +8837,7 @@ TEST_F(MaatCmd, HitPathBasic) {
|
||||
long long object2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
|
||||
char object2_uuid_str[UUID_STR_LEN] = {0};
|
||||
snprintf(object2_uuid_str, UUID_STR_LEN, "00000000-0000-0000-0000-%012lld", object2_id);
|
||||
ret = object2object_table_set_line(maat_inst, o2o_table_name, MAAT_OP_ADD,
|
||||
ret = object_group_table_set_line(maat_inst, object_group_table_name, MAAT_OP_ADD,
|
||||
object21_uuid_str, &object2_uuid_str, 1, NULL, 0, 0);
|
||||
EXPECT_EQ(ret, 1);
|
||||
|
||||
@@ -8863,7 +8863,7 @@ TEST_F(MaatCmd, HitPathBasic) {
|
||||
long long object11_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
|
||||
char object11_uuid_str[UUID_STR_LEN] = {0};
|
||||
snprintf(object11_uuid_str, UUID_STR_LEN, "00000000-0000-0000-0000-%012lld", object11_id);
|
||||
ret = object2object_table_set_line(maat_inst, o2o_table_name, MAAT_OP_ADD,
|
||||
ret = object_group_table_set_line(maat_inst, object_group_table_name, MAAT_OP_ADD,
|
||||
object11_uuid_str, &object1_uuid_str, 1, NULL, 0, 0);
|
||||
EXPECT_EQ(ret, 1);
|
||||
|
||||
@@ -9114,7 +9114,7 @@ that the edges be all directed in the same direction.";
|
||||
item4 -> object4 -/
|
||||
*/
|
||||
TEST_F(MaatCmd, HitPathAdvanced) {
|
||||
const char *o2o_table_name = "OBJECT2OBJECT";
|
||||
const char *object_group_table_name = "OBJECT_GROUP";
|
||||
const char *rule_table_name = "RULE_DEFAULT";
|
||||
const char *ip_table_name = "IP_CONFIG";
|
||||
const char *ip_attribute_name = "IP_CONFIG";
|
||||
@@ -9172,7 +9172,7 @@ TEST_F(MaatCmd, HitPathAdvanced) {
|
||||
long long object2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
|
||||
char object2_uuid_str[UUID_STR_LEN] = {0};
|
||||
snprintf(object2_uuid_str, UUID_STR_LEN, "00000000-0000-0000-0000-%012lld", object2_id);
|
||||
ret = object2object_table_set_line(maat_inst, o2o_table_name, MAAT_OP_ADD,
|
||||
ret = object_group_table_set_line(maat_inst, object_group_table_name, MAAT_OP_ADD,
|
||||
object21_uuid_str, &object2_uuid_str, 1, NULL, 0, 0);
|
||||
EXPECT_EQ(ret, 1);
|
||||
|
||||
@@ -9545,7 +9545,7 @@ TEST_F(MaatCmd, HitPathAdvanced) {
|
||||
}
|
||||
|
||||
TEST_F(MaatCmd, HitPathHasNotObject) {
|
||||
const char *o2o_table_name = "OBJECT2OBJECT";
|
||||
const char *object_group_table_name = "OBJECT_GROUP";
|
||||
const char *rule_table_name = "RULE_DEFAULT";
|
||||
const char *http_sig_table_name = "HTTP_SIGNATURE";
|
||||
const char *http_req_attr_name = "HTTP_REQUEST_HEADER";
|
||||
@@ -9605,7 +9605,7 @@ TEST_F(MaatCmd, HitPathHasNotObject) {
|
||||
long long object2_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
|
||||
char object2_uuid_str[UUID_STR_LEN] = {0};
|
||||
snprintf(object2_uuid_str, UUID_STR_LEN, "00000000-0000-0000-0000-%012lld", object2_id);
|
||||
ret = object2object_table_set_line(maat_inst, o2o_table_name, MAAT_OP_ADD,
|
||||
ret = object_group_table_set_line(maat_inst, object_group_table_name, MAAT_OP_ADD,
|
||||
object21_uuid_str, &object2_uuid_str, 1, NULL, 0, 0);
|
||||
EXPECT_EQ(ret, 1);
|
||||
|
||||
@@ -9631,7 +9631,7 @@ TEST_F(MaatCmd, HitPathHasNotObject) {
|
||||
long long object11_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
|
||||
char object11_uuid_str[UUID_STR_LEN] = {0};
|
||||
snprintf(object11_uuid_str, UUID_STR_LEN, "00000000-0000-0000-0000-%012lld", object11_id);
|
||||
ret = object2object_table_set_line(maat_inst, o2o_table_name, MAAT_OP_ADD,
|
||||
ret = object_group_table_set_line(maat_inst, object_group_table_name, MAAT_OP_ADD,
|
||||
object11_uuid_str, &object1_uuid_str, 1, NULL, 0, 0);
|
||||
EXPECT_EQ(ret, 1);
|
||||
|
||||
@@ -9873,7 +9873,7 @@ TEST_F(MaatCmd, HitPathHasNotObject) {
|
||||
|
||||
TEST_F(MaatCmd, SameSuperObjectRefByMultiRule) {
|
||||
int thread_id = 0;
|
||||
const char *o2o_table_name = "OBJECT2OBJECT";
|
||||
const char *object_group_table_name = "OBJECT_GROUP";
|
||||
const char *rule_table_name = "RULE_DEFAULT";
|
||||
const char *http_sig_table_name = "HTTP_SIGNATURE";
|
||||
const char *http_resp_attr_name = "HTTP_RESPONSE_HEADER";
|
||||
@@ -9898,7 +9898,7 @@ TEST_F(MaatCmd, SameSuperObjectRefByMultiRule) {
|
||||
long long object52_id = maat_cmd_incrby(maat_inst, "SEQUENCE_OBJECT", 1);
|
||||
char object52_uuid_str[UUID_STR_LEN] = {0};
|
||||
snprintf(object52_uuid_str, UUID_STR_LEN, "00000000-0000-0000-0000-%012lld", object52_id);
|
||||
ret = object2object_table_set_line(maat_inst, o2o_table_name, MAAT_OP_ADD,
|
||||
ret = object_group_table_set_line(maat_inst, object_group_table_name, MAAT_OP_ADD,
|
||||
object52_uuid_str, &object5_uuid_str, 1, NULL, 0, 0);
|
||||
EXPECT_EQ(ret, 1);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"rule_table": "RULE_DEFAULT",
|
||||
"object2object_table": "OBJECT2OBJECT",
|
||||
"object_group_table": "OBJECT_GROUP",
|
||||
"objects": [
|
||||
{
|
||||
"object_name": "ASN1234",
|
||||
@@ -4162,8 +4162,8 @@
|
||||
"attribute_name": "KEYWORDS_TABLE",
|
||||
"objects": [
|
||||
{
|
||||
"object_name": "236_keywords_object",
|
||||
"uuid": "00000000-0000-0000-0000-000000000262",
|
||||
"object_name": "237_keywords_object",
|
||||
"uuid": "00000000-0000-0000-0000-000000000263",
|
||||
"items": [
|
||||
{
|
||||
"table_type": "expr",
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#define MAX_IDS_STR_LEN 64
|
||||
#define MAX_ITEM_NUM 64
|
||||
#define WAIT_FOR_EFFECTIVE_S 2
|
||||
#define MAX_O2O_SCAN_TIMES (1000 * 1000)
|
||||
#define MAX_OBJECT_GROUP_SCAN_TIMES (1000 * 1000)
|
||||
|
||||
const char *g_table_info_path = "./object_exclude_table_info.json";
|
||||
const char *log_file = "./object_exclude_gtest.log";
|
||||
@@ -24,7 +24,7 @@ struct object_item {
|
||||
char excl_sub_ids_str[MAX_IDS_STR_LEN];
|
||||
};
|
||||
|
||||
struct object2object_rule {
|
||||
struct object_group_rule {
|
||||
size_t n_add_item;
|
||||
size_t n_del_item;
|
||||
struct object_item add_items[MAX_ITEM_NUM];
|
||||
@@ -34,7 +34,7 @@ struct object2object_rule {
|
||||
UT_icd ut_ex_object_id_icd = {sizeof(long long), NULL, NULL, NULL};
|
||||
|
||||
static int
|
||||
parse_config_file(const char *filename, struct object2object_rule *rules)
|
||||
parse_config_file(const char *filename, struct object_group_rule *rules)
|
||||
{
|
||||
unsigned char *json_buff = NULL;
|
||||
size_t json_buff_size = 0;
|
||||
@@ -140,12 +140,12 @@ protected:
|
||||
assert(0);
|
||||
}
|
||||
|
||||
o2o_schema = object2object_schema_new(root, NULL, "EXCLUDE_OBJECT2OBJECT", logger);
|
||||
object_group_schema = object_group_schema_new(root, NULL, "EXCLUDE_OBJECT_GROUP", logger);
|
||||
FREE(json_buff);
|
||||
cJSON_Delete(root);
|
||||
|
||||
if (NULL == o2o_schema) {
|
||||
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object2object_schema_new failed.");
|
||||
if (NULL == object_group_schema) {
|
||||
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object_group_schema_new failed.");
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
@@ -153,26 +153,26 @@ protected:
|
||||
static void TearDownTestCase() {
|
||||
log_handle_destroy(logger);
|
||||
maat_garbage_bin_free(garbage_bin);
|
||||
object2object_schema_free(o2o_schema);
|
||||
object_group_schema_free(object_group_schema);
|
||||
}
|
||||
|
||||
static void *o2o_schema;
|
||||
static void *object_group_schema;
|
||||
static struct log_handle *logger;
|
||||
static struct maat_garbage_bin *garbage_bin;
|
||||
};
|
||||
|
||||
void *MaatObjectExclude::o2o_schema;
|
||||
void *MaatObjectExclude::object_group_schema;
|
||||
struct log_handle *MaatObjectExclude::logger;
|
||||
struct maat_garbage_bin *MaatObjectExclude::garbage_bin;
|
||||
|
||||
TEST_F(MaatObjectExclude, level_3_function) {
|
||||
char table_line[1024];
|
||||
struct object2object_rule rules;
|
||||
const char *table_name = "EXCLUDE_OBJECT2OBJECT";
|
||||
struct object_group_rule rules;
|
||||
const char *table_name = "EXCLUDE_OBJECT_GROUP";
|
||||
|
||||
void *o2o_runtime = object2object_runtime_new(o2o_schema, 1, garbage_bin, logger);
|
||||
if (NULL == o2o_runtime) {
|
||||
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object2object_runtime_new failed.");
|
||||
void *object_group_runtime = object_group_runtime_new(object_group_schema, 1, garbage_bin, logger);
|
||||
if (NULL == object_group_runtime) {
|
||||
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object_group_runtime_new failed.");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
@@ -185,14 +185,14 @@ TEST_F(MaatObjectExclude, level_3_function) {
|
||||
|
||||
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.add_items[i].object_id,
|
||||
rules.add_items[i].incl_sub_ids_str, rules.add_items[i].excl_sub_ids_str, 1);
|
||||
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_ADD);
|
||||
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_ADD);
|
||||
}
|
||||
|
||||
object2object_runtime_commit(o2o_runtime, table_name, 1);
|
||||
object_group_runtime_commit(object_group_runtime, table_name, 1);
|
||||
|
||||
long long hit_object_ids[2] = {11, 13};
|
||||
long long super_object_ids[MAX_ITEM_NUM];
|
||||
size_t super_object_cnt = object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
|
||||
size_t super_object_cnt = object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
|
||||
super_object_ids, MAX_ITEM_NUM);
|
||||
EXPECT_EQ(super_object_cnt, 2);
|
||||
EXPECT_EQ(super_object_ids[0], 2);
|
||||
@@ -202,10 +202,10 @@ TEST_F(MaatObjectExclude, level_3_function) {
|
||||
memset(table_line, 0, sizeof(table_line));
|
||||
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[0].object_id,
|
||||
rules.del_items[0].incl_sub_ids_str, rules.del_items[0].excl_sub_ids_str, 0);
|
||||
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_DEL);
|
||||
object2object_runtime_commit(o2o_runtime, table_name, 2);
|
||||
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_DEL);
|
||||
object_group_runtime_commit(object_group_runtime, table_name, 2);
|
||||
|
||||
super_object_cnt = object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
|
||||
super_object_cnt = object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
|
||||
super_object_ids, MAX_ITEM_NUM);
|
||||
EXPECT_EQ(super_object_cnt, 3);
|
||||
EXPECT_EQ(super_object_ids[0], 1);
|
||||
@@ -216,10 +216,10 @@ TEST_F(MaatObjectExclude, level_3_function) {
|
||||
memset(table_line, 0, sizeof(table_line));
|
||||
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[1].object_id,
|
||||
rules.del_items[1].incl_sub_ids_str, rules.del_items[1].excl_sub_ids_str, 0);
|
||||
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_DEL);
|
||||
object2object_runtime_commit(o2o_runtime, table_name, 3);
|
||||
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_DEL);
|
||||
object_group_runtime_commit(object_group_runtime, table_name, 3);
|
||||
|
||||
super_object_cnt = object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
|
||||
super_object_cnt = object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
|
||||
super_object_ids, MAX_ITEM_NUM);
|
||||
EXPECT_EQ(super_object_cnt, 4);
|
||||
EXPECT_EQ(super_object_ids[0], 1);
|
||||
@@ -227,17 +227,17 @@ TEST_F(MaatObjectExclude, level_3_function) {
|
||||
EXPECT_EQ(super_object_ids[2], 6);
|
||||
EXPECT_EQ(super_object_ids[3], 7);
|
||||
|
||||
object2object_runtime_free(o2o_runtime);
|
||||
object_group_runtime_free(object_group_runtime);
|
||||
}
|
||||
|
||||
TEST_F(MaatObjectExclude, level_3_perf) {
|
||||
char table_line[1024];
|
||||
struct object2object_rule rules;
|
||||
const char *table_name = "EXCLUDE_OBJECT2OBJECT";
|
||||
struct object_group_rule rules;
|
||||
const char *table_name = "EXCLUDE_OBJECT_GROUP";
|
||||
|
||||
void *o2o_runtime = object2object_runtime_new(o2o_schema, 1, garbage_bin, logger);
|
||||
if (NULL == o2o_runtime) {
|
||||
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object2object_runtime_new failed.");
|
||||
void *object_group_runtime = object_group_runtime_new(object_group_schema, 1, garbage_bin, logger);
|
||||
if (NULL == object_group_runtime) {
|
||||
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object_group_runtime_new failed.");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
@@ -250,10 +250,10 @@ TEST_F(MaatObjectExclude, level_3_perf) {
|
||||
|
||||
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.add_items[i].object_id,
|
||||
rules.add_items[i].incl_sub_ids_str, rules.add_items[i].excl_sub_ids_str, 1);
|
||||
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_ADD);
|
||||
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_ADD);
|
||||
}
|
||||
|
||||
object2object_runtime_commit(o2o_runtime, table_name, 4);
|
||||
object_group_runtime_commit(object_group_runtime, table_name, 4);
|
||||
|
||||
long long hit_object_ids[2] = {11, 13};
|
||||
long long super_object_ids[MAX_ITEM_NUM];
|
||||
@@ -261,8 +261,8 @@ TEST_F(MaatObjectExclude, level_3_perf) {
|
||||
struct log_handle *logger = MaatObjectExclude::logger;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
for (int i = 0; i < MAX_O2O_SCAN_TIMES; i++) {
|
||||
object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
|
||||
for (int i = 0; i < MAX_OBJECT_GROUP_SCAN_TIMES; i++) {
|
||||
object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
|
||||
super_object_ids, MAX_ITEM_NUM);
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||
@@ -274,12 +274,12 @@ TEST_F(MaatObjectExclude, level_3_perf) {
|
||||
memset(table_line, 0, sizeof(table_line));
|
||||
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[0].object_id,
|
||||
rules.del_items[0].incl_sub_ids_str, rules.del_items[0].excl_sub_ids_str, 0);
|
||||
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_DEL);
|
||||
object2object_runtime_commit(o2o_runtime, table_name, 5);
|
||||
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_DEL);
|
||||
object_group_runtime_commit(object_group_runtime, table_name, 5);
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
for (int i = 0; i < MAX_O2O_SCAN_TIMES; i++) {
|
||||
object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
|
||||
for (int i = 0; i < MAX_OBJECT_GROUP_SCAN_TIMES; i++) {
|
||||
object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
|
||||
super_object_ids, MAX_ITEM_NUM);
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||
@@ -291,12 +291,12 @@ TEST_F(MaatObjectExclude, level_3_perf) {
|
||||
memset(table_line, 0, sizeof(table_line));
|
||||
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[1].object_id,
|
||||
rules.del_items[1].incl_sub_ids_str, rules.del_items[1].excl_sub_ids_str, 0);
|
||||
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_DEL);
|
||||
object2object_runtime_commit(o2o_runtime, table_name, 6);
|
||||
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_DEL);
|
||||
object_group_runtime_commit(object_group_runtime, table_name, 6);
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
for (int i = 0; i < MAX_O2O_SCAN_TIMES; i++) {
|
||||
object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
|
||||
for (int i = 0; i < MAX_OBJECT_GROUP_SCAN_TIMES; i++) {
|
||||
object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
|
||||
super_object_ids, MAX_ITEM_NUM);
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||
@@ -304,17 +304,17 @@ TEST_F(MaatObjectExclude, level_3_perf) {
|
||||
log_info(logger, MODULE_OBJECT_NESTING_GTEST, "level_3_basic hit 4 super_objects scan consume time %lldms",
|
||||
time_elapse_ms);
|
||||
|
||||
object2object_runtime_free(o2o_runtime);
|
||||
object_group_runtime_free(object_group_runtime);
|
||||
}
|
||||
|
||||
TEST_F(MaatObjectExclude, level_4_function) {
|
||||
char table_line[1024];
|
||||
struct object2object_rule rules;
|
||||
const char *table_name = "EXCLUDE_OBJECT2OBJECT";
|
||||
struct object_group_rule rules;
|
||||
const char *table_name = "EXCLUDE_OBJECT_GROUP";
|
||||
|
||||
void *o2o_runtime = object2object_runtime_new(o2o_schema, 1, garbage_bin, logger);
|
||||
if (NULL == o2o_runtime) {
|
||||
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object2object_runtime_new failed.");
|
||||
void *object_group_runtime = object_group_runtime_new(object_group_schema, 1, garbage_bin, logger);
|
||||
if (NULL == object_group_runtime) {
|
||||
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object_group_runtime_new failed.");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
@@ -327,14 +327,14 @@ TEST_F(MaatObjectExclude, level_4_function) {
|
||||
|
||||
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.add_items[i].object_id,
|
||||
rules.add_items[i].incl_sub_ids_str, rules.add_items[i].excl_sub_ids_str, 1);
|
||||
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_ADD);
|
||||
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_ADD);
|
||||
}
|
||||
|
||||
object2object_runtime_commit(o2o_runtime, table_name, 7);
|
||||
object_group_runtime_commit(object_group_runtime, table_name, 7);
|
||||
|
||||
long long hit_object_ids[2] = {14, 16};
|
||||
long long super_object_ids[MAX_ITEM_NUM];
|
||||
size_t super_object_cnt = object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
|
||||
size_t super_object_cnt = object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
|
||||
super_object_ids, MAX_ITEM_NUM);
|
||||
EXPECT_EQ(super_object_cnt, 5);
|
||||
EXPECT_EQ(super_object_ids[0], 4);
|
||||
@@ -347,10 +347,10 @@ TEST_F(MaatObjectExclude, level_4_function) {
|
||||
memset(table_line, 0, sizeof(table_line));
|
||||
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[0].object_id,
|
||||
rules.del_items[0].incl_sub_ids_str, rules.del_items[0].excl_sub_ids_str, 0);
|
||||
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_DEL);
|
||||
object2object_runtime_commit(o2o_runtime, table_name, 8);
|
||||
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_DEL);
|
||||
object_group_runtime_commit(object_group_runtime, table_name, 8);
|
||||
|
||||
super_object_cnt = object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
|
||||
super_object_cnt = object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
|
||||
super_object_ids, MAX_ITEM_NUM);
|
||||
EXPECT_EQ(super_object_cnt, 7);
|
||||
EXPECT_EQ(super_object_ids[0], 1);
|
||||
@@ -361,17 +361,17 @@ TEST_F(MaatObjectExclude, level_4_function) {
|
||||
EXPECT_EQ(super_object_ids[5], 9);
|
||||
EXPECT_EQ(super_object_ids[6], 10);
|
||||
|
||||
object2object_runtime_free(o2o_runtime);
|
||||
object_group_runtime_free(object_group_runtime);
|
||||
}
|
||||
|
||||
TEST_F(MaatObjectExclude, level_4_perf) {
|
||||
char table_line[1024];
|
||||
struct object2object_rule rules;
|
||||
const char *table_name = "EXCLUDE_OBJECT2OBJECT";
|
||||
struct object_group_rule rules;
|
||||
const char *table_name = "EXCLUDE_OBJECT_GROUP";
|
||||
|
||||
void *o2o_runtime = object2object_runtime_new(o2o_schema, 1, garbage_bin, logger);
|
||||
if (NULL == o2o_runtime) {
|
||||
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object2object_runtime_new failed.");
|
||||
void *object_group_runtime = object_group_runtime_new(object_group_schema, 1, garbage_bin, logger);
|
||||
if (NULL == object_group_runtime) {
|
||||
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object_group_runtime_new failed.");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
@@ -384,10 +384,10 @@ TEST_F(MaatObjectExclude, level_4_perf) {
|
||||
|
||||
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.add_items[i].object_id,
|
||||
rules.add_items[i].incl_sub_ids_str, rules.add_items[i].excl_sub_ids_str, 1);
|
||||
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_ADD);
|
||||
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_ADD);
|
||||
}
|
||||
|
||||
object2object_runtime_commit(o2o_runtime, table_name, 7);
|
||||
object_group_runtime_commit(object_group_runtime, table_name, 7);
|
||||
|
||||
long long hit_object_ids[2] = {14, 16};
|
||||
long long super_object_ids[MAX_ITEM_NUM];
|
||||
@@ -395,8 +395,8 @@ TEST_F(MaatObjectExclude, level_4_perf) {
|
||||
struct log_handle *logger = MaatObjectExclude::logger;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
for (int i = 0; i < MAX_O2O_SCAN_TIMES; i++) {
|
||||
object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
|
||||
for (int i = 0; i < MAX_OBJECT_GROUP_SCAN_TIMES; i++) {
|
||||
object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
|
||||
super_object_ids, MAX_ITEM_NUM);
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||
@@ -408,12 +408,12 @@ TEST_F(MaatObjectExclude, level_4_perf) {
|
||||
memset(table_line, 0, sizeof(table_line));
|
||||
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[0].object_id,
|
||||
rules.del_items[0].incl_sub_ids_str, rules.del_items[0].excl_sub_ids_str, 0);
|
||||
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_DEL);
|
||||
object2object_runtime_commit(o2o_runtime, table_name, 8);
|
||||
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_DEL);
|
||||
object_group_runtime_commit(object_group_runtime, table_name, 8);
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
for (int i = 0; i < MAX_O2O_SCAN_TIMES; i++) {
|
||||
object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
|
||||
for (int i = 0; i < MAX_OBJECT_GROUP_SCAN_TIMES; i++) {
|
||||
object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
|
||||
super_object_ids, MAX_ITEM_NUM);
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||
@@ -421,17 +421,17 @@ TEST_F(MaatObjectExclude, level_4_perf) {
|
||||
log_info(logger, MODULE_OBJECT_NESTING_GTEST, "level_4_basic hit 7 super_objects scan consume time %lldms",
|
||||
time_elapse_ms);
|
||||
|
||||
object2object_runtime_free(o2o_runtime);
|
||||
object_group_runtime_free(object_group_runtime);
|
||||
}
|
||||
|
||||
TEST_F(MaatObjectExclude, level_exceed_function) {
|
||||
char table_line[1024];
|
||||
struct object2object_rule rules;
|
||||
const char *table_name = "EXCLUDE_OBJECT2OBJECT";
|
||||
struct object_group_rule rules;
|
||||
const char *table_name = "EXCLUDE_OBJECT_GROUP";
|
||||
|
||||
void *o2o_runtime = object2object_runtime_new(o2o_schema, 1, garbage_bin, logger);
|
||||
if (NULL == o2o_runtime) {
|
||||
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object2object_runtime_new failed.");
|
||||
void *object_group_runtime = object_group_runtime_new(object_group_schema, 1, garbage_bin, logger);
|
||||
if (NULL == object_group_runtime) {
|
||||
log_fatal(logger, MODULE_OBJECT_NESTING_GTEST, "object_group_runtime_new failed.");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
@@ -444,14 +444,14 @@ TEST_F(MaatObjectExclude, level_exceed_function) {
|
||||
|
||||
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.add_items[i].object_id,
|
||||
rules.add_items[i].incl_sub_ids_str, rules.add_items[i].excl_sub_ids_str, 1);
|
||||
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_ADD);
|
||||
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_ADD);
|
||||
}
|
||||
|
||||
object2object_runtime_commit(o2o_runtime, table_name, 8);
|
||||
object_group_runtime_commit(object_group_runtime, table_name, 8);
|
||||
|
||||
long long hit_object_ids[2] = {7, 13};
|
||||
long long super_object_ids[MAX_ITEM_NUM];
|
||||
size_t super_object_cnt = object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
|
||||
size_t super_object_cnt = object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
|
||||
super_object_ids, MAX_ITEM_NUM);
|
||||
EXPECT_EQ(super_object_cnt, 6);
|
||||
EXPECT_EQ(super_object_ids[0], 4);
|
||||
@@ -465,12 +465,12 @@ TEST_F(MaatObjectExclude, level_exceed_function) {
|
||||
memset(table_line, 0, sizeof(table_line));
|
||||
sprintf(table_line, "%lld\t%s\t%s\t%d", rules.del_items[0].object_id,
|
||||
rules.del_items[0].incl_sub_ids_str, rules.del_items[0].excl_sub_ids_str, 0);
|
||||
object2object_runtime_update(o2o_runtime, o2o_schema, table_name, table_line, MAAT_OP_DEL);
|
||||
object2object_runtime_commit(o2o_runtime, table_name, 9);
|
||||
object_group_runtime_update(object_group_runtime, object_group_schema, table_name, table_line, MAAT_OP_DEL);
|
||||
object_group_runtime_commit(object_group_runtime, table_name, 9);
|
||||
|
||||
hit_object_ids[0] = 7;
|
||||
hit_object_ids[1] = 10;
|
||||
super_object_cnt = object2object_runtime_get_super_objects(o2o_runtime, hit_object_ids, 2,
|
||||
super_object_cnt = object_group_runtime_get_super_objects(object_group_runtime, hit_object_ids, 2,
|
||||
super_object_ids, MAX_ITEM_NUM);
|
||||
EXPECT_EQ(super_object_cnt, 5);
|
||||
EXPECT_EQ(super_object_ids[0], 2);
|
||||
@@ -479,7 +479,7 @@ TEST_F(MaatObjectExclude, level_exceed_function) {
|
||||
EXPECT_EQ(super_object_ids[3], 8);
|
||||
EXPECT_EQ(super_object_ids[4], 11);
|
||||
|
||||
object2object_runtime_free(o2o_runtime);
|
||||
object_group_runtime_free(object_group_runtime);
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"table_id":1,
|
||||
"table_name":"EXCLUDE_OBJECT2OBJECT",
|
||||
"table_type":"object2object",
|
||||
"table_name":"EXCLUDE_OBJECT_GROUP",
|
||||
"table_type":"object_group",
|
||||
"valid_column":4,
|
||||
"custom": {
|
||||
"object_id":1,
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
},
|
||||
{
|
||||
"table_id":7,
|
||||
"table_name":"OBJECT2OBJECT",
|
||||
"table_type":"object2object"
|
||||
"table_name":"OBJECT_GROUP",
|
||||
"table_type":"object_group"
|
||||
},
|
||||
{
|
||||
"table_id":8,
|
||||
|
||||
@@ -43,7 +43,7 @@ make_serial_rule(const char *table_name, const char *line, void *u_para, enum ma
|
||||
rule_uuid = cJSON_GetObjectItem(json, "uuid");
|
||||
|
||||
if (NULL == rule_uuid) {
|
||||
rule_uuid = cJSON_GetObjectItem(json, "object_uuid");//for object2object table
|
||||
rule_uuid = cJSON_GetObjectItem(json, "object_uuid");//for object_group table
|
||||
}
|
||||
|
||||
if (NULL == rule_uuid || rule_uuid->type != cJSON_String) {
|
||||
@@ -193,7 +193,7 @@ int rule_table_set_line(struct maat *maat_inst, const char *table_name,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int object2object_table_set_line(struct maat *maat_inst, const char *table_name,
|
||||
int object_group_table_set_line(struct maat *maat_inst, const char *table_name,
|
||||
enum maat_operation op, const char *object_uuid_str,
|
||||
const char inc_object_uuid_strs[][UUID_STR_LEN], int inc_object_num,
|
||||
const char exc_object_uuid_strs[][UUID_STR_LEN], int exc_object_num, int expire_after)
|
||||
|
||||
@@ -25,7 +25,7 @@ int rule_table_set_line(struct maat *maat_inst, const char *table_name,
|
||||
struct maat_cmd_and_condition and_conditions[],
|
||||
int condition_num, const char *action_para_str, int expire_after);
|
||||
|
||||
int object2object_table_set_line(struct maat *maat_inst, const char *table_name,
|
||||
int object_group_table_set_line(struct maat *maat_inst, const char *table_name,
|
||||
enum maat_operation op, const char *object_uuid_str,
|
||||
const char inc_object_uuid_strs[][UUID_STR_LEN], int inc_object_num,
|
||||
const char exc_object_uuid_strs[][UUID_STR_LEN], int exc_object_num, int expire_after);
|
||||
|
||||
Reference in New Issue
Block a user