Its in progress right now ....

Approach

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, 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 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.

 

Request Message (Down)DescriptionResponse Message (up)Description
MessageBytesCollector

Collect Message bytes

  1. read message header, find payload size
  2. read payload
  3. pass byte buffer to next handler
MessageSenderSend the message to the client
MetadataCollector
  1. Extract metadata from byte buffer
  2. Set metadata in context
  3. pass byte buffer to next handler
  
MessageDecoder

Construct Message.

  1. Look apiId and decode message
  2. create Request, ApiInvoker
  3. And pass to next handler
  4. We will have multiple decoder(thrift)
ResponseEncoder

Serialize the response if there is no Exception

We will have multiple encoders(thrift)

DecorateKeyValue

Update key value based on metadata

  1. if metadata indicates it is JSON string then
    convert that string to pdx
  2. pass to next handler

 

ResponseMetadataHandleradd any metadata in response
  DecorateKeyValue

Decorate key value based on metadata

  1. if metadata indicates it is expecting JSON string then
    convert pdx to JSON
  2. pass to next handler
  ExceptionHandlerif Exception is set in context, then generate Exception Message
AuthenticateHandler
  1. verify whether connection is authenticated or not
  2. if fail then generate AuthRequired error
ResponseAuthorizationHandler

authorize response

  1. if fail then set generateAuthFailedException

 

RequestAuthorizationHandler

1. Request object will generate AuthContext

2. And then call authCallback

3. if fail then generate AuthFailed error

StatsHandlerUpdate the stats based on response or error code
StatsHandlerUpdate the geode stats for requestResponseHandlerConstruct 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

 

Handler

 

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.

 

  • No labels