Skip to content

Commit

Permalink
add connection stats
Browse files Browse the repository at this point in the history
  • Loading branch information
yuqing committed Sep 13, 2014
1 parent b32ef5c commit 738a320
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 10 deletions.
6 changes: 6 additions & 0 deletions storage/storage_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ static int fdfs_dump_storage_stat(char *buff, const int buffSize)
total_len = snprintf(buff, buffSize,
"\ng_stat_change_count=%d\n"
"g_sync_change_count=%d\n"
"alloc_count=%d\n"
"current_count=%d\n"
"max_count=%d\n"
"total_upload_count=%"PRId64"\n"
"success_upload_count=%"PRId64"\n"
"total_set_meta_count=%"PRId64"\n"
Expand All @@ -350,6 +353,9 @@ static int fdfs_dump_storage_stat(char *buff, const int buffSize)
"last_synced_timestamp=%s\n"
"last_heart_beat_time=%s\n",
g_stat_change_count, g_sync_change_count,
free_queue_alloc_connections(),
g_storage_stat.connection.current_count,
g_storage_stat.connection.max_count,
g_storage_stat.total_upload_count,
g_storage_stat.success_upload_count,
g_storage_stat.total_set_meta_count,
Expand Down
2 changes: 0 additions & 2 deletions storage/storage_global.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ char g_exe_name[256] = {0};
struct storage_nio_thread_data *g_nio_thread_data = NULL;
struct storage_dio_thread_data *g_dio_thread_data = NULL;

FDFSConnectionStat g_connection_stat = {0, 0};

int storage_cmp_by_server_id(const void *p1, const void *p2)
{
return strcmp((*((FDFSStorageServer **)p1))->server.id,
Expand Down
2 changes: 0 additions & 2 deletions storage/storage_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,6 @@ extern char g_exe_name[256];
extern struct storage_nio_thread_data *g_nio_thread_data; //network io thread data
extern struct storage_dio_thread_data *g_dio_thread_data; //disk io thread data

extern FDFSConnectionStat g_connection_stat;

int storage_cmp_by_server_id(const void *p1, const void *p2);

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion storage/storage_nio.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void task_finish_clean_up(struct fast_task_info *pTask)
memset(pTask->arg, 0, sizeof(StorageClientInfo));
free_queue_push(pTask);

__sync_fetch_and_sub(&g_connection_stat.current_count, 1);
__sync_fetch_and_sub(&g_storage_stat.connection.current_count, 1);
++g_stat_change_count;
}

Expand Down
6 changes: 3 additions & 3 deletions storage/storage_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -1852,10 +1852,10 @@ static void *accept_thread_entrance(void* arg)
else
{
int current_connections;
current_connections = __sync_add_and_fetch(&g_connection_stat.
current_connections = __sync_add_and_fetch(&g_storage_stat.connection.
current_count, 1);
if (current_connections > g_connection_stat.max_count) {
g_connection_stat.max_count = current_connections;
if (current_connections > g_storage_stat.connection.max_count) {
g_storage_stat.connection.max_count = current_connections;
}
++g_stat_change_count;
}
Expand Down
1 change: 1 addition & 0 deletions tracker/tracker_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -2223,6 +2223,7 @@ static int tracker_deal_server_list_group_storages(struct fast_task_info *pTask)
long2buff((*ppServer)->current_write_path, \
pDest->sz_current_write_path);


int2buff(pStorageStat->connection.alloc_count, \
pStatBuff->connection.sz_alloc_count);
int2buff(pStorageStat->connection.current_count, \
Expand Down
4 changes: 2 additions & 2 deletions tracker/tracker_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ typedef struct

struct {
int alloc_count;
int current_count;
volatile int current_count;
int max_count;
} connection;
} FDFSStorageStat;
Expand Down Expand Up @@ -454,7 +454,7 @@ typedef struct {

typedef struct fdfs_connection_stat {
volatile int current_count;
volatile int max_count;
int max_count;
} FDFSConnectionStat;

#endif
Expand Down

0 comments on commit 738a320

Please sign in to comment.