AbstractCoordinator Contract

AbstractCoordinator is the base of Coordinators that FIXME.

Note
AbstractCoordinator is a Java abstract class and cannot be created directly. It is created indirectly for the concrete Coordinators.
Note
ConsumerCoordinator is the one and only known implementation of the AbstractCoordinator Contract in Apache Kafka’s Consumer API.
Table 1. AbstractCoordinator Contract (Abstract Methods Only)
Method Description

metadata

List<ProtocolMetadata> metadata()

Used exclusively when AbstractCoordinator is requested to sendJoinGroupRequest

onJoinComplete

void onJoinComplete(
  int generation,
  String memberId,
  String protocol,
  ByteBuffer memberAssignment)

Used exclusively when AbstractCoordinator is requested to joinGroupIfNeeded (and the request to initiateJoinGroup succeeded)

onJoinPrepare

void onJoinPrepare(
  int generation,
  String memberId)

Used exclusively when AbstractCoordinator is requested to joinGroupIfNeeded (and the needsJoinPrepare flag is on)

performAssignment

Map<String, ByteBuffer> performAssignment(
  String leaderId,
  String protocol,
  Map<String, ByteBuffer> allMemberMetadata)

Used exclusively when AbstractCoordinator is requested to onJoinLeader

protocolType

String protocolType()

Used exclusively when AbstractCoordinator is requested to sendJoinGroupRequest

Table 2. AbstractCoordinator’s Internal Properties (e.g. Registries, Counters and Flags)
Name Description

coordinator

Group Coordinator (as a Kafka Node)

Initialized when FindCoordinatorResponseHandler is requested to onSuccess

findCoordinatorFuture

RequestFuture<Void> for sendFindCoordinatorRequest when lookupCoordinator

Reset in clearFindCoordinatorFuture

Used in lookupCoordinator and when HeartbeatThread is requested to run

generation

Defaults to NO_GENERATION

heartbeatThread

HeartbeatThread

joinFuture

RequestFuture<ByteBuffer> for sendJoinGroupRequest when initiateJoinGroup

Reset in resetJoinGroupFuture

Used in rejoinNeededOrPending and initiateJoinGroup

needsJoinPrepare

Flag to control whether to execute onJoinPrepare while performing joinGroupIfNeeded

rejoinNeeded

boolean rejoinNeeded

Flag to control whether to rejoinNeededOrPending. Enabled (true) by default.

Turned off (false) when the joinFuture completed successfully in initiateJoinGroup

Turned on (true) in resetGeneration and requestRejoin

state

Defaults to UNJOINED

Tip

Enable WARN, INFO, or DEBUG logging level for org.apache.kafka.clients.consumer.internals.AbstractCoordinator logger to see what happens inside.

Add the following line to log4j.properties:

log4j.logger.org.apache.kafka.clients.consumer.internals.AbstractCoordinator=DEBUG

Refer to Logging.

Creating AbstractCoordinator Instance

AbstractCoordinator takes the following when created:

  • LogContext

  • ConsumerNetworkClient

  • Group ID

  • rebalanceTimeoutMs

  • sessionTimeoutMs

  • heartbeatIntervalMs (or simply a Heartbeat instance)

  • Metrics

  • Metric group prefix

  • Time

  • retryBackoffMs

  • leaveGroupOnClose flag

Note
AbstractCoordinator is a Java abstract class and cannot be created directly. It is created indirectly for the concrete Coordinators.

joinGroupIfNeeded Method

boolean joinGroupIfNeeded(final Timer timer)

joinGroupIfNeeded…​FIXME

Note
joinGroupIfNeeded is used exclusively when AbstractCoordinator is requested to ensureActiveGroup.

initiateJoinGroup Internal Method

RequestFuture<ByteBuffer> initiateJoinGroup()

initiateJoinGroup…​FIXME

Note
initiateJoinGroup is used exclusively when AbstractCoordinator is requested to joinGroupIfNeeded.

ensureActiveGroup Method

boolean ensureActiveGroup(final Timer timer)

ensureActiveGroup…​FIXME

Note
ensureActiveGroup is used when ConsumerCoordinator is requested to poll for coordinator events.

lookupCoordinator Method

RequestFuture<Void> lookupCoordinator()

lookupCoordinator…​FIXME

Note

lookupCoordinator is used when:

ensureCoordinatorReady Method

boolean ensureCoordinatorReady(final Timer timer)

ensureCoordinatorReady…​FIXME

Note

ensureCoordinatorReady is used when:

sendJoinGroupRequest Method

RequestFuture<ByteBuffer> sendJoinGroupRequest()

sendJoinGroupRequest…​FIXME

Note
sendJoinGroupRequest is used exclusively when AbstractCoordinator is requested to initiateJoinGroup.

sendSyncGroupRequest Internal Method

RequestFuture<ByteBuffer> sendSyncGroupRequest(
  SyncGroupRequest.Builder requestBuilder)

sendSyncGroupRequest…​FIXME

Note
sendSyncGroupRequest is used when…​FIXME

Sending FindCoordinatorRequest (to Kafka Broker) — sendFindCoordinatorRequest Internal Method

RequestFuture<Void> sendFindCoordinatorRequest(Node node)

sendFindCoordinatorRequest prints out the following DEBUG message to the logs:

Sending FindCoordinator request to broker [node]

sendFindCoordinatorRequest creates a new FindCoordinatorRequest with GROUP type and the groupId.

In the end, sendFindCoordinatorRequest requests the ConsumerNetworkClient to send the FindCoordinatorRequest and convert the request future using a new FindCoordinatorResponseHandler.

Note
sendFindCoordinatorRequest is used exclusively when AbstractCoordinator is requested to lookupCoordinator.

maybeLeaveGroup Method

void maybeLeaveGroup()

maybeLeaveGroup…​FIXME

Note
maybeLeaveGroup is used when…​FIXME

sendHeartbeatRequest Method

RequestFuture<Void> sendHeartbeatRequest()

sendHeartbeatRequest…​FIXME

Note
sendHeartbeatRequest is used when…​FIXME

onJoinLeader Internal Method

RequestFuture<ByteBuffer> onJoinLeader(JoinGroupResponse joinResponse)

onJoinLeader…​FIXME

Note
onJoinLeader is used when…​FIXME

resetJoinGroupFuture Internal Method

void resetJoinGroupFuture()

resetJoinGroupFuture simply resets the joinFuture internal registry (i.e. sets it to null).

Note
resetJoinGroupFuture is used exclusively when AbstractCoordinator is requested to joinGroupIfNeeded.

clearFindCoordinatorFuture Internal Method

void clearFindCoordinatorFuture()

clearFindCoordinatorFuture simply resets the findCoordinatorFuture internal registry (i.e. sets it to null).

Note
clearFindCoordinatorFuture is used exclusively when FindCoordinatorResponseHandler is requested to onSuccess and onFailure.

rejoinNeededOrPending Internal Method

boolean rejoinNeededOrPending()

rejoinNeededOrPending is positive (true) when rejoinNeeded and joinFuture is initialized (i.e. not null).

Note

rejoinNeededOrPending is used when:

pollHeartbeat Method

void pollHeartbeat(long now)

pollHeartbeat…​FIXME

Note
pollHeartbeat is used exclusively when ConsumerCoordinator is requested to poll for Coordinator events.

startHeartbeatThreadIfNeeded Internal Method

void startHeartbeatThreadIfNeeded()

startHeartbeatThreadIfNeeded…​FIXME

Note
startHeartbeatThreadIfNeeded is used exclusively when AbstractCoordinator is requested to ensureActiveGroup.

needRejoin Method

boolean needRejoin()

needRejoin simply returns the rejoinNeeded flag.

Note
needRejoin is used when…​FIXME

requestRejoin Method

void requestRejoin()

requestRejoin simply turns the rejoinNeeded flag on.

Note

requestRejoin is used when:

  • HeartbeatResponseHandler is requested to handle a response that the consumer group is rebalancing

  • SyncGroupResponseHandler is requested to handle a response with an error

resetGeneration Method

void resetGeneration()

resetGeneration simply resets the following internal registries:

Note

resetGeneration is used when:

coordinatorUnknown Method

boolean coordinatorUnknown()

coordinatorUnknown…​FIXME

Note
coordinatorUnknown is used when…​FIXME

results matching ""

    No results matching ""