Skip to content
Sergey Klyaus edited this page Dec 16, 2012 · 5 revisions

JSON-TS is a protocol for communication between server and agent. It uses JSON for message representation, and runs over raw TCP (no HTTP is needed).

Message format

Each message is obviously represented in JSON format, and has one mandatory field: id. For commands it is sequence number of invoked command.

There are three types of messages:

  • Commands:
{   
   "id": ...  
   "cmd": name of the command  
   "msg": { "arg1": { value of arg1 },  
            "arg2": { value of arg2 } ... }  
  } 
  • Responses:
{   
   "id": ...   
   "response": { "arg1": { value of arg1 },   
                "arg2": { value of arg2 } ... }   
} 
  • Errors:
{ 
   "id": ...
   "error": "Error message"
   "code": ERROR_CODE (integer)
} 

Error codes:

code agent_errcode TSClient exception comment
100 AE_COMMAND_NOT_FOUND TSClientCommandNotFound Name of command in "cmd" is invalid
101 AE_MESSAGE_FORMAT TSClientMessageFormatError Invalid format of "msg" field
102 AE_INVALID_DATA TSClientInvalidData Invalid data provided in message (internal checks)
103 AE_INVALID_STATE TSClientInvalidState Invalid state of object that used in agent operation
200 AE_INTERNAL_ERROR TSClientError Internal error occured while processing message

All messages are null-terminated!

Structure of clients

Because of nature of multi-agent environment of vPerfGenerator, traditional RPC protocols are not fit, because they can send requests only in one direction. In JSON-TS, every node may send requests and respond to them, but there is small difference in server and agent behaviour: server listens on socket and accepts connection from everybody, while agent only connects to one dedicated server.

Here is dataflow diagram for JSON-TS client/server/agent: JSON-TS

Command invocation is synchronious, so it will block invoking thread until response or error message arrive, while incoming commands, response and error to invoked commands are processed in separate threads - receiver (that reads it from socket) and processor (that notifies invoking thread or executes incoming command). Also, processor on server will spawn separate actor for each processing message to avoid deadlock between agent and server.

Loader protocol

Clone this wiki locally