properly deal with clients that talked to another campaign server before
A campaign server now tells all clients a unique run ID (the UNIX timestamp when it was started). This allows us to ignore results from "old" clients that talked to another server before, and to tell them to die. git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1677 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
@ -15,6 +15,7 @@ JobClient::JobClient(const std::string& server, int port)
|
||||
exit(1);
|
||||
}
|
||||
srand(time(NULL)); // needed for random backoff (see connectToServer)
|
||||
m_server_runid = 0; // server accepts this for virgin clients
|
||||
}
|
||||
|
||||
bool JobClient::connectToServer()
|
||||
@ -91,11 +92,15 @@ FailControlMessage_Command JobClient::tryToGetExperimentData(ExperimentData& exp
|
||||
FailControlMessage ctrlmsg;
|
||||
ctrlmsg.set_command(FailControlMessage_Command_NEED_WORK);
|
||||
ctrlmsg.set_build_id(42);
|
||||
ctrlmsg.set_run_id(m_server_runid);
|
||||
|
||||
SocketComm::sendMsg(m_sockfd, ctrlmsg);
|
||||
ctrlmsg.Clear();
|
||||
SocketComm::rcvMsg(m_sockfd, ctrlmsg);
|
||||
|
||||
// now we know the current run ID
|
||||
m_server_runid = ctrlmsg.run_id();
|
||||
|
||||
switch (ctrlmsg.command()) {
|
||||
case FailControlMessage_Command_WORK_FOLLOWS:
|
||||
SocketComm::rcvMsg(m_sockfd, exp.getMessage());
|
||||
@ -119,6 +124,7 @@ bool JobClient::sendResult(ExperimentData& result)
|
||||
FailControlMessage ctrlmsg;
|
||||
ctrlmsg.set_command(FailControlMessage_Command_RESULT_FOLLOWS);
|
||||
ctrlmsg.set_build_id(42);
|
||||
ctrlmsg.set_run_id(m_server_runid);
|
||||
ctrlmsg.set_workloadid(result.getWorkloadID());
|
||||
cout << "[Client] Sending back result [" << std::dec << result.getWorkloadID() << "]..." << endl;
|
||||
// TODO: Log-level?
|
||||
|
||||
@ -26,6 +26,7 @@ private:
|
||||
int m_server_port;
|
||||
struct hostent* m_server_ent;
|
||||
int m_sockfd;
|
||||
uint64_t m_server_runid;
|
||||
|
||||
bool connectToServer();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user