support multi ip for storage server (tracker part)
parent
82e95ccee7
commit
ae8024d355
|
|
@ -188,6 +188,30 @@ static int fdfs_init_ip_array(FDFSStorageIdMapArray *mapArray,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int fdfs_check_id_duplicated()
|
||||
{
|
||||
FDFSStorageIdInfo *current;
|
||||
FDFSStorageIdInfo *idEnd;
|
||||
FDFSStorageIdInfo *previous;
|
||||
|
||||
current=g_storage_ids_by_id.ids + 0;
|
||||
idEnd = g_storage_ids_by_id.ids + g_storage_ids_by_id.count;
|
||||
for (current=g_storage_ids_by_id.ids + 1; current<idEnd; current++)
|
||||
{
|
||||
if (strcmp(current->id, previous->id) == 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"config file: storage_ids.conf, "
|
||||
"duplicate storage id: %s",
|
||||
__LINE__, current->id);
|
||||
return EEXIST;
|
||||
}
|
||||
previous = current;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fdfs_check_ip_port()
|
||||
{
|
||||
int i;
|
||||
|
|
@ -490,6 +514,10 @@ int fdfs_load_storage_ids(char *content, const char *pStorageIdsFilename)
|
|||
|
||||
qsort(g_storage_ids_by_id.ids, g_storage_ids_by_id.count,
|
||||
sizeof(FDFSStorageIdInfo), fdfs_cmp_server_id);
|
||||
if ((result=fdfs_check_id_duplicated()) != 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
if ((result=fdfs_init_ip_array(&g_storage_ids_by_ip,
|
||||
fdfs_cmp_group_name_and_ip)) != 0)
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ int fdfs_load_storage_ids(char *content, const char *pStorageIdsFilename);
|
|||
|
||||
FDFSStorageIdInfo *fdfs_get_storage_by_id(const char *id);
|
||||
|
||||
FDFSStorageIdInfo *fdfs_get_storage_id_by_ip(const char *group_name, \
|
||||
FDFSStorageIdInfo *fdfs_get_storage_id_by_ip(const char *group_name,
|
||||
const char *pIpAddr);
|
||||
|
||||
FDFSStorageIdInfo *fdfs_get_storage_id_by_ip_port(const char *pIpAddr,
|
||||
|
|
@ -71,7 +71,7 @@ int fdfs_get_storage_ids_from_tracker_server(TrackerServerInfo *pTrackerServer);
|
|||
|
||||
int fdfs_get_storage_ids_from_tracker_group(TrackerServerGroup *pTrackerGroup);
|
||||
|
||||
int fdfs_load_storage_ids_from_file(const char *config_filename, \
|
||||
int fdfs_load_storage_ids_from_file(const char *config_filename,
|
||||
IniContext *pItemContext);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -525,6 +525,7 @@ int fdfs_parse_multi_ips_ex(char *ip_str, FDFSMultiIP *ip_addrs,
|
|||
char *hosts[FDFS_MULTI_IP_MAX_COUNT];
|
||||
int i;
|
||||
|
||||
ip_addrs->index = 0;
|
||||
ip_addrs->count = splitEx(ip_str, ',', hosts, FDFS_MULTI_IP_MAX_COUNT);
|
||||
for (i=0; i<ip_addrs->count; i++)
|
||||
{
|
||||
|
|
@ -641,3 +642,21 @@ int fdfs_check_and_format_ips(FDFSMultiIP *ip_addrs,
|
|||
*error_info = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
void fdfs_set_multi_ip_index(FDFSMultiIP *multi_ip, const char *target_ip)
|
||||
{
|
||||
int i;
|
||||
if (multi_ip->count == 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (i=0; i<multi_ip->count; i++)
|
||||
{
|
||||
if (strcmp(multi_ip->ips[i], target_ip) == 0)
|
||||
{
|
||||
multi_ip->index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,6 +122,8 @@ int fdfs_check_and_format_ips(FDFSMultiIP *ip_addrs,
|
|||
const char *fdfs_get_ipaddr_by_client_ip(const FDFSMultiIP *ip_addrs,
|
||||
const char *client_ip);
|
||||
|
||||
void fdfs_set_multi_ip_index(FDFSMultiIP *multi_ip, const char *target_ip);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ static int fdfs_dump_group_stat(FDFSGroupInfo *pGroup, char *buff, const int buf
|
|||
pGroup->store_path_count,
|
||||
pGroup->subdir_count_per_path,
|
||||
pGroup->current_trunk_file_id,
|
||||
pGroup->pStoreServer != NULL ? pGroup->pStoreServer->ip_addr : "",
|
||||
pGroup->pTrunkServer != NULL ? pGroup->pTrunkServer->ip_addr : "",
|
||||
pGroup->pStoreServer != NULL ? FDFS_CURRENT_IP_ADDR(pGroup->pStoreServer) : "",
|
||||
pGroup->pTrunkServer != NULL ? FDFS_CURRENT_IP_ADDR(pGroup->pTrunkServer) : "",
|
||||
pGroup->last_trunk_server_id,
|
||||
pGroup->chg_count,
|
||||
pGroup->trunk_chg_count,
|
||||
|
|
@ -91,7 +91,7 @@ static int fdfs_dump_group_stat(FDFSGroupInfo *pGroup, char *buff, const int buf
|
|||
for (ppServer=pGroup->all_servers; ppServer<ppServerEnd; ppServer++)
|
||||
{
|
||||
total_len += snprintf(buff + total_len, buffSize - total_len,
|
||||
"\t%s\n", (*ppServer)->ip_addr);
|
||||
"\t%s\n", FDFS_CURRENT_IP_ADDR(*ppServer));
|
||||
}
|
||||
|
||||
total_len += snprintf(buff + total_len, buffSize - total_len,
|
||||
|
|
@ -100,7 +100,7 @@ static int fdfs_dump_group_stat(FDFSGroupInfo *pGroup, char *buff, const int buf
|
|||
for (ppServer=pGroup->active_servers; ppServer<ppServerEnd; ppServer++)
|
||||
{
|
||||
total_len += snprintf(buff + total_len, buffSize - total_len,
|
||||
"\t%s\n", (*ppServer)->ip_addr);
|
||||
"\t%s\n", FDFS_CURRENT_IP_ADDR(*ppServer));
|
||||
}
|
||||
|
||||
#ifdef WITH_HTTPD
|
||||
|
|
@ -141,8 +141,8 @@ static int fdfs_dump_group_stat(FDFSGroupInfo *pGroup, char *buff, const int buf
|
|||
|
||||
total_len += snprintf(buff + total_len, buffSize - total_len,
|
||||
"\t%s => %s: %s\n",
|
||||
pGroup->all_servers[i]->ip_addr,
|
||||
pGroup->all_servers[j]->ip_addr,
|
||||
FDFS_CURRENT_IP_ADDR(pGroup->all_servers[i]),
|
||||
FDFS_CURRENT_IP_ADDR(pGroup->all_servers[j]),
|
||||
formatDatetime(pGroup->last_sync_timestamps[i][j],
|
||||
"%Y-%m-%d %H:%M:%S",
|
||||
szSyncedTimestamp,
|
||||
|
|
@ -213,12 +213,12 @@ static int fdfs_dump_storage_stat(FDFSStorageDetail *pServer,
|
|||
"last_sync_update=%s\n"
|
||||
"last_synced_timestamp=%s\n"
|
||||
"last_heart_beat_time=%s\n",
|
||||
pServer->ip_addr,
|
||||
FDFS_CURRENT_IP_ADDR(pServer),
|
||||
pServer->version,
|
||||
pServer->status,
|
||||
pServer->domain_name,
|
||||
pServer->psync_src_server != NULL ?
|
||||
pServer->psync_src_server->ip_addr : "",
|
||||
FDFS_CURRENT_IP_ADDR(pServer->psync_src_server) : "",
|
||||
formatDatetime(pServer->sync_until_timestamp,
|
||||
"%Y-%m-%d %H:%M:%S",
|
||||
szSyncUntilTimestamp, sizeof(szSyncUntilTimestamp)),
|
||||
|
|
|
|||
|
|
@ -777,7 +777,7 @@ int tracker_load_from_conf_file(const char *filename, \
|
|||
g_trunk_init_reload_from_binlog, \
|
||||
g_trunk_compress_binlog_min_interval, \
|
||||
g_use_storage_id, g_id_type_in_filename == \
|
||||
FDFS_ID_TYPE_SERVER_ID ? "id" : "ip", g_storage_id_count, \
|
||||
FDFS_ID_TYPE_SERVER_ID ? "id" : "ip", g_storage_ids_by_id.count, \
|
||||
g_rotate_error_log, g_error_log_rotate_time.hour, \
|
||||
g_error_log_rotate_time.minute, \
|
||||
g_log_context.rotate_size, g_log_file_keep_days,
|
||||
|
|
|
|||
|
|
@ -129,12 +129,16 @@ static int _tracker_mem_add_storage(FDFSGroupInfo *pGroup,
|
|||
const char *ip_addr, const bool bNeedSleep,
|
||||
const bool bNeedLock, bool *bInserted);
|
||||
|
||||
static int tracker_mem_add_storage(TrackerClientInfo *pClientInfo, \
|
||||
const char *id, const char *ip_addr, \
|
||||
static int tracker_mem_add_storage(TrackerClientInfo *pClientInfo,
|
||||
const char *id, const char *ip_addr,
|
||||
const bool bNeedSleep, const bool bNeedLock, bool *bInserted);
|
||||
|
||||
static int tracker_mem_add_group_ex(FDFSGroups *pGroups, \
|
||||
TrackerClientInfo *pClientInfo, const char *group_name, \
|
||||
static int tracker_mem_add_storage_from_file(FDFSGroups *pGroups,
|
||||
const char *data_path, TrackerClientInfo *pClientInfo,
|
||||
const char *group_name, const char *storage_id, char *ip_addr);
|
||||
|
||||
static int tracker_mem_add_group_ex(FDFSGroups *pGroups,
|
||||
TrackerClientInfo *pClientInfo, const char *group_name,
|
||||
const bool bNeedSleep, bool *bInserted);
|
||||
|
||||
static int tracker_mem_destroy_groups(FDFSGroups *pGroups, const bool saveFiles);
|
||||
|
|
@ -918,7 +922,7 @@ static int tracker_load_storages_old(FDFSGroups *pGroups, const char *data_path)
|
|||
break;
|
||||
}
|
||||
|
||||
if ((result=tracker_mem_add_storage(&clientInfo, NULL, ip_addr, \
|
||||
if ((result=tracker_mem_add_storage(&clientInfo, NULL, ip_addr,
|
||||
false, false, &bInserted)) != 0)
|
||||
{
|
||||
break;
|
||||
|
|
@ -1077,7 +1081,6 @@ static int tracker_load_storages_new(FDFSGroups *pGroups, const char *data_path)
|
|||
int result;
|
||||
char section_name[64];
|
||||
TrackerClientInfo clientInfo;
|
||||
bool bInserted;
|
||||
|
||||
if (!fileExists(STORAGE_SERVERS_LIST_FILENAME_NEW) && \
|
||||
fileExists(STORAGE_SERVERS_LIST_FILENAME_OLD))
|
||||
|
|
@ -1146,59 +1149,14 @@ static int tracker_load_storages_new(FDFSGroups *pGroups, const char *data_path)
|
|||
|
||||
ip_addr = iniGetStrValue(section_name, \
|
||||
STORAGE_ITEM_IP_ADDR, &iniContext);
|
||||
if (ip_addr == NULL)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"in the file \"%s/%s\", " \
|
||||
"item \"%s\" is not found", \
|
||||
__LINE__, data_path, \
|
||||
STORAGE_SERVERS_LIST_FILENAME_NEW, \
|
||||
STORAGE_ITEM_IP_ADDR);
|
||||
result = ENOENT;
|
||||
break;
|
||||
}
|
||||
if (*ip_addr == '\0')
|
||||
{
|
||||
logWarning("file: "__FILE__", line: %d, " \
|
||||
"in the file \"%s/%s\", " \
|
||||
"item \"%s\" is empty", \
|
||||
__LINE__, data_path, \
|
||||
STORAGE_SERVERS_LIST_FILENAME_NEW, \
|
||||
STORAGE_ITEM_IP_ADDR);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((result=tracker_mem_add_storage_from_file(pGroups,
|
||||
data_path, &clientInfo, group_name,
|
||||
storage_id, ip_addr)) != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
memset(&clientInfo, 0, sizeof(TrackerClientInfo));
|
||||
if ((clientInfo.pGroup=tracker_mem_get_group_ex(pGroups, \
|
||||
group_name)) == NULL)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"in the file \"%s/%s\", " \
|
||||
"group \"%s\" is not found", \
|
||||
__LINE__, data_path, \
|
||||
STORAGE_SERVERS_LIST_FILENAME_NEW, \
|
||||
group_name);
|
||||
result = errno != 0 ? errno : ENOENT;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((result=tracker_mem_add_storage(&clientInfo, storage_id, \
|
||||
ip_addr, false, false, &bInserted)) != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (!bInserted)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"in the file \"%s/%s\", " \
|
||||
"storage \"%s\" is duplicate", \
|
||||
__LINE__, data_path, \
|
||||
STORAGE_SERVERS_LIST_FILENAME_NEW, ip_addr);
|
||||
result = errno != 0 ? errno : EEXIST;
|
||||
break;
|
||||
}
|
||||
|
||||
pStorage = clientInfo.pStorage;
|
||||
pStat = &(pStorage->stat);
|
||||
pStorage->status = iniGetIntValue(section_name, \
|
||||
|
|
@ -3625,6 +3583,93 @@ static int tracker_mem_add_storage(TrackerClientInfo *pClientInfo,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int tracker_mem_add_storage_from_file(FDFSGroups *pGroups,
|
||||
const char *data_path, TrackerClientInfo *pClientInfo,
|
||||
const char *group_name, const char *storage_id, char *ip_addr)
|
||||
{
|
||||
FDFSMultiIP multi_ip;
|
||||
char error_info[256];
|
||||
int result;
|
||||
bool bInserted;
|
||||
|
||||
if (g_use_storage_id)
|
||||
{
|
||||
if (storage_id == NULL || *storage_id == '\0')
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"in the file \"%s/%s\", "
|
||||
"group: %s, item \"%s\" is not found or empty",
|
||||
__LINE__, data_path,
|
||||
STORAGE_SERVERS_LIST_FILENAME_NEW,
|
||||
group_name, STORAGE_ITEM_SERVER_ID);
|
||||
return ENOENT;
|
||||
}
|
||||
}
|
||||
|
||||
if (ip_addr == NULL)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"in the file \"%s/%s\", "
|
||||
"group: %s, item \"%s\" is not found",
|
||||
__LINE__, data_path,
|
||||
STORAGE_SERVERS_LIST_FILENAME_NEW,
|
||||
group_name, STORAGE_ITEM_IP_ADDR);
|
||||
return ENOENT;
|
||||
}
|
||||
if (*ip_addr == '\0')
|
||||
{
|
||||
logWarning("file: "__FILE__", line: %d, "
|
||||
"in the file \"%s/%s\", "
|
||||
"group: %s, item \"%s\" is empty",
|
||||
__LINE__, data_path,
|
||||
STORAGE_SERVERS_LIST_FILENAME_NEW,
|
||||
group_name, STORAGE_ITEM_IP_ADDR);
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
memset(pClientInfo, 0, sizeof(TrackerClientInfo));
|
||||
if ((pClientInfo->pGroup=tracker_mem_get_group_ex(pGroups,
|
||||
group_name)) == NULL)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"in the file \"%s/%s\", "
|
||||
"group \"%s\" is not found",
|
||||
__LINE__, data_path,
|
||||
STORAGE_SERVERS_LIST_FILENAME_NEW,
|
||||
group_name);
|
||||
return errno != 0 ? errno : ENOENT;
|
||||
}
|
||||
|
||||
if ((result=fdfs_parse_multi_ips_ex(ip_addr, &multi_ip,
|
||||
error_info, sizeof(error_info), false)) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"in the file \"%s/%s\", invalid ip address, "
|
||||
"group: %s, error info: %s", __LINE__, data_path,
|
||||
STORAGE_SERVERS_LIST_FILENAME_NEW,
|
||||
group_name, error_info);
|
||||
return result;
|
||||
}
|
||||
|
||||
if ((result=tracker_mem_add_storage(pClientInfo, storage_id,
|
||||
multi_ip.ips[0], false, false, &bInserted)) != 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!bInserted)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"in the file \"%s/%s\", "
|
||||
"storage \"%s\" is duplicate",
|
||||
__LINE__, data_path,
|
||||
STORAGE_SERVERS_LIST_FILENAME_NEW, ip_addr);
|
||||
return EEXIST;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _tracker_mem_add_storage(FDFSGroupInfo *pGroup,
|
||||
FDFSStorageDetail **ppStorageServer, const char *id,
|
||||
const char *ip_addr, const bool bNeedSleep,
|
||||
|
|
@ -3632,6 +3677,8 @@ static int _tracker_mem_add_storage(FDFSGroupInfo *pGroup,
|
|||
{
|
||||
int result;
|
||||
const char *storage_id;
|
||||
FDFSStorageIdInfo *pStorageIdInfo;
|
||||
FDFSMultiIP multi_ip;
|
||||
|
||||
if (*ip_addr == '\0')
|
||||
{
|
||||
|
|
@ -3640,40 +3687,59 @@ static int _tracker_mem_add_storage(FDFSGroupInfo *pGroup,
|
|||
return EINVAL;
|
||||
}
|
||||
|
||||
memset(&multi_ip, 0, sizeof(multi_ip));
|
||||
if (!g_use_storage_id)
|
||||
{
|
||||
multi_ip.count = 1;
|
||||
multi_ip.index = 0;
|
||||
strcpy(multi_ip.ips[0], ip_addr);
|
||||
}
|
||||
|
||||
if (id != NULL)
|
||||
{
|
||||
if (g_use_storage_id)
|
||||
{
|
||||
result = fdfs_check_storage_id( \
|
||||
pGroup->group_name, id);
|
||||
if (result != 0)
|
||||
pStorageIdInfo = fdfs_get_storage_by_id(id);
|
||||
if (pStorageIdInfo == NULL)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"storage id: %s not exist in config file, "
|
||||
"group_name: %s, storage ip: %s", __LINE__,
|
||||
id, pGroup->group_name, ip_addr);
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
if (strcmp(pStorageIdInfo->group_name, pGroup->group_name) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"check storage id fail, " \
|
||||
"group_name: %s, id: %s, " \
|
||||
"storage ip: %s, errno: %d, " \
|
||||
"error info: %s", __LINE__, \
|
||||
pGroup->group_name, id, ip_addr, \
|
||||
result, STRERROR(result));
|
||||
return result;
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"check storage id fail, inconsistent group names, "
|
||||
"id: %s, storage ip: %s, "
|
||||
"reported group_name: %s != "
|
||||
"group name in config file: %s", __LINE__,
|
||||
pGroup->group_name, id, ip_addr,
|
||||
pStorageIdInfo->group_name);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
multi_ip = pStorageIdInfo->ip_addrs;
|
||||
}
|
||||
|
||||
storage_id = id;
|
||||
}
|
||||
else if (g_use_storage_id)
|
||||
{
|
||||
FDFSStorageIdInfo *pStorageIdInfo;
|
||||
pStorageIdInfo = fdfs_get_storage_id_by_ip( \
|
||||
pStorageIdInfo = fdfs_get_storage_id_by_ip(
|
||||
pGroup->group_name, ip_addr);
|
||||
if (pStorageIdInfo == NULL)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"get storage id info fail, " \
|
||||
"group_name: %s, storage ip: %s", \
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"get storage id info fail, "
|
||||
"group_name: %s, storage ip: %s not exist in config file",
|
||||
__LINE__, pGroup->group_name, ip_addr);
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
multi_ip = pStorageIdInfo->ip_addrs;
|
||||
storage_id = pStorageIdInfo->id;
|
||||
}
|
||||
else
|
||||
|
|
@ -3699,8 +3765,7 @@ static int _tracker_mem_add_storage(FDFSGroupInfo *pGroup,
|
|||
{
|
||||
if (g_use_storage_id)
|
||||
{
|
||||
memcpy ((*ppStorageServer)->ip_addr, ip_addr, \
|
||||
IP_ADDRESS_SIZE);
|
||||
fdfs_set_multi_ip_index(&(*ppStorageServer)->ip_addrs, ip_addr);
|
||||
}
|
||||
|
||||
if ((*ppStorageServer)->status==FDFS_STORAGE_STATUS_DELETED \
|
||||
|
|
@ -3714,7 +3779,7 @@ static int _tracker_mem_add_storage(FDFSGroupInfo *pGroup,
|
|||
|
||||
if (pGroup->count >= pGroup->alloc_size)
|
||||
{
|
||||
result = tracker_mem_realloc_store_servers( \
|
||||
result = tracker_mem_realloc_store_servers(
|
||||
pGroup, 1, bNeedSleep);
|
||||
if (result != 0)
|
||||
{
|
||||
|
|
@ -3723,11 +3788,15 @@ static int _tracker_mem_add_storage(FDFSGroupInfo *pGroup,
|
|||
}
|
||||
|
||||
*ppStorageServer = *(pGroup->all_servers + pGroup->count);
|
||||
snprintf((*ppStorageServer)->id, FDFS_STORAGE_ID_MAX_SIZE, \
|
||||
snprintf((*ppStorageServer)->id, FDFS_STORAGE_ID_MAX_SIZE,
|
||||
"%s", storage_id);
|
||||
memcpy((*ppStorageServer)->ip_addr, ip_addr, IP_ADDRESS_SIZE);
|
||||
(*ppStorageServer)->ip_addrs = multi_ip;
|
||||
if (g_use_storage_id)
|
||||
{
|
||||
fdfs_set_multi_ip_index(&(*ppStorageServer)->ip_addrs, ip_addr);
|
||||
}
|
||||
|
||||
tracker_mem_insert_into_sorted_servers(*ppStorageServer, \
|
||||
tracker_mem_insert_into_sorted_servers(*ppStorageServer,
|
||||
pGroup->sorted_servers, pGroup->count);
|
||||
pGroup->count++;
|
||||
pGroup->chg_count++;
|
||||
|
|
@ -4345,7 +4414,7 @@ int tracker_mem_add_group_and_storage(TrackerClientInfo *pClientInfo, \
|
|||
|
||||
if (g_use_storage_id)
|
||||
{
|
||||
pStorageIdInfo = fdfs_get_storage_id_by_ip( \
|
||||
pStorageIdInfo = fdfs_get_storage_id_by_ip(
|
||||
pClientInfo->pGroup->group_name, ip_addr);
|
||||
if (pStorageIdInfo == NULL)
|
||||
{
|
||||
|
|
@ -4518,7 +4587,7 @@ int tracker_mem_add_group_and_storage(TrackerClientInfo *pClientInfo, \
|
|||
}
|
||||
}
|
||||
|
||||
if ((result=tracker_mem_add_storage(pClientInfo, storage_id, ip_addr, \
|
||||
if ((result=tracker_mem_add_storage(pClientInfo, storage_id, ip_addr,
|
||||
bNeedSleep, true, &bStorageInserted)) != 0)
|
||||
{
|
||||
return result;
|
||||
|
|
@ -4703,6 +4772,7 @@ int tracker_mem_sync_storages(FDFSGroupInfo *pGroup, \
|
|||
FDFSStorageDetail target_storage;
|
||||
FDFSStorageDetail *pTargetStorage;
|
||||
FDFSStorageDetail **ppFound;
|
||||
char ip_str[256];
|
||||
|
||||
if ((result=pthread_mutex_lock(&mem_thread_lock)) != 0)
|
||||
{
|
||||
|
|
@ -4750,11 +4820,12 @@ int tracker_mem_sync_storages(FDFSGroupInfo *pGroup, \
|
|||
continue;
|
||||
}
|
||||
|
||||
fdfs_multi_ips_to_string(&(*ppFound)->ip_addrs,
|
||||
ip_str, sizeof(ip_str));
|
||||
logWarning("file: "__FILE__", line: %d, "
|
||||
"storage server: %s:%d, dest status: %d, "
|
||||
"my status: %d, should change my status!",
|
||||
__LINE__, (*ppFound)->ip_addr,
|
||||
(*ppFound)->storage_port,
|
||||
__LINE__, ip_str, (*ppFound)->storage_port,
|
||||
pServer->status, (*ppFound)->status);
|
||||
|
||||
if (pServer->status == \
|
||||
|
|
@ -4788,9 +4859,9 @@ int tracker_mem_sync_storages(FDFSGroupInfo *pGroup, \
|
|||
FDFSStorageDetail *pStorageServer;
|
||||
bool bInserted;
|
||||
|
||||
result = _tracker_mem_add_storage(pGroup, \
|
||||
&pStorageServer, pServer->id, \
|
||||
pServer->ip_addr, true, false, \
|
||||
result = _tracker_mem_add_storage(pGroup,
|
||||
&pStorageServer, pServer->id,
|
||||
pServer->ip_addr, true, false,
|
||||
&bInserted);
|
||||
if (result != 0)
|
||||
{
|
||||
|
|
@ -4930,6 +5001,7 @@ static int tracker_write_to_trunk_change_log(FDFSGroupInfo *pGroup, \
|
|||
struct tm tm;
|
||||
time_t current_time;
|
||||
FDFSStorageDetail *pLastTrunk;
|
||||
char ip_str[256];
|
||||
|
||||
tracker_mem_file_lock();
|
||||
|
||||
|
|
@ -4960,14 +5032,16 @@ static int tracker_write_to_trunk_change_log(FDFSGroupInfo *pGroup, \
|
|||
{
|
||||
if (pLastTrunk == NULL)
|
||||
{
|
||||
len += sprintf(buff + len, " %s/%s => ", \
|
||||
*(pGroup->last_trunk_server_id) == '\0' ? \
|
||||
len += sprintf(buff + len, " %s/%s => ",
|
||||
*(pGroup->last_trunk_server_id) == '\0' ?
|
||||
"-" : pGroup->last_trunk_server_id, "-");
|
||||
}
|
||||
else
|
||||
{
|
||||
len += sprintf(buff + len, " %s/%s => ", \
|
||||
pLastTrunk->id, pLastTrunk->ip_addr);
|
||||
fdfs_multi_ips_to_string(&pLastTrunk->ip_addrs,
|
||||
ip_str, sizeof(ip_str));
|
||||
len += sprintf(buff + len, " %s/%s => ",
|
||||
pLastTrunk->id, ip_str);
|
||||
}
|
||||
|
||||
if (pGroup->pTrunkServer == NULL)
|
||||
|
|
@ -4976,23 +5050,25 @@ static int tracker_write_to_trunk_change_log(FDFSGroupInfo *pGroup, \
|
|||
}
|
||||
else
|
||||
{
|
||||
len += sprintf(buff + len, " %s/%s\n", \
|
||||
pGroup->pTrunkServer->id, \
|
||||
pGroup->pTrunkServer->ip_addr);
|
||||
fdfs_multi_ips_to_string(&pGroup->pTrunkServer->ip_addrs,
|
||||
ip_str, sizeof(ip_str));
|
||||
len += sprintf(buff + len, " %s/%s\n",
|
||||
pGroup->pTrunkServer->id, ip_str);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pLastTrunk == NULL)
|
||||
{
|
||||
len += sprintf(buff + len, " %s => ", \
|
||||
*(pGroup->last_trunk_server_id) == '\0' ? \
|
||||
len += sprintf(buff + len, " %s => ",
|
||||
*(pGroup->last_trunk_server_id) == '\0' ?
|
||||
"-" : pGroup->last_trunk_server_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
len += sprintf(buff + len, " %s => ", \
|
||||
pLastTrunk->ip_addr);
|
||||
fdfs_multi_ips_to_string(&pLastTrunk->ip_addrs,
|
||||
ip_str, sizeof(ip_str));
|
||||
len += sprintf(buff + len, " %s => ", ip_str);
|
||||
}
|
||||
|
||||
if (pGroup->pTrunkServer == NULL)
|
||||
|
|
@ -5001,8 +5077,9 @@ static int tracker_write_to_trunk_change_log(FDFSGroupInfo *pGroup, \
|
|||
}
|
||||
else
|
||||
{
|
||||
len += sprintf(buff + len, " %s\n", \
|
||||
pGroup->pTrunkServer->ip_addr);
|
||||
fdfs_multi_ips_to_string(&pGroup->pTrunkServer->ip_addrs,
|
||||
ip_str, sizeof(ip_str));
|
||||
len += sprintf(buff + len, " %s\n", ip_str);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -5053,14 +5130,15 @@ static int tracker_mem_do_set_trunk_server(FDFSGroupInfo *pGroup,
|
|||
FDFSStorageDetail *pTrunkServer, const bool save)
|
||||
{
|
||||
int result;
|
||||
char ip_str[256];
|
||||
|
||||
if (*(pGroup->last_trunk_server_id) != '\0' &&
|
||||
strcmp(pTrunkServer->id, pGroup->last_trunk_server_id) != 0)
|
||||
{
|
||||
if ((result=fdfs_deal_no_body_cmd_ex(
|
||||
pTrunkServer->ip_addr,
|
||||
pGroup->storage_port,
|
||||
STORAGE_PROTO_CMD_TRUNK_DELETE_BINLOG_MARKS)) != 0)
|
||||
FDFS_CURRENT_IP_ADDR(pTrunkServer),
|
||||
pGroup->storage_port,
|
||||
STORAGE_PROTO_CMD_TRUNK_DELETE_BINLOG_MARKS)) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"fdfs_deal_no_body_cmd_ex fail, result: %d",
|
||||
|
|
@ -5073,10 +5151,12 @@ static int tracker_mem_do_set_trunk_server(FDFSGroupInfo *pGroup,
|
|||
pGroup->trunk_chg_count++;
|
||||
g_trunk_server_chg_count++;
|
||||
|
||||
logInfo("file: "__FILE__", line: %d, " \
|
||||
"group: %s, trunk server set to %s(%s:%d)", __LINE__, \
|
||||
pGroup->group_name, pGroup->pTrunkServer->id, \
|
||||
pGroup->pTrunkServer->ip_addr, pGroup->storage_port);
|
||||
fdfs_multi_ips_to_string(&pGroup->pTrunkServer->ip_addrs,
|
||||
ip_str, sizeof(ip_str));
|
||||
logInfo("file: "__FILE__", line: %d, "
|
||||
"group: %s, trunk server set to %s(%s:%d)", __LINE__,
|
||||
pGroup->group_name, pGroup->pTrunkServer->id,
|
||||
ip_str, pGroup->storage_port);
|
||||
if (save)
|
||||
{
|
||||
return tracker_save_groups();
|
||||
|
|
@ -5101,8 +5181,9 @@ static int tracker_mem_find_trunk_server(FDFSGroupInfo *pGroup,
|
|||
return ENOENT;
|
||||
}
|
||||
|
||||
result = tracker_mem_get_trunk_binlog_size(pStoreServer->ip_addr,
|
||||
pGroup->storage_port, &max_file_size);
|
||||
result = tracker_mem_get_trunk_binlog_size(
|
||||
FDFS_CURRENT_IP_ADDR(pStoreServer),
|
||||
pGroup->storage_port, &max_file_size);
|
||||
if (result != 0)
|
||||
{
|
||||
return result;
|
||||
|
|
@ -5116,8 +5197,9 @@ static int tracker_mem_find_trunk_server(FDFSGroupInfo *pGroup,
|
|||
continue;
|
||||
}
|
||||
|
||||
result = tracker_mem_get_trunk_binlog_size((*ppServer)->ip_addr,
|
||||
pGroup->storage_port, &file_size);
|
||||
result = tracker_mem_get_trunk_binlog_size(
|
||||
FDFS_CURRENT_IP_ADDR(*ppServer),
|
||||
pGroup->storage_port, &file_size);
|
||||
if (result != 0)
|
||||
{
|
||||
continue;
|
||||
|
|
@ -5129,8 +5211,7 @@ static int tracker_mem_find_trunk_server(FDFSGroupInfo *pGroup,
|
|||
}
|
||||
}
|
||||
|
||||
return tracker_mem_do_set_trunk_server(pGroup, \
|
||||
pStoreServer, save);
|
||||
return tracker_mem_do_set_trunk_server(pGroup, pStoreServer, save);
|
||||
}
|
||||
|
||||
const FDFSStorageDetail *tracker_mem_set_trunk_server( \
|
||||
|
|
@ -5322,17 +5403,17 @@ int tracker_mem_active_store_server(FDFSGroupInfo *pGroup, \
|
|||
|
||||
if (g_use_storage_id)
|
||||
{
|
||||
logDebug("file: "__FILE__", line: %d, " \
|
||||
"storage server %s::%s(%s) now active", \
|
||||
__LINE__, pGroup->group_name, \
|
||||
pTargetServer->id, pTargetServer->ip_addr);
|
||||
logDebug("file: "__FILE__", line: %d, "
|
||||
"storage server %s::%s(%s) now active",
|
||||
__LINE__, pGroup->group_name,
|
||||
pTargetServer->id, FDFS_CURRENT_IP_ADDR(pTargetServer));
|
||||
}
|
||||
else
|
||||
{
|
||||
logDebug("file: "__FILE__", line: %d, " \
|
||||
"storage server %s::%s now active", \
|
||||
__LINE__, pGroup->group_name, \
|
||||
pTargetServer->ip_addr);
|
||||
logDebug("file: "__FILE__", line: %d, "
|
||||
"storage server %s::%s now active",
|
||||
__LINE__, pGroup->group_name,
|
||||
FDFS_CURRENT_IP_ADDR(pTargetServer));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -5394,17 +5475,17 @@ int tracker_mem_offline_store_server(FDFSGroupInfo *pGroup, \
|
|||
|
||||
if (g_use_storage_id)
|
||||
{
|
||||
logDebug("file: "__FILE__", line: %d, " \
|
||||
"storage server %s::%s (%s) offline", \
|
||||
__LINE__, pGroup->group_name, \
|
||||
pStorage->id, pStorage->ip_addr);
|
||||
logDebug("file: "__FILE__", line: %d, "
|
||||
"storage server %s::%s (%s) offline",
|
||||
__LINE__, pGroup->group_name,
|
||||
pStorage->id, FDFS_CURRENT_IP_ADDR(pStorage));
|
||||
}
|
||||
else
|
||||
{
|
||||
logDebug("file: "__FILE__", line: %d, " \
|
||||
"storage server %s::%s offline", \
|
||||
__LINE__, pGroup->group_name, \
|
||||
pStorage->ip_addr);
|
||||
logDebug("file: "__FILE__", line: %d, "
|
||||
"storage server %s::%s offline",
|
||||
__LINE__, pGroup->group_name,
|
||||
FDFS_CURRENT_IP_ADDR(pStorage));
|
||||
}
|
||||
|
||||
pStorage->status = FDFS_STORAGE_STATUS_OFFLINE;
|
||||
|
|
@ -5679,13 +5760,13 @@ int tracker_mem_get_storage_by_filename(const byte cmd,FDFS_DOWNLOAD_TYPE_PARAM\
|
|||
memset(&ip_addr, 0, sizeof(ip_addr));
|
||||
if (*storage_id != '\0')
|
||||
{
|
||||
cmp_res = strcmp(storage_id, ppStoreServers[0]->id);
|
||||
cmp_res = strcmp(storage_id, ppStoreServers[0]->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
ip_addr.s_addr = storage_ip;
|
||||
inet_ntop(AF_INET, &ip_addr, szIpAddr, sizeof(szIpAddr));
|
||||
cmp_res = strcmp(szIpAddr, ppStoreServers[0]->ip_addr);
|
||||
ip_addr.s_addr = storage_ip;
|
||||
inet_ntop(AF_INET, &ip_addr, szIpAddr, sizeof(szIpAddr));
|
||||
cmp_res = strcmp(szIpAddr, FDFS_CURRENT_IP_ADDR(ppStoreServers[0]));
|
||||
}
|
||||
if (cmp_res == 0)
|
||||
{
|
||||
|
|
@ -5866,17 +5947,17 @@ int tracker_mem_get_storage_by_filename(const byte cmd,FDFS_DOWNLOAD_TYPE_PARAM\
|
|||
for (ppServer=(*ppGroup)->active_servers; \
|
||||
ppServer<ppServerEnd; ppServer++)
|
||||
{
|
||||
if ((file_timestamp < current_time - \
|
||||
g_storage_sync_file_max_delay) || \
|
||||
((*ppServer)->stat.last_synced_timestamp > \
|
||||
file_timestamp) || \
|
||||
((*ppServer)->stat.last_synced_timestamp + 1 >= \
|
||||
file_timestamp && current_time - file_timestamp > \
|
||||
g_storage_sync_file_max_time) \
|
||||
|| (storage_ip == INADDR_NONE \
|
||||
&& g_groups.store_server == \
|
||||
if ((file_timestamp < current_time -
|
||||
g_storage_sync_file_max_delay) ||
|
||||
((*ppServer)->stat.last_synced_timestamp >
|
||||
file_timestamp) ||
|
||||
((*ppServer)->stat.last_synced_timestamp + 1 >=
|
||||
file_timestamp && current_time - file_timestamp >
|
||||
g_storage_sync_file_max_time)
|
||||
|| (storage_ip == INADDR_NONE
|
||||
&& g_groups.store_server ==
|
||||
FDFS_STORE_SERVER_ROUND_ROBIN)
|
||||
|| strcmp((*ppServer)->ip_addr, szIpAddr) == 0)
|
||||
|| strcmp(FDFS_CURRENT_IP_ADDR(*ppServer), szIpAddr) == 0)
|
||||
{
|
||||
ppStoreServers[(*server_count)++] = *ppServer;
|
||||
}
|
||||
|
|
@ -5953,18 +6034,19 @@ int tracker_mem_check_alive(void *arg)
|
|||
tracker_mem_deactive_store_server(*ppGroup, *ppServer);
|
||||
if (g_use_storage_id)
|
||||
{
|
||||
logInfo("file: "__FILE__", line: %d, " \
|
||||
"storage server %s(%s:%d) idle too long, " \
|
||||
"status change to offline!", __LINE__, \
|
||||
(*ppServer)->id, (*ppServer)->ip_addr, \
|
||||
logInfo("file: "__FILE__", line: %d, "
|
||||
"storage server %s(%s:%d) idle too long, "
|
||||
"status change to offline!", __LINE__,
|
||||
(*ppServer)->id, FDFS_CURRENT_IP_ADDR(*ppServer),
|
||||
(*ppGroup)->storage_port);
|
||||
}
|
||||
else
|
||||
{
|
||||
logInfo("file: "__FILE__", line: %d, " \
|
||||
"storage server %s:%d idle too long, " \
|
||||
"status change to offline!", __LINE__, \
|
||||
(*ppServer)->ip_addr, (*ppGroup)->storage_port);
|
||||
logInfo("file: "__FILE__", line: %d, "
|
||||
"storage server %s:%d idle too long, "
|
||||
"status change to offline!", __LINE__,
|
||||
FDFS_CURRENT_IP_ADDR(*ppServer),
|
||||
(*ppGroup)->storage_port);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6010,13 +6092,13 @@ int tracker_mem_check_alive(void *arg)
|
|||
g_check_active_interval;
|
||||
if (last_beat_interval > check_trunk_interval)
|
||||
{
|
||||
logInfo("file: "__FILE__", line: %d, " \
|
||||
"trunk server %s(%s:%d) offline because idle " \
|
||||
"time: %d s > threshold: %d s, should " \
|
||||
"re-select trunk server", __LINE__, \
|
||||
(*ppGroup)->pTrunkServer->id, \
|
||||
(*ppGroup)->pTrunkServer->ip_addr, \
|
||||
(*ppGroup)->storage_port, last_beat_interval, \
|
||||
logInfo("file: "__FILE__", line: %d, "
|
||||
"trunk server %s(%s:%d) offline because idle "
|
||||
"time: %d s > threshold: %d s, should "
|
||||
"re-select trunk server", __LINE__,
|
||||
(*ppGroup)->pTrunkServer->id,
|
||||
FDFS_CURRENT_IP_ADDR((*ppGroup)->pTrunkServer),
|
||||
(*ppGroup)->storage_port, last_beat_interval,
|
||||
check_trunk_interval);
|
||||
|
||||
(*ppGroup)->pTrunkServer = NULL;
|
||||
|
|
@ -6056,9 +6138,9 @@ int tracker_mem_get_storage_index(FDFSGroupInfo *pGroup, \
|
|||
}
|
||||
}
|
||||
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"get index of storage %s fail!!!", \
|
||||
__LINE__, pStorage->ip_addr);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"get index of storage %s fail!!!",
|
||||
__LINE__, FDFS_CURRENT_IP_ADDR(pStorage));
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -411,11 +411,11 @@ static int tracker_check_and_sync(struct fast_task_info *pTask, \
|
|||
if (pServer != NULL)
|
||||
{
|
||||
pDestServer->status = pServer->status;
|
||||
memcpy(pDestServer->id, pServer->id, \
|
||||
memcpy(pDestServer->id, pServer->id,
|
||||
FDFS_STORAGE_ID_MAX_SIZE);
|
||||
memcpy(pDestServer->ip_addr, pServer->ip_addr, \
|
||||
memcpy(pDestServer->ip_addr, FDFS_CURRENT_IP_ADDR(pServer),
|
||||
IP_ADDRESS_SIZE);
|
||||
int2buff(pClientInfo->pGroup->storage_port, \
|
||||
int2buff(pClientInfo->pGroup->storage_port,
|
||||
pDestServer->port);
|
||||
}
|
||||
pDestServer++;
|
||||
|
|
@ -436,11 +436,11 @@ static int tracker_check_and_sync(struct fast_task_info *pTask, \
|
|||
ppServer<ppEnd; ppServer++)
|
||||
{
|
||||
pDestServer->status = (*ppServer)->status;
|
||||
memcpy(pDestServer->id, (*ppServer)->id, \
|
||||
memcpy(pDestServer->id, (*ppServer)->id,
|
||||
FDFS_STORAGE_ID_MAX_SIZE);
|
||||
memcpy(pDestServer->ip_addr, (*ppServer)->ip_addr, \
|
||||
memcpy(pDestServer->ip_addr, FDFS_CURRENT_IP_ADDR(*ppServer),
|
||||
IP_ADDRESS_SIZE);
|
||||
int2buff(pClientInfo->pGroup->storage_port, \
|
||||
int2buff(pClientInfo->pGroup->storage_port,
|
||||
pDestServer->port);
|
||||
pDestServer++;
|
||||
}
|
||||
|
|
@ -1054,7 +1054,7 @@ static int tracker_deal_server_get_storage_status(struct fast_task_info *pTask)
|
|||
pDest = (FDFSStorageBrief *)(pTask->data + sizeof(TrackerHeader));
|
||||
memset(pDest, 0, sizeof(FDFSStorageBrief));
|
||||
strcpy(pDest->id, pStorage->id);
|
||||
strcpy(pDest->ip_addr, pStorage->ip_addr);
|
||||
strcpy(pDest->ip_addr, pStorage->ip_addrs.ips[0]);
|
||||
pDest->status = pStorage->status;
|
||||
int2buff(pGroup->storage_port, pDest->port);
|
||||
|
||||
|
|
@ -1213,6 +1213,7 @@ static int tracker_deal_fetch_storage_ids(struct fast_task_info *pTask)
|
|||
int *pCurrentCount;
|
||||
int nPkgLen;
|
||||
int start_index;
|
||||
char ip_str[256];
|
||||
|
||||
if (!g_use_storage_id)
|
||||
{
|
||||
|
|
@ -1237,7 +1238,7 @@ static int tracker_deal_fetch_storage_ids(struct fast_task_info *pTask)
|
|||
}
|
||||
|
||||
start_index = buff2int(pTask->data + sizeof(TrackerHeader));
|
||||
if (start_index < 0 || start_index >= g_storage_id_count)
|
||||
if (start_index < 0 || start_index >= g_storage_ids_by_id.count)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"client ip addr: %s, invalid offset: %d", \
|
||||
|
|
@ -1247,13 +1248,13 @@ static int tracker_deal_fetch_storage_ids(struct fast_task_info *pTask)
|
|||
}
|
||||
|
||||
p = pTask->data + sizeof(TrackerHeader);
|
||||
int2buff(g_storage_id_count, p);
|
||||
int2buff(g_storage_ids_by_id.count, p);
|
||||
p += sizeof(int);
|
||||
pCurrentCount = (int *)p;
|
||||
p += sizeof(int);
|
||||
|
||||
pIdsStart = g_storage_ids_by_ip + start_index;
|
||||
pIdsEnd = g_storage_ids_by_ip + g_storage_id_count;
|
||||
pIdsStart = g_storage_ids_by_id.ids + start_index;
|
||||
pIdsEnd = g_storage_ids_by_id.ids + g_storage_ids_by_id.count;
|
||||
for (pIdInfo = pIdsStart; pIdInfo < pIdsEnd; pIdInfo++)
|
||||
{
|
||||
char szPortPart[16];
|
||||
|
|
@ -1270,8 +1271,11 @@ static int tracker_deal_fetch_storage_ids(struct fast_task_info *pTask)
|
|||
{
|
||||
*szPortPart = '\0';
|
||||
}
|
||||
|
||||
fdfs_multi_ips_to_string(&pIdInfo->ip_addrs,
|
||||
ip_str, sizeof(ip_str));
|
||||
p += sprintf(p, "%s %s %s%s\n", pIdInfo->id,
|
||||
pIdInfo->group_name, pIdInfo->ip_addr, szPortPart);
|
||||
pIdInfo->group_name, ip_str, szPortPart);
|
||||
}
|
||||
|
||||
int2buff((int)(pIdInfo - pIdsStart), (char *)pCurrentCount);
|
||||
|
|
@ -1470,8 +1474,8 @@ static int tracker_deal_storage_join(struct fast_task_info *pTask)
|
|||
tracker_ip, IP_ADDRESS_SIZE);
|
||||
insert_into_local_host_ip(tracker_ip);
|
||||
|
||||
result = tracker_mem_add_group_and_storage(pClientInfo, \
|
||||
pTask->client_ip, &joinBody, true);
|
||||
result = tracker_mem_add_group_and_storage(pClientInfo,
|
||||
pTask->client_ip, &joinBody, true);
|
||||
if (result != 0)
|
||||
{
|
||||
pTask->length = sizeof(TrackerHeader);
|
||||
|
|
@ -2281,7 +2285,7 @@ static int tracker_deal_server_list_group_storages(struct fast_task_info *pTask)
|
|||
pStorageStat = &((*ppServer)->stat);
|
||||
pDest->status = (*ppServer)->status;
|
||||
strcpy(pDest->id, (*ppServer)->id);
|
||||
strcpy(pDest->ip_addr, (*ppServer)->ip_addr);
|
||||
strcpy(pDest->ip_addr, FDFS_CURRENT_IP_ADDR(*ppServer));
|
||||
if ((*ppServer)->psync_src_server != NULL)
|
||||
{
|
||||
strcpy(pDest->src_id, \
|
||||
|
|
@ -2487,7 +2491,8 @@ static int tracker_deal_service_query_fetch_update( \
|
|||
p = pTask->data + sizeof(TrackerHeader);
|
||||
memcpy(p, pGroup->group_name, FDFS_GROUP_NAME_MAX_LEN);
|
||||
p += FDFS_GROUP_NAME_MAX_LEN;
|
||||
memcpy(p, ppStoreServers[0]->ip_addr, IP_ADDRESS_SIZE-1);
|
||||
strcpy(p, fdfs_get_ipaddr_by_client_ip(
|
||||
&ppStoreServers[0]->ip_addrs, pTask->client_ip));
|
||||
p += IP_ADDRESS_SIZE - 1;
|
||||
long2buff(pGroup->storage_port, p);
|
||||
p += FDFS_PROTO_PKG_LEN_SIZE;
|
||||
|
|
@ -2498,8 +2503,8 @@ static int tracker_deal_service_query_fetch_update( \
|
|||
for (ppServer=ppStoreServers+1; ppServer<ppServerEnd; \
|
||||
ppServer++)
|
||||
{
|
||||
memcpy(p, (*ppServer)->ip_addr, \
|
||||
IP_ADDRESS_SIZE - 1);
|
||||
strcpy(p, fdfs_get_ipaddr_by_client_ip(
|
||||
&(*ppServer)->ip_addrs, pTask->client_ip));
|
||||
p += IP_ADDRESS_SIZE - 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -2875,7 +2880,8 @@ static int tracker_deal_service_query_storage( \
|
|||
for (ppServer=pStoreGroup->active_servers; ppServer<ppEnd; \
|
||||
ppServer++)
|
||||
{
|
||||
memcpy(p, (*ppServer)->ip_addr, IP_ADDRESS_SIZE - 1);
|
||||
strcpy(p, fdfs_get_ipaddr_by_client_ip(
|
||||
&(*ppServer)->ip_addrs, pTask->client_ip));
|
||||
p += IP_ADDRESS_SIZE - 1;
|
||||
|
||||
long2buff(pStoreGroup->storage_port, p);
|
||||
|
|
@ -2884,7 +2890,8 @@ static int tracker_deal_service_query_storage( \
|
|||
}
|
||||
else
|
||||
{
|
||||
memcpy(p, pStorageServer->ip_addr, IP_ADDRESS_SIZE - 1);
|
||||
strcpy(p, fdfs_get_ipaddr_by_client_ip(
|
||||
&pStorageServer->ip_addrs, pTask->client_ip));
|
||||
p += IP_ADDRESS_SIZE - 1;
|
||||
|
||||
long2buff(pStoreGroup->storage_port, p);
|
||||
|
|
@ -2892,7 +2899,6 @@ static int tracker_deal_service_query_storage( \
|
|||
}
|
||||
|
||||
*p++ = (char)write_path_index;
|
||||
|
||||
pTask->length = p - pTask->data;
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -275,9 +275,13 @@ typedef struct
|
|||
typedef struct StructFDFSMultiIP
|
||||
{
|
||||
int count;
|
||||
int index;
|
||||
char ips[FDFS_MULTI_IP_MAX_COUNT][IP_ADDRESS_SIZE];
|
||||
} FDFSMultiIP;
|
||||
|
||||
#define FDFS_CURRENT_IP_ADDR(pServer) \
|
||||
(pServer)->ip_addrs.ips[(pServer)->ip_addrs.index]
|
||||
|
||||
typedef struct StructFDFSStorageDetail
|
||||
{
|
||||
char status;
|
||||
|
|
|
|||
Loading…
Reference in New Issue