tracker relationship refine
parent
77b1207fdd
commit
c7f02064f9
|
|
@ -4049,10 +4049,6 @@ static int tracker_mem_check_add_tracker_servers(FDFSStorageJoinBody *pJoinBody)
|
||||||
return ENOSPC;
|
return ENOSPC;
|
||||||
}
|
}
|
||||||
|
|
||||||
logInfo("file: "__FILE__", line: %d, " \
|
|
||||||
"add %d tracker servers", \
|
|
||||||
__LINE__, add_count);
|
|
||||||
|
|
||||||
bytes = sizeof(ConnectionInfo) * (g_tracker_servers.server_count \
|
bytes = sizeof(ConnectionInfo) * (g_tracker_servers.server_count \
|
||||||
+ add_count);
|
+ add_count);
|
||||||
new_servers = (ConnectionInfo *)malloc(bytes);
|
new_servers = (ConnectionInfo *)malloc(bytes);
|
||||||
|
|
@ -4071,8 +4067,8 @@ static int tracker_mem_check_add_tracker_servers(FDFSStorageJoinBody *pJoinBody)
|
||||||
for (pJoinTracker=pJoinBody->tracker_servers; \
|
for (pJoinTracker=pJoinBody->tracker_servers; \
|
||||||
pJoinTracker<pJoinEnd; pJoinTracker++)
|
pJoinTracker<pJoinEnd; pJoinTracker++)
|
||||||
{
|
{
|
||||||
for (pLocalTracker=g_tracker_servers.servers; \
|
for (pLocalTracker=new_servers; \
|
||||||
pLocalTracker<pLocalEnd; pLocalTracker++)
|
pLocalTracker<pNewServer; pLocalTracker++)
|
||||||
{
|
{
|
||||||
if (pJoinTracker->port == pLocalTracker->port && \
|
if (pJoinTracker->port == pLocalTracker->port && \
|
||||||
strcmp(pJoinTracker->ip_addr, \
|
strcmp(pJoinTracker->ip_addr, \
|
||||||
|
|
@ -4082,7 +4078,7 @@ static int tracker_mem_check_add_tracker_servers(FDFSStorageJoinBody *pJoinBody)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pLocalTracker == pLocalEnd)
|
if (pLocalTracker == pNewServer)
|
||||||
{
|
{
|
||||||
memcpy(pNewServer, pJoinTracker, \
|
memcpy(pNewServer, pJoinTracker, \
|
||||||
sizeof(ConnectionInfo));
|
sizeof(ConnectionInfo));
|
||||||
|
|
@ -4091,10 +4087,15 @@ static int tracker_mem_check_add_tracker_servers(FDFSStorageJoinBody *pJoinBody)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_count = pNewServer - new_servers;
|
||||||
g_last_tracker_servers = g_tracker_servers.servers;
|
g_last_tracker_servers = g_tracker_servers.servers;
|
||||||
g_tracker_servers.servers = new_servers;
|
g_tracker_servers.servers = new_servers;
|
||||||
g_tracker_servers.server_count += add_count;
|
g_tracker_servers.server_count += add_count;
|
||||||
|
|
||||||
|
logInfo("file: "__FILE__", line: %d, " \
|
||||||
|
"add %d tracker servers, total tracker servers: %d", \
|
||||||
|
__LINE__, add_count, g_tracker_servers.server_count);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,11 +52,11 @@ static int fdfs_ping_leader(ConnectionInfo *pTrackerServer)
|
||||||
sizeof(header), g_fdfs_network_timeout);
|
sizeof(header), g_fdfs_network_timeout);
|
||||||
if(result != 0)
|
if(result != 0)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, " \
|
logError("file: "__FILE__", line: %d, "
|
||||||
"tracker server ip: %s, send data fail, " \
|
"tracker server %s:%d, send data fail, "
|
||||||
"errno: %d, error info: %s", \
|
"errno: %d, error info: %s",
|
||||||
__LINE__, pTrackerServer->ip_addr, \
|
__LINE__, pTrackerServer->ip_addr,
|
||||||
result, STRERROR(result));
|
pTrackerServer->port, result, STRERROR(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -65,8 +65,9 @@ static int fdfs_ping_leader(ConnectionInfo *pTrackerServer)
|
||||||
sizeof(in_buff), &in_bytes)) != 0)
|
sizeof(in_buff), &in_bytes)) != 0)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"fdfs_recv_response fail, result: %d",
|
"fdfs_recv_response from %s:%d fail, result: %d",
|
||||||
__LINE__, result);
|
__LINE__, pTrackerServer->ip_addr,
|
||||||
|
pTrackerServer->port, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,10 +78,10 @@ static int fdfs_ping_leader(ConnectionInfo *pTrackerServer)
|
||||||
else if (in_bytes % (FDFS_GROUP_NAME_MAX_LEN + \
|
else if (in_bytes % (FDFS_GROUP_NAME_MAX_LEN + \
|
||||||
FDFS_STORAGE_ID_MAX_SIZE) != 0)
|
FDFS_STORAGE_ID_MAX_SIZE) != 0)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, " \
|
logError("file: "__FILE__", line: %d, "
|
||||||
"tracker server ip: %s, invalid body length: " \
|
"tracker server %s:%d, invalid body length: "
|
||||||
"%"PRId64, __LINE__, \
|
"%"PRId64, __LINE__, pTrackerServer->ip_addr,
|
||||||
pTrackerServer->ip_addr, in_bytes);
|
pTrackerServer->port, in_bytes);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -290,8 +291,9 @@ static int do_notify_leader_changed(ConnectionInfo *pTrackerServer, \
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"fdfs_recv_response fail, result: %d",
|
"fdfs_recv_response from tracker server %s:%d fail, "
|
||||||
__LINE__, result);
|
"result: %d", __LINE__, pTrackerServer->ip_addr,
|
||||||
|
pTrackerServer->port, result);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -517,6 +519,7 @@ static void *relationship_thread_entrance(void* arg)
|
||||||
if (fail_count >= 3)
|
if (fail_count >= 3)
|
||||||
{
|
{
|
||||||
g_tracker_servers.leader_index = -1;
|
g_tracker_servers.leader_index = -1;
|
||||||
|
fail_count = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue