[ 
https://issues.apache.org/jira/browse/KAFKA-1316?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14004009#comment-14004009
 ] 

Jay Kreps commented on KAFKA-1316:
----------------------------------

I started on this and I think I have a design that at least works for the 
producer, let's think if it would also work for the consumer.

The plan is that Sender remains, but most of the logic is moved into a new 
class Client which will be shared by the producer, consumer, and any additional 
clients (admin, for example).

The Client class will incapsulate the connection state and the management of 
metadata. The client will exposes two methods:
{noformat}
class Client {
  /* Initiate a connection to the given node (if one doesn't already exist). 
Return true if we already have a ready connection. */
  boolean ready(Node node, long now);

  /* Send new requests and return any completed requests */
  List<ClientResponse> poll(List<ClientRequest> requests, long ms);
}
{noformat}

The poll request takes a list of requests for ready connections and attempts to 
send them. It returns any completed requests. The responses returned will not 
generally be for the requests being sent but for previous requests.

ClientRequest is just a renaming and generalization of InFlightRequest. 
ClientResponse is a new class that will reference the original ClientRequest as 
well as maintain the response information received (which we currently handle 
inline in Sender).

The user of this class (e.g. Sender) has to use the ready() method to ensure it 
only initiates requests to ready connections.

What needs to be thought through is whether these APIs suffice for the consumer.

> Refactor Sender
> ---------------
>
>                 Key: KAFKA-1316
>                 URL: https://issues.apache.org/jira/browse/KAFKA-1316
>             Project: Kafka
>          Issue Type: Sub-task
>          Components: producer 
>            Reporter: Jay Kreps
>            Assignee: Jay Kreps
>
> Currently most of the logic of the producer I/O thread is in Sender.java.
> However we will need to do a fair number of similar things in the new 
> consumer. Specifically:
>  - Track in-flight requests
>  - Fetch metadata
>  - Manage connection lifecycle
> It may be possible to refactor some of this into a helper class that can be 
> shared with the consumer. This will require some detailed thought.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to