155 lines
4.1 KiB
C++
155 lines
4.1 KiB
C++
#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"
|
||
|
||
#include "doris_consumer_client.h"
|
||
#include "doris_server_receive.h"
|
||
#include "doris_server_kvdb.h"
|
||
|
||
#include <map>
|
||
#include <string>
|
||
|
||
using namespace std;
|
||
|
||
#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"
|
||
#define MAX_BUSINESS_NUM 64
|
||
|
||
#define RECV_WAY_DRS_CLIENT 1
|
||
#define RECV_WAY_IDX_FILE 2
|
||
#define RECV_WAY_HTTP_POST 3
|
||
|
||
#define PROMETHUES_POST_SERVER_OK 0
|
||
#define PROMETHUES_POST_SERVER_UPING 1
|
||
#define PROMETHUES_POST_SERVER_DOWN 2
|
||
|
||
struct doris_business
|
||
{
|
||
/*first for configuration*/
|
||
char bizname[32];
|
||
u_int32_t recv_way;
|
||
int32_t cache_max_versions;
|
||
u_int32_t concurrency_allowed;
|
||
u_int32_t saves_when_fulldel; //有全量到来时,最多保存几个最新的全量版本,0-全保存
|
||
u_int32_t persistence_write_on;
|
||
char recv_path_full[256];
|
||
char recv_path_inc[256];
|
||
char store_path_root[256];
|
||
int64_t full_version_inc[16];
|
||
struct version_list_handle *cfgver_head;
|
||
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; //保证每个biz生产server线程只有一个,避免交叉访问instance
|
||
evutil_socket_t listener_prod;
|
||
int64_t total_cfgnum;
|
||
int32_t mmid_latest_ver;
|
||
int32_t mmid_total_cfgnum;
|
||
u_int32_t mmval_status_codeid; //MM内部异常状态id,Grafana的value
|
||
u_int32_t fs_lineid;
|
||
pthread_rwlock_t rwlock;
|
||
|
||
/*next for updating*/
|
||
struct event_base *worker_evbase;
|
||
struct doris_prod_instance *instance;
|
||
map<string, struct version_list_node *> *token2node;
|
||
int64_t version;
|
||
int64_t genversion_seq; //post模式,用于生成版本号的序列
|
||
int32_t source_from;
|
||
int32_t type;
|
||
int64_t version_cfgnum;
|
||
char inc_index_path[256]; //inc目录下的增量全量
|
||
char tmp_index_path[256]; //inc目录下的增量全量
|
||
char full_index_path[256]; //full目录下的全量
|
||
char cfg_file_path[256];
|
||
FILE *fp_cfg_file; //仅限于读文件和DRS Client接口
|
||
FILE *fp_idx_file; //仅限于读文件和DRS Client接口
|
||
struct version_list_node *cur_vernode;
|
||
};
|
||
|
||
struct doris_global_info
|
||
{
|
||
u_int32_t iothreads;
|
||
int32_t consumer_port;
|
||
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;
|
||
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;
|
||
|
||
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;
|
||
|
||
evutil_socket_t listener_csum;
|
||
evutil_socket_t manager;
|
||
u_int32_t token_seq;
|
||
int32_t local_ip;
|
||
|
||
struct doris_business business[MAX_BUSINESS_NUM];
|
||
u_int32_t business_num;
|
||
u_int32_t business_post_num; //post模式有几个
|
||
int32_t business_post_ups; //启动了几个
|
||
int32_t business_post_nopersists;
|
||
int32_t mmid_post_server; //value=PROMETHUES_POST_*
|
||
map<string, struct doris_business*> *name2business;
|
||
map<string, struct doris_csum_param *> *confile2csmparam;
|
||
|
||
struct MESA_MonitorHandler *monitor;
|
||
pthread_mutex_t mutex_lock;
|
||
struct doris_kvhandle *kvdbhandle;
|
||
|
||
/*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];
|
||
int32_t fsstat_column[DRS_FSSTAT_CLUMN_NUM];
|
||
};
|
||
|
||
int doris_mkdir_according_path(const char * path);
|
||
int doris_create_listen_socket(int bind_port);
|
||
|
||
#endif
|
||
|