include libfastcommon header files start with fastcommon/
parent
99526a2523
commit
b1423a3ace
|
|
@ -19,13 +19,13 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "base64.h"
|
#include "fastcommon/base64.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "ini_file_reader.h"
|
#include "fastcommon/ini_file_reader.h"
|
||||||
#include "connection_pool.h"
|
#include "fastcommon/connection_pool.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
#include "client_global.h"
|
#include "client_global.h"
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "client_global.h"
|
#include "client_global.h"
|
||||||
#include "ini_file_reader.h"
|
#include "fastcommon/ini_file_reader.h"
|
||||||
|
|
||||||
#ifndef _CLIENT_FUNC_H_
|
#ifndef _CLIENT_FUNC_H_
|
||||||
#define _CLIENT_FUNC_H_
|
#define _CLIENT_FUNC_H_
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
#ifndef _CLIENT_GLOBAL_H
|
#ifndef _CLIENT_GLOBAL_H
|
||||||
#define _CLIENT_GLOBAL_H
|
#define _CLIENT_GLOBAL_H
|
||||||
|
|
||||||
#include "common_define.h"
|
#include "fastcommon/common_define.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "fdfs_shared_func.h"
|
#include "fdfs_shared_func.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include "fdfs_client.h"
|
#include "fdfs_client.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include "fdfs_client.h"
|
#include "fdfs_client.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "base64.h"
|
#include "fastcommon/base64.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_http_shared.h"
|
#include "fdfs_http_shared.h"
|
||||||
|
|
||||||
int writeToFileCallback(void *arg, const int64_t file_size, const char *data, \
|
int writeToFileCallback(void *arg, const int64_t file_size, const char *data, \
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include "fdfs_client.h"
|
#include "fdfs_client.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "base64.h"
|
#include "fastcommon/base64.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_http_shared.h"
|
#include "fdfs_http_shared.h"
|
||||||
|
|
||||||
int writeToFileCallback(void *arg, const int64_t file_size, const char *data, \
|
int writeToFileCallback(void *arg, const int64_t file_size, const char *data, \
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#ifndef FDFS_CLIENT_H
|
#ifndef FDFS_CLIENT_H
|
||||||
#define FDFS_CLIENT_H
|
#define FDFS_CLIENT_H
|
||||||
|
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
#include "tracker_client.h"
|
#include "tracker_client.h"
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include "hash.h"
|
#include "fastcommon/hash.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include "fdfs_client.h"
|
#include "fdfs_client.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include "fdfs_client.h"
|
#include "fdfs_client.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include "fdfs_client.h"
|
#include "fdfs_client.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "client_global.h"
|
#include "client_global.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "fdfs_client.h"
|
#include "fdfs_client.h"
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include "fdfs_client.h"
|
#include "fdfs_client.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "base64.h"
|
#include "fastcommon/base64.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_http_shared.h"
|
#include "fdfs_http_shared.h"
|
||||||
|
|
||||||
int writeToFileCallback(void *arg, const int64_t file_size, const char *data, \
|
int writeToFileCallback(void *arg, const int64_t file_size, const char *data, \
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,10 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include "fdfs_client.h"
|
#include "fdfs_client.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "base64.h"
|
#include "fastcommon/base64.h"
|
||||||
#include "fdfs_http_shared.h"
|
#include "fdfs_http_shared.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
|
|
||||||
int writeToFileCallback(void *arg, const int64_t file_size, const char *data, \
|
int writeToFileCallback(void *arg, const int64_t file_size, const char *data, \
|
||||||
const int current_size)
|
const int current_size)
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include "fdfs_client.h"
|
#include "fdfs_client.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include "fdfs_client.h"
|
#include "fdfs_client.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
|
|
||||||
static void usage(char *argv[])
|
static void usage(char *argv[])
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,10 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
#include "client_func.h"
|
#include "client_func.h"
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
#include "storage_client.h"
|
#include "storage_client.h"
|
||||||
#include "storage_client1.h"
|
#include "storage_client1.h"
|
||||||
#include "client_global.h"
|
#include "client_global.h"
|
||||||
#include "base64.h"
|
#include "fastcommon/base64.h"
|
||||||
|
|
||||||
static struct base64_context the_base64_context;
|
static struct base64_context the_base64_context;
|
||||||
static int the_base64_context_inited = 0;
|
static int the_base64_context_inited = 0;
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
../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 <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#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 <config_file> [-h <tracker_server>] [list|delete|set_trunk_server <group_name> " \
|
||||||
|
"[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; i<g_tracker_group.server_count; i++)
|
||||||
|
{
|
||||||
|
if (strcmp(g_tracker_group.servers[i].ip_addr, \
|
||||||
|
ip_addr) == 0)
|
||||||
|
{
|
||||||
|
g_tracker_group.server_index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == g_tracker_group.server_count)
|
||||||
|
{
|
||||||
|
printf("tracker server: %s not exists!\n", tracker_server);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("server_count=%d, server_index=%d\n", g_tracker_group.server_count, g_tracker_group.server_index);
|
||||||
|
|
||||||
|
pTrackerServer = tracker_get_connection();
|
||||||
|
if (pTrackerServer == NULL)
|
||||||
|
{
|
||||||
|
fdfs_client_destroy();
|
||||||
|
return errno != 0 ? errno : ECONNREFUSED;
|
||||||
|
}
|
||||||
|
printf("\ntracker server is %s:%d\n\n", pTrackerServer->ip_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; pStorage<pStorageEnd; \
|
||||||
|
pStorage++)
|
||||||
|
{
|
||||||
|
max_last_source_update = 0;
|
||||||
|
for (p=storage_infos; p<pStorageEnd; p++)
|
||||||
|
{
|
||||||
|
if (p != pStorage && p->stat.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; pGroupStat<pGroupEnd; \
|
||||||
|
pGroupStat++)
|
||||||
|
{
|
||||||
|
printf( "\nGroup %d:\n", ++i);
|
||||||
|
list_storages(pGroupStat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (pGroupStat=group_stats; pGroupStat<pGroupEnd; \
|
||||||
|
pGroupStat++)
|
||||||
|
{
|
||||||
|
if (strcmp(pGroupStat->group_name, group_name) == 0)
|
||||||
|
{
|
||||||
|
list_storages(pGroupStat);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
../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 <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#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 <config_file> <operation>\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 <config_file> upload " \
|
||||||
|
"<local_filename> [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; pServer<pServerEnd; pServer++)
|
||||||
|
{
|
||||||
|
printf("\tserver %d. group_name=%s, " \
|
||||||
|
"ip_addr=%s, port=%d\n", \
|
||||||
|
(int)(pServer - storageServers) + 1, \
|
||||||
|
group_name, pServer->ip_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 <config_file> %s " \
|
||||||
|
"<group_name> <remote_filename>\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<server_count; i++)
|
||||||
|
{
|
||||||
|
printf("\t%s:%d\n", \
|
||||||
|
storageServers[i].ip_addr, \
|
||||||
|
storageServers[i].port);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
tracker_disconnect_server_ex(pTrackerServer, result != 0);
|
||||||
|
fdfs_client_destroy();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = tracker_query_storage_fetch(pTrackerServer, \
|
||||||
|
&storageServer, group_name, remote_filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result != 0)
|
||||||
|
{
|
||||||
|
fdfs_client_destroy();
|
||||||
|
printf("tracker_query_storage_fetch fail, " \
|
||||||
|
"group_name=%s, filename=%s, " \
|
||||||
|
"error no: %d, error info: %s\n", \
|
||||||
|
group_name, remote_filename, \
|
||||||
|
result, STRERROR(result));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("storage=%s:%d\n", storageServer.ip_addr, \
|
||||||
|
storageServer.port);
|
||||||
|
|
||||||
|
if ((pStorageServer=tracker_connect_server(&storageServer, \
|
||||||
|
&result)) == NULL)
|
||||||
|
{
|
||||||
|
fdfs_client_destroy();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(operation, "download") == 0)
|
||||||
|
{
|
||||||
|
if (argc >= 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<meta_count; i++)
|
||||||
|
{
|
||||||
|
printf("%s=%s\n", \
|
||||||
|
pMetaList[i].name, \
|
||||||
|
pMetaList[i].value);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(pMetaList);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("getmeta fail, " \
|
||||||
|
"error no: %d, error info: %s\n", \
|
||||||
|
result, STRERROR(result));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (strcmp(operation, "setmeta") == 0)
|
||||||
|
{
|
||||||
|
if (argc < 7)
|
||||||
|
{
|
||||||
|
printf("Usage: %s <config_file> %s " \
|
||||||
|
"<group_name> <remote_filename> " \
|
||||||
|
"<op_flag> <metadata_list>\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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
../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 <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#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 <config_file> <operation>\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 <config_file> upload " \
|
||||||
|
"<local_filename> [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; pServer<pServerEnd; pServer++)
|
||||||
|
{
|
||||||
|
printf("\tserver %d. group_name=%s, " \
|
||||||
|
"ip_addr=%s, port=%d\n", \
|
||||||
|
(int)(pServer - storageServers) + 1, \
|
||||||
|
group_name, pServer->ip_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 <config_file> %s " \
|
||||||
|
"<file_id>\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<server_count; i++)
|
||||||
|
{
|
||||||
|
printf("\t%s:%d\n", \
|
||||||
|
storageServers[i].ip_addr, \
|
||||||
|
storageServers[i].port);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
tracker_disconnect_server_ex(pTrackerServer, true);
|
||||||
|
fdfs_client_destroy();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((result=tracker_query_storage_fetch1(pTrackerServer, \
|
||||||
|
&storageServer, file_id)) != 0)
|
||||||
|
{
|
||||||
|
fdfs_client_destroy();
|
||||||
|
printf("tracker_query_storage_fetch fail, " \
|
||||||
|
"file_id=%s, " \
|
||||||
|
"error no: %d, error info: %s\n", \
|
||||||
|
file_id, result, STRERROR(result));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("storage=%s:%d\n", storageServer.ip_addr, \
|
||||||
|
storageServer.port);
|
||||||
|
|
||||||
|
if ((pStorageServer=tracker_connect_server(&storageServer, \
|
||||||
|
&result)) == NULL)
|
||||||
|
{
|
||||||
|
fdfs_client_destroy();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(operation, "download") == 0)
|
||||||
|
{
|
||||||
|
if (argc >= 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<meta_count; i++)
|
||||||
|
{
|
||||||
|
printf("%s=%s\n", \
|
||||||
|
pMetaList[i].name, \
|
||||||
|
pMetaList[i].value);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(pMetaList);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("getmeta fail, " \
|
||||||
|
"error no: %d, error info: %s\n", \
|
||||||
|
result, STRERROR(result));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (strcmp(operation, "setmeta") == 0)
|
||||||
|
{
|
||||||
|
if (argc < 6)
|
||||||
|
{
|
||||||
|
printf("Usage: %s <config_file> %s " \
|
||||||
|
"<file_id> " \
|
||||||
|
"<op_flag> <metadata_list>\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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -17,10 +17,10 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
#include "tracker_client.h"
|
#include "tracker_client.h"
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
#define _FDFS_DEFINE_H_
|
#define _FDFS_DEFINE_H_
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "common_define.h"
|
#include "fastcommon/common_define.h"
|
||||||
|
|
||||||
#define FDFS_TRACKER_SERVER_DEF_PORT 22000
|
#define FDFS_TRACKER_SERVER_DEF_PORT 22000
|
||||||
#define FDFS_STORAGE_SERVER_DEF_PORT 23000
|
#define FDFS_STORAGE_SERVER_DEF_PORT 23000
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
|
|
||||||
int g_fdfs_connect_timeout = DEFAULT_CONNECT_TIMEOUT;
|
int g_fdfs_connect_timeout = DEFAULT_CONNECT_TIMEOUT;
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@
|
||||||
#ifndef _FDFS_GLOBAL_H
|
#ifndef _FDFS_GLOBAL_H
|
||||||
#define _FDFS_GLOBAL_H
|
#define _FDFS_GLOBAL_H
|
||||||
|
|
||||||
#include "common_define.h"
|
#include "fastcommon/common_define.h"
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "connection_pool.h"
|
#include "fastcommon/connection_pool.h"
|
||||||
|
|
||||||
#define FDFS_FILE_EXT_NAME_MAX_LEN 6
|
#define FDFS_FILE_EXT_NAME_MAX_LEN 6
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "md5.h"
|
#include "fastcommon/md5.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "mime_file_parser.h"
|
#include "mime_file_parser.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "fdfs_http_shared.h"
|
#include "fdfs_http_shared.h"
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "ini_file_reader.h"
|
#include "fastcommon/ini_file_reader.h"
|
||||||
#include "hash.h"
|
#include "fastcommon/hash.h"
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "http_func.h"
|
#include "fastcommon/http_func.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "mime_file_parser.h"
|
#include "mime_file_parser.h"
|
||||||
|
|
||||||
int load_mime_types_from_file(HashArray *pHash, const char *mime_filename)
|
int load_mime_types_from_file(HashArray *pHash, const char *mime_filename)
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "hash.h"
|
#include "fastcommon/hash.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
||||||
2
make.sh
2
make.sh
|
|
@ -43,7 +43,7 @@ elif [ "$uname" = "FreeBSD" ] || [ "$uname" = "Darwin" ]; then
|
||||||
LIBS="$LIBS -L/usr/lib"
|
LIBS="$LIBS -L/usr/lib"
|
||||||
CFLAGS="$CFLAGS"
|
CFLAGS="$CFLAGS"
|
||||||
if [ "$uname" = "Darwin" ]; then
|
if [ "$uname" = "Darwin" ]; then
|
||||||
CFLAGS="$CFLAGS -DDARWIN -I/usr/local/include/fastcommon"
|
CFLAGS="$CFLAGS -DDARWIN"
|
||||||
fi
|
fi
|
||||||
elif [ "$uname" = "SunOS" ]; then
|
elif [ "$uname" = "SunOS" ]; then
|
||||||
LIBS="$LIBS -L/usr/lib"
|
LIBS="$LIBS -L/usr/lib"
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,7 @@ if test "$PHP_FASTDFS_CLIENT" != "no"; then
|
||||||
ROOT=/usr
|
ROOT=/usr
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PHP_ADD_INCLUDE($ROOT/include/fastcommon)
|
PHP_ADD_INCLUDE($ROOT/local/include)
|
||||||
PHP_ADD_INCLUDE($ROOT/include/fastdfs)
|
|
||||||
|
|
||||||
PHP_ADD_LIBRARY_WITH_PATH(fastcommon, $ROOT/lib, FASTDFS_CLIENT_SHARED_LIBADD)
|
PHP_ADD_LIBRARY_WITH_PATH(fastcommon, $ROOT/lib, FASTDFS_CLIENT_SHARED_LIBADD)
|
||||||
PHP_ADD_LIBRARY_WITH_PATH(fdfsclient, $ROOT/lib, FASTDFS_CLIENT_SHARED_LIBADD)
|
PHP_ADD_LIBRARY_WITH_PATH(fdfsclient, $ROOT/lib, FASTDFS_CLIENT_SHARED_LIBADD)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#include "php7_ext_wrapper.h"
|
#include "fastcommon/php7_ext_wrapper.h"
|
||||||
#include "ext/standard/info.h"
|
#include "ext/standard/info.h"
|
||||||
#include <zend_extensions.h>
|
#include <zend_extensions.h>
|
||||||
#include <zend_exceptions.h>
|
#include <zend_exceptions.h>
|
||||||
|
|
@ -7,14 +7,14 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "fdfs_client.h"
|
#include "fastdfs/fdfs_client.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "fdfs_global.h"
|
#include "fastdfs/fdfs_global.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "client_global.h"
|
#include "fastdfs/client_global.h"
|
||||||
#include "fastdfs_client.h"
|
#include "fastdfs/fastdfs_client.h"
|
||||||
#include "fdfs_http_shared.h"
|
#include "fastdfs/fdfs_http_shared.h"
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "pthread_func.h"
|
#include "fastcommon/pthread_func.h"
|
||||||
#include "process_ctrl.h"
|
#include "fastcommon/process_ctrl.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "ini_file_reader.h"
|
#include "fastcommon/ini_file_reader.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
#include "tracker_client_thread.h"
|
#include "tracker_client_thread.h"
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
#include "storage_func.h"
|
#include "storage_func.h"
|
||||||
#include "storage_sync.h"
|
#include "storage_sync.h"
|
||||||
#include "storage_service.h"
|
#include "storage_service.h"
|
||||||
#include "sched_thread.h"
|
#include "fastcommon/sched_thread.h"
|
||||||
#include "storage_dio.h"
|
#include "storage_dio.h"
|
||||||
#include "trunk_mem.h"
|
#include "trunk_mem.h"
|
||||||
#include "trunk_sync.h"
|
#include "trunk_sync.h"
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,11 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "hash.h"
|
#include "fastcommon/hash.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "ini_file_reader.h"
|
#include "fastcommon/ini_file_reader.h"
|
||||||
#include "fdht_types.h"
|
#include "fdht_types.h"
|
||||||
#include "fdht_proto.h"
|
#include "fdht_proto.h"
|
||||||
#include "fdht_global.h"
|
#include "fdht_global.h"
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
#ifndef _FDHT_DEFINE_H_
|
#ifndef _FDHT_DEFINE_H_
|
||||||
#define _FDHT_DEFINE_H_
|
#define _FDHT_DEFINE_H_
|
||||||
|
|
||||||
#include "common_define.h"
|
#include "fastcommon/common_define.h"
|
||||||
|
|
||||||
#define FDHT_SERVER_DEFAULT_PORT 24000
|
#define FDHT_SERVER_DEFAULT_PORT 24000
|
||||||
#define FDHT_DEFAULT_PROXY_PORT 12200
|
#define FDHT_DEFAULT_PROXY_PORT 12200
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,10 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "ini_file_reader.h"
|
#include "fastcommon/ini_file_reader.h"
|
||||||
#include "fdht_func.h"
|
#include "fdht_func.h"
|
||||||
|
|
||||||
int fdht_split_ids(const char *szIds, int **ppIds, int *id_count)
|
int fdht_split_ids(const char *szIds, int **ppIds, int *id_count)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "fdht_types.h"
|
#include "fdht_types.h"
|
||||||
#include "ini_file_reader.h"
|
#include "fastcommon/ini_file_reader.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "common_define.h"
|
#include "fastcommon/common_define.h"
|
||||||
#include "fdht_define.h"
|
#include "fdht_define.h"
|
||||||
#include "fdht_types.h"
|
#include "fdht_types.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "fdht_define.h"
|
#include "fdht_define.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "fdht_types.h"
|
#include "fdht_types.h"
|
||||||
#include "fdht_proto.h"
|
#include "fdht_proto.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,10 @@
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "pthread_func.h"
|
#include "fastcommon/pthread_func.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "storage_dio.h"
|
#include "storage_dio.h"
|
||||||
#include "storage_nio.h"
|
#include "storage_nio.h"
|
||||||
#include "storage_service.h"
|
#include "storage_service.h"
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "fast_task_queue.h"
|
#include "fastcommon/fast_task_queue.h"
|
||||||
#include "fast_blocked_queue.h"
|
#include "fastcommon/fast_blocked_queue.h"
|
||||||
|
|
||||||
struct storage_dio_context
|
struct storage_dio_context
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,11 @@
|
||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "avl_tree.h"
|
#include "fastcommon/avl_tree.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
#include "storage_global.h"
|
#include "storage_global.h"
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,11 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "storage_dump.h"
|
#include "storage_dump.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "sched_thread.h"
|
#include "fastcommon/sched_thread.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "hash.h"
|
#include "fastcommon/hash.h"
|
||||||
#include "connection_pool.h"
|
#include "fastcommon/connection_pool.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "storage_global.h"
|
#include "storage_global.h"
|
||||||
#include "storage_service.h"
|
#include "storage_service.h"
|
||||||
|
|
|
||||||
|
|
@ -23,14 +23,14 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "pthread_func.h"
|
#include "fastcommon/pthread_func.h"
|
||||||
#include "sched_thread.h"
|
#include "fastcommon/sched_thread.h"
|
||||||
#include "ini_file_reader.h"
|
#include "fastcommon/ini_file_reader.h"
|
||||||
#include "connection_pool.h"
|
#include "fastcommon/connection_pool.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
#include "fdfs_shared_func.h"
|
#include "fdfs_shared_func.h"
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "storage_global.h"
|
#include "storage_global.h"
|
||||||
|
|
||||||
volatile bool g_continue_flag = true;
|
volatile bool g_continue_flag = true;
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,12 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "common_define.h"
|
#include "fastcommon/common_define.h"
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "client_global.h"
|
#include "client_global.h"
|
||||||
#include "fdht_types.h"
|
#include "fdht_types.h"
|
||||||
#include "local_ip_func.h"
|
#include "fastcommon/local_ip_func.h"
|
||||||
#include "trunk_shared.h"
|
#include "trunk_shared.h"
|
||||||
|
|
||||||
#ifdef WITH_HTTPD
|
#ifdef WITH_HTTPD
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,10 @@
|
||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
#include "storage_global.h"
|
#include "storage_global.h"
|
||||||
|
|
|
||||||
|
|
@ -21,16 +21,16 @@
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "sched_thread.h"
|
#include "fastcommon/sched_thread.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "fast_task_queue.h"
|
#include "fastcommon/fast_task_queue.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
#include "storage_global.h"
|
#include "storage_global.h"
|
||||||
#include "storage_service.h"
|
#include "storage_service.h"
|
||||||
#include "ioevent_loop.h"
|
#include "fastcommon/ioevent_loop.h"
|
||||||
#include "storage_dio.h"
|
#include "storage_dio.h"
|
||||||
#include "storage_nio.h"
|
#include "storage_nio.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,11 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "storage_func.h"
|
#include "storage_func.h"
|
||||||
#include "fast_task_queue.h"
|
#include "fastcommon/fast_task_queue.h"
|
||||||
#include "storage_global.h"
|
#include "storage_global.h"
|
||||||
#include "fdht_types.h"
|
#include "fdht_types.h"
|
||||||
#include "trunk_mem.h"
|
#include "trunk_mem.h"
|
||||||
#include "md5.h"
|
#include "fastcommon/md5.h"
|
||||||
|
|
||||||
#define FDFS_STORAGE_STAGE_NIO_INIT 0
|
#define FDFS_STORAGE_STAGE_NIO_INIT 0
|
||||||
#define FDFS_STORAGE_STAGE_NIO_RECV 1
|
#define FDFS_STORAGE_STAGE_NIO_RECV 1
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@
|
||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
|
|
|
||||||
|
|
@ -22,20 +22,20 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "pthread_func.h"
|
#include "fastcommon/pthread_func.h"
|
||||||
#include "sched_thread.h"
|
#include "fastcommon/sched_thread.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
#include "storage_service.h"
|
#include "storage_service.h"
|
||||||
#include "storage_func.h"
|
#include "storage_func.h"
|
||||||
#include "storage_sync.h"
|
#include "storage_sync.h"
|
||||||
#include "storage_global.h"
|
#include "storage_global.h"
|
||||||
#include "base64.h"
|
#include "fastcommon/base64.h"
|
||||||
#include "hash.h"
|
#include "fastcommon/hash.h"
|
||||||
#include "fdht_client.h"
|
#include "fdht_client.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "tracker_client.h"
|
#include "tracker_client.h"
|
||||||
|
|
@ -46,7 +46,7 @@
|
||||||
#include "trunk_mem.h"
|
#include "trunk_mem.h"
|
||||||
#include "trunk_sync.h"
|
#include "trunk_sync.h"
|
||||||
#include "trunk_client.h"
|
#include "trunk_client.h"
|
||||||
#include "ioevent_loop.h"
|
#include "fastcommon/ioevent_loop.h"
|
||||||
|
|
||||||
//storage access log actions
|
//storage access log actions
|
||||||
#define ACCESS_LOG_ACTION_UPLOAD_FILE "upload"
|
#define ACCESS_LOG_ACTION_UPLOAD_FILE "upload"
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@
|
||||||
#define STORAGE_DELETE_FLAG_FILE 1
|
#define STORAGE_DELETE_FLAG_FILE 1
|
||||||
#define STORAGE_DELETE_FLAG_LINK 2
|
#define STORAGE_DELETE_FLAG_LINK 2
|
||||||
|
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "fast_task_queue.h"
|
#include "fastcommon/fast_task_queue.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
||||||
|
|
@ -20,13 +20,13 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "pthread_func.h"
|
#include "fastcommon/pthread_func.h"
|
||||||
#include "sched_thread.h"
|
#include "fastcommon/sched_thread.h"
|
||||||
#include "ini_file_reader.h"
|
#include "fastcommon/ini_file_reader.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
#include "storage_global.h"
|
#include "storage_global.h"
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,13 @@
|
||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "pthread_func.h"
|
#include "fastcommon/pthread_func.h"
|
||||||
#include "sched_thread.h"
|
#include "fastcommon/sched_thread.h"
|
||||||
#include "fast_task_queue.h"
|
#include "fastcommon/fast_task_queue.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
#include "tracker_client_thread.h"
|
#include "tracker_client_thread.h"
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,10 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
#include "storage_global.h"
|
#include "storage_global.h"
|
||||||
#include "trunk_client.h"
|
#include "trunk_client.h"
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
#ifndef _TRUNK_CLIENT_H_
|
#ifndef _TRUNK_CLIENT_H_
|
||||||
#define _TRUNK_CLIENT_H_
|
#define _TRUNK_CLIENT_H_
|
||||||
|
|
||||||
#include "common_define.h"
|
#include "fastcommon/common_define.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "trunk_mem.h"
|
#include "trunk_mem.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "avl_tree.h"
|
#include "fastcommon/avl_tree.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "storage_global.h"
|
#include "storage_global.h"
|
||||||
#include "trunk_free_block_checker.h"
|
#include "trunk_free_block_checker.h"
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "common_define.h"
|
#include "fastcommon/common_define.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "trunk_shared.h"
|
#include "trunk_shared.h"
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,12 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "pthread_func.h"
|
#include "fastcommon/pthread_func.h"
|
||||||
#include "sched_thread.h"
|
#include "fastcommon/sched_thread.h"
|
||||||
#include "avl_tree.h"
|
#include "fastcommon/avl_tree.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
#include "storage_global.h"
|
#include "storage_global.h"
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "common_define.h"
|
#include "fastcommon/common_define.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "fast_mblock.h"
|
#include "fastcommon/fast_mblock.h"
|
||||||
#include "trunk_shared.h"
|
#include "trunk_shared.h"
|
||||||
#include "fdfs_shared_func.h"
|
#include "fdfs_shared_func.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "trunk_shared.h"
|
#include "trunk_shared.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "base64.h"
|
#include "fastcommon/base64.h"
|
||||||
#include "common_define.h"
|
#include "fastcommon/common_define.h"
|
||||||
#include "ini_file_reader.h"
|
#include "fastcommon/ini_file_reader.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "pthread_func.h"
|
#include "fastcommon/pthread_func.h"
|
||||||
#include "sched_thread.h"
|
#include "fastcommon/sched_thread.h"
|
||||||
#include "ini_file_reader.h"
|
#include "fastcommon/ini_file_reader.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
#include "storage_global.h"
|
#include "storage_global.h"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
.SUFFIXES: .c .o .lo
|
.SUFFIXES: .c .o .lo
|
||||||
|
|
||||||
COMPILE = $(CC) -g -Wall -O -D_FILE_OFFSET_BITS=64 -DDEBUG
|
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
|
LIB_PATH = -L/usr/local/lib -lfdfsclient -lfastcommon
|
||||||
TARGET_PATH = $(TARGET_PREFIX)/bin
|
TARGET_PATH = $(TARGET_PREFIX)/bin
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "common_define.h"
|
#include "fastcommon/common_define.h"
|
||||||
#include "test_types.h"
|
#include "test_types.h"
|
||||||
#include "common_func.h"
|
#include "common_func.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "fdfs_global.h"
|
#include "fastdfs/fdfs_global.h"
|
||||||
#include "dfs_func.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)
|
int dfs_init(const int proccess_index, const char *conf_filename)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "fdfs_global.h"
|
#include "fastdfs/fdfs_global.h"
|
||||||
#include "dfs_func.h"
|
#include "dfs_func.h"
|
||||||
#include "fdfs_client.h"
|
#include "fastdfs/fdfs_client.h"
|
||||||
|
|
||||||
static ConnectionInfo *pTrackerServer;
|
static ConnectionInfo *pTrackerServer;
|
||||||
static ConnectionInfo storage_servers[FDFS_MAX_SERVERS_EACH_GROUP];
|
static ConnectionInfo storage_servers[FDFS_MAX_SERVERS_EACH_GROUP];
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "common_define.h"
|
#include "fastcommon/common_define.h"
|
||||||
#include "test_types.h"
|
#include "test_types.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "test_types.h"
|
#include "test_types.h"
|
||||||
#include "common_func.h"
|
#include "common_func.h"
|
||||||
#include "dfs_func.h"
|
#include "dfs_func.h"
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "common_define.h"
|
#include "fastcommon/common_define.h"
|
||||||
#include "test_types.h"
|
#include "test_types.h"
|
||||||
#include "common_func.h"
|
#include "common_func.h"
|
||||||
#include "dfs_func.h"
|
#include "dfs_func.h"
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include "common_define.h"
|
#include "fastcommon/common_define.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "test_types.h"
|
#include "test_types.h"
|
||||||
#include "common_func.h"
|
#include "common_func.h"
|
||||||
#include "dfs_func.h"
|
#include "dfs_func.h"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
.SUFFIXES: .c .o
|
.SUFFIXES: .c .o
|
||||||
|
|
||||||
COMPILE = $(CC) $(CFLAGS)
|
COMPILE = $(CC) $(CFLAGS)
|
||||||
INC_PATH = -I../common -I/usr/include/fastcommon
|
INC_PATH = -I../common -I/usr/local/include
|
||||||
LIB_PATH = $(LIBS) -lfastcommon
|
LIB_PATH = $(LIBS) -lfastcommon
|
||||||
TARGET_PATH = $(TARGET_PREFIX)/bin
|
TARGET_PATH = $(TARGET_PREFIX)/bin
|
||||||
CONFIG_PATH = $(TARGET_CONF_PATH)
|
CONFIG_PATH = $(TARGET_CONF_PATH)
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "fdfs_shared_func.h"
|
#include "fdfs_shared_func.h"
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@
|
||||||
#ifndef _FDFS_SHARED_FUNC_H
|
#ifndef _FDFS_SHARED_FUNC_H
|
||||||
#define _FDFS_SHARED_FUNC_H
|
#define _FDFS_SHARED_FUNC_H
|
||||||
|
|
||||||
#include "common_define.h"
|
#include "fastcommon/common_define.h"
|
||||||
#include "ini_file_reader.h"
|
#include "fastcommon/ini_file_reader.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
||||||
|
|
@ -20,14 +20,14 @@
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "pthread_func.h"
|
#include "fastcommon/pthread_func.h"
|
||||||
#include "process_ctrl.h"
|
#include "fastcommon/process_ctrl.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "base64.h"
|
#include "fastcommon/base64.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "sched_thread.h"
|
#include "fastcommon/sched_thread.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "tracker_mem.h"
|
#include "tracker_mem.h"
|
||||||
#include "tracker_service.h"
|
#include "tracker_service.h"
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,11 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "tracker_dump.h"
|
#include "tracker_dump.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "sched_thread.h"
|
#include "fastcommon/sched_thread.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "hash.h"
|
#include "fastcommon/hash.h"
|
||||||
#include "connection_pool.h"
|
#include "fastcommon/connection_pool.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "tracker_global.h"
|
#include "tracker_global.h"
|
||||||
#include "tracker_mem.h"
|
#include "tracker_mem.h"
|
||||||
|
|
|
||||||
|
|
@ -22,18 +22,18 @@
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "ini_file_reader.h"
|
#include "fastcommon/ini_file_reader.h"
|
||||||
#include "connection_pool.h"
|
#include "fastcommon/connection_pool.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
#include "tracker_global.h"
|
#include "tracker_global.h"
|
||||||
#include "tracker_func.h"
|
#include "tracker_func.h"
|
||||||
#include "tracker_mem.h"
|
#include "tracker_mem.h"
|
||||||
#include "local_ip_func.h"
|
#include "fastcommon/local_ip_func.h"
|
||||||
#include "fdfs_shared_func.h"
|
#include "fdfs_shared_func.h"
|
||||||
|
|
||||||
#ifdef WITH_HTTPD
|
#ifdef WITH_HTTPD
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,13 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "common_define.h"
|
#include "fastcommon/common_define.h"
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "tracker_status.h"
|
#include "tracker_status.h"
|
||||||
#include "base64.h"
|
#include "fastcommon/base64.h"
|
||||||
#include "hash.h"
|
#include "fastcommon/hash.h"
|
||||||
#include "local_ip_func.h"
|
#include "fastcommon/local_ip_func.h"
|
||||||
|
|
||||||
#ifdef WITH_HTTPD
|
#ifdef WITH_HTTPD
|
||||||
#include "fdfs_http_shared.h"
|
#include "fdfs_http_shared.h"
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,13 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "tracker_global.h"
|
#include "tracker_global.h"
|
||||||
#include "tracker_mem.h"
|
#include "tracker_mem.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
#include "http_func.h"
|
#include "fastcommon/http_func.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "tracker_http_check.h"
|
#include "tracker_http_check.h"
|
||||||
|
|
||||||
static pthread_t http_check_tid;
|
static pthread_t http_check_tid;
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,12 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "pthread_func.h"
|
#include "fastcommon/pthread_func.h"
|
||||||
#include "sched_thread.h"
|
#include "fastcommon/sched_thread.h"
|
||||||
#include "fdfs_shared_func.h"
|
#include "fdfs_shared_func.h"
|
||||||
#include "tracker_global.h"
|
#include "tracker_global.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
|
|
|
||||||
|
|
@ -21,18 +21,18 @@
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "sched_thread.h"
|
#include "fastcommon/sched_thread.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "fast_task_queue.h"
|
#include "fastcommon/fast_task_queue.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
#include "tracker_mem.h"
|
#include "tracker_mem.h"
|
||||||
#include "tracker_global.h"
|
#include "tracker_global.h"
|
||||||
#include "tracker_service.h"
|
#include "tracker_service.h"
|
||||||
#include "ioevent_loop.h"
|
#include "fastcommon/ioevent_loop.h"
|
||||||
#include "tracker_nio.h"
|
#include "tracker_nio.h"
|
||||||
|
|
||||||
static void client_sock_read(int sock, short event, void *arg);
|
static void client_sock_read(int sock, short event, void *arg);
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "fast_task_queue.h"
|
#include "fastcommon/fast_task_queue.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,10 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@
|
||||||
#define _TRACKER_PROTO_H_
|
#define _TRACKER_PROTO_H_
|
||||||
|
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "connection_pool.h"
|
#include "fastcommon/connection_pool.h"
|
||||||
#include "ini_file_reader.h"
|
#include "fastcommon/ini_file_reader.h"
|
||||||
|
|
||||||
#define TRACKER_PROTO_CMD_STORAGE_JOIN 81
|
#define TRACKER_PROTO_CMD_STORAGE_JOIN 81
|
||||||
#define FDFS_PROTO_CMD_QUIT 82
|
#define FDFS_PROTO_CMD_QUIT 82
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,11 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "pthread_func.h"
|
#include "fastcommon/pthread_func.h"
|
||||||
#include "tracker_global.h"
|
#include "tracker_global.h"
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
#include "tracker_mem.h"
|
#include "tracker_mem.h"
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,13 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "base64.h"
|
#include "fastcommon/base64.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "pthread_func.h"
|
#include "fastcommon/pthread_func.h"
|
||||||
#include "sched_thread.h"
|
#include "fastcommon/sched_thread.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "tracker_global.h"
|
#include "tracker_global.h"
|
||||||
#include "tracker_mem.h"
|
#include "tracker_mem.h"
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
#include "tracker_nio.h"
|
#include "tracker_nio.h"
|
||||||
#include "tracker_relationship.h"
|
#include "tracker_relationship.h"
|
||||||
#include "fdfs_shared_func.h"
|
#include "fdfs_shared_func.h"
|
||||||
#include "ioevent_loop.h"
|
#include "fastcommon/ioevent_loop.h"
|
||||||
#include "tracker_service.h"
|
#include "tracker_service.h"
|
||||||
|
|
||||||
#define PKG_LEN_PRINTF_FORMAT "%d"
|
#define PKG_LEN_PRINTF_FORMAT "%d"
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "ioevent.h"
|
#include "fastcommon/ioevent.h"
|
||||||
#include "fast_task_queue.h"
|
#include "fastcommon/fast_task_queue.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,11 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "sched_thread.h"
|
#include "fastcommon/sched_thread.h"
|
||||||
#include "ini_file_reader.h"
|
#include "fastcommon/ini_file_reader.h"
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "tracker_global.h"
|
#include "tracker_global.h"
|
||||||
#include "tracker_status.h"
|
#include "tracker_status.h"
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "connection_pool.h"
|
#include "fastcommon/connection_pool.h"
|
||||||
|
|
||||||
#define FDFS_ONE_MB (1024 * 1024)
|
#define FDFS_ONE_MB (1024 * 1024)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue