2021-07-16 16:06:59 +08:00
|
|
|
|
#ifndef __DORIS_SERVER_MAIN_H__
|
|
|
|
|
|
#define __DORIS_SERVER_MAIN_H__
|
|
|
|
|
|
|
|
|
|
|
|
#include <openssl/ssl.h>
|
|
|
|
|
|
#include <openssl/crypto.h>
|
|
|
|
|
|
#include <openssl/x509.h>
|
|
|
|
|
|
#include <openssl/pem.h>
|
|
|
|
|
|
#include <openssl/err.h>
|
|
|
|
|
|
#include <openssl/rsa.h>
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include <event.h>
|
|
|
|
|
|
#include <evhttp.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include <MESA/field_stat2.h>
|
|
|
|
|
|
#include <MESA/MESA_htable.h>
|
|
|
|
|
|
#include <MESA/MESA_handle_logger.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "MESA_Monitor.h"
|
|
|
|
|
|
|
2021-08-25 18:40:20 +08:00
|
|
|
|
#include "doris_consumer_client.h"
|
2021-07-16 16:06:59 +08:00
|
|
|
|
#include "doris_server_receive.h"
|
2021-09-08 10:45:47 +08:00
|
|
|
|
#include "doris_server_kvdb.h"
|
2021-07-16 16:06:59 +08:00
|
|
|
|
|
2021-07-22 10:25:42 +08:00
|
|
|
|
#include <map>
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
2021-07-16 16:06:59 +08:00
|
|
|
|
#ifndef __FILENAME__
|
|
|
|
|
|
#define __FILENAME__ __FILE__
|
|
|
|
|
|
#endif
|
|
|
|
|
|
#define MESA_RUNTIME_LOGV3(handle, lv, fmt, args...) \
|
|
|
|
|
|
MESA_handle_runtime_log((handle), (lv), "DorisServer", "%s:%d, " fmt, __FILENAME__, __LINE__, ##args)
|
|
|
|
|
|
|
|
|
|
|
|
#define NIRVANA_CONFIG_FILE "./conf/doris_main.conf"
|
2021-07-22 10:25:42 +08:00
|
|
|
|
#define MAX_BUSINESS_NUM 64
|
2021-07-16 16:06:59 +08:00
|
|
|
|
|
|
|
|
|
|
#define RECV_WAY_DRS_CLIENT 1
|
|
|
|
|
|
#define RECV_WAY_IDX_FILE 2
|
2021-07-22 10:25:42 +08:00
|
|
|
|
#define RECV_WAY_HTTP_POST 3
|
|
|
|
|
|
|
2021-08-25 18:40:20 +08:00
|
|
|
|
#define PROMETHUES_POST_SERVER_OK 0
|
|
|
|
|
|
#define PROMETHUES_POST_SERVER_UPING 1
|
|
|
|
|
|
#define PROMETHUES_POST_SERVER_DOWN 2
|
|
|
|
|
|
|
2021-07-22 10:25:42 +08:00
|
|
|
|
struct doris_business
|
|
|
|
|
|
{
|
2021-08-25 18:40:20 +08:00
|
|
|
|
/*first for configuration*/
|
2021-07-22 10:25:42 +08:00
|
|
|
|
char bizname[32];
|
|
|
|
|
|
u_int32_t recv_way;
|
2021-09-08 10:45:47 +08:00
|
|
|
|
int32_t cache_max_versions;
|
2021-08-25 18:40:20 +08:00
|
|
|
|
u_int32_t concurrency_allowed;
|
2021-08-30 14:22:48 +08:00
|
|
|
|
u_int32_t saves_when_fulldel; //<2F><>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>ౣ<EFBFBD>漸<EFBFBD><E6BCB8><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD>汾<EFBFBD><E6B1BE>0-ȫ<><C8AB><EFBFBD><EFBFBD>
|
2021-09-08 10:45:47 +08:00
|
|
|
|
u_int32_t persistence_write_on;
|
2021-07-22 10:25:42 +08:00
|
|
|
|
char recv_path_full[256];
|
|
|
|
|
|
char recv_path_inc[256];
|
|
|
|
|
|
char store_path_root[256];
|
2021-08-30 14:22:48 +08:00
|
|
|
|
int64_t full_version_inc[16];
|
2021-07-22 10:25:42 +08:00
|
|
|
|
struct version_list_handle *cfgver_head;
|
2021-08-25 18:40:20 +08:00
|
|
|
|
struct doris_csum_param *param_csum;
|
|
|
|
|
|
struct doris_prod_param *param_prod;
|
|
|
|
|
|
u_int32_t ready_to_sync;
|
|
|
|
|
|
u_int32_t posts_on_the_way;
|
|
|
|
|
|
int32_t producer_port; //<2F><>֤ÿ<D6A4><C3BF>biz<69><7A><EFBFBD><EFBFBD>server<65>߳<EFBFBD>ֻ<EFBFBD><D6BB>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⽻<EFBFBD><E2BDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>instance
|
|
|
|
|
|
evutil_socket_t listener_prod;
|
2021-07-22 10:25:42 +08:00
|
|
|
|
int64_t total_cfgnum;
|
2021-08-25 18:40:20 +08:00
|
|
|
|
int32_t mmid_latest_ver;
|
|
|
|
|
|
int32_t mmid_total_cfgnum;
|
|
|
|
|
|
u_int32_t mmval_status_codeid; //MM<4D>ڲ<EFBFBD><DAB2>쳣״̬id<69><64>Grafana<6E><61>value
|
2021-07-22 10:25:42 +08:00
|
|
|
|
u_int32_t fs_lineid;
|
|
|
|
|
|
pthread_rwlock_t rwlock;
|
2021-08-25 18:40:20 +08:00
|
|
|
|
|
|
|
|
|
|
/*next for updating*/
|
|
|
|
|
|
struct event_base *worker_evbase;
|
|
|
|
|
|
struct doris_prod_instance *instance;
|
|
|
|
|
|
map<string, struct version_list_node *> *token2node;
|
|
|
|
|
|
int64_t version;
|
2021-09-08 10:45:47 +08:00
|
|
|
|
int64_t genversion_seq; //postģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɰ汾<C9B0>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD>
|
2021-08-25 18:40:20 +08:00
|
|
|
|
int32_t source_from;
|
|
|
|
|
|
int32_t type;
|
|
|
|
|
|
int64_t version_cfgnum;
|
|
|
|
|
|
char inc_index_path[256]; //incĿ¼<C4BF>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB>
|
|
|
|
|
|
char tmp_index_path[256]; //incĿ¼<C4BF>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB>
|
|
|
|
|
|
char full_index_path[256]; //fullĿ¼<C4BF>µ<EFBFBD>ȫ<EFBFBD><C8AB>
|
|
|
|
|
|
char cfg_file_path[256];
|
|
|
|
|
|
FILE *fp_cfg_file; //<2F><><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6>ļ<EFBFBD><C4BC><EFBFBD>DRS Client<6E>ӿ<EFBFBD>
|
|
|
|
|
|
FILE *fp_idx_file; //<2F><><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6>ļ<EFBFBD><C4BC><EFBFBD>DRS Client<6E>ӿ<EFBFBD>
|
|
|
|
|
|
struct version_list_node *cur_vernode;
|
2021-07-22 10:25:42 +08:00
|
|
|
|
};
|
2021-07-16 16:06:59 +08:00
|
|
|
|
|
2021-07-19 17:21:38 +08:00
|
|
|
|
struct doris_global_info
|
2021-07-16 16:06:59 +08:00
|
|
|
|
{
|
|
|
|
|
|
u_int32_t iothreads;
|
2021-08-25 18:40:20 +08:00
|
|
|
|
int32_t consumer_port;
|
2021-07-16 16:06:59 +08:00
|
|
|
|
int32_t manager_port;
|
|
|
|
|
|
int32_t sock_recv_bufsize;
|
|
|
|
|
|
u_int32_t ssl_conn_on;
|
|
|
|
|
|
u_int32_t scan_idx_interval;
|
|
|
|
|
|
u_int32_t cache_frag_size;
|
2021-08-25 18:40:20 +08:00
|
|
|
|
u_int32_t max_http_body_size;
|
|
|
|
|
|
u_int32_t idx_file_maat;
|
|
|
|
|
|
u_int32_t max_concurrent_reqs;
|
|
|
|
|
|
u_int32_t cluster_sync_mode;
|
|
|
|
|
|
u_int32_t post_vernode_ttl;
|
2021-07-16 16:06:59 +08:00
|
|
|
|
|
|
|
|
|
|
char ssl_CA_path[256];
|
|
|
|
|
|
char ssl_cert_file[256];
|
|
|
|
|
|
char ssl_key_file[256];
|
|
|
|
|
|
char ssl_key_passwd[64];
|
|
|
|
|
|
pthread_mutex_t *lock_cs;
|
|
|
|
|
|
SSL_CTX *ssl_instance;
|
|
|
|
|
|
|
2021-08-25 18:40:20 +08:00
|
|
|
|
evutil_socket_t listener_csum;
|
2021-07-16 16:06:59 +08:00
|
|
|
|
evutil_socket_t manager;
|
2021-08-25 18:40:20 +08:00
|
|
|
|
u_int32_t token_seq;
|
|
|
|
|
|
int32_t local_ip;
|
2021-07-22 10:25:42 +08:00
|
|
|
|
|
|
|
|
|
|
struct doris_business business[MAX_BUSINESS_NUM];
|
|
|
|
|
|
u_int32_t business_num;
|
2021-08-25 18:40:20 +08:00
|
|
|
|
u_int32_t business_post_num; //postģʽ<C4A3>м<EFBFBD><D0BC><EFBFBD>
|
|
|
|
|
|
int32_t business_post_ups; //<2F><><EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD><CBBC><EFBFBD>
|
2021-09-08 10:45:47 +08:00
|
|
|
|
int32_t business_post_nopersists;
|
2021-08-25 18:40:20 +08:00
|
|
|
|
int32_t mmid_post_server; //value=PROMETHUES_POST_*
|
2021-07-22 10:25:42 +08:00
|
|
|
|
map<string, struct doris_business*> *name2business;
|
2021-08-25 18:40:20 +08:00
|
|
|
|
map<string, struct doris_csum_param *> *confile2csmparam;
|
2021-07-16 16:06:59 +08:00
|
|
|
|
|
|
|
|
|
|
struct MESA_MonitorHandler *monitor;
|
2021-08-25 18:40:20 +08:00
|
|
|
|
pthread_mutex_t mutex_lock;
|
2021-09-08 10:45:47 +08:00
|
|
|
|
struct doris_kvhandle *kvdbhandle;
|
2021-07-22 10:25:42 +08:00
|
|
|
|
|
2021-07-16 16:06:59 +08:00
|
|
|
|
/*logs*/
|
|
|
|
|
|
u_int32_t log_level;
|
|
|
|
|
|
u_int32_t statistic_period;
|
|
|
|
|
|
char root_log_dir[256];
|
|
|
|
|
|
void *log_runtime;
|
|
|
|
|
|
|
|
|
|
|
|
screen_stat_handle_t fsstat_handle;
|
|
|
|
|
|
char fsstat_dst_ip[64];
|
|
|
|
|
|
char fsstat_appname[16];
|
|
|
|
|
|
char fsstat_filepath[256];
|
|
|
|
|
|
u_int32_t fsstat_period;
|
|
|
|
|
|
int32_t fsstat_print_mode;
|
|
|
|
|
|
int32_t fsstat_dst_port;
|
|
|
|
|
|
int32_t fsstat_field[DRS_FSSTAT_FIELD_NUM];
|
|
|
|
|
|
int32_t fsstat_status[DRS_FSSTAT_STATUS_NUM];
|
2021-07-22 10:25:42 +08:00
|
|
|
|
int32_t fsstat_column[DRS_FSSTAT_CLUMN_NUM];
|
2021-07-16 16:06:59 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
int doris_mkdir_according_path(const char * path);
|
2021-08-25 18:40:20 +08:00
|
|
|
|
int doris_create_listen_socket(int bind_port);
|
2021-07-16 16:06:59 +08:00
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|