...
We will have layered approach for handling the client request message and server response message. Each layer will do its work and pass the message to next layer. Currently, we are planning to add this with Geode server, but eventually, it this architecture should work with Netty server/ other.
Layering
Multiple layers will process the Client request message. The following table contains the handlers for processing request, handler to execute the api, and handlers to send a response back to the client. Each handler will implement the Message Handler interface and will be responsible for its task. . The column-1 represents(top-to-bottom) the inbound handlers to process the incoming request. The column-3(bottom-to-top) represents the outbound handler to send the response back to the client.
Gliffy Diagram
Request Message (Down) | Description | Response Message (up) | Description |
---|---|---|---|
MessageBytesCollector | Collect Message bytes
| MessageSender | Send the message to the client |
MetadataCollector |
| ||
MessageDecoder | Construct Message.
| ResponseEncoder | Serialize the response if there is no Exception We will have multiple encoders(thrift) |
DecorateKeyValue | Update key value based on metadata
| ResponseMetadataHandler | add any metadata in response |
DecorateKeyValue | Decorate key value based on metadata
| ||
ExceptionHandler | if Exception is set in context, then generate Exception Message | ||
AuthenticateHandler |
| ResponseAuthorizationHandler | authorize response
|
RequestAuthorizationHandler | 1. Request object will generate AuthContext 2. And Call then call authCallback 3. if fail then generate AuthFailed error | StatsHandler | Update the stats based on response or error code |
StatsHandler | Update the geode stats for request | ResponseHandler | Construct Response Message from request |
ApiExecutionHandler (execute the api); if there is no error then call Request.ApiInvoker() for a synchronous request or call Request.AsyncApiInvoker for async Request |
Class Hierarchy
Gliffy Diagram | ||||
---|---|---|---|---|
|
Handler
Any layer in server architecture needs to implement Handler interface. The layer needs to make sure if there is any exception generated by the previous layer before doing its own work. Apart from that, it needs to make sure it is stateless.
Context
For each client request, we will create the Context object. This will hold all info about the request, its response, and the connection.
Message
The message interface will be implemented by request, response, and exception.
Request
The Request class will implement the Message interface. Then we will have specific Request class for each api. Those classes will read request buffer and will create specific request class.
Response
The Response class will implement the Message interface. Then we will have specific Response class for each api. Those classes will write a response to wire accordingly.
Exception
The exception class will implement the Message interface. The Exception class will have error code and message. That will be an error response to a api invocation.
SyncApiInvoker
This class will have the ability to execute the particular api.
AsyncApiInvoker
This class will have the ability to execute the particular api asynchronously.
ResponseSender
This class holds the context to write the response asynchronously on a wire. The function execution framework will hold response sender to write partial back to a client. Similarly, the Geode queue framework will hold response sender to notify events to a client.
Connection
This class will hold the socket to read the request and write the response.