Selector — Selectable on Socket Channels (from Java’s New IO API)

Selector is the one and only Selectable that uses Java’s selectable channels for stream-oriented connecting sockets (i.e. Java’s java.nio.channels.SocketChannel).

Selector is used by Kafka services to create a NetworkClient.

Selector.png
Figure 1. Selector is Created for Kafka Services For NetworkClient
Tip

Enable ALL logging levels for org.apache.kafka.common.network.Selector logger to see what happens inside.

Add the following line to config/log4j.properties:

log4j.logger.org.apache.kafka.common.network.Selector=ALL

Refer to Logging.

connect Method

void connect(
  String id,
  InetSocketAddress address,
  int sendBufferSize,
  int receiveBufferSize) throws IOException
Note
connect is a part of Selectable contract that NetworkClient uses when requested to establish a connection to a broker.

connect…​FIXME

addToCompletedReceives Internal Method

void addToCompletedReceives()
void addToCompletedReceives(
  KafkaChannel channel,
  Deque<NetworkReceive> stagedDeque)

addToCompletedReceives…​FIXME

Note
addToCompletedReceives is used exclusively when Selector is requested to poll.

poll Method

void poll(
  long timeout)
Note
poll is part of the Selectable Contract to…​FIXME.

poll…​FIXME

register Method

void register(
  String id,
  SocketChannel socketChannel)

register…​FIXME

Note
register is used when Processor is requested to configureNewConnections.

registerChannel Method

SelectionKey registerChannel(
  String id,
  SocketChannel socketChannel,
  int interestedOps)

registerChannel…​FIXME

Note
registerChannel is used when Selector is requested to connect and register.

buildAndAttachKafkaChannel Internal Method

KafkaChannel buildAndAttachKafkaChannel(
  SocketChannel socketChannel,
  String id,
  SelectionKey key)

buildAndAttachKafkaChannel…​FIXME

Note
buildAndAttachKafkaChannel is used when Selector is requested to registerChannel

results matching ""

    No results matching ""