From b1423a3acecf24d4fd387b32e3a13e8c0eee59d8 Mon Sep 17 00:00:00 2001 From: yuqing Date: Fri, 29 Jun 2018 11:21:07 +0800 Subject: [PATCH] include libfastcommon header files start with fastcommon/ --- client/client_func.c | 12 +- client/client_func.h | 2 +- client/client_global.h | 2 +- client/fdfs_append_file.c | 2 +- client/fdfs_appender_test.c | 6 +- client/fdfs_appender_test1.c | 6 +- client/fdfs_client.h | 2 +- client/fdfs_crc32.c | 2 +- client/fdfs_delete_file.c | 2 +- client/fdfs_download_file.c | 2 +- client/fdfs_file_info.c | 2 +- client/fdfs_monitor.c | 4 +- client/fdfs_test.c | 6 +- client/fdfs_test1.c | 6 +- client/fdfs_upload_appender.c | 2 +- client/fdfs_upload_file.c | 2 +- client/storage_client.c | 8 +- client/test/fdfs_monitor.c | 590 +++++++++++++++- client/test/fdfs_test.c | 692 ++++++++++++++++++- client/test/fdfs_test1.c | 659 +++++++++++++++++- client/tracker_client.c | 6 +- common/fdfs_define.h | 2 +- common/fdfs_global.c | 2 +- common/fdfs_global.h | 4 +- common/fdfs_http_shared.c | 6 +- common/fdfs_http_shared.h | 4 +- common/mime_file_parser.c | 6 +- common/mime_file_parser.h | 2 +- make.sh | 2 +- php_client/config.m4 | 3 +- php_client/fastdfs_client.c | 18 +- storage/fdfs_storaged.c | 14 +- storage/fdht_client/fdht_client.c | 10 +- storage/fdht_client/fdht_define.h | 2 +- storage/fdht_client/fdht_func.c | 8 +- storage/fdht_client/fdht_func.h | 2 +- storage/fdht_client/fdht_global.h | 2 +- storage/fdht_client/fdht_proto.c | 6 +- storage/storage_dio.c | 8 +- storage/storage_dio.h | 4 +- storage/storage_disk_recovery.c | 8 +- storage/storage_dump.c | 10 +- storage/storage_func.c | 14 +- storage/storage_global.c | 6 +- storage/storage_global.h | 4 +- storage/storage_ip_changed_dealer.c | 6 +- storage/storage_nio.c | 12 +- storage/storage_nio.h | 4 +- storage/storage_param_getter.c | 4 +- storage/storage_service.c | 16 +- storage/storage_service.h | 4 +- storage/storage_sync.c | 12 +- storage/tracker_client_thread.c | 12 +- storage/trunk_mgr/trunk_client.c | 6 +- storage/trunk_mgr/trunk_client.h | 2 +- storage/trunk_mgr/trunk_free_block_checker.c | 6 +- storage/trunk_mgr/trunk_free_block_checker.h | 2 +- storage/trunk_mgr/trunk_mem.c | 12 +- storage/trunk_mgr/trunk_mem.h | 4 +- storage/trunk_mgr/trunk_shared.c | 4 +- storage/trunk_mgr/trunk_shared.h | 6 +- storage/trunk_mgr/trunk_sync.c | 12 +- test/Makefile | 2 +- test/combine_result.c | 2 +- test/dfs_func.c | 4 +- test/dfs_func_pc.c | 4 +- test/gen_files.c | 2 +- test/test_delete.c | 2 +- test/test_download.c | 4 +- test/test_upload.c | 4 +- tracker/Makefile.in | 2 +- tracker/fdfs_shared_func.c | 6 +- tracker/fdfs_shared_func.h | 6 +- tracker/fdfs_trackerd.c | 14 +- tracker/tracker_dump.c | 10 +- tracker/tracker_func.c | 12 +- tracker/tracker_global.h | 8 +- tracker/tracker_http_check.c | 6 +- tracker/tracker_mem.c | 10 +- tracker/tracker_nio.c | 12 +- tracker/tracker_nio.h | 2 +- tracker/tracker_proto.c | 6 +- tracker/tracker_proto.h | 4 +- tracker/tracker_relationship.c | 8 +- tracker/tracker_service.c | 14 +- tracker/tracker_service.h | 4 +- tracker/tracker_status.c | 8 +- tracker/tracker_types.h | 2 +- 88 files changed, 2189 insertions(+), 255 deletions(-) mode change 120000 => 100644 client/test/fdfs_monitor.c mode change 120000 => 100644 client/test/fdfs_test.c mode change 120000 => 100644 client/test/fdfs_test1.c diff --git a/client/client_func.c b/client/client_func.c index 5d5b4caf..3c812708 100644 --- a/client/client_func.c +++ b/client/client_func.c @@ -19,13 +19,13 @@ #include #include #include "fdfs_define.h" -#include "logger.h" +#include "fastcommon/logger.h" #include "fdfs_global.h" -#include "base64.h" -#include "sockopt.h" -#include "shared_func.h" -#include "ini_file_reader.h" -#include "connection_pool.h" +#include "fastcommon/base64.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/ini_file_reader.h" +#include "fastcommon/connection_pool.h" #include "tracker_types.h" #include "tracker_proto.h" #include "client_global.h" diff --git a/client/client_func.h b/client/client_func.h index fe83ca73..01c338c8 100644 --- a/client/client_func.h +++ b/client/client_func.h @@ -10,7 +10,7 @@ #include "tracker_types.h" #include "client_global.h" -#include "ini_file_reader.h" +#include "fastcommon/ini_file_reader.h" #ifndef _CLIENT_FUNC_H_ #define _CLIENT_FUNC_H_ diff --git a/client/client_global.h b/client/client_global.h index e0e17434..35f58189 100644 --- a/client/client_global.h +++ b/client/client_global.h @@ -11,7 +11,7 @@ #ifndef _CLIENT_GLOBAL_H #define _CLIENT_GLOBAL_H -#include "common_define.h" +#include "fastcommon/common_define.h" #include "tracker_types.h" #include "fdfs_shared_func.h" diff --git a/client/fdfs_append_file.c b/client/fdfs_append_file.c index fd539fad..1bc8b81f 100644 --- a/client/fdfs_append_file.c +++ b/client/fdfs_append_file.c @@ -14,7 +14,7 @@ #include #include #include "fdfs_client.h" -#include "logger.h" +#include "fastcommon/logger.h" int main(int argc, char *argv[]) { diff --git a/client/fdfs_appender_test.c b/client/fdfs_appender_test.c index 0cecb637..1083b0c8 100644 --- a/client/fdfs_appender_test.c +++ b/client/fdfs_appender_test.c @@ -15,9 +15,9 @@ #include #include "fdfs_client.h" #include "fdfs_global.h" -#include "base64.h" -#include "sockopt.h" -#include "logger.h" +#include "fastcommon/base64.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/logger.h" #include "fdfs_http_shared.h" int writeToFileCallback(void *arg, const int64_t file_size, const char *data, \ diff --git a/client/fdfs_appender_test1.c b/client/fdfs_appender_test1.c index 5ddf5e59..b5b59011 100644 --- a/client/fdfs_appender_test1.c +++ b/client/fdfs_appender_test1.c @@ -15,9 +15,9 @@ #include #include "fdfs_client.h" #include "fdfs_global.h" -#include "base64.h" -#include "sockopt.h" -#include "logger.h" +#include "fastcommon/base64.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/logger.h" #include "fdfs_http_shared.h" int writeToFileCallback(void *arg, const int64_t file_size, const char *data, \ diff --git a/client/fdfs_client.h b/client/fdfs_client.h index d63e7920..aaf9a391 100644 --- a/client/fdfs_client.h +++ b/client/fdfs_client.h @@ -9,7 +9,7 @@ #ifndef FDFS_CLIENT_H #define FDFS_CLIENT_H -#include "shared_func.h" +#include "fastcommon/shared_func.h" #include "tracker_types.h" #include "tracker_proto.h" #include "tracker_client.h" diff --git a/client/fdfs_crc32.c b/client/fdfs_crc32.c index f8d75223..7de0e9e5 100644 --- a/client/fdfs_crc32.c +++ b/client/fdfs_crc32.c @@ -14,7 +14,7 @@ #include #include #include -#include "hash.h" +#include "fastcommon/hash.h" int main(int argc, char *argv[]) { diff --git a/client/fdfs_delete_file.c b/client/fdfs_delete_file.c index da3ce1a5..fa0ce4dc 100644 --- a/client/fdfs_delete_file.c +++ b/client/fdfs_delete_file.c @@ -14,7 +14,7 @@ #include #include #include "fdfs_client.h" -#include "logger.h" +#include "fastcommon/logger.h" int main(int argc, char *argv[]) { diff --git a/client/fdfs_download_file.c b/client/fdfs_download_file.c index 23c27751..de68b999 100644 --- a/client/fdfs_download_file.c +++ b/client/fdfs_download_file.c @@ -14,7 +14,7 @@ #include #include #include "fdfs_client.h" -#include "logger.h" +#include "fastcommon/logger.h" int main(int argc, char *argv[]) { diff --git a/client/fdfs_file_info.c b/client/fdfs_file_info.c index 546fbd5a..2e153ad2 100644 --- a/client/fdfs_file_info.c +++ b/client/fdfs_file_info.c @@ -14,7 +14,7 @@ #include #include #include "fdfs_client.h" -#include "logger.h" +#include "fastcommon/logger.h" int main(int argc, char *argv[]) { diff --git a/client/fdfs_monitor.c b/client/fdfs_monitor.c index 11155871..68bd61a6 100644 --- a/client/fdfs_monitor.c +++ b/client/fdfs_monitor.c @@ -13,8 +13,8 @@ #include #include #include -#include "sockopt.h" -#include "logger.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/logger.h" #include "client_global.h" #include "fdfs_global.h" #include "fdfs_client.h" diff --git a/client/fdfs_test.c b/client/fdfs_test.c index afee1d30..ad28e4c6 100644 --- a/client/fdfs_test.c +++ b/client/fdfs_test.c @@ -15,9 +15,9 @@ #include #include "fdfs_client.h" #include "fdfs_global.h" -#include "base64.h" -#include "sockopt.h" -#include "logger.h" +#include "fastcommon/base64.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/logger.h" #include "fdfs_http_shared.h" int writeToFileCallback(void *arg, const int64_t file_size, const char *data, \ diff --git a/client/fdfs_test1.c b/client/fdfs_test1.c index c49a38bd..b942cc35 100644 --- a/client/fdfs_test1.c +++ b/client/fdfs_test1.c @@ -15,10 +15,10 @@ #include #include "fdfs_client.h" #include "fdfs_global.h" -#include "base64.h" +#include "fastcommon/base64.h" #include "fdfs_http_shared.h" -#include "sockopt.h" -#include "logger.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/logger.h" int writeToFileCallback(void *arg, const int64_t file_size, const char *data, \ const int current_size) diff --git a/client/fdfs_upload_appender.c b/client/fdfs_upload_appender.c index ebd02b79..9225c2fc 100644 --- a/client/fdfs_upload_appender.c +++ b/client/fdfs_upload_appender.c @@ -13,7 +13,7 @@ #include #include #include "fdfs_client.h" -#include "logger.h" +#include "fastcommon/logger.h" int main(int argc, char *argv[]) { diff --git a/client/fdfs_upload_file.c b/client/fdfs_upload_file.c index 4ac119f4..900f6a2e 100644 --- a/client/fdfs_upload_file.c +++ b/client/fdfs_upload_file.c @@ -14,7 +14,7 @@ #include #include #include "fdfs_client.h" -#include "logger.h" +#include "fastcommon/logger.h" static void usage(char *argv[]) { diff --git a/client/storage_client.c b/client/storage_client.c index 4b53b63f..e0b18ebd 100644 --- a/client/storage_client.c +++ b/client/storage_client.c @@ -18,10 +18,10 @@ #include #include #include "fdfs_define.h" -#include "logger.h" +#include "fastcommon/logger.h" #include "fdfs_global.h" -#include "sockopt.h" -#include "shared_func.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/shared_func.h" #include "tracker_types.h" #include "tracker_proto.h" #include "client_func.h" @@ -29,7 +29,7 @@ #include "storage_client.h" #include "storage_client1.h" #include "client_global.h" -#include "base64.h" +#include "fastcommon/base64.h" static struct base64_context the_base64_context; static int the_base64_context_inited = 0; diff --git a/client/test/fdfs_monitor.c b/client/test/fdfs_monitor.c deleted file mode 120000 index 9f42ff42..00000000 --- a/client/test/fdfs_monitor.c +++ /dev/null @@ -1 +0,0 @@ -../fdfs_monitor.c \ No newline at end of file diff --git a/client/test/fdfs_monitor.c b/client/test/fdfs_monitor.c new file mode 100644 index 00000000..68bd61a6 --- /dev/null +++ b/client/test/fdfs_monitor.c @@ -0,0 +1,589 @@ +/** +* Copyright (C) 2008 Happy Fish / YuQing +* +* FastDFS may be copied only under the terms of the GNU General +* Public License V3, which may be found in the FastDFS source kit. +* Please visit the FastDFS Home Page http://www.csource.org/ for more detail. +**/ + +#include +#include +#include +#include +#include +#include +#include +#include "fastcommon/sockopt.h" +#include "fastcommon/logger.h" +#include "client_global.h" +#include "fdfs_global.h" +#include "fdfs_client.h" + +static ConnectionInfo *pTrackerServer; + +static int list_all_groups(const char *group_name); + +static void usage(char *argv[]) +{ + printf("Usage: %s [-h ] [list|delete|set_trunk_server " \ + "[storage_id]]\n", argv[0]); +} + +int main(int argc, char *argv[]) +{ + char *conf_filename; + int result; + char *op_type; + char *tracker_server; + int arg_index; + char *group_name; + + if (argc < 2) + { + usage(argv); + return 1; + } + + tracker_server = NULL; + conf_filename = argv[1]; + arg_index = 2; + + if (arg_index >= argc) + { + op_type = "list"; + } + else + { + int len; + + len = strlen(argv[arg_index]); + if (len >= 2 && strncmp(argv[arg_index], "-h", 2) == 0) + { + if (len == 2) + { + arg_index++; + if (arg_index >= argc) + { + usage(argv); + return 1; + } + + tracker_server = argv[arg_index++]; + } + else + { + tracker_server = argv[arg_index] + 2; + arg_index++; + } + + if (arg_index < argc) + { + op_type = argv[arg_index++]; + } + else + { + op_type = "list"; + } + } + else + { + op_type = argv[arg_index++]; + } + } + + log_init(); + g_log_context.log_level = LOG_DEBUG; + ignore_signal_pipe(); + + if ((result=fdfs_client_init(conf_filename)) != 0) + { + return result; + } + load_log_level_ex(conf_filename); + + if (tracker_server == NULL) + { + if (g_tracker_group.server_count > 1) + { + srand(time(NULL)); + rand(); //discard the first + g_tracker_group.server_index = (int)( \ + (g_tracker_group.server_count * (double)rand()) \ + / (double)RAND_MAX); + } + } + else + { + int i; + char ip_addr[IP_ADDRESS_SIZE]; + + *ip_addr = '\0'; + if (getIpaddrByName(tracker_server, ip_addr, sizeof(ip_addr)) \ + == INADDR_NONE) + { + printf("resolve ip address of tracker server: %s " \ + "fail!\n", tracker_server); + return 2; + } + + for (i=0; iip_addr, pTrackerServer->port); + + if (arg_index < argc) + { + group_name = argv[arg_index++]; + } + else + { + group_name = NULL; + } + + if (strcmp(op_type, "list") == 0) + { + if (group_name == NULL) + { + result = list_all_groups(NULL); + } + else + { + result = list_all_groups(group_name); + } + } + else if (strcmp(op_type, "delete") == 0) + { + if (arg_index >= argc) + { + if ((result=tracker_delete_group(&g_tracker_group, \ + group_name)) == 0) + { + printf("delete group: %s success\n", \ + group_name); + } + else + { + printf("delete group: %s fail, " \ + "error no: %d, error info: %s\n", \ + group_name, result, STRERROR(result)); + } + } + else + { + char *storage_id; + + storage_id = argv[arg_index++]; + if ((result=tracker_delete_storage(&g_tracker_group, \ + group_name, storage_id)) == 0) + { + printf("delete storage server %s::%s success\n", \ + group_name, storage_id); + } + else + { + printf("delete storage server %s::%s fail, " \ + "error no: %d, error info: %s\n", \ + group_name, storage_id, \ + result, STRERROR(result)); + } + } + } + else if (strcmp(op_type, "set_trunk_server") == 0) + { + char *storage_id; + char new_trunk_server_id[FDFS_STORAGE_ID_MAX_SIZE]; + + if (group_name == NULL) + { + usage(argv); + return 1; + } + if (arg_index >= argc) + { + storage_id = ""; + } + else + { + storage_id = argv[arg_index++]; + } + + if ((result=tracker_set_trunk_server(&g_tracker_group, \ + group_name, storage_id, new_trunk_server_id)) == 0) + { + printf("set trunk server %s::%s success, " \ + "new trunk server: %s\n", group_name, \ + storage_id, new_trunk_server_id); + } + else + { + printf("set trunk server %s::%s fail, " \ + "error no: %d, error info: %s\n", \ + group_name, storage_id, \ + result, STRERROR(result)); + } + } + else + { + printf("Invalid command %s\n\n", op_type); + usage(argv); + } + + tracker_disconnect_server_ex(pTrackerServer, true); + fdfs_client_destroy(); + return 0; +} + +static int list_storages(FDFSGroupStat *pGroupStat) +{ + int result; + int storage_count; + FDFSStorageInfo storage_infos[FDFS_MAX_SERVERS_EACH_GROUP]; + FDFSStorageInfo *p; + FDFSStorageInfo *pStorage; + FDFSStorageInfo *pStorageEnd; + FDFSStorageStat *pStorageStat; + char szJoinTime[32]; + char szUpTime[32]; + char szLastHeartBeatTime[32]; + char szSrcUpdTime[32]; + char szSyncUpdTime[32]; + char szSyncedTimestamp[32]; + char szSyncedDelaySeconds[128]; + char szHostname[128]; + char szHostnamePrompt[128+8]; + int k; + int max_last_source_update; + + printf( "group name = %s\n" \ + "disk total space = %"PRId64" MB\n" \ + "disk free space = %"PRId64" MB\n" \ + "trunk free space = %"PRId64" MB\n" \ + "storage server count = %d\n" \ + "active server count = %d\n" \ + "storage server port = %d\n" \ + "storage HTTP port = %d\n" \ + "store path count = %d\n" \ + "subdir count per path = %d\n" \ + "current write server index = %d\n" \ + "current trunk file id = %d\n\n", \ + pGroupStat->group_name, \ + pGroupStat->total_mb, \ + pGroupStat->free_mb, \ + pGroupStat->trunk_free_mb, \ + pGroupStat->count, \ + pGroupStat->active_count, \ + pGroupStat->storage_port, \ + pGroupStat->storage_http_port, \ + pGroupStat->store_path_count, \ + pGroupStat->subdir_count_per_path, \ + pGroupStat->current_write_server, \ + pGroupStat->current_trunk_file_id + ); + + result = tracker_list_servers(pTrackerServer, \ + pGroupStat->group_name, NULL, \ + storage_infos, FDFS_MAX_SERVERS_EACH_GROUP, \ + &storage_count); + if (result != 0) + { + return result; + } + + k = 0; + pStorageEnd = storage_infos + storage_count; + for (pStorage=storage_infos; pStoragestat.last_source_update + > max_last_source_update) + { + max_last_source_update = \ + p->stat.last_source_update; + } + } + + pStorageStat = &(pStorage->stat); + if (max_last_source_update == 0) + { + *szSyncedDelaySeconds = '\0'; + } + else + { + if (pStorageStat->last_synced_timestamp == 0) + { + strcpy(szSyncedDelaySeconds, "(never synced)"); + } + else + { + int delay_seconds; + int remain_seconds; + int day; + int hour; + int minute; + int second; + char szDelayTime[64]; + + delay_seconds = (int)(max_last_source_update - \ + pStorageStat->last_synced_timestamp); + day = delay_seconds / (24 * 3600); + remain_seconds = delay_seconds % (24 * 3600); + hour = remain_seconds / 3600; + remain_seconds %= 3600; + minute = remain_seconds / 60; + second = remain_seconds % 60; + + if (day != 0) + { + sprintf(szDelayTime, "%d days " \ + "%02dh:%02dm:%02ds", \ + day, hour, minute, second); + } + else if (hour != 0) + { + sprintf(szDelayTime, "%02dh:%02dm:%02ds", \ + hour, minute, second); + } + else if (minute != 0) + { + sprintf(szDelayTime, "%02dm:%02ds", minute, second); + } + else + { + sprintf(szDelayTime, "%ds", second); + } + + sprintf(szSyncedDelaySeconds, "(%s delay)", szDelayTime); + } + } + + getHostnameByIp(pStorage->ip_addr, szHostname, sizeof(szHostname)); + if (*szHostname != '\0') + { + sprintf(szHostnamePrompt, " (%s)", szHostname); + } + else + { + *szHostnamePrompt = '\0'; + } + + if (pStorage->up_time != 0) + { + formatDatetime(pStorage->up_time, \ + "%Y-%m-%d %H:%M:%S", \ + szUpTime, sizeof(szUpTime)); + } + else + { + *szUpTime = '\0'; + } + + printf( "\tStorage %d:\n" \ + "\t\tid = %s\n" \ + "\t\tip_addr = %s%s %s\n" \ + "\t\thttp domain = %s\n" \ + "\t\tversion = %s\n" \ + "\t\tjoin time = %s\n" \ + "\t\tup time = %s\n" \ + "\t\ttotal storage = %d MB\n" \ + "\t\tfree storage = %d MB\n" \ + "\t\tupload priority = %d\n" \ + "\t\tstore_path_count = %d\n" \ + "\t\tsubdir_count_per_path = %d\n" \ + "\t\tstorage_port = %d\n" \ + "\t\tstorage_http_port = %d\n" \ + "\t\tcurrent_write_path = %d\n" \ + "\t\tsource storage id = %s\n" \ + "\t\tif_trunk_server = %d\n" \ + "\t\tconnection.alloc_count = %d\n" \ + "\t\tconnection.current_count = %d\n" \ + "\t\tconnection.max_count = %d\n" \ + "\t\ttotal_upload_count = %"PRId64"\n" \ + "\t\tsuccess_upload_count = %"PRId64"\n" \ + "\t\ttotal_append_count = %"PRId64"\n" \ + "\t\tsuccess_append_count = %"PRId64"\n" \ + "\t\ttotal_modify_count = %"PRId64"\n" \ + "\t\tsuccess_modify_count = %"PRId64"\n" \ + "\t\ttotal_truncate_count = %"PRId64"\n" \ + "\t\tsuccess_truncate_count = %"PRId64"\n" \ + "\t\ttotal_set_meta_count = %"PRId64"\n" \ + "\t\tsuccess_set_meta_count = %"PRId64"\n" \ + "\t\ttotal_delete_count = %"PRId64"\n" \ + "\t\tsuccess_delete_count = %"PRId64"\n" \ + "\t\ttotal_download_count = %"PRId64"\n" \ + "\t\tsuccess_download_count = %"PRId64"\n" \ + "\t\ttotal_get_meta_count = %"PRId64"\n" \ + "\t\tsuccess_get_meta_count = %"PRId64"\n" \ + "\t\ttotal_create_link_count = %"PRId64"\n" \ + "\t\tsuccess_create_link_count = %"PRId64"\n"\ + "\t\ttotal_delete_link_count = %"PRId64"\n" \ + "\t\tsuccess_delete_link_count = %"PRId64"\n" \ + "\t\ttotal_upload_bytes = %"PRId64"\n" \ + "\t\tsuccess_upload_bytes = %"PRId64"\n" \ + "\t\ttotal_append_bytes = %"PRId64"\n" \ + "\t\tsuccess_append_bytes = %"PRId64"\n" \ + "\t\ttotal_modify_bytes = %"PRId64"\n" \ + "\t\tsuccess_modify_bytes = %"PRId64"\n" \ + "\t\tstotal_download_bytes = %"PRId64"\n" \ + "\t\tsuccess_download_bytes = %"PRId64"\n" \ + "\t\ttotal_sync_in_bytes = %"PRId64"\n" \ + "\t\tsuccess_sync_in_bytes = %"PRId64"\n" \ + "\t\ttotal_sync_out_bytes = %"PRId64"\n" \ + "\t\tsuccess_sync_out_bytes = %"PRId64"\n" \ + "\t\ttotal_file_open_count = %"PRId64"\n" \ + "\t\tsuccess_file_open_count = %"PRId64"\n" \ + "\t\ttotal_file_read_count = %"PRId64"\n" \ + "\t\tsuccess_file_read_count = %"PRId64"\n" \ + "\t\ttotal_file_write_count = %"PRId64"\n" \ + "\t\tsuccess_file_write_count = %"PRId64"\n" \ + "\t\tlast_heart_beat_time = %s\n" \ + "\t\tlast_source_update = %s\n" \ + "\t\tlast_sync_update = %s\n" \ + "\t\tlast_synced_timestamp = %s %s\n", \ + ++k, pStorage->id, pStorage->ip_addr, \ + szHostnamePrompt, get_storage_status_caption( \ + pStorage->status), pStorage->domain_name, \ + pStorage->version, \ + formatDatetime(pStorage->join_time, \ + "%Y-%m-%d %H:%M:%S", \ + szJoinTime, sizeof(szJoinTime)), \ + szUpTime, pStorage->total_mb, \ + pStorage->free_mb, \ + pStorage->upload_priority, \ + pStorage->store_path_count, \ + pStorage->subdir_count_per_path, \ + pStorage->storage_port, \ + pStorage->storage_http_port, \ + pStorage->current_write_path, \ + pStorage->src_id, \ + pStorage->if_trunk_server, \ + pStorageStat->connection.alloc_count, \ + pStorageStat->connection.current_count, \ + pStorageStat->connection.max_count, \ + pStorageStat->total_upload_count, \ + pStorageStat->success_upload_count, \ + pStorageStat->total_append_count, \ + pStorageStat->success_append_count, \ + pStorageStat->total_modify_count, \ + pStorageStat->success_modify_count, \ + pStorageStat->total_truncate_count, \ + pStorageStat->success_truncate_count, \ + pStorageStat->total_set_meta_count, \ + pStorageStat->success_set_meta_count, \ + pStorageStat->total_delete_count, \ + pStorageStat->success_delete_count, \ + pStorageStat->total_download_count, \ + pStorageStat->success_download_count, \ + pStorageStat->total_get_meta_count, \ + pStorageStat->success_get_meta_count, \ + pStorageStat->total_create_link_count, \ + pStorageStat->success_create_link_count, \ + pStorageStat->total_delete_link_count, \ + pStorageStat->success_delete_link_count, \ + pStorageStat->total_upload_bytes, \ + pStorageStat->success_upload_bytes, \ + pStorageStat->total_append_bytes, \ + pStorageStat->success_append_bytes, \ + pStorageStat->total_modify_bytes, \ + pStorageStat->success_modify_bytes, \ + pStorageStat->total_download_bytes, \ + pStorageStat->success_download_bytes, \ + pStorageStat->total_sync_in_bytes, \ + pStorageStat->success_sync_in_bytes, \ + pStorageStat->total_sync_out_bytes, \ + pStorageStat->success_sync_out_bytes, \ + pStorageStat->total_file_open_count, \ + pStorageStat->success_file_open_count, \ + pStorageStat->total_file_read_count, \ + pStorageStat->success_file_read_count, \ + pStorageStat->total_file_write_count, \ + pStorageStat->success_file_write_count, \ + formatDatetime(pStorageStat->last_heart_beat_time, \ + "%Y-%m-%d %H:%M:%S", \ + szLastHeartBeatTime, sizeof(szLastHeartBeatTime)), \ + formatDatetime(pStorageStat->last_source_update, \ + "%Y-%m-%d %H:%M:%S", \ + szSrcUpdTime, sizeof(szSrcUpdTime)), \ + formatDatetime(pStorageStat->last_sync_update, \ + "%Y-%m-%d %H:%M:%S", \ + szSyncUpdTime, sizeof(szSyncUpdTime)), \ + formatDatetime(pStorageStat->last_synced_timestamp, \ + "%Y-%m-%d %H:%M:%S", \ + szSyncedTimestamp, sizeof(szSyncedTimestamp)),\ + szSyncedDelaySeconds); + } + + return 0; +} + +static int list_all_groups(const char *group_name) +{ + int result; + int group_count; + FDFSGroupStat group_stats[FDFS_MAX_GROUPS]; + FDFSGroupStat *pGroupStat; + FDFSGroupStat *pGroupEnd; + int i; + + result = tracker_list_groups(pTrackerServer, \ + group_stats, FDFS_MAX_GROUPS, \ + &group_count); + if (result != 0) + { + tracker_close_all_connections(); + fdfs_client_destroy(); + return result; + } + + pGroupEnd = group_stats + group_count; + if (group_name == NULL) + { + printf("group count: %d\n", group_count); + i = 0; + for (pGroupStat=group_stats; pGroupStatgroup_name, group_name) == 0) + { + list_storages(pGroupStat); + break; + } + } + } + + return 0; +} + diff --git a/client/test/fdfs_test.c b/client/test/fdfs_test.c deleted file mode 120000 index c3a3f16e..00000000 --- a/client/test/fdfs_test.c +++ /dev/null @@ -1 +0,0 @@ -../fdfs_test.c \ No newline at end of file diff --git a/client/test/fdfs_test.c b/client/test/fdfs_test.c new file mode 100644 index 00000000..ad28e4c6 --- /dev/null +++ b/client/test/fdfs_test.c @@ -0,0 +1,691 @@ +/** +* Copyright (C) 2008 Happy Fish / YuQing +* +* FastDFS may be copied only under the terms of the GNU General +* Public License V3, which may be found in the FastDFS source kit. +* Please visit the FastDFS Home Page http://www.csource.org/ for more detail. +**/ + +#include +#include +#include +#include +#include +#include +#include +#include "fdfs_client.h" +#include "fdfs_global.h" +#include "fastcommon/base64.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/logger.h" +#include "fdfs_http_shared.h" + +int writeToFileCallback(void *arg, const int64_t file_size, const char *data, \ + const int current_size) +{ + if (arg == NULL) + { + return EINVAL; + } + + if (fwrite(data, current_size, 1, (FILE *)arg) != 1) + { + return errno != 0 ? errno : EIO; + } + + return 0; +} + +int uploadFileCallback(void *arg, const int64_t file_size, int sock) +{ + int64_t total_send_bytes; + char *filename; + + if (arg == NULL) + { + return EINVAL; + } + + filename = (char *)arg; + return tcpsendfile(sock, filename, file_size, \ + g_fdfs_network_timeout, &total_send_bytes); +} + +int main(int argc, char *argv[]) +{ + char *conf_filename; + char *local_filename; + ConnectionInfo *pTrackerServer; + ConnectionInfo *pStorageServer; + int result; + ConnectionInfo storageServer; + char group_name[FDFS_GROUP_NAME_MAX_LEN + 1]; + char remote_filename[256]; + char master_filename[256]; + FDFSMetaData meta_list[32]; + int meta_count; + int i; + FDFSMetaData *pMetaList; + char token[32 + 1]; + char file_id[128]; + char file_url[256]; + char szDatetime[20]; + char szPortPart[16]; + int url_len; + time_t ts; + char *file_buff; + int64_t file_size; + char *operation; + char *meta_buff; + int store_path_index; + FDFSFileInfo file_info; + + printf("This is FastDFS client test program v%d.%02d\n" \ +"\nCopyright (C) 2008, Happy Fish / YuQing\n" \ +"\nFastDFS may be copied only under the terms of the GNU General\n" \ +"Public License V3, which may be found in the FastDFS source kit.\n" \ +"Please visit the FastDFS Home Page http://www.csource.org/ \n" \ +"for more detail.\n\n" \ +, g_fdfs_version.major, g_fdfs_version.minor); + + if (argc < 3) + { + printf("Usage: %s \n" \ + "\toperation: upload, download, getmeta, setmeta, " \ + "delete and query_servers\n", argv[0]); + return 1; + } + + log_init(); + g_log_context.log_level = LOG_DEBUG; + + conf_filename = argv[1]; + operation = argv[2]; + if ((result=fdfs_client_init(conf_filename)) != 0) + { + return result; + } + + pTrackerServer = tracker_get_connection(); + if (pTrackerServer == NULL) + { + fdfs_client_destroy(); + return errno != 0 ? errno : ECONNREFUSED; + } + + pStorageServer = NULL; + *group_name = '\0'; + local_filename = NULL; + if (strcmp(operation, "upload") == 0) + { + int upload_type; + char *prefix_name; + const char *file_ext_name; + char slave_filename[256]; + int slave_filename_len; + + if (argc < 4) + { + printf("Usage: %s upload " \ + " [FILE | BUFF | CALLBACK] \n",\ + argv[0]); + fdfs_client_destroy(); + return EINVAL; + } + + local_filename = argv[3]; + if (argc == 4) + { + upload_type = FDFS_UPLOAD_BY_FILE; + } + else + { + if (strcmp(argv[4], "BUFF") == 0) + { + upload_type = FDFS_UPLOAD_BY_BUFF; + } + else if (strcmp(argv[4], "CALLBACK") == 0) + { + upload_type = FDFS_UPLOAD_BY_CALLBACK; + } + else + { + upload_type = FDFS_UPLOAD_BY_FILE; + } + } + + store_path_index = 0; + + { + ConnectionInfo storageServers[FDFS_MAX_SERVERS_EACH_GROUP]; + ConnectionInfo *pServer; + ConnectionInfo *pServerEnd; + int storage_count; + + if ((result=tracker_query_storage_store_list_without_group( \ + pTrackerServer, storageServers, \ + FDFS_MAX_SERVERS_EACH_GROUP, &storage_count, \ + group_name, &store_path_index)) == 0) + { + printf("tracker_query_storage_store_list_without_group: \n"); + pServerEnd = storageServers + storage_count; + for (pServer=storageServers; pServerip_addr, pServer->port); + } + printf("\n"); + } + } + + if ((result=tracker_query_storage_store(pTrackerServer, \ + &storageServer, group_name, &store_path_index)) != 0) + { + fdfs_client_destroy(); + printf("tracker_query_storage fail, " \ + "error no: %d, error info: %s\n", \ + result, STRERROR(result)); + return result; + } + + printf("group_name=%s, ip_addr=%s, port=%d\n", \ + group_name, storageServer.ip_addr, \ + storageServer.port); + + if ((pStorageServer=tracker_connect_server(&storageServer, \ + &result)) == NULL) + { + fdfs_client_destroy(); + return result; + } + + memset(&meta_list, 0, sizeof(meta_list)); + meta_count = 0; + strcpy(meta_list[meta_count].name, "ext_name"); + strcpy(meta_list[meta_count].value, "jpg"); + meta_count++; + strcpy(meta_list[meta_count].name, "width"); + strcpy(meta_list[meta_count].value, "160"); + meta_count++; + strcpy(meta_list[meta_count].name, "height"); + strcpy(meta_list[meta_count].value, "80"); + meta_count++; + strcpy(meta_list[meta_count].name, "file_size"); + strcpy(meta_list[meta_count].value, "115120"); + meta_count++; + + file_ext_name = fdfs_get_file_ext_name(local_filename); + *group_name = '\0'; + + if (upload_type == FDFS_UPLOAD_BY_FILE) + { + result = storage_upload_by_filename(pTrackerServer, \ + pStorageServer, store_path_index, \ + local_filename, file_ext_name, \ + meta_list, meta_count, \ + group_name, remote_filename); + + printf("storage_upload_by_filename\n"); + } + else if (upload_type == FDFS_UPLOAD_BY_BUFF) + { + char *file_content; + if ((result=getFileContent(local_filename, \ + &file_content, &file_size)) == 0) + { + result = storage_upload_by_filebuff(pTrackerServer, \ + pStorageServer, store_path_index, \ + file_content, file_size, file_ext_name, \ + meta_list, meta_count, \ + group_name, remote_filename); + free(file_content); + } + + printf("storage_upload_by_filebuff\n"); + } + else + { + struct stat stat_buf; + + if (stat(local_filename, &stat_buf) == 0 && \ + S_ISREG(stat_buf.st_mode)) + { + file_size = stat_buf.st_size; + result = storage_upload_by_callback(pTrackerServer, \ + pStorageServer, store_path_index, \ + uploadFileCallback, local_filename, \ + file_size, file_ext_name, \ + meta_list, meta_count, \ + group_name, remote_filename); + } + + printf("storage_upload_by_callback\n"); + } + + if (result != 0) + { + printf("upload file fail, " \ + "error no: %d, error info: %s\n", \ + result, STRERROR(result)); + tracker_disconnect_server_ex(pStorageServer, true); + fdfs_client_destroy(); + return result; + } + + if (g_tracker_server_http_port == 80) + { + *szPortPart = '\0'; + } + else + { + sprintf(szPortPart, ":%d", g_tracker_server_http_port); + } + + sprintf(file_id, "%s/%s", group_name, remote_filename); + url_len = sprintf(file_url, "http://%s%s/%s", \ + pStorageServer->ip_addr, szPortPart, file_id); + if (g_anti_steal_token) + { + ts = time(NULL); + fdfs_http_gen_token(&g_anti_steal_secret_key, file_id, \ + ts, token); + sprintf(file_url + url_len, "?token=%s&ts=%d", \ + token, (int)ts); + } + + printf("group_name=%s, remote_filename=%s\n", \ + group_name, remote_filename); + + fdfs_get_file_info(group_name, remote_filename, &file_info); + printf("source ip address: %s\n", file_info.source_ip_addr); + printf("file timestamp=%s\n", formatDatetime( + file_info.create_timestamp, "%Y-%m-%d %H:%M:%S", \ + szDatetime, sizeof(szDatetime))); + printf("file size=%"PRId64"\n", file_info.file_size); + printf("file crc32=%u\n", file_info.crc32); + printf("example file url: %s\n", file_url); + + strcpy(master_filename, remote_filename); + *remote_filename = '\0'; + if (upload_type == FDFS_UPLOAD_BY_FILE) + { + prefix_name = "_big"; + result = storage_upload_slave_by_filename(pTrackerServer, + NULL, local_filename, master_filename, \ + prefix_name, file_ext_name, \ + meta_list, meta_count, \ + group_name, remote_filename); + + printf("storage_upload_slave_by_filename\n"); + } + else if (upload_type == FDFS_UPLOAD_BY_BUFF) + { + char *file_content; + prefix_name = "1024x1024"; + if ((result=getFileContent(local_filename, \ + &file_content, &file_size)) == 0) + { + result = storage_upload_slave_by_filebuff(pTrackerServer, \ + NULL, file_content, file_size, master_filename, + prefix_name, file_ext_name, \ + meta_list, meta_count, \ + group_name, remote_filename); + free(file_content); + } + + printf("storage_upload_slave_by_filebuff\n"); + } + else + { + struct stat stat_buf; + + prefix_name = "-small"; + if (stat(local_filename, &stat_buf) == 0 && \ + S_ISREG(stat_buf.st_mode)) + { + file_size = stat_buf.st_size; + result = storage_upload_slave_by_callback(pTrackerServer, \ + NULL, uploadFileCallback, local_filename, \ + file_size, master_filename, prefix_name, \ + file_ext_name, meta_list, meta_count, \ + group_name, remote_filename); + } + + printf("storage_upload_slave_by_callback\n"); + } + + if (result != 0) + { + printf("upload slave file fail, " \ + "error no: %d, error info: %s\n", \ + result, STRERROR(result)); + tracker_disconnect_server_ex(pStorageServer, true); + fdfs_client_destroy(); + return result; + } + + if (g_tracker_server_http_port == 80) + { + *szPortPart = '\0'; + } + else + { + sprintf(szPortPart, ":%d", g_tracker_server_http_port); + } + + sprintf(file_id, "%s/%s", group_name, remote_filename); + url_len = sprintf(file_url, "http://%s%s/%s", \ + pStorageServer->ip_addr, szPortPart, file_id); + if (g_anti_steal_token) + { + ts = time(NULL); + fdfs_http_gen_token(&g_anti_steal_secret_key, file_id, \ + ts, token); + sprintf(file_url + url_len, "?token=%s&ts=%d", \ + token, (int)ts); + } + + printf("group_name=%s, remote_filename=%s\n", \ + group_name, remote_filename); + + fdfs_get_file_info(group_name, remote_filename, &file_info); + + printf("source ip address: %s\n", file_info.source_ip_addr); + printf("file timestamp=%s\n", formatDatetime( + file_info.create_timestamp, "%Y-%m-%d %H:%M:%S", \ + szDatetime, sizeof(szDatetime))); + printf("file size=%"PRId64"\n", file_info.file_size); + printf("file crc32=%u\n", file_info.crc32); + printf("example file url: %s\n", file_url); + + if (fdfs_gen_slave_filename(master_filename, \ + prefix_name, file_ext_name, \ + slave_filename, &slave_filename_len) == 0) + { + + if (strcmp(remote_filename, slave_filename) != 0) + { + printf("slave_filename=%s\n" \ + "remote_filename=%s\n" \ + "not equal!\n", \ + slave_filename, remote_filename); + } + } + } + else if (strcmp(operation, "download") == 0 || + strcmp(operation, "getmeta") == 0 || + strcmp(operation, "setmeta") == 0 || + strcmp(operation, "query_servers") == 0 || + strcmp(operation, "delete") == 0) + { + if (argc < 5) + { + printf("Usage: %s %s " \ + " \n", \ + argv[0], operation); + fdfs_client_destroy(); + return EINVAL; + } + + snprintf(group_name, sizeof(group_name), "%s", argv[3]); + snprintf(remote_filename, sizeof(remote_filename), \ + "%s", argv[4]); + if (strcmp(operation, "setmeta") == 0 || + strcmp(operation, "delete") == 0) + { + result = tracker_query_storage_update(pTrackerServer, \ + &storageServer, group_name, remote_filename); + } + else if (strcmp(operation, "query_servers") == 0) + { + ConnectionInfo storageServers[FDFS_MAX_SERVERS_EACH_GROUP]; + int server_count; + + result = tracker_query_storage_list(pTrackerServer, \ + storageServers, FDFS_MAX_SERVERS_EACH_GROUP, \ + &server_count, group_name, remote_filename); + + if (result != 0) + { + printf("tracker_query_storage_list fail, "\ + "group_name=%s, filename=%s, " \ + "error no: %d, error info: %s\n", \ + group_name, remote_filename, \ + result, STRERROR(result)); + } + else + { + printf("server list (%d):\n", server_count); + for (i=0; i= 6) + { + local_filename = argv[5]; + if (strcmp(local_filename, "CALLBACK") == 0) + { + FILE *fp; + fp = fopen(local_filename, "wb"); + if (fp == NULL) + { + result = errno != 0 ? errno : EPERM; + printf("open file \"%s\" fail, " \ + "errno: %d, error info: %s", \ + local_filename, result, \ + STRERROR(result)); + } + else + { + result = storage_download_file_ex( \ + pTrackerServer, pStorageServer, \ + group_name, remote_filename, 0, 0, \ + writeToFileCallback, fp, &file_size); + fclose(fp); + } + } + else + { + result = storage_download_file_to_file( \ + pTrackerServer, pStorageServer, \ + group_name, remote_filename, \ + local_filename, &file_size); + } + } + else + { + file_buff = NULL; + if ((result=storage_download_file_to_buff( \ + pTrackerServer, pStorageServer, \ + group_name, remote_filename, \ + &file_buff, &file_size)) == 0) + { + local_filename = strrchr( \ + remote_filename, '/'); + if (local_filename != NULL) + { + local_filename++; //skip / + } + else + { + local_filename=remote_filename; + } + + result = writeToFile(local_filename, \ + file_buff, file_size); + + free(file_buff); + } + } + + if (result == 0) + { + printf("download file success, " \ + "file size=%"PRId64", file save to %s\n", \ + file_size, local_filename); + } + else + { + printf("download file fail, " \ + "error no: %d, error info: %s\n", \ + result, STRERROR(result)); + } + } + else if (strcmp(operation, "getmeta") == 0) + { + if ((result=storage_get_metadata(pTrackerServer, \ + pStorageServer, group_name, remote_filename, \ + &pMetaList, &meta_count)) == 0) + { + printf("get meta data success, " \ + "meta count=%d\n", meta_count); + for (i=0; i %s " \ + " " \ + " \n" \ + "\top_flag: %c for overwrite, " \ + "%c for merge\n" \ + "\tmetadata_list: name1=value1," \ + "name2=value2,...\n", \ + argv[0], operation, \ + STORAGE_SET_METADATA_FLAG_OVERWRITE, \ + STORAGE_SET_METADATA_FLAG_MERGE); + fdfs_client_destroy(); + return EINVAL; + } + + meta_buff = strdup(argv[6]); + if (meta_buff == NULL) + { + printf("Out of memory!\n"); + return ENOMEM; + } + + pMetaList = fdfs_split_metadata_ex(meta_buff, \ + ',', '=', &meta_count, &result); + if (pMetaList == NULL) + { + printf("Out of memory!\n"); + free(meta_buff); + return ENOMEM; + } + + if ((result=storage_set_metadata(pTrackerServer, \ + NULL, group_name, remote_filename, \ + pMetaList, meta_count, *argv[5])) == 0) + { + printf("set meta data success\n"); + } + else + { + printf("setmeta fail, " \ + "error no: %d, error info: %s\n", \ + result, STRERROR(result)); + } + + free(meta_buff); + free(pMetaList); + } + else if(strcmp(operation, "delete") == 0) + { + if ((result=storage_delete_file(pTrackerServer, \ + NULL, group_name, remote_filename)) == 0) + { + printf("delete file success\n"); + } + else + { + printf("delete file fail, " \ + "error no: %d, error info: %s\n", \ + result, STRERROR(result)); + } + } + } + else + { + fdfs_client_destroy(); + printf("invalid operation: %s\n", operation); + return EINVAL; + } + + /* for test only */ + if ((result=fdfs_active_test(pTrackerServer)) != 0) + { + printf("active_test to tracker server %s:%d fail, errno: %d\n", \ + pTrackerServer->ip_addr, pTrackerServer->port, result); + } + + /* for test only */ + if ((result=fdfs_active_test(pStorageServer)) != 0) + { + printf("active_test to storage server %s:%d fail, errno: %d\n", \ + pStorageServer->ip_addr, pStorageServer->port, result); + } + + tracker_disconnect_server_ex(pStorageServer, true); + tracker_disconnect_server_ex(pTrackerServer, true); + + fdfs_client_destroy(); + + return result; +} + diff --git a/client/test/fdfs_test1.c b/client/test/fdfs_test1.c deleted file mode 120000 index c87e07dc..00000000 --- a/client/test/fdfs_test1.c +++ /dev/null @@ -1 +0,0 @@ -../fdfs_test1.c \ No newline at end of file diff --git a/client/test/fdfs_test1.c b/client/test/fdfs_test1.c new file mode 100644 index 00000000..b942cc35 --- /dev/null +++ b/client/test/fdfs_test1.c @@ -0,0 +1,658 @@ +/** +* Copyright (C) 2008 Happy Fish / YuQing +* +* FastDFS may be copied only under the terms of the GNU General +* Public License V3, which may be found in the FastDFS source kit. +* Please visit the FastDFS Home Page http://www.csource.org/ for more detail. +**/ + +#include +#include +#include +#include +#include +#include +#include +#include "fdfs_client.h" +#include "fdfs_global.h" +#include "fastcommon/base64.h" +#include "fdfs_http_shared.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/logger.h" + +int writeToFileCallback(void *arg, const int64_t file_size, const char *data, \ + const int current_size) +{ + if (arg == NULL) + { + return EINVAL; + } + + if (fwrite(data, current_size, 1, (FILE *)arg) != 1) + { + return errno != 0 ? errno : EIO; + } + + return 0; +} + +int uploadFileCallback(void *arg, const int64_t file_size, int sock) +{ + int64_t total_send_bytes; + char *filename; + if (arg == NULL) + { + return EINVAL; + } + + filename = (char *)arg; + return tcpsendfile(sock, filename, file_size, \ + g_fdfs_network_timeout, &total_send_bytes); +} + +int main(int argc, char *argv[]) +{ + char *conf_filename; + char *local_filename; + ConnectionInfo *pTrackerServer; + ConnectionInfo *pStorageServer; + int result; + ConnectionInfo storageServer; + char group_name[FDFS_GROUP_NAME_MAX_LEN + 1]; + FDFSMetaData meta_list[32]; + int meta_count; + int i; + FDFSMetaData *pMetaList; + char token[32 + 1]; + char file_id[128]; + char master_file_id[128]; + char file_url[256]; + char szDatetime[20]; + char szPortPart[16]; + int url_len; + time_t ts; + char *file_buff; + int64_t file_size; + char *operation; + char *meta_buff; + int store_path_index; + FDFSFileInfo file_info; + + printf("This is FastDFS client test program v%d.%02d\n" \ +"\nCopyright (C) 2008, Happy Fish / YuQing\n" \ +"\nFastDFS may be copied only under the terms of the GNU General\n" \ +"Public License V3, which may be found in the FastDFS source kit.\n" \ +"Please visit the FastDFS Home Page http://www.csource.org/ \n" \ +"for more detail.\n\n" \ +, g_fdfs_version.major, g_fdfs_version.minor); + + if (argc < 3) + { + printf("Usage: %s \n" \ + "\toperation: upload, download, getmeta, setmeta, " \ + "delete and query_servers\n", argv[0]); + return 1; + } + + log_init(); + g_log_context.log_level = LOG_DEBUG; + + conf_filename = argv[1]; + operation = argv[2]; + if ((result=fdfs_client_init(conf_filename)) != 0) + { + return result; + } + + pTrackerServer = tracker_get_connection(); + if (pTrackerServer == NULL) + { + fdfs_client_destroy(); + return errno != 0 ? errno : ECONNREFUSED; + } + + local_filename = NULL; + if (strcmp(operation, "upload") == 0) + { + int upload_type; + char *prefix_name; + const char *file_ext_name; + char slave_file_id[256]; + int slave_file_id_len; + + if (argc < 4) + { + printf("Usage: %s upload " \ + " [FILE | BUFF | CALLBACK] \n",\ + argv[0]); + fdfs_client_destroy(); + return EINVAL; + } + + local_filename = argv[3]; + if (argc == 4) + { + upload_type = FDFS_UPLOAD_BY_FILE; + } + else + { + if (strcmp(argv[4], "BUFF") == 0) + { + upload_type = FDFS_UPLOAD_BY_BUFF; + } + else if (strcmp(argv[4], "CALLBACK") == 0) + { + upload_type = FDFS_UPLOAD_BY_CALLBACK; + } + else + { + upload_type = FDFS_UPLOAD_BY_FILE; + } + } + + { + ConnectionInfo storageServers[FDFS_MAX_SERVERS_EACH_GROUP]; + ConnectionInfo *pServer; + ConnectionInfo *pServerEnd; + int storage_count; + + strcpy(group_name, "group1"); + if ((result=tracker_query_storage_store_list_with_group( \ + pTrackerServer, group_name, storageServers, \ + FDFS_MAX_SERVERS_EACH_GROUP, &storage_count, \ + &store_path_index)) == 0) + { + printf("tracker_query_storage_store_list_with_group: \n"); + pServerEnd = storageServers + storage_count; + for (pServer=storageServers; pServerip_addr, \ + pServer->port); + } + printf("\n"); + } + } + + *group_name = '\0'; + if ((result=tracker_query_storage_store(pTrackerServer, \ + &storageServer, group_name, &store_path_index)) != 0) + { + fdfs_client_destroy(); + printf("tracker_query_storage fail, " \ + "error no: %d, error info: %s\n", \ + result, STRERROR(result)); + return result; + } + + printf("group_name=%s, ip_addr=%s, port=%d\n", \ + group_name, storageServer.ip_addr, \ + storageServer.port); + + if ((pStorageServer=tracker_connect_server(&storageServer, \ + &result)) == NULL) + { + fdfs_client_destroy(); + return result; + } + + memset(&meta_list, 0, sizeof(meta_list)); + meta_count = 0; + strcpy(meta_list[meta_count].name, "ext_name"); + strcpy(meta_list[meta_count].value, "jpg"); + meta_count++; + strcpy(meta_list[meta_count].name, "width"); + strcpy(meta_list[meta_count].value, "160"); + meta_count++; + strcpy(meta_list[meta_count].name, "height"); + strcpy(meta_list[meta_count].value, "80"); + meta_count++; + strcpy(meta_list[meta_count].name, "file_size"); + strcpy(meta_list[meta_count].value, "115120"); + meta_count++; + + file_ext_name = fdfs_get_file_ext_name(local_filename); + strcpy(group_name, ""); + + if (upload_type == FDFS_UPLOAD_BY_FILE) + { + printf("storage_upload_by_filename\n"); + result = storage_upload_by_filename1(pTrackerServer, \ + pStorageServer, store_path_index, \ + local_filename, file_ext_name, \ + meta_list, meta_count, \ + group_name, file_id); + } + else if (upload_type == FDFS_UPLOAD_BY_BUFF) + { + char *file_content; + printf("storage_upload_by_filebuff\n"); + if ((result=getFileContent(local_filename, \ + &file_content, &file_size)) == 0) + { + result = storage_upload_by_filebuff1(pTrackerServer, \ + pStorageServer, store_path_index, \ + file_content, file_size, file_ext_name, \ + meta_list, meta_count, \ + group_name, file_id); + free(file_content); + } + } + else + { + struct stat stat_buf; + + printf("storage_upload_by_callback\n"); + if (stat(local_filename, &stat_buf) == 0 && \ + S_ISREG(stat_buf.st_mode)) + { + file_size = stat_buf.st_size; + result = storage_upload_by_callback1(pTrackerServer, \ + pStorageServer, store_path_index, \ + uploadFileCallback, local_filename, \ + file_size, file_ext_name, \ + meta_list, meta_count, \ + group_name, file_id); + } + } + + if (result != 0) + { + printf("upload file fail, " \ + "error no: %d, error info: %s\n", \ + result, STRERROR(result)); + tracker_disconnect_server_ex(pStorageServer, true); + fdfs_client_destroy(); + return result; + } + + if (g_tracker_server_http_port == 80) + { + *szPortPart = '\0'; + } + else + { + sprintf(szPortPart, ":%d", g_tracker_server_http_port); + } + + url_len = sprintf(file_url, "http://%s%s/%s", \ + pStorageServer->ip_addr, szPortPart, file_id); + if (g_anti_steal_token) + { + ts = time(NULL); + fdfs_http_gen_token(&g_anti_steal_secret_key, \ + file_id, ts, token); + sprintf(file_url + url_len, "?token=%s&ts=%d", \ + token, (int)ts); + } + + fdfs_get_file_info1(file_id, &file_info); + printf("source ip address: %s\n", file_info.source_ip_addr); + printf("file timestamp=%s\n", formatDatetime( + file_info.create_timestamp, "%Y-%m-%d %H:%M:%S", \ + szDatetime, sizeof(szDatetime))); + printf("file size=%"PRId64"\n", file_info.file_size); + printf("file crc32=%u\n", file_info.crc32); + printf("example file url: %s\n", file_url); + + strcpy(master_file_id, file_id); + *file_id = '\0'; + + if (upload_type == FDFS_UPLOAD_BY_FILE) + { + prefix_name = "_big"; + printf("storage_upload_slave_by_filename\n"); + result = storage_upload_slave_by_filename1( \ + pTrackerServer, NULL, \ + local_filename, master_file_id, \ + prefix_name, file_ext_name, \ + meta_list, meta_count, file_id); + } + else if (upload_type == FDFS_UPLOAD_BY_BUFF) + { + char *file_content; + prefix_name = "1024x1024"; + printf("storage_upload_slave_by_filebuff\n"); + if ((result=getFileContent(local_filename, \ + &file_content, &file_size)) == 0) + { + result = storage_upload_slave_by_filebuff1( \ + pTrackerServer, NULL, file_content, file_size, \ + master_file_id, prefix_name, file_ext_name, \ + meta_list, meta_count, file_id); + free(file_content); + } + } + else + { + struct stat stat_buf; + + prefix_name = "_small"; + printf("storage_upload_slave_by_callback\n"); + if (stat(local_filename, &stat_buf) == 0 && \ + S_ISREG(stat_buf.st_mode)) + { + file_size = stat_buf.st_size; + result = storage_upload_slave_by_callback1( \ + pTrackerServer, NULL, \ + uploadFileCallback, local_filename, \ + file_size, master_file_id, \ + prefix_name, file_ext_name, \ + meta_list, meta_count, file_id); + } + } + + if (result != 0) + { + printf("upload slave file fail, " \ + "error no: %d, error info: %s\n", \ + result, STRERROR(result)); + tracker_disconnect_server_ex(pStorageServer, true); + fdfs_client_destroy(); + return result; + } + + if (g_tracker_server_http_port == 80) + { + *szPortPart = '\0'; + } + else + { + sprintf(szPortPart, ":%d", g_tracker_server_http_port); + } + url_len = sprintf(file_url, "http://%s%s/%s", \ + pStorageServer->ip_addr, szPortPart, file_id); + if (g_anti_steal_token) + { + ts = time(NULL); + fdfs_http_gen_token(&g_anti_steal_secret_key, \ + file_id, ts, token); + sprintf(file_url + url_len, "?token=%s&ts=%d", \ + token, (int)ts); + } + + fdfs_get_file_info1(file_id, &file_info); + printf("source ip address: %s\n", file_info.source_ip_addr); + printf("file timestamp=%s\n", formatDatetime( + file_info.create_timestamp, "%Y-%m-%d %H:%M:%S", \ + szDatetime, sizeof(szDatetime))); + printf("file size=%"PRId64"\n", file_info.file_size); + printf("file crc32=%u\n", file_info.crc32); + printf("example file url: %s\n", file_url); + + if (fdfs_gen_slave_filename(master_file_id, \ + prefix_name, file_ext_name, \ + slave_file_id, &slave_file_id_len) == 0) + { + if (strcmp(file_id, slave_file_id) != 0) + { + printf("slave_file_id=%s\n" \ + "file_id=%s\n" \ + "not equal!\n", \ + slave_file_id, file_id); + } + } + } + else if (strcmp(operation, "download") == 0 || + strcmp(operation, "getmeta") == 0 || + strcmp(operation, "setmeta") == 0 || + strcmp(operation, "query_servers") == 0 || + strcmp(operation, "delete") == 0) + { + if (argc < 4) + { + printf("Usage: %s %s " \ + "\n", \ + argv[0], operation); + fdfs_client_destroy(); + return EINVAL; + } + + snprintf(file_id, sizeof(file_id), "%s", argv[3]); + if (strcmp(operation, "query_servers") == 0) + { + ConnectionInfo storageServers[FDFS_MAX_SERVERS_EACH_GROUP]; + int server_count; + + result = tracker_query_storage_list1(pTrackerServer, \ + storageServers, FDFS_MAX_SERVERS_EACH_GROUP, \ + &server_count, file_id); + + if (result != 0) + { + printf("tracker_query_storage_list1 fail, "\ + "file_id=%s, " \ + "error no: %d, error info: %s\n", \ + file_id, result, STRERROR(result)); + } + else + { + printf("server list (%d):\n", server_count); + for (i=0; i= 5) + { + local_filename = argv[4]; + if (strcmp(local_filename, "CALLBACK") == 0) + { + FILE *fp; + fp = fopen(local_filename, "wb"); + if (fp == NULL) + { + result = errno != 0 ? errno : EPERM; + printf("open file \"%s\" fail, " \ + "errno: %d, error info: %s", \ + local_filename, result, \ + STRERROR(result)); + } + else + { + result = storage_download_file_ex1( \ + pTrackerServer, pStorageServer, \ + file_id, 0, 0, \ + writeToFileCallback, fp, &file_size); + fclose(fp); + } + } + else + { + result = storage_download_file_to_file1( \ + pTrackerServer, pStorageServer, \ + file_id, \ + local_filename, &file_size); + } + } + else + { + file_buff = NULL; + if ((result=storage_download_file_to_buff1( \ + pTrackerServer, pStorageServer, \ + file_id, \ + &file_buff, &file_size)) == 0) + { + local_filename = strrchr( \ + file_id, '/'); + if (local_filename != NULL) + { + local_filename++; //skip / + } + else + { + local_filename=file_id; + } + + result = writeToFile(local_filename, \ + file_buff, file_size); + + free(file_buff); + } + } + + if (result == 0) + { + printf("download file success, " \ + "file size=%"PRId64", file save to %s\n", \ + file_size, local_filename); + } + else + { + printf("download file fail, " \ + "error no: %d, error info: %s\n", \ + result, STRERROR(result)); + } + } + else if (strcmp(operation, "getmeta") == 0) + { + if ((result=storage_get_metadata1(pTrackerServer, \ + NULL, file_id, \ + &pMetaList, &meta_count)) == 0) + { + printf("get meta data success, " \ + "meta count=%d\n", meta_count); + for (i=0; i %s " \ + " " \ + " \n" \ + "\top_flag: %c for overwrite, " \ + "%c for merge\n" \ + "\tmetadata_list: name1=value1," \ + "name2=value2,...\n", \ + argv[0], operation, \ + STORAGE_SET_METADATA_FLAG_OVERWRITE, \ + STORAGE_SET_METADATA_FLAG_MERGE); + fdfs_client_destroy(); + return EINVAL; + } + + meta_buff = strdup(argv[5]); + if (meta_buff == NULL) + { + printf("Out of memory!\n"); + return ENOMEM; + } + + pMetaList = fdfs_split_metadata_ex(meta_buff, \ + ',', '=', &meta_count, &result); + if (pMetaList == NULL) + { + printf("Out of memory!\n"); + free(meta_buff); + return ENOMEM; + } + + if ((result=storage_set_metadata1(pTrackerServer, \ + NULL, file_id, \ + pMetaList, meta_count, *argv[4])) == 0) + { + printf("set meta data success\n"); + } + else + { + printf("setmeta fail, " \ + "error no: %d, error info: %s\n", \ + result, STRERROR(result)); + } + + free(meta_buff); + free(pMetaList); + } + else if(strcmp(operation, "delete") == 0) + { + if ((result=storage_delete_file1(pTrackerServer, \ + NULL, file_id)) == 0) + { + printf("delete file success\n"); + } + else + { + printf("delete file fail, " \ + "error no: %d, error info: %s\n", \ + result, STRERROR(result)); + } + } + } + else + { + fdfs_client_destroy(); + printf("invalid operation: %s\n", operation); + return EINVAL; + } + + /* for test only */ + if ((result=fdfs_active_test(pTrackerServer)) != 0) + { + printf("active_test to tracker server %s:%d fail, errno: %d\n", \ + pTrackerServer->ip_addr, pTrackerServer->port, result); + } + + /* for test only */ + if ((result=fdfs_active_test(pStorageServer)) != 0) + { + printf("active_test to storage server %s:%d fail, errno: %d\n", \ + pStorageServer->ip_addr, pStorageServer->port, result); + } + + tracker_disconnect_server_ex(pStorageServer, true); + tracker_disconnect_server_ex(pTrackerServer, true); + + fdfs_client_destroy(); + + return result; +} + diff --git a/client/tracker_client.c b/client/tracker_client.c index 79ac1227..e5397ff5 100644 --- a/client/tracker_client.c +++ b/client/tracker_client.c @@ -17,10 +17,10 @@ #include #include #include "fdfs_define.h" -#include "logger.h" -#include "shared_func.h" +#include "fastcommon/logger.h" +#include "fastcommon/shared_func.h" #include "fdfs_global.h" -#include "sockopt.h" +#include "fastcommon/sockopt.h" #include "tracker_types.h" #include "tracker_proto.h" #include "tracker_client.h" diff --git a/common/fdfs_define.h b/common/fdfs_define.h index 2eaf394e..ea71032a 100644 --- a/common/fdfs_define.h +++ b/common/fdfs_define.h @@ -12,7 +12,7 @@ #define _FDFS_DEFINE_H_ #include -#include "common_define.h" +#include "fastcommon/common_define.h" #define FDFS_TRACKER_SERVER_DEF_PORT 22000 #define FDFS_STORAGE_SERVER_DEF_PORT 23000 diff --git a/common/fdfs_global.c b/common/fdfs_global.c index 283a50ab..61bf5c66 100644 --- a/common/fdfs_global.c +++ b/common/fdfs_global.c @@ -17,7 +17,7 @@ #include #include #include -#include "logger.h" +#include "fastcommon/logger.h" #include "fdfs_global.h" int g_fdfs_connect_timeout = DEFAULT_CONNECT_TIMEOUT; diff --git a/common/fdfs_global.h b/common/fdfs_global.h index 8aae9977..98a99dfd 100644 --- a/common/fdfs_global.h +++ b/common/fdfs_global.h @@ -11,9 +11,9 @@ #ifndef _FDFS_GLOBAL_H #define _FDFS_GLOBAL_H -#include "common_define.h" +#include "fastcommon/common_define.h" #include "fdfs_define.h" -#include "connection_pool.h" +#include "fastcommon/connection_pool.h" #define FDFS_FILE_EXT_NAME_MAX_LEN 6 diff --git a/common/fdfs_http_shared.c b/common/fdfs_http_shared.c index f25ec173..ff79fb67 100644 --- a/common/fdfs_http_shared.c +++ b/common/fdfs_http_shared.c @@ -18,9 +18,9 @@ #include #include #include -#include "logger.h" -#include "md5.h" -#include "shared_func.h" +#include "fastcommon/logger.h" +#include "fastcommon/md5.h" +#include "fastcommon/shared_func.h" #include "mime_file_parser.h" #include "fdfs_global.h" #include "fdfs_http_shared.h" diff --git a/common/fdfs_http_shared.h b/common/fdfs_http_shared.h index febd6702..5da53ad2 100644 --- a/common/fdfs_http_shared.h +++ b/common/fdfs_http_shared.h @@ -14,8 +14,8 @@ #include #include #include -#include "ini_file_reader.h" -#include "hash.h" +#include "fastcommon/ini_file_reader.h" +#include "fastcommon/hash.h" typedef struct { diff --git a/common/mime_file_parser.c b/common/mime_file_parser.c index c28f3368..aa7461c6 100644 --- a/common/mime_file_parser.c +++ b/common/mime_file_parser.c @@ -18,9 +18,9 @@ #include #include #include -#include "logger.h" -#include "http_func.h" -#include "shared_func.h" +#include "fastcommon/logger.h" +#include "fastcommon/http_func.h" +#include "fastcommon/shared_func.h" #include "mime_file_parser.h" int load_mime_types_from_file(HashArray *pHash, const char *mime_filename) diff --git a/common/mime_file_parser.h b/common/mime_file_parser.h index 621ae3a5..ecb2c4fc 100644 --- a/common/mime_file_parser.h +++ b/common/mime_file_parser.h @@ -14,7 +14,7 @@ #include #include #include -#include "hash.h" +#include "fastcommon/hash.h" #ifdef __cplusplus extern "C" { diff --git a/make.sh b/make.sh index 4a3ed1e1..1294ef62 100755 --- a/make.sh +++ b/make.sh @@ -43,7 +43,7 @@ elif [ "$uname" = "FreeBSD" ] || [ "$uname" = "Darwin" ]; then LIBS="$LIBS -L/usr/lib" CFLAGS="$CFLAGS" if [ "$uname" = "Darwin" ]; then - CFLAGS="$CFLAGS -DDARWIN -I/usr/local/include/fastcommon" + CFLAGS="$CFLAGS -DDARWIN" fi elif [ "$uname" = "SunOS" ]; then LIBS="$LIBS -L/usr/lib" diff --git a/php_client/config.m4 b/php_client/config.m4 index 54f78de0..268917fc 100644 --- a/php_client/config.m4 +++ b/php_client/config.m4 @@ -10,8 +10,7 @@ if test "$PHP_FASTDFS_CLIENT" != "no"; then ROOT=/usr fi - PHP_ADD_INCLUDE($ROOT/include/fastcommon) - PHP_ADD_INCLUDE($ROOT/include/fastdfs) + PHP_ADD_INCLUDE($ROOT/local/include) PHP_ADD_LIBRARY_WITH_PATH(fastcommon, $ROOT/lib, FASTDFS_CLIENT_SHARED_LIBADD) PHP_ADD_LIBRARY_WITH_PATH(fdfsclient, $ROOT/lib, FASTDFS_CLIENT_SHARED_LIBADD) diff --git a/php_client/fastdfs_client.c b/php_client/fastdfs_client.c index 28c82e89..e03264a5 100644 --- a/php_client/fastdfs_client.c +++ b/php_client/fastdfs_client.c @@ -1,4 +1,4 @@ -#include "php7_ext_wrapper.h" +#include "fastcommon/php7_ext_wrapper.h" #include "ext/standard/info.h" #include #include @@ -7,14 +7,14 @@ #include #include #include -#include "fdfs_client.h" -#include "logger.h" -#include "sockopt.h" -#include "fdfs_global.h" -#include "shared_func.h" -#include "client_global.h" -#include "fastdfs_client.h" -#include "fdfs_http_shared.h" +#include "fastdfs/fdfs_client.h" +#include "fastcommon/logger.h" +#include "fastcommon/sockopt.h" +#include "fastdfs/fdfs_global.h" +#include "fastcommon/shared_func.h" +#include "fastdfs/client_global.h" +#include "fastdfs/fastdfs_client.h" +#include "fastdfs/fdfs_http_shared.h" typedef struct { diff --git a/storage/fdfs_storaged.c b/storage/fdfs_storaged.c index 1ea704c5..3aef64bc 100644 --- a/storage/fdfs_storaged.c +++ b/storage/fdfs_storaged.c @@ -21,13 +21,13 @@ #include #include #include -#include "shared_func.h" -#include "pthread_func.h" -#include "process_ctrl.h" -#include "logger.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/pthread_func.h" +#include "fastcommon/process_ctrl.h" +#include "fastcommon/logger.h" #include "fdfs_global.h" -#include "ini_file_reader.h" -#include "sockopt.h" +#include "fastcommon/ini_file_reader.h" +#include "fastcommon/sockopt.h" #include "tracker_types.h" #include "tracker_proto.h" #include "tracker_client_thread.h" @@ -35,7 +35,7 @@ #include "storage_func.h" #include "storage_sync.h" #include "storage_service.h" -#include "sched_thread.h" +#include "fastcommon/sched_thread.h" #include "storage_dio.h" #include "trunk_mem.h" #include "trunk_sync.h" diff --git a/storage/fdht_client/fdht_client.c b/storage/fdht_client/fdht_client.c index b3769f2c..7ae6718a 100644 --- a/storage/fdht_client/fdht_client.c +++ b/storage/fdht_client/fdht_client.c @@ -13,11 +13,11 @@ #include #include #include -#include "sockopt.h" -#include "logger.h" -#include "hash.h" -#include "shared_func.h" -#include "ini_file_reader.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/logger.h" +#include "fastcommon/hash.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/ini_file_reader.h" #include "fdht_types.h" #include "fdht_proto.h" #include "fdht_global.h" diff --git a/storage/fdht_client/fdht_define.h b/storage/fdht_client/fdht_define.h index cc4c7240..c61afd98 100644 --- a/storage/fdht_client/fdht_define.h +++ b/storage/fdht_client/fdht_define.h @@ -11,7 +11,7 @@ #ifndef _FDHT_DEFINE_H_ #define _FDHT_DEFINE_H_ -#include "common_define.h" +#include "fastcommon/common_define.h" #define FDHT_SERVER_DEFAULT_PORT 24000 #define FDHT_DEFAULT_PROXY_PORT 12200 diff --git a/storage/fdht_client/fdht_func.c b/storage/fdht_client/fdht_func.c index be8c33f0..765fd16d 100644 --- a/storage/fdht_client/fdht_func.c +++ b/storage/fdht_client/fdht_func.c @@ -20,10 +20,10 @@ #include #include #include -#include "logger.h" -#include "sockopt.h" -#include "shared_func.h" -#include "ini_file_reader.h" +#include "fastcommon/logger.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/ini_file_reader.h" #include "fdht_func.h" int fdht_split_ids(const char *szIds, int **ppIds, int *id_count) diff --git a/storage/fdht_client/fdht_func.h b/storage/fdht_client/fdht_func.h index af0e0364..7bfee302 100644 --- a/storage/fdht_client/fdht_func.h +++ b/storage/fdht_client/fdht_func.h @@ -24,7 +24,7 @@ #include #include #include "fdht_types.h" -#include "ini_file_reader.h" +#include "fastcommon/ini_file_reader.h" #ifdef __cplusplus extern "C" { diff --git a/storage/fdht_client/fdht_global.h b/storage/fdht_client/fdht_global.h index 20c6cd13..c6fa4678 100644 --- a/storage/fdht_client/fdht_global.h +++ b/storage/fdht_client/fdht_global.h @@ -16,7 +16,7 @@ #include #include #include -#include "common_define.h" +#include "fastcommon/common_define.h" #include "fdht_define.h" #include "fdht_types.h" diff --git a/storage/fdht_client/fdht_proto.c b/storage/fdht_client/fdht_proto.c index 6cef30ac..418ca62e 100644 --- a/storage/fdht_client/fdht_proto.c +++ b/storage/fdht_client/fdht_proto.c @@ -16,9 +16,9 @@ #include #include #include "fdht_define.h" -#include "shared_func.h" -#include "logger.h" -#include "sockopt.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/logger.h" +#include "fastcommon/sockopt.h" #include "fdht_types.h" #include "fdht_proto.h" diff --git a/storage/storage_dio.c b/storage/storage_dio.c index f34eda04..5936c17d 100644 --- a/storage/storage_dio.c +++ b/storage/storage_dio.c @@ -20,10 +20,10 @@ #include #include #include -#include "shared_func.h" -#include "pthread_func.h" -#include "logger.h" -#include "sockopt.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/pthread_func.h" +#include "fastcommon/logger.h" +#include "fastcommon/sockopt.h" #include "storage_dio.h" #include "storage_nio.h" #include "storage_service.h" diff --git a/storage/storage_dio.h b/storage/storage_dio.h index f9eee052..9d517fa2 100644 --- a/storage/storage_dio.h +++ b/storage/storage_dio.h @@ -16,8 +16,8 @@ #include #include #include "tracker_types.h" -#include "fast_task_queue.h" -#include "fast_blocked_queue.h" +#include "fastcommon/fast_task_queue.h" +#include "fastcommon/fast_blocked_queue.h" struct storage_dio_context { diff --git a/storage/storage_disk_recovery.c b/storage/storage_disk_recovery.c index 60d64839..ffa7beae 100644 --- a/storage/storage_disk_recovery.c +++ b/storage/storage_disk_recovery.c @@ -22,11 +22,11 @@ #include #include #include "fdfs_define.h" -#include "logger.h" +#include "fastcommon/logger.h" #include "fdfs_global.h" -#include "sockopt.h" -#include "avl_tree.h" -#include "shared_func.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/avl_tree.h" +#include "fastcommon/shared_func.h" #include "tracker_types.h" #include "tracker_proto.h" #include "storage_global.h" diff --git a/storage/storage_dump.c b/storage/storage_dump.c index 20467288..8ec4121d 100644 --- a/storage/storage_dump.c +++ b/storage/storage_dump.c @@ -12,11 +12,11 @@ #include #include #include "storage_dump.h" -#include "shared_func.h" -#include "sched_thread.h" -#include "logger.h" -#include "hash.h" -#include "connection_pool.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/sched_thread.h" +#include "fastcommon/logger.h" +#include "fastcommon/hash.h" +#include "fastcommon/connection_pool.h" #include "fdfs_global.h" #include "storage_global.h" #include "storage_service.h" diff --git a/storage/storage_func.c b/storage/storage_func.c index db2a20e2..cf32938a 100644 --- a/storage/storage_func.c +++ b/storage/storage_func.c @@ -23,14 +23,14 @@ #include #include #include "fdfs_define.h" -#include "logger.h" +#include "fastcommon/logger.h" #include "fdfs_global.h" -#include "sockopt.h" -#include "shared_func.h" -#include "pthread_func.h" -#include "sched_thread.h" -#include "ini_file_reader.h" -#include "connection_pool.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/pthread_func.h" +#include "fastcommon/sched_thread.h" +#include "fastcommon/ini_file_reader.h" +#include "fastcommon/connection_pool.h" #include "tracker_types.h" #include "tracker_proto.h" #include "fdfs_shared_func.h" diff --git a/storage/storage_global.c b/storage/storage_global.c index 602bdac5..7fbd3139 100644 --- a/storage/storage_global.c +++ b/storage/storage_global.c @@ -9,9 +9,9 @@ #include #include #include -#include "logger.h" -#include "sockopt.h" -#include "shared_func.h" +#include "fastcommon/logger.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/shared_func.h" #include "storage_global.h" volatile bool g_continue_flag = true; diff --git a/storage/storage_global.h b/storage/storage_global.h index d7f4b8d6..7b309597 100644 --- a/storage/storage_global.h +++ b/storage/storage_global.h @@ -15,12 +15,12 @@ #include #include #include -#include "common_define.h" +#include "fastcommon/common_define.h" #include "fdfs_define.h" #include "tracker_types.h" #include "client_global.h" #include "fdht_types.h" -#include "local_ip_func.h" +#include "fastcommon/local_ip_func.h" #include "trunk_shared.h" #ifdef WITH_HTTPD diff --git a/storage/storage_ip_changed_dealer.c b/storage/storage_ip_changed_dealer.c index 4c6dee53..ac9efbd6 100644 --- a/storage/storage_ip_changed_dealer.c +++ b/storage/storage_ip_changed_dealer.c @@ -18,10 +18,10 @@ #include #include #include "fdfs_define.h" -#include "logger.h" +#include "fastcommon/logger.h" #include "fdfs_global.h" -#include "sockopt.h" -#include "shared_func.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/shared_func.h" #include "tracker_types.h" #include "tracker_proto.h" #include "storage_global.h" diff --git a/storage/storage_nio.c b/storage/storage_nio.c index 14c1cf20..23f29d3c 100644 --- a/storage/storage_nio.c +++ b/storage/storage_nio.c @@ -21,16 +21,16 @@ #include #include #include -#include "shared_func.h" -#include "sched_thread.h" -#include "logger.h" -#include "sockopt.h" -#include "fast_task_queue.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/sched_thread.h" +#include "fastcommon/logger.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/fast_task_queue.h" #include "tracker_types.h" #include "tracker_proto.h" #include "storage_global.h" #include "storage_service.h" -#include "ioevent_loop.h" +#include "fastcommon/ioevent_loop.h" #include "storage_dio.h" #include "storage_nio.h" diff --git a/storage/storage_nio.h b/storage/storage_nio.h index 632362c3..79094a54 100644 --- a/storage/storage_nio.h +++ b/storage/storage_nio.h @@ -17,11 +17,11 @@ #include #include "tracker_types.h" #include "storage_func.h" -#include "fast_task_queue.h" +#include "fastcommon/fast_task_queue.h" #include "storage_global.h" #include "fdht_types.h" #include "trunk_mem.h" -#include "md5.h" +#include "fastcommon/md5.h" #define FDFS_STORAGE_STAGE_NIO_INIT 0 #define FDFS_STORAGE_STAGE_NIO_RECV 1 diff --git a/storage/storage_param_getter.c b/storage/storage_param_getter.c index 603e682e..4f288301 100644 --- a/storage/storage_param_getter.c +++ b/storage/storage_param_getter.c @@ -19,8 +19,8 @@ #include #include #include "fdfs_define.h" -#include "logger.h" -#include "shared_func.h" +#include "fastcommon/logger.h" +#include "fastcommon/shared_func.h" #include "fdfs_global.h" #include "tracker_types.h" #include "tracker_proto.h" diff --git a/storage/storage_service.c b/storage/storage_service.c index e4a7a6d3..71c17acb 100644 --- a/storage/storage_service.c +++ b/storage/storage_service.c @@ -22,20 +22,20 @@ #include #include #include "fdfs_define.h" -#include "logger.h" +#include "fastcommon/logger.h" #include "fdfs_global.h" -#include "sockopt.h" -#include "shared_func.h" -#include "pthread_func.h" -#include "sched_thread.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/pthread_func.h" +#include "fastcommon/sched_thread.h" #include "tracker_types.h" #include "tracker_proto.h" #include "storage_service.h" #include "storage_func.h" #include "storage_sync.h" #include "storage_global.h" -#include "base64.h" -#include "hash.h" +#include "fastcommon/base64.h" +#include "fastcommon/hash.h" #include "fdht_client.h" #include "fdfs_global.h" #include "tracker_client.h" @@ -46,7 +46,7 @@ #include "trunk_mem.h" #include "trunk_sync.h" #include "trunk_client.h" -#include "ioevent_loop.h" +#include "fastcommon/ioevent_loop.h" //storage access log actions #define ACCESS_LOG_ACTION_UPLOAD_FILE "upload" diff --git a/storage/storage_service.h b/storage/storage_service.h index a820184b..fb896b01 100644 --- a/storage/storage_service.h +++ b/storage/storage_service.h @@ -19,9 +19,9 @@ #define STORAGE_DELETE_FLAG_FILE 1 #define STORAGE_DELETE_FLAG_LINK 2 -#include "logger.h" +#include "fastcommon/logger.h" #include "fdfs_define.h" -#include "fast_task_queue.h" +#include "fastcommon/fast_task_queue.h" #ifdef __cplusplus extern "C" { diff --git a/storage/storage_sync.c b/storage/storage_sync.c index 982ba9ab..fa5176bc 100644 --- a/storage/storage_sync.c +++ b/storage/storage_sync.c @@ -20,13 +20,13 @@ #include #include #include "fdfs_define.h" -#include "logger.h" +#include "fastcommon/logger.h" #include "fdfs_global.h" -#include "sockopt.h" -#include "shared_func.h" -#include "pthread_func.h" -#include "sched_thread.h" -#include "ini_file_reader.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/pthread_func.h" +#include "fastcommon/sched_thread.h" +#include "fastcommon/ini_file_reader.h" #include "tracker_types.h" #include "tracker_proto.h" #include "storage_global.h" diff --git a/storage/tracker_client_thread.c b/storage/tracker_client_thread.c index c3ff030a..2f82206a 100644 --- a/storage/tracker_client_thread.c +++ b/storage/tracker_client_thread.c @@ -19,13 +19,13 @@ #include #include #include "fdfs_define.h" -#include "logger.h" +#include "fastcommon/logger.h" #include "fdfs_global.h" -#include "sockopt.h" -#include "shared_func.h" -#include "pthread_func.h" -#include "sched_thread.h" -#include "fast_task_queue.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/pthread_func.h" +#include "fastcommon/sched_thread.h" +#include "fastcommon/fast_task_queue.h" #include "tracker_types.h" #include "tracker_proto.h" #include "tracker_client_thread.h" diff --git a/storage/trunk_mgr/trunk_client.c b/storage/trunk_mgr/trunk_client.c index 9e7d514e..c6646581 100644 --- a/storage/trunk_mgr/trunk_client.c +++ b/storage/trunk_mgr/trunk_client.c @@ -20,10 +20,10 @@ #include #include #include "fdfs_define.h" -#include "logger.h" +#include "fastcommon/logger.h" #include "fdfs_global.h" -#include "sockopt.h" -#include "shared_func.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/shared_func.h" #include "tracker_proto.h" #include "storage_global.h" #include "trunk_client.h" diff --git a/storage/trunk_mgr/trunk_client.h b/storage/trunk_mgr/trunk_client.h index 93413d07..e094c8f9 100644 --- a/storage/trunk_mgr/trunk_client.h +++ b/storage/trunk_mgr/trunk_client.h @@ -11,7 +11,7 @@ #ifndef _TRUNK_CLIENT_H_ #define _TRUNK_CLIENT_H_ -#include "common_define.h" +#include "fastcommon/common_define.h" #include "tracker_types.h" #include "trunk_mem.h" diff --git a/storage/trunk_mgr/trunk_free_block_checker.c b/storage/trunk_mgr/trunk_free_block_checker.c index 03ba8b4f..46ac87fd 100644 --- a/storage/trunk_mgr/trunk_free_block_checker.c +++ b/storage/trunk_mgr/trunk_free_block_checker.c @@ -21,9 +21,9 @@ #include #include #include "fdfs_define.h" -#include "logger.h" -#include "shared_func.h" -#include "avl_tree.h" +#include "fastcommon/logger.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/avl_tree.h" #include "tracker_types.h" #include "storage_global.h" #include "trunk_free_block_checker.h" diff --git a/storage/trunk_mgr/trunk_free_block_checker.h b/storage/trunk_mgr/trunk_free_block_checker.h index 663d9be2..e5393651 100644 --- a/storage/trunk_mgr/trunk_free_block_checker.h +++ b/storage/trunk_mgr/trunk_free_block_checker.h @@ -15,7 +15,7 @@ #include #include #include -#include "common_define.h" +#include "fastcommon/common_define.h" #include "fdfs_global.h" #include "tracker_types.h" #include "trunk_shared.h" diff --git a/storage/trunk_mgr/trunk_mem.c b/storage/trunk_mgr/trunk_mem.c index 95d078ae..f5e13096 100644 --- a/storage/trunk_mgr/trunk_mem.c +++ b/storage/trunk_mgr/trunk_mem.c @@ -20,12 +20,12 @@ #include #include #include "fdfs_define.h" -#include "logger.h" -#include "sockopt.h" -#include "shared_func.h" -#include "pthread_func.h" -#include "sched_thread.h" -#include "avl_tree.h" +#include "fastcommon/logger.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/pthread_func.h" +#include "fastcommon/sched_thread.h" +#include "fastcommon/avl_tree.h" #include "tracker_types.h" #include "tracker_proto.h" #include "storage_global.h" diff --git a/storage/trunk_mgr/trunk_mem.h b/storage/trunk_mgr/trunk_mem.h index b96b8e07..7b3a6cc2 100644 --- a/storage/trunk_mgr/trunk_mem.h +++ b/storage/trunk_mgr/trunk_mem.h @@ -16,9 +16,9 @@ #include #include #include -#include "common_define.h" +#include "fastcommon/common_define.h" #include "fdfs_global.h" -#include "fast_mblock.h" +#include "fastcommon/fast_mblock.h" #include "trunk_shared.h" #include "fdfs_shared_func.h" diff --git a/storage/trunk_mgr/trunk_shared.c b/storage/trunk_mgr/trunk_shared.c index e0b73c9c..89b82487 100644 --- a/storage/trunk_mgr/trunk_shared.c +++ b/storage/trunk_mgr/trunk_shared.c @@ -19,8 +19,8 @@ #include #include #include -#include "logger.h" -#include "shared_func.h" +#include "fastcommon/logger.h" +#include "fastcommon/shared_func.h" #include "trunk_shared.h" #include "tracker_proto.h" diff --git a/storage/trunk_mgr/trunk_shared.h b/storage/trunk_mgr/trunk_shared.h index 7f74d8c1..db2513c4 100644 --- a/storage/trunk_mgr/trunk_shared.h +++ b/storage/trunk_mgr/trunk_shared.h @@ -15,9 +15,9 @@ #include #include #include -#include "base64.h" -#include "common_define.h" -#include "ini_file_reader.h" +#include "fastcommon/base64.h" +#include "fastcommon/common_define.h" +#include "fastcommon/ini_file_reader.h" #include "fdfs_global.h" #include "tracker_types.h" diff --git a/storage/trunk_mgr/trunk_sync.c b/storage/trunk_mgr/trunk_sync.c index ee87ad84..721a3fa7 100644 --- a/storage/trunk_mgr/trunk_sync.c +++ b/storage/trunk_mgr/trunk_sync.c @@ -21,13 +21,13 @@ #include #include #include "fdfs_define.h" -#include "logger.h" +#include "fastcommon/logger.h" #include "fdfs_global.h" -#include "sockopt.h" -#include "shared_func.h" -#include "pthread_func.h" -#include "sched_thread.h" -#include "ini_file_reader.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/pthread_func.h" +#include "fastcommon/sched_thread.h" +#include "fastcommon/ini_file_reader.h" #include "tracker_types.h" #include "tracker_proto.h" #include "storage_global.h" diff --git a/test/Makefile b/test/Makefile index ffc176be..fc7c3671 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,7 +1,7 @@ .SUFFIXES: .c .o .lo COMPILE = $(CC) -g -Wall -O -D_FILE_OFFSET_BITS=64 -DDEBUG -INC_PATH = -I/usr/local/include -I/usr/include/fastdfs -I/usr/include/fastcommon +INC_PATH = -I/usr/local/include LIB_PATH = -L/usr/local/lib -lfdfsclient -lfastcommon TARGET_PATH = $(TARGET_PREFIX)/bin diff --git a/test/combine_result.c b/test/combine_result.c index cefaecf0..2faed61b 100644 --- a/test/combine_result.c +++ b/test/combine_result.c @@ -7,7 +7,7 @@ #include #include #include -#include "common_define.h" +#include "fastcommon/common_define.h" #include "test_types.h" #include "common_func.h" diff --git a/test/dfs_func.c b/test/dfs_func.c index f69e5ede..09768fe8 100644 --- a/test/dfs_func.c +++ b/test/dfs_func.c @@ -6,9 +6,9 @@ #include #include #include -#include "fdfs_global.h" +#include "fastdfs/fdfs_global.h" #include "dfs_func.h" -#include "fdfs_client.h" +#include "fastdfs/fdfs_client.h" int dfs_init(const int proccess_index, const char *conf_filename) { diff --git a/test/dfs_func_pc.c b/test/dfs_func_pc.c index d1f60480..524fdd3b 100644 --- a/test/dfs_func_pc.c +++ b/test/dfs_func_pc.c @@ -6,9 +6,9 @@ #include #include #include -#include "fdfs_global.h" +#include "fastdfs/fdfs_global.h" #include "dfs_func.h" -#include "fdfs_client.h" +#include "fastdfs/fdfs_client.h" static ConnectionInfo *pTrackerServer; static ConnectionInfo storage_servers[FDFS_MAX_SERVERS_EACH_GROUP]; diff --git a/test/gen_files.c b/test/gen_files.c index 64e156bc..072b7e00 100644 --- a/test/gen_files.c +++ b/test/gen_files.c @@ -3,7 +3,7 @@ #include #include #include -#include "common_define.h" +#include "fastcommon/common_define.h" #include "test_types.h" typedef struct { diff --git a/test/test_delete.c b/test/test_delete.c index 107434ab..c933b2af 100644 --- a/test/test_delete.c +++ b/test/test_delete.c @@ -7,7 +7,7 @@ #include #include #include -#include "logger.h" +#include "fastcommon/logger.h" #include "test_types.h" #include "common_func.h" #include "dfs_func.h" diff --git a/test/test_download.c b/test/test_download.c index bcfe87fb..87f1b98d 100644 --- a/test/test_download.c +++ b/test/test_download.c @@ -7,8 +7,8 @@ #include #include #include -#include "logger.h" -#include "common_define.h" +#include "fastcommon/logger.h" +#include "fastcommon/common_define.h" #include "test_types.h" #include "common_func.h" #include "dfs_func.h" diff --git a/test/test_upload.c b/test/test_upload.c index cd35b4f4..2f2a190c 100644 --- a/test/test_upload.c +++ b/test/test_upload.c @@ -8,8 +8,8 @@ #include #include #include -#include "common_define.h" -#include "logger.h" +#include "fastcommon/common_define.h" +#include "fastcommon/logger.h" #include "test_types.h" #include "common_func.h" #include "dfs_func.h" diff --git a/tracker/Makefile.in b/tracker/Makefile.in index 6bfd3728..acb6f54f 100644 --- a/tracker/Makefile.in +++ b/tracker/Makefile.in @@ -1,7 +1,7 @@ .SUFFIXES: .c .o COMPILE = $(CC) $(CFLAGS) -INC_PATH = -I../common -I/usr/include/fastcommon +INC_PATH = -I../common -I/usr/local/include LIB_PATH = $(LIBS) -lfastcommon TARGET_PATH = $(TARGET_PREFIX)/bin CONFIG_PATH = $(TARGET_CONF_PATH) diff --git a/tracker/fdfs_shared_func.c b/tracker/fdfs_shared_func.c index 9fc67c1c..9a62fcf2 100644 --- a/tracker/fdfs_shared_func.c +++ b/tracker/fdfs_shared_func.c @@ -9,9 +9,9 @@ #include #include #include -#include "logger.h" -#include "sockopt.h" -#include "shared_func.h" +#include "fastcommon/logger.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/shared_func.h" #include "tracker_proto.h" #include "fdfs_global.h" #include "fdfs_shared_func.h" diff --git a/tracker/fdfs_shared_func.h b/tracker/fdfs_shared_func.h index 899bf5d3..03b0c226 100644 --- a/tracker/fdfs_shared_func.h +++ b/tracker/fdfs_shared_func.h @@ -11,9 +11,9 @@ #ifndef _FDFS_SHARED_FUNC_H #define _FDFS_SHARED_FUNC_H -#include "common_define.h" -#include "ini_file_reader.h" -#include "logger.h" +#include "fastcommon/common_define.h" +#include "fastcommon/ini_file_reader.h" +#include "fastcommon/logger.h" #include "tracker_types.h" #ifdef __cplusplus diff --git a/tracker/fdfs_trackerd.c b/tracker/fdfs_trackerd.c index b45d0ed3..85f97d92 100644 --- a/tracker/fdfs_trackerd.c +++ b/tracker/fdfs_trackerd.c @@ -20,14 +20,14 @@ #include #include #include -#include "shared_func.h" -#include "pthread_func.h" -#include "process_ctrl.h" -#include "logger.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/pthread_func.h" +#include "fastcommon/process_ctrl.h" +#include "fastcommon/logger.h" #include "fdfs_global.h" -#include "base64.h" -#include "sockopt.h" -#include "sched_thread.h" +#include "fastcommon/base64.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/sched_thread.h" #include "tracker_types.h" #include "tracker_mem.h" #include "tracker_service.h" diff --git a/tracker/tracker_dump.c b/tracker/tracker_dump.c index 9698f95d..81572b1a 100644 --- a/tracker/tracker_dump.c +++ b/tracker/tracker_dump.c @@ -12,11 +12,11 @@ #include #include #include "tracker_dump.h" -#include "shared_func.h" -#include "sched_thread.h" -#include "logger.h" -#include "hash.h" -#include "connection_pool.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/sched_thread.h" +#include "fastcommon/logger.h" +#include "fastcommon/hash.h" +#include "fastcommon/connection_pool.h" #include "fdfs_global.h" #include "tracker_global.h" #include "tracker_mem.h" diff --git a/tracker/tracker_func.c b/tracker/tracker_func.c index 938ad5a6..5551ece7 100644 --- a/tracker/tracker_func.c +++ b/tracker/tracker_func.c @@ -22,18 +22,18 @@ #include #include #include "fdfs_define.h" -#include "logger.h" +#include "fastcommon/logger.h" #include "fdfs_global.h" -#include "sockopt.h" -#include "shared_func.h" -#include "ini_file_reader.h" -#include "connection_pool.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/ini_file_reader.h" +#include "fastcommon/connection_pool.h" #include "tracker_types.h" #include "tracker_proto.h" #include "tracker_global.h" #include "tracker_func.h" #include "tracker_mem.h" -#include "local_ip_func.h" +#include "fastcommon/local_ip_func.h" #include "fdfs_shared_func.h" #ifdef WITH_HTTPD diff --git a/tracker/tracker_global.h b/tracker/tracker_global.h index f1b4fe5c..af3d010e 100644 --- a/tracker/tracker_global.h +++ b/tracker/tracker_global.h @@ -15,13 +15,13 @@ #include #include #include -#include "common_define.h" +#include "fastcommon/common_define.h" #include "fdfs_define.h" #include "tracker_types.h" #include "tracker_status.h" -#include "base64.h" -#include "hash.h" -#include "local_ip_func.h" +#include "fastcommon/base64.h" +#include "fastcommon/hash.h" +#include "fastcommon/local_ip_func.h" #ifdef WITH_HTTPD #include "fdfs_http_shared.h" diff --git a/tracker/tracker_http_check.c b/tracker/tracker_http_check.c index db0032d6..b339cb0d 100644 --- a/tracker/tracker_http_check.c +++ b/tracker/tracker_http_check.c @@ -7,13 +7,13 @@ #include #include #include -#include "logger.h" +#include "fastcommon/logger.h" #include "fdfs_global.h" #include "tracker_global.h" #include "tracker_mem.h" #include "tracker_proto.h" -#include "http_func.h" -#include "sockopt.h" +#include "fastcommon/http_func.h" +#include "fastcommon/sockopt.h" #include "tracker_http_check.h" static pthread_t http_check_tid; diff --git a/tracker/tracker_mem.c b/tracker/tracker_mem.c index 25f2dd67..79223de7 100644 --- a/tracker/tracker_mem.c +++ b/tracker/tracker_mem.c @@ -19,12 +19,12 @@ #include #include #include "fdfs_define.h" -#include "logger.h" -#include "sockopt.h" +#include "fastcommon/logger.h" +#include "fastcommon/sockopt.h" #include "fdfs_global.h" -#include "shared_func.h" -#include "pthread_func.h" -#include "sched_thread.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/pthread_func.h" +#include "fastcommon/sched_thread.h" #include "fdfs_shared_func.h" #include "tracker_global.h" #include "tracker_proto.h" diff --git a/tracker/tracker_nio.c b/tracker/tracker_nio.c index e48f6d04..51b1f240 100644 --- a/tracker/tracker_nio.c +++ b/tracker/tracker_nio.c @@ -21,18 +21,18 @@ #include #include #include -#include "shared_func.h" -#include "sched_thread.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/sched_thread.h" #include "fdfs_global.h" -#include "logger.h" -#include "sockopt.h" -#include "fast_task_queue.h" +#include "fastcommon/logger.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/fast_task_queue.h" #include "tracker_types.h" #include "tracker_proto.h" #include "tracker_mem.h" #include "tracker_global.h" #include "tracker_service.h" -#include "ioevent_loop.h" +#include "fastcommon/ioevent_loop.h" #include "tracker_nio.h" static void client_sock_read(int sock, short event, void *arg); diff --git a/tracker/tracker_nio.h b/tracker/tracker_nio.h index 13e1470d..e4625d4a 100644 --- a/tracker/tracker_nio.h +++ b/tracker/tracker_nio.h @@ -14,7 +14,7 @@ #include #include #include -#include "fast_task_queue.h" +#include "fastcommon/fast_task_queue.h" #ifdef __cplusplus extern "C" { diff --git a/tracker/tracker_proto.c b/tracker/tracker_proto.c index 685734f5..dea7fcab 100644 --- a/tracker/tracker_proto.c +++ b/tracker/tracker_proto.c @@ -16,10 +16,10 @@ #include #include #include "fdfs_define.h" -#include "shared_func.h" -#include "logger.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/logger.h" #include "fdfs_global.h" -#include "sockopt.h" +#include "fastcommon/sockopt.h" #include "tracker_types.h" #include "tracker_proto.h" diff --git a/tracker/tracker_proto.h b/tracker/tracker_proto.h index 353bc741..d4ba636f 100644 --- a/tracker/tracker_proto.h +++ b/tracker/tracker_proto.h @@ -12,8 +12,8 @@ #define _TRACKER_PROTO_H_ #include "tracker_types.h" -#include "connection_pool.h" -#include "ini_file_reader.h" +#include "fastcommon/connection_pool.h" +#include "fastcommon/ini_file_reader.h" #define TRACKER_PROTO_CMD_STORAGE_JOIN 81 #define FDFS_PROTO_CMD_QUIT 82 diff --git a/tracker/tracker_relationship.c b/tracker/tracker_relationship.c index f48f14cb..edaa47f7 100644 --- a/tracker/tracker_relationship.c +++ b/tracker/tracker_relationship.c @@ -19,11 +19,11 @@ #include #include #include "fdfs_define.h" -#include "logger.h" -#include "sockopt.h" +#include "fastcommon/logger.h" +#include "fastcommon/sockopt.h" #include "fdfs_global.h" -#include "shared_func.h" -#include "pthread_func.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/pthread_func.h" #include "tracker_global.h" #include "tracker_proto.h" #include "tracker_mem.h" diff --git a/tracker/tracker_service.c b/tracker/tracker_service.c index 2003ae39..538b370e 100644 --- a/tracker/tracker_service.c +++ b/tracker/tracker_service.c @@ -19,13 +19,13 @@ #include #include #include "fdfs_define.h" -#include "base64.h" -#include "logger.h" +#include "fastcommon/base64.h" +#include "fastcommon/logger.h" #include "fdfs_global.h" -#include "sockopt.h" -#include "shared_func.h" -#include "pthread_func.h" -#include "sched_thread.h" +#include "fastcommon/sockopt.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/pthread_func.h" +#include "fastcommon/sched_thread.h" #include "tracker_types.h" #include "tracker_global.h" #include "tracker_mem.h" @@ -34,7 +34,7 @@ #include "tracker_nio.h" #include "tracker_relationship.h" #include "fdfs_shared_func.h" -#include "ioevent_loop.h" +#include "fastcommon/ioevent_loop.h" #include "tracker_service.h" #define PKG_LEN_PRINTF_FORMAT "%d" diff --git a/tracker/tracker_service.h b/tracker/tracker_service.h index 6203dee6..62d56f3f 100644 --- a/tracker/tracker_service.h +++ b/tracker/tracker_service.h @@ -15,8 +15,8 @@ #include #include #include "fdfs_define.h" -#include "ioevent.h" -#include "fast_task_queue.h" +#include "fastcommon/ioevent.h" +#include "fastcommon/fast_task_queue.h" #ifdef __cplusplus extern "C" { diff --git a/tracker/tracker_status.c b/tracker/tracker_status.c index 5cc34eb9..ce4e5abc 100644 --- a/tracker/tracker_status.c +++ b/tracker/tracker_status.c @@ -18,11 +18,11 @@ #include #include #include "fdfs_define.h" -#include "logger.h" +#include "fastcommon/logger.h" #include "fdfs_global.h" -#include "shared_func.h" -#include "sched_thread.h" -#include "ini_file_reader.h" +#include "fastcommon/shared_func.h" +#include "fastcommon/sched_thread.h" +#include "fastcommon/ini_file_reader.h" #include "tracker_types.h" #include "tracker_global.h" #include "tracker_status.h" diff --git a/tracker/tracker_types.h b/tracker/tracker_types.h index edff92a3..83d0c851 100644 --- a/tracker/tracker_types.h +++ b/tracker/tracker_types.h @@ -17,7 +17,7 @@ #include #include #include "fdfs_define.h" -#include "connection_pool.h" +#include "fastcommon/connection_pool.h" #define FDFS_ONE_MB (1024 * 1024)