tracker.conf add parameters: min_buff_size and max_buff_size

pull/74/merge
yuqing 2016-11-10 11:04:51 +08:00
parent 0ea1795cbd
commit 9fc89b6522
6 changed files with 75 additions and 6 deletions

View File

@ -1,6 +1,7 @@
Version 5.09 2016-11-10 Version 5.09 2016-11-10
* bug fixed: list_all_groups expand buffer auto * bug fixed: list_all_groups expand buffer auto for so many groups
* tracker.conf add parameters: min_buff_size and max_buff_size
Version 5.08 2016-04-08 Version 5.08 2016-04-08
* install library to $(TARGET_PREFIX)/lib anyway * install library to $(TARGET_PREFIX)/lib anyway

View File

@ -34,6 +34,14 @@ accept_threads=1
# since V2.00 # since V2.00
work_threads=4 work_threads=4
# min buff size
# default value 8KB
min_buff_size = 8KB
# max buff size
# default value 128KB
max_buff_size = 128KB
# the method of selecting group to upload files # the method of selecting group to upload files
# 0: round robin # 0: round robin
# 1: specify group # 1: specify group

View File

@ -136,6 +136,8 @@ int tracker_load_from_conf_file(const char *filename, \
char *pSpaceThreshold; char *pSpaceThreshold;
char *pTrunkFileSize; char *pTrunkFileSize;
char *pRotateErrorLogSize; char *pRotateErrorLogSize;
char *pMinBuffSize;
char *pMaxBuffSize;
#ifdef WITH_HTTPD #ifdef WITH_HTTPD
char *pHttpCheckUri; char *pHttpCheckUri;
char *pHttpCheckType; char *pHttpCheckType;
@ -147,6 +149,8 @@ int tracker_load_from_conf_file(const char *filename, \
int64_t slot_min_size; int64_t slot_min_size;
int64_t slot_max_size; int64_t slot_max_size;
int64_t rotate_error_log_size; int64_t rotate_error_log_size;
int64_t min_buff_size;
int64_t max_buff_size;
char reserved_space_str[32]; char reserved_space_str[32];
memset(&g_groups, 0, sizeof(FDFSGroups)); memset(&g_groups, 0, sizeof(FDFSGroups));
@ -616,6 +620,38 @@ int tracker_load_from_conf_file(const char *filename, \
break; break;
} }
pMinBuffSize = iniGetStrValue(NULL,
"min_buff_size", &iniContext);
if (pMinBuffSize == NULL) {
min_buff_size = TRACKER_MAX_PACKAGE_SIZE;
}
else if ((result=parse_bytes(pMinBuffSize, 1,
&min_buff_size)) != 0)
{
return result;
}
g_min_buff_size = (int)min_buff_size;
pMaxBuffSize = iniGetStrValue(NULL,
"max_buff_size", &iniContext);
if (pMaxBuffSize == NULL) {
max_buff_size = 16 * TRACKER_MAX_PACKAGE_SIZE;
}
else if ((result=parse_bytes(pMaxBuffSize, 1,
&max_buff_size)) != 0)
{
return result;
}
g_max_buff_size = (int)max_buff_size;
if (g_min_buff_size < TRACKER_MAX_PACKAGE_SIZE) {
g_min_buff_size = TRACKER_MAX_PACKAGE_SIZE;
}
if (g_max_buff_size < g_min_buff_size) {
g_max_buff_size = g_min_buff_size;
}
#ifdef WITH_HTTPD #ifdef WITH_HTTPD
if ((result=fdfs_http_params_load(&iniContext, \ if ((result=fdfs_http_params_load(&iniContext, \
filename, &g_http_params)) != 0) filename, &g_http_params)) != 0)
@ -667,6 +703,8 @@ int tracker_load_from_conf_file(const char *filename, \
"max_connections=%d, " \ "max_connections=%d, " \
"accept_threads=%d, " \ "accept_threads=%d, " \
"work_threads=%d, " \ "work_threads=%d, " \
"min_buff_size=%d, " \
"max_buff_size=%d, " \
"store_lookup=%d, store_group=%s, " \ "store_lookup=%d, store_group=%s, " \
"store_server=%d, store_path=%d, " \ "store_server=%d, store_path=%d, " \
"reserved_storage_space=%s, " \ "reserved_storage_space=%s, " \
@ -703,6 +741,7 @@ int tracker_load_from_conf_file(const char *filename, \
g_fdfs_connect_timeout, \ g_fdfs_connect_timeout, \
g_fdfs_network_timeout, g_server_port, bind_addr, \ g_fdfs_network_timeout, g_server_port, bind_addr, \
g_max_connections, g_accept_threads, g_work_threads, \ g_max_connections, g_accept_threads, g_work_threads, \
g_min_buff_size, g_max_buff_size, \
g_groups.store_lookup, g_groups.store_group, \ g_groups.store_lookup, g_groups.store_group, \
g_groups.store_server, g_groups.store_path, \ g_groups.store_server, g_groups.store_path, \
fdfs_storage_reserved_space_to_string( \ fdfs_storage_reserved_space_to_string( \

View File

@ -15,6 +15,8 @@ int g_accept_threads = 1;
int g_work_threads = DEFAULT_WORK_THREADS; int g_work_threads = DEFAULT_WORK_THREADS;
int g_sync_log_buff_interval = SYNC_LOG_BUFF_DEF_INTERVAL; int g_sync_log_buff_interval = SYNC_LOG_BUFF_DEF_INTERVAL;
int g_check_active_interval = CHECK_ACTIVE_DEF_INTERVAL; int g_check_active_interval = CHECK_ACTIVE_DEF_INTERVAL;
int g_min_buff_size = TRACKER_MAX_PACKAGE_SIZE;
int g_max_buff_size = 16 * TRACKER_MAX_PACKAGE_SIZE;
FDFSGroups g_groups; FDFSGroups g_groups;
int g_storage_stat_chg_count = 0; int g_storage_stat_chg_count = 0;

View File

@ -41,6 +41,8 @@ extern FDFSGroups g_groups;
extern int g_storage_stat_chg_count; extern int g_storage_stat_chg_count;
extern int g_storage_sync_time_chg_count; //sync timestamp extern int g_storage_sync_time_chg_count; //sync timestamp
extern int g_max_connections; extern int g_max_connections;
extern int g_min_buff_size;
extern int g_max_buff_size;
extern int g_accept_threads; extern int g_accept_threads;
extern int g_work_threads; extern int g_work_threads;
extern FDFSStorageReservedSpace g_storage_reserved_space; extern FDFSStorageReservedSpace g_storage_reserved_space;

View File

@ -82,8 +82,8 @@ int tracker_service_init()
init_connections = g_max_connections < ALLOC_CONNECTIONS_ONCE ? init_connections = g_max_connections < ALLOC_CONNECTIONS_ONCE ?
g_max_connections : ALLOC_CONNECTIONS_ONCE; g_max_connections : ALLOC_CONNECTIONS_ONCE;
if ((result=free_queue_init_ex(g_max_connections, init_connections, if ((result=free_queue_init_ex(g_max_connections, init_connections,
ALLOC_CONNECTIONS_ONCE, TRACKER_MAX_PACKAGE_SIZE, ALLOC_CONNECTIONS_ONCE, g_min_buff_size,
TRACKER_MAX_PACKAGE_SIZE, sizeof(TrackerClientInfo))) != 0) g_max_buff_size, sizeof(TrackerClientInfo))) != 0)
{ {
return result; return result;
} }
@ -2969,10 +2969,27 @@ static int tracker_deal_server_list_all_groups(struct fast_task_info *pTask)
} }
expect_size = sizeof(TrackerHeader) + g_groups.count * sizeof(TrackerGroupStat); expect_size = sizeof(TrackerHeader) + g_groups.count * sizeof(TrackerGroupStat);
if ((result=free_queue_set_buffer_size(pTask, expect_size)) != 0) if (expect_size > g_min_buff_size)
{ {
pTask->length = sizeof(TrackerHeader); if (expect_size <= g_max_buff_size)
return result; {
if ((result=free_queue_set_buffer_size(pTask, expect_size)) != 0)
{
pTask->length = sizeof(TrackerHeader);
return result;
}
}
else
{
logError("file: "__FILE__", line: %d, "
"cmd=%d, client ip: %s, "
"expect buffer size: %d > max_buff_size: %d, "
"you should increase max_buff_size in tracker.conf",
__LINE__, TRACKER_PROTO_CMD_SERVER_LIST_ALL_GROUPS,
pTask->client_ip, expect_size, g_max_buff_size);
pTask->length = sizeof(TrackerHeader);
return ENOSPC;
}
} }
groupStats = (TrackerGroupStat *)(pTask->data + sizeof(TrackerHeader)); groupStats = (TrackerGroupStat *)(pTask->data + sizeof(TrackerHeader));